Author: tfaber Date: Sat Feb 21 12:24:19 2015 New Revision: 66382
URL: http://svn.reactos.org/svn/reactos?rev=66382&view=rev Log: [KERNEL32] - BasepGetModuleHandleExW returns BOOLEAN, not NTSTATUS. Treat it as such. - Always set last error code on failure in BasepGetModuleHandleExW. CORE-9241 #resolve
Modified: trunk/reactos/dll/win32/kernel32/client/loader.c
Modified: trunk/reactos/dll/win32/kernel32/client/loader.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/l... ============================================================================== --- trunk/reactos/dll/win32/kernel32/client/loader.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/loader.c [iso-8859-1] Sat Feb 21 12:24:19 2015 @@ -722,7 +722,7 @@ { DWORD Cookie; NTSTATUS Status = STATUS_SUCCESS, Status2; - HANDLE hModule = 0; + HANDLE hModule = NULL; UNICODE_STRING ModuleNameU; DWORD dwValid; BOOLEAN Redirected = FALSE; // FIXME @@ -739,7 +739,7 @@ { /* Fail */ BaseSetLastNTError(Status); - if (phModule) *phModule = 0; + if (phModule) *phModule = NULL; return NT_SUCCESS(Status); } } @@ -789,11 +789,11 @@ hModule); }
+quickie: /* Set last error in case of failure */ if (!NT_SUCCESS(Status)) BaseSetLastNTError(Status);
-quickie: /* Unlock loader lock if it was acquired */ if (!NoLock) { @@ -843,20 +843,20 @@ GetModuleHandleW(LPCWSTR lpModuleName) { HMODULE hModule; - NTSTATUS Status; + BOOLEAN Success;
/* If current module is requested - return it right away */ if (!lpModuleName) return ((HMODULE)NtCurrentPeb()->ImageBaseAddress);
/* Use common helper routine */ - Status = BasepGetModuleHandleExW(TRUE, - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - lpModuleName, - &hModule); - - /* If it wasn't successful - return 0 */ - if (!NT_SUCCESS(Status)) hModule = 0; + Success = BasepGetModuleHandleExW(TRUE, + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + lpModuleName, + &hModule); + + /* If it wasn't successful - return NULL */ + if (!Success) hModule = NULL;
/* Return the handle */ return hModule; @@ -872,9 +872,8 @@ IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE* phModule) { - NTSTATUS Status; DWORD dwValid; - BOOL Ret = FALSE; + BOOL Ret;
/* Validate parameters */ dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, lpwModuleName, phModule); @@ -886,13 +885,10 @@ if (dwValid == BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS) return TRUE;
/* Use common helper routine */ - Status = BasepGetModuleHandleExW(FALSE, - dwFlags, - lpwModuleName, - phModule); - - /* Return TRUE in case of success */ - if (NT_SUCCESS(Status)) Ret = TRUE; + Ret = BasepGetModuleHandleExW(FALSE, + dwFlags, + lpwModuleName, + phModule);
return Ret; } @@ -908,8 +904,7 @@ { PUNICODE_STRING lpModuleNameW; DWORD dwValid; - BOOL Ret = FALSE; - NTSTATUS Status; + BOOL Ret;
/* Validate parameters */ dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, (LPCWSTR)lpModuleName, phModule); @@ -924,10 +919,10 @@ if (dwFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS) { /* Call the extended version of the API without conversion */ - Status = BasepGetModuleHandleExW(FALSE, - dwFlags, - (LPCWSTR)lpModuleName, - phModule); + Ret = BasepGetModuleHandleExW(FALSE, + dwFlags, + (LPCWSTR)lpModuleName, + phModule); } else { @@ -938,15 +933,11 @@ if (!lpModuleNameW) return FALSE;
/* Call the extended version of the API */ - Status = BasepGetModuleHandleExW(FALSE, - dwFlags, - lpModuleNameW->Buffer, - phModule); - } - - /* If result was successful - return true */ - if (NT_SUCCESS(Status)) - Ret = TRUE; + Ret = BasepGetModuleHandleExW(FALSE, + dwFlags, + lpModuleNameW->Buffer, + phModule); + }
/* Return result */ return Ret;