Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep x86 and x86_64 FLAGS Register when calls to mprotect. #844

Merged
merged 1 commit into from
Jun 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -2729,11 +2729,13 @@ def mprotect_asm(cls, addr: int, size: int, perm: Permission) -> str:
_NR_mprotect = 125
insns = [
"pushad",
"pushfd",
f"mov eax, {_NR_mprotect:d}",
f"mov ebx, {addr:d}",
f"mov ecx, {size:d}",
f"mov edx, {perm.value:d}",
"int 0x80",
"popfd",
"popad",
]
return "; ".join(insns)
Expand Down Expand Up @@ -2770,6 +2772,7 @@ class X86_64(X86):
def mprotect_asm(cls, addr: int, size: int, perm: Permission) -> str:
_NR_mprotect = 10
insns = [
"pushfq",
"push rax",
"push rdi",
"push rsi",
Expand All @@ -2787,6 +2790,7 @@ def mprotect_asm(cls, addr: int, size: int, perm: Permission) -> str:
"pop rsi",
"pop rdi",
"pop rax",
"popfq",
]
return "; ".join(insns)

Expand Down