📄 rpcserver.c
字号:
unsigned char *lpServiceArgBuffer,
unsigned long cbBufSize)
{
DWORD dwError = ERROR_SUCCESS;
PSERVICE_HANDLE hSvc;
PSERVICE lpService = NULL;
DPRINT("ScmrStartServiceW() called\n");
if (ScmShutdown)
return ERROR_SHUTDOWN_IN_PROGRESS;
hSvc = (PSERVICE_HANDLE)hService;
if (hSvc->Handle.Tag != SERVICE_TAG)
{
DPRINT1("Invalid handle tag!\n");
return ERROR_INVALID_HANDLE;
}
if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess,
SERVICE_START))
{
DPRINT1("Insufficient access rights! 0x%lx\n", hSvc->Handle.DesiredAccess);
return ERROR_ACCESS_DENIED;
}
lpService = hSvc->ServiceEntry;
if (lpService == NULL)
{
DPRINT1("lpService == NULL!\n");
return ERROR_INVALID_HANDLE;
}
if (lpService->dwStartType == SERVICE_DISABLED)
return ERROR_SERVICE_DISABLED;
if (lpService->bDeleted)
return ERROR_SERVICE_MARKED_FOR_DELETE;
/* Start the service */
dwError = ScmStartService(lpService, (LPWSTR)lpServiceArgBuffer);
return dwError;
}
/* Function 20 */
unsigned long
ScmrGetServiceDisplayNameW(handle_t BindingHandle,
unsigned int hSCManager,
wchar_t *lpServiceName,
wchar_t *lpDisplayName, /* [out, unique] */
unsigned long *lpcchBuffer)
{
// PMANAGER_HANDLE hManager;
PSERVICE lpService;
DWORD dwLength;
DWORD dwError;
DPRINT("ScmrGetServiceDisplayNameW() called\n");
DPRINT("hSCManager = %x\n", hSCManager);
DPRINT("lpServiceName: %S\n", lpServiceName);
DPRINT("lpDisplayName: %p\n", lpDisplayName);
DPRINT("*lpcchBuffer: %lu\n", *lpcchBuffer);
// hManager = (PMANAGER_HANDLE)hSCManager;
// if (hManager->Handle.Tag != MANAGER_TAG)
// {
// DPRINT1("Invalid manager handle!\n");
// return ERROR_INVALID_HANDLE;
// }
/* Get service database entry */
lpService = ScmGetServiceEntryByName(lpServiceName);
if (lpService == NULL)
{
DPRINT1("Could not find a service!\n");
return ERROR_SERVICE_DOES_NOT_EXIST;
}
dwLength = wcslen(lpService->lpDisplayName) + 1;
if (lpDisplayName != NULL &&
*lpcchBuffer >= dwLength)
{
wcscpy(lpDisplayName, lpService->lpDisplayName);
}
dwError = (*lpcchBuffer > dwLength) ? ERROR_SUCCESS : ERROR_INSUFFICIENT_BUFFER;
*lpcchBuffer = dwLength;
return dwError;
}
/* Function 21 */
unsigned long
ScmrGetServiceKeyNameW(handle_t BindingHandle,
unsigned int hSCManager,
wchar_t *lpDisplayName,
wchar_t *lpServiceName, /* [out, unique] */
unsigned long *lpcchBuffer)
{
// PMANAGER_HANDLE hManager;
PSERVICE lpService;
DWORD dwLength;
DWORD dwError;
DPRINT("ScmrGetServiceKeyNameW() called\n");
DPRINT("hSCManager = %x\n", hSCManager);
DPRINT("lpDisplayName: %S\n", lpDisplayName);
DPRINT("lpServiceName: %p\n", lpServiceName);
DPRINT("*lpcchBuffer: %lu\n", *lpcchBuffer);
// hManager = (PMANAGER_HANDLE)hSCManager;
// if (hManager->Handle.Tag != MANAGER_TAG)
// {
// DPRINT1("Invalid manager handle!\n");
// return ERROR_INVALID_HANDLE;
// }
/* Get service database entry */
lpService = ScmGetServiceEntryByDisplayName(lpDisplayName);
if (lpService == NULL)
{
DPRINT1("Could not find a service!\n");
return ERROR_SERVICE_DOES_NOT_EXIST;
}
dwLength = wcslen(lpService->lpServiceName) + 1;
if (lpServiceName != NULL &&
*lpcchBuffer >= dwLength)
{
wcscpy(lpServiceName, lpService->lpServiceName);
}
dwError = (*lpcchBuffer > dwLength) ? ERROR_SUCCESS : ERROR_INSUFFICIENT_BUFFER;
*lpcchBuffer = dwLength;
return dwError;
}
/* Function 22 */
unsigned long
ScmrSetServiceBitsA(handle_t BindingHandle,
unsigned long hServiceStatus,
unsigned long dwServiceBits,
unsigned long bSetBitsOn,
unsigned long bUpdateImmediately,
char *lpString)
{
DPRINT1("ScmrSetServiceBitsA() is unimplemented\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 23 */
unsigned long
ScmrChangeServiceConfigA(handle_t BiningHandle,
unsigned int hService,
unsigned long dwServiceType,
unsigned long dwStartType,
unsigned long dwErrorControl,
char *lpBinaryPathName,
char *lpLoadOrderGroup,
unsigned long *lpdwTagId,
char *lpDependencies,
unsigned long dwDependenciesLength,
char *lpServiceStartName,
char *lpPassword,
unsigned long dwPasswordLength,
char *lpDisplayName)
{
DPRINT1("ScmrChangeServiceConfigA() is unimplemented\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 24 */
unsigned long
ScmrCreateServiceA(handle_t BindingHandle,
unsigned int hSCManager,
char *lpServiceName,
char *lpDisplayName,
unsigned long dwDesiredAccess,
unsigned long dwServiceType,
unsigned long dwStartType,
unsigned long dwErrorControl,
char *lpBinaryPathName,
char *lpLoadOrderGroup,
unsigned long *lpdwTagId, /* in, out */
char *lpDependencies,
unsigned long dwDependenciesLength,
char *lpServiceStartName,
char *lpPassword,
unsigned long dwPasswordLength,
unsigned int *hService) /* out */
{
DPRINT1("ScmrCreateServiceA() is unimplemented\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 25 */
unsigned long
ScmrEnumDependentServicesA(handle_t BindingHandle,
unsigned int hService,
unsigned long dwServiceState,
unsigned char *lpServices,
unsigned long cbBufSize,
unsigned long *pcbBytesNeeded,
unsigned long *lpServicesReturned)
{
DPRINT1("ScmrEnumDependentServicesA() is unimplemented\n");
*pcbBytesNeeded = 0;
*lpServicesReturned = 0;
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 26 */
unsigned long
ScmrEnumServicesStatusA(handle_t BindingHandle,
unsigned int hSCManager,
unsigned long dwServiceType,
unsigned long dwServiceState,
unsigned char *lpServices,
unsigned long dwBufSize,
unsigned long *pcbBytesNeeded,
unsigned long *lpServicesReturned,
unsigned long *lpResumeHandle)
{
DPRINT1("ScmrEnumServicesAtatusA() is unimplemented\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 27 */
unsigned long
ScmrOpenSCManagerA(handle_t BindingHandle,
char *lpMachineName,
char *lpDatabaseName,
unsigned long dwDesiredAccess,
unsigned int *hScm)
{
UNICODE_STRING MachineName;
UNICODE_STRING DatabaseName;
DWORD dwError;
DPRINT("ScmrOpenSCManagerA() called\n");
if (lpMachineName)
RtlCreateUnicodeStringFromAsciiz(&MachineName,
lpMachineName);
if (lpDatabaseName)
RtlCreateUnicodeStringFromAsciiz(&DatabaseName,
lpDatabaseName);
dwError = ScmrOpenSCManagerW(BindingHandle,
lpMachineName ? MachineName.Buffer : NULL,
lpDatabaseName ? DatabaseName.Buffer : NULL,
dwDesiredAccess,
hScm);
if (lpMachineName)
RtlFreeUnicodeString(&MachineName);
if (lpDatabaseName)
RtlFreeUnicodeString(&DatabaseName);
return dwError;
}
/* Function 28 */
unsigned int
ScmrOpenServiceA(handle_t BindingHandle,
unsigned int hSCManager,
char *lpServiceName,
unsigned long dwDesiredAccess,
unsigned int *hService)
{
UNICODE_STRING ServiceName;
DWORD dwError;
DPRINT("ScmrOpenServiceA() called\n");
RtlCreateUnicodeStringFromAsciiz(&ServiceName,
lpServiceName);
dwError = ScmrOpenServiceW(BindingHandle,
hSCManager,
ServiceName.Buffer,
dwDesiredAccess,
hService);
RtlFreeUnicodeString(&ServiceName);
return dwError;
}
/* Function 29 */
unsigned long
ScmrQueryServiceConfigA(handle_t BindingHandle,
unsigned int hService,
unsigned char *lpServiceConfig,
unsigned long cbBufSize,
unsigned long *pcbBytesNeeded)
{
DPRINT1("ScmrQueryServiceConfigA() is unimplemented\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 30 */
unsigned long
ScmrQueryServiceLockStatusA(handle_t BindingHandle,
unsigned int hSCManager,
unsigned char *lpLockStatus, /* [out, unique, size_is(cbBufSize)] */
unsigned long cbBufSize, /* [in] */
unsigned long *pcbBytesNeeded) /* [out] */
{
DPRINT1("ScmrQueryServiceLockStatusA() called\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 31 */
unsigned long
ScmrStartServiceA(handle_t BindingHandle,
unsigned int hService,
unsigned long dwNumServiceArgs,
unsigned char *lpServiceArgBuffer,
unsigned long cbBufSize)
{
DWORD dwError = ERROR_SUCCESS;
PSERVICE_HANDLE hSvc;
PSERVICE lpService = NULL;
DPRINT1("ScmrStartServiceA() called\n");
if (ScmShutdown)
return ERROR_SHUTDOWN_IN_PROGRESS;
hSvc = (PSERVICE_HANDLE)hService;
if (hSvc->Handle.Tag != SERVICE_TAG)
{
DPRINT1("Invalid handle tag!\n");
return ERROR_INVALID_HANDLE;
}
if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess,
SERVICE_START))
{
DPRINT1("Insufficient access rights! 0x%lx\n", hSvc->Handle.DesiredAccess);
return ERROR_ACCESS_DENIED;
}
lpService = hSvc->ServiceEntry;
if (lpService == NULL)
{
DPRINT1("lpService == NULL!\n");
return ERROR_INVALID_HANDLE;
}
if (lpService->dwStartType == SERVICE_DISABLED)
return ERROR_SERVICE_DISABLED;
if (lpService->bDeleted)
return ERROR_SERVICE_MARKED_FOR_DELETE;
/* FIXME: Convert argument vector to Unicode */
/* Start the service */
dwError = ScmStartService(lpService, NULL);
/* FIXME: Free argument vector */
return dwError;
}
/* Function 32 */
unsigned long
ScmrGetServiceDisplayNameA(handle_t BindingHandle,
unsigned int hSCManager,
char *lpServiceName,
char *lpDisplayName, /* [out, unique] */
unsigned long *lpcchBuffer)
{
DPRINT1("ScmrGetServiceDisplayNameA() is unimplemented\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 33 */
unsigned long
ScmrGetServiceKeyNameA(handle_t BindingHandle,
unsigned int hSCManager,
char *lpDisplayName,
char *lpServiceName, /* [out, unique] */
unsigned long *lpcchBuffer)
{
DPRINT1("ScmrGetServiceKeyNameA() is unimplemented\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 34 */
unsigned long
ScmrGetCurrentGroupStateW(handle_t BindingHandle)
{
DPRINT1("ScmrGetCurrentGroupStateW() is unimplemented\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 35 */
unsigned long
ScmrEnumServiceGroupW(handle_t BindingHandle)
{
DPRINT1("ScmrEnumServiceGroupW() is unimplemented\n");
return ERROR_CALL_NOT_IMPLEMENTED;
}
/* Function 36 */
unsigned long
ScmrChangeServiceConfig2A(handle_t BindingHandle,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -