- added PEB_LDR_DATA structure to PEB
- removed a couple of no longer needed global & static variables
(Note: with this path, DVD Shrink 2.0 now starts. It's still unusable because of missing features in the file part, like calling SetFilePointer on a handle gotten from a CDROM drive)
A+ -- Eric Pouech
diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/ntdll31/loader.c dlls/ntdll/loader.c --- dlls/ntdll31/loader.c 2003-06-09 11:50:43.000000000 +0200 +++ dlls/ntdll/loader.c 2003-06-26 21:52:38.000000000 +0200 @@ -41,9 +41,6 @@ typedef DWORD (CALLBACK *DLLENTRYPROC)(HMODULE,DWORD,LPVOID); -WINE_MODREF *MODULE_modref_list = NULL; - -static WINE_MODREF *exe_modref; static int process_detaching = 0; /* set on process detach to avoid deadlocks with thread detach */ static int free_lib_count; /* recursion depth of LdrUnloadDll calls */ @@ -89,19 +86,20 @@ */ static WINE_MODREF *get_modref( HMODULE hmod ) { - WINE_MODREF *wm; + PLIST_ENTRY mark, entry; + PLDR_MODULE mod; if (cached_modref && cached_modref->ldr.BaseAddress == hmod) return cached_modref; - for ( wm = MODULE_modref_list; wm; wm=wm->next ) + mark = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) { - if (wm->ldr.BaseAddress == hmod) - { - cached_modref = wm; - break; - } + mod = CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList); + if (mod->BaseAddress == hmod) + return cached_modref = CONTAINING_RECORD(mod, WINE_MODREF, ldr); + if (mod->BaseAddress > (void*)hmod) break; } - return wm; + return NULL; } @@ -351,6 +349,8 @@ { WINE_MODREF *wm; IMAGE_NT_HEADERS *nt = RtlImageNtHeader(hModule); + PLIST_ENTRY entry, mark; + BOOLEAN linked = FALSE; DWORD long_len = strlen( filename ); DWORD short_len = GetShortPathNameA( filename, NULL, 0 ); @@ -368,16 +368,6 @@ if ((wm->short_modname = strrchr( wm->short_filename, '\\' ))) wm->short_modname++; else wm->short_modname = wm->short_filename; - wm->next = MODULE_modref_list; - if (wm->next) wm->next->prev = wm; - MODULE_modref_list = wm; - - wm->ldr.InLoadOrderModuleList.Flink = NULL; - wm->ldr.InLoadOrderModuleList.Blink = NULL; - wm->ldr.InMemoryOrderModuleList.Flink = NULL; - wm->ldr.InMemoryOrderModuleList.Blink = NULL; - wm->ldr.InInitializationOrderModuleList.Flink = NULL; - wm->ldr.InInitializationOrderModuleList.Blink = NULL; wm->ldr.BaseAddress = hModule; wm->ldr.EntryPoint = (nt->OptionalHeader.AddressOfEntryPoint) ? ((char *)hModule + nt->OptionalHeader.AddressOfEntryPoint) : 0; @@ -391,12 +381,45 @@ wm->ldr.CheckSum = 0; wm->ldr.TimeDateStamp = 0; + /* this is a bit ugly, but we need to have app module first in LoadOrder + * list, but in wine, ntdll is loaded first, so this by inserting DLLs at the tail + * and app at the head we insure that order + */ if (!(nt->FileHeader.Characteristics & IMAGE_FILE_DLL)) { - if (!exe_modref) exe_modref = wm; - else FIXME( "Trying to load second .EXE file: %s\n", filename ); + /* is first loaded module a DLL or an exec ? */ + mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList; + if (mark->Flink == mark || + (CONTAINING_RECORD(mark->Flink, LDR_MODULE, InLoadOrderModuleList)->Flags & LDR_IMAGE_IS_DLL)) + { + InsertHeadList(&NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList, + &wm->ldr.InLoadOrderModuleList); + linked = TRUE; + } + else + FIXME( "Trying to load second .EXE file: %s\n", filename ); } else wm->ldr.Flags |= LDR_IMAGE_IS_DLL; + + if (!linked) + InsertTailList(&NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList, + &wm->ldr.InLoadOrderModuleList); + + /* insert module in MemoryList, sorted in increasing base addresses */ + mark = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) + { + if (CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList)->BaseAddress > wm->ldr.BaseAddress) + break; + } + entry->Blink->Flink = &wm->ldr.InMemoryOrderModuleList; + wm->ldr.InMemoryOrderModuleList.Blink = entry->Blink; + wm->ldr.InMemoryOrderModuleList.Flink = entry; + entry->Blink = &wm->ldr.InMemoryOrderModuleList; + + /* wait until init is called for inserting into this list */ + wm->ldr.InInitializationOrderModuleList.Flink = NULL; + wm->ldr.InInitializationOrderModuleList.Blink = NULL; } return wm; } @@ -409,13 +432,16 @@ */ static NTSTATUS alloc_process_tls(void) { - WINE_MODREF *wm; + PLIST_ENTRY mark, entry; + PLDR_MODULE mod; IMAGE_TLS_DIRECTORY *dir; ULONG size, i; - for (wm = MODULE_modref_list; wm; wm = wm->next) + mark = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) { - if (!(dir = RtlImageDirectoryEntryToData( wm->ldr.BaseAddress, TRUE, + mod = CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList); + if (!(dir = RtlImageDirectoryEntryToData( mod->BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_TLS, &size ))) continue; size = (dir->EndAddressOfRawData - dir->StartAddressOfRawData) + dir->SizeOfZeroFill; @@ -430,15 +456,16 @@ tls_dirs = RtlAllocateHeap( ntdll_get_process_heap(), 0, tls_module_count * sizeof(*tls_dirs) ); if (!tls_dirs) return STATUS_NO_MEMORY; - for (i = 0, wm = MODULE_modref_list; wm; wm = wm->next) + for (i = 0, entry = mark->Flink; entry != mark; entry = entry->Flink) { - if (!(dir = RtlImageDirectoryEntryToData( wm->ldr.BaseAddress, TRUE, + mod = CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList); + if (!(dir = RtlImageDirectoryEntryToData( mod->BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_TLS, &size ))) continue; tls_dirs[i] = dir; *dir->AddressOfIndex = i; - wm->ldr.TlsIndex = i; - wm->ldr.LoadCount = -1; /* can't unload it */ + mod->TlsIndex = i; + mod->LoadCount = -1; /* can't unload it */ i++; } return STATUS_SUCCESS; @@ -591,7 +618,12 @@ if (!wm) { - wm = exe_modref; + PLIST_ENTRY mark; + + mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList; + wm = CONTAINING_RECORD(CONTAINING_RECORD(mark->Flink, + LDR_MODULE, InLoadOrderModuleList), + WINE_MODREF, ldr); wm->ldr.LoadCount = -1; /* can't unload main exe */ if ((status = alloc_process_tls()) != STATUS_SUCCESS) goto done; if ((status = alloc_thread_tls()) != STATUS_SUCCESS) goto done; @@ -627,17 +659,9 @@ current_modref = prev; } - /* Re-insert MODREF at head of list */ - if (status == STATUS_SUCCESS && wm->prev ) - { - wm->prev->next = wm->next; - if ( wm->next ) wm->next->prev = wm->prev; - - wm->prev = NULL; - wm->next = MODULE_modref_list; - MODULE_modref_list = wm->next->prev = wm; - } - + InsertTailList(&NtCurrentTeb()->Peb->LdrData->InInitializationOrderModuleList, + &wm->ldr.InInitializationOrderModuleList); + /* Remove recursion flag */ wm->ldr.Flags &= ~LDR_LOAD_IN_PROGRESS; @@ -657,29 +681,34 @@ */ static void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved ) { - WINE_MODREF *wm; + PLIST_ENTRY mark, entry; + PLDR_MODULE mod; RtlEnterCriticalSection( &loader_section ); if (bForceDetach) process_detaching = 1; + mark = &NtCurrentTeb()->Peb->LdrData->InInitializationOrderModuleList; do { - for ( wm = MODULE_modref_list; wm; wm = wm->next ) + for (entry = mark->Blink; entry != mark; entry = entry->Blink) { + mod = CONTAINING_RECORD(entry, LDR_MODULE, + InInitializationOrderModuleList); /* Check whether to detach this DLL */ - if ( !(wm->ldr.Flags & LDR_PROCESS_ATTACHED) ) + if ( !(mod->Flags & LDR_PROCESS_ATTACHED) ) continue; - if ( wm->ldr.LoadCount && !bForceDetach ) + if ( mod->LoadCount && !bForceDetach ) continue; /* Call detach notification */ - wm->ldr.Flags &= ~LDR_PROCESS_ATTACHED; - MODULE_InitDLL( wm, DLL_PROCESS_DETACH, lpReserved ); + mod->Flags &= ~LDR_PROCESS_ATTACHED; + MODULE_InitDLL( CONTAINING_RECORD(mod, WINE_MODREF, ldr), + DLL_PROCESS_DETACH, lpReserved ); /* Restart at head of WINE_MODREF list, as entries might have been added and/or removed while performing the call ... */ break; } - } while ( wm ); + } while (entry != mark); RtlLeaveCriticalSection( &loader_section ); } @@ -693,8 +722,9 @@ */ NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved ) { - WINE_MODREF *wm; - NTSTATUS status; + PLIST_ENTRY mark, entry; + PLDR_MODULE mod; + NTSTATUS status; /* don't do any attach calls if process is exiting */ if (process_detaching) return STATUS_SUCCESS; @@ -704,18 +734,18 @@ if ((status = alloc_thread_tls()) != STATUS_SUCCESS) goto done; - for ( wm = MODULE_modref_list; wm; wm = wm->next ) - if ( !wm->next ) - break; - - for ( ; wm; wm = wm->prev ) + mark = &NtCurrentTeb()->Peb->LdrData->InInitializationOrderModuleList; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) { - if ( !(wm->ldr.Flags & LDR_PROCESS_ATTACHED) ) + mod = CONTAINING_RECORD(entry, LDR_MODULE, + InInitializationOrderModuleList); + if ( !(mod->Flags & LDR_PROCESS_ATTACHED) ) continue; - if ( wm->ldr.Flags & LDR_NO_DLL_CALLS ) + if ( mod->Flags & LDR_NO_DLL_CALLS ) continue; - MODULE_InitDLL( wm, DLL_THREAD_ATTACH, lpReserved ); + MODULE_InitDLL( CONTAINING_RECORD(mod, WINE_MODREF, ldr), + DLL_THREAD_ATTACH, lpReserved ); } done: @@ -750,18 +780,22 @@ * * The loader_section must be locked while calling this function */ -NTSTATUS WINAPI LdrFindEntryForAddress(const void* addr, PLDR_MODULE* mod) +NTSTATUS WINAPI LdrFindEntryForAddress(const void* addr, PLDR_MODULE* pmod) { - WINE_MODREF* wm; + PLIST_ENTRY mark, entry; + PLDR_MODULE mod; - for ( wm = MODULE_modref_list; wm; wm = wm->next ) + mark = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) { - if ((const void *)wm->ldr.BaseAddress <= addr && - (char *)addr < (char*)wm->ldr.BaseAddress + wm->ldr.SizeOfImage) + mod = CONTAINING_RECORD(entry, LDR_MODULE, InMemoryOrderModuleList); + if ((const void *)mod->BaseAddress <= addr && + (char *)addr < (char*)mod->BaseAddress + mod->SizeOfImage) { - *mod = &wm->ldr; + *pmod = mod; return STATUS_SUCCESS; } + if ((const void *)mod->BaseAddress > addr) break; } return STATUS_NO_MORE_ENTRIES; } @@ -780,6 +814,8 @@ WINE_MODREF *MODULE_FindModule(LPCSTR path) { WINE_MODREF *wm; + PLIST_ENTRY mark, entry; + PLDR_MODULE mod; char dllname[260], *p; /* Append .DLL to name if no extension present */ @@ -795,13 +831,19 @@ if ( !FILE_strcasecmp( dllname, wm->short_filename ) ) return wm; } - for ( wm = MODULE_modref_list; wm; wm = wm->next ) + mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) { + mod = CONTAINING_RECORD(entry, LDR_MODULE, InLoadOrderModuleList); + wm = CONTAINING_RECORD(mod, WINE_MODREF, ldr); + if ( !FILE_strcasecmp( dllname, wm->modname ) ) break; if ( !FILE_strcasecmp( dllname, wm->filename ) ) break; if ( !FILE_strcasecmp( dllname, wm->short_modname ) ) break; if ( !FILE_strcasecmp( dllname, wm->short_filename ) ) break; } + if (entry == mark) wm = NULL; + cached_modref = wm; return wm; } @@ -1156,28 +1198,31 @@ NTSTATUS nts = STATUS_SUCCESS; ANSI_STRING str; char* ptr; - WINE_MODREF* wm; + PLIST_ENTRY mark, entry; + PLDR_MODULE mod; smi->ModulesCount = 0; RtlEnterCriticalSection( &loader_section ); - for ( wm = MODULE_modref_list; wm; wm = wm->next ) + mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) { + mod = CONTAINING_RECORD(entry, LDR_MODULE, InLoadOrderModuleList); size += sizeof(*sm); if (size <= buf_size) { sm->Reserved1 = 0; /* FIXME */ sm->Reserved2 = 0; /* FIXME */ - sm->ImageBaseAddress = wm->ldr.BaseAddress; - sm->ImageSize = wm->ldr.SizeOfImage; - sm->Flags = wm->ldr.Flags; + sm->ImageBaseAddress = mod->BaseAddress; + sm->ImageSize = mod->SizeOfImage; + sm->Flags = mod->Flags; sm->Id = 0; /* FIXME */ sm->Rank = 0; /* FIXME */ sm->Unknown = 0; /* FIXME */ str.Length = 0; str.MaximumLength = MAXIMUM_FILENAME_LENGTH; str.Buffer = sm->Name; - RtlUnicodeStringToAnsiString(&str, &wm->ldr.FullDllName, FALSE); + RtlUnicodeStringToAnsiString(&str, &mod->FullDllName, FALSE); ptr = strrchr(sm->Name, '\\'); sm->NameOffset = (ptr != NULL) ? (ptr - (char*)sm->Name + 1) : 0; @@ -1209,7 +1254,9 @@ */ void WINAPI LdrShutdownThread(void) { - WINE_MODREF *wm; + PLIST_ENTRY mark, entry; + PLDR_MODULE mod; + TRACE("()\n"); /* don't do any detach calls if process is exiting */ @@ -1218,14 +1265,18 @@ RtlEnterCriticalSection( &loader_section ); - for ( wm = MODULE_modref_list; wm; wm = wm->next ) + mark = &NtCurrentTeb()->Peb->LdrData->InInitializationOrderModuleList; + for (entry = mark->Blink; entry != mark; entry = entry->Blink) { - if ( !(wm->ldr.Flags & LDR_PROCESS_ATTACHED) ) + mod = CONTAINING_RECORD(entry, LDR_MODULE, + InInitializationOrderModuleList); + if ( !(mod->Flags & LDR_PROCESS_ATTACHED) ) continue; - if ( wm->ldr.Flags & LDR_NO_DLL_CALLS ) + if ( mod->Flags & LDR_NO_DLL_CALLS ) continue; - MODULE_InitDLL( wm, DLL_THREAD_DETACH, NULL ); + MODULE_InitDLL( CONTAINING_RECORD(mod, WINE_MODREF, ldr), + DLL_THREAD_DETACH, NULL ); } RtlLeaveCriticalSection( &loader_section ); @@ -1241,22 +1292,23 @@ */ static void MODULE_FlushModrefs(void) { - WINE_MODREF *wm, *next; - - for (wm = MODULE_modref_list; wm; wm = next) - { - next = wm->next; - - if (wm->ldr.LoadCount) - continue; - - /* Unlink this modref from the chain */ - if (wm->next) - wm->next->prev = wm->prev; - if (wm->prev) - wm->prev->next = wm->next; - if (wm == MODULE_modref_list) - MODULE_modref_list = wm->next; + PLIST_ENTRY mark, entry, prev; + PLDR_MODULE mod; + WINE_MODREF*wm; + + mark = &NtCurrentTeb()->Peb->LdrData->InInitializationOrderModuleList; + for (entry = mark->Blink; entry != mark; entry = prev) + { + mod = CONTAINING_RECORD(entry, LDR_MODULE, + InInitializationOrderModuleList); + wm = CONTAINING_RECORD(mod, WINE_MODREF, ldr); + + prev = entry->Blink; + if (wm->ldr.LoadCount) continue; + + RemoveEntryList(&wm->ldr.InLoadOrderModuleList); + RemoveEntryList(&wm->ldr.InMemoryOrderModuleList); + RemoveEntryList(&wm->ldr.InInitializationOrderModuleList); TRACE(" unloading %s\n", wm->filename); if (!TRACE_ON(module)) diff -u -N -r -x '*~' -x '.#*' -x CVS include31/module.h include/module.h --- include31/module.h 2003-05-22 08:28:31.000000000 +0200 +++ include/module.h 2003-06-26 21:49:13.000000000 +0200 @@ -128,8 +128,6 @@ /* internal representation of 32bit modules. per process. */ typedef struct _wine_modref { - struct _wine_modref *next; - struct _wine_modref *prev; void *dlhandle; /* handle returned by dlopen() */ LDR_MODULE ldr; @@ -144,8 +142,6 @@ char data[1]; /* space for storing filename and short_filename */ } WINE_MODREF; -extern WINE_MODREF *MODULE_modref_list; - /* Resource types */ #define NE_SEG_TABLE(pModule) \ diff -u -N -r -x '*~' -x '.#*' -x CVS include31/winternl.h include/winternl.h --- include31/winternl.h 2003-06-26 21:42:39.000000000 +0200 +++ include/winternl.h 2003-06-26 20:13:36.000000000 +0200 @@ -133,6 +133,16 @@ } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; +typedef struct _PEB_LDR_DATA +{ + ULONG Length; + BOOLEAN Initialized; + PVOID SsHandle; + LIST_ENTRY InLoadOrderModuleList; + LIST_ENTRY InMemoryOrderModuleList; + LIST_ENTRY InInitializationOrderModuleList; +} PEB_LDR_DATA, *PPEB_LDR_DATA; + /*********************************************************************** * PEB data structure */ @@ -142,7 +152,7 @@ BYTE BeingDebugged; /* 02 */ BYTE Reserved2[5]; /* 03 */ HMODULE ImageBaseAddress; /* 08 */ - PVOID __pad_0c; /* 0c */ + PPEB_LDR_DATA LdrData; /* 0c */ RTL_USER_PROCESS_PARAMETERS *ProcessParameters; /* 10 */ PVOID __pad_14; /* 14 */ HANDLE ProcessHeap; /* 18 */ @@ -1366,6 +1376,39 @@ NTSTATUS WINAPI LdrUnloadDll(HMODULE); NTSTATUS WINAPI LdrUnlockLoaderLock(ULONG,ULONG); +/* list manipulation macros */ +#define InitializeListHead(le) (void)((le)->Flink = (le)->Blink = (le)) +#define InsertHeadList(le,e) do { PLIST_ENTRY f = (le)->Flink; (e)->Flink = f; (e)->Blink = (le); f->Blink = (e); (le)->Flink = (e); } while (0) +#define InsertTailList(le,e) do { PLIST_ENTRY b = (le)->Blink; (e)->Flink = (le); (e)->Blink = b; b->Flink = (e); (le)->Blink = (e); } while (0) +#define IsListEmpty(le) ((le)->Flink == (le)) +#define RemoveEntryList(e) do { PLIST_ENTRY f = (e)->Flink, b = (e)->Blink; f->Blink = b; b->Flink = f; (e)->Flink = (e)->Blink = NULL; } while (0) +static inline PLIST_ENTRY RemoveHeadList(PLIST_ENTRY le) +{ + PLIST_ENTRY f, b, e; + + e = le->Flink; + f = le->Flink->Flink; + b = le->Flink->Blink; + f->Blink = b; + b->Flink = f; + + if (e != le) e->Flink = e->Blink = NULL; + return e; +} +static inline PLIST_ENTRY RemoveTailList(PLIST_ENTRY le) +{ + PLIST_ENTRY f, b, e; + + e = le->Blink; + f = le->Blink->Flink; + b = le->Blink->Blink; + f->Blink = b; + b->Flink = f; + + if (e != le) e->Flink = e->Blink = NULL; + return e; +} + #ifdef __cplusplus } /* extern "C" */ #endif /* defined(__cplusplus) */ diff -u -N -r -x '*~' -x '.#*' -x CVS loader31/pe_image.c loader/pe_image.c --- loader31/pe_image.c 2003-05-20 20:47:16.000000000 +0200 +++ loader/pe_image.c 2003-06-26 21:56:23.000000000 +0200 @@ -265,15 +265,9 @@ if (!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) && PE_fixup_imports( wm )) { - /* remove entry from modref chain */ - - if ( !wm->prev ) - MODULE_modref_list = wm->next; - else - wm->prev->next = wm->next; - - if ( wm->next ) wm->next->prev = wm->prev; - wm->next = wm->prev = NULL; + /* the module has only be inserted in the load & memory order lists */ + RemoveEntryList(&wm->ldr.InLoadOrderModuleList); + RemoveEntryList(&wm->ldr.InMemoryOrderModuleList); /* FIXME: there are several more dangling references * left. Including dlls loaded by this dll before the diff -u -N -r -x '*~' -x '.#*' -x CVS relay3231/relay386.c relay32/relay386.c --- relay3231/relay386.c 2003-06-17 21:23:03.000000000 +0200 +++ relay32/relay386.c 2003-06-12 22:49:34.000000000 +0200 @@ -27,7 +27,6 @@ #include "winternl.h" #include "stackframe.h" -#include "module.h" #include "wine/unicode.h" #include "wine/debug.h" #include "ntdll_misc.h" @@ -284,15 +283,18 @@ char *p, *base = NULL; const char *name; int ordinal = 0; - WINE_MODREF *wm; + PLIST_ENTRY mark, entry; + PLDR_MODULE mod = NULL; DWORD size; /* First find the module */ - for (wm = MODULE_modref_list; wm; wm = wm->next) + mark = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) { - if (!(wm->ldr.Flags & LDR_WINE_INTERNAL)) continue; - exp = RtlImageDirectoryEntryToData( wm->ldr.BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &size ); + mod = CONTAINING_RECORD(entry, LDR_MODULE, InLoadOrderModuleList); + if (!(mod->Flags & LDR_WINE_INTERNAL)) continue; + exp = RtlImageDirectoryEntryToData( mod->BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &size ); if (!exp) continue; debug = (DEBUG_ENTRY_POINT *)((char *)exp + size); if (debug <= relay && relay < debug + exp->NumberOfFunctions) @@ -304,7 +306,7 @@ /* Now find the function */ - base = (char *)wm->ldr.BaseAddress; + base = (char *)mod->BaseAddress; strcpy( buffer, base + exp->Name ); p = buffer + strlen(buffer); if (p > buffer + 4 && !strcasecmp( p - 4, ".dll" )) p -= 4; diff -u -N -r -x '*~' -x '.#*' -x CVS scheduler31/process.c scheduler/process.c --- scheduler31/process.c 2003-06-21 16:26:34.000000000 +0200 +++ scheduler/process.c 2003-06-26 21:47:56.000000000 +0200 @@ -60,8 +60,8 @@ { LONG header[2]; /* 00 Kernel object header */ HMODULE module; /* 08 Main exe module (NT) */ - void *event; /* 0c Pointer to an event object (unused) */ - RTL_USER_PROCESS_PARAMETERS *ProcessParameters; /* 10 Process parameters*/ + PPEB_LDR_DATA LdrData; /* 0c Pointer to loader information */ + RTL_USER_PROCESS_PARAMETERS *ProcessParameters; /* 10 Process parameters */ DWORD unknown2; /* 14 Unknown */ HANDLE heap; /* 18 Default process heap */ HANDLE mem_context; /* 1c Process memory context */ @@ -107,7 +107,8 @@ PDB current_process; -static RTL_USER_PROCESS_PARAMETERS process_pmts; +static RTL_USER_PROCESS_PARAMETERS process_pmts; +static PEB_LDR_DATA process_ldr; /* Process flags */ #define PDB32_DEBUGGED 0x0001 /* Process is being debugged */ @@ -298,12 +299,16 @@ argv0 = argv[0]; /* Fill the initial process structure */ - current_process.threads = 1; - current_process.running_threads = 1; - current_process.ring0_threads = 1; - current_process.group = ¤t_process; - current_process.priority = 8; /* Normal */ + current_process.threads = 1; + current_process.running_threads = 1; + current_process.ring0_threads = 1; + current_process.group = ¤t_process; + current_process.priority = 8; /* Normal */ current_process.ProcessParameters = &process_pmts; + current_process.LdrData = &process_ldr; + InitializeListHead(&process_ldr.InLoadOrderModuleList); + InitializeListHead(&process_ldr.InMemoryOrderModuleList); + InitializeListHead(&process_ldr.InInitializationOrderModuleList); /* Setup the server connection */ CLIENT_InitServer();