Source code of Windows XP (NT5)
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.

111 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. EmulateVerQueryValue.cpp
  5. Abstract:
  6. This shim fixes a null version length buffer pointer.
  7. Notes:
  8. This is a general purpose shim.
  9. History:
  10. 01/03/2000 jdoherty Revised coding style.
  11. 11/28/2000 jdoherty Converted to framework version 2
  12. --*/
  13. #include "precomp.h"
  14. IMPLEMENT_SHIM_BEGIN(EmulateVerQueryValue)
  15. #include "ShimHookMacro.h"
  16. APIHOOK_ENUM_BEGIN
  17. APIHOOK_ENUM_ENTRY(VerQueryValueA)
  18. APIHOOK_ENUM_ENTRY(VerQueryValueW)
  19. APIHOOK_ENUM_END
  20. /*++
  21. Fix the null version length buffer pointer.
  22. --*/
  23. BOOL
  24. APIHOOK(VerQueryValueA)(
  25. const LPVOID pBlock,
  26. LPSTR lpSubBlock,
  27. LPVOID *lplpBuffer,
  28. PUINT puLen
  29. )
  30. {
  31. BOOL bRet;
  32. UINT nLen;
  33. if (!puLen) {
  34. puLen = &nLen;
  35. DPFN( eDbgLevelError, "[APIHook_VerQueryValueA] Null puLen param. Fixed.\n");
  36. }
  37. bRet = ORIGINAL_API(VerQueryValueA)(
  38. pBlock,
  39. lpSubBlock,
  40. lplpBuffer,
  41. puLen);
  42. return bRet;
  43. }
  44. /*++
  45. Fix the null version length buffer pointer. Unicode version.
  46. --*/
  47. BOOL
  48. APIHOOK(VerQueryValueW)(
  49. const LPVOID pBlock,
  50. LPWSTR lpSubBlock,
  51. LPVOID *lplpBuffer,
  52. PUINT puLen
  53. )
  54. {
  55. BOOL bRet;
  56. UINT nLen;
  57. if (!puLen) {
  58. puLen = &nLen;
  59. DPFN( eDbgLevelError, "[APIHook_VerQueryValueW] Null puLen param. Fixed.\n");
  60. }
  61. bRet = ORIGINAL_API(VerQueryValueW)(
  62. pBlock,
  63. lpSubBlock,
  64. lplpBuffer,
  65. puLen);
  66. return bRet;
  67. }
  68. /*++
  69. Register hooked functions
  70. --*/
  71. HOOK_BEGIN
  72. APIHOOK_ENTRY(VERSION.DLL, VerQueryValueA)
  73. APIHOOK_ENTRY(VERSION.DLL, VerQueryValueW)
  74. HOOK_END
  75. IMPLEMENT_SHIM_END