kernel32: Return failure from GetModuleHandleEx if the module handle pointer is NULL.
This commit is contained in:
parent
7133c000cd
commit
e8a95bf683
|
@ -508,6 +508,12 @@ BOOL WINAPI GetModuleHandleExW( DWORD flags, LPCWSTR name, HMODULE *module )
|
|||
HMODULE ret;
|
||||
ULONG magic;
|
||||
|
||||
if (!module)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* if we are messing with the refcount, grab the loader lock */
|
||||
if ((flags & GET_MODULE_HANDLE_EX_FLAG_PIN) ||
|
||||
!(flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
|
||||
|
@ -542,7 +548,7 @@ BOOL WINAPI GetModuleHandleExW( DWORD flags, LPCWSTR name, HMODULE *module )
|
|||
!(flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
|
||||
LdrUnlockLoaderLock( 0, magic );
|
||||
|
||||
if (module) *module = ret;
|
||||
*module = ret;
|
||||
return (status == STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
@ -518,14 +518,14 @@ static void testGetModuleHandleEx(void)
|
|||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExA( 0, NULL, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExA( 0, "kernel32", NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
mod = (HMODULE)0xdeadbeef;
|
||||
|
@ -545,14 +545,14 @@ static void testGetModuleHandleEx(void)
|
|||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExW( 0, NULL, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExW( 0, kernel32W, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
mod = (HMODULE)0xdeadbeef;
|
||||
|
@ -572,14 +572,14 @@ static void testGetModuleHandleEx(void)
|
|||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
mod = (HMODULE)0xdeadbeef;
|
||||
|
@ -598,14 +598,14 @@ static void testGetModuleHandleEx(void)
|
|||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
mod = (HMODULE)0xdeadbeef;
|
||||
|
@ -626,14 +626,14 @@ static void testGetModuleHandleEx(void)
|
|||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
mod = (HMODULE)0xdeadbeef;
|
||||
|
@ -653,14 +653,14 @@ static void testGetModuleHandleEx(void)
|
|||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, NULL );
|
||||
error = GetLastError();
|
||||
todo_wine ok( !ret, "unexpected success\n" );
|
||||
todo_wine ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
mod = (HMODULE)0xdeadbeef;
|
||||
|
|
Loading…
Reference in New Issue