event injection is wrong

merge-requests/1/head
_xeroxz 4 years ago
parent 761e6b16ac
commit 647250f1af

@ -85,6 +85,7 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="entry.cpp" /> <ClCompile Include="entry.cpp" />
<ClCompile Include="exit_handler.cpp" /> <ClCompile Include="exit_handler.cpp" />
<ClCompile Include="idt.cpp" />
<ClCompile Include="mm.cpp" /> <ClCompile Include="mm.cpp" />
<ClCompile Include="segment.cpp" /> <ClCompile Include="segment.cpp" />
<ClCompile Include="vmcs.cpp" /> <ClCompile Include="vmcs.cpp" />
@ -93,6 +94,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="ia32.hpp" /> <ClInclude Include="ia32.hpp" />
<ClInclude Include="idt.hpp" />
<ClInclude Include="mm.hpp" /> <ClInclude Include="mm.hpp" />
<ClInclude Include="segment_intrin.h" /> <ClInclude Include="segment_intrin.h" />
<ClInclude Include="hv_types.hpp" /> <ClInclude Include="hv_types.hpp" />
@ -102,6 +104,7 @@
<ClInclude Include="vmxon.hpp" /> <ClInclude Include="vmxon.hpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<MASM Include="idt_handler.asm" />
<MASM Include="segment_intrin.asm" /> <MASM Include="segment_intrin.asm" />
<MASM Include="vmxexit_handler.asm" /> <MASM Include="vmxexit_handler.asm" />
</ItemGroup> </ItemGroup>

@ -32,6 +32,9 @@
<ClCompile Include="mm.cpp"> <ClCompile Include="mm.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="idt.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="vmxon.hpp"> <ClInclude Include="vmxon.hpp">
@ -58,6 +61,9 @@
<ClInclude Include="mm.hpp"> <ClInclude Include="mm.hpp">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="idt.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<MASM Include="segment_intrin.asm"> <MASM Include="segment_intrin.asm">
@ -66,5 +72,8 @@
<MASM Include="vmxexit_handler.asm"> <MASM Include="vmxexit_handler.asm">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</MASM> </MASM>
<MASM Include="idt_handler.asm">
<Filter>Source Files</Filter>
</MASM>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -79,6 +79,35 @@ namespace hv
}; };
}; };
typedef union _idt_entry_t
{
u128 flags;
struct
{
u64 offset_low : 16;
u64 segment_selector : 16;
u64 reserved_0 : 8;
u64 gate_type : 4;
u64 storage_segment : 1;
u64 dpl : 2;
u64 present : 1;
u64 offset_middle : 16;
u64 offset_high : 32;
u64 reserved_1 : 32;
};
} idt_entry_t, *pidt_entry_t;
union idt_addr_t
{
u64 addr;
struct
{
u64 offset_low : 16;
u64 offset_middle : 16;
u64 offset_high : 32;
};
};
union ia32_efer_t union ia32_efer_t
{ {
unsigned __int64 control; unsigned __int64 control;

@ -0,0 +1,20 @@
#include "idt.hpp"
namespace idt
{
auto create_entry(void* address) -> hv::idt_entry_t
{
hv::idt_addr_t idt_addr{ (u64) address };
hv::idt_entry_t result{};
result.dpl = 0;
result.storage_segment = 0;
result.segment_selector = readcs();
result.gate_type = SEGMENT_DESCRIPTOR_TYPE_INTERRUPT_GATE;
result.present = 1;
result.offset_high = idt_addr.offset_high;
result.offset_middle = idt_addr.offset_middle;
result.offset_low = idt_addr.offset_low;
return result;
}
}

@ -0,0 +1,10 @@
#pragma once
#include "hv_types.hpp"
#include "segment_intrin.h"
#pragma section(".idt", read, write)
namespace idt
{
__declspec(allocate(".idt")) inline hv::idt_entry_t table[256];
auto create_entry(void* address) -> hv::idt_entry_t;
}

@ -1,7 +1,5 @@
#pragma once #pragma once
#include "hv_types.hpp" #include "hv_types.hpp"
// the pml4 itself is inside of the HV...
#pragma section(".pml4", read, write) #pragma section(".pml4", read, write)
namespace mm namespace mm

Loading…
Cancel
Save