Publish the files

This commit is contained in:
Satoshi Tanda
2020-02-22 13:54:50 -08:00
parent 83bd8d5f19
commit 791486327d
79 changed files with 36078 additions and 47 deletions

View File

@@ -0,0 +1,94 @@
[Defines]
INF_VERSION = 1.27
BASE_NAME = MiniVisorDxe
FILE_GUID = 503682AC-F01E-4D10-AAE3-BE5A90A563E7
MODULE_TYPE = DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = DriverEntry
UNLOAD_IMAGE = DriverUnload
[Sources]
../../../Sources/Platform/EFI/EfiAsm.asm
../../../Sources/Platform/EFI/EfiAsm.h
../../../Sources/Platform/EFI/EfiBitmap.c
../../../Sources/Platform/EFI/EfiBitmap.h
../../../Sources/Platform/EFI/EfiCommon.h
../../../Sources/Platform/EFI/EfiHostInitialization.c
../../../Sources/Platform/EFI/EfiHostInitialization.h
../../../Sources/Platform/EFI/EfiLogger.c
../../../Sources/Platform/EFI/EfiLogger.h
../../../Sources/Platform/EFI/EfiPlatform.c
../../../Sources/Platform/EFI/EfiPlatform.h
../../../Sources/ExtendedPageTables.c
../../../Sources/ExtendedPageTables.h
../../../Sources/HostMain.c
../../../Sources/HostMain.h
#../../../Sources/HostNesting.c
../../../Sources/HostNesting.h
../../../Sources/HostUtils.c
../../../Sources/HostUtils.h
../../../Sources/HostVmcall.c
../../../Sources/HostVmcall.h
../../../Sources/Logger.h
../../../Sources/MemoryAccess.c
../../../Sources/MemoryAccess.h
../../../Sources/MemoryManager.c
../../../Sources/MemoryManager.h
../../../Sources/MemoryType.c
../../../Sources/MemoryType.h
../../../Sources/MiniVisor.c
../../../Sources/MiniVisor.h
../../../Sources/Platform.h
../../../Sources/Utils.c
../../../Sources/Utils.h
../../../Sources/Ia32.h
../../../Sources/Asm.asm
../../../Sources/Asm.h
../../../Sources/Common.h
../../../Sources/ia32-doc/out/ia32.h
[Packages]
MdePkg/MdePkg.dec
MiniVisorPkg/Builds/Platform/EFI/MiniVisorPkg.dec
[LibraryClasses]
UefiDriverEntryPoint
UefiLib
DevicePathLib
SynchronizationLib
MemoryAllocationLib
PrintLib
[Protocols]
gEfiLoadedImageProtocolGuid ## CONSUMES
gEfiMpServiceProtocolGuid ## CONSUMES
[Guids]
gEfiEventExitBootServicesGuid ## CONSUMES
gEfiEventVirtualAddressChangeGuid ## CONSUMES
[Depex]
TRUE
[BuildOptions.common.DXE_RUNTIME_DRIVER]
# Detect use of deprecated interfaces if any.
MSFT:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
# Remove DebugLib library instances (ASSERT and such) from the RELEASE binary.
# https://github.com/tianocore-docs/edk2-UefiDriverWritersGuide/blob/master/31_testing_and_debugging_uefi_drivers/314_debugging_code_statements/3141_configuring_debuglib_with_edk_ii.md
MSFT:RELEASE_*_*_CC_FLAGS = -D MDEPKG_NDEBUG
# EDK2 default defines /ALIGN:32, which is way too small for and causes link
# error. Reset to the default value.
MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096 /DEBUG
# By default, certain meta-data in the PE header is zeroed out to increase
# compression ratio. Some of those information can be helpful for a debugger,
# for example, to reconstruct stack trace. Leave it for such cases. See also,
# https://edk2-docs.gitbooks.io/edk-ii-basetools-user-guides/content/GenFw.html
MSFT:*_*_X64_GENFW_FLAGS = --keepexceptiontable --keepzeropending --keepoptionalheader
# Finally, note that the RELEASE build will generate excessively large binary
# file. To avoid this open the Conf/tools_def.txt, locate the below line,
# RELEASE_VS2019_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
# then, remove "/MERGE:.rdata=.data".

View File

