kernel32: Partial implementation of GetModuleHandleExA/W.
This commit is contained in:
parent
9769806c3a
commit
ab2349daf0
|
@ -540,8 +540,8 @@
|
||||||
@ stdcall GetModuleFileNameA(long ptr long)
|
@ stdcall GetModuleFileNameA(long ptr long)
|
||||||
@ stdcall GetModuleFileNameW(long ptr long)
|
@ stdcall GetModuleFileNameW(long ptr long)
|
||||||
@ stdcall GetModuleHandleA(str)
|
@ stdcall GetModuleHandleA(str)
|
||||||
# @ stub GetModuleHandleExA
|
@ stdcall GetModuleHandleExA(long ptr ptr)
|
||||||
# @ stub GetModuleHandleExW
|
@ stdcall GetModuleHandleExW(long ptr ptr)
|
||||||
@ stdcall GetModuleHandleW(wstr)
|
@ stdcall GetModuleHandleW(wstr)
|
||||||
@ stdcall GetNamedPipeHandleStateA(long ptr ptr ptr ptr str long)
|
@ stdcall GetNamedPipeHandleStateA(long ptr ptr ptr ptr str long)
|
||||||
@ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr wstr long)
|
@ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr wstr long)
|
||||||
|
|
|
@ -480,6 +480,57 @@ BOOL WINAPI GetBinaryTypeA( LPCSTR lpApplicationName, LPDWORD lpBinaryType )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* GetModuleHandleExA (KERNEL32.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI GetModuleHandleExA( DWORD flags, LPCSTR name, HMODULE *module )
|
||||||
|
{
|
||||||
|
WCHAR *nameW;
|
||||||
|
|
||||||
|
if (!name || (flags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS))
|
||||||
|
return GetModuleHandleExW( flags, (LPCWSTR)name, module );
|
||||||
|
|
||||||
|
if (!(nameW = FILE_name_AtoW( name, FALSE ))) return FALSE;
|
||||||
|
return GetModuleHandleExW( flags, nameW, module );
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* GetModuleHandleExW (KERNEL32.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI GetModuleHandleExW( DWORD flags, LPCWSTR name, HMODULE *module )
|
||||||
|
{
|
||||||
|
NTSTATUS status = STATUS_SUCCESS;
|
||||||
|
HMODULE ret;
|
||||||
|
|
||||||
|
if (!name)
|
||||||
|
{
|
||||||
|
ret = NtCurrentTeb()->Peb->ImageBaseAddress;
|
||||||
|
}
|
||||||
|
else if (flags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)
|
||||||
|
{
|
||||||
|
void *dummy;
|
||||||
|
if (!(ret = RtlPcToFileHeader( (void *)name, &dummy ))) status = STATUS_DLL_NOT_FOUND;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UNICODE_STRING wstr;
|
||||||
|
RtlInitUnicodeString( &wstr, name );
|
||||||
|
status = LdrGetDllHandle( 0, 0, &wstr, &ret );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( status ) );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((flags & GET_MODULE_HANDLE_EX_FLAG_PIN) ||
|
||||||
|
!(flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
|
||||||
|
FIXME( "should update refcount, flags %lx\n", flags );
|
||||||
|
|
||||||
|
if (module) *module = ret;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* GetModuleHandleA (KERNEL32.@)
|
* GetModuleHandleA (KERNEL32.@)
|
||||||
|
@ -496,11 +547,10 @@ BOOL WINAPI GetBinaryTypeA( LPCSTR lpApplicationName, LPDWORD lpBinaryType )
|
||||||
*/
|
*/
|
||||||
HMODULE WINAPI GetModuleHandleA(LPCSTR module)
|
HMODULE WINAPI GetModuleHandleA(LPCSTR module)
|
||||||
{
|
{
|
||||||
WCHAR *moduleW;
|
HMODULE ret;
|
||||||
|
|
||||||
if (!module) return NtCurrentTeb()->Peb->ImageBaseAddress;
|
if (!GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, module, &ret )) ret = 0;
|
||||||
if (!(moduleW = FILE_name_AtoW( module, FALSE ))) return 0;
|
return ret;
|
||||||
return GetModuleHandleW( moduleW );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -510,19 +560,9 @@ HMODULE WINAPI GetModuleHandleA(LPCSTR module)
|
||||||
*/
|
*/
|
||||||
HMODULE WINAPI GetModuleHandleW(LPCWSTR module)
|
HMODULE WINAPI GetModuleHandleW(LPCWSTR module)
|
||||||
{
|
{
|
||||||
NTSTATUS nts;
|
|
||||||
HMODULE ret;
|
HMODULE ret;
|
||||||
UNICODE_STRING wstr;
|
|
||||||
|
|
||||||
if (!module) return NtCurrentTeb()->Peb->ImageBaseAddress;
|
if (!GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, module, &ret )) ret = 0;
|
||||||
|
|
||||||
RtlInitUnicodeString( &wstr, module );
|
|
||||||
nts = LdrGetDllHandle( 0, 0, &wstr, &ret);
|
|
||||||
if (nts != STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
SetLastError( RtlNtStatusToDosError( nts ) );
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -750,6 +750,10 @@ DECL_WINELIB_TYPE_AW(ENUMRESLANGPROC)
|
||||||
#define LOAD_LIBRARY_AS_DATAFILE 0x00000002
|
#define LOAD_LIBRARY_AS_DATAFILE 0x00000002
|
||||||
#define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008
|
#define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008
|
||||||
|
|
||||||
|
#define GET_MODULE_HANDLE_EX_FLAG_PIN 1
|
||||||
|
#define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2
|
||||||
|
#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4
|
||||||
|
|
||||||
typedef PLDT_ENTRY LPLDT_ENTRY;
|
typedef PLDT_ENTRY LPLDT_ENTRY;
|
||||||
|
|
||||||
typedef enum _GET_FILEEX_INFO_LEVELS {
|
typedef enum _GET_FILEEX_INFO_LEVELS {
|
||||||
|
@ -1568,6 +1572,9 @@ DWORD WINAPI GetModuleFileNameW(HMODULE,LPWSTR,DWORD);
|
||||||
HMODULE WINAPI GetModuleHandleA(LPCSTR);
|
HMODULE WINAPI GetModuleHandleA(LPCSTR);
|
||||||
HMODULE WINAPI GetModuleHandleW(LPCWSTR);
|
HMODULE WINAPI GetModuleHandleW(LPCWSTR);
|
||||||
#define GetModuleHandle WINELIB_NAME_AW(GetModuleHandle)
|
#define GetModuleHandle WINELIB_NAME_AW(GetModuleHandle)
|
||||||
|
BOOL WINAPI GetModuleHandleExA(DWORD,LPCSTR,HMODULE*);
|
||||||
|
BOOL WINAPI GetModuleHandleExW(DWORD,LPCWSTR,HMODULE*);
|
||||||
|
#define GetModuleHandleEx WINELIB_NAME_AW(GetModuleHandleEx)
|
||||||
BOOL WINAPI GetNamedPipeHandleStateA(HANDLE,LPDWORD,LPDWORD,LPDWORD,LPDWORD,LPSTR,DWORD);
|
BOOL WINAPI GetNamedPipeHandleStateA(HANDLE,LPDWORD,LPDWORD,LPDWORD,LPDWORD,LPSTR,DWORD);
|
||||||
BOOL WINAPI GetNamedPipeHandleStateW(HANDLE,LPDWORD,LPDWORD,LPDWORD,LPDWORD,LPWSTR,DWORD);
|
BOOL WINAPI GetNamedPipeHandleStateW(HANDLE,LPDWORD,LPDWORD,LPDWORD,LPDWORD,LPWSTR,DWORD);
|
||||||
#define GetNamedPipeHandleState WINELIB_NAME_AW(GetNamedPipeHandleState)
|
#define GetNamedPipeHandleState WINELIB_NAME_AW(GetNamedPipeHandleState)
|
||||||
|
|
Loading…
Reference in New Issue