diff options
Diffstat (limited to 'platform/windows/platform_windows.cpp')
| -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; + } }; |
