if (LDR_IS_DATAFILE(hModule) && !AsDataFile)
return NULL;
- /* It'a a normal DLL, just return its handle */
+ /* It's a normal DLL, just return its handle */
return hModule;
}
LoadLibraryW(LPCWSTR lpLibFileName)
{
/* Call Ex version of the API */
- return LoadLibraryExW (lpLibFileName, 0, 0);
+ return LoadLibraryExW(lpLibFileName, 0, 0);
}
/* Set last error in failure case */
if (!NT_SUCCESS(Status))
{
+ DPRINT1("LoadLibraryExW(%ls) failing with status %lx\n", lpLibFileName, Status);
BaseSetLastNTError(Status);
return NULL;
}
}
/* Check for a special case when returned pointer is
- the same as iamge's base address */
+ the same as image's base address */
if (fnExp == hMapped)
{
/* Set correct error code */
Status = BasepUnicodeStringTo8BitString(&FilenameA, &FilenameW, TRUE);
if (!NT_SUCCESS(Status))
{
- /* Set last error, free string and retun failure */
+ /* Set last error, free string and return failure */
BaseSetLastNTError(Status);
RtlFreeUnicodeString(&FilenameW);
return 0;
PLIST_ENTRY ModuleListHead, Entry;
PLDR_DATA_TABLE_ENTRY Module;
ULONG Length = 0;
- ULONG Cookie;
+ ULONG_PTR Cookie;
PPEB Peb;
hModule = BasepMapModuleHandle(hModule, FALSE);
WINAPI
BasepGetModuleHandleExW(BOOLEAN NoLock, DWORD dwPublicFlags, LPCWSTR lpwModuleName, HMODULE *phModule)
{
- DWORD Cookie;
+ ULONG_PTR Cookie;
NTSTATUS Status = STATUS_SUCCESS, Status2;
- HANDLE hModule = 0;
+ HANDLE hModule = NULL;
UNICODE_STRING ModuleNameU;
DWORD dwValid;
BOOLEAN Redirected = FALSE; // FIXME
{
/* Fail */
BaseSetLastNTError(Status);
- if (phModule) *phModule = 0;
+ if (phModule) *phModule = NULL;
return NT_SUCCESS(Status);
}
}
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)
{
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);
+ Success = BasepGetModuleHandleExW(TRUE,
+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+ lpModuleName,
+ &hModule);
- /* If it wasn't successful - return 0 */
- if (!NT_SUCCESS(Status)) hModule = 0;
+ /* If it wasn't successful - return NULL */
+ if (!Success) hModule = NULL;
/* Return the handle */
return hModule;
IN LPCWSTR lpwModuleName OPTIONAL,
OUT HMODULE* phModule)
{
- NTSTATUS Status;
DWORD dwValid;
- BOOL Ret = FALSE;
+ BOOL Ret;
/* Validate parameters */
dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, lpwModuleName, phModule);
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;
}
{
PUNICODE_STRING lpModuleNameW;
DWORD dwValid;
- BOOL Ret = FALSE;
- NTSTATUS Status;
+ BOOL Ret;
/* Validate parameters */
dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, (LPCWSTR)lpModuleName, phModule);
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
{
if (!lpModuleNameW) return FALSE;
/* Call the extended version of the API */
- Status = BasepGetModuleHandleExW(FALSE,
- dwFlags,
- lpModuleNameW->Buffer,
- phModule);
+ Ret = BasepGetModuleHandleExW(FALSE,
+ dwFlags,
+ lpModuleNameW->Buffer,
+ phModule);
}
- /* If result was successful - return true */
- if (NT_SUCCESS(Status))
- Ret = TRUE;
-
/* Return result */
return Ret;
}