I'm patching an executable on OSX. So far I know the patches have been applied successfully.
Steps taken (via LLDB):
lldb /users/Brandon/Desktop/Test.app/Contents/MacOS/Test
b start
run
br del 1
memory write 0x0006cc9f 0xB8
memory write 0x0006cc9f 0x01
memory write 0x0006cc9f 0x00
memory write 0x0006cc9f 0x00
memory write 0x0006cc9f 0x00
process continue
Everything works fine. The above changes:
call testFunc
to mov eax, 1
. TestFunc is simple, it looks like:
bool testFunc()
{
return 0;
}
Now if I apply this patch via IDA-Pro/Hex-Rays, it does NOT run! I applied the patches via IDA-Pro and ran the executable but that function never seems to be executed.
However, if I take the same patched executable and I run:
memory read 0x0006cc9f
It prints: 0xB8, 0x01, 0x00, 0x00, 0x00
which is my patch! So the patch is applied.
Now if I run the same memory write
code in lldb on the already patched executable, and then process continue
the executable behaves correctly.
I suspect it's because it's some sort of memory protection. How can I re-protect my executable after patching it?