Commit 675b7559 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

- removed next & prev fields from WINE_MODREF and implement instead

the three linked lists in LDR_MODULE - added PEB_LDR_DATA structure to PEB - removed a couple of no longer needed global & static variables
parent 2a3ce4c4
...@@ -128,8 +128,6 @@ typedef struct ...@@ -128,8 +128,6 @@ typedef struct
/* internal representation of 32bit modules. per process. */ /* internal representation of 32bit modules. per process. */
typedef struct _wine_modref typedef struct _wine_modref
{ {
struct _wine_modref *next;
struct _wine_modref *prev;
void *dlhandle; /* handle returned by dlopen() */ void *dlhandle; /* handle returned by dlopen() */
LDR_MODULE ldr; LDR_MODULE ldr;
...@@ -144,8 +142,6 @@ typedef struct _wine_modref ...@@ -144,8 +142,6 @@ typedef struct _wine_modref
char data[1]; /* space for storing filename and short_filename */ char data[1]; /* space for storing filename and short_filename */
} WINE_MODREF; } WINE_MODREF;
extern WINE_MODREF *MODULE_modref_list;
/* Resource types */ /* Resource types */
#define NE_SEG_TABLE(pModule) \ #define NE_SEG_TABLE(pModule) \
......
...@@ -133,6 +133,16 @@ typedef struct _RTL_USER_PROCESS_PARAMETERS ...@@ -133,6 +133,16 @@ typedef struct _RTL_USER_PROCESS_PARAMETERS
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; } 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 * PEB data structure
*/ */
...@@ -142,7 +152,7 @@ typedef struct _PEB ...@@ -142,7 +152,7 @@ typedef struct _PEB
BYTE BeingDebugged; /* 02 */ BYTE BeingDebugged; /* 02 */
BYTE Reserved2[5]; /* 03 */ BYTE Reserved2[5]; /* 03 */
HMODULE ImageBaseAddress; /* 08 */ HMODULE ImageBaseAddress; /* 08 */
PVOID __pad_0c; /* 0c */ PPEB_LDR_DATA LdrData; /* 0c */
RTL_USER_PROCESS_PARAMETERS *ProcessParameters; /* 10 */ RTL_USER_PROCESS_PARAMETERS *ProcessParameters; /* 10 */
PVOID __pad_14; /* 14 */ PVOID __pad_14; /* 14 */
HANDLE ProcessHeap; /* 18 */ HANDLE ProcessHeap; /* 18 */
...@@ -1367,6 +1377,39 @@ NTSTATUS WINAPI LdrQueryProcessModuleInformation(SYSTEM_MODULE_INFORMATION*, ULO ...@@ -1367,6 +1377,39 @@ NTSTATUS WINAPI LdrQueryProcessModuleInformation(SYSTEM_MODULE_INFORMATION*, ULO
NTSTATUS WINAPI LdrUnloadDll(HMODULE); NTSTATUS WINAPI LdrUnloadDll(HMODULE);
NTSTATUS WINAPI LdrUnlockLoaderLock(ULONG,ULONG); 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 #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif /* defined(__cplusplus) */ #endif /* defined(__cplusplus) */
......
...@@ -265,15 +265,9 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags, ...@@ -265,15 +265,9 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
if (!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) && if (!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) &&
PE_fixup_imports( wm )) PE_fixup_imports( wm ))
{ {
/* remove entry from modref chain */ /* the module has only be inserted in the load & memory order lists */
RemoveEntryList(&wm->ldr.InLoadOrderModuleList);
if ( !wm->prev ) RemoveEntryList(&wm->ldr.InMemoryOrderModuleList);
MODULE_modref_list = wm->next;
else
wm->prev->next = wm->next;
if ( wm->next ) wm->next->prev = wm->prev;
wm->next = wm->prev = NULL;
/* FIXME: there are several more dangling references /* FIXME: there are several more dangling references
* left. Including dlls loaded by this dll before the * left. Including dlls loaded by this dll before the
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "winternl.h" #include "winternl.h"
#include "stackframe.h" #include "stackframe.h"
#include "module.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "ntdll_misc.h" #include "ntdll_misc.h"
...@@ -284,15 +283,18 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay ) ...@@ -284,15 +283,18 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay )
char *p, *base = NULL; char *p, *base = NULL;
const char *name; const char *name;
int ordinal = 0; int ordinal = 0;
WINE_MODREF *wm; PLIST_ENTRY mark, entry;
PLDR_MODULE mod = NULL;
DWORD size; DWORD size;
/* First find the module */ /* 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; mod = CONTAINING_RECORD(entry, LDR_MODULE, InLoadOrderModuleList);
exp = RtlImageDirectoryEntryToData( wm->ldr.BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &size ); if (!(mod->Flags & LDR_WINE_INTERNAL)) continue;
exp = RtlImageDirectoryEntryToData( mod->BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &size );
if (!exp) continue; if (!exp) continue;
debug = (DEBUG_ENTRY_POINT *)((char *)exp + size); debug = (DEBUG_ENTRY_POINT *)((char *)exp + size);
if (debug <= relay && relay < debug + exp->NumberOfFunctions) if (debug <= relay && relay < debug + exp->NumberOfFunctions)
...@@ -304,7 +306,7 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay ) ...@@ -304,7 +306,7 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay )
/* Now find the function */ /* Now find the function */
base = (char *)wm->ldr.BaseAddress; base = (char *)mod->BaseAddress;
strcpy( buffer, base + exp->Name ); strcpy( buffer, base + exp->Name );
p = buffer + strlen(buffer); p = buffer + strlen(buffer);
if (p > buffer + 4 && !strcasecmp( p - 4, ".dll" )) p -= 4; if (p > buffer + 4 && !strcasecmp( p - 4, ".dll" )) p -= 4;
......
...@@ -60,8 +60,8 @@ typedef struct _PDB ...@@ -60,8 +60,8 @@ typedef struct _PDB
{ {
LONG header[2]; /* 00 Kernel object header */ LONG header[2]; /* 00 Kernel object header */
HMODULE module; /* 08 Main exe module (NT) */ HMODULE module; /* 08 Main exe module (NT) */
void *event; /* 0c Pointer to an event object (unused) */ PPEB_LDR_DATA LdrData; /* 0c Pointer to loader information */
RTL_USER_PROCESS_PARAMETERS *ProcessParameters; /* 10 Process parameters*/ RTL_USER_PROCESS_PARAMETERS *ProcessParameters; /* 10 Process parameters */
DWORD unknown2; /* 14 Unknown */ DWORD unknown2; /* 14 Unknown */
HANDLE heap; /* 18 Default process heap */ HANDLE heap; /* 18 Default process heap */
HANDLE mem_context; /* 1c Process memory context */ HANDLE mem_context; /* 1c Process memory context */
...@@ -107,7 +107,8 @@ typedef struct _PDB ...@@ -107,7 +107,8 @@ typedef struct _PDB
PDB current_process; PDB current_process;
static RTL_USER_PROCESS_PARAMETERS process_pmts; static RTL_USER_PROCESS_PARAMETERS process_pmts;
static PEB_LDR_DATA process_ldr;
static char main_exe_name[MAX_PATH]; static char main_exe_name[MAX_PATH];
static char *main_exe_name_ptr = main_exe_name; static char *main_exe_name_ptr = main_exe_name;
...@@ -290,12 +291,16 @@ static BOOL process_init( char *argv[] ) ...@@ -290,12 +291,16 @@ static BOOL process_init( char *argv[] )
argv0 = argv[0]; argv0 = argv[0];
/* Fill the initial process structure */ /* Fill the initial process structure */
current_process.threads = 1; current_process.threads = 1;
current_process.running_threads = 1; current_process.running_threads = 1;
current_process.ring0_threads = 1; current_process.ring0_threads = 1;
current_process.group = &current_process; current_process.group = &current_process;
current_process.priority = 8; /* Normal */ current_process.priority = 8; /* Normal */
current_process.ProcessParameters = &process_pmts; 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 */ /* Setup the server connection */
CLIENT_InitServer(); CLIENT_InitServer();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment