Author: dgorbachev
Date: Mon Dec 15 12:19:18 2008
New Revision: 38113
URL:
http://svn.reactos.org/svn/reactos?rev=38113&view=rev
Log:
Fix TLS callbacks. Testers, please test it on real software.
Modified:
trunk/reactos/dll/ntdll/ldr/utils.c
Modified: trunk/reactos/dll/ntdll/ldr/utils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/utils.c?rev=…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/utils.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/utils.c [iso-8859-1] Mon Dec 15 12:19:18 2008
@@ -40,7 +40,7 @@
PVOID StartAddressOfRawData;
DWORD TlsDataSize;
DWORD TlsZeroSize;
- PIMAGE_TLS_CALLBACK TlsAddressOfCallBacks;
+ PIMAGE_TLS_CALLBACK *TlsAddressOfCallBacks;
PLDR_DATA_TABLE_ENTRY Module;
} TLS_DATA, *PTLS_DATA;
@@ -151,7 +151,7 @@
static __inline VOID LdrpTlsCallback(PLDR_DATA_TABLE_ENTRY Module, ULONG dwReason)
{
- PIMAGE_TLS_CALLBACK TlsCallback;
+ PIMAGE_TLS_CALLBACK *TlsCallback;
if (Module->TlsIndex != 0xFFFF && Module->LoadCount == 0xFFFF)
{
TlsCallback = LdrpTlsArray[Module->TlsIndex].TlsAddressOfCallBacks;
@@ -160,9 +160,9 @@
while (*TlsCallback)
{
TRACE_LDR("%wZ - Calling tls callback at %x\n",
- &Module->BaseDllName, TlsCallback);
- TlsCallback(Module->DllBase, dwReason, NULL);
- TlsCallback = (PIMAGE_TLS_CALLBACK)((ULONG_PTR)TlsCallback +
sizeof(PVOID));
+ &Module->BaseDllName, *TlsCallback);
+ (*TlsCallback)(Module->DllBase, dwReason, NULL);
+ TlsCallback++;
}
}
}
@@ -271,7 +271,7 @@
TlsData->TlsDataSize = TlsDirectory->EndAddressOfRawData -
TlsDirectory->StartAddressOfRawData;
TlsData->TlsZeroSize = TlsDirectory->SizeOfZeroFill;
if (TlsDirectory->AddressOfCallBacks)
- TlsData->TlsAddressOfCallBacks =
*(PIMAGE_TLS_CALLBACK*)TlsDirectory->AddressOfCallBacks;
+ TlsData->TlsAddressOfCallBacks = (PIMAGE_TLS_CALLBACK
*)TlsDirectory->AddressOfCallBacks;
else
TlsData->TlsAddressOfCallBacks = NULL;
TlsData->Module = Module;