From d9a3aa6fb8f77434f1ecfbc9127d28067a2cc9b8 Mon Sep 17 00:00:00 2001 From: Satoshi Tanda Date: Sat, 25 Nov 2017 20:06:57 -0800 Subject: Fix code analysis warnings and typo This change fixes warnings seen with code analysis on VS2017 and typo. Also, excludes a .VC.db file. --- .gitignore | 3 ++- nt/shvos.c | 8 +++++++- shv_x.h | 2 +- shvvmx.c | 2 +- shvvmxhv.c | 4 ++-- shvvmxhvx64.asm | 2 +- shvvp.c | 3 ++- uefi/shvos.c | 2 +- uefi/shvosx64.asm | 2 +- 9 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 0b72f22..2eabe1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ x64 -.vs \ No newline at end of file +.vs +.VC.db \ No newline at end of file diff --git a/nt/shvos.c b/nt/shvos.c index 2e1832f..532fcf0 100644 --- a/nt/shvos.c +++ b/nt/shvos.c @@ -52,6 +52,8 @@ KeSignalCallDpcSynchronize ( _In_ PVOID SystemArgument2 ); +DRIVER_INITIALIZE DriverEntry; + DECLSPEC_NORETURN VOID __cdecl @@ -120,6 +122,10 @@ ShvOsDpcRoutine ( PSHV_DPC_CONTEXT dpcContext = DeferredContext; UNREFERENCED_PARAMETER(Dpc); + __analysis_assume(DeferredContext != NULL); + __analysis_assume(SystemArgument1 != NULL); + __analysis_assume(SystemArgument2 != NULL); + // // Execute the internal callback function // @@ -137,7 +143,7 @@ ShvOsDpcRoutine ( // thread, that's perfectly fine (albeit unusual). If the DPC interrupted a // 64-bit long-mode thread, that's also fine. However if the DPC interrupts // a thread in compatibility-mode, running as part of WoW64, it will hit a - // GPF instantenously and crash. + // GPF instantaneously and crash. // // Thus, set the segments to their correct value, one more time, as a fix. // diff --git a/shv_x.h b/shv_x.h index 95eac78..bb86f0d 100644 --- a/shv_x.h +++ b/shv_x.h @@ -38,7 +38,7 @@ struct _SHV_CALLBACK_CONTEXT; typedef void SHV_CPU_CALLBACK ( - struct _SHV_CALLBACK_CONTEXT* Context + _In_ struct _SHV_CALLBACK_CONTEXT* Context ); typedef SHV_CPU_CALLBACK *PSHV_CPU_CALLBACK; diff --git a/shvvmx.c b/shvvmx.c index 7030453..dfdd3a8 100644 --- a/shvvmx.c +++ b/shvvmx.c @@ -331,7 +331,7 @@ ShvVmxSetupVmcsForVp ( // Enable support for RDTSCP and XSAVES/XRESTORES in the guest. Windows 10 // makes use of both of these instructions if the CPU supports it. By using // ShvUtilAdjustMsr, these options will be ignored if this processor does - // not actully support the instructions to begin with. + // not actually support the instructions to begin with. // // Also enable EPT support, for additional performance and ability to trap // memory access efficiently. diff --git a/shvvmxhv.c b/shvvmxhv.c index c04c06b..dd0c3b5 100644 --- a/shvvmxhv.c +++ b/shvvmxhv.c @@ -102,9 +102,9 @@ ShvVmxHandleCpuid ( INT32 cpu_info[4]; // - // Check for the magic CPUID sequence, and check that it is is coming from + // Check for the magic CPUID sequence, and check that it is coming from // Ring 0. Technically we could also check the RIP and see if this falls - // in the expected function, but we may want to allow a sepaarate "unload" + // in the expected function, but we may want to allow a separate "unload" // driver or code at some point. // if ((VpState->VpRegs->Rax == 0x41414141) && diff --git a/shvvmxhvx64.asm b/shvvmxhvx64.asm index e010e66..c981bfb 100644 --- a/shvvmxhvx64.asm +++ b/shvvmxhvx64.asm @@ -4,7 +4,7 @@ ; ; Module: ; -; shvx64.asm +; shvvmxhvx64.asm ; ; Abstract: ; diff --git a/shvvp.c b/shvvp.c index 75334c5..dd1f43b 100644 --- a/shvvp.c +++ b/shvvp.c @@ -135,7 +135,7 @@ ShvVpInitialize ( // Then, capture the entire register state. We will need this, as once we // launch the VM, it will begin execution at the defined guest instruction // pointer, which we set to ShvVpRestoreAfterLaunch, with the registers set - // to whatever value they were deep inside the VMCS/VMX inialization code. + // to whatever value they were deep inside the VMCS/VMX initialization code. // By using RtlRestoreContext, that function sets the AC flag in EFLAGS and // returns here with our registers restored. // @@ -178,6 +178,7 @@ ShvVpUnloadCallback ( // if (cpuInfo[2] == 0x43434343) { + __analysis_assume((cpuInfo[0] != 0) && (cpuInfo[1] != 0)); vpData = (PSHV_VP_DATA)((UINT64)cpuInfo[0] << 32 | (UINT32)cpuInfo[1]); ShvOsFreeContiguousAlignedMemory(vpData, sizeof(*vpData)); } diff --git a/uefi/shvos.c b/uefi/shvos.c index 57732bf..091cf96 100644 --- a/uefi/shvos.c +++ b/uefi/shvos.c @@ -384,7 +384,7 @@ UefiMain ( &_gPiMpService); if (EFI_ERROR(efiStatus)) { - Print(L"Unable to locate the MpServices procotol: %r\n", efiStatus); + Print(L"Unable to locate the MpServices protocol: %r\n", efiStatus); return efiStatus; } diff --git a/uefi/shvosx64.asm b/uefi/shvosx64.asm index c1bdf84..dcdd2e3 100644 --- a/uefi/shvosx64.asm +++ b/uefi/shvosx64.asm @@ -4,7 +4,7 @@ ; ; Module: ; -; shvx64.asm +; shvosx64.asm ; ; Abstract: ; -- cgit v1.2.3