From: Eric Kohl Date: Mon, 22 Feb 2010 19:26:54 +0000 (+0000) Subject: Revert remaining parts of patches 45626 and 45633. X-Git-Tag: ReactOS-0.3.11-CLT2010~8^2~101 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=a634cc3aa5f7e8a4f2132b88edc04bbb631f6a14 Revert remaining parts of patches 45626 and 45633. svn path=/trunk/; revision=45658 --- diff --git a/reactos/base/services/umpnpmgr/umpnpmgr.c b/reactos/base/services/umpnpmgr/umpnpmgr.c index 75080d583df..8dc8a16e031 100644 --- a/reactos/base/services/umpnpmgr/umpnpmgr.c +++ b/reactos/base/services/umpnpmgr/umpnpmgr.c @@ -51,11 +51,12 @@ /* GLOBALS ******************************************************************/ -static VOID CALLBACK ServiceMain(DWORD, LPWSTR *); -static WCHAR ServiceName[] = L"PlugPlay"; -static SERVICE_TABLE_ENTRYW ServiceTable[] = +static VOID CALLBACK +ServiceMain(DWORD argc, LPTSTR *argv); + +static SERVICE_TABLE_ENTRY ServiceTable[2] = { - {ServiceName, ServiceMain}, + {TEXT("PlugPlay"), ServiceMain}, {NULL, NULL} }; @@ -2445,36 +2446,63 @@ PnpEventThread(LPVOID lpParameter) } -static DWORD WINAPI -ServiceControlHandler(DWORD dwControl, - DWORD dwEventType, - LPVOID lpEventData, - LPVOID lpContext) +static VOID CALLBACK +ServiceMain(DWORD argc, LPTSTR *argv) { - /* FIXME */ - DPRINT1("ServiceControlHandler() called (control code %lu)\n", dwControl); - return ERROR_SUCCESS; + HANDLE hThread; + DWORD dwThreadId; + + UNREFERENCED_PARAMETER(argc); + UNREFERENCED_PARAMETER(argv); + + DPRINT("ServiceMain() called\n"); + + hThread = CreateThread(NULL, + 0, + PnpEventThread, + NULL, + 0, + &dwThreadId); + if (hThread != NULL) + CloseHandle(hThread); + + hThread = CreateThread(NULL, + 0, + RpcServerThread, + NULL, + 0, + &dwThreadId); + if (hThread != NULL) + CloseHandle(hThread); + + hThread = CreateThread(NULL, + 0, + DeviceInstallThread, + NULL, + 0, + &dwThreadId); + if (hThread != NULL) + CloseHandle(hThread); + + DPRINT("ServiceMain() done\n"); } -static DWORD -ServiceInit(VOID) +int +wmain(int argc, WCHAR *argv[]) { - HANDLE hThread; - DWORD dwThreadId; - DWORD dwError; BOOLEAN OldValue; + DWORD dwError; + + UNREFERENCED_PARAMETER(argc); + UNREFERENCED_PARAMETER(argv); + + DPRINT("Umpnpmgr: main() started\n"); /* We need this privilege for using CreateProcessAsUserW */ - RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, - TRUE, - FALSE, - &OldValue); - - hInstallEvent = CreateEvent(NULL, - TRUE, - SetupIsActive()/*FALSE*/, - NULL); + RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, FALSE, &OldValue); + + hInstallEvent = CreateEvent(NULL, TRUE, SetupIsActive()/*FALSE*/, NULL); if (hInstallEvent == NULL) { dwError = GetLastError(); @@ -2482,10 +2510,7 @@ ServiceInit(VOID) return dwError; } - hDeviceInstallListNotEmpty = CreateEvent(NULL, - FALSE, - FALSE, - NULL); + hDeviceInstallListNotEmpty = CreateEvent(NULL, FALSE, FALSE, NULL); if (hDeviceInstallListNotEmpty == NULL) { dwError = GetLastError(); @@ -2532,110 +2557,11 @@ ServiceInit(VOID) return dwError; } - hThread = CreateThread(NULL, - 0, - PnpEventThread, - NULL, - 0, - &dwThreadId); - if (hThread == NULL) - { - return GetLastError(); - } - CloseHandle(hThread); - - hThread = CreateThread(NULL, - 0, - RpcServerThread, - NULL, - 0, - &dwThreadId); - if (hThread == NULL) - { - return GetLastError(); - } - CloseHandle(hThread); - - hThread = CreateThread(NULL, - 0, - DeviceInstallThread, - NULL, - 0, - &dwThreadId); - if (hThread == NULL) - { - return GetLastError(); - } - CloseHandle(hThread); - - return ERROR_SUCCESS; -} - - -static VOID CALLBACK -ServiceMain(DWORD argc, - LPWSTR *argv) -{ - SERVICE_STATUS ServiceStatus; - SERVICE_STATUS_HANDLE ServiceStatusHandle; - DWORD dwError; - - UNREFERENCED_PARAMETER(argc); - UNREFERENCED_PARAMETER(argv); - - DPRINT("ServiceMain() called\n"); - - ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName, - ServiceControlHandler, - NULL); - if (!ServiceStatusHandle) - { - dwError = GetLastError(); - DPRINT1("RegisterServiceCtrlHandlerW() failed! (Error %lu)\n", dwError); - return; - } - - ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; - ServiceStatus.dwCurrentState = SERVICE_START_PENDING; - ServiceStatus.dwControlsAccepted = 0; - ServiceStatus.dwWin32ExitCode = NO_ERROR; - ServiceStatus.dwServiceSpecificExitCode = 0; - ServiceStatus.dwCheckPoint = 0; - ServiceStatus.dwWaitHint = 2000; - - SetServiceStatus(ServiceStatusHandle, - &ServiceStatus); - - dwError = ServiceInit(); - if (dwError != ERROR_SUCCESS) - { - DPRINT1("Service stopped\n"); - ServiceStatus.dwCurrentState = SERVICE_STOPPED; - } - else - { - ServiceStatus.dwCurrentState = SERVICE_RUNNING; - } - - SetServiceStatus(ServiceStatusHandle, - &ServiceStatus); - - DPRINT("ServiceMain() done\n"); -} - - -int -wmain(int argc, - WCHAR *argv[]) -{ - UNREFERENCED_PARAMETER(argc); - UNREFERENCED_PARAMETER(argv); - - DPRINT1("Umpnpmgr: main() started\n"); + StartServiceCtrlDispatcher(ServiceTable); - StartServiceCtrlDispatcherW(ServiceTable); + DPRINT("Umpnpmgr: main() done\n"); - DPRINT1("Umpnpmgr: main() done\n"); + ExitThread(0); return 0; } diff --git a/reactos/base/system/services/services.c b/reactos/base/system/services/services.c index 0c5327d5b1e..44ee8f396af 100644 --- a/reactos/base/system/services/services.c +++ b/reactos/base/system/services/services.c @@ -48,34 +48,35 @@ PrintString(LPCSTR fmt, ...) BOOL -ScmCreateEvent(PHANDLE Event, - LPCWSTR Name) +ScmCreateStartEvent(PHANDLE StartEvent) { HANDLE hEvent; - hEvent = CreateEventW(NULL, - TRUE, - FALSE, - Name); + hEvent = CreateEvent(NULL, + TRUE, + FALSE, + TEXT("SvcctrlStartEvent_A3752DX")); if (hEvent == NULL) { if (GetLastError() == ERROR_ALREADY_EXISTS) { - hEvent = OpenEventW(EVENT_ALL_ACCESS, - FALSE, - Name); + hEvent = OpenEvent(EVENT_ALL_ACCESS, + FALSE, + TEXT("SvcctrlStartEvent_A3752DX")); + if (hEvent == NULL) + { + return FALSE; + } + } + else + { + return FALSE; } } - if (hEvent) - { - DPRINT("SERVICES: created event %S with handle %x\n", Name, hEvent); - *Event = hEvent; - return TRUE; - } + *StartEvent = hEvent; - DPRINT1("SERVICES: Failed to create event %S\n", Name); - return FALSE; + return TRUE; } @@ -298,7 +299,6 @@ wWinMain(HINSTANCE hInstance, int nShowCmd) { HANDLE hScmStartEvent; - HANDLE hScmAutoStartCompleteEvent; HANDLE hEvent; DWORD dwError; @@ -307,16 +307,14 @@ wWinMain(HINSTANCE hInstance, /* Acquire privileges to load drivers */ AcquireLoadDriverPrivilege(); - /* Create events */ - if (!ScmCreateEvent(&hScmAutoStartCompleteEvent, L"SC_AutoStartComplete")) + /* Create start event */ + if (!ScmCreateStartEvent(&hScmStartEvent)) { + DPRINT1("SERVICES: Failed to create start event\n"); ExitThread(0); } - if (!ScmCreateEvent(&hScmStartEvent, L"SvcctrlStartEvent_A3752DX")) - { - ExitThread(0); - } + DPRINT("SERVICES: created start event with handle %x.\n", hScmStartEvent); // ScmInitThreadManager(); @@ -356,9 +354,6 @@ wWinMain(HINSTANCE hInstance, DPRINT("SERVICES: Running.\n"); - /* Signal complete event */ - SetEvent(hScmAutoStartCompleteEvent); - #if 1 hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (hEvent)