Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wbenny committed Aug 6, 2018
0 parents commit 52e91d2
Show file tree
Hide file tree
Showing 64 changed files with 8,477 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*.{c,h,cpp,hpp}]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Compiled binaries.
#
bin/**

#
# Visual Studio files.
#
.vs/**
*.VC.db
*.VC.opendb

#
# VS Code files.
#
.vscode/**
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Petr Benes

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 8 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class system_thread
better EPT handling
split VCPU to hypervisor + vcpu
make some intelligent guess of how much memory will be needed to allocate (to memory_manager)
implement in/out exiting
remove all references to ntoskrnl, all functions should be provided via struct
implement io-ctrl, make hvppctrl somewhat useful
fix cr3 on exit + inspect ShvVmxCleanup (ds, es, fs fix)
38 changes: 38 additions & 0 deletions hvpp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2000
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hvpp", "src\hvpp\hvpp.vcxproj", "{2FC6C155-2BDF-4761-B9B5-7DFE9C2BB4F4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hvppctrl", "src\hvppctrl\hvppctrl.vcxproj", "{A72DAEF5-C739-4E70-B57E-4310ABA03749}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{01B84E09-7D4F-4415-95AD-C9291497D28C}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2FC6C155-2BDF-4761-B9B5-7DFE9C2BB4F4}.Debug|x64.ActiveCfg = Debug|x64
{2FC6C155-2BDF-4761-B9B5-7DFE9C2BB4F4}.Debug|x64.Build.0 = Debug|x64
{2FC6C155-2BDF-4761-B9B5-7DFE9C2BB4F4}.Debug|x64.Deploy.0 = Debug|x64
{2FC6C155-2BDF-4761-B9B5-7DFE9C2BB4F4}.Release|x64.ActiveCfg = Release|x64
{2FC6C155-2BDF-4761-B9B5-7DFE9C2BB4F4}.Release|x64.Build.0 = Release|x64
{2FC6C155-2BDF-4761-B9B5-7DFE9C2BB4F4}.Release|x64.Deploy.0 = Release|x64
{A72DAEF5-C739-4E70-B57E-4310ABA03749}.Debug|x64.ActiveCfg = Debug|x64
{A72DAEF5-C739-4E70-B57E-4310ABA03749}.Debug|x64.Build.0 = Debug|x64
{A72DAEF5-C739-4E70-B57E-4310ABA03749}.Release|x64.ActiveCfg = Release|x64
{A72DAEF5-C739-4E70-B57E-4310ABA03749}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B2F42D07-8CF5-40C5-924F-6EAB82D9ABF0}
EndGlobalSection
EndGlobal
71 changes: 71 additions & 0 deletions src/hvpp/hvpp.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
;
; hvpp.inf
;

[Version]
Signature="$WINDOWS NT$"
Class=Sample ; TODO: edit Class
ClassGuid={78A1C341-4539-11d3-B88D-00C04FAD5171} ; TODO: edit ClassGuid
Provider=%ManufacturerName%
CatalogFile=hvpp.cat
DriverVer= ; TODO: set DriverVer in stampinf property pages

[DestinationDirs]
DefaultDestDir = 12
hvpp_Device_CoInstaller_CopyFiles = 11

; ================= Class section =====================

[ClassInstall32]
Addreg=SampleClassReg

[SampleClassReg]
HKR,,,0,%ClassName%
HKR,,Icon,,-5

[SourceDisksNames]
1 = %DiskName%,,,""

[SourceDisksFiles]
hvpp.sys = 1,,
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1 ; make sure the number matches with SourceDisksNames

;*****************************************
; Install Section
;*****************************************

[Manufacturer]
%ManufacturerName%=Standard,NT$ARCH$

[Standard.NT$ARCH$]
%hvpp.DeviceDesc%=hvpp_Device, Root\hvpp ; TODO: edit hw-id

[hvpp_Device.NT]
CopyFiles=Drivers_Dir

[Drivers_Dir]
hvpp.sys

;-------------- Service installation
[hvpp_Device.NT.Services]
AddService = hvpp,%SPSVCINST_ASSOCSERVICE%, hvpp_Service_Inst

; -------------- hvpp driver install sections
[hvpp_Service_Inst]
DisplayName = %hvpp.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\hvpp.sys

;
;--- hvpp_Device Coinstaller installation ------
;

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
ManufacturerName="<Your manufacturer name>" ;TODO: Replace with your manufacturer name
ClassName="Samples" ; TODO: edit ClassName
DiskName = "hvpp Installation Disk"
hvpp.DeviceDesc = "hvpp Device"
hvpp.SVCDESC = "hvpp Service"
154 changes: 154 additions & 0 deletions src/hvpp/hvpp.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2FC6C155-2BDF-4761-B9B5-7DFE9C2BB4F4}</ProjectGuid>
<TemplateGuid>{1bc93793-694f-48fe-9372-81e2b05556fd}</TemplateGuid>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration>Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
<RootNamespace>hvpp</RootNamespace>
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<TargetVersion>Windows7</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
<DriverType>WDM</DriverType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<TargetVersion>Windows7</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
<DriverType>WDM</DriverType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(IncludePath);$(KMDF_INC_PATH)$(KMDF_VER_PATH)</IncludePath>
<OutDir>$(SolutionDir)bin\$(PlatformShortName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(PlatformShortName)\$(Configuration)\$(ProjectName)\</IntDir>
<EnableInf2cat>false</EnableInf2cat>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
<IncludePath>$(ProjectDir);$(VC_IncludePath);$(IncludePath);$(KMDF_INC_PATH)$(KMDF_VER_PATH)</IncludePath>
<OutDir>$(SolutionDir)bin\$(PlatformShortName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(PlatformShortName)\$(Configuration)\$(ProjectName)\</IntDir>
<Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<DisableSpecificWarnings>4201;4748;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<LanguageStandard>stdcpplatest</LanguageStandard>
<ObjectFileName>$(IntDir)%(RelativeDir)%(Filename)%(Extension).obj</ObjectFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Inf />
<Inf />
<MASM />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<DisableSpecificWarnings>4201;4603;4627;4986;4987;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<LanguageStandard>stdcpplatest</LanguageStandard>
<ObjectFileName>$(IntDir)%(RelativeDir)%(Filename)%(Extension).obj</ObjectFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Inf />
<MASM />
</ItemDefinitionGroup>
<ItemGroup>
<Inf Include="hvpp.inf">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</Inf>
</ItemGroup>
<ItemGroup>
<FilesToPackage Include="$(TargetPath)" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="hvpp\ept.cpp" />
<ClCompile Include="hvpp\hypervisor.cpp" />
<ClCompile Include="hvpp\vcpu.cpp" />
<ClCompile Include="hvpp\vcpu_vmcs.cpp" />
<ClCompile Include="hvpp\vmexit.cpp">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)/$(RelativeDir)/%(Filename)%(Extension).obj</ObjectFileName>
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)/$(RelativeDir)/%(Filename)%(Extension).obj</ObjectFileName>
</ClCompile>
<ClCompile Include="lib\log.cpp" />
<ClCompile Include="lib\mm.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="hvpp\ept.h" />
<ClInclude Include="hvpp\hypervisor.h" />
<ClInclude Include="hvpp\vcpu.h" />
<ClInclude Include="hvpp\vmexit.h" />
<ClInclude Include="ia32\arch.h" />
<ClInclude Include="ia32\arch\cr.h" />
<ClInclude Include="ia32\arch\dr.h" />
<ClInclude Include="ia32\arch\rflags.h" />
<ClInclude Include="ia32\arch\segment.h" />
<ClInclude Include="ia32\asm.h" />
<ClInclude Include="ia32\ept.h" />
<ClInclude Include="ia32\exception.h" />
<ClInclude Include="ia32\interrupt.h" />
<ClInclude Include="ia32\memory.h" />
<ClInclude Include="ia32\msr.h" />
<ClInclude Include="ia32\msr\arch.h" />
<ClInclude Include="ia32\msr\mtrr.h" />
<ClInclude Include="ia32\msr\vmx.h" />
<ClInclude Include="ia32\mtrr.h" />
<ClInclude Include="ia32\vmx.h" />
<ClInclude Include="ia32\vmx\exception_bitmap.h" />
<ClInclude Include="ia32\vmx\instruction_error.h" />
<ClInclude Include="ia32\vmx\exit_qualification.h" />
<ClInclude Include="ia32\vmx\exit_reason.h" />
<ClInclude Include="ia32\vmx\interrupt.h" />
<ClInclude Include="ia32\vmx\io_bitmap.h" />
<ClInclude Include="ia32\vmx\msr_bitmap.h" />
<ClInclude Include="ia32\vmx\vmcs.h" />
<ClInclude Include="lib\assert.h" />
<ClInclude Include="lib\bitmap.h" />
<ClInclude Include="lib\enumname.h" />
<ClInclude Include="lib\log.h" />
<ClInclude Include="lib\mm.h" />
<ClInclude Include="lib\mp.h" />
<ClInclude Include="lib\noopt.h" />
<ClInclude Include="lib\spinlock.h" />
<ClInclude Include="lib\thread.h" />
<ClInclude Include="lib\typelist.h" />
</ItemGroup>
<ItemGroup>
<MASM Include="hvpp\vcpu.asm" />
<MASM Include="ia32\context.asm" />
<MASM Include="ia32\asm.asm" />
<MASM Include="lib\noopt.asm" />
</ItemGroup>
<ItemGroup>
<None Include="ia32\common.inc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading

0 comments on commit 52e91d2

Please sign in to comment.