@@ -11,11 +11,16 @@ Ref<Platform> g_efiX86Windows, g_efiX64Windows, g_efiArm64Windows;
1111
1212class EFIX86Platform : public Platform
1313{
14+ uint32_t m_idtr;
15+ Ref<Type> m_idtrtype;
16+
1417public:
1518 EFIX86Platform (Architecture* arch) : Platform(arch, " efi-x86" )
1619 {
1720 Ref<CallingConvention> cc;
1821
22+ m_idtr = arch->GetRegisterByName (" idtr" );
23+
1924 cc = arch->GetCallingConventionByName (" cdecl" );
2025 if (cc)
2126 {
@@ -50,16 +55,36 @@ class EFIX86Platform : public Platform
5055 return g_efiX86;
5156 return nullptr ;
5257 }
58+
59+ virtual void BinaryViewInit (BinaryView* view) override
60+ {
61+ if (!m_idtrtype)
62+ m_idtrtype = Type::NamedType (QualifiedName (" IDTR32" ), GetTypeByName (QualifiedName (" IDTR32" )));
63+ }
64+
65+ virtual Ref<Type> GetGlobalRegisterType (uint32_t reg) override
66+ {
67+ if (reg == m_idtr)
68+ return m_idtrtype;
69+
70+ return nullptr ;
71+ }
72+
5373};
5474
5575
5676class EFIX86WindowsPlatform : public Platform
5777{
78+ uint32_t m_idtr;
79+ Ref<Type> m_idtrtype;
80+
5881public:
5982 EFIX86WindowsPlatform (Architecture* arch) : Platform(arch, " efi-windows-x86" )
6083 {
6184 Ref<CallingConvention> cc;
6285
86+ m_idtr = arch->GetRegisterByName (" idtr" );
87+
6388 cc = arch->GetCallingConventionByName (" cdecl" );
6489 if (cc)
6590 {
@@ -94,16 +119,34 @@ class EFIX86WindowsPlatform : public Platform
94119 return g_efiX86Windows;
95120 return nullptr ;
96121 }
122+
123+ virtual void BinaryViewInit (BinaryView* view) override
124+ {
125+ if (!m_idtrtype)
126+ m_idtrtype = Type::NamedType (QualifiedName (" IDTR32" ), GetTypeByName (QualifiedName (" IDTR32" )));
127+ }
128+
129+ virtual Ref<Type> GetGlobalRegisterType (uint32_t reg) override
130+ {
131+ if (reg == m_idtr)
132+ return m_idtrtype;
133+
134+ return nullptr ;
135+ }
97136};
98137
99138
100139class EFIX64Platform : public Platform
101140{
141+ uint32_t m_idtr;
142+ Ref<Type> m_idtrtype;
143+
102144public:
103145 EFIX64Platform (Architecture* arch) : Platform(arch, " efi-x86_64" )
104146 {
105147 Ref<CallingConvention> cc;
106148
149+ m_idtr = arch->GetRegisterByName (" idtr" );
107150 cc = arch->GetCallingConventionByName (" win64" );
108151 if (cc)
109152 {
@@ -123,16 +166,34 @@ class EFIX64Platform : public Platform
123166 return g_efiX64;
124167 return nullptr ;
125168 }
169+
170+ virtual void BinaryViewInit (BinaryView* view) override
171+ {
172+ if (!m_idtrtype)
173+ m_idtrtype = Type::NamedType (QualifiedName (" IDTR64" ), GetTypeByName (QualifiedName (" IDTR64" )));
174+ }
175+
176+ virtual Ref<Type> GetGlobalRegisterType (uint32_t reg) override
177+ {
178+ if (reg == m_idtr)
179+ return m_idtrtype;
180+
181+ return nullptr ;
182+ }
126183};
127184
128185
129186class EFIX64WindowsPlatform : public Platform
130187{
188+ uint32_t m_idtr;
189+ Ref<Type> m_idtrtype;
190+
131191public:
132192 EFIX64WindowsPlatform (Architecture* arch) : Platform(arch, " efi-windows-x86_64" )
133193 {
134194 Ref<CallingConvention> cc;
135195
196+ m_idtr = arch->GetRegisterByName (" idtr" );
136197 cc = arch->GetCallingConventionByName (" win64" );
137198 if (cc)
138199 {
@@ -152,6 +213,20 @@ class EFIX64WindowsPlatform : public Platform
152213 return g_efiX64Windows;
153214 return nullptr ;
154215 }
216+
217+ virtual void BinaryViewInit (BinaryView* view) override
218+ {
219+ if (!m_idtrtype)
220+ m_idtrtype = Type::NamedType (QualifiedName (" IDTR64" ), GetTypeByName (QualifiedName (" IDTR64" )));
221+ }
222+
223+ virtual Ref<Type> GetGlobalRegisterType (uint32_t reg) override
224+ {
225+ if (reg == m_idtr)
226+ return m_idtrtype;
227+
228+ return nullptr ;
229+ }
155230};
156231
157232
0 commit comments