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.

81 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. IMPLEMENT_SHIM_BEGIN(SuperChix76)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_ENTRY(LoadLibraryA)
  19. APIHOOK_ENUM_END
  20. /*++
  21. Hook LoadLibrary and detect their dll.
  22. --*/
  23. HINSTANCE
  24. APIHOOK(LoadLibraryA)(
  25. LPCSTR lpLibFileName
  26. )
  27. {
  28. if (stristr(lpLibFileName, "did3d"))
  29. {
  30. LPDIRECTDRAW g_pDD;
  31. LPDIRECTDRAW7 g_pDD7;
  32. if (0 == DirectDrawCreate(NULL, &g_pDD, NULL))
  33. {
  34. if (0 == g_pDD->QueryInterface(IID_IDirectDraw7, (void **)&g_pDD7))
  35. {
  36. DDDEVICEIDENTIFIER2 devid;
  37. DWORD dwBlank[16]; // GetDeviceIdentifier writes passed it's allocation
  38. g_pDD7->GetDeviceIdentifier(&devid, 0);
  39. g_pDD7->Release();
  40. }
  41. g_pDD->Release();
  42. }
  43. }
  44. return ORIGINAL_API(LoadLibraryA)(lpLibFileName);
  45. }
  46. /*++
  47. Register hooked functions
  48. --*/
  49. HOOK_BEGIN
  50. APIHOOK_ENTRY(KERNEL32.DLL, LoadLibraryA)
  51. HOOK_END
  52. IMPLEMENT_SHIM_END