Created
March 3, 2025 18:46
-
-
Save ZeroSkill1/e27cac7a16d75647b2ad42ab9eb74b54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
def ipc_getcmdid(hdr: int) -> int: | |
return ((hdr & ~0xFFFF) >> 16) | |
def ipc_get_normal_args_count(hdr: int) -> int: | |
return ((hdr >> 6) & 0x3F) | |
def ipc_get_translate_args_count(hdr: int) -> int: | |
return hdr & 0xF | |
if len(sys.argv) != 2: | |
exit('bad args') | |
try: | |
hdr = int(sys.argv[1]) | |
except Exception as e: | |
try: | |
hdr = int(sys.argv[1], 16) | |
except Exception as f: | |
exit('bad args') | |
if hdr > (1 << 31) or hdr < -(1 << 31): | |
exit('int out of range') | |
cmdid = ipc_getcmdid(hdr) | |
normal = ipc_get_normal_args_count(hdr) | |
translate = ipc_get_translate_args_count(hdr) | |
print(f"0x{hdr:08X} == IPC_MakeHeader(({cmdid} or 0x{cmdid:x}), {normal}, {translate})") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment