[ADVAPI32]

- Implement AbortSystemShutdownW by a call to BaseAbortSystemShutdown.
- Implement InitiateSystemShutdownW by a call to BaseInitiateSystemShutdown.
- Implement InitiateSystemShutdownExW by a call to BaseInitiateSystemShutdownEx.
- Add RPC binding code for the winreg server (in winlogon.exe).

svn path=/trunk/; revision=70420
This commit is contained in:
Eric Kohl 2015-12-26 01:14:18 +00:00
parent 1ce137ac92
commit f32ee3e8ff
4 changed files with 263 additions and 115 deletions

View file

@ -14,7 +14,8 @@ include_directories(
add_rpc_files(client
${REACTOS_SOURCE_DIR}/include/reactos/idl/eventlogrpc.idl
${REACTOS_SOURCE_DIR}/include/reactos/idl/lsa.idl
${REACTOS_SOURCE_DIR}/include/reactos/idl/svcctl.idl)
${REACTOS_SOURCE_DIR}/include/reactos/idl/svcctl.idl
${REACTOS_SOURCE_DIR}/include/reactos/idl/winreg.idl)
list(APPEND SOURCE
misc/dllmain.c
@ -37,6 +38,7 @@ list(APPEND SOURCE
service/rpc.c
service/scm.c
service/sctrl.c
service/winreg.c
token/token.c
wine/cred.c
wine/crypt.c
@ -52,7 +54,8 @@ add_library(advapi32 SHARED
${CMAKE_CURRENT_BINARY_DIR}/advapi32.def
${CMAKE_CURRENT_BINARY_DIR}/eventlogrpc_c.c
${CMAKE_CURRENT_BINARY_DIR}/lsa_c.c
${CMAKE_CURRENT_BINARY_DIR}/svcctl_c.c)
${CMAKE_CURRENT_BINARY_DIR}/svcctl_c.c
${CMAKE_CURRENT_BINARY_DIR}/winreg_c.c)
set_module_type(advapi32 win32dll UNICODE ENTRYPOINT DllMain 12)
target_link_libraries(advapi32 cryptlib wine ${PSEH_LIB})

View file

@ -35,6 +35,7 @@
#include <services/services.h>
#include <svcctl_c.h>
#include <winreg_c.h>
#include <wine/debug.h>
#include <wine/unicode.h>

View file

@ -9,23 +9,8 @@
#include <advapi32.h>
#include <ndk/exfuncs.h>
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
/**********************************************************************
* AbortSystemShutdownW
*
* @unimplemented
*/
BOOL WINAPI
AbortSystemShutdownW(LPCWSTR lpMachineName)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/**********************************************************************
* AbortSystemShutdownA
*
@ -53,29 +38,38 @@ AbortSystemShutdownA(LPCSTR lpMachineName)
return rv;
}
/**********************************************************************
* InitiateSystemShutdownW
* AbortSystemShutdownW
*
* @implemented
*/
BOOL WINAPI
InitiateSystemShutdownW(LPWSTR lpMachineName,
LPWSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown)
AbortSystemShutdownW(LPCWSTR lpMachineName)
{
return InitiateSystemShutdownExW(lpMachineName,
lpMessage,
dwTimeout,
bForceAppsClosed,
bRebootAfterShutdown,
SHTDN_REASON_MAJOR_OTHER |
SHTDN_REASON_MINOR_OTHER |
SHTDN_REASON_FLAG_PLANNED
/* SHTDN_REASON_MAJOR_LEGACY_API */);
DWORD dwError;
RpcTryExcept
{
dwError = BaseAbortSystemShutdown((PREGISTRY_SERVER_NAME)lpMachineName);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwError = RtlNtStatusToDosError(RpcExceptionCode());
}
RpcEndExcept;
if (dwError != ERROR_SUCCESS)
{
TRACE("BaseAbortSystemShutdown() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
return TRUE;
}
/**********************************************************************
* InitiateSystemShutdownA
*
@ -88,84 +82,11 @@ InitiateSystemShutdownA(LPSTR lpMachineName,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown)
{
return InitiateSystemShutdownExA(lpMachineName,
lpMessage,
dwTimeout,
bForceAppsClosed,
bRebootAfterShutdown,
SHTDN_REASON_MAJOR_OTHER |
SHTDN_REASON_MINOR_OTHER |
SHTDN_REASON_FLAG_PLANNED
/* SHTDN_REASON_MAJOR_LEGACY_API */);
}
/******************************************************************************
* InitiateSystemShutdownExW [ADVAPI32.@]
*
* @unimplemented
*/
BOOL WINAPI
InitiateSystemShutdownExW(LPWSTR lpMachineName,
LPWSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown,
DWORD dwReason)
{
SHUTDOWN_ACTION action;
NTSTATUS Status;
ULONG Timeout_ms;
DBG_UNREFERENCED_LOCAL_VARIABLE(Timeout_ms);
/* Convert to milliseconds so we can use the value later on */
Timeout_ms = dwTimeout * 1000;
if (lpMachineName != NULL)
{
/* FIXME: Remote system shutdown not supported yet */
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
else /* The local system is being used */
{
/* FIXME: Right now, only basic shutting down and rebooting
is supported */
if(bRebootAfterShutdown == TRUE)
{
action = ShutdownReboot;
}
else
{
action = ShutdownNoReboot;
}
Status = NtShutdownSystem(action);
}
SetLastError(RtlNtStatusToDosError(Status));
return (Status == STATUS_SUCCESS);
}
/******************************************************************************
* InitiateSystemShutdownExA [ADVAPI32.@]
*
* see InitiateSystemShutdownExW
*/
BOOL WINAPI
InitiateSystemShutdownExA(LPSTR lpMachineName,
LPSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown,
DWORD dwReason)
{
ANSI_STRING MachineNameA, MessageA;
UNICODE_STRING MachineNameW, MessageW;
NTSTATUS Status;
INT LastError;
BOOL rv;
BOOL res;
MachineNameW.Buffer = NULL;
MessageW.Buffer = NULL;
@ -198,13 +119,11 @@ InitiateSystemShutdownExA(LPSTR lpMachineName,
}
}
rv = InitiateSystemShutdownExW(MachineNameW.Buffer,
MessageW.Buffer,
dwTimeout,
bForceAppsClosed,
bRebootAfterShutdown,
dwReason);
LastError = GetLastError();
res = InitiateSystemShutdownW(MachineNameW.Buffer,
MessageW.Buffer,
dwTimeout,
bForceAppsClosed,
bRebootAfterShutdown);
/* Clear the values of both strings */
if (lpMachineName)
@ -213,10 +132,163 @@ InitiateSystemShutdownExA(LPSTR lpMachineName,
if (lpMessage)
RtlFreeUnicodeString(&MessageW);
SetLastError(LastError);
return rv;
return res;
}
/**********************************************************************
* InitiateSystemShutdownW
*
* @implemented
*/
BOOL WINAPI
InitiateSystemShutdownW(LPWSTR lpMachineName,
LPWSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown)
{
UNICODE_STRING Message;
DWORD dwError;
RtlInitUnicodeString(&Message, lpMessage);
RpcTryExcept
{
dwError = BaseInitiateSystemShutdown((PREGISTRY_SERVER_NAME)lpMachineName,
(PRPC_UNICODE_STRING)&Message,
dwTimeout,
bForceAppsClosed,
bRebootAfterShutdown);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwError = RtlNtStatusToDosError(RpcExceptionCode());
}
RpcEndExcept;
if (dwError != ERROR_SUCCESS)
{
TRACE("BaseInitiateSystemShutdown() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
return TRUE;
}
/******************************************************************************
* InitiateSystemShutdownExA [ADVAPI32.@]
*
* see InitiateSystemShutdownExW
*/
BOOL WINAPI
InitiateSystemShutdownExA(LPSTR lpMachineName,
LPSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown,
DWORD dwReason)
{
ANSI_STRING MachineNameA, MessageA;
UNICODE_STRING MachineNameW, MessageW;
NTSTATUS Status;
BOOL res;
MachineNameW.Buffer = NULL;
MessageW.Buffer = NULL;
if (lpMachineName)
{
RtlInitAnsiString(&MachineNameA, lpMachineName);
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
if (STATUS_SUCCESS != Status)
{
if(MachineNameW.Buffer)
RtlFreeUnicodeString(&MachineNameW);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
}
if (lpMessage)
{
RtlInitAnsiString(&MessageA, lpMessage);
Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
if (STATUS_SUCCESS != Status)
{
if (MessageW.Buffer)
RtlFreeUnicodeString(&MessageW);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
}
res = InitiateSystemShutdownExW(MachineNameW.Buffer,
MessageW.Buffer,
dwTimeout,
bForceAppsClosed,
bRebootAfterShutdown,
dwReason);
/* Clear the values of both strings */
if (lpMachineName)
RtlFreeUnicodeString(&MachineNameW);
if (lpMessage)
RtlFreeUnicodeString(&MessageW);
return res;
}
/******************************************************************************
* InitiateSystemShutdownExW [ADVAPI32.@]
*
* @unimplemented
*/
BOOL WINAPI
InitiateSystemShutdownExW(LPWSTR lpMachineName,
LPWSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown,
DWORD dwReason)
{
UNICODE_STRING Message;
DWORD dwError;
RtlInitUnicodeString(&Message, lpMessage);
RpcTryExcept
{
dwError = BaseInitiateSystemShutdownEx((PREGISTRY_SERVER_NAME)lpMachineName,
(PRPC_UNICODE_STRING)&Message,
dwTimeout,
bForceAppsClosed,
bRebootAfterShutdown,
dwReason);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
dwError = RpcExceptionCode();
}
RpcEndExcept;
if (dwError != ERROR_SUCCESS)
{
TRACE("BaseInitiateSystemShutdownEx() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
return TRUE;
}
/******************************************************************************
* InitiateShutdownW [ADVAPI32.@]
*

View file

@ -0,0 +1,72 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/advapi32/service/winreg.c
* PURPOSE: Remote registry functions
* PROGRAMMER: Eric Kohl
*/
/* INCLUDES ******************************************************************/
#include <advapi32.h>
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
/* FUNCTIONS *****************************************************************/
handle_t __RPC_USER
PREGISTRY_SERVER_NAME_bind(PREGISTRY_SERVER_NAME pszServerName)
{
handle_t hBinding = NULL;
LPWSTR pszStringBinding;
RPC_STATUS status;
TRACE("PREGISTRY_SERVER_NAME_bind() called\n");
status = RpcStringBindingComposeW(NULL,
L"ncacn_np",
pszServerName,
L"\\pipe\\winreg",
NULL,
&pszStringBinding);
if (status != RPC_S_OK)
{
ERR("RpcStringBindingCompose returned 0x%x\n", status);
return NULL;
}
/* Set the binding handle that will be used to bind to the server. */
status = RpcBindingFromStringBindingW(pszStringBinding,
&hBinding);
if (status != RPC_S_OK)
{
ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
}
status = RpcStringFreeW(&pszStringBinding);
if (status != RPC_S_OK)
{
ERR("RpcStringFree returned 0x%x\n", status);
}
return hBinding;
}
void __RPC_USER
PREGISTRY_SERVER_NAME_unbind(PREGISTRY_SERVER_NAME pszServerName,
handle_t hBinding)
{
RPC_STATUS status;
TRACE("PREGISTRY_SERVER_NAME_unbind() called\n");
status = RpcBindingFree(&hBinding);
if (status != RPC_S_OK)
{
ERR("RpcBindingFree returned 0x%x\n", status);
}
}
/* EOF */