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.

74 lines
1.6 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Starts a process server and sleeps forever.
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000.
  6. //
  7. //----------------------------------------------------------------------------
  8. #include <stdio.h>
  9. #include <dbgeng.h>
  10. PDEBUG_CLIENT2 g_Client2;
  11. void DECLSPEC_NORETURN
  12. Panic(HRESULT Status, char* Format, ...)
  13. {
  14. va_list Args;
  15. char Msg[256];
  16. char Err[80];
  17. va_start(Args, Format);
  18. _vsnprintf(Msg, sizeof(Msg), Format, Args);
  19. va_end(Args);
  20. sprintf(Err, "Error 0x%08X", Status);
  21. MessageBox(GetDesktopWindow(), Msg, Err, MB_OK);
  22. exit(1);
  23. }
  24. void __cdecl
  25. main(int Argc, char** Argv)
  26. {
  27. PSTR Options;
  28. while (--Argc > 0)
  29. {
  30. Argv++;
  31. break;
  32. }
  33. if (Argc != 1)
  34. {
  35. Panic(E_INVALIDARG, "Usage: dbgsrv <transport>");
  36. }
  37. Options = *Argv;
  38. HRESULT Status;
  39. PDEBUG_CLIENT Client;
  40. if ((Status = DebugCreate(__uuidof(IDebugClient),
  41. (void**)&Client)) != S_OK)
  42. {
  43. Panic(Status, "DebugCreate");
  44. }
  45. if ((Status = Client->QueryInterface(__uuidof(IDebugClient2),
  46. (void**)&g_Client2)) != S_OK)
  47. {
  48. Panic(Status, "dbgeng version 2 is required");
  49. }
  50. Client->Release();
  51. if ((Status = g_Client2->
  52. StartProcessServer(DEBUG_CLASS_USER_WINDOWS, Options, NULL)) != S_OK)
  53. {
  54. Panic(Status, "StartProcessServer");
  55. }
  56. g_Client2->WaitForProcessServerEnd(INFINITE);
  57. g_Client2->EndSession(DEBUG_END_REENTRANT);
  58. g_Client2->Release();
  59. }