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.

90 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. OverlayPro.cpp
  5. Abstract:
  6. This shim changes the return value of RegOpenKeyA from ERROR_SUCCESS
  7. to ERROR_FILE_NOT_FOUND if the key is "System\CurrentControlSet\Control\Print\Printers"
  8. No idea why this is needed but it seems to make the app work. Probably
  9. something else is the cause the app behaves differently but no one investigated
  10. more into the app's code to figure it out.
  11. Notes:
  12. This is an app specific shim.
  13. History:
  14. 02/16/2000 clupu Created
  15. --*/
  16. #include "precomp.h"
  17. IMPLEMENT_SHIM_BEGIN(OverlayPro)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(RegOpenKeyA)
  21. APIHOOK_ENUM_END
  22. /*++
  23. Change the return value of RegOpenKeyA from 0 to 2 if the key is
  24. "System\CurrentControlSet\Control\Print\Printers"
  25. --*/
  26. LONG
  27. APIHOOK(RegOpenKeyA)(
  28. HKEY hKey,
  29. LPSTR lpSubKey,
  30. PHKEY phkResult
  31. )
  32. {
  33. LONG lRet;
  34. //
  35. // Call the original API
  36. //
  37. lRet = ORIGINAL_API(RegOpenKeyA)(hKey, lpSubKey, phkResult);
  38. if (lRet == 0) {
  39. if (CompareStringA(MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_NEUTRAL),SORT_DEFAULT),
  40. NORM_IGNORECASE, lpSubKey, -1,
  41. "System\\CurrentControlSet\\Control\\Print\\Printers",-1) == CSTR_EQUAL) {
  42. DPFN(
  43. eDbgLevelInfo,
  44. "OverlayPro.dll, Changing RegOpenKeyA's "
  45. "return from ERROR_SUCCESS to ERROR_FILE_NOT_FOUND.\n");
  46. lRet = 2;
  47. }
  48. }
  49. return lRet;
  50. }
  51. /*++
  52. Register hooked functions
  53. --*/
  54. HOOK_BEGIN
  55. APIHOOK_ENTRY(ADVAPI32.DLL, RegOpenKeyA)
  56. HOOK_END
  57. IMPLEMENT_SHIM_END