Implementations for LdrGetDllHandle and LdrGetProcedureAddress

Mike McCormack mikem at codeweavers.com
Thu Jun 6 07:51:02 CDT 2002


Tested with test program that works on NT 4.0. Eventually, we should 
access the loader functionality solely through the ntdll Ldr* functions.

Mike


License: LPGL (as always)
ChangeLog:
* partially implement LdrGetDllHandle
* implement LdrGetProcedureAddress
-------------- next part --------------
Index: dlls/ntdll/ntdll.spec
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/ntdll.spec,v
retrieving revision 1.67
diff -u -r1.67 ntdll.spec
--- dlls/ntdll/ntdll.spec	1 Jun 2002 02:55:50 -0000	1.67
+++ dlls/ntdll/ntdll.spec	6 Jun 2002 04:22:40 -0000
@@ -41,8 +41,8 @@
 @ stub LdrFindEntryForAddress
 @ stub LdrFindResourceDirectory_U
 @ stub LdrFindResource_U
-@ stub LdrGetDllHandle
-@ stub LdrGetProcedureAddress
+@ stdcall LdrGetDllHandle(long long ptr ptr) LdrGetDllHandle
+@ stdcall LdrGetProcedureAddress(ptr ptr long ptr) LdrGetProcedureAddress
 @ stub LdrInitializeThunk
 @ stub LdrLoadDll
 @ stub LdrProcessRelocationBlock
Index: dlls/ntdll/loader.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/loader.c,v
retrieving revision 1.2
diff -u -r1.2 loader.c
--- dlls/ntdll/loader.c	9 Mar 2002 23:39:09 -0000	1.2
+++ dlls/ntdll/loader.c	6 Jun 2002 04:22:40 -0000
@@ -19,6 +19,13 @@
 #include "winbase.h"
 #include "ntdef.h"
 #include "winnt.h"
+#include "ntddk.h"
+
+#include "module.h"
+#include "wine/debug.h"
+
+
+WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
 
 NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HANDLE hModule)
 {
@@ -27,3 +34,38 @@
     else
 	return STATUS_DLL_NOT_FOUND;
 }
+
+/* FIXME : MODULE_FindModule should depend on LdrGetDllHandle, not vice-versa */
+
+NTSTATUS WINAPI LdrGetDllHandle(ULONG x, LONG y, PUNICODE_STRING name, PVOID *base)
+{
+    STRING str;
+    WINE_MODREF *wm;
+
+    FIXME("%08lx %08lx %s %p : partial stub\n",x,y,debugstr_wn(name->Buffer,name->Length),base);
+
+    *base = 0;
+
+    RtlUnicodeStringToAnsiString(&str, name, TRUE);
+    wm = MODULE_FindModule(str.Buffer);
+    if(!wm)
+        return STATUS_DLL_NOT_FOUND;
+    *base = (PVOID) wm->module;
+
+    return STATUS_SUCCESS;
+}
+
+/* FIXME : MODULE_GetProcAddress should depend on LdrGetProcedureAddress, not vice-versa */
+
+NTSTATUS WINAPI LdrGetProcedureAddress(PVOID base, PANSI_STRING name, ULONG ord, PVOID *address)
+{
+    WARN("%p %s %ld %p\n",base, debugstr_an(name->Buffer,name->Length), ord, address);
+
+    if(name)
+        *address = MODULE_GetProcAddress( (HMODULE) base, name->Buffer, FALSE);
+    else
+        *address = MODULE_GetProcAddress( (HMODULE) base, (LPSTR) ord, FALSE);
+
+    return (*address) ? STATUS_SUCCESS : STATUS_DLL_NOT_FOUND;
+}
+


More information about the wine-patches mailing list