about summary refs log tree commit diff stats
path: root/miasm/loader/pe_init.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2019-12-23 16:42:08 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2019-12-23 16:42:37 +0100
commit3a0d984146e8b3428c4445d37709f2af9d98fb5a (patch)
tree0dde449942b0fd5a192e80945a2e4f1fb98bb991 /miasm/loader/pe_init.py
parenta2d2e3bd87636c2ccca1afecc5c7c20360aa43fa (diff)
downloadfocaccia-miasm-3a0d984146e8b3428c4445d37709f2af9d98fb5a.tar.gz
focaccia-miasm-3a0d984146e8b3428c4445d37709f2af9d98fb5a.zip
Loader/PE: add minimal tls support
Diffstat (limited to 'miasm/loader/pe_init.py')
-rw-r--r--miasm/loader/pe_init.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/miasm/loader/pe_init.py b/miasm/loader/pe_init.py
index 1d179efb..7a8d2abd 100644
--- a/miasm/loader/pe_init.py
+++ b/miasm/loader/pe_init.py
@@ -220,6 +220,7 @@ class PE(object):
             self.DirDelay = pe.DirDelay(self)
             self.DirReloc = pe.DirReloc(self)
             self.DirRes = pe.DirRes(self)
+            self.DirTls = pe.DirTls(self)
 
             self.Doshdr.magic = 0x5a4d
             self.Doshdr.lfanew = 0xe0
@@ -414,6 +415,17 @@ class PE(object):
                 except pe.InvalidOffset:
                     log.warning('cannot parse DirRes, skipping')
 
+        if len(self.NThdr.optentries) > pe.DIRECTORY_ENTRY_TLS:
+            self.DirTls = pe.DirTls(self)
+            try:
+                self.DirTls = pe.DirTls.unpack(
+                    self.img_rva,
+                    self.NThdr.optentries[pe.DIRECTORY_ENTRY_TLS].rva,
+                    self
+                )
+            except pe.InvalidOffset:
+                log.warning('cannot parse DirTls, skipping')
+
     def resize(self, old, new):
         pass
 
@@ -567,6 +579,7 @@ class PE(object):
         self.DirDelay.build_content(content)
         self.DirReloc.build_content(content)
         self.DirRes.build_content(content)
+        self.DirTls.build_content(content)
 
         if (self.Doshdr.lfanew + len(self.NTsig) + len(self.Coffhdr)) % 4:
             log.warn("non aligned coffhdr, bad crc calculation")