Author: ekohl
Date: Sat Dec 26 01:14:18 2015
New Revision: 70420
URL:
http://svn.reactos.org/svn/reactos?rev=70420&view=rev
Log:
[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).
Added:
trunk/reactos/dll/win32/advapi32/service/winreg.c (with props)
Modified:
trunk/reactos/dll/win32/advapi32/CMakeLists.txt
trunk/reactos/dll/win32/advapi32/advapi32.h
trunk/reactos/dll/win32/advapi32/misc/shutdown.c
Modified: trunk/reactos/dll/win32/advapi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/CMakeLi…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/CMakeLists.txt [iso-8859-1] Sat Dec 26 01:14:18 2015
@@ -14,7 +14,8 @@
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 @@
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 @@
${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})
Modified: trunk/reactos/dll/win32/advapi32/advapi32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/advapi3…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/advapi32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/advapi32.h [iso-8859-1] Sat Dec 26 01:14:18 2015
@@ -35,6 +35,7 @@
#include <services/services.h>
#include <svcctl_c.h>
+#include <winreg_c.h>
#include <wine/debug.h>
#include <wine/unicode.h>
Modified: trunk/reactos/dll/win32/advapi32/misc/shutdown.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/misc/sh…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/misc/shutdown.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/misc/shutdown.c [iso-8859-1] Sat Dec 26 01:14:18
2015
@@ -9,22 +9,7 @@
#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,28 +38,37 @@
return rv;
}
+
/**********************************************************************
- * InitiateSystemShutdownW
+ * AbortSystemShutdownW
*
* @implemented
*/
BOOL WINAPI
-InitiateSystemShutdownW(LPWSTR lpMachineName,
- LPWSTR lpMessage,
- DWORD dwTimeout,
- BOOL bForceAppsClosed,
- BOOL bRebootAfterShutdown)
-{
- return InitiateSystemShutdownExW(lpMachineName,
- lpMessage,
- dwTimeout,
- bForceAppsClosed,
- bRebootAfterShutdown,
- SHTDN_REASON_MAJOR_OTHER |
- SHTDN_REASON_MINOR_OTHER |
- SHTDN_REASON_FLAG_PLANNED
- /* SHTDN_REASON_MAJOR_LEGACY_API */);
-}
+AbortSystemShutdownW(LPCWSTR lpMachineName)
+{
+ 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
@@ -89,16 +83,167 @@
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 */);
-}
+ 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 = InitiateSystemShutdownW(MachineNameW.Buffer,
+ MessageW.Buffer,
+ dwTimeout,
+ bForceAppsClosed,
+ bRebootAfterShutdown);
+
+ /* Clear the values of both strings */
+ if (lpMachineName)
+ RtlFreeUnicodeString(&MachineNameW);
+
+ if (lpMessage)
+ RtlFreeUnicodeString(&MessageW);
+
+ 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.@]
@@ -113,109 +258,36 @@
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);
+ 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;
}
- 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;
-
- 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;
- }
- }
-
- rv = InitiateSystemShutdownExW(MachineNameW.Buffer,
- MessageW.Buffer,
- dwTimeout,
- bForceAppsClosed,
- bRebootAfterShutdown,
- dwReason);
- LastError = GetLastError();
-
- /* Clear the values of both strings */
- if (lpMachineName)
- RtlFreeUnicodeString(&MachineNameW);
-
- if (lpMessage)
- RtlFreeUnicodeString(&MessageW);
-
- SetLastError(LastError);
- return rv;
-}
+
+ return TRUE;
+}
+
/******************************************************************************
* InitiateShutdownW [ADVAPI32.@]
Added: trunk/reactos/dll/win32/advapi32/service/winreg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/service/winreg.c (added)
+++ trunk/reactos/dll/win32/advapi32/service/winreg.c [iso-8859-1] Sat Dec 26 01:14:18
2015
@@ -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 */
Propchange: trunk/reactos/dll/win32/advapi32/service/winreg.c
------------------------------------------------------------------------------
svn:eol-style = native