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

Read memory issue #681

Open
mgp25 opened this issue Sep 26, 2024 · 0 comments
Open

Read memory issue #681

mgp25 opened this issue Sep 26, 2024 · 0 comments

Comments

@mgp25
Copy link

mgp25 commented Sep 26, 2024

Hello,

While making some tests, I started facing some issues, some of them were resolved, however there is one that I am unable to solve.

At first I was getting this:

[09:01:02 753]  WARN [com.github.unidbg.arm.AbstractARMEmulator] (AbstractARMEmulator$1:67) - Write memory failed: address=0xe4000008, size=4, value=0x122691e0, PC=RX@0x1208bac8[library.so]0x8bac8, LR=RX@0x120815e0[library.so]0x815e0
54 [main] WARN com.github.unidbg.arm.AbstractARMEmulator  - Write memory failed: address=0xe4000008, size=4, value=0x122691e0, PC=RX@0x1208bac8[library.so]0x8bac8, LR=RX@0x120815e0[library.so]0x815e0
[09:01:02 754]  WARN [com.github.unidbg.AbstractEmulator] (AbstractEmulator:417) - emulate RX@0x12078770[library.so]0x78770 exception sp=unidbg@0xe4ffeda0, msg=unicorn.UnicornException: Invalid memory write (UC_ERR_WRITE_UNMAPPED), offset=137ms @ Runnable|Function32 address=0x12078770, arguments=[unidbg@0xfffe12a0, -639021477, 1059063940, 1295226194, 252651381, 1514840818, 1704064279]
55 [main] WARN com.github.unidbg.AbstractEmulator  - emulate RX@0x12078770[library.so]0x78770 exception sp=unidbg@0xe4ffeda0, msg=unicorn.UnicornException: Invalid memory write (UC_ERR_WRITE_UNMAPPED), offset=137ms @ Runnable|Function32 address=0x12078770, arguments=[unidbg@0xfffe12a0, -639021477, 1059063940, 1295226194, 252651381, 1514840818, 1704064279]

it was solved by mapping the memory on that memory range:

Backend backend = emulator.getBackend();
backend.mem_map(0xe4000000L, 0x1000, UnicornConst.UC_PROT_READ | UnicornConst.UC_PROT_WRITE);

After that, code started to work again until reaching a similar issue:

[09:05:16 332]  WARN [com.github.unidbg.arm.AbstractARMEmulator] (AbstractARMEmulator$1:67) - Read memory failed: address=0xff000000, size=4, value=0x0, PC=RX@0x12081510[library.so]0x81510, LR=RX@0x1207ad00[library.so]0x7ad00
119 [main] WARN com.github.unidbg.arm.AbstractARMEmulator  - Read memory failed: address=0xff000000, size=4, value=0x0, PC=RX@0x12081510[library.so]0x81510, LR=RX@0x1207ad00[library.so]0x7ad00
[09:05:16 333]  WARN [com.github.unidbg.AbstractEmulator] (AbstractEmulator:417) - emulate RX@0x12078770[library.so]0x78770 exception sp=unidbg@0xe4ffefb8, msg=unicorn.UnicornException: Invalid memory read (UC_ERR_READ_UNMAPPED), offset=199ms @ Runnable|Function32 address=0x12078770, arguments=[unidbg@0xfffe12a0, -639021477, 1059063940, 1295226194, 252651381, 1514840818, 1704064279]
120 [main] WARN com.github.unidbg.AbstractEmulator  - emulate RX@0x12078770[library.so]0x78770 exception sp=unidbg@0xe4ffefb8, msg=unicorn.UnicornException: Invalid memory read (UC_ERR_READ_UNMAPPED), offset=199ms @ Runnable|Function32 address=0x12078770, arguments=[unidbg@0xfffe12a0, -639021477, 1059063940, 1295226194, 252651381, 1514840818, 1704064279]

Which was resolved in a similar way:

backend.mem_map(0xff000000L, 0x4000, UnicornConst.UC_PROT_READ | UnicornConst.UC_PROT_WRITE);

And code started to work again but here is where comes the issue, it started to give:

[15:49:26 871]  WARN [com.github.unidbg.arm.AbstractARMEmulator] (AbstractARMEmulator$1:67) - Read memory failed: address=0x2a4, size=4, value=0x0, PC=RX@0x12081510[library.so]0x81510, LR=RX@0x1207ad00[library.so]0x7ad00
118 [main] WARN com.github.unidbg.arm.AbstractARMEmulator  - Read memory failed: address=0x2a4, size=4, value=0x0, PC=RX@0x12081510[library.so]0x81510, LR=RX@0x1207ad00[library.so]0x7ad00
[15:49:26 871]  WARN [com.github.unidbg.AbstractEmulator] (AbstractEmulator:417) - emulate RX@0x12078770[library.so]0x78770 exception sp=unidbg@0xe4ffefb8, msg=unicorn.UnicornException: Invalid memory read (UC_ERR_READ_UNMAPPED), offset=206ms @ Runnable|Function32 address=0x12078770, arguments=[unidbg@0xfffe12a0, -639021477, 1059063940, 1295226194, 252651381, 1514840818, 1704064279]
118 [main] WARN com.github.unidbg.AbstractEmulator  - emulate RX@0x12078770[library.so]0x78770 exception sp=unidbg@0xe4ffefb8, msg=unicorn.UnicornException: Invalid memory read (UC_ERR_READ_UNMAPPED), offset=206ms @ Runnable|Function32 address=0x12078770, arguments=[unidbg@0xfffe12a0, -639021477, 1059063940, 1295226194, 252651381, 1514840818, 1704064279]

As far as I know 0x2a4 should be mapped to:

impl.setPointer(0x2a4, _GetStringUTFChars);

Any idea on how to solve this?

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant