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)
This commit is contained in:
parent
e1ab22da8f
commit
0a45ada038
|
@ -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)
|
void PE_InitTls(THDB *thdb)
|
||||||
{
|
{
|
||||||
WINE_MODREF *wm;
|
WINE_MODREF *wm;
|
||||||
|
@ -958,33 +965,28 @@ void PE_InitTls(THDB *thdb)
|
||||||
delta = wm->module - peh->OptionalHeader.ImageBase;
|
delta = wm->module - peh->OptionalHeader.ImageBase;
|
||||||
if (!peh->OptionalHeader.DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress)
|
if (!peh->OptionalHeader.DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress)
|
||||||
continue;
|
continue;
|
||||||
|
FIXME(win32,"%s has TLS directory.\n",wm->longname);
|
||||||
pdir = (LPVOID)(wm->module + peh->OptionalHeader.
|
pdir = (LPVOID)(wm->module + peh->OptionalHeader.
|
||||||
DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress);
|
DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress);
|
||||||
|
|
||||||
|
|
||||||
if (!(pem->flags & PE_MODREF_TLS_ALLOCED)) {
|
if (!(pem->flags & PE_MODREF_TLS_ALLOCED)) {
|
||||||
pem->tlsindex = THREAD_TlsAlloc(thdb);
|
pem->tlsindex = THREAD_TlsAlloc(thdb);
|
||||||
*(LPDWORD)AdjustPtr(pdir->AddressOfIndex,delta)
|
*pdir->AddressOfIndex=pem->tlsindex;
|
||||||
=pem->tlsindex;
|
|
||||||
}
|
}
|
||||||
pem->flags |= PE_MODREF_TLS_ALLOCED;
|
pem->flags |= PE_MODREF_TLS_ALLOCED;
|
||||||
datasize= pdir->EndAddressOfRawData-pdir->StartAddressOfRawData;
|
datasize= pdir->EndAddressOfRawData-pdir->StartAddressOfRawData;
|
||||||
size = datasize + pdir->SizeOfZeroFill;
|
size = datasize + pdir->SizeOfZeroFill;
|
||||||
mem=VirtualAlloc(0,size,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
|
mem=VirtualAlloc(0,size,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
|
||||||
memcpy(mem,
|
memcpy(mem,(LPVOID)pdir->StartAddressOfRawData,datasize);
|
||||||
AdjustPtr(pdir->StartAddressOfRawData,delta),
|
|
||||||
datasize);
|
|
||||||
|
|
||||||
/* don't use TlsSetValue, we are in the wrong thread */
|
|
||||||
if (pdir->AddressOfCallBacks) {
|
if (pdir->AddressOfCallBacks) {
|
||||||
PIMAGE_TLS_CALLBACK *cbs =
|
PIMAGE_TLS_CALLBACK *cbs =
|
||||||
(PIMAGE_TLS_CALLBACK *)
|
(PIMAGE_TLS_CALLBACK *)pdir->AddressOfCallBacks;
|
||||||
AdjustPtr(pdir->AddressOfCallBacks, delta);
|
|
||||||
|
|
||||||
if (*cbs) {
|
if (*cbs)
|
||||||
FIXME(win32, "TLS Callbacks aren't going to be called\n");
|
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;
|
thdb->tls_array[pem->tlsindex] = mem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue