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
/* 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 @@ typedef struct _wine_modref
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) \
......
......@@ -133,6 +133,16 @@ typedef struct _RTL_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
*/
......@@ -142,7 +152,7 @@ typedef struct _PEB
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 */
......@@ -1367,6 +1377,39 @@ NTSTATUS WINAPI LdrQueryProcessModuleInformation(SYSTEM_MODULE_INFORMATION*, ULO
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) */
......
......@@ -265,15 +265,9 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
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
......
......@@ -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 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay )
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 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay )
/* 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;
......
......@@ -60,8 +60,8 @@ typedef struct _PDB
{
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 @@ typedef struct _PDB
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_ptr = main_exe_name;
......@@ -290,12 +291,16 @@ static BOOL process_init( char *argv[] )
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 = &current_process;
current_process.priority = 8; /* Normal */
current_process.threads = 1;
current_process.running_threads = 1;
current_process.ring0_threads = 1;
current_process.group = &current_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();
......
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