Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. IConfig.cpp
  5. Abstract:
  6. Remove iconfig.exe from \\HKLM\Software\Microsoft\Windows\CurrentVersion\Run.
  7. Delete iconfig.exe and iconfig.dll.
  8. Notes:
  9. This is an app specific shim.
  10. History:
  11. 09/17/2001 astritz Created
  12. --*/
  13. #include "precomp.h"
  14. IMPLEMENT_SHIM_BEGIN(IConfig)
  15. #include "ShimHookMacro.h"
  16. APIHOOK_ENUM_BEGIN
  17. // Not hooking an API
  18. APIHOOK_ENUM_END
  19. /*++
  20. Notify Function
  21. --*/
  22. BOOL
  23. NOTIFY_FUNCTION(DWORD fdwReason)
  24. {
  25. HKEY hKey = 0;
  26. WCHAR wszFileName[MAX_PATH];
  27. DWORD dwLen = 0;
  28. if( SHIM_STATIC_DLLS_INITIALIZED == fdwReason ) {
  29. if( RegOpenKeyExW(
  30. HKEY_LOCAL_MACHINE,
  31. L"Software\\Microsoft\\Windows\\CurrentVersion\\Run",
  32. 0,
  33. KEY_ALL_ACCESS,
  34. &hKey
  35. ) != ERROR_SUCCESS ) {
  36. goto EXIT_PROCESS;
  37. }
  38. DPFN(eDbgLevelError, "Removing ICONFIG.EXE from \\HKLM\\Software\\Microsoft\\Windows\\CurrentVerion\\Run");
  39. RegDeleteValueW(hKey, L"ICONFIG");
  40. RegCloseKey(hKey);
  41. dwLen = GetModuleFileNameW(NULL, wszFileName, ARRAYSIZE(wszFileName));
  42. if( 0 == dwLen || ARRAYSIZE(wszFileName) == dwLen ) {
  43. goto EXIT_PROCESS;
  44. }
  45. DPFN(eDbgLevelError, "Deleting %S.", wszFileName);
  46. MoveFileExW(wszFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
  47. if( dwLen < 3 ) {
  48. goto EXIT_PROCESS;
  49. }
  50. StringCchCopyW(&wszFileName[dwLen-3], ARRAYSIZE(wszFileName)-dwLen+3, L"DLL");
  51. DPFN(eDbgLevelError, "Deleting %S.", wszFileName);
  52. MoveFileExW(wszFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
  53. EXIT_PROCESS:
  54. ExitProcess(0);
  55. }
  56. return TRUE;
  57. }
  58. HOOK_BEGIN
  59. CALL_NOTIFY_FUNCTION
  60. HOOK_END
  61. IMPLEMENT_SHIM_END