Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
WolverinDEV committed Oct 25, 2024
2 parents 354b1c8 + d923315 commit 205524c
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions driver-standalone/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"
7 changes: 7 additions & 0 deletions driver-standalone/src/panic_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ pub unsafe extern "C" fn __CxxFrameHandler3() {
KeBugCheck(BUGCHECK_CODE_CXX_FRAME);
}
}

#[no_mangle]
extern "C" fn __chkstk() {
use core::arch::asm;

// unsafe { asm!("int 3") };
}
1 change: 1 addition & 0 deletions driver-uefi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ lazy_link = "0.1.1"

[dependencies.compiler_builtins]
git = "https://github.com/rust-lang/compiler-builtins"
version = "0.1.132"
features = ["mem"]

[dependencies.winapi]
Expand Down
2 changes: 2 additions & 0 deletions driver-uefi/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly-2024-09-25"
7 changes: 7 additions & 0 deletions driver-uefi/src/panic_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ pub unsafe extern "C" fn __CxxFrameHandler3() {
KeBugCheck(BUGCHECK_CODE_CXX_FRAME);
}
}

#[no_mangle]
extern "C" fn __chkstk() {
use core::arch::asm;

// unsafe { asm!("int 3") };
}
22 changes: 16 additions & 6 deletions driver/src/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,22 @@ fn find_mouse_service_callback() -> anyhow::Result<MouseClassServiceCallbackFn>
let module_kdbclass = KModule::find_by_name(obfstr!("mouclass.sys"))?
.with_context(|| anyhow!("failed to locate {} module", obfstr!("mouclass.sys")))?;

[/* Windows 11 */ Signature::relative_address(
obfstr!("MouseClassServiceCallback"),
obfstr!("48 8D 05 ? ? ? ? 48 89 44"),
0x03,
0x07,
)]
// 48 8D 05 ? ? ? ? 48 89 44
[
Signature::relative_address(
obfstr!("MouseClassServiceCallback"),
obfstr!("48 8D 05 ? ? ? ? 48 89 44"),
0x03,
0x07,
),
/* Windows 11 */
Signature::relative_address(
obfstr!("MouseClassServiceCallback"),
obfstr!("48 8D 05 ? ? ? ? 48 89 44"),
0x03,
0x07,
),
]
.iter()
.find_map(|sig| NtOffsets::locate_signature(&module_kdbclass, sig).ok())
.map(|v| unsafe { core::mem::transmute_copy(&v) })
Expand Down
45 changes: 32 additions & 13 deletions driver/src/offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ pub fn initialize_nt_offsets() -> anyhow::Result<()> {

let ps_get_next_process = {
[
Signature::relative_address(
obfstr!("PsGetNextProcess (2600.1252)"),
obfstr!("E8 ? ? ? ? 48 8B D8 48 89 44 24 ? 48 85 C0 48"),
0x01,
0x05,
),
/* Windows 11 */
Signature::relative_address(
obfstr!("PsGetNextProcess (Win 11)"),
Expand All @@ -117,19 +123,26 @@ pub fn initialize_nt_offsets() -> anyhow::Result<()> {
};

let mm_verify_callback_function_flags = {
if let Ok(target) = find_mm_verify_callback_function_flags_new(&ntoskrnl) {
unsafe { core::mem::transmute_copy::<_, _>(&target) }
} else {
log::debug!("{}", obfstr!("Failed to resolve MmVerifyCallbackFunctionFlags by instruction pattern. Try old pattern."));
if let Ok(target) = find_mm_verify_callback_function_flags_old(&ntoskrnl) {
unsafe { core::mem::transmute_copy::<_, _>(&target) }
} else {
anyhow::bail!(
"{}",
obfstr!("Failed to resolve MmVerifyCallbackFunctionFlags")
)
}
}
[
Signature::relative_address(
obfstr!("MmVerifyCallbackFunctionFlags (2600.1252)"),
obfstr!("E8 ? ? ? ? 85 C0 74 6F 48 8B 4E"),
0x01,
0x05,
),
Signature::pattern(
obfstr!("MmVerifyCallbackFunctionFlags (Win 11)"),
obfstr!("48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 20 8B FA 48 8B F1"),
),
Signature::pattern(
obfstr!("MmVerifyCallbackFunctionFlags"),
obfstr!("E8 ?? ?? ?? ?? 85 C0 0F 84 ?? ?? ?? ?? 48 8B 4D 00"),
),
]
.iter()
.find_map(|sig| NtOffsets::locate_signature(&ntoskrnl, sig).ok())
.map(|v| unsafe { core::mem::transmute_copy(&v) })
.with_context(|| obfstr!("Failed to find MmVerifyCallbackFunctionFlags").to_string())?
};

log::debug!(
Expand All @@ -141,6 +154,12 @@ pub fn initialize_nt_offsets() -> anyhow::Result<()> {
);
let eprocess_thread_list_head = {
[
Signature::offset(
obfstr!("_EPROCESS.ThreadListHead (2600.1252)"),
obfstr!("4C 8D B1 ? ? ? ? 33 ED 45"),
0x03,
),

/* Windows 11 */
Signature::offset(
obfstr!("_EPROCESS.ThreadListHead (Win 11)"),
Expand Down

0 comments on commit 205524c

Please sign in to comment.