Commit 0a45ada0 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

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)
parent e1ab22da
......@@ -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;
}
}
......
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