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.

85 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. Keisoku7.cpp
  5. Abstract:
  6. The app has an executable bplayer.exe to launch its virtual CD driver. The
  7. problem is bplayer.exe is put in start-group and will be launched by
  8. explorer.exe, at the time the virtual CD driver is launched, explorer.exe
  9. has already finished initialization and cached all local drive info. Fixing
  10. this by broadcasting a WM_DEVICECHANGE message.
  11. Notes:
  12. This is an app specific shim.
  13. History:
  14. 06/20/2001 xiaoz Created
  15. --*/
  16. #include "precomp.h"
  17. #include "Dbt.h"
  18. IMPLEMENT_SHIM_BEGIN(Keisoku7)
  19. #include "ShimHookMacro.h"
  20. APIHOOK_ENUM_BEGIN
  21. APIHOOK_ENUM_ENTRY(StartServiceA)
  22. APIHOOK_ENUM_END
  23. /*++
  24. Hook StartServiceA to broadcast a WM_DEVICECHANGE message
  25. --*/
  26. BOOL
  27. APIHOOK(StartServiceA)(
  28. SC_HANDLE hService,
  29. DWORD dwNumServiceArgs,
  30. LPCSTR *lpServiceArgVectors
  31. )
  32. {
  33. BOOL bRet;
  34. DEV_BROADCAST_VOLUME devbVol;
  35. bRet = ORIGINAL_API(StartServiceA)(hService, dwNumServiceArgs,
  36. lpServiceArgVectors);
  37. //
  38. // If succeed, we will broadcast WM_DEVICECHANGE message
  39. //
  40. if (bRet)
  41. {
  42. devbVol.dbcv_size = sizeof(DEV_BROADCAST_VOLUME);
  43. devbVol.dbcv_devicetype = DBT_DEVTYP_VOLUME;
  44. devbVol.dbcv_reserved = 0;
  45. devbVol.dbcv_unitmask = 0x3FFFFF8; // All drives except A: B: C:
  46. devbVol.dbcv_flags = 0;
  47. SendMessageTimeout(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVICEARRIVAL,
  48. (LPARAM) &devbVol, SMTO_NOTIMEOUTIFNOTHUNG, 1000, NULL);
  49. LOGN(eDbgLevelWarning, "WM_DEVICECHANGE broadcasted");
  50. }
  51. return bRet;
  52. }
  53. /*++
  54. Register hooked functions
  55. --*/
  56. HOOK_BEGIN
  57. APIHOOK_ENTRY(ADVAPI32.DLL, StartServiceA)
  58. HOOK_END
  59. IMPLEMENT_SHIM_END