Commit a6451971 authored by Alexandre Julliard's avatar Alexandre Julliard

kernelbase: Report correct errors in GetModuleHandleExA().

parent 34a797e8
......@@ -953,6 +953,10 @@ static void init_pointers(void)
static void testGetModuleHandleEx(void)
{
static const char longname[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0};
static const WCHAR nosuchmodW[] = {'n','o','s','u','c','h','m','o','d',0};
BOOL ret;
......@@ -987,6 +991,20 @@ static void testGetModuleHandleEx(void)
ok( mod == NULL, "got %p\n", mod );
SetLastError( 0xdeadbeef );
ret = GetModuleHandleExA( 0, longname, NULL );
error = GetLastError();
ok( !ret, "unexpected success\n" );
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
SetLastError( 0xdeadbeef );
mod = (HMODULE)0xdeadbeef;
ret = GetModuleHandleExA( 0, longname, &mod );
error = GetLastError();
ok( !ret, "unexpected success\n" );
ok( error == ERROR_MOD_NOT_FOUND, "got %lu\n", error );
ok( mod == NULL, "got %p\n", mod );
SetLastError( 0xdeadbeef );
ret = GetModuleHandleExW( 0, NULL, NULL );
error = GetLastError();
ok( !ret, "unexpected success\n" );
......
......@@ -352,10 +352,21 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetModuleHandleExA( DWORD flags, LPCSTR name, HMOD
{
WCHAR *nameW;
if (!module)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
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;
if (!(nameW = file_name_AtoW( name, FALSE )))
{
*module = NULL;
SetLastError( ERROR_MOD_NOT_FOUND );
return FALSE;
}
return GetModuleHandleExW( flags, nameW, module );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment