Hans Leidekker : kernel32: Return failure from GetModuleHandleEx if the module handle pointer is NULL .

Alexandre Julliard julliard at winehq.org
Thu Apr 5 12:31:45 CDT 2012


Module: wine
Branch: master
Commit: e8a95bf68379a5245a9e26c9a291e25dac212644
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e8a95bf68379a5245a9e26c9a291e25dac212644

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Thu Apr  5 11:15:50 2012 +0200

kernel32: Return failure from GetModuleHandleEx if the module handle pointer is NULL.

---

 dlls/kernel32/module.c       |    8 ++++++-
 dlls/kernel32/tests/module.c |   48 +++++++++++++++++++++---------------------
 2 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index 7d4d93b..739392f 100644
--- a/dlls/kernel32/module.c
+++ b/dlls/kernel32/module.c
@@ -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);
 }
 
diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c
index 70940f5..30da85f 100644
--- a/dlls/kernel32/tests/module.c
+++ b/dlls/kernel32/tests/module.c
@@ -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;




More information about the wine-cvs mailing list