diff --git a/reactos/lib/advapi32/reg/reg.c b/reactos/lib/advapi32/reg/reg.c index 7391a22b3b2..0f495f4e461 100644 --- a/reactos/lib/advapi32/reg/reg.c +++ b/reactos/lib/advapi32/reg/reg.c @@ -264,7 +264,6 @@ OpenCurrentConfigKey (PHANDLE KeyHandle) LONG STDCALL RegCloseKey (HKEY hKey) { - LONG ErrorCode; NTSTATUS Status; /* don't close null handle or a pseudo handle */ @@ -276,9 +275,7 @@ RegCloseKey (HKEY hKey) Status = NtClose (hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -444,7 +441,6 @@ RegCreateKeyExA (HKEY hKey, UNICODE_STRING ClassString; OBJECT_ATTRIBUTES Attributes; HANDLE ParentKey; - LONG ErrorCode; NTSTATUS Status; DPRINT("RegCreateKeyExA() called\n"); @@ -454,9 +450,7 @@ RegCreateKeyExA (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } DPRINT("ParentKey %x\n", (ULONG)ParentKey); @@ -488,9 +482,7 @@ RegCreateKeyExA (HKEY hKey, DPRINT("Status %x\n", Status); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -517,7 +509,6 @@ RegCreateKeyExW (HKEY hKey, UNICODE_STRING ClassString; OBJECT_ATTRIBUTES Attributes; HANDLE ParentKey; - LONG ErrorCode; NTSTATUS Status; DPRINT("RegCreateKeyExW() called\n"); @@ -527,9 +518,7 @@ RegCreateKeyExW (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError(Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError(Status); } DPRINT("ParentKey %x\n", (ULONG)ParentKey); @@ -551,9 +540,7 @@ RegCreateKeyExW (HKEY hKey, DPRINT("Status %x\n", Status); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -618,15 +605,12 @@ RegDeleteKeyA (HKEY hKey, HANDLE ParentKey; HANDLE TargetKey; NTSTATUS Status; - LONG ErrorCode; Status = MapDefaultKey (&ParentKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } RtlCreateUnicodeStringFromAsciiz (&SubKeyName, @@ -643,18 +627,14 @@ RegDeleteKeyA (HKEY hKey, RtlFreeUnicodeString (&SubKeyName); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } Status = NtDeleteKey (TargetKey); NtClose (TargetKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError(Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError(Status); } return ERROR_SUCCESS; @@ -675,15 +655,12 @@ RegDeleteKeyW (HKEY hKey, HANDLE ParentKey; HANDLE TargetKey; NTSTATUS Status; - LONG ErrorCode; Status = MapDefaultKey (&ParentKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } RtlInitUnicodeString (&SubKeyName, @@ -698,18 +675,14 @@ RegDeleteKeyW (HKEY hKey, &ObjectAttributes); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } Status = NtDeleteKey (TargetKey); NtClose (TargetKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -727,16 +700,13 @@ RegDeleteValueA (HKEY hKey, { UNICODE_STRING ValueName; HANDLE KeyHandle; - LONG ErrorCode; NTSTATUS Status; Status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } RtlCreateUnicodeStringFromAsciiz (&ValueName, @@ -746,9 +716,7 @@ RegDeleteValueA (HKEY hKey, RtlFreeUnicodeString (&ValueName); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -766,16 +734,13 @@ RegDeleteValueW (HKEY hKey, { UNICODE_STRING ValueName; NTSTATUS Status; - LONG ErrorCode; HANDLE KeyHandle; Status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } RtlInitUnicodeString (&ValueName, @@ -785,9 +750,7 @@ RegDeleteValueW (HKEY hKey, &ValueName); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -880,16 +843,13 @@ RegEnumKeyExA (HKEY hKey, if ((lpClass) && (!lpcbClass)) { - SetLastError (ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER; } Status = MapDefaultKey(&KeyHandle, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (*lpcbName > 0) @@ -923,7 +883,6 @@ RegEnumKeyExA (HKEY hKey, KeyInfo = RtlAllocateHeap (ProcessHeap, 0, BufferSize); if (KeyInfo == NULL) { - SetLastError (ERROR_OUTOFMEMORY); return ERROR_OUTOFMEMORY; } @@ -1010,11 +969,6 @@ RegEnumKeyExA (HKEY hKey, 0, KeyInfo); - if (ErrorCode != ERROR_SUCCESS) - { - SetLastError(ErrorCode); - } - return ErrorCode; } @@ -1052,9 +1006,7 @@ RegEnumKeyExW (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (*lpcbName > 0) @@ -1089,7 +1041,6 @@ RegEnumKeyExW (HKEY hKey, BufferSize); if (KeyInfo == NULL) { - SetLastError (ERROR_OUTOFMEMORY); return ERROR_OUTOFMEMORY; } @@ -1162,11 +1113,6 @@ RegEnumKeyExW (HKEY hKey, 0, KeyInfo); - if (ErrorCode != ERROR_SUCCESS) - { - SetLastError(ErrorCode); - } - return ErrorCode; } @@ -1194,10 +1140,7 @@ RegEnumValueA( HKEY hKey, DWORD index, LPSTR value, LPDWORD val_count, status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(status)) { - LONG ErrorCode; - ErrorCode = RtlNtStatusToDosError (status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (status); } total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR); @@ -1321,10 +1264,7 @@ RegEnumValueW( HKEY hKey, DWORD index, LPWSTR value, PDWORD val_count, status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(status)) { - LONG ErrorCode; - ErrorCode = RtlNtStatusToDosError (status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (status); } total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR); @@ -1399,7 +1339,6 @@ LONG STDCALL RegFlushKey(HKEY hKey) { HANDLE KeyHandle; - LONG ErrorCode; NTSTATUS Status; if (hKey == HKEY_PERFORMANCE_DATA) @@ -1411,17 +1350,13 @@ RegFlushKey(HKEY hKey) hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } Status = NtFlushKey (KeyHandle); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -1440,12 +1375,10 @@ RegGetKeySecurity(HKEY hKey, LPDWORD lpcbSecurityDescriptor) { HANDLE KeyHandle; - LONG ErrorCode; NTSTATUS Status; if (hKey == HKEY_PERFORMANCE_DATA) { - SetLastError(ERROR_INVALID_HANDLE); return ERROR_INVALID_HANDLE; } @@ -1454,9 +1387,7 @@ RegGetKeySecurity(HKEY hKey, if (!NT_SUCCESS(Status)) { DPRINT("MapDefaultKey() failed (Status %lx)\n", Status); - ErrorCode = RtlNtStatusToDosError(Status); - SetLastError(ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } Status = NtQuerySecurityObject(KeyHandle, @@ -1467,9 +1398,7 @@ RegGetKeySecurity(HKEY hKey, if (!NT_SUCCESS(Status)) { DPRINT("NtQuerySecurityObject() failed (Status %lx)\n", Status); - ErrorCode = RtlNtStatusToDosError(Status); - SetLastError(ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -1521,12 +1450,10 @@ RegLoadKeyW (HKEY hKey, UNICODE_STRING FileName; UNICODE_STRING KeyName; HANDLE KeyHandle; - LONG ErrorCode; NTSTATUS Status; if (hKey == HKEY_PERFORMANCE_DATA) { - SetLastError(ERROR_INVALID_HANDLE); return ERROR_INVALID_HANDLE; } @@ -1534,9 +1461,7 @@ RegLoadKeyW (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFile, @@ -1544,7 +1469,6 @@ RegLoadKeyW (HKEY hKey, NULL, NULL)) { - SetLastError (ERROR_BAD_PATHNAME); return ERROR_BAD_PATHNAME; } @@ -1570,9 +1494,7 @@ RegLoadKeyW (HKEY hKey, if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -1720,7 +1642,6 @@ RegOpenKeyExA (HKEY hKey, OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING SubKeyString; HANDLE KeyHandle; - LONG ErrorCode; NTSTATUS Status; DPRINT("RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n", @@ -1729,9 +1650,7 @@ RegOpenKeyExA (HKEY hKey, Status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } RtlCreateUnicodeStringFromAsciiz (&SubKeyString, (LPSTR)lpSubKey); @@ -1745,9 +1664,7 @@ RegOpenKeyExA (HKEY hKey, RtlFreeUnicodeString (&SubKeyString); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -1769,7 +1686,6 @@ RegOpenKeyExW (HKEY hKey, OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING SubKeyString; HANDLE KeyHandle; - LONG ErrorCode; NTSTATUS Status; DPRINT("RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n", @@ -1778,9 +1694,7 @@ RegOpenKeyExW (HKEY hKey, Status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (lpSubKey != NULL) @@ -1798,9 +1712,7 @@ RegOpenKeyExW (HKEY hKey, if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -1893,12 +1805,11 @@ RegQueryInfoKeyW (HKEY hKey, ULONG ClassLength = 0; HANDLE KeyHandle; NTSTATUS Status; - LONG ErrorCode = ERROR_SUCCESS; ULONG Length; + LONG ErrorCode = ERROR_SUCCESS; if ((lpClass) && (!lpcbClass)) { - SetLastError(ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER; } @@ -1906,9 +1817,7 @@ RegQueryInfoKeyW (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (lpClass != NULL) @@ -1928,7 +1837,6 @@ RegQueryInfoKeyW (HKEY hKey, FullInfoSize); if (FullInfo == NULL) { - SetLastError (ERROR_OUTOFMEMORY); return ERROR_OUTOFMEMORY; } @@ -1957,9 +1865,7 @@ RegQueryInfoKeyW (HKEY hKey, FullInfo); } - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } DPRINT("SubKeys %d\n", FullInfo->SubKeys); @@ -2016,9 +1922,7 @@ RegQueryInfoKeyW (HKEY hKey, FullInfo); } - ErrorCode = RtlNtStatusToDosError(Status); - SetLastError(ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } } @@ -2048,11 +1952,6 @@ RegQueryInfoKeyW (HKEY hKey, FullInfo); } - if (ErrorCode != ERROR_SUCCESS) - { - SetLastError (ErrorCode); - } - return ErrorCode; } @@ -2201,10 +2100,10 @@ RegQueryValueExW (HKEY hKey, PKEY_VALUE_PARTIAL_INFORMATION ValueInfo; UNICODE_STRING ValueName; NTSTATUS Status; - LONG ErrorCode = ERROR_SUCCESS; ULONG BufferSize; ULONG ResultSize; HANDLE KeyHandle; + LONG ErrorCode = ERROR_SUCCESS; ULONG MaxCopy = lpcbData != NULL && lpData != NULL ? *lpcbData : 0; DPRINT("hKey 0x%X lpValueName %S lpData 0x%X lpcbData %d\n", @@ -2214,14 +2113,11 @@ RegQueryValueExW (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (lpData != NULL && lpcbData == NULL) { - SetLastError (ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER; } @@ -2233,7 +2129,6 @@ RegQueryValueExW (HKEY hKey, BufferSize); if (ValueInfo == NULL) { - SetLastError(ERROR_OUTOFMEMORY); return ERROR_OUTOFMEMORY; } @@ -2253,7 +2148,6 @@ RegQueryValueExW (HKEY hKey, else if (!NT_SUCCESS(Status)) { ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); MaxCopy = 0; if (lpcbData != NULL) { @@ -2332,7 +2226,6 @@ RegQueryValueExA (HKEY hKey, if (lpData != NULL && lpcbData == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER; } @@ -2345,7 +2238,6 @@ RegQueryValueExA (HKEY hKey, ValueData.MaximumLength); if (!ValueData.Buffer) { - SetLastError(ERROR_OUTOFMEMORY); return ERROR_OUTOFMEMORY; } } @@ -2441,7 +2333,6 @@ RegQueryValueA (HKEY hKey, if (lpValue != NULL && lpcbValue == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER; } @@ -2470,7 +2361,6 @@ RegQueryValueA (HKEY hKey, ValueSize); if (Value.Buffer == NULL) { - SetLastError(ERROR_OUTOFMEMORY); return ERROR_OUTOFMEMORY; } } @@ -2533,9 +2423,7 @@ RegQueryValueW (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (lpSubKey != NULL && @@ -2553,9 +2441,7 @@ RegQueryValueW (HKEY hKey, &ObjectAttributes); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } CloseRealKey = TRUE; } @@ -2636,7 +2522,6 @@ RegReplaceKeyW (HKEY hKey, BOOLEAN CloseRealKey; HANDLE RealKeyHandle; HANDLE KeyHandle; - LONG ErrorCode; NTSTATUS Status; if (hKey == HKEY_PERFORMANCE_DATA) @@ -2648,9 +2533,7 @@ RegReplaceKeyW (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } /* Open the real key */ @@ -2668,9 +2551,7 @@ RegReplaceKeyW (HKEY hKey, &KeyObjectAttributes); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } CloseRealKey = TRUE; } @@ -2690,7 +2571,6 @@ RegReplaceKeyW (HKEY hKey, { NtClose (RealKeyHandle); } - SetLastError (ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER; } @@ -2711,7 +2591,6 @@ RegReplaceKeyW (HKEY hKey, { NtClose (RealKeyHandle); } - SetLastError (ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER; } @@ -2735,9 +2614,7 @@ RegReplaceKeyW (HKEY hKey, if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -2785,7 +2662,6 @@ RegRestoreKeyW (HKEY hKey, UNICODE_STRING FileName; HANDLE FileHandle; HANDLE KeyHandle; - LONG ErrorCode; NTSTATUS Status; if (hKey == HKEY_PERFORMANCE_DATA) @@ -2797,9 +2673,7 @@ RegRestoreKeyW (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFile, @@ -2807,7 +2681,6 @@ RegRestoreKeyW (HKEY hKey, NULL, NULL)) { - SetLastError (ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER; } @@ -2826,9 +2699,7 @@ RegRestoreKeyW (HKEY hKey, RtlFreeUnicodeString (&FileName); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } Status = NtRestoreKey (KeyHandle, @@ -2837,9 +2708,7 @@ RegRestoreKeyW (HKEY hKey, NtClose (FileHandle); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -2887,15 +2756,12 @@ RegSaveKeyW (HKEY hKey, HANDLE FileHandle; HANDLE KeyHandle; NTSTATUS Status; - LONG ErrorCode; Status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (!RtlDosPathNameToNtPathName_U ((PWSTR)lpFile, @@ -2903,7 +2769,6 @@ RegSaveKeyW (HKEY hKey, NULL, NULL)) { - SetLastError (ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER; } @@ -2931,9 +2796,7 @@ RegSaveKeyW (HKEY hKey, RtlFreeUnicodeString (&FileName); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } Status = NtSaveKey (KeyHandle, @@ -2941,9 +2804,7 @@ RegSaveKeyW (HKEY hKey, NtClose (FileHandle); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -2961,12 +2822,10 @@ RegSetKeySecurity (HKEY hKey, PSECURITY_DESCRIPTOR pSecurityDescriptor) { HANDLE KeyHandle; - LONG ErrorCode; NTSTATUS Status; if (hKey == HKEY_PERFORMANCE_DATA) { - SetLastError(ERROR_INVALID_HANDLE); return ERROR_INVALID_HANDLE; } @@ -2974,9 +2833,7 @@ RegSetKeySecurity (HKEY hKey, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } Status = NtSetSecurityObject (KeyHandle, @@ -2984,9 +2841,7 @@ RegSetKeySecurity (HKEY hKey, pSecurityDescriptor); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -3097,15 +2952,12 @@ RegSetValueExW (HKEY hKey, PUNICODE_STRING pValueName; HANDLE KeyHandle; NTSTATUS Status; - LONG ErrorCode; Status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if (lpValueName != NULL) @@ -3136,9 +2988,7 @@ RegSetValueExW (HKEY hKey, (ULONG)cbData); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS; @@ -3211,17 +3061,15 @@ RegSetValueW (HKEY hKey, UNICODE_STRING SubKeyString; HANDLE KeyHandle; HANDLE RealKey; - LONG ErrorCode; BOOL CloseRealKey; NTSTATUS Status; + LONG ErrorCode; Status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } if ((lpSubKey) && (wcslen(lpSubKey) != 0)) @@ -3238,9 +3086,7 @@ RegSetValueW (HKEY hKey, &ObjectAttributes); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } CloseRealKey = TRUE; } @@ -3301,21 +3147,17 @@ RegUnLoadKeyW (HKEY hKey, OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING KeyName; HANDLE KeyHandle; - DWORD ErrorCode; NTSTATUS Status; if (hKey == HKEY_PERFORMANCE_DATA) { - SetLastError(ERROR_INVALID_HANDLE); return ERROR_INVALID_HANDLE; } Status = MapDefaultKey (&KeyHandle, hKey); if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } RtlInitUnicodeString (&KeyName, @@ -3331,9 +3173,7 @@ RegUnLoadKeyW (HKEY hKey, if (!NT_SUCCESS(Status)) { - ErrorCode = RtlNtStatusToDosError (Status); - SetLastError (ErrorCode); - return ErrorCode; + return RtlNtStatusToDosError (Status); } return ERROR_SUCCESS;