/* INCLUDES *****************************************************************/
#include <advapi32.h>
+
+#include <ndk/cmfuncs.h>
+#include <pseh/pseh2.h>
+
WINE_DEFAULT_DEBUG_CHANNEL(reg);
/* DEFINES ******************************************************************/
LocalObjectAttributes.ObjectName = &LocalKeyName;
FullNameLength = LocalKeyName.Length / sizeof(WCHAR);
- LocalKeyHandle = NULL;
+ LocalKeyHandle = NULL;
/* Remove the last part of the key name and try to create the key again. */
while (Status == STATUS_OBJECT_NAME_NOT_FOUND)
{
UNICODE_STRING SubKeyString;
UNICODE_STRING ClassString;
- OBJECT_ATTRIBUTES Attributes;
+ OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE ParentKey;
+ ULONG Attributes = OBJ_CASE_INSENSITIVE;
NTSTATUS Status;
TRACE("RegCreateKeyExA() called\n");
lpClass);
}
+ if (dwOptions & REG_OPTION_OPEN_LINK)
+ Attributes |= OBJ_OPENLINK;
+
RtlCreateUnicodeStringFromAsciiz(&SubKeyString,
(LPSTR)lpSubKey);
- InitializeObjectAttributes(&Attributes,
+ InitializeObjectAttributes(&ObjectAttributes,
&SubKeyString,
- OBJ_CASE_INSENSITIVE,
+ Attributes,
(HANDLE)ParentKey,
lpSecurityAttributes ? (PSECURITY_DESCRIPTOR)lpSecurityAttributes->lpSecurityDescriptor : NULL);
Status = CreateNestedKey(phkResult,
- &Attributes,
+ &ObjectAttributes,
(lpClass == NULL)? NULL : &ClassString,
dwOptions,
samDesired,
{
UNICODE_STRING SubKeyString;
UNICODE_STRING ClassString;
- OBJECT_ATTRIBUTES Attributes;
+ OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE ParentKey;
+ ULONG Attributes = OBJ_CASE_INSENSITIVE;
NTSTATUS Status;
TRACE("RegCreateKeyExW() called\n");
TRACE("ParentKey %p\n", ParentKey);
+ if (dwOptions & REG_OPTION_OPEN_LINK)
+ Attributes |= OBJ_OPENLINK;
+
RtlInitUnicodeString(&ClassString,
lpClass);
RtlInitUnicodeString(&SubKeyString,
lpSubKey);
- InitializeObjectAttributes(&Attributes,
+ InitializeObjectAttributes(&ObjectAttributes,
&SubKeyString,
- OBJ_CASE_INSENSITIVE,
+ Attributes,
(HANDLE)ParentKey,
lpSecurityAttributes ? (PSECURITY_DESCRIPTOR)lpSecurityAttributes->lpSecurityDescriptor : NULL);
Status = CreateNestedKey(phkResult,
- &Attributes,
+ &ObjectAttributes,
(lpClass == NULL)? NULL : &ClassString,
dwOptions,
samDesired,
/************************************************************************
* RegDeleteKeyExA
*
- * @unimplemented
+ * @implemented
*/
LONG
WINAPI
REGSAM samDesired,
DWORD Reserved)
{
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return ERROR_CALL_NOT_IMPLEMENTED;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING SubKeyName;
+ HANDLE ParentKey;
+ HANDLE TargetKey;
+ NTSTATUS Status;
+
+ /* Make sure we got a subkey */
+ if (!lpSubKey)
+ {
+ /* Fail */
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ Status = MapDefaultKey(&ParentKey,
+ hKey);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ if (samDesired & KEY_WOW64_32KEY)
+ ERR("Wow64 not yet supported!\n");
+
+ if (samDesired & KEY_WOW64_64KEY)
+ ERR("Wow64 not yet supported!\n");
+
+ RtlCreateUnicodeStringFromAsciiz(&SubKeyName,
+ (LPSTR)lpSubKey);
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SubKeyName,
+ OBJ_CASE_INSENSITIVE,
+ ParentKey,
+ NULL);
+
+ Status = NtOpenKey(&TargetKey,
+ DELETE,
+ &ObjectAttributes);
+ RtlFreeUnicodeString(&SubKeyName);
+ if (!NT_SUCCESS(Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = NtDeleteKey(TargetKey);
+ NtClose (TargetKey);
+
+Cleanup:
+ ClosePredefKey(ParentKey);
+
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ return ERROR_SUCCESS;
}
/************************************************************************
* RegDeleteKeyExW
*
- * @unimplemented
+ * @implemented
*/
LONG
WINAPI
REGSAM samDesired,
DWORD Reserved)
{
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return ERROR_CALL_NOT_IMPLEMENTED;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING SubKeyName;
+ HANDLE ParentKey;
+ HANDLE TargetKey;
+ NTSTATUS Status;
+
+ /* Make sure we got a subkey */
+ if (!lpSubKey)
+ {
+ /* Fail */
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ Status = MapDefaultKey(&ParentKey,
+ hKey);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ if (samDesired & KEY_WOW64_32KEY)
+ ERR("Wow64 not yet supported!\n");
+
+ if (samDesired & KEY_WOW64_64KEY)
+ ERR("Wow64 not yet supported!\n");
+
+
+ RtlInitUnicodeString(&SubKeyName,
+ (LPWSTR)lpSubKey);
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SubKeyName,
+ OBJ_CASE_INSENSITIVE,
+ ParentKey,
+ NULL);
+ Status = NtOpenKey(&TargetKey,
+ DELETE,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = NtDeleteKey(TargetKey);
+ NtClose(TargetKey);
+
+Cleanup:
+ ClosePredefKey(ParentKey);
+
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ return ERROR_SUCCESS;
}
if (KeyInfo->Node.NameLength > NameLength ||
KeyInfo->Node.ClassLength > ClassLength)
{
- ErrorCode = ERROR_BUFFER_OVERFLOW;
+ ErrorCode = ERROR_BUFFER_OVERFLOW;
}
else
{
return RtlNtStatusToDosError(Status);
}
-#if 0
Status = NtQuerySecurityObject(KeyHandle,
SecurityInformation,
pSecurityDescriptor,
*lpcbSecurityDescriptor,
lpcbSecurityDescriptor);
-#endif
ClosePredefKey(KeyHandle);
* @implemented
*/
LONG WINAPI
-RegOpenKeyExA(HKEY hKey,
- LPCSTR lpSubKey,
- DWORD ulOptions,
- REGSAM samDesired,
- PHKEY phkResult)
+RegOpenKeyExA(
+ _In_ HKEY hKey,
+ _In_ LPCSTR lpSubKey,
+ _In_ DWORD ulOptions,
+ _In_ REGSAM samDesired,
+ _Out_ PHKEY phkResult)
{
- OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING SubKeyString;
- HANDLE KeyHandle;
- NTSTATUS Status;
- LONG ErrorCode = ERROR_SUCCESS;
+ LONG ErrorCode;
TRACE("RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
hKey, lpSubKey, ulOptions, samDesired, phkResult);
- if (!phkResult)
- {
- return ERROR_INVALID_PARAMETER;
- }
-
- Status = MapDefaultKey(&KeyHandle,
- hKey);
- if (!NT_SUCCESS(Status))
- {
- return RtlNtStatusToDosError(Status);
- }
RtlCreateUnicodeStringFromAsciiz(&SubKeyString,
(LPSTR)lpSubKey);
- InitializeObjectAttributes(&ObjectAttributes,
- &SubKeyString,
- OBJ_CASE_INSENSITIVE,
- KeyHandle,
- NULL);
- Status = NtOpenKey((PHANDLE)phkResult,
- samDesired,
- &ObjectAttributes);
- RtlFreeUnicodeString(&SubKeyString);
- if (!NT_SUCCESS(Status))
- {
- ErrorCode = RtlNtStatusToDosError(Status);
- }
+ ErrorCode = RegOpenKeyExW(hKey, SubKeyString.Buffer, ulOptions, samDesired, phkResult);
- ClosePredefKey(KeyHandle);
+ RtlFreeUnicodeString(&SubKeyString);
return ErrorCode;
}
UNICODE_STRING SubKeyString;
HANDLE KeyHandle;
NTSTATUS Status;
+ ULONG Attributes = OBJ_CASE_INSENSITIVE;
LONG ErrorCode = ERROR_SUCCESS;
TRACE("RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n",
return RtlNtStatusToDosError(Status);
}
+ if (ulOptions & REG_OPTION_OPEN_LINK)
+ Attributes |= OBJ_OPENLINK;
+
if (lpSubKey != NULL)
RtlInitUnicodeString(&SubKeyString, (LPWSTR)lpSubKey);
else
InitializeObjectAttributes(&ObjectAttributes,
&SubKeyString,
- OBJ_CASE_INSENSITIVE,
+ Attributes,
KeyHandle,
NULL);
*lpcbMaxValueLen = FullInfo->MaxValueDataLen;
}
-#if 0
if (lpcbSecurityDescriptor != NULL)
{
Status = NtQuerySecurityObject(KeyHandle,
NULL,
0,
lpcbSecurityDescriptor);
- if (!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_TOO_SMALL)
{
if (lpClass != NULL)
{
goto Cleanup;
}
}
-#endif
if (lpftLastWriteTime != NULL)
{
RtlInitAnsiString( &nameA, name );
if ((status = RtlAnsiStringToUnicodeString( &nameW, &nameA, TRUE )))
{
- return RtlNtStatusToDosError(status);
ClosePredefKey(hkey);
+ return RtlNtStatusToDosError(status);
}
status = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
DWORD cbData)
{
UNICODE_STRING ValueName;
- PUNICODE_STRING pValueName;
HANDLE KeyHandle;
NTSTATUS Status;
+ if (is_string(dwType) && (cbData != 0))
+ {
+ PWSTR pwsData = (PWSTR)lpData;
+
+ _SEH2_TRY
+ {
+ if((pwsData[cbData / sizeof(WCHAR) - 1] != L'\0') &&
+ (pwsData[cbData / sizeof(WCHAR)] == L'\0'))
+ {
+ /* Increment length if last character is not zero and next is zero */
+ cbData += sizeof(WCHAR);
+ }
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return ERROR_NOACCESS);
+ }
+ _SEH2_END;
+ }
+
Status = MapDefaultKey(&KeyHandle,
hKey);
if (!NT_SUCCESS(Status))
}
RtlInitUnicodeString(&ValueName, lpValueName);
- pValueName = &ValueName;
-
- if (is_string(dwType) && (cbData != 0))
- {
- PWSTR pwsData = (PWSTR)lpData;
-
- if((pwsData[cbData / sizeof(WCHAR) - 1] != L'\0') &&
- (pwsData[cbData / sizeof(WCHAR)] == L'\0'))
- {
- /* Increment length if last character is not zero and next is zero */
- cbData += sizeof(WCHAR);
- }
- }
Status = NtSetValueKey(KeyHandle,
- pValueName,
+ &ValueName,
0,
dwType,
(PVOID)lpData,