File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ class ReflectionContext
288
288
}
289
289
290
290
#elif defined(_WIN32)
291
- bool addImage (RemoteAddress ImageStart) {
291
+ bool readPECOFFSections (RemoteAddress ImageStart) {
292
292
auto DOSHdrBuf = this ->getReader ().readBytes (
293
293
ImageStart, sizeof (llvm::object::dos_header));
294
294
auto DOSHdr =
@@ -380,6 +380,29 @@ class ReflectionContext
380
380
return true ;
381
381
}
382
382
383
+ bool addImage (RemoteAddress ImageStart) {
384
+ auto Buf = this ->getReader ().readBytes (ImageStart,
385
+ sizeof (llvm::object::dos_header));
386
+ if (!Buf)
387
+ return false ;
388
+
389
+ auto DOSHdr = reinterpret_cast <const llvm::object::dos_header *>(Buf.get ());
390
+ if (!(DOSHdr->Magic [0 ] == ' M' && DOSHdr->Magic [1 ] == ' Z' ))
391
+ return false ;
392
+
393
+ auto PEHeaderAddress =
394
+ ImageStart.getAddressData () + DOSHdr->AddressOfNewExeHeader ;
395
+
396
+ Buf = this ->getReader ().readBytes (RemoteAddress (PEHeaderAddress),
397
+ sizeof (llvm::COFF::PEMagic));
398
+ if (!Buf)
399
+ return false ;
400
+
401
+ if (memcmp (Buf.get (), llvm::COFF::PEMagic, sizeof (llvm::COFF::PEMagic)))
402
+ return false ;
403
+
404
+ return readPECOFFSections (ImageStart);
405
+ }
383
406
#else // ELF platforms.
384
407
template <typename T> bool readELFSections (RemoteAddress ImageStart) {
385
408
auto Buf =
You can’t perform that action at this time.
0 commit comments