diff options
| author | Ryan Snyder <ryan@vector35.com> | 2024-05-24 14:47:15 -0400 |
|---|---|---|
| committer | Ryan Snyder <ryan@vector35.com> | 2024-05-24 17:14:46 -0400 |
| commit | 56115aecf186bc720dae9a20cc4c6aef248ba07f (patch) | |
| tree | 1754beaa4e8601be328de689c0f6dc9d05851b35 /platform | |
| parent | 74920c190c5c6230833be6d50536119ce5e44c98 (diff) | |
platform: initial BNCustomPlatform support
Diffstat (limited to 'platform')
| -rw-r--r-- | platform/windows/platform_windows.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/platform/windows/platform_windows.cpp b/platform/windows/platform_windows.cpp index 2b0a427f..cb256660 100644 --- a/platform/windows/platform_windows.cpp +++ b/platform/windows/platform_windows.cpp @@ -7,11 +7,16 @@ using namespace std; class WindowsX86Platform: public Platform { + uint32_t m_fsbase; + Ref<Type> m_teb; + public: WindowsX86Platform(Architecture* arch): Platform(arch, "windows-x86") { Ref<CallingConvention> cc; + m_fsbase = arch->GetRegisterByName("fsbase"); + cc = arch->GetCallingConventionByName("cdecl"); if (cc) { @@ -36,14 +41,35 @@ public: if (cc) RegisterCallingConvention(cc); } + + + virtual void BinaryViewInit(BinaryView* view) override + { + if (!m_teb) + m_teb = Type::PointerType(GetArchitecture()->GetAddressSize(), Type::NamedType(QualifiedName("TEB"), GetTypeByName(QualifiedName("TEB")))); + } + + + virtual Ref<Type> GetGlobalRegisterType(uint32_t reg) override + { + if (reg == m_fsbase) + return m_teb; + + return nullptr; + } }; class WindowsX64Platform: public Platform { + uint32_t m_gsbase; + Ref<Type> m_teb; + public: WindowsX64Platform(Architecture* arch): Platform(arch, "windows-x86_64") { + m_gsbase = arch->GetRegisterByName("gsbase"); + Ref<CallingConvention> cc; cc = arch->GetCallingConventionByName("win64"); @@ -55,6 +81,22 @@ public: RegisterStdcallCallingConvention(cc); } } + + + virtual void BinaryViewInit(BinaryView* view) override + { + if (!m_teb) + m_teb = Type::PointerType(GetArchitecture()->GetAddressSize(), Type::NamedType(QualifiedName("TEB"), GetTypeByName(QualifiedName("TEB")))); + } + + + virtual Ref<Type> GetGlobalRegisterType(uint32_t reg) override + { + if (reg == m_gsbase) + return m_teb; + + return nullptr; + } }; |
