From ba71316172c79815598138435974e9a141217384 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 18 Sep 2003 20:59:54 +0000 Subject: [PATCH] Moved a couple more functions to dlls/kernel. --- dlls/kernel/ne_module.c | 98 +++++++++++++++++++++++++++++++++++ loader/ne/module.c | 110 ---------------------------------------- loader/task.c | 37 -------------- 3 files changed, 98 insertions(+), 147 deletions(-) diff --git a/dlls/kernel/ne_module.c b/dlls/kernel/ne_module.c index 7e124698925..74b53dfac5c 100644 --- a/dlls/kernel/ne_module.c +++ b/dlls/kernel/ne_module.c @@ -1586,6 +1586,104 @@ void WINAPI FreeLibrary16( HINSTANCE16 handle ) } +/*********************************************************************** + * GetModuleHandle16 (KERNEL32.@) + */ +HMODULE16 WINAPI GetModuleHandle16( LPCSTR name ) +{ + HMODULE16 hModule = hFirstModule; + LPSTR s; + BYTE len, *name_table; + char tmpstr[MAX_PATH]; + NE_MODULE *pModule; + + TRACE("(%s)\n", name); + + if (!HIWORD(name)) return GetExePtr(LOWORD(name)); + + len = strlen(name); + if (!len) return 0; + + lstrcpynA(tmpstr, name, sizeof(tmpstr)); + + /* If 'name' matches exactly the module name of a module: + * Return its handle. + */ + for (hModule = hFirstModule; hModule ; hModule = pModule->next) + { + pModule = NE_GetPtr( hModule ); + if (!pModule) break; + if (pModule->flags & NE_FFLAGS_WIN32) continue; + + name_table = (BYTE *)pModule + pModule->name_table; + if ((*name_table == len) && !strncmp(name, name_table+1, len)) + return hModule; + } + + /* If uppercased 'name' matches exactly the module name of a module: + * Return its handle + */ + for (s = tmpstr; *s; s++) *s = FILE_toupper(*s); + + for (hModule = hFirstModule; hModule ; hModule = pModule->next) + { + pModule = NE_GetPtr( hModule ); + if (!pModule) break; + if (pModule->flags & NE_FFLAGS_WIN32) continue; + + name_table = (BYTE *)pModule + pModule->name_table; + /* FIXME: the strncasecmp is WRONG. It should not be case insensitive, + * but case sensitive! (Unfortunately Winword 6 and subdlls have + * lowercased module names, but try to load uppercase DLLs, so this + * 'i' compare is just a quickfix until the loader handles that + * correctly. -MM 990705 + */ + if ((*name_table == len) && !FILE_strncasecmp(tmpstr, name_table+1, len)) + return hModule; + } + + /* If the base filename of 'name' matches the base filename of the module + * filename of some module (case-insensitive compare): + * Return its handle. + */ + + /* basename: search backwards in passed name to \ / or : */ + s = tmpstr + strlen(tmpstr); + while (s > tmpstr) + { + if (s[-1]=='/' || s[-1]=='\\' || s[-1]==':') + break; + s--; + } + + /* search this in loaded filename list */ + for (hModule = hFirstModule; hModule ; hModule = pModule->next) + { + char *loadedfn; + OFSTRUCT *ofs; + + pModule = NE_GetPtr( hModule ); + if (!pModule) break; + if (!pModule->fileinfo) continue; + if (pModule->flags & NE_FFLAGS_WIN32) continue; + + ofs = (OFSTRUCT*)((BYTE *)pModule + pModule->fileinfo); + loadedfn = ((char*)ofs->szPathName) + strlen(ofs->szPathName); + /* basename: search backwards in pathname to \ / or : */ + while (loadedfn > (char*)ofs->szPathName) + { + if (loadedfn[-1]=='/' || loadedfn[-1]=='\\' || loadedfn[-1]==':') + break; + loadedfn--; + } + /* case insensitive compare ... */ + if (!FILE_strcasecmp(loadedfn, s)) + return hModule; + } + return 0; +} + + /********************************************************************** * GetModuleName (KERNEL.27) */ diff --git a/loader/ne/module.c b/loader/ne/module.c index 99fb8115f1f..1e479b1931c 100644 --- a/loader/ne/module.c +++ b/loader/ne/module.c @@ -51,16 +51,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(module); WINE_DECLARE_DEBUG_CHANNEL(loaddll); -#include "pshpack1.h" -typedef struct _GPHANDLERDEF -{ - WORD selector; - WORD rangeStart; - WORD rangeEnd; - WORD handler; -} GPHANDLERDEF; -#include "poppack.h" - #define hFirstModule (pThhook->hExeHead) @@ -97,103 +87,3 @@ INT16 WINAPI GetModuleFileName16( HINSTANCE16 hModule, LPSTR lpFileName, TRACE("%04x -> '%s'\n", hModule, lpFileName ); return strlen(lpFileName); } - - -/*********************************************************************** - * GetModuleHandle16 (KERNEL32.@) - */ -HMODULE16 WINAPI GetModuleHandle16( LPCSTR name ) -{ - HMODULE16 hModule = hFirstModule; - LPSTR s; - BYTE len, *name_table; - char tmpstr[MAX_PATH]; - NE_MODULE *pModule; - - TRACE("(%s)\n", name); - - if (!HIWORD(name)) - return GetExePtr(LOWORD(name)); - - len = strlen(name); - if (!len) - return 0; - - lstrcpynA(tmpstr, name, sizeof(tmpstr)); - - /* If 'name' matches exactly the module name of a module: - * Return its handle. - */ - for (hModule = hFirstModule; hModule ; hModule = pModule->next) - { - pModule = NE_GetPtr( hModule ); - if (!pModule) break; - if (pModule->flags & NE_FFLAGS_WIN32) continue; - - name_table = (BYTE *)pModule + pModule->name_table; - if ((*name_table == len) && !strncmp(name, name_table+1, len)) - return hModule; - } - - /* If uppercased 'name' matches exactly the module name of a module: - * Return its handle - */ - for (s = tmpstr; *s; s++) *s = FILE_toupper(*s); - - for (hModule = hFirstModule; hModule ; hModule = pModule->next) - { - pModule = NE_GetPtr( hModule ); - if (!pModule) break; - if (pModule->flags & NE_FFLAGS_WIN32) continue; - - name_table = (BYTE *)pModule + pModule->name_table; - /* FIXME: the strncasecmp is WRONG. It should not be case insensitive, - * but case sensitive! (Unfortunately Winword 6 and subdlls have - * lowercased module names, but try to load uppercase DLLs, so this - * 'i' compare is just a quickfix until the loader handles that - * correctly. -MM 990705 - */ - if ((*name_table == len) && !FILE_strncasecmp(tmpstr, name_table+1, len)) - return hModule; - } - - /* If the base filename of 'name' matches the base filename of the module - * filename of some module (case-insensitive compare): - * Return its handle. - */ - - /* basename: search backwards in passed name to \ / or : */ - s = tmpstr + strlen(tmpstr); - while (s > tmpstr) - { - if (s[-1]=='/' || s[-1]=='\\' || s[-1]==':') - break; - s--; - } - - /* search this in loaded filename list */ - for (hModule = hFirstModule; hModule ; hModule = pModule->next) - { - char *loadedfn; - OFSTRUCT *ofs; - - pModule = NE_GetPtr( hModule ); - if (!pModule) break; - if (!pModule->fileinfo) continue; - if (pModule->flags & NE_FFLAGS_WIN32) continue; - - ofs = (OFSTRUCT*)((BYTE *)pModule + pModule->fileinfo); - loadedfn = ((char*)ofs->szPathName) + strlen(ofs->szPathName); - /* basename: search backwards in pathname to \ / or : */ - while (loadedfn > (char*)ofs->szPathName) - { - if (loadedfn[-1]=='/' || loadedfn[-1]=='\\' || loadedfn[-1]==':') - break; - loadedfn--; - } - /* case insensitive compare ... */ - if (!FILE_strcasecmp(loadedfn, s)) - return hModule; - } - return 0; -} diff --git a/loader/task.c b/loader/task.c index 245ab13f887..c457039edc8 100644 --- a/loader/task.c +++ b/loader/task.c @@ -67,15 +67,6 @@ static TDB *TASK_GetPtr( HTASK16 hTask ) } -/*********************************************************************** - * TASK_GetCurrent - */ -TDB *TASK_GetCurrent(void) -{ - return TASK_GetPtr( GetCurrentTask() ); -} - - /*********************************************************************** * GetCurrentTask (KERNEL32.@) */ @@ -84,20 +75,6 @@ HTASK16 WINAPI GetCurrentTask(void) return NtCurrentTeb()->htask16; } -/*********************************************************************** - * GetCurrentPDB (KERNEL.37) - * - * UNDOC: returns PSP of KERNEL in high word - */ -DWORD WINAPI GetCurrentPDB16(void) -{ - TDB *pTask; - - if (!(pTask = TASK_GetCurrent())) return 0; - return MAKELONG(pTask->hPDB, 0); /* FIXME */ -} - - /*********************************************************************** * GetExePtrHelper */ @@ -146,20 +123,6 @@ static inline HMODULE16 GetExePtrHelper( HANDLE16 handle, HTASK16 *hTask ) return 0; } -/*********************************************************************** - * GetExePtr (KERNEL.133) - */ -HMODULE16 WINAPI WIN16_GetExePtr( HANDLE16 handle ) -{ - HTASK16 hTask = 0; - HMODULE16 hModule = GetExePtrHelper( handle, &hTask ); - STACK16FRAME *frame = CURRENT_STACK16; - frame->ecx = hModule; - if (hTask) frame->es = hTask; - return hModule; -} - - /*********************************************************************** * K228 (KERNEL.228) */