diff --git a/reactos/dll/win32/advapi32/reg/reg.c b/reactos/dll/win32/advapi32/reg/reg.c index 64e87b26186..de15bf5f7d7 100644 --- a/reactos/dll/win32/advapi32/reg/reg.c +++ b/reactos/dll/win32/advapi32/reg/reg.c @@ -14,6 +14,7 @@ /* INCLUDES *****************************************************************/ #include +#include WINE_DEFAULT_DEBUG_CHANNEL(reg); /* DEFINES ******************************************************************/ @@ -4952,10 +4953,29 @@ RegSetValueExW(HKEY hKey, 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)) @@ -4964,22 +4984,9 @@ RegSetValueExW(HKEY hKey, } 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,