diff --git a/loader/pe_image.c b/loader/pe_image.c index 7770dbbb135..ac17fc70472 100644 --- a/loader/pe_image.c +++ b/loader/pe_image.c @@ -1056,7 +1056,12 @@ void PE_InitTls( void ) if ( pem->tlsindex == -1 ) { pem->tlsindex = TlsAlloc(); - *pdir->AddressOfIndex=pem->tlsindex; + if ((((DWORD)pdir->AddressOfIndex)>peh->OptionalHeader.ImageBase) + &&(((DWORD)pdir->AddressOfIndex)OptionalHeader.ImageBase+peh->OptionalHeader.SizeOfImage) + ) + *pdir->AddressOfIndex=pem->tlsindex; + else + *(LPDWORD)((((char*)pdir->AddressOfIndex)+delta))=pem->tlsindex; } datasize= pdir->EndAddressOfRawData-pdir->StartAddressOfRawData; size = datasize + pdir->SizeOfZeroFill;