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.

77 lines
1.2 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. NetBackup45.cpp
  5. Abstract:
  6. The app calls CString::SetAt with an index > length. This API was
  7. modified to throw an exception in this case to prevent a buffer
  8. overrun.
  9. Notes:
  10. This is an app specific shim.
  11. History:
  12. 07/08/2002 linstev Created
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(NetBackup45)
  16. #include "ShimHookMacro.h"
  17. typedef VOID (WINAPI *_pfn_MFC_CString_SetAt)();
  18. APIHOOK_ENUM_BEGIN
  19. APIHOOK_ENUM_ENTRY(MFC_CString_SetAt)
  20. APIHOOK_ENUM_END
  21. /*++
  22. Only allow the call if index < length
  23. --*/
  24. __declspec(naked)
  25. VOID
  26. APIHOOK(MFC_CString_SetAt)()
  27. {
  28. __asm {
  29. mov eax, [ecx]
  30. mov eax, [eax - 8] // This gets us the length
  31. cmp [esp + 4], eax // [esp + 4] = Index; eax = Length
  32. jge Done
  33. push [esp + 8]
  34. push [esp + 8]
  35. }
  36. ORIGINAL_API(MFC_CString_SetAt)();
  37. Done:
  38. __asm {
  39. ret 8
  40. }
  41. }
  42. /*++
  43. Register hooked functions
  44. --*/
  45. HOOK_BEGIN
  46. APIHOOK_ENTRY_ORD(MFC42.DLL, MFC_CString_SetAt, 5856)
  47. HOOK_END
  48. IMPLEMENT_SHIM_END