Commit graph

106 commits

Author SHA1 Message Date
Vivyy
60a6a57510
EfiDSEFix: FindCiOptions: match arbitrary r32 immediates (#156) 2026-06-17 01:48:43 +02:00
Matthijs Lavrijsen
04fb763465
EfiDSEFix: fix failure to find g_CiOptions with KB5083631
Additionally, print a more helpful error message when FindCiOptions fails.

Fixes #151
2026-05-11 18:36:18 +02:00
Matthijs Lavrijsen
c047987382
Update VS project files to VS2026 2026-04-02 07:56:28 +02:00
Matthijs Lavrijsen
801ad43372
PatchImgpValidateImageHash: help out images with invalid PE checksums
Fixes #132
2025-08-03 20:11:40 +02:00
Matthijs Lavrijsen
b648673acb
Increase file and section alignments to equal page size
Some environments restrict images from running if sections are not page-aligned, because this prevents them from fully enforcing section protections such as RO and NX in hardware via page tables.

Also increase the file alignment to match the new section alignment, because identical file and section alignments are a requirement for running images as XIP. XIP execution is not the norm for EfiGuard, but it at least shouldn't be prevented over a few KBs of difference in binary file size.
2025-08-03 20:01:50 +02:00
Matthijs Lavrijsen
f29c1b9d6a
Correctly handle UNW_FLAG_CHAININFO in unwind data 2025-06-11 23:29:22 +02:00
Matthijs Lavrijsen
6cb7f8575b
Verify found addresses are inside known PE functions where possible
This commit fixes a bug that was causing ImgpValidateImageHash to not be found in bootmgfw/bootmgr.efi 10.0.26100.0, due to a false positive match from Zydis being incorrectly accepted. The found 'instruction' address was actually part of a CRC lookup table. This means the address has no matching runtime function metadata in the PE exception directory, and this check is now used to ignore any such results.

Additionally, pre-emptively add this check anywhere it should logically succeed. The runtime overhead of doing this is very small relative to the instruction decoding we are already doing anyway.
2025-06-11 23:29:21 +02:00
Matthijs Lavrijsen
b8ccb6c731
Move BacktrackToFunctionStart to pe.c
This function is highly PE-specific, and pe.c is therefore a more suitable TU.
Also rename it to FindFunctionStart, so as to not imply that any state (e.g. the virtual runtime address used for decoding, ..) is modified, nor that we necessarily need to be backtracking when calling it. This function can also be used more generally to verify whether an address is part of any function at all according to the PE exception directory.

Misc: minor const correctness fixes
2025-06-11 23:29:21 +02:00
Matthijs Lavrijsen
17a79a44f7
Update Zydis submodule
Update Zydis to v4.1.1.
2025-06-11 23:29:21 +02:00
Matthijs Lavrijsen
66a4e637e2
Fix build with current EDK2 master
Reason is the same as the last commit. EDK2 now also requires an implementation of a 'StackCheckLib' in addition to the (still unfixed) issues already mentioned in #134.
2025-06-11 23:29:10 +02:00
worldwidefuckfest
5193eca662
Add VeraCrypt support (#136) 2025-02-24 12:57:35 +01:00
Matthijs Lavrijsen
5bfa808faa
Fix build with current EDK2 master
Re-add the missing headers for EFI_LEGACY_BIOS_PROTOCOL and gEfiLegacyBiosGuid which were removed from OvmfPkg in 9d4becddba.

Neither OVMF nor EfiGuard actually *needs* the CSM for anything, but being able to check for the presence of the legacy BIOS protocol is still important in order to determine if we are actually booting a legacy BIOS boot option. This allows us to then inform the user that what they are doing is not suppported and most likely a mistake.

Fixes #119
2025-01-17 04:46:34 +01:00
Matthijs Lavrijsen
b55a50a414
Fix build with current EDK2 master
Override the unwanted /GS flag addition (MSVC) and -fno-stack-protector removal (GCC) introduced in f53f029122

Additionally remove some other (less harmful but still unwanted) build flags that have been made the default in MSVC in the .vcxproj/.props files as well.

Fixes #134
2025-01-17 04:46:34 +01:00
Matthijs Lavrijsen
f3cf9d1c6b
Misc. minor warning fixes 2025-01-17 04:46:34 +01:00
Matthijs Lavrijsen
b8d787c347
Loader: do not pass load options to auto-generated boot entries 2024-01-21 07:27:42 +01:00
Matthijs Lavrijsen
620defa398
Use case-insensitive string comparison when checking file names 2024-01-21 07:25:48 +01:00
Matthijs Lavrijsen
a1c33c4ae6
Loader: close root volume handle in LocateFile() 2024-01-21 06:07:36 +01:00
Matthijs Lavrijsen
4dc84bdb64
Pedantic assert fix in SetVariable hook 2024-01-20 23:16:47 +01:00
Matthijs Lavrijsen
0f5dca4e65
Drop /MERGE from linker flags in DSC 2023-10-15 04:31:58 +02:00
Matthijs Lavrijsen
b77c4896c6
KiSwInterrupt patch: reuse INIT section as PG context
INIT is already discardable (and exists in all NT kernels), no need to obtain INITDATA separately.
2023-10-15 04:23:23 +02:00
Matthijs Lavrijsen
8db9145e25
Fix build with GCC toolchain 2023-10-14 22:02:46 +02:00
Matthijs Lavrijsen
f04570f799
EfiDSEFix: do not request UAC elevation in manifest
This works around a Windows Shell issue when launching console applications that require admin elevation (this includes EfiDSEFix) from an unelevated command prompt while having UAC enabled.

Fixes #75
2023-10-14 22:02:46 +02:00
Matthijs Lavrijsen
6774173bfc
Always use CopyWpMem in SetVariable hook 2023-10-14 22:02:45 +02:00
Matthijs Lavrijsen
99aa1dbaad
Check CR4_CET.SH_STK_EN before adjusting shadow stack 2023-10-14 22:02:45 +02:00
Matthijs Lavrijsen
8a1730a0bb
Update README.md 2023-10-12 12:19:17 +02:00
Matthijs Lavrijsen
529537f027
Loader: make driver configuration a runtime option
The interactive driver configuration now requires the HOME key to be pressed when the loader is started. If it is not pressed, the default configuration will be used as before.
The CONFIGURE_DRIVER compile time define is no longer useful due to this change and has been removed.
2023-10-12 12:15:45 +02:00
Matthijs Lavrijsen
d9eafb77f8
Use EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL if available 2023-10-12 09:01:55 +02:00
Matthijs Lavrijsen
1eeb31ac49
Loader: report POST codes when booting 2023-10-12 03:10:56 +02:00
Matthijs Lavrijsen
9fed1455eb
Update README.md 2023-10-10 22:41:22 +02:00
Matthijs Lavrijsen
375b677e4f
GitHub: add code of conduct, issue templates 2023-10-04 23:14:44 +02:00
Matthijs Lavrijsen
26406e2c93
Fix KiVerifyScopesExecute signature for LA57 kernel
ntkrla57.exe uses AND with r/m32 here rather than r/m64, which the signature was needlessly specific about by including a REX prefix
2023-10-03 18:33:01 +02:00
Matthijs Lavrijsen
5195ae9ab7
Add updated decode search for OslFwpKernelSetupPhase1 2023-10-03 07:05:53 +02:00
Matthijs Lavrijsen
b94b82d6cf
KiSwInterrupt patch: change the PG context address instead if possible
Reference: #101
2023-10-01 23:10:41 +02:00
Matthijs Lavrijsen
0e62d5af80
Disable CET when clearing CR0.WP 2023-09-27 04:37:46 +02:00
Matthijs Lavrijsen
9aff3669c6
EfiGuardDxe: delay driver unload when a non-Windows OS is booted
Fixes #91
2023-09-26 06:29:01 +02:00
Matthijs Lavrijsen
bb77cca1a7
Loader: continue booting if the driver is already loaded 2023-09-25 21:17:57 +02:00
Matthijs Lavrijsen
41b17319e8
EfiDSEFix: acquire SE_DEBUG_PRIVILEGE when finding kernel addresses
Fixes #97
2023-07-31 03:54:46 +02:00
Matthijs Lavrijsen
3779ef2496
Fix build with current EDK2 master
Rename RUNTIME_FUNCTION to resolve a conflict with edk2's incomplete redefinition added in ff52068d92
2023-06-22 20:10:59 +02:00
Matthijs Lavrijsen
edd474d5ff
Update README.md 2023-06-21 05:40:31 +02:00
Matthijs Lavrijsen
2233c19374
EfiDSEFix: print help text on invalid usage 2023-05-31 18:19:16 +02:00
Matthijs Lavrijsen
fe90876989
Handle 5-level paging when checking canonical address bits 2023-04-26 05:18:56 +02:00
Matthijs Lavrijsen
616f587d55
EfiGuardDxe: distinguish between winload and kernel build numbers 2023-04-03 01:21:37 +02:00
Matthijs Lavrijsen
383aea8793
Clean up linker options 2023-03-26 20:50:13 +02:00
Matthijs Lavrijsen
8b673b91c6
RtlSleep: wait for a timer event instead of stalling 2023-03-26 20:07:41 +02:00
Matthijs Lavrijsen
e588a7d948
Loader: check entry descriptions to determine whether they are Windows 2023-03-26 19:10:14 +02:00
Matthijs Lavrijsen
9c35789cf8
Loader: remove BdsLibConnectAllDriversToAllControllers
EfiBootManagerConnectAll provides this functionality now.
2023-03-26 18:04:41 +02:00
Matthijs Lavrijsen
3e9c9868b0
Loader: minor SetHighestAvailableMode improvements
- Add primitive aspect ratio weighting when determining which text mode is best
- Move all uses of gST->ConOut to SetHighestAvailableTextMode and exit early if it is NULL
2023-03-26 18:04:00 +02:00
Matthijs Lavrijsen
83bb58f2f4
Loader: handle EFI_SECURITY_VIOLATION from LoadImage
This behaviour matches that of edk2's UefiBootManagerLib since edk2 commit f7fdd620e8
2023-03-26 16:36:44 +02:00
Matthijs Lavrijsen
82b91beedf
EfiGuardDxe: clear and restore CR0.WP when copying
This is intended to deal with the UEFI memory protection protocol (EFI_MEMORY_ATTRIBUTE_PROTOCOL) introduced in the UEFI 2.10 specification.
2023-03-26 15:22:09 +02:00
Matthijs Lavrijsen
4465715c2c
Add CopyWpMem and SetWpMem routines
Additionally make SetServicePointer also clear and restore CR0.WP if needed
2023-03-26 15:11:22 +02:00