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.

84 lines
1.5 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. SuperChix76.cpp
  5. Abstract:
  6. Hook LoadLibrary and calls GetDeviceIdentifier which initializes wintrust.
  7. This fixes the problem whereby the app will hang if they call
  8. GetDeviceIdentifier from within a DllMain - which is an app bug.
  9. Notes:
  10. This is an app specific shim.
  11. History:
  12. 10/22/2000 linstev Created
  13. --*/
  14. #include "precomp.h"
  15. // This module has been given an official blessing to use the str routines.
  16. #include "LegalStr.h"
  17. IMPLEMENT_SHIM_BEGIN(SuperChix76)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(LoadLibraryA)
  21. APIHOOK_ENUM_END
  22. /*++
  23. Hook LoadLibrary and detect their dll.
  24. --*/
  25. HINSTANCE
  26. APIHOOK(LoadLibraryA)(
  27. LPCSTR lpLibFileName
  28. )
  29. {
  30. if (stristr(lpLibFileName, "did3d"))
  31. {
  32. LPDIRECTDRAW g_pDD;
  33. LPDIRECTDRAW7 g_pDD7;
  34. if (0 == DirectDrawCreate(NULL, &g_pDD, NULL))
  35. {
  36. if (0 == g_pDD->QueryInterface(IID_IDirectDraw7, (void **)&g_pDD7))
  37. {
  38. DDDEVICEIDENTIFIER2 devid;
  39. DWORD dwBlank[16]; // GetDeviceIdentifier writes passed it's allocation
  40. g_pDD7->GetDeviceIdentifier(&devid, 0);
  41. g_pDD7->Release();
  42. }
  43. g_pDD->Release();
  44. }
  45. }
  46. return ORIGINAL_API(LoadLibraryA)(lpLibFileName);
  47. }
  48. /*++
  49. Register hooked functions
  50. --*/
  51. HOOK_BEGIN
  52. APIHOOK_ENTRY(KERNEL32.DLL, LoadLibraryA)
  53. HOOK_END
  54. IMPLEMENT_SHIM_END