Skip to content

Commit

Permalink
Fix assumption that ebx is caller-saved
Browse files Browse the repository at this point in the history
"ebx" cannot be used without first pushing its value to the stack and
restoring it later, so just push the old value of "dest" to the stack
before "lock cmpxchg" and pop it into "eax" before returning.
  • Loading branch information
friendlyanon committed May 1, 2024
1 parent 3a96083 commit 7a14ce3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wrappers/kernel32.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ __declspec(naked) LONG WINAPI CORKEL32_InterlockedCompareExchange(LONG* dest, LO
mov edx, DWORD PTR [esp + 4] ; dest
mov ecx, DWORD PTR [esp + 8] ; exchange
mov eax, DWORD PTR [esp + 12] ; compare
mov ebx, DWORD PTR [edx]
push DWORD PTR [edx]
lock cmpxchg DWORD PTR [edx], ecx
mov eax, ebx
pop eax
ret 12

ICE_is_386:
Expand Down

0 comments on commit 7a14ce3

Please sign in to comment.