Alistair Leslie-Hughes : ntoskrnl.exe: Implement MmGetSystemRoutineAddress.

Alexandre Julliard julliard at winehq.org
Thu Nov 20 08:20:41 CST 2008


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

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Mon Nov 17 21:01:10 2008 +1100

ntoskrnl.exe: Implement MmGetSystemRoutineAddress.

---

 dlls/ntoskrnl.exe/ntoskrnl.c        |   30 ++++++++++++++++++++++++++++++
 dlls/ntoskrnl.exe/ntoskrnl.exe.spec |    2 +-
 2 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index e4b0ea5..c41d289 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -1071,6 +1071,36 @@ NTSTATUS WINAPI PsSetCreateProcessNotifyRoutine( PCREATE_PROCESS_NOTIFY_ROUTINE
     return STATUS_SUCCESS;
 }
 
+/***********************************************************************
+ *           MmGetSystemRoutineAddress   (NTOSKRNL.EXE.@)
+ */
+PVOID WINAPI MmGetSystemRoutineAddress(PUNICODE_STRING SystemRoutineName)
+{
+    HMODULE hMod;
+    STRING routineNameA;
+    PVOID pFunc = NULL;
+
+    static const WCHAR ntoskrnlW[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
+    static const WCHAR halW[] = {'h','a','l','.','d','l','l',0};
+
+    if (!SystemRoutineName) return NULL;
+
+    if (RtlUnicodeStringToAnsiString( &routineNameA, SystemRoutineName, TRUE ) == STATUS_SUCCESS)
+    {
+        /* We only support functions exported from ntoskrnl.exe or hal.dll */
+        hMod = GetModuleHandleW( ntoskrnlW );
+        pFunc = GetProcAddress( hMod, routineNameA.Buffer );
+        if (!pFunc)
+        {
+           hMod = GetModuleHandleW( halW );
+           if (hMod) pFunc = GetProcAddress( hMod, routineNameA.Buffer );
+        }
+        RtlFreeAnsiString( &routineNameA );
+    }
+
+    TRACE( "%s -> %p\n", debugstr_us(SystemRoutineName), pFunc );
+    return pFunc;
+}
 
 /*****************************************************
  *           DllMain
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
index 7d543d4..9303d03 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -675,7 +675,7 @@
 @ stub MmFreePagesFromMdl
 @ stub MmGetPhysicalAddress
 @ stub MmGetPhysicalMemoryRanges
-@ stub MmGetSystemRoutineAddress
+@ stdcall MmGetSystemRoutineAddress(ptr)
 @ stub MmGetVirtualForPhysical
 @ stub MmGrowKernelStack
 @ stub MmHighestUserAddress




More information about the wine-cvs mailing list