Skip to content

Commit af44dc0

Browse files
negasoraplafosse
authored andcommitted
Actually fix crash when opening aarch64 TE binary with free version
1 parent 2b31504 commit af44dc0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

view/pe/teview.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,27 @@ bool TEView::Init()
242242
{
243243
case IMAGE_FILE_MACHINE_I386:
244244
platform = Platform::GetByName("efi-x86");
245+
m_addressSize = 4;
245246
break;
246247
case IMAGE_FILE_MACHINE_AMD64:
247248
platform = Platform::GetByName("efi-x86_64");
249+
m_addressSize = 8;
248250
break;
249251
case IMAGE_FILE_MACHINE_ARM64:
250252
platform = Platform::GetByName("efi-aarch64");
253+
m_addressSize = 8;
251254
break;
252255
case IMAGE_FILE_MACHINE_ARM:
253256
platform = Platform::GetByName("efi-armv7");
257+
m_addressSize = 4;
254258
break;
255259
case IMAGE_FILE_MACHINE_THUMB:
256260
platform = Platform::GetByName("efi-thumb2");
261+
m_addressSize = 4;
257262
break;
258263
default:
259264
LogError("TE platform '0x%x' is not supported", header.machine);
265+
m_addressSize = 4;
260266
if (!m_parseOnly)
261267
m_logger->LogWarn("Unable to determine architecture. Please open the file with options and select a valid architecture.");
262268
return false;
@@ -276,6 +282,8 @@ bool TEView::Init()
276282
return false;
277283
}
278284

285+
m_addressSize = m_arch->GetAddressSize();
286+
279287
SetDefaultPlatform(platform);
280288
SetDefaultArchitecture(m_arch);
281289

@@ -309,7 +317,7 @@ uint64_t TEView::PerformGetEntryPoint() const
309317

310318
size_t TEView::PerformGetAddressSize() const
311319
{
312-
return m_arch->GetAddressSize();
320+
return m_addressSize;
313321
}
314322

315323
TEViewType::TEViewType() : BinaryViewType("TE", "TE")

view/pe/teview.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ namespace BinaryNinja
6262
uint64_t m_headersOffset;
6363
Ref<Architecture> m_arch;
6464
uint64_t m_entryPoint;
65-
65+
uint32_t m_addressSize = 4;
66+
6667
protected:
6768
virtual uint64_t PerformGetEntryPoint() const override;
6869
virtual bool PerformIsExecutable() const override { return true; }

0 commit comments

Comments
 (0)