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.

114 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. MindSpring4.cpp
  5. Abstract:
  6. Shim to register the files using regedt32.exe
  7. The app creates *.dcu files during installation but fails to register them
  8. thus leading to no entires under the HKLM/Software/MindSpring Enterprise/MID4 subkey.
  9. This causes the the app to AV when run after successfull installation.
  10. Notes:
  11. This is an app specific shim.
  12. History:
  13. 01/29/2001 a-leelat Created
  14. 03/13/2001 robkenny Converted to CString
  15. --*/
  16. #include "precomp.h"
  17. IMPLEMENT_SHIM_BEGIN(MindSpring4)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(CopyFileA)
  21. APIHOOK_ENUM_END
  22. BOOL APIHOOK(CopyFileA)(
  23. LPCSTR lpExistingFileName, // name of an existing file
  24. LPCSTR lpNewFileName, // name of new file
  25. BOOL bFailIfExists // operation if file exists
  26. )
  27. {
  28. BOOL bRet = ORIGINAL_API(CopyFileA)(
  29. lpExistingFileName,
  30. lpNewFileName,
  31. bFailIfExists);
  32. if ( bRet != 0 )
  33. {
  34. CSTRING_TRY
  35. {
  36. CString csExisting(lpExistingFileName);
  37. CString csExt;
  38. csExisting.SplitPath(NULL, NULL, NULL, &csExt);
  39. //Check if the file name has .dcu in it
  40. //if so run regedit on it
  41. if (csExt.CompareNoCase(L"dcu") == 0)
  42. {
  43. CString csCl(L"regedit.exe /s ");
  44. csCl += lpExistingFileName;
  45. STARTUPINFOW si;
  46. ZeroMemory( &si, sizeof(si) );
  47. si.cb = sizeof(si);
  48. PROCESS_INFORMATION pi;
  49. ZeroMemory( &pi, sizeof(pi) );
  50. BOOL bProc = CreateProcessW(NULL,
  51. (WCHAR *)csCl.Get(), // Stupid non-const api
  52. NULL,
  53. NULL,
  54. FALSE,
  55. NORMAL_PRIORITY_CLASS,
  56. NULL,
  57. NULL,
  58. &si,
  59. &pi);
  60. if (bProc)
  61. {
  62. WaitForSingleObject(pi.hProcess,INFINITE);
  63. }
  64. else
  65. {
  66. //Fail to run the regedit
  67. DPFN(eDbgLevelInfo,"Failed to run regedit on %s\n",lpExistingFileName);
  68. }
  69. }
  70. }
  71. CSTRING_CATCH
  72. {
  73. // Do nothing
  74. }
  75. }
  76. return bRet;
  77. }
  78. /*++
  79. Register hooked functions
  80. --*/
  81. HOOK_BEGIN
  82. APIHOOK_ENTRY(KERNEL32.DLL, CopyFileA)
  83. HOOK_END
  84. IMPLEMENT_SHIM_END