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.

94 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. IgnoreVBOverflow.cpp
  5. Abstract:
  6. Some VB applications don't expect full 32-bit handles from some APIs. VB
  7. type checking typically throws a "Runtime Error 6" message when
  8. applications try and store a 32-bit value in a 16-bit variable.
  9. This fix works with VB5 and VB6 apps.
  10. Notes:
  11. This is a general purpose shim.
  12. History:
  13. 05/21/2001 linstev Created
  14. --*/
  15. #include "precomp.h"
  16. IMPLEMENT_SHIM_BEGIN(IgnoreVBOverflow)
  17. #include "ShimHookMacro.h"
  18. typedef DWORD (WINAPI *_pfn_VB5_vbaI2I4)();
  19. typedef DWORD (WINAPI *_pfn_VB6_vbaI2I4)();
  20. APIHOOK_ENUM_BEGIN
  21. APIHOOK_ENUM_ENTRY(VB5_vbaI2I4)
  22. APIHOOK_ENUM_ENTRY(VB6_vbaI2I4)
  23. APIHOOK_ENUM_END
  24. /*++
  25. Zero the return if ecx > 0xFFFF
  26. --*/
  27. __declspec(naked)
  28. VOID
  29. APIHOOK(VB5_vbaI2I4)()
  30. {
  31. __asm {
  32. test ecx, 0xFFFF0000
  33. jz Loc1
  34. xor ecx, ecx
  35. Loc1:
  36. mov eax, ecx
  37. ret
  38. }
  39. }
  40. /*++
  41. Zero the return if ecx > 0xFFFF
  42. --*/
  43. __declspec(naked)
  44. VOID
  45. APIHOOK(VB6_vbaI2I4)()
  46. {
  47. __asm {
  48. test ecx, 0xFFFF0000
  49. jz Loc1
  50. xor ecx, ecx
  51. Loc1:
  52. mov eax, ecx
  53. ret
  54. }
  55. }
  56. /*++
  57. Register hooked functions
  58. --*/
  59. HOOK_BEGIN
  60. APIHOOK_ENTRY_NAME(MSVBVM50.DLL, VB5_vbaI2I4, __vbaI2I4)
  61. APIHOOK_ENTRY_NAME(MSVBVM60.DLL, VB6_vbaI2I4, __vbaI2I4)
  62. HOOK_END
  63. IMPLEMENT_SHIM_END