ntdll: Fix a problem with starting Garant 7.5.0 (eterbug #5864).
authorAlexander Morozov <amorozov@etersoft.ru>
Tue, 10 Aug 2010 15:43:12 +0000 (19:43 +0400)
committerAlexander Morozov <amorozov@etersoft.ru>
Tue, 10 Aug 2010 16:05:04 +0000 (20:05 +0400)
dlls/ntdll/loader.c

index 6fb81241c358b1adda4a2297e817fb985e5e3de4..4432164dd6884cfd39d075d7b6d34f96d81b3418 100644 (file)
@@ -100,7 +100,7 @@ static struct builtin_load_info *builtin_load_info = &default_load_info;
 static HANDLE main_exe_file;
 static UINT tls_module_count;      /* number of modules with TLS directory */
 static UINT tls_total_size;        /* total size of TLS storage */
-static const IMAGE_TLS_DIRECTORY **tls_dirs;  /* array of TLS directories */
+static IMAGE_TLS_DIRECTORY *tls_dirs;  /* array of TLS directories */
 
 static RTL_CRITICAL_SECTION loader_section;
 static RTL_CRITICAL_SECTION_DEBUG critsect_debug =
@@ -854,7 +854,8 @@ static NTSTATUS alloc_process_tls(void)
 
     TRACE( "count %u size %u\n", tls_module_count, tls_total_size );
 
-    tls_dirs = RtlAllocateHeap( GetProcessHeap(), 0, tls_module_count * sizeof(*tls_dirs) );
+    tls_dirs = RtlAllocateHeap( GetProcessHeap(), 0, tls_module_count *
+                                sizeof(IMAGE_TLS_DIRECTORY) );
     if (!tls_dirs) return STATUS_NO_MEMORY;
 
     for (i = 0, entry = mark->Flink; entry != mark; entry = entry->Flink)
@@ -863,8 +864,8 @@ static NTSTATUS alloc_process_tls(void)
         if (!(dir = RtlImageDirectoryEntryToData( mod->BaseAddress, TRUE,
                                                   IMAGE_DIRECTORY_ENTRY_TLS, &size )))
             continue;
-        tls_dirs[i] = dir;
         *(DWORD *)dir->AddressOfIndex = i;
+        memcpy( &tls_dirs[i], dir, sizeof(IMAGE_TLS_DIRECTORY) );
         mod->TlsIndex = i;
         mod->LoadCount = -1;  /* can't unload it */
         i++;
@@ -898,7 +899,7 @@ static NTSTATUS alloc_thread_tls(void)
 
     for (i = 0; i < tls_module_count; i++)
     {
-        const IMAGE_TLS_DIRECTORY *dir = tls_dirs[i];
+        const IMAGE_TLS_DIRECTORY *dir = &tls_dirs[i];
         ULONG size = dir->EndAddressOfRawData - dir->StartAddressOfRawData;
 
         TRACE( "thread %04x idx %d: %d/%d bytes from %p to %p\n",