[PATCH v2 18/22] ntdll: Factor out get_procedure_address() function.

Paul Gofman pgofman at codeweavers.com
Tue Oct 5 17:49:24 CDT 2021


Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
 dlls/ntdll/loader.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index e3610667e06..a503b577027 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2053,22 +2053,21 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG_PTR magic )
     return STATUS_SUCCESS;
 }
 
-
 /******************************************************************
- *		LdrGetProcedureAddress  (NTDLL.@)
+ *		get_procedure_address
+ *
+ *  Helper for LdrGetProcedureAddress().
  */
-NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
-                                       ULONG ord, PVOID *address)
+NTSTATUS get_procedure_address( HMODULE module, const ANSI_STRING *name,
+                                ULONG ord, void **address )
 {
     IMAGE_EXPORT_DIRECTORY *exports;
     DWORD exp_size;
-    NTSTATUS ret = STATUS_PROCEDURE_NOT_FOUND;
-
-    lock_loader_exclusive();
 
     /* check if the module itself is invalid to return the proper error */
-    if (!get_modref( module )) ret = STATUS_DLL_NOT_FOUND;
-    else if ((exports = RtlImageDirectoryEntryToData( module, TRUE,
+    if (!get_modref( module )) return STATUS_DLL_NOT_FOUND;
+
+    if ((exports = RtlImageDirectoryEntryToData( module, TRUE,
                                                       IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size )))
     {
         void *proc = name ? find_named_export( module, exports, exp_size, name->Buffer, -1, NULL )
@@ -2076,10 +2075,22 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
         if (proc)
         {
             *address = proc;
-            ret = STATUS_SUCCESS;
+            return STATUS_SUCCESS;
         }
     }
+    return STATUS_PROCEDURE_NOT_FOUND;
+}
+
+/******************************************************************
+ *		LdrGetProcedureAddress  (NTDLL.@)
+ */
+NTSTATUS WINAPI LdrGetProcedureAddress( HMODULE module, const ANSI_STRING *name,
+                                        ULONG ord, PVOID *address )
+{
+    NTSTATUS ret;
 
+    lock_loader_exclusive();
+    ret = get_procedure_address( module, name, ord, address );
     unlock_loader();
     return ret;
 }
-- 
2.31.1




More information about the wine-devel mailing list