From 0a45ada03865133af8ceff2b3d4fa469636e3505 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sun, 22 Nov 1998 14:11:59 +0000 Subject: [PATCH] Do not relocate the pointers in the IMAGE_THREAD_LOCAL_STORAGE directory, for they seem to be relocated by the standard relocating mechanism. (Explicitly checked one program using it) --- loader/pe_image.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/loader/pe_image.c b/loader/pe_image.c index c62cfc3618c..64ece28908e 100644 --- a/loader/pe_image.c +++ b/loader/pe_image.c @@ -939,6 +939,13 @@ void PE_InitDLL(WINE_MODREF *wm, DWORD type, LPVOID lpReserved) } } +/************************************************************************ + * PE_InitTls (internal) + * + * If included, initialises the thread local storages of modules. + * Pointers in those structs are not RVAs but real pointers which have been + * relocated by do_relocations() already. + */ void PE_InitTls(THDB *thdb) { WINE_MODREF *wm; @@ -958,33 +965,28 @@ void PE_InitTls(THDB *thdb) delta = wm->module - peh->OptionalHeader.ImageBase; if (!peh->OptionalHeader.DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress) continue; + FIXME(win32,"%s has TLS directory.\n",wm->longname); pdir = (LPVOID)(wm->module + peh->OptionalHeader. DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress); if (!(pem->flags & PE_MODREF_TLS_ALLOCED)) { pem->tlsindex = THREAD_TlsAlloc(thdb); - *(LPDWORD)AdjustPtr(pdir->AddressOfIndex,delta) - =pem->tlsindex; + *pdir->AddressOfIndex=pem->tlsindex; } pem->flags |= PE_MODREF_TLS_ALLOCED; datasize= pdir->EndAddressOfRawData-pdir->StartAddressOfRawData; size = datasize + pdir->SizeOfZeroFill; mem=VirtualAlloc(0,size,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); - memcpy(mem, - AdjustPtr(pdir->StartAddressOfRawData,delta), - datasize); - - /* don't use TlsSetValue, we are in the wrong thread */ + memcpy(mem,(LPVOID)pdir->StartAddressOfRawData,datasize); if (pdir->AddressOfCallBacks) { PIMAGE_TLS_CALLBACK *cbs = - (PIMAGE_TLS_CALLBACK *) - AdjustPtr(pdir->AddressOfCallBacks, delta); + (PIMAGE_TLS_CALLBACK *)pdir->AddressOfCallBacks; - if (*cbs) { + if (*cbs) FIXME(win32, "TLS Callbacks aren't going to be called\n"); - } } + /* Don't use TlsSetValue, we are in the wrong thread */ thdb->tls_array[pem->tlsindex] = mem; } }