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.

75 lines
1.2 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. NikonView.cpp
  5. Abstract:
  6. App crashes on exit trying to dereference a NULL. This memory is never
  7. initialized, so it's not clear how this ever worked.
  8. Fixed by recognizing the exit sequence and killing the process before it
  9. AVs.
  10. Notes:
  11. This is an app specific shim.
  12. History:
  13. 06/25/2002 linstev Created
  14. --*/
  15. #include "precomp.h"
  16. IMPLEMENT_SHIM_BEGIN(NikonView)
  17. #include "ShimHookMacro.h"
  18. APIHOOK_ENUM_BEGIN
  19. APIHOOK_ENUM_ENTRY(UnregisterClassA)
  20. APIHOOK_ENUM_END
  21. DWORD g_dwCount = 0;
  22. /*++
  23. Kill the app on failed UnregisterClass
  24. --*/
  25. BOOL
  26. APIHOOK(UnregisterClassA)(
  27. LPCSTR lpClassName,
  28. HINSTANCE hInstance
  29. )
  30. {
  31. BOOL bRet = ORIGINAL_API(UnregisterClassA)(lpClassName, hInstance);
  32. // Recognize termination sequence
  33. if (!bRet && lpClassName && (!IsBadReadPtr(lpClassName, 1)) && (*lpClassName == '\0')) {
  34. g_dwCount++;
  35. if (g_dwCount == 3) {
  36. ExitProcess(0);
  37. }
  38. }
  39. return bRet;
  40. }
  41. /*++
  42. Register hooked functions
  43. --*/
  44. HOOK_BEGIN
  45. APIHOOK_ENTRY(USER32.DLL, UnregisterClassA)
  46. HOOK_END
  47. IMPLEMENT_SHIM_END