mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Update indentation.
svn path=/trunk/; revision=18686
This commit is contained in:
parent
cf54e94b6e
commit
1060e47c32
3 changed files with 997 additions and 978 deletions
File diff suppressed because it is too large
Load diff
|
@ -18,30 +18,30 @@
|
||||||
|
|
||||||
typedef struct _SCMGR_HANDLE
|
typedef struct _SCMGR_HANDLE
|
||||||
{
|
{
|
||||||
DWORD Tag;
|
DWORD Tag;
|
||||||
DWORD RefCount;
|
DWORD RefCount;
|
||||||
DWORD DesiredAccess;
|
DWORD DesiredAccess;
|
||||||
} SCMGR_HANDLE;
|
} SCMGR_HANDLE;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _MANAGER_HANDLE
|
typedef struct _MANAGER_HANDLE
|
||||||
{
|
{
|
||||||
SCMGR_HANDLE Handle;
|
SCMGR_HANDLE Handle;
|
||||||
|
|
||||||
/* FIXME: Insert more data here */
|
/* FIXME: Insert more data here */
|
||||||
|
|
||||||
WCHAR DatabaseName[1];
|
WCHAR DatabaseName[1];
|
||||||
} MANAGER_HANDLE, *PMANAGER_HANDLE;
|
} MANAGER_HANDLE, *PMANAGER_HANDLE;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _SERVICE_HANDLE
|
typedef struct _SERVICE_HANDLE
|
||||||
{
|
{
|
||||||
SCMGR_HANDLE Handle;
|
SCMGR_HANDLE Handle;
|
||||||
|
|
||||||
DWORD DesiredAccess;
|
DWORD DesiredAccess;
|
||||||
PSERVICE ServiceEntry;
|
PSERVICE ServiceEntry;
|
||||||
|
|
||||||
/* FIXME: Insert more data here */
|
/* FIXME: Insert more data here */
|
||||||
|
|
||||||
} SERVICE_HANDLE, *PSERVICE_HANDLE;
|
} SERVICE_HANDLE, *PSERVICE_HANDLE;
|
||||||
|
|
||||||
|
@ -103,37 +103,37 @@ ScmServiceMapping = {SERVICE_READ,
|
||||||
VOID
|
VOID
|
||||||
ScmStartRpcServer(VOID)
|
ScmStartRpcServer(VOID)
|
||||||
{
|
{
|
||||||
RPC_STATUS Status;
|
RPC_STATUS Status;
|
||||||
|
|
||||||
DPRINT("ScmStartRpcServer() called");
|
DPRINT("ScmStartRpcServer() called");
|
||||||
|
|
||||||
Status = RpcServerUseProtseqEpW(L"ncacn_np",
|
Status = RpcServerUseProtseqEpW(L"ncacn_np",
|
||||||
10,
|
10,
|
||||||
L"\\pipe\\ntsvcs",
|
L"\\pipe\\ntsvcs",
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != RPC_S_OK)
|
if (Status != RPC_S_OK)
|
||||||
{
|
{
|
||||||
DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
|
DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = RpcServerRegisterIf(svcctl_ServerIfHandle,
|
Status = RpcServerRegisterIf(svcctl_ServerIfHandle,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != RPC_S_OK)
|
if (Status != RPC_S_OK)
|
||||||
{
|
{
|
||||||
DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status);
|
DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = RpcServerListen(1, 20, TRUE);
|
Status = RpcServerListen(1, 20, TRUE);
|
||||||
if (Status != RPC_S_OK)
|
if (Status != RPC_S_OK)
|
||||||
{
|
{
|
||||||
DPRINT1("RpcServerListen() failed (Status %lx)\n", Status);
|
DPRINT1("RpcServerListen() failed (Status %lx)\n", Status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("ScmStartRpcServer() done");
|
DPRINT("ScmStartRpcServer() done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,27 +141,27 @@ static DWORD
|
||||||
ScmCreateManagerHandle(LPWSTR lpDatabaseName,
|
ScmCreateManagerHandle(LPWSTR lpDatabaseName,
|
||||||
SC_HANDLE *Handle)
|
SC_HANDLE *Handle)
|
||||||
{
|
{
|
||||||
PMANAGER_HANDLE Ptr;
|
PMANAGER_HANDLE Ptr;
|
||||||
|
|
||||||
if (lpDatabaseName == NULL)
|
if (lpDatabaseName == NULL)
|
||||||
lpDatabaseName = SERVICES_ACTIVE_DATABASEW;
|
lpDatabaseName = SERVICES_ACTIVE_DATABASEW;
|
||||||
|
|
||||||
Ptr = HeapAlloc(GetProcessHeap(),
|
Ptr = HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
sizeof(MANAGER_HANDLE) + wcslen(lpDatabaseName) * sizeof(WCHAR));
|
sizeof(MANAGER_HANDLE) + wcslen(lpDatabaseName) * sizeof(WCHAR));
|
||||||
if (Ptr == NULL)
|
if (Ptr == NULL)
|
||||||
return ERROR_NOT_ENOUGH_MEMORY;
|
return ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
|
||||||
Ptr->Handle.Tag = MANAGER_TAG;
|
Ptr->Handle.Tag = MANAGER_TAG;
|
||||||
Ptr->Handle.RefCount = 1;
|
Ptr->Handle.RefCount = 1;
|
||||||
|
|
||||||
/* FIXME: initialize more data here */
|
/* FIXME: initialize more data here */
|
||||||
|
|
||||||
wcscpy(Ptr->DatabaseName, lpDatabaseName);
|
wcscpy(Ptr->DatabaseName, lpDatabaseName);
|
||||||
|
|
||||||
*Handle = (SC_HANDLE)Ptr;
|
*Handle = (SC_HANDLE)Ptr;
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,23 +169,23 @@ static DWORD
|
||||||
ScmCreateServiceHandle(PSERVICE lpServiceEntry,
|
ScmCreateServiceHandle(PSERVICE lpServiceEntry,
|
||||||
SC_HANDLE *Handle)
|
SC_HANDLE *Handle)
|
||||||
{
|
{
|
||||||
PSERVICE_HANDLE Ptr;
|
PSERVICE_HANDLE Ptr;
|
||||||
|
|
||||||
Ptr = HeapAlloc(GetProcessHeap(),
|
Ptr = HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
sizeof(SERVICE_HANDLE));
|
sizeof(SERVICE_HANDLE));
|
||||||
if (Ptr == NULL)
|
if (Ptr == NULL)
|
||||||
return ERROR_NOT_ENOUGH_MEMORY;
|
return ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
|
||||||
Ptr->Handle.Tag = SERVICE_TAG;
|
Ptr->Handle.Tag = SERVICE_TAG;
|
||||||
Ptr->Handle.RefCount = 1;
|
Ptr->Handle.RefCount = 1;
|
||||||
|
|
||||||
/* FIXME: initialize more data here */
|
/* FIXME: initialize more data here */
|
||||||
Ptr->ServiceEntry = lpServiceEntry;
|
Ptr->ServiceEntry = lpServiceEntry;
|
||||||
|
|
||||||
*Handle = (SC_HANDLE)Ptr;
|
*Handle = (SC_HANDLE)Ptr;
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,29 +193,29 @@ static DWORD
|
||||||
ScmCheckAccess(SC_HANDLE Handle,
|
ScmCheckAccess(SC_HANDLE Handle,
|
||||||
DWORD dwDesiredAccess)
|
DWORD dwDesiredAccess)
|
||||||
{
|
{
|
||||||
PMANAGER_HANDLE hMgr;
|
PMANAGER_HANDLE hMgr;
|
||||||
|
|
||||||
hMgr = (PMANAGER_HANDLE)Handle;
|
hMgr = (PMANAGER_HANDLE)Handle;
|
||||||
if (hMgr->Handle.Tag == MANAGER_TAG)
|
if (hMgr->Handle.Tag == MANAGER_TAG)
|
||||||
{
|
{
|
||||||
RtlMapGenericMask(&dwDesiredAccess,
|
RtlMapGenericMask(&dwDesiredAccess,
|
||||||
&ScmManagerMapping);
|
&ScmManagerMapping);
|
||||||
|
|
||||||
hMgr->Handle.DesiredAccess = dwDesiredAccess;
|
hMgr->Handle.DesiredAccess = dwDesiredAccess;
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (hMgr->Handle.Tag == SERVICE_TAG)
|
else if (hMgr->Handle.Tag == SERVICE_TAG)
|
||||||
{
|
{
|
||||||
RtlMapGenericMask(&dwDesiredAccess,
|
RtlMapGenericMask(&dwDesiredAccess,
|
||||||
&ScmServiceMapping);
|
&ScmServiceMapping);
|
||||||
|
|
||||||
hMgr->Handle.DesiredAccess = dwDesiredAccess;
|
hMgr->Handle.DesiredAccess = dwDesiredAccess;
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,50 +224,50 @@ unsigned long
|
||||||
ScmrCloseServiceHandle(handle_t BindingHandle,
|
ScmrCloseServiceHandle(handle_t BindingHandle,
|
||||||
unsigned int hScObject)
|
unsigned int hScObject)
|
||||||
{
|
{
|
||||||
PMANAGER_HANDLE hManager;
|
PMANAGER_HANDLE hManager;
|
||||||
|
|
||||||
DPRINT("ScmrCloseServiceHandle() called\n");
|
DPRINT("ScmrCloseServiceHandle() called\n");
|
||||||
|
|
||||||
DPRINT("hScObject = %X\n", hScObject);
|
DPRINT("hScObject = %X\n", hScObject);
|
||||||
|
|
||||||
|
if (hScObject == 0)
|
||||||
|
return ERROR_INVALID_HANDLE;
|
||||||
|
|
||||||
|
hManager = (PMANAGER_HANDLE)hScObject;
|
||||||
|
if (hManager->Handle.Tag == MANAGER_TAG)
|
||||||
|
{
|
||||||
|
DPRINT("Found manager handle\n");
|
||||||
|
|
||||||
|
hManager->Handle.RefCount--;
|
||||||
|
if (hManager->Handle.RefCount == 0)
|
||||||
|
{
|
||||||
|
/* FIXME: add cleanup code */
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, hManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("ScmrCloseServiceHandle() done\n");
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
else if (hManager->Handle.Tag == SERVICE_TAG)
|
||||||
|
{
|
||||||
|
DPRINT("Found service handle\n");
|
||||||
|
|
||||||
|
hManager->Handle.RefCount--;
|
||||||
|
if (hManager->Handle.RefCount == 0)
|
||||||
|
{
|
||||||
|
/* FIXME: add cleanup code */
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, hManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("ScmrCloseServiceHandle() done\n");
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT1("Invalid handle tag (Tag %lx)\n", hManager->Handle.Tag);
|
||||||
|
|
||||||
if (hScObject == 0)
|
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
|
|
||||||
hManager = (PMANAGER_HANDLE)hScObject;
|
|
||||||
if (hManager->Handle.Tag == MANAGER_TAG)
|
|
||||||
{
|
|
||||||
DPRINT("Found manager handle\n");
|
|
||||||
|
|
||||||
hManager->Handle.RefCount--;
|
|
||||||
if (hManager->Handle.RefCount == 0)
|
|
||||||
{
|
|
||||||
/* FIXME: add cleanup code */
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, hManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("ScmrCloseServiceHandle() done\n");
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
else if (hManager->Handle.Tag == SERVICE_TAG)
|
|
||||||
{
|
|
||||||
DPRINT("Found service handle\n");
|
|
||||||
|
|
||||||
hManager->Handle.RefCount--;
|
|
||||||
if (hManager->Handle.RefCount == 0)
|
|
||||||
{
|
|
||||||
/* FIXME: add cleanup code */
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, hManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("ScmrCloseServiceHandle() done\n");
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT1("Invalid handle tag (Tag %lx)\n", hManager->Handle.Tag);
|
|
||||||
|
|
||||||
return ERROR_INVALID_HANDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -278,39 +278,39 @@ ScmrControlService(handle_t BindingHandle,
|
||||||
unsigned long dwControl,
|
unsigned long dwControl,
|
||||||
LPSERVICE_STATUS lpServiceStatus)
|
LPSERVICE_STATUS lpServiceStatus)
|
||||||
{
|
{
|
||||||
PSERVICE_HANDLE hSvc;
|
PSERVICE_HANDLE hSvc;
|
||||||
PSERVICE lpService;
|
PSERVICE lpService;
|
||||||
|
|
||||||
DPRINT1("ScmrControlService() called\n");
|
DPRINT1("ScmrControlService() called\n");
|
||||||
|
|
||||||
hSvc = (PSERVICE_HANDLE)hService;
|
hSvc = (PSERVICE_HANDLE)hService;
|
||||||
if (hSvc->Handle.Tag != SERVICE_TAG)
|
if (hSvc->Handle.Tag != SERVICE_TAG)
|
||||||
{
|
{
|
||||||
DPRINT1("Invalid handle tag!\n");
|
DPRINT1("Invalid handle tag!\n");
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: Check access rights */
|
/* FIXME: Check access rights */
|
||||||
|
|
||||||
|
|
||||||
lpService = hSvc->ServiceEntry;
|
lpService = hSvc->ServiceEntry;
|
||||||
if (lpService == NULL)
|
if (lpService == NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("lpService == NULL!\n");
|
DPRINT1("lpService == NULL!\n");
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: Send control code to the service */
|
/* FIXME: Send control code to the service */
|
||||||
|
|
||||||
|
|
||||||
/* Return service status information */
|
/* Return service status information */
|
||||||
RtlCopyMemory(lpServiceStatus,
|
RtlCopyMemory(lpServiceStatus,
|
||||||
&lpService->Status,
|
&lpService->Status,
|
||||||
sizeof(SERVICE_STATUS));
|
sizeof(SERVICE_STATUS));
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,37 +319,37 @@ unsigned long
|
||||||
ScmrDeleteService(handle_t BindingHandle,
|
ScmrDeleteService(handle_t BindingHandle,
|
||||||
unsigned int hService)
|
unsigned int hService)
|
||||||
{
|
{
|
||||||
PSERVICE_HANDLE hSvc;
|
PSERVICE_HANDLE hSvc;
|
||||||
PSERVICE lpService;
|
PSERVICE lpService;
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
|
|
||||||
DPRINT1("ScmrDeleteService() called\n");
|
DPRINT1("ScmrDeleteService() called\n");
|
||||||
|
|
||||||
hSvc = (PSERVICE_HANDLE)hService;
|
hSvc = (PSERVICE_HANDLE)hService;
|
||||||
if (hSvc->Handle.Tag != SERVICE_TAG)
|
if (hSvc->Handle.Tag != SERVICE_TAG)
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
|
|
||||||
if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess,
|
if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess,
|
||||||
STANDARD_RIGHTS_REQUIRED))
|
STANDARD_RIGHTS_REQUIRED))
|
||||||
return ERROR_ACCESS_DENIED;
|
return ERROR_ACCESS_DENIED;
|
||||||
|
|
||||||
lpService = hSvc->ServiceEntry;
|
lpService = hSvc->ServiceEntry;
|
||||||
if (lpService == NULL)
|
if (lpService == NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("lpService == NULL!\n");
|
DPRINT1("lpService == NULL!\n");
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Acquire service database lock exclusively */
|
/* FIXME: Acquire service database lock exclusively */
|
||||||
|
|
||||||
/* Mark service for delete */
|
/* Mark service for delete */
|
||||||
dwError = ScmMarkServiceForDelete(lpService);
|
dwError = ScmMarkServiceForDelete(lpService);
|
||||||
|
|
||||||
/* FIXME: Release service database lock */
|
/* FIXME: Release service database lock */
|
||||||
|
|
||||||
DPRINT1("ScmrDeleteService() done\n");
|
DPRINT1("ScmrDeleteService() done\n");
|
||||||
|
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -359,24 +359,24 @@ ScmrLockServiceDatabase(handle_t BindingHandle,
|
||||||
unsigned int hSCManager,
|
unsigned int hSCManager,
|
||||||
unsigned int *hLock)
|
unsigned int *hLock)
|
||||||
{
|
{
|
||||||
PMANAGER_HANDLE hMgr;
|
PMANAGER_HANDLE hMgr;
|
||||||
|
|
||||||
DPRINT("ScmrLockServiceDatabase() called\n");
|
DPRINT("ScmrLockServiceDatabase() called\n");
|
||||||
|
|
||||||
*hLock = 0;
|
*hLock = 0;
|
||||||
|
|
||||||
hMgr = (PMANAGER_HANDLE)hSCManager;
|
hMgr = (PMANAGER_HANDLE)hSCManager;
|
||||||
if (hMgr->Handle.Tag != MANAGER_TAG)
|
if (hMgr->Handle.Tag != MANAGER_TAG)
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
|
|
||||||
if (!RtlAreAllAccessesGranted(hMgr->Handle.DesiredAccess,
|
if (!RtlAreAllAccessesGranted(hMgr->Handle.DesiredAccess,
|
||||||
SC_MANAGER_LOCK))
|
SC_MANAGER_LOCK))
|
||||||
return ERROR_ACCESS_DENIED;
|
return ERROR_ACCESS_DENIED;
|
||||||
|
|
||||||
/* FIXME: Lock the database */
|
/* FIXME: Lock the database */
|
||||||
*hLock = 0x12345678; /* Dummy! */
|
*hLock = 0x12345678; /* Dummy! */
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -384,8 +384,8 @@ ScmrLockServiceDatabase(handle_t BindingHandle,
|
||||||
unsigned long
|
unsigned long
|
||||||
ScmrQueryServiceObjectSecurity(handle_t BindingHandle)
|
ScmrQueryServiceObjectSecurity(handle_t BindingHandle)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmrQueryServiceSecurity() is unimplemented\n");
|
DPRINT1("ScmrQueryServiceSecurity() is unimplemented\n");
|
||||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -393,8 +393,8 @@ ScmrQueryServiceObjectSecurity(handle_t BindingHandle)
|
||||||
unsigned long
|
unsigned long
|
||||||
ScmrSetServiceObjectSecurity(handle_t BindingHandle)
|
ScmrSetServiceObjectSecurity(handle_t BindingHandle)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmrSetServiceSecurity() is unimplemented\n");
|
DPRINT1("ScmrSetServiceSecurity() is unimplemented\n");
|
||||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -404,36 +404,38 @@ ScmrQueryServiceStatus(handle_t BindingHandle,
|
||||||
unsigned int hService,
|
unsigned int hService,
|
||||||
LPSERVICE_STATUS lpServiceStatus)
|
LPSERVICE_STATUS lpServiceStatus)
|
||||||
{
|
{
|
||||||
PSERVICE_HANDLE hSvc;
|
PSERVICE_HANDLE hSvc;
|
||||||
PSERVICE lpService;
|
PSERVICE lpService;
|
||||||
|
|
||||||
DPRINT("ScmrQueryServiceStatus() called\n");
|
DPRINT("ScmrQueryServiceStatus() called\n");
|
||||||
|
|
||||||
hSvc = (PSERVICE_HANDLE)hService;
|
hSvc = (PSERVICE_HANDLE)hService;
|
||||||
if (hSvc->Handle.Tag != SERVICE_TAG)
|
if (hSvc->Handle.Tag != SERVICE_TAG)
|
||||||
{
|
{
|
||||||
DPRINT1("Invalid handle tag!\n");
|
DPRINT1("Invalid handle tag!\n");
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess,
|
if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess,
|
||||||
SERVICE_QUERY_STATUS))
|
SERVICE_QUERY_STATUS))
|
||||||
{
|
{
|
||||||
DPRINT1("Insufficient access rights! 0x%lx\n", hSvc->Handle.DesiredAccess);
|
DPRINT1("Insufficient access rights! 0x%lx\n", hSvc->Handle.DesiredAccess);
|
||||||
return ERROR_ACCESS_DENIED;
|
return ERROR_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
lpService = hSvc->ServiceEntry;
|
lpService = hSvc->ServiceEntry;
|
||||||
if (lpService == NULL)
|
if (lpService == NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("lpService == NULL!\n");
|
DPRINT1("lpService == NULL!\n");
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return service status information */
|
/* Return service status information */
|
||||||
RtlCopyMemory(lpServiceStatus, &lpService->Status, sizeof(SERVICE_STATUS));
|
RtlCopyMemory(lpServiceStatus,
|
||||||
|
&lpService->Status,
|
||||||
|
sizeof(SERVICE_STATUS));
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -441,9 +443,9 @@ ScmrQueryServiceStatus(handle_t BindingHandle,
|
||||||
unsigned long
|
unsigned long
|
||||||
ScmrSetServiceStatus(handle_t BindingHandle)
|
ScmrSetServiceStatus(handle_t BindingHandle)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmrSetServiceStatus() is unimplemented\n");
|
DPRINT1("ScmrSetServiceStatus() is unimplemented\n");
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -452,9 +454,9 @@ unsigned long
|
||||||
ScmrUnlockServiceDatabase(handle_t BindingHandle,
|
ScmrUnlockServiceDatabase(handle_t BindingHandle,
|
||||||
unsigned int hLock)
|
unsigned int hLock)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmrUnlockServiceDatabase() called\n");
|
DPRINT1("ScmrUnlockServiceDatabase() called\n");
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -463,9 +465,9 @@ unsigned long
|
||||||
ScmrNotifyBootConfigStatus(handle_t BindingHandle,
|
ScmrNotifyBootConfigStatus(handle_t BindingHandle,
|
||||||
unsigned long BootAcceptable)
|
unsigned long BootAcceptable)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmrNotifyBootConfigStatus() called\n");
|
DPRINT1("ScmrNotifyBootConfigStatus() called\n");
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -729,40 +731,40 @@ ScmrOpenSCManagerW(handle_t BindingHandle,
|
||||||
unsigned long dwDesiredAccess,
|
unsigned long dwDesiredAccess,
|
||||||
unsigned int *hScm)
|
unsigned int *hScm)
|
||||||
{
|
{
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
SC_HANDLE hHandle;
|
SC_HANDLE hHandle;
|
||||||
|
|
||||||
DPRINT("ScmrOpenSCManagerW() called\n");
|
DPRINT("ScmrOpenSCManagerW() called\n");
|
||||||
DPRINT("lpMachineName = %p\n", lpMachineName);
|
DPRINT("lpMachineName = %p\n", lpMachineName);
|
||||||
DPRINT("lpMachineName: %S\n", lpMachineName);
|
DPRINT("lpMachineName: %S\n", lpMachineName);
|
||||||
DPRINT("lpDataBaseName = %p\n", lpDatabaseName);
|
DPRINT("lpDataBaseName = %p\n", lpDatabaseName);
|
||||||
DPRINT("lpDataBaseName: %S\n", lpDatabaseName);
|
DPRINT("lpDataBaseName: %S\n", lpDatabaseName);
|
||||||
DPRINT("dwDesiredAccess = %x\n", dwDesiredAccess);
|
DPRINT("dwDesiredAccess = %x\n", dwDesiredAccess);
|
||||||
|
|
||||||
dwError = ScmCreateManagerHandle(lpDatabaseName,
|
dwError = ScmCreateManagerHandle(lpDatabaseName,
|
||||||
&hHandle);
|
&hHandle);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmCreateManagerHandle() failed (Error %lu)\n", dwError);
|
DPRINT1("ScmCreateManagerHandle() failed (Error %lu)\n", dwError);
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the desired access */
|
/* Check the desired access */
|
||||||
dwError = ScmCheckAccess(hHandle,
|
dwError = ScmCheckAccess(hHandle,
|
||||||
dwDesiredAccess | SC_MANAGER_CONNECT);
|
dwDesiredAccess | SC_MANAGER_CONNECT);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmCheckAccess() failed (Error %lu)\n", dwError);
|
DPRINT1("ScmCheckAccess() failed (Error %lu)\n", dwError);
|
||||||
HeapFree(GetProcessHeap(), 0, hHandle);
|
HeapFree(GetProcessHeap(), 0, hHandle);
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
*hScm = (unsigned int)hHandle;
|
*hScm = (unsigned int)hHandle;
|
||||||
DPRINT("*hScm = %x\n", *hScm);
|
DPRINT("*hScm = %x\n", *hScm);
|
||||||
|
|
||||||
DPRINT("ScmrOpenSCManagerW() done\n");
|
DPRINT("ScmrOpenSCManagerW() done\n");
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -774,59 +776,59 @@ ScmrOpenServiceW(handle_t BindingHandle,
|
||||||
unsigned long dwDesiredAccess,
|
unsigned long dwDesiredAccess,
|
||||||
unsigned int *hService)
|
unsigned int *hService)
|
||||||
{
|
{
|
||||||
PSERVICE lpService;
|
PSERVICE lpService;
|
||||||
PMANAGER_HANDLE hManager;
|
PMANAGER_HANDLE hManager;
|
||||||
SC_HANDLE hHandle;
|
SC_HANDLE hHandle;
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
|
|
||||||
DPRINT("ScmrOpenServiceW() called\n");
|
DPRINT("ScmrOpenServiceW() called\n");
|
||||||
DPRINT("hSCManager = %x\n", hSCManager);
|
DPRINT("hSCManager = %x\n", hSCManager);
|
||||||
DPRINT("lpServiceName = %p\n", lpServiceName);
|
DPRINT("lpServiceName = %p\n", lpServiceName);
|
||||||
DPRINT("lpServiceName: %S\n", lpServiceName);
|
DPRINT("lpServiceName: %S\n", lpServiceName);
|
||||||
DPRINT("dwDesiredAccess = %x\n", dwDesiredAccess);
|
DPRINT("dwDesiredAccess = %x\n", dwDesiredAccess);
|
||||||
|
|
||||||
hManager = (PMANAGER_HANDLE)hSCManager;
|
hManager = (PMANAGER_HANDLE)hSCManager;
|
||||||
if (hManager->Handle.Tag != MANAGER_TAG)
|
if (hManager->Handle.Tag != MANAGER_TAG)
|
||||||
{
|
{
|
||||||
DPRINT1("Invalid manager handle!\n");
|
DPRINT1("Invalid manager handle!\n");
|
||||||
return ERROR_INVALID_HANDLE;
|
return ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Lock the service list */
|
/* FIXME: Lock the service list */
|
||||||
|
|
||||||
/* Get service database entry */
|
/* Get service database entry */
|
||||||
lpService = ScmGetServiceEntryByName(lpServiceName);
|
lpService = ScmGetServiceEntryByName(lpServiceName);
|
||||||
if (lpService == NULL)
|
if (lpService == NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("Could not find a service!\n");
|
DPRINT1("Could not find a service!\n");
|
||||||
return ERROR_SERVICE_DOES_NOT_EXIST;
|
return ERROR_SERVICE_DOES_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a service handle */
|
/* Create a service handle */
|
||||||
dwError = ScmCreateServiceHandle(lpService,
|
dwError = ScmCreateServiceHandle(lpService,
|
||||||
&hHandle);
|
&hHandle);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmCreateServiceHandle() failed (Error %lu)\n", dwError);
|
DPRINT1("ScmCreateServiceHandle() failed (Error %lu)\n", dwError);
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the desired access */
|
/* Check the desired access */
|
||||||
dwError = ScmCheckAccess(hHandle,
|
dwError = ScmCheckAccess(hHandle,
|
||||||
dwDesiredAccess);
|
dwDesiredAccess);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmCheckAccess() failed (Error %lu)\n", dwError);
|
DPRINT1("ScmCheckAccess() failed (Error %lu)\n", dwError);
|
||||||
HeapFree(GetProcessHeap(), 0, hHandle);
|
HeapFree(GetProcessHeap(), 0, hHandle);
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
*hService = (unsigned int)hHandle;
|
*hService = (unsigned int)hHandle;
|
||||||
DPRINT("*hService = %x\n", *hService);
|
DPRINT("*hService = %x\n", *hService);
|
||||||
|
|
||||||
DPRINT("ScmrOpenServiceW() done\n");
|
DPRINT("ScmrOpenServiceW() done\n");
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -839,33 +841,33 @@ ScmrOpenSCManagerA(handle_t BindingHandle,
|
||||||
unsigned long dwDesiredAccess,
|
unsigned long dwDesiredAccess,
|
||||||
unsigned int *hScm)
|
unsigned int *hScm)
|
||||||
{
|
{
|
||||||
UNICODE_STRING MachineName;
|
UNICODE_STRING MachineName;
|
||||||
UNICODE_STRING DatabaseName;
|
UNICODE_STRING DatabaseName;
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
|
|
||||||
DPRINT("ScmrOpenSCManagerA() called\n");
|
DPRINT("ScmrOpenSCManagerA() called\n");
|
||||||
|
|
||||||
if (lpMachineName)
|
if (lpMachineName)
|
||||||
RtlCreateUnicodeStringFromAsciiz(&MachineName,
|
RtlCreateUnicodeStringFromAsciiz(&MachineName,
|
||||||
lpMachineName);
|
lpMachineName);
|
||||||
|
|
||||||
if (lpDatabaseName)
|
if (lpDatabaseName)
|
||||||
RtlCreateUnicodeStringFromAsciiz(&DatabaseName,
|
RtlCreateUnicodeStringFromAsciiz(&DatabaseName,
|
||||||
lpDatabaseName);
|
lpDatabaseName);
|
||||||
|
|
||||||
dwError = ScmrOpenSCManagerW(BindingHandle,
|
dwError = ScmrOpenSCManagerW(BindingHandle,
|
||||||
lpMachineName ? MachineName.Buffer : NULL,
|
lpMachineName ? MachineName.Buffer : NULL,
|
||||||
lpDatabaseName ? DatabaseName.Buffer : NULL,
|
lpDatabaseName ? DatabaseName.Buffer : NULL,
|
||||||
dwDesiredAccess,
|
dwDesiredAccess,
|
||||||
hScm);
|
hScm);
|
||||||
|
|
||||||
if (lpMachineName)
|
if (lpMachineName)
|
||||||
RtlFreeUnicodeString(&MachineName);
|
RtlFreeUnicodeString(&MachineName);
|
||||||
|
|
||||||
if (lpDatabaseName)
|
if (lpDatabaseName)
|
||||||
RtlFreeUnicodeString(&DatabaseName);
|
RtlFreeUnicodeString(&DatabaseName);
|
||||||
|
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -877,36 +879,36 @@ ScmrOpenServiceA(handle_t BindingHandle,
|
||||||
unsigned long dwDesiredAccess,
|
unsigned long dwDesiredAccess,
|
||||||
unsigned int *hService)
|
unsigned int *hService)
|
||||||
{
|
{
|
||||||
UNICODE_STRING ServiceName;
|
UNICODE_STRING ServiceName;
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
|
|
||||||
DPRINT("ScmrOpenServiceA() called\n");
|
DPRINT("ScmrOpenServiceA() called\n");
|
||||||
|
|
||||||
RtlCreateUnicodeStringFromAsciiz(&ServiceName,
|
RtlCreateUnicodeStringFromAsciiz(&ServiceName,
|
||||||
lpServiceName);
|
lpServiceName);
|
||||||
|
|
||||||
dwError = ScmrOpenServiceW(BindingHandle,
|
dwError = ScmrOpenServiceW(BindingHandle,
|
||||||
hSCManager,
|
hSCManager,
|
||||||
ServiceName.Buffer,
|
ServiceName.Buffer,
|
||||||
dwDesiredAccess,
|
dwDesiredAccess,
|
||||||
hService);
|
hService);
|
||||||
|
|
||||||
RtlFreeUnicodeString(&ServiceName);
|
RtlFreeUnicodeString(&ServiceName);
|
||||||
|
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
|
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
|
||||||
{
|
{
|
||||||
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
|
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, ptr);
|
HeapFree(GetProcessHeap(), 0, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -47,14 +47,14 @@ VOID
|
||||||
PrintString(LPCSTR fmt, ...)
|
PrintString(LPCSTR fmt, ...)
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
CHAR buffer[512];
|
CHAR buffer[512];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsprintf(buffer, fmt, ap);
|
vsprintf(buffer, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
OutputDebugStringA(buffer);
|
OutputDebugStringA(buffer);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,46 +62,46 @@ PrintString(LPCSTR fmt, ...)
|
||||||
BOOL
|
BOOL
|
||||||
ScmCreateStartEvent(PHANDLE StartEvent)
|
ScmCreateStartEvent(PHANDLE StartEvent)
|
||||||
{
|
{
|
||||||
HANDLE hEvent;
|
HANDLE hEvent;
|
||||||
|
|
||||||
hEvent = CreateEvent(NULL,
|
hEvent = CreateEvent(NULL,
|
||||||
TRUE,
|
TRUE,
|
||||||
FALSE,
|
|
||||||
TEXT("SvcctrlStartEvent_A3725DX"));
|
|
||||||
if (hEvent == NULL)
|
|
||||||
{
|
|
||||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
|
||||||
{
|
|
||||||
hEvent = OpenEvent(EVENT_ALL_ACCESS,
|
|
||||||
FALSE,
|
FALSE,
|
||||||
TEXT("SvcctrlStartEvent_A3725DX"));
|
TEXT("SvcctrlStartEvent_A3725DX"));
|
||||||
if (hEvent == NULL)
|
if (hEvent == NULL)
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||||
|
{
|
||||||
|
hEvent = OpenEvent(EVENT_ALL_ACCESS,
|
||||||
|
FALSE,
|
||||||
|
TEXT("SvcctrlStartEvent_A3725DX"));
|
||||||
|
if (hEvent == NULL)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*StartEvent = hEvent;
|
*StartEvent = hEvent;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
ScmNamedPipeHandleRequest(PVOID Request,
|
ScmNamedPipeHandleRequest(PVOID Request,
|
||||||
DWORD RequestSize,
|
DWORD RequestSize,
|
||||||
PVOID Reply,
|
PVOID Reply,
|
||||||
LPDWORD ReplySize)
|
LPDWORD ReplySize)
|
||||||
{
|
{
|
||||||
DbgPrint("SCM READ: %s\n", Request);
|
DbgPrint("SCM READ: %s\n", Request);
|
||||||
|
|
||||||
*ReplySize = 0;
|
*ReplySize = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,38 +113,47 @@ ScmNamedPipeThread(LPVOID Context)
|
||||||
DWORD cbReplyBytes;
|
DWORD cbReplyBytes;
|
||||||
DWORD cbBytesRead;
|
DWORD cbBytesRead;
|
||||||
DWORD cbWritten;
|
DWORD cbWritten;
|
||||||
BOOL fSuccess;
|
BOOL bSuccess;
|
||||||
HANDLE hPipe;
|
HANDLE hPipe;
|
||||||
|
|
||||||
hPipe = (HANDLE)Context;
|
hPipe = (HANDLE)Context;
|
||||||
|
|
||||||
DPRINT("ScmNamedPipeThread(%x) - Accepting SCM commands through named pipe\n", hPipe);
|
DPRINT("ScmNamedPipeThread(%x) - Accepting SCM commands through named pipe\n", hPipe);
|
||||||
|
|
||||||
for (;;) {
|
for (;;)
|
||||||
fSuccess = ReadFile(hPipe,
|
{
|
||||||
|
bSuccess = ReadFile(hPipe,
|
||||||
&chRequest,
|
&chRequest,
|
||||||
PIPE_BUFSIZE,
|
PIPE_BUFSIZE,
|
||||||
&cbBytesRead,
|
&cbBytesRead,
|
||||||
NULL);
|
NULL);
|
||||||
if (!fSuccess || cbBytesRead == 0) {
|
if (!bSuccess || cbBytesRead == 0)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ScmNamedPipeHandleRequest(&chRequest, cbBytesRead, &chReply, &cbReplyBytes)) {
|
|
||||||
fSuccess = WriteFile(hPipe,
|
if (ScmNamedPipeHandleRequest(&chRequest, cbBytesRead, &chReply, &cbReplyBytes))
|
||||||
|
{
|
||||||
|
bSuccess = WriteFile(hPipe,
|
||||||
&chReply,
|
&chReply,
|
||||||
cbReplyBytes,
|
cbReplyBytes,
|
||||||
&cbWritten,
|
&cbWritten,
|
||||||
NULL);
|
NULL);
|
||||||
if (!fSuccess || cbReplyBytes != cbWritten) {
|
if (!bSuccess || cbReplyBytes != cbWritten)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("ScmNamedPipeThread(%x) - Disconnecting named pipe connection\n", hPipe);
|
DPRINT("ScmNamedPipeThread(%x) - Disconnecting named pipe connection\n", hPipe);
|
||||||
|
|
||||||
FlushFileBuffers(hPipe);
|
FlushFileBuffers(hPipe);
|
||||||
DisconnectNamedPipe(hPipe);
|
DisconnectNamedPipe(hPipe);
|
||||||
CloseHandle(hPipe);
|
CloseHandle(hPipe);
|
||||||
|
|
||||||
DPRINT("ScmNamedPipeThread(%x) - Done.\n", hPipe);
|
DPRINT("ScmNamedPipeThread(%x) - Done.\n", hPipe);
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +162,7 @@ BOOL
|
||||||
ScmCreateNamedPipe(VOID)
|
ScmCreateNamedPipe(VOID)
|
||||||
{
|
{
|
||||||
DWORD dwThreadId;
|
DWORD dwThreadId;
|
||||||
BOOL fConnected;
|
BOOL bConnected;
|
||||||
HANDLE hThread;
|
HANDLE hThread;
|
||||||
HANDLE hPipe;
|
HANDLE hPipe;
|
||||||
|
|
||||||
|
@ -167,17 +176,19 @@ ScmCreateNamedPipe(VOID)
|
||||||
PIPE_BUFSIZE,
|
PIPE_BUFSIZE,
|
||||||
PIPE_TIMEOUT,
|
PIPE_TIMEOUT,
|
||||||
NULL);
|
NULL);
|
||||||
if (hPipe == INVALID_HANDLE_VALUE) {
|
if (hPipe == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
DPRINT("CreateNamedPipe() failed (%d)\n", GetLastError());
|
DPRINT("CreateNamedPipe() failed (%d)\n", GetLastError());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("CreateNamedPipe() - calling ConnectNamedPipe(%x)\n", hPipe);
|
DPRINT("CreateNamedPipe() - calling ConnectNamedPipe(%x)\n", hPipe);
|
||||||
fConnected = ConnectNamedPipe(hPipe,
|
bConnected = ConnectNamedPipe(hPipe,
|
||||||
NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
|
NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
|
||||||
DPRINT("CreateNamedPipe() - ConnectNamedPipe() returned %d\n", fConnected);
|
DPRINT("CreateNamedPipe() - ConnectNamedPipe() returned %d\n", bConnected);
|
||||||
|
|
||||||
if (fConnected) {
|
if (bConnected)
|
||||||
|
{
|
||||||
DPRINT("Pipe connected\n");
|
DPRINT("Pipe connected\n");
|
||||||
hThread = CreateThread(NULL,
|
hThread = CreateThread(NULL,
|
||||||
0,
|
0,
|
||||||
|
@ -185,14 +196,17 @@ ScmCreateNamedPipe(VOID)
|
||||||
(LPVOID)hPipe,
|
(LPVOID)hPipe,
|
||||||
0,
|
0,
|
||||||
&dwThreadId);
|
&dwThreadId);
|
||||||
if (!hThread) {
|
if (!hThread)
|
||||||
|
{
|
||||||
DPRINT("Could not create thread (%d)\n", GetLastError());
|
DPRINT("Could not create thread (%d)\n", GetLastError());
|
||||||
DisconnectNamedPipe(hPipe);
|
DisconnectNamedPipe(hPipe);
|
||||||
CloseHandle(hPipe);
|
CloseHandle(hPipe);
|
||||||
DPRINT("CreateNamedPipe() - returning FALSE\n");
|
DPRINT("CreateNamedPipe() - returning FALSE\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
DPRINT("Pipe not connected\n");
|
DPRINT("Pipe not connected\n");
|
||||||
CloseHandle(hPipe);
|
CloseHandle(hPipe);
|
||||||
DPRINT("CreateNamedPipe() - returning FALSE\n");
|
DPRINT("CreateNamedPipe() - returning FALSE\n");
|
||||||
|
@ -210,10 +224,12 @@ ScmNamedPipeListenerThread(LPVOID Context)
|
||||||
DPRINT("ScmNamedPipeListenerThread(%x) - aka SCM.\n", Context);
|
DPRINT("ScmNamedPipeListenerThread(%x) - aka SCM.\n", Context);
|
||||||
|
|
||||||
// hPipe = (HANDLE)Context;
|
// hPipe = (HANDLE)Context;
|
||||||
for (;;) {
|
for (;;)
|
||||||
|
{
|
||||||
DPRINT("SCM: Waiting for new connection on named pipe...\n");
|
DPRINT("SCM: Waiting for new connection on named pipe...\n");
|
||||||
/* Create named pipe */
|
/* Create named pipe */
|
||||||
if (!ScmCreateNamedPipe()) {
|
if (!ScmCreateNamedPipe())
|
||||||
|
{
|
||||||
DPRINT1("\nSCM: Failed to create named pipe\n");
|
DPRINT1("\nSCM: Failed to create named pipe\n");
|
||||||
break;
|
break;
|
||||||
//ExitThread(0);
|
//ExitThread(0);
|
||||||
|
@ -229,44 +245,44 @@ ScmNamedPipeListenerThread(LPVOID Context)
|
||||||
BOOL
|
BOOL
|
||||||
StartScmNamedPipeThreadListener(VOID)
|
StartScmNamedPipeThreadListener(VOID)
|
||||||
{
|
{
|
||||||
DWORD dwThreadId;
|
DWORD dwThreadId;
|
||||||
HANDLE hThread;
|
HANDLE hThread;
|
||||||
|
|
||||||
hThread = CreateThread(NULL,
|
hThread = CreateThread(NULL,
|
||||||
0,
|
0,
|
||||||
ScmNamedPipeListenerThread,
|
ScmNamedPipeListenerThread,
|
||||||
NULL, /*(LPVOID)hPipe,*/
|
NULL, /*(LPVOID)hPipe,*/
|
||||||
0,
|
0,
|
||||||
&dwThreadId);
|
&dwThreadId);
|
||||||
if (!hThread)
|
if (!hThread)
|
||||||
{
|
{
|
||||||
DPRINT1("SERVICES: Could not create thread (Status %lx)\n", GetLastError());
|
DPRINT1("SERVICES: Could not create thread (Status %lx)\n", GetLastError());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID FASTCALL
|
VOID FASTCALL
|
||||||
AcquireLoadDriverPrivilege(VOID)
|
AcquireLoadDriverPrivilege(VOID)
|
||||||
{
|
{
|
||||||
HANDLE hToken;
|
HANDLE hToken;
|
||||||
TOKEN_PRIVILEGES tkp;
|
TOKEN_PRIVILEGES tkp;
|
||||||
|
|
||||||
/* Get a token for this process */
|
/* Get a token for this process */
|
||||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
|
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
|
||||||
{
|
{
|
||||||
/* Get the LUID for the debug privilege */
|
/* Get the LUID for the debug privilege */
|
||||||
LookupPrivilegeValue(NULL, SE_LOAD_DRIVER_NAME, &tkp.Privileges[0].Luid);
|
LookupPrivilegeValue(NULL, SE_LOAD_DRIVER_NAME, &tkp.Privileges[0].Luid);
|
||||||
|
|
||||||
/* One privilege to set */
|
/* One privilege to set */
|
||||||
tkp.PrivilegeCount = 1;
|
tkp.PrivilegeCount = 1;
|
||||||
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||||
|
|
||||||
/* Get the debug privilege for this process */
|
/* Get the debug privilege for this process */
|
||||||
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
|
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,79 +292,79 @@ WinMain(HINSTANCE hInstance,
|
||||||
LPSTR lpCmdLine,
|
LPSTR lpCmdLine,
|
||||||
int nShowCmd)
|
int nShowCmd)
|
||||||
{
|
{
|
||||||
HANDLE hScmStartEvent;
|
HANDLE hScmStartEvent;
|
||||||
HANDLE hEvent;
|
HANDLE hEvent;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("SERVICES: Service Control Manager\n");
|
DPRINT("SERVICES: Service Control Manager\n");
|
||||||
|
|
||||||
/* Acquire privileges to load drivers */
|
/* Acquire privileges to load drivers */
|
||||||
AcquireLoadDriverPrivilege();
|
AcquireLoadDriverPrivilege();
|
||||||
|
|
||||||
/* Create start event */
|
/* Create start event */
|
||||||
if (!ScmCreateStartEvent(&hScmStartEvent))
|
if (!ScmCreateStartEvent(&hScmStartEvent))
|
||||||
{
|
{
|
||||||
DPRINT1("SERVICES: Failed to create start event\n");
|
DPRINT1("SERVICES: Failed to create start event\n");
|
||||||
ExitThread(0);
|
ExitThread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("SERVICES: created start event with handle %x.\n", hScmStartEvent);
|
DPRINT("SERVICES: created start event with handle %x.\n", hScmStartEvent);
|
||||||
|
|
||||||
// ScmInitThreadManager();
|
// ScmInitThreadManager();
|
||||||
|
|
||||||
/* FIXME: more initialization */
|
/* FIXME: more initialization */
|
||||||
|
|
||||||
|
|
||||||
/* Create the service database */
|
/* Create the service database */
|
||||||
Status = ScmCreateServiceDataBase();
|
Status = ScmCreateServiceDataBase();
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("SERVICES: failed to create SCM database (Status %lx)\n", Status);
|
DPRINT1("SERVICES: failed to create SCM database (Status %lx)\n", Status);
|
||||||
ExitThread(0);
|
ExitThread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update service database */
|
/* Update service database */
|
||||||
ScmGetBootAndSystemDriverState();
|
ScmGetBootAndSystemDriverState();
|
||||||
|
|
||||||
/* Start the RPC server */
|
/* Start the RPC server */
|
||||||
ScmStartRpcServer();
|
ScmStartRpcServer();
|
||||||
|
|
||||||
/* Register service process with CSRSS */
|
/* Register service process with CSRSS */
|
||||||
// RegisterServicesProcess(GetCurrentProcessId());
|
// RegisterServicesProcess(GetCurrentProcessId());
|
||||||
|
|
||||||
DPRINT("SERVICES: Initialized.\n");
|
DPRINT("SERVICES: Initialized.\n");
|
||||||
|
|
||||||
/* Signal start event */
|
/* Signal start event */
|
||||||
SetEvent(hScmStartEvent);
|
SetEvent(hScmStartEvent);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* FIXME: register event handler (used for system shutdown) */
|
/* FIXME: register event handler (used for system shutdown) */
|
||||||
SetConsoleCtrlHandler(...);
|
SetConsoleCtrlHandler(...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Start auto-start services */
|
/* Start auto-start services */
|
||||||
ScmAutoStartServices();
|
ScmAutoStartServices();
|
||||||
|
|
||||||
/* FIXME: more to do ? */
|
/* FIXME: more to do ? */
|
||||||
|
|
||||||
|
|
||||||
DPRINT("SERVICES: Running.\n");
|
DPRINT("SERVICES: Running.\n");
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
WaitForSingleObject(hEvent, INFINITE);
|
WaitForSingleObject(hEvent, INFINITE);
|
||||||
#else
|
#else
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
NtYieldExecution();
|
NtYieldExecution();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DPRINT("SERVICES: Finished.\n");
|
DPRINT("SERVICES: Finished.\n");
|
||||||
|
|
||||||
ExitThread(0);
|
ExitThread(0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue