[ros-diffs] [tfaber] 72976: [KMTESTS:OB] - Add a test for the NT directory structure's ACLs CORE-9184

2016-10-17 Thread tfaber
Author: tfaber
Date: Mon Oct 17 09:28:15 2016
New Revision: 72976

URL: http://svn.reactos.org/svn/reactos?rev=72976=rev
Log:
[KMTESTS:OB]
- Add a test for the NT directory structure's ACLs
CORE-9184

Added:
trunk/rostests/kmtests/ntos_ob/ObSecurity.c   (with props)
Modified:
trunk/rostests/kmtests/CMakeLists.txt
trunk/rostests/kmtests/kmtest_drv/testlist.c

Modified: trunk/rostests/kmtests/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/CMakeLists.txt?rev=72976=72975=72976=diff
==
--- trunk/rostests/kmtests/CMakeLists.txt   [iso-8859-1] (original)
+++ trunk/rostests/kmtests/CMakeLists.txt   [iso-8859-1] Mon Oct 17 
09:28:15 2016
@@ -79,6 +79,7 @@
 ntos_mm/ZwMapViewOfSection.c
 ntos_ob/ObHandle.c
 ntos_ob/ObReference.c
+ntos_ob/ObSecurity.c
 ntos_ob/ObSymbolicLink.c
 ntos_ob/ObType.c
 ntos_ob/ObTypes.c

Modified: trunk/rostests/kmtests/kmtest_drv/testlist.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest_drv/testlist.c?rev=72976=72975=72976=diff
==
--- trunk/rostests/kmtests/kmtest_drv/testlist.c[iso-8859-1] (original)
+++ trunk/rostests/kmtests/kmtest_drv/testlist.c[iso-8859-1] Mon Oct 17 
09:28:15 2016
@@ -54,6 +54,7 @@
 KMT_TESTFUNC Test_NpfsVolumeInfo;
 KMT_TESTFUNC Test_ObHandle;
 KMT_TESTFUNC Test_ObReference;
+KMT_TESTFUNC Test_ObSecurity;
 KMT_TESTFUNC Test_ObSymbolicLink;
 KMT_TESTFUNC Test_ObType;
 KMT_TESTFUNC Test_ObTypeClean;
@@ -124,6 +125,7 @@
 { "NpfsVolumeInfo", Test_NpfsVolumeInfo },
 { "ObHandle",   Test_ObHandle },
 { "ObReference",Test_ObReference },
+{ "ObSecurity", Test_ObSecurity },
 { "ObSymbolicLink", Test_ObSymbolicLink },
 { "ObType", Test_ObType },
 { "-ObTypeClean",   Test_ObTypeClean },

Added: trunk/rostests/kmtests/ntos_ob/ObSecurity.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_ob/ObSecurity.c?rev=72976
==
--- trunk/rostests/kmtests/ntos_ob/ObSecurity.c (added)
+++ trunk/rostests/kmtests/ntos_ob/ObSecurity.c [iso-8859-1] Mon Oct 17 
09:28:15 2016
@@ -0,0 +1,196 @@
+/*
+ * PROJECT: ReactOS kernel-mode tests
+ * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE: Kernel-Mode Test Suite object security test
+ * PROGRAMMER:  Thomas Faber 
+ */
+
+#include 
+#include "../ntos_se/se.h"
+
+#define CheckDirectorySecurityWithOwnerAndGroup(name, Owner, Group, AceCount, 
...) CheckDirectorySecurity_(name, Owner, Group, AceCount, __FILE__, __LINE__, 
##__VA_ARGS__)
+#define CheckDirectorySecurity(name, AceCount, ...) 
CheckDirectorySecurity_(name, SeExports->SeAliasAdminsSid, 
SeExports->SeLocalSystemSid, AceCount, __FILE__, __LINE__, ##__VA_ARGS__)
+#define CheckDirectorySecurity_(name, Owner, Group, AceCount, file, line, ...) 
CheckDirectorySecurity__(name, Owner, Group, AceCount, file ":" 
KMT_STRINGIZE(line), ##__VA_ARGS__)
+static
+VOID
+CheckDirectorySecurity__(
+_In_ PCWSTR DirectoryName,
+_In_ PSID ExpectedOwner,
+_In_ PSID ExpectedGroup,
+_In_ ULONG AceCount,
+_In_ PCSTR FileAndLine,
+...)
+{
+NTSTATUS Status;
+UNICODE_STRING DirectoryNameString;
+OBJECT_ATTRIBUTES ObjectAttributes;
+HANDLE DirectoryHandle;
+PSECURITY_DESCRIPTOR SecurityDescriptor;
+ULONG SecurityDescriptorSize;
+PSID Owner;
+PSID Group;
+PACL Dacl;
+PACL Sacl;
+BOOLEAN Present;
+BOOLEAN Defaulted;
+va_list Arguments;
+
+RtlInitUnicodeString(, DirectoryName);
+InitializeObjectAttributes(,
+   ,
+   OBJ_KERNEL_HANDLE,
+   NULL,
+   NULL);
+Status = ZwOpenDirectoryObject(,
+   READ_CONTROL | ACCESS_SYSTEM_SECURITY,
+   );
+ok_eq_hex(Status, STATUS_SUCCESS);
+if (skip(NT_SUCCESS(Status), "No directory (%ls)\n", DirectoryName))
+{
+return;
+}
+
+Status = ZwQuerySecurityObject(DirectoryHandle,
+   OWNER_SECURITY_INFORMATION | 
GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | 
SACL_SECURITY_INFORMATION,
+   NULL,
+   0,
+   );
+ok_eq_hex(Status, STATUS_BUFFER_TOO_SMALL);
+if (skip(Status == STATUS_BUFFER_TOO_SMALL, "No security size (%ls)\n", 
DirectoryName))
+{
+ObCloseHandle(DirectoryHandle, KernelMode);
+return;
+}
+
+

[ros-diffs] [hbelusca] 72980: [MODE]: Numerous fixes for the MODE utility: - Parse the command line the same peculiar way as Windows' mode.com tool. This is certainly done such as to be backwards-comp

2016-10-17 Thread hbelusca
Author: hbelusca
Date: Mon Oct 17 22:19:22 2016
New Revision: 72980

URL: http://svn.reactos.org/svn/reactos?rev=72980=rev
Log:
[MODE]: Numerous fixes for the MODE utility:
- Parse the command line the same peculiar way as Windows' mode.com tool. This 
is certainly done such as to be backwards-compatible with MS-DOS' tool.
- Fix serial port string parsing, based on Wine's 
dll/win32/kernel32/wine/comm.c code. Note that the BuildCommDCB kernel32 API 
has the same syntax :)
- Implement support for MODE CON codepage, as well as screen size and typematic 
settings. Screen size code is based on NTVDM's one and will be subject to fixes 
later on.

MISSING stuff:
- LPT/COM port redirection.
- Localization :)

CORE-12176 #resolve
CORE-7998 CORE-8001

Modified:
trunk/reactos/base/applications/cmdutils/mode/CMakeLists.txt
trunk/reactos/base/applications/cmdutils/mode/mode.c

Modified: trunk/reactos/base/applications/cmdutils/mode/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/mode/CMakeLists.txt?rev=72980=72979=72980=diff
==
--- trunk/reactos/base/applications/cmdutils/mode/CMakeLists.txt
[iso-8859-1] (original)
+++ trunk/reactos/base/applications/cmdutils/mode/CMakeLists.txt
[iso-8859-1] Mon Oct 17 22:19:22 2016
@@ -1,6 +1,6 @@
 
 add_executable(mode mode.c mode.rc)
 set_module_type(mode win32cui UNICODE)
+add_importlibs(mode user32 msvcrt kernel32)
 set_target_properties(mode PROPERTIES SUFFIX ".com")
-add_importlibs(mode user32 msvcrt kernel32)
 add_cd_file(TARGET mode DESTINATION reactos/system32 FOR all)

Modified: trunk/reactos/base/applications/cmdutils/mode/mode.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/mode/mode.c?rev=72980=72979=72980=diff
==
--- trunk/reactos/base/applications/cmdutils/mode/mode.c[iso-8859-1] 
(original)
+++ trunk/reactos/base/applications/cmdutils/mode/mode.c[iso-8859-1] 
Mon Oct 17 22:19:22 2016
@@ -19,16 +19,24 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT: ReactOS Mode Utility
+ * FILE:base/applications/cmdutils/mode/mode.c
+ * PURPOSE: Provides fast mode setup for DOS devices.
+ * PROGRAMMERS: Robert Dickenson
+ *  Hermes Belusca-Maito
+ */
+
+#include 
 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #define MAX_PORTNAME_LEN 20
 #define MAX_COMPORT_NUM  10
-#define MAX_COMPARAM_LEN 20
 
 #define ASSERT(a)
 
@@ -46,23 +54,9 @@
 L"[rts=on|off|hs|tg] [idsr=on|off]",
 };
 
-const WCHAR* const parity_strings[] =
-{
-L"None",// default
-L"Odd", // only symbol in this set to have a 'd' in it
-L"Even",// ... 'v' in it
-L"Mark",// ... 'm' in it
-L"Space"// ... 's' and/or a 'c' in it
-};
-
-const WCHAR* const control_strings[] = { L"OFF", L"ON", L"HANDSHAKE", 
L"TOGGLE" };
-
-const WCHAR* const stopbit_strings[] = { L"1", L"1.5", L"2" };
-
-
-int Usage()
-{
-int i;
+void Usage(void)
+{
+UINT i;
 
 wprintf(L"\nConfigures system devices.\n\n");
 for (i = 0; i < ARRAYSIZE(usage_strings); i++)
@@ -70,21 +64,19 @@
 wprintf(L"%s\n", usage_strings[i]);
 }
 wprintf(L"\n");
-return 0;
-}
-
-int QueryDevices()
+}
+
+int QueryDevices(VOID)
 {
 WCHAR buffer[20240];
-int len;
 WCHAR* ptr = buffer;
 
 *ptr = L'\0';
+// FIXME: Dynamically allocate 'buffer' in a loop.
 if (QueryDosDeviceW(NULL, buffer, ARRAYSIZE(buffer)))
 {
 while (*ptr != L'\0')
 {
-len = wcslen(ptr);
 if (wcsstr(ptr, L"COM"))
 {
 wprintf(L"Found serial device - %s\n", ptr);
@@ -101,7 +93,7 @@
 {
 // wprintf(L"Found other device - %s\n", ptr);
 }
-ptr += (len+1);
+ptr += (wcslen(ptr) + 1);
 }
 }
 else
@@ -111,7 +103,7 @@
 return 1;
 }
 
-int ShowParallelStatus(int nPortNum)
+int ShowParallelStatus(INT nPortNum)
 {
 WCHAR buffer[250];
 WCHAR szPortName[MAX_PORTNAME_LEN];
@@ -124,7 +116,7 @@
 WCHAR* ptr = wcsrchr(buffer, L'\\');
 if (ptr != NULL)
 {
-if (0 == wcscmp(szPortName, ++ptr))
+if (_wcsicmp(szPortName, ++ptr) == 0)
 {
 wprintf(L"Printer output is not being rerouted.\n");
 }
@@ -146,115 +138,7 @@
 return 1;
 }
 
-int ShowConsoleStatus()
-{
-DWORD dwKbdDelay;
-DWORD dwKbdSpeed;
-CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
-HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
-
-wprintf(L"\nStatus for device 

[ros-diffs] [mjansen] 72977: [ATL][ATL_APITEST] Implementation / fixes for varions CRegKey functions, by Katayama Hirofumi MZ. CORE-11746 #resolve

2016-10-17 Thread mjansen
Author: mjansen
Date: Mon Oct 17 12:50:54 2016
New Revision: 72977

URL: http://svn.reactos.org/svn/reactos?rev=72977=rev
Log:
[ATL][ATL_APITEST] Implementation / fixes for varions CRegKey functions, by 
Katayama Hirofumi MZ. CORE-11746 #resolve

Modified:
trunk/reactos/sdk/lib/atl/atlbase.h
trunk/rostests/apitests/atl/CRegKey.cpp

Modified: trunk/reactos/sdk/lib/atl/atlbase.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/atl/atlbase.h?rev=72977=72976=72977=diff
==
--- trunk/reactos/sdk/lib/atl/atlbase.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/atl/atlbase.h [iso-8859-1] Mon Oct 17 12:50:54 2016
@@ -54,6 +54,10 @@
 #define ATL_NO_VTABLE __declspec(novtable)
 #endif
 
+#ifndef ATL_DEPRECATED
+#define ATL_DEPRECATED __declspec(deprecated)
+#endif
+
 #define offsetofclass(base, derived) 
(reinterpret_cast(static_cast(reinterpret_cast(_ATL_PACKING))) - _ATL_PACKING)
 
 namespace ATL
@@ -891,6 +895,10 @@
 {
 public:
 HKEY m_hKey;
+#if 0
+// FIXME & TODO:
+CAtlTransactionManager* m_pTM;
+#endif
 
 public:
 
@@ -900,14 +908,22 @@
 }
 
 CRegKey(CRegKey& key) throw()
-{
-Attach(key.Detach());
+: m_hKey(key.Detach())
+{
 }
 
 explicit CRegKey(HKEY hKey) throw()
-:m_hKey(hKey)
-{
-}
+: m_hKey(hKey)
+{
+}
+
+#if 0
+// FIXME & TODO:
+CRegKey(CAtlTransactionManager* pTM) throw()
+{
+...
+}
+#endif
 
 ~CRegKey() throw()
 {
@@ -923,7 +939,7 @@
 if (m_hKey)
 {
 HKEY hKey = Detach();
-return RegCloseKey(hKey);
+return ::RegCloseKey(hKey);
 }
 return ERROR_SUCCESS;
 }
@@ -935,11 +951,19 @@
 return hKey;
 }
 
-LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired = 
KEY_READ | KEY_WRITE) throw()
-{
+LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName,
+  REGSAM samDesired = KEY_READ | KEY_WRITE) throw()
+{
+ATLASSERT(hKeyParent);
+ATLASSERT(lpszKeyName);
+
 HKEY hKey = NULL;
-
-LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyName, NULL, samDesired, 
);
+LONG lRes = ::RegOpenKeyEx(hKeyParent, lpszKeyName, NULL, samDesired, 
);
+if (lRes != ERROR_SUCCESS)
+{
+samDesired |= KEY_WOW64_64KEY;
+lRes = ::RegOpenKeyEx(hKeyParent, lpszKeyName, NULL, samDesired, 
);
+}
 if (lRes == ERROR_SUCCESS)
 {
 Close();
@@ -948,11 +972,27 @@
 return lRes;
 }
 
-LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass = 
REG_NONE, DWORD dwOptions = REG_OPTION_NON_VOLATILE, REGSAM samDesired = 
KEY_READ | KEY_WRITE, LPSECURITY_ATTRIBUTES lpSecAttr = NULL, LPDWORD 
lpdwDisposition = NULL) throw()
-{
+LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName,
+LPTSTR lpszClass = REG_NONE,
+DWORD dwOptions = REG_OPTION_NON_VOLATILE,
+REGSAM samDesired = KEY_READ | KEY_WRITE,
+LPSECURITY_ATTRIBUTES lpSecAttr = NULL,
+LPDWORD lpdwDisposition = NULL) throw()
+{
+ATLASSERT(hKeyParent);
+ATLASSERT(lpszKeyName);
+
 HKEY hKey = NULL;
-
-LONG lRes = RegCreateKeyEx(hKeyParent, lpszKeyName, NULL, lpszClass, 
dwOptions, samDesired, lpSecAttr, , lpdwDisposition);
+LONG lRes = ::RegCreateKeyEx(hKeyParent, lpszKeyName, NULL, lpszClass,
+ dwOptions, samDesired, lpSecAttr, ,
+ lpdwDisposition);
+if (lRes != ERROR_SUCCESS)
+{
+samDesired |= KEY_WOW64_64KEY;
+lRes = ::RegCreateKeyEx(hKeyParent, lpszKeyName, NULL, lpszClass,
+dwOptions, samDesired, lpSecAttr, ,
+lpdwDisposition);
+}
 if (lRes == ERROR_SUCCESS)
 {
 Close();
@@ -961,10 +1001,10 @@
 return lRes;
 }
 
-
 LONG QueryValue(LPCTSTR pszValueName, DWORD* pdwType, void* pData, ULONG* 
pnBytes) throw()
 {
-return RegQueryValueEx(m_hKey, pszValueName, NULL, pdwType, 
(LPBYTE)pData, pnBytes);
+ATLASSERT(m_hKey);
+return ::RegQueryValueEx(m_hKey, pszValueName, NULL, pdwType, 
(LPBYTE)pData, pnBytes);
 }
 
 LONG QueryDWORDValue(LPCTSTR pszValueName, DWORD& dwValue) throw()
@@ -996,7 +1036,7 @@
 DWORD type = 0;
 LONG lRet = QueryValue(pszValueName, , pszValue, );
 
-if (lRet == ERROR_SUCCESS && type != REG_SZ)
+if (lRet == ERROR_SUCCESS && type != REG_SZ && type != REG_EXPAND_SZ)
 lRet = ERROR_INVALID_DATA;
 
 *pnChars = size / sizeof(TCHAR);
@@ -1022,15 +1062,42 @@
 if (lRet != ERROR_SUCCESS)
 return lRet;
 
-if (!SUCCEEDED(CLSIDFromString(buf, )))
+if 

[ros-diffs] [phater] 72978: [MSAFD] Add some parameter checks on send/recv based on wine tests. CORE-12104

2016-10-17 Thread phater
Author: phater
Date: Mon Oct 17 15:24:43 2016
New Revision: 72978

URL: http://svn.reactos.org/svn/reactos?rev=72978=rev
Log:
[MSAFD] Add some parameter checks on send/recv based on wine tests. CORE-12104

Modified:
trunk/reactos/dll/win32/msafd/misc/sndrcv.c

Modified: trunk/reactos/dll/win32/msafd/misc/sndrcv.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/sndrcv.c?rev=72978=72977=72978=diff
==
--- trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] Mon Oct 17 
15:24:43 2016
@@ -208,8 +208,15 @@
 Socket = GetSocketStructure(Handle);
 if (!Socket)
 {
-   *lpErrno = WSAENOTSOCK;
-   return SOCKET_ERROR;
+if (lpErrno)
+*lpErrno = WSAENOTSOCK;
+return SOCKET_ERROR;
+}
+if (!lpNumberOfBytesRead && !lpOverlapped)
+{
+if (lpErrno)
+*lpErrno = WSAEFAULT;
+return SOCKET_ERROR;
 }
 
 Status = NtCreateEvent( , EVENT_ALL_ACCESS,
@@ -389,8 +396,15 @@
 Socket = GetSocketStructure(Handle);
 if (!Socket)
 {
-   *lpErrno = WSAENOTSOCK;
-   return SOCKET_ERROR;
+if (lpErrno)
+*lpErrno = WSAENOTSOCK;
+return SOCKET_ERROR;
+}
+if (!lpNumberOfBytesRead && !lpOverlapped)
+{
+if (lpErrno)
+*lpErrno = WSAEFAULT;
+return SOCKET_ERROR;
 }
 
 if (!(Socket->SharedData->ServiceFlags1 & XP1_CONNECTIONLESS))
@@ -591,8 +605,15 @@
 Socket = GetSocketStructure(Handle);
 if (!Socket)
 {
-   *lpErrno = WSAENOTSOCK;
-   return SOCKET_ERROR;
+if (lpErrno)
+*lpErrno = WSAENOTSOCK;
+return SOCKET_ERROR;
+}
+if (!lpNumberOfBytesSent && !lpOverlapped)
+{
+if (lpErrno)
+*lpErrno = WSAEFAULT;
+return SOCKET_ERROR;
 }
 
 Status = NtCreateEvent( , EVENT_ALL_ACCESS,
@@ -740,8 +761,15 @@
 Socket = GetSocketStructure(Handle);
 if (!Socket)
 {
-   *lpErrno = WSAENOTSOCK;
-   return SOCKET_ERROR;
+if (lpErrno)
+*lpErrno = WSAENOTSOCK;
+return SOCKET_ERROR;
+}
+if (!lpNumberOfBytesSent && !lpOverlapped)
+{
+if (lpErrno)
+*lpErrno = WSAEFAULT;
+return SOCKET_ERROR;
 }
 
 if (!(Socket->SharedData->ServiceFlags1 & XP1_CONNECTIONLESS))




[ros-diffs] [janderwald] 72979: [WDMAUD] - fix a bug in WdmAudControlDeviceType - clear handle value when opening device interface key fails

2016-10-17 Thread janderwald
Author: janderwald
Date: Mon Oct 17 19:03:01 2016
New Revision: 72979

URL: http://svn.reactos.org/svn/reactos?rev=72979=rev
Log:
[WDMAUD]
- fix a bug in WdmAudControlDeviceType
- clear handle value when opening device interface key fails

Modified:
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c

Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c?rev=72979=72978=72979=diff
==
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] 
(original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/control.c [iso-8859-1] 
Mon Oct 17 19:03:01 2016
@@ -55,11 +55,11 @@
 }
 else if (DeviceInfo->DeviceType == WAVE_OUT_DEVICE_TYPE)
 {
+Result = WdmAudGetWaveOutDeviceCount();
+}
+else if (DeviceInfo->DeviceType == WAVE_IN_DEVICE_TYPE)
+{
 Result = WdmAudGetWaveInDeviceCount();
-}
-else if (DeviceInfo->DeviceType == WAVE_IN_DEVICE_TYPE)
-{
-Result = WdmAudGetWaveOutDeviceCount();
 }
 else if (DeviceInfo->DeviceType == MIDI_IN_DEVICE_TYPE)
 {

Modified: trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c?rev=72979=72978=72979=diff
==
--- trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c  [iso-8859-1] 
(original)
+++ trunk/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c  [iso-8859-1] 
Mon Oct 17 19:03:01 2016
@@ -271,6 +271,12 @@
 
 /* open device interface key */
 Status = IoOpenDeviceInterfaceRegistryKey(, GENERIC_READ | 
GENERIC_WRITE, OutKey);
+
+if (!NT_SUCCESS(Status))
+{
+*OutKey = NULL;
+}
+
 #if 0
 if (!NT_SUCCESS(Status))
 {