Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Fix other cases that cause hangs with certain transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
PieKing1215 committed Sep 12, 2024
1 parent be38498 commit 85e2b84
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/tweaks/transform_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,21 @@ fn is_orthonormal(matrix: &[i32; 9]) -> bool {
#[no_mangle]
extern "stdcall" fn safety_check() {
unsafe {
// safety check that EAX is at least 1
// safety check that increments are at least 1
// EDX is overwritten immediately after so safe to use for work
asm!(
// if [RSP + 0x78] == 0 { [RSP + 0x78] = 1 }
"MOV EAX,[RSP + 0x8 + 0x78]",
"TEST EAX,EAX",
"MOV EDX,1",
"CMOVZ EAX,EDX",
"MOV [RSP + 0x8 + 0x78],EAX",
// if [RBP + -0x68] == 0 { [RBP + -0x68] = 1 }
"MOV EAX,[RBP + -0x68]",
"TEST EAX,EAX",
"MOV EDX,1",
"CMOVZ EAX,EDX",
"MOV [RBP + -0x68],EAX",
// original
"ADD EAX,R14D",
"MOV ECX,dword ptr [RBP + 0x18]",
Expand All @@ -361,7 +374,7 @@ extern "stdcall" fn safety_check() {
"SUB EAX,EDX",
// if eax == 0 { eax = 1; }
"TEST EAX,EAX",
"MOV EDX,1", // edx is overwritten immediately after so safe to use
"MOV EDX,1",
"CMOVZ EAX,EDX",
options(nostack),
);
Expand Down

0 comments on commit 85e2b84

Please sign in to comment.