@@ -0,0 +1,9 @@
[Defines]
DEC_SPECIFICATION = 1.27
PACKAGE_NAME = MiniVisorPkg
PACKAGE_GUID = 6BFA833B-A9DF-490D-AF7E-7F92A80E3F9A
PACKAGE_VERSION = 1.00
[Includes]
../../../Sources
../../../Sources/Platform/EFI

View File

@@ -0,0 +1,51 @@
[Defines]
DSC_SPECIFICATION = 1.28
PLATFORM_NAME = MiniVisor
PLATFORM_GUID = C5ACE17D-FD90-44F7-847C-693ED2B8BEF9
PLATFORM_VERSION = 1.00
OUTPUT_DIRECTORY = Build/MiniVisor
SUPPORTED_ARCHITECTURES = X64
BUILD_TARGETS = DEBUG|RELEASE|NOOPT
SKUID_IDENTIFIER = DEFAULT
[LibraryClasses]
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
!if $(TARGET) == RELEASE
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
!else
!ifdef $(DEBUG_ON_SERIAL_PORT)
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
!else
DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
!endif
!endif
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
[PcdsFixedAtBuild]
# Define DEBUG_ERROR | DEBUG_VERBOSE | DEBUG_INFO | DEBUG_WARN to enable
# logging at those levels. Also, define DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED
# and such. Assertion failure will call CpuDeadLoop.
# https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Debugging
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80400042
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f
[Components]
MiniVisorPkg/Builds/Platform/EFI/MiniVisorDxe.inf

View File

@@ -0,0 +1,13 @@
current_page_base = idaapi.get_reg_val('rip') & (~0xfff)
offset = 0
while idc.read_dbg_word(current_page_base - offset) != 0x5a4d:
offset += 0x1000
image_base = current_page_base - offset
print(
f'Base found at 0x{image_base:02X}. To load symbols, go [File] menu >'
f' Load file > PDB file..., then set,\n'
f' Input file: the PDB file, for example, C:\\edk2\\MiniVisorPkg\\Builds\\x64\\UEFI\\MiniVisorDxe.pdb\n'
f' Address: 0x{image_base:02X}\n'
f'and hit [OK], and then, [Yes].'
)

View File

@@ -0,0 +1,66 @@
/*!
@file DumpActiveLogs.js
@brief Implements the DumpActiveLogs function which dumps buffered log entries.
@author Satoshi Tanda
@copyright Copyright (c) 2019 - , Satoshi Tanda. All rights reserved.
*/
"use strict";
function initializeScript()
{
return [new host.apiVersionSupport(1, 3)];
}
function invokeScript()
{
//
// Insert your script content here. This method will be called whenever the script is
// invoked from a client.
//
// See the following for more details:
//
// https://aka.ms/JsDbgExt
//
}
const log = x => host.diagnostics.debugLog(x + "\n");
const u64 = x => host.memory.readMemoryValues(x, 1, 8)[0];
const sizeof = x => host.evaluateExpression("sizeof(" + x + ")");
const str = (x) => host.memory.readString(x);
const strn = (x, y) => host.memory.readString(x, y);
/**
* Returns an array of arrays of log entries where 0=ProcessName, 1=FunctionName,
* and 2=LogMessage.
*
* Example:
* kd> .scriptload C:\edk2\MiniVisorPkg\Builds\Platform\Windows\DumpActiveLogs.js
* kd> dx Debugger.State.Scripts.DumpActiveLogs.Contents.DumpActiveLogs(),0xffff
*/
function DumpActiveLogs()
{
let addr = host.getModuleSymbolAddress("MiniVisor", "g_Logger");
let context = host.createPointerObject(u64(addr), "MiniVisor", "LOGGER_CONTEXT*");
let entriesBase = context.PairedLogBuffer.ActiveLogBuffer.LogEntries;
let logs = [];
host.diagnostics.debugLog("Collecting buffered log entries.");
for (let offset = 0; offset < context.PairedLogBuffer.ActiveLogBuffer.NextLogOffset; /**/)
{
let entry = host.createPointerObject(entriesBase.address.add(offset),
"MiniVisor",
"_DEBUG_LOG_ENTRY*");
logs.push([
str(entry.ProcessName),
str(entry.FunctionName),
strn(entry.LogMessage, entry.LogMessageLength),
]);
offset += sizeof("_DEBUG_LOG_ENTRY") - 1 + entry.LogMessageLength;
host.diagnostics.debugLog(".");
}
host.diagnostics.debugLog("\n");
return logs;
}