Commit f94c8b85 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Move some fields (refCount, tls_index and module) from WINE_MODREF to

LDR_MODULE.
parent 255b6141
...@@ -71,7 +71,7 @@ static WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hmod ) ...@@ -71,7 +71,7 @@ static WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hmod )
return NULL; return NULL;
} }
for ( wm = MODULE_modref_list; wm; wm=wm->next ) for ( wm = MODULE_modref_list; wm; wm=wm->next )
if (wm->module == hmod) if (wm->ldr.BaseAddress == hmod)
return wm; return wm;
return NULL; return NULL;
} }
...@@ -93,8 +93,8 @@ WINE_MODREF *MODULE_AllocModRef( HMODULE hModule, LPCSTR filename ) ...@@ -93,8 +93,8 @@ WINE_MODREF *MODULE_AllocModRef( HMODULE hModule, LPCSTR filename )
if ((wm = RtlAllocateHeap( ntdll_get_process_heap(), HEAP_ZERO_MEMORY, if ((wm = RtlAllocateHeap( ntdll_get_process_heap(), HEAP_ZERO_MEMORY,
sizeof(*wm) + long_len + short_len + 1 ))) sizeof(*wm) + long_len + short_len + 1 )))
{ {
wm->module = hModule; wm->ldr.BaseAddress = hModule;
wm->tlsindex = -1; wm->ldr.TlsIndex = -1;
wm->filename = wm->data; wm->filename = wm->data;
memcpy( wm->filename, filename, long_len + 1 ); memcpy( wm->filename, filename, long_len + 1 );
...@@ -154,7 +154,7 @@ static BOOL MODULE_InitDLL( WINE_MODREF *wm, DWORD type, LPVOID lpReserved ) ...@@ -154,7 +154,7 @@ static BOOL MODULE_InitDLL( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
TRACE("(%s,%s,%p) - CALL\n", wm->modname, typeName[type], lpReserved ); TRACE("(%s,%s,%p) - CALL\n", wm->modname, typeName[type], lpReserved );
/* Call the initialization routine */ /* Call the initialization routine */
retv = PE_InitDLL( wm->module, type, lpReserved ); retv = PE_InitDLL( wm->ldr.BaseAddress, type, lpReserved );
/* The state of the module list may have changed due to the call /* The state of the module list may have changed due to the call
to PE_InitDLL. We cannot assume that this module has not been to PE_InitDLL. We cannot assume that this module has not been
...@@ -272,7 +272,7 @@ void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved ) ...@@ -272,7 +272,7 @@ void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved )
/* Check whether to detach this DLL */ /* Check whether to detach this DLL */
if ( !(wm->flags & WINE_MODREF_PROCESS_ATTACHED) ) if ( !(wm->flags & WINE_MODREF_PROCESS_ATTACHED) )
continue; continue;
if ( wm->refCount > 0 && !bForceDetach ) if ( wm->ldr.LoadCount > 0 && !bForceDetach )
continue; continue;
/* Call detach notification */ /* Call detach notification */
...@@ -357,8 +357,8 @@ NTSTATUS WINAPI LdrFindEntryForAddress(const void* addr, PLDR_MODULE* mod) ...@@ -357,8 +357,8 @@ NTSTATUS WINAPI LdrFindEntryForAddress(const void* addr, PLDR_MODULE* mod)
for ( wm = MODULE_modref_list; wm; wm = wm->next ) for ( wm = MODULE_modref_list; wm; wm = wm->next )
{ {
if ((const void *)wm->module <= addr && if ((const void *)wm->ldr.BaseAddress <= addr &&
(char *)addr < (char*)wm->module + wm->ldr.SizeOfImage) (char *)addr < (char*)wm->ldr.BaseAddress + wm->ldr.SizeOfImage)
{ {
*mod = &wm->ldr; *mod = &wm->ldr;
return STATUS_SUCCESS; return STATUS_SUCCESS;
...@@ -471,7 +471,7 @@ NTSTATUS WINAPI LdrGetDllHandle(ULONG x, ULONG y, PUNICODE_STRING name, HMODULE ...@@ -471,7 +471,7 @@ NTSTATUS WINAPI LdrGetDllHandle(ULONG x, ULONG y, PUNICODE_STRING name, HMODULE
return STATUS_DLL_NOT_FOUND; return STATUS_DLL_NOT_FOUND;
} }
*base = wm->module; *base = wm->ldr.BaseAddress;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -632,7 +632,7 @@ NTSTATUS MODULE_LoadLibraryExA( LPCSTR libname, DWORD flags, WINE_MODREF** pwm) ...@@ -632,7 +632,7 @@ NTSTATUS MODULE_LoadLibraryExA( LPCSTR libname, DWORD flags, WINE_MODREF** pwm)
} }
if (*pwm) if (*pwm)
{ {
(*pwm)->refCount++; (*pwm)->ldr.LoadCount++;
if (((*pwm)->flags & WINE_MODREF_DONT_RESOLVE_REFS) && if (((*pwm)->flags & WINE_MODREF_DONT_RESOLVE_REFS) &&
!(flags & DONT_RESOLVE_DLL_REFERENCES)) !(flags & DONT_RESOLVE_DLL_REFERENCES))
...@@ -640,7 +640,7 @@ NTSTATUS MODULE_LoadLibraryExA( LPCSTR libname, DWORD flags, WINE_MODREF** pwm) ...@@ -640,7 +640,7 @@ NTSTATUS MODULE_LoadLibraryExA( LPCSTR libname, DWORD flags, WINE_MODREF** pwm)
(*pwm)->flags &= ~WINE_MODREF_DONT_RESOLVE_REFS; (*pwm)->flags &= ~WINE_MODREF_DONT_RESOLVE_REFS;
PE_fixup_imports( *pwm ); PE_fixup_imports( *pwm );
} }
TRACE("Already loaded module '%s' at %p, count=%d\n", filename, (*pwm)->module, (*pwm)->refCount); TRACE("Already loaded module '%s' at %p, count=%d\n", filename, (*pwm)->ldr.BaseAddress, (*pwm)->ldr.LoadCount);
if (allocated_libdir) if (allocated_libdir)
{ {
RtlFreeHeap( ntdll_get_process_heap(), 0, (LPSTR)libdir ); RtlFreeHeap( ntdll_get_process_heap(), 0, (LPSTR)libdir );
...@@ -679,12 +679,12 @@ NTSTATUS MODULE_LoadLibraryExA( LPCSTR libname, DWORD flags, WINE_MODREF** pwm) ...@@ -679,12 +679,12 @@ NTSTATUS MODULE_LoadLibraryExA( LPCSTR libname, DWORD flags, WINE_MODREF** pwm)
if (nts == STATUS_SUCCESS) if (nts == STATUS_SUCCESS)
{ {
/* Initialize DLL just loaded */ /* Initialize DLL just loaded */
TRACE("Loaded module '%s' at %p\n", filename, (*pwm)->module); TRACE("Loaded module '%s' at %p\n", filename, (*pwm)->ldr.BaseAddress);
if (!TRACE_ON(module)) if (!TRACE_ON(module))
TRACE_(loaddll)("Loaded module '%s' : %s\n", filename, filetype); TRACE_(loaddll)("Loaded module '%s' : %s\n", filename, filetype);
/* Set the refCount here so that an attach failure will */ /* Set the ldr.LoadCount here so that an attach failure will */
/* decrement the dependencies through the MODULE_FreeLibrary call. */ /* decrement the dependencies through the MODULE_FreeLibrary call. */
(*pwm)->refCount = 1; (*pwm)->ldr.LoadCount = 1;
if (allocated_libdir) if (allocated_libdir)
{ {
...@@ -735,7 +735,7 @@ NTSTATUS WINAPI LdrLoadDll(LPCWSTR path_name, DWORD flags, PUNICODE_STRING libna ...@@ -735,7 +735,7 @@ NTSTATUS WINAPI LdrLoadDll(LPCWSTR path_name, DWORD flags, PUNICODE_STRING libna
if ( !MODULE_DllProcessAttach( wm, NULL ) ) if ( !MODULE_DllProcessAttach( wm, NULL ) )
{ {
WARN_(module)("Attach failed for module '%s'.\n", str.Buffer); WARN_(module)("Attach failed for module '%s'.\n", str.Buffer);
LdrUnloadDll(wm->module); LdrUnloadDll(wm->ldr.BaseAddress);
nts = STATUS_DLL_INIT_FAILED; nts = STATUS_DLL_INIT_FAILED;
wm = NULL; wm = NULL;
} }
...@@ -747,7 +747,7 @@ NTSTATUS WINAPI LdrLoadDll(LPCWSTR path_name, DWORD flags, PUNICODE_STRING libna ...@@ -747,7 +747,7 @@ NTSTATUS WINAPI LdrLoadDll(LPCWSTR path_name, DWORD flags, PUNICODE_STRING libna
break; break;
} }
*hModule = (wm) ? wm->module : NULL; *hModule = (wm) ? wm->ldr.BaseAddress : NULL;
RtlLeaveCriticalSection( &loader_section ); RtlLeaveCriticalSection( &loader_section );
...@@ -812,7 +812,7 @@ static void MODULE_FlushModrefs(void) ...@@ -812,7 +812,7 @@ static void MODULE_FlushModrefs(void)
{ {
next = wm->next; next = wm->next;
if (wm->refCount) if (wm->ldr.LoadCount)
continue; continue;
/* Unlink this modref from the chain */ /* Unlink this modref from the chain */
...@@ -830,13 +830,13 @@ static void MODULE_FlushModrefs(void) ...@@ -830,13 +830,13 @@ static void MODULE_FlushModrefs(void)
SERVER_START_REQ( unload_dll ) SERVER_START_REQ( unload_dll )
{ {
req->base = (void *)wm->module; req->base = wm->ldr.BaseAddress;
wine_server_call( req ); wine_server_call( req );
} }
SERVER_END_REQ; SERVER_END_REQ;
if (wm->dlhandle) wine_dll_unload( wm->dlhandle ); if (wm->dlhandle) wine_dll_unload( wm->dlhandle );
else UnmapViewOfFile( (LPVOID)wm->module ); else NtUnmapViewOfSection( GetCurrentProcess(), wm->ldr.BaseAddress );
FreeLibrary16( wm->hDummyMod ); FreeLibrary16( wm->hDummyMod );
RtlFreeHeap( ntdll_get_process_heap(), 0, wm->deps ); RtlFreeHeap( ntdll_get_process_heap(), 0, wm->deps );
RtlFreeHeap( ntdll_get_process_heap(), 0, wm ); RtlFreeHeap( ntdll_get_process_heap(), 0, wm );
...@@ -855,13 +855,13 @@ static void MODULE_DecRefCount( WINE_MODREF *wm ) ...@@ -855,13 +855,13 @@ static void MODULE_DecRefCount( WINE_MODREF *wm )
if ( wm->flags & WINE_MODREF_MARKER ) if ( wm->flags & WINE_MODREF_MARKER )
return; return;
if ( wm->refCount <= 0 ) if ( wm->ldr.LoadCount <= 0 )
return; return;
--wm->refCount; --wm->ldr.LoadCount;
TRACE("(%s) refCount: %d\n", wm->modname, wm->refCount ); TRACE("(%s) ldr.LoadCount: %d\n", wm->modname, wm->ldr.LoadCount );
if ( wm->refCount == 0 ) if ( wm->ldr.LoadCount == 0 )
{ {
wm->flags |= WINE_MODREF_MARKER; wm->flags |= WINE_MODREF_MARKER;
......
...@@ -130,10 +130,8 @@ typedef struct _wine_modref ...@@ -130,10 +130,8 @@ typedef struct _wine_modref
{ {
struct _wine_modref *next; struct _wine_modref *next;
struct _wine_modref *prev; struct _wine_modref *prev;
HMODULE module;
HMODULE16 hDummyMod; /* Win16 dummy module */ HMODULE16 hDummyMod; /* Win16 dummy module */
void *dlhandle; /* handle returned by dlopen() */ void *dlhandle; /* handle returned by dlopen() */
int tlsindex; /* TLS index or -1 if none */
LDR_MODULE ldr; LDR_MODULE ldr;
FARPROC (*find_export)( struct _wine_modref *wm, LPCSTR func, FARPROC (*find_export)( struct _wine_modref *wm, LPCSTR func,
int hint, BOOL snoop ); int hint, BOOL snoop );
...@@ -142,7 +140,6 @@ typedef struct _wine_modref ...@@ -142,7 +140,6 @@ typedef struct _wine_modref
struct _wine_modref **deps; struct _wine_modref **deps;
int flags; int flags;
int refCount;
char *filename; char *filename;
char *modname; char *modname;
......
...@@ -126,18 +126,18 @@ static FARPROC PE_FindExportedFunction( ...@@ -126,18 +126,18 @@ static FARPROC PE_FindExportedFunction(
IMAGE_EXPORT_DIRECTORY *exports; IMAGE_EXPORT_DIRECTORY *exports;
DWORD exp_size; DWORD exp_size;
if (!(exports = RtlImageDirectoryEntryToData( wm->module, TRUE, if (!(exports = RtlImageDirectoryEntryToData( wm->ldr.BaseAddress, TRUE,
IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size ))) IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size )))
return NULL; return NULL;
if (HIWORD(funcName)) TRACE("(%s)\n",funcName); if (HIWORD(funcName)) TRACE("(%s)\n",funcName);
else TRACE("(%d)\n",LOWORD(funcName)); else TRACE("(%d)\n",LOWORD(funcName));
ordinals= get_rva(wm->module, exports->AddressOfNameOrdinals); ordinals= get_rva(wm->ldr.BaseAddress, exports->AddressOfNameOrdinals);
function= get_rva(wm->module, exports->AddressOfFunctions); function= get_rva(wm->ldr.BaseAddress, exports->AddressOfFunctions);
name = get_rva(wm->module, exports->AddressOfNames); name = get_rva(wm->ldr.BaseAddress, exports->AddressOfNames);
forward = NULL; forward = NULL;
rva_start = (char *)exports - (char *)wm->module; rva_start = (char *)exports - (char *)wm->ldr.BaseAddress;
if (HIWORD(funcName)) if (HIWORD(funcName))
{ {
...@@ -146,7 +146,7 @@ static FARPROC PE_FindExportedFunction( ...@@ -146,7 +146,7 @@ static FARPROC PE_FindExportedFunction(
/* first check the hint */ /* first check the hint */
if (hint >= 0 && hint <= max) if (hint >= 0 && hint <= max)
{ {
ename = get_rva(wm->module, name[hint]); ename = get_rva(wm->ldr.BaseAddress, name[hint]);
if (!strcmp( ename, funcName )) if (!strcmp( ename, funcName ))
{ {
ordinal = ordinals[hint]; ordinal = ordinals[hint];
...@@ -158,7 +158,7 @@ static FARPROC PE_FindExportedFunction( ...@@ -158,7 +158,7 @@ static FARPROC PE_FindExportedFunction(
while (min <= max) while (min <= max)
{ {
int res, pos = (min + max) / 2; int res, pos = (min + max) / 2;
ename = get_rva(wm->module, name[pos]); ename = get_rva(wm->ldr.BaseAddress, name[pos]);
if (!(res = strcmp( ename, funcName ))) if (!(res = strcmp( ename, funcName )))
{ {
ordinal = ordinals[pos]; ordinal = ordinals[pos];
...@@ -177,7 +177,7 @@ static FARPROC PE_FindExportedFunction( ...@@ -177,7 +177,7 @@ static FARPROC PE_FindExportedFunction(
for (i = 0; i < exports->NumberOfNames; i++) for (i = 0; i < exports->NumberOfNames; i++)
if (ordinals[i] == ordinal) if (ordinals[i] == ordinal)
{ {
ename = get_rva(wm->module, name[i]); ename = get_rva(wm->ldr.BaseAddress, name[i]);
break; break;
} }
} }
...@@ -192,13 +192,13 @@ static FARPROC PE_FindExportedFunction( ...@@ -192,13 +192,13 @@ static FARPROC PE_FindExportedFunction(
addr = function[ordinal]; addr = function[ordinal];
if (!addr) return NULL; if (!addr) return NULL;
proc = get_rva(wm->module, addr); proc = get_rva(wm->ldr.BaseAddress, addr);
if (((char *)proc < (char *)exports) || ((char *)proc >= (char *)exports + exp_size)) if (((char *)proc < (char *)exports) || ((char *)proc >= (char *)exports + exp_size))
{ {
if (snoop) if (snoop)
{ {
if (!ename) ename = "@"; if (!ename) ename = "@";
proc = SNOOP_GetProcAddress(wm->module,ename,ordinal,proc); proc = SNOOP_GetProcAddress(wm->ldr.BaseAddress,ename,ordinal,proc);
} }
return proc; return proc;
} }
...@@ -218,7 +218,7 @@ static FARPROC PE_FindExportedFunction( ...@@ -218,7 +218,7 @@ static FARPROC PE_FindExportedFunction(
ERR("module not found for forward '%s' used by '%s'\n", forward, wm->modname ); ERR("module not found for forward '%s' used by '%s'\n", forward, wm->modname );
return NULL; return NULL;
} }
if (!(proc = MODULE_GetProcAddress( wm_fw->module, end + 1, -1, snoop ))) if (!(proc = MODULE_GetProcAddress( wm_fw->ldr.BaseAddress, end + 1, -1, snoop )))
ERR("function not found for forward '%s' used by '%s'. If you are using builtin '%s', try using the native one instead.\n", forward, wm->modname, wm->modname ); ERR("function not found for forward '%s' used by '%s'. If you are using builtin '%s', try using the native one instead.\n", forward, wm->modname, wm->modname );
return proc; return proc;
} }
...@@ -233,7 +233,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm ) ...@@ -233,7 +233,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
IMAGE_IMPORT_DESCRIPTOR *imports, *pe_imp; IMAGE_IMPORT_DESCRIPTOR *imports, *pe_imp;
DWORD size; DWORD size;
imports = RtlImageDirectoryEntryToData( wm->module, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &size ); imports = RtlImageDirectoryEntryToData( wm->ldr.BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &size );
/* first, count the number of imported non-internal modules */ /* first, count the number of imported non-internal modules */
pe_imp = imports; pe_imp = imports;
...@@ -267,7 +267,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm ) ...@@ -267,7 +267,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
WINE_MODREF *wmImp; WINE_MODREF *wmImp;
IMAGE_IMPORT_BY_NAME *pe_name; IMAGE_IMPORT_BY_NAME *pe_name;
PIMAGE_THUNK_DATA import_list,thunk_list; PIMAGE_THUNK_DATA import_list,thunk_list;
char *name = get_rva(wm->module, pe_imp->Name); char *name = get_rva(wm->ldr.BaseAddress, pe_imp->Name);
NTSTATUS nts; NTSTATUS nts;
if (characteristics_detection && !pe_imp->u.Characteristics) if (characteristics_detection && !pe_imp->u.Characteristics)
...@@ -292,8 +292,8 @@ DWORD PE_fixup_imports( WINE_MODREF *wm ) ...@@ -292,8 +292,8 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
if (pe_imp->u.OriginalFirstThunk != 0) { /* original MS style */ if (pe_imp->u.OriginalFirstThunk != 0) { /* original MS style */
TRACE("Microsoft style imports used\n"); TRACE("Microsoft style imports used\n");
import_list = get_rva(wm->module, (DWORD)pe_imp->u.OriginalFirstThunk); import_list = get_rva(wm->ldr.BaseAddress, (DWORD)pe_imp->u.OriginalFirstThunk);
thunk_list = get_rva(wm->module, (DWORD)pe_imp->FirstThunk); thunk_list = get_rva(wm->ldr.BaseAddress, (DWORD)pe_imp->FirstThunk);
while (import_list->u1.Ordinal) { while (import_list->u1.Ordinal) {
if (IMAGE_SNAP_BY_ORDINAL(import_list->u1.Ordinal)) { if (IMAGE_SNAP_BY_ORDINAL(import_list->u1.Ordinal)) {
...@@ -301,7 +301,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm ) ...@@ -301,7 +301,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
TRACE("--- Ordinal %s,%d\n", name, ordinal); TRACE("--- Ordinal %s,%d\n", name, ordinal);
thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress( thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress(
wmImp->module, (LPCSTR)ordinal, -1, TRUE wmImp->ldr.BaseAddress, (LPCSTR)ordinal, -1, TRUE
); );
if (!thunk_list->u1.Function) { if (!thunk_list->u1.Function) {
ERR("No implementation for %s.%d imported from %s, setting to 0xdeadbeef\n", ERR("No implementation for %s.%d imported from %s, setting to 0xdeadbeef\n",
...@@ -309,10 +309,10 @@ DWORD PE_fixup_imports( WINE_MODREF *wm ) ...@@ -309,10 +309,10 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
thunk_list->u1.Function = (PDWORD)0xdeadbeef; thunk_list->u1.Function = (PDWORD)0xdeadbeef;
} }
} else { /* import by name */ } else { /* import by name */
pe_name = get_rva(wm->module, (DWORD)import_list->u1.AddressOfData); pe_name = get_rva(wm->ldr.BaseAddress, (DWORD)import_list->u1.AddressOfData);
TRACE("--- %s %s.%d\n", pe_name->Name, name, pe_name->Hint); TRACE("--- %s %s.%d\n", pe_name->Name, name, pe_name->Hint);
thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress( thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress(
wmImp->module, pe_name->Name, pe_name->Hint, TRUE wmImp->ldr.BaseAddress, pe_name->Name, pe_name->Hint, TRUE
); );
if (!thunk_list->u1.Function) { if (!thunk_list->u1.Function) {
ERR("No implementation for %s.%d(%s) imported from %s, setting to 0xdeadbeef\n", ERR("No implementation for %s.%d(%s) imported from %s, setting to 0xdeadbeef\n",
...@@ -325,7 +325,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm ) ...@@ -325,7 +325,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
} }
} else { /* Borland style */ } else { /* Borland style */
TRACE("Borland style imports used\n"); TRACE("Borland style imports used\n");
thunk_list = get_rva(wm->module, (DWORD)pe_imp->FirstThunk); thunk_list = get_rva(wm->ldr.BaseAddress, (DWORD)pe_imp->FirstThunk);
while (thunk_list->u1.Ordinal) { while (thunk_list->u1.Ordinal) {
if (IMAGE_SNAP_BY_ORDINAL(thunk_list->u1.Ordinal)) { if (IMAGE_SNAP_BY_ORDINAL(thunk_list->u1.Ordinal)) {
/* not sure about this branch, but it seems to work */ /* not sure about this branch, but it seems to work */
...@@ -333,7 +333,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm ) ...@@ -333,7 +333,7 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
TRACE("--- Ordinal %s.%d\n",name,ordinal); TRACE("--- Ordinal %s.%d\n",name,ordinal);
thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress( thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress(
wmImp->module, (LPCSTR) ordinal, -1, TRUE wmImp->ldr.BaseAddress, (LPCSTR) ordinal, -1, TRUE
); );
if (!thunk_list->u1.Function) { if (!thunk_list->u1.Function) {
ERR("No implementation for %s.%d imported from %s, setting to 0xdeadbeef\n", ERR("No implementation for %s.%d imported from %s, setting to 0xdeadbeef\n",
...@@ -341,11 +341,11 @@ DWORD PE_fixup_imports( WINE_MODREF *wm ) ...@@ -341,11 +341,11 @@ DWORD PE_fixup_imports( WINE_MODREF *wm )
thunk_list->u1.Function = (PDWORD)0xdeadbeef; thunk_list->u1.Function = (PDWORD)0xdeadbeef;
} }
} else { } else {
pe_name=get_rva(wm->module, (DWORD)thunk_list->u1.AddressOfData); pe_name=get_rva(wm->ldr.BaseAddress, (DWORD)thunk_list->u1.AddressOfData);
TRACE("--- %s %s.%d\n", TRACE("--- %s %s.%d\n",
pe_name->Name,name,pe_name->Hint); pe_name->Name,name,pe_name->Hint);
thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress( thunk_list->u1.Function=(PDWORD)MODULE_GetProcAddress(
wmImp->module, pe_name->Name, pe_name->Hint, TRUE wmImp->ldr.BaseAddress, pe_name->Name, pe_name->Hint, TRUE
); );
if (!thunk_list->u1.Function) { if (!thunk_list->u1.Function) {
ERR("No implementation for %s.%d(%s) imported from %s, setting to 0xdeadbeef\n", ERR("No implementation for %s.%d(%s) imported from %s, setting to 0xdeadbeef\n",
...@@ -672,19 +672,19 @@ void PE_InitTls( void ) ...@@ -672,19 +672,19 @@ void PE_InitTls( void )
int delta; int delta;
for (wm = MODULE_modref_list;wm;wm=wm->next) { for (wm = MODULE_modref_list;wm;wm=wm->next) {
peh = RtlImageNtHeader(wm->module); peh = RtlImageNtHeader(wm->ldr.BaseAddress);
pdir = RtlImageDirectoryEntryToData( wm->module, TRUE, pdir = RtlImageDirectoryEntryToData( wm->ldr.BaseAddress, TRUE,
IMAGE_DIRECTORY_ENTRY_TLS, &dirsize ); IMAGE_DIRECTORY_ENTRY_TLS, &dirsize );
if (!pdir) continue; if (!pdir) continue;
delta = (char *)wm->module - (char *)peh->OptionalHeader.ImageBase; delta = (char *)wm->ldr.BaseAddress - (char *)peh->OptionalHeader.ImageBase;
if ( wm->tlsindex == -1 ) { if ( wm->ldr.TlsIndex == -1 ) {
LPDWORD xaddr; LPDWORD xaddr;
wm->tlsindex = TlsAlloc(); wm->ldr.TlsIndex = TlsAlloc();
xaddr = _fixup_address(&(peh->OptionalHeader),delta, xaddr = _fixup_address(&(peh->OptionalHeader),delta,
pdir->AddressOfIndex pdir->AddressOfIndex
); );
*xaddr=wm->tlsindex; *xaddr=wm->ldr.TlsIndex;
} }
datasize= pdir->EndAddressOfRawData-pdir->StartAddressOfRawData; datasize= pdir->EndAddressOfRawData-pdir->StartAddressOfRawData;
size = datasize + pdir->SizeOfZeroFill; size = datasize + pdir->SizeOfZeroFill;
...@@ -698,6 +698,6 @@ void PE_InitTls( void ) ...@@ -698,6 +698,6 @@ void PE_InitTls( void )
FIXME("TLS Callbacks aren't going to be called\n"); FIXME("TLS Callbacks aren't going to be called\n");
} }
TlsSetValue( wm->tlsindex, mem ); TlsSetValue( wm->ldr.TlsIndex, mem );
} }
} }
...@@ -453,7 +453,7 @@ static DWORD VERSION_GetLinkedDllVersion(void) ...@@ -453,7 +453,7 @@ static DWORD VERSION_GetLinkedDllVersion(void)
from one windows version */ from one windows version */
for ( wm = MODULE_modref_list; wm; wm=wm->next ) for ( wm = MODULE_modref_list; wm; wm=wm->next )
{ {
nt = RtlImageNtHeader(wm->module); nt = RtlImageNtHeader(wm->ldr.BaseAddress);
ophd = &nt->OptionalHeader; ophd = &nt->OptionalHeader;
TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n", TRACE("%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
...@@ -472,7 +472,7 @@ static DWORD VERSION_GetLinkedDllVersion(void) ...@@ -472,7 +472,7 @@ static DWORD VERSION_GetLinkedDllVersion(void)
/* test if it is a special dll */ /* test if it is a special dll */
if (!strcasecmp(wm->modname, special_dlls[i])) if (!strcasecmp(wm->modname, special_dlls[i]))
{ {
DWORD DllVersion = VERSION_GetSystemDLLVersion(wm->module); DWORD DllVersion = VERSION_GetSystemDLLVersion(wm->ldr.BaseAddress);
if (WinVersion == NB_WINDOWS_VERSIONS) if (WinVersion == NB_WINDOWS_VERSIONS)
WinVersion = DllVersion; WinVersion = DllVersion;
else { else {
......
...@@ -134,7 +134,6 @@ static void load_library( void *base, const char *filename ) ...@@ -134,7 +134,6 @@ static void load_library( void *base, const char *filename )
} }
TRACE( "loaded %s %p %p\n", fullname, wm, module ); TRACE( "loaded %s %p %p\n", fullname, wm, module );
HeapFree( GetProcessHeap(), 0, fullname ); HeapFree( GetProcessHeap(), 0, fullname );
wm->refCount++; /* we don't support freeing builtin dlls (FIXME)*/
/* setup relay debugging entry points */ /* setup relay debugging entry points */
if (TRACE_ON(relay)) RELAY_SetupDLL( (void *)module ); if (TRACE_ON(relay)) RELAY_SetupDLL( (void *)module );
......
...@@ -239,7 +239,7 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay ) ...@@ -239,7 +239,7 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay )
for (wm = MODULE_modref_list; wm; wm = wm->next) for (wm = MODULE_modref_list; wm; wm = wm->next)
{ {
if (!(wm->flags & WINE_MODREF_INTERNAL)) continue; if (!(wm->flags & WINE_MODREF_INTERNAL)) continue;
exp = RtlImageDirectoryEntryToData( wm->module, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &size ); exp = RtlImageDirectoryEntryToData( wm->ldr.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)
...@@ -251,7 +251,7 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay ) ...@@ -251,7 +251,7 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay )
/* Now find the function */ /* Now find the function */
base = (char *)wm->module; base = (char *)wm->ldr.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;
......
...@@ -535,7 +535,7 @@ static void start_process(void) ...@@ -535,7 +535,7 @@ static void start_process(void)
/* create the main modref and load dependencies */ /* create the main modref and load dependencies */
if (!(wm = PE_CreateModule( current_process.module, main_exe_name, 0, 0, FALSE ))) if (!(wm = PE_CreateModule( current_process.module, main_exe_name, 0, 0, FALSE )))
goto error; goto error;
wm->refCount++; wm->ldr.LoadCount++;
if (main_exe_file) CloseHandle( main_exe_file ); /* we no longer need it */ if (main_exe_file) CloseHandle( main_exe_file ); /* we no longer need it */
......
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