Comments (12)
To be honest, I don't know yet. It started happening after #7 (comment).
You can try to change the load_library
calls to include do_init=False
to fix some of the issues (most important on the libc one).
It's something libc memory related.
from androidnativeemu.
setting do_init=False actually worked... kinda, but the example of douyin still does not:
2019-08-24 08:15:19,239 WARNING androidemu.java.java_class_def | Register native ('jni', '(II)V') failed on class XGorgen.
2019-08-24 08:15:19,239 WARNING androidemu.java.java_class_def | Register native ('jns', '(ILjava/lang/String;)V') failed on class XGorgen.
2019-08-24 08:15:19,239 WARNING androidemu.java.java_class_def | Register native ('rb', '(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)[B') failed on class XGorgen.
2019-08-24 08:15:19,239 WARNING androidemu.java.java_class_def | Register native ('e', '([B)[B') failed on class XGorgen.
2019-08-24 08:15:19,239 WARNING androidemu.java.java_class_def | Register native ('d', '([B)[B') failed on class XGorgen.
2019-08-24 08:15:19,240 WARNING androidemu.java.java_class_def | Register native ('ws', '(I)V') failed on class XGorgen.
2019-08-24 08:15:19,240 DEBUG androidemu.java.java_class_def | Registered native function ('leviathan', '(I[B)[B') to XGorgen.leviathan
2019-08-24 08:15:19,243 DEBUG androidemu.java.jni_env | JNIEnv->FindClass(com/ss/sys/secuni/b/c) was called
2019-08-24 08:15:19,244 DEBUG androidemu.java.jni_env | JNIEnv->ExceptionCheck() was called
2019-08-24 08:15:19,244 DEBUG androidemu.java.jni_env | JNIEnv->RegisterNatives(2, 0x000ffb88, 2) was called
2019-08-24 08:15:19,244 DEBUG androidemu.java.java_class_def | Registered native function ('n1', '(Landroid/content/Context;Ljava/lang/String;)I') to secuni_b.n1
2019-08-24 08:15:19,245 DEBUG androidemu.java.java_class_def | Registered native function ('n0', '(Landroid/content/Context;)[B') to secuni_b.n0
2019-08-24 08:15:19,245 DEBUG androidemu.java.jni_env | JNIEnv->DeleteLocalRef(2) was called
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 232, in 'calling callback function'
File "/home/daniel/.local/lib/python3.7/site-packages/unicorn/unicorn.py", line 438, in _hookcode_cb
cb(self, address, size, data)
File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/hooker.py", line 97, in _hook
hook_func(self._emu)
File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/java/helpers/native_method.py", line 110, in native_method_wrapper
result = func(argv[0], mu, *native_args)
File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/java/jni_env.py", line 350, in find_class
name = memory_helpers.read_utf8(mu, name_ptr)
File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/utils/memory_helpers.py", line 29, in read_utf8
return buffer[:null_pos].decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc2 in position 38: invalid continuation byte
2019-08-24 08:15:19,252 DEBUG samples.debug_utils | mem unmapped: pc: cbd0d456 access: 13 address: fffffff4 length: 4 value: 0
Traceback (most recent call last):
File "example_douyin.py", line 156, in <module>
print(''.join(['%02x' % b for b in result]))
TypeError: 'NoneType' object is not iterable
from androidnativeemu.
@P4nda0s Same on your branch. any idea?
from androidnativeemu.
you guys have no idea either?
Also, are these outputs normal or is something not loading right:
2019-08-30 17:55:18,548 ERROR androidemu.internal.modules | => Undefined external symbol: __cxa_finalize
2019-08-30 17:55:18,548 ERROR androidemu.internal.modules | => Undefined external symbol: __cxa_atexit
2019-08-30 17:55:18,548 ERROR androidemu.internal.modules | => Undefined external symbol: __register_atfork
2019-08-30 17:55:18,549 ERROR androidemu.internal.modules | => Undefined external symbol: abort
2019-08-30 17:55:18,549 ERROR androidemu.internal.modules | => Undefined external symbol: memcpy
2019-08-30 17:55:19,704 WARNING androidemu.java.java_class_def | Register native ('jni', '(II)V') failed on class XGorgen.
2019-08-30 17:55:19,704 WARNING androidemu.java.java_class_def | Register native ('jns', '(ILjava/lang/String;)V') failed on class XGorgen.
2019-08-30 17:55:19,704 WARNING androidemu.java.java_class_def | Register native ('rb', '(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)[B') failed on class XGorgen.
2019-08-30 17:55:19,704 WARNING androidemu.java.java_class_def | Register native ('e', '([B)[B') failed on class XGorgen.
2019-08-30 17:55:19,704 WARNING androidemu.java.java_class_def | Register native ('d', '([B)[B') failed on class XGorgen.
2019-08-30 17:55:19,704 WARNING androidemu.java.java_class_def | Register native ('ws', '(I)V') failed on class XGorgen.
from androidnativeemu.
Yes they are "normal".
from androidnativeemu.
I think i found something out, but i am not sure WHY this is even happening, or WHY this is even called.
In memory_helper.py the read_utf8 function seems to error out because of a invalid UTF-8 on .encode("UTF-8") so nothing is returned from there. if i change it to .encode("UTF-8", "ignore"), it then tries to find a class with that return value, and of course errors out again:
019-09-01 11:28:53,987 DEBUG androidemu.java.jni_env | JNIEnv->FindClass(YUWII[T^HUS^YUWWUT[JJVU]oI_HsT\U:٫gAJ]JGJELx_YBELb+�{~XSDS^S\UaF@[\U i~XSDS^S\UaF@[\U XSDS^S\UaF@[\U 2ݼڙڦήڙڦιڙڦܹڙڦ-/>�+)!+-/Jlj
�/'
mD㉈%vەݕ݁GETt 잇OM\nADM(]Gf4֢0 dxP+& }*1<3m]kzf>Nݟ) was called
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 232, in 'calling callback function'
File "/usr/local/lib/python3.7/dist-packages/unicorn/unicorn.py", line 438, in _hookcode_cb
cb(self, address, size, data)
File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/hooker.py", line 97, in _hook
hook_func(self._emu)
File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/java/helpers/native_method.py", line 110, in native_method_wrapper
result = func(argv[0], mu, *native_args)
File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/java/jni_env.py", line 360, in find_class
raise RuntimeError('Could not find class \'%s\' for JNIEnv.' % name)
RuntimeError: Could not find class 'YUWII[T^HUS^YUWWUT[JJVU]oI_HsT\U:٫gAJ]JGJELx_YBELb+�{~XSDS^S\UaF@[\U i~XSDS^S\UaF@[\U XSDS^S\UaF@[\U 2ݼڙڦήڙڦιڙڦܹڙڦ-/>�+)!+-/Jlj
�/'
mD㉈%vەݕ݁GETt 잇OM\nADM(]Gf4֢0 dxP+& }*1<3m]kzf>Nݟ' for JNIEnv.
2019-09-01 11:28:54,024 DEBUG samples.debug_utils | mem unmapped: pc: cbd0d456 access: 13 address: fffffff4 length: 4 value: 0
what i do not get is WHY is it trying to find a class with that name though
from androidnativeemu.
Yes they are "normal".
Are they "normal" ?
2019-09-05 14:42:57,131 DEBUG androidemu.cpu.syscall_handlers | Executing syscall getpid() at 0xcbc1ab14
2019-09-05 14:42:57,131 DEBUG androidemu.cpu.syscall_handlers | Executing syscall null1() at 0xcbbea10c
2019-09-05 14:42:57,132 DEBUG androidemu.cpu.syscall_handlers | Executing syscall writev(00000002, 000ffb34, 00000002) at 0xcbc1afa0
2019-09-05 14:42:57,132 DEBUG androidemu.cpu.syscall_handlers | Executing syscall socket(00000001, 00080802, 00000000) at 0xcbc1ae70
2019-09-05 14:42:57,133 DEBUG androidemu.cpu.syscall_handlers | Executing syscall connect(00000000, 000ffa90, 0000006e) at 0xcbc1aa0c
00000000: 01 00 2F 64 65 76 2F 73 6F 63 6B 65 74 2F 6C 6F ../dev/socket/lo
00000010: 67 64 77 00 00 00 00 00 00 00 00 00 00 00 00 00 gdw.............
00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ..............
None
2019-09-05 14:42:57,141 ERROR androidemu.cpu.syscall_handlers | An error occured during in 11b syscall hander, stopping emulation
getentropy failed
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 232, in 'calling callback function'
File "C:\Users\tingxinluan\AppData\Local\Programs\Python\Python37\lib\site-packages\unicorn\unicorn.py", line 453, in _hook_intr_cb
cb(self, intno, data)
File "F:\code\AndroidNativeEmu-master_another\AndroidNativeEmu-master\androidemu\cpu\interrupt_handler.py", line 21, in _hook_interrupt
self._handlers[intno](uc)
File "F:\code\AndroidNativeEmu-master_another\AndroidNativeEmu-master\androidemu\cpu\syscall_handlers.py", line 37, in _handle_syscall
result = handler.callback(mu, *args)
File "F:\code\AndroidNativeEmu-master_another\AndroidNativeEmu-master\androidemu\cpu\syscall_hooks.py", line 150, in _connect
raise NotImplementedError()
NotImplementedError
2019-09-05 14:42:57,151 DEBUG androidemu.emulator | Calling Init function: cbc0278d
2019-09-05 14:42:57,154 DEBUG androidemu.emulator | Calling Init function: cbc3f381
2019-09-05 14:42:57,155 DEBUG androidemu.cpu.syscall_handlers | Executing syscall openat(ffffff9c, cbc42384, 00020000, 00000000) at 0xcbc1abe4
2019-09-05 14:42:57,158 WARNING androidemu.vfs.file_system | File does not exist '/proc/sys/vm/overcommit_memory'
2019-09-05 14:42:57,162 DEBUG androidemu.cpu.syscall_handlers | Executing syscall mmap2(00000000, 00080000, 00000003, 00000022, ffffffff, 00000000) at 0xcbc1abc4
2019-09-05 14:42:57,162 DEBUG androidemu.cpu.syscall_handlers | Executing syscall madvise(02000000, 00080000, 0000000c) at 0xcbc1b78c
2019-09-05 14:42:57,163 DEBUG androidemu.cpu.syscall_handlers | Executing syscall prctl(53564d41, 00000000, 02000000, 00080000, cbc42068) at 0xcbc1b97c
2019-09-05 14:42:57,166 DEBUG androidemu.cpu.syscall_handlers | Executing syscall clock_gettime(00000006, 000fe95c) at 0xcbc1a9ec
2019-09-05 14:42:57,168 DEBUG androidemu.cpu.syscall_handlers | Executing syscall openat(ffffff9c, cbbf31b4, 000a0000, 00000000) at 0xcbc1abe4
2019-09-05 14:42:57,171 WARNING androidemu.vfs.file_system | File does not exist '/sys/devices/system/cpu/online'
2019-09-05 14:42:57,173 DEBUG androidemu.cpu.syscall_handlers | Executing syscall mmap2(00000000, 00080000, 00000000, 00000022, ffffffff, 00000000) at 0xcbc1abc4
2019-09-05 14:42:57,174 DEBUG androidemu.cpu.syscall_handlers | Executing syscall madvise(02080000, 00080000, 0000000c) at 0xcbc1b78c
2019-09-05 14:42:57,174 DEBUG androidemu.cpu.syscall_handlers | Executing syscall prctl(53564d41, 00000000, 02080000, 00080000, cbc42068) at 0xcbc1b97c
2019-09-05 14:42:57,178 DEBUG androidemu.cpu.syscall_handlers | Executing syscall mmap2(02080000, 00003000, 00000003, 00000032, ffffffff, 00000000) at 0xcbc1abc4
2019-09-05 14:42:57,179 DEBUG androidemu.cpu.syscall_handlers | Executing syscall madvise(02100000, 00003000, 0000000c) at 0xcbc1b78c
2019-09-05 14:42:57,179 DEBUG androidemu.cpu.syscall_handlers | Executing syscall munmap(02100000, 00003000) at 0xcbc1b8f4
2019-09-05 14:42:57,181 DEBUG androidemu.cpu.syscall_handlers | Executing syscall mmap2(02080000, 00080000, 00000003, 00000032, ffffffff, 00000000) at 0xcbc1abc4
2019-09-05 14:42:57,181 DEBUG androidemu.cpu.syscall_handlers | Executing syscall madvise(02100000, 00080000, 0000000c) at 0xcbc1b78c
2019-09-05 14:42:57,181 DEBUG androidemu.cpu.syscall_handlers | Executing syscall munmap(02100000, 00080000) at 0xcbc1b8f4
2019-09-05 14:42:57,182 DEBUG androidemu.cpu.syscall_handlers | Executing syscall mmap2(00000000, 00080000, 00000000, 00000022, ffffffff, 00000000) at 0xcbc1abc4
2019-09-05 14:42:57,183 DEBUG androidemu.cpu.syscall_handlers | Executing syscall madvise(02100000, 00080000, 0000000c) at 0xcbc1b78c
2019-09-05 14:42:57,189 DEBUG androidemu.cpu.syscall_handlers | Executing syscall prctl(53564d41, 00000000, 02100000, 00080000, cbc42068) at 0xcbc1b97c
2019-09-05 14:42:57,189 DEBUG androidemu.cpu.syscall_handlers | Executing syscall mmap2(02100000, 00003000, 00000003, 00000032, ffffffff, 00000000) at 0xcbc1abc4
2019-09-05 14:42:57,190 DEBUG androidemu.cpu.syscall_handlers | Executing syscall madvise(02180000, 00003000, 0000000c) at 0xcbc1b78c
2019-09-05 14:42:57,190 DEBUG androidemu.cpu.syscall_handlers | Executing syscall munmap(02180000, 00003000) at 0xcbc1b8f4
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 232, in 'calling callback function'
File "C:\Users\tingxinluan\AppData\Local\Programs\Python\Python37\lib\site-packages\unicorn\unicorn.py", line 453, in _hook_intr_cb
cb(self, intno, data)
File "F:\code\AndroidNativeEmu-master_another\AndroidNativeEmu-master\androidemu\cpu\interrupt_handler.py", line 21, in _hook_interrupt
self._handlers[intno](uc)
File "F:\code\AndroidNativeEmu-master_another\AndroidNativeEmu-master\androidemu\cpu\syscall_handlers.py", line 50, in _handle_syscall
raise RuntimeError(error)
RuntimeError: Unhandled syscall 0x4 (4) at 0xcbc1c2ec, stopping emulation
2019-09-05 14:42:57,199 DEBUG androidemu.internal.modules | Loading module 'samples/example_binaries/libstdc++.so'.
2019-09-05 14:42:57,200 DEBUG androidemu.internal.memory | => Mapping memory page 0xcbc6c000 - 0xcbc70000, size 0x00004000, prot 5
2019-09-05 14:42:57,200 DEBUG androidemu.internal.memory | => Mapping memory page 0xcbc70000 - 0xcbc72000, size 0x00002000, prot 3
2019-09-05 14:42:57,207 DEBUG androidemu.emulator | Calling Init for: samples/example_binaries/libstdc++.so
from androidnativeemu.
@bwmaples ur missing files, causing it to run into an unexpected syscall.
from androidnativeemu.
I think i found something out, but i am not sure WHY this is even happening, or WHY this is even called.
In memory_helper.py the read_utf8 function seems to error out because of a invalid UTF-8 on .encode("UTF-8") so nothing is returned from there. if i change it to .encode("UTF-8", "ignore"), it then tries to find a class with that return value, and of course errors out again:
019-09-01 11:28:53,987 DEBUG androidemu.java.jni_env | JNIEnv->FindClass(YUWII[T^HUS^YUWWUT[JJVU]oI_HsT\U:٫gAJ]JGJELx_YBELb+�{~XSDS^S\UaF@[\U i~XSDS^S\UaF@[\U XSDS^S\UaF@[\U 2ݼڙڦήڙڦιڙڦܹڙڦ-/>�+)!+-/Jlj �/' mD㉈%vەݕ݁GETt 잇OM\nADM(]Gf4֢0 dxP+& }*1<3m]kzf>Nݟ) was called Traceback (most recent call last): File "_ctypes/callbacks.c", line 232, in 'calling callback function' File "/usr/local/lib/python3.7/dist-packages/unicorn/unicorn.py", line 438, in _hookcode_cb cb(self, address, size, data) File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/hooker.py", line 97, in _hook hook_func(self._emu) File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/java/helpers/native_method.py", line 110, in native_method_wrapper result = func(argv[0], mu, *native_args) File "/home/daniel/Downloads/AndroidNativeEmu-master/androidemu/java/jni_env.py", line 360, in find_class raise RuntimeError('Could not find class \'%s\' for JNIEnv.' % name) RuntimeError: Could not find class 'YUWII[T^HUS^YUWWUT[JJVU]oI_HsT\U:٫gAJ]JGJELx_YBELb+�{~XSDS^S\UaF@[\U i~XSDS^S\UaF@[\U XSDS^S\UaF@[\U 2ݼڙڦήڙڦιڙڦܹڙڦ-/>�+)!+-/Jlj �/' mD㉈%vەݕ݁GETt 잇OM\nADM(]Gf4֢0 dxP+& }*1<3m]kzf>Nݟ' for JNIEnv. 2019-09-01 11:28:54,024 DEBUG samples.debug_utils | mem unmapped: pc: cbd0d456 access: 13 address: fffffff4 length: 4 value: 0
what i do not get is WHY is it trying to find a class with that name though
you can look what i have done in the commits of my fork. https://github.com/MockyBang/AndroidNativeEmu/commits/master
do_init=True is necessary. what cause the Invalid memory write (UC_ERR_WRITE_UNMAPPED) error is the getrandom syscall. I don't know why. but it actually resolve the problem and I get the correct result.
from androidnativeemu.
@MockyBang Thanks, maybe the syscall 0x180 is something else?
from androidnativeemu.
@MockyBang Thanks, maybe the syscall 0x180 is something else?
syscall 0x180 is getrandom (goldfish/arch/arm/include/uapi/asm/unistd.h)
def _getrandom(self, mu, buf, buflen, flags):
ret = buflen-1
rand_bytes = urandom(ret)
print('....random...' , rand_bytes, ret)
mu.mem_write(buf, rand_bytes)
return ret
That is OK
Maybe because memory out of bounds
from androidnativeemu.
@yusitek why are you returning buflen - 1
? Shouldn't it return the amount of random bytes written to buf
?
from androidnativeemu.
Related Issues (20)
- didn't get any response from douyin levithan function HOT 3
- Do you know how to deal with the return value in the parameter? HOT 3
- Bug with Java ClassFieldDef translated to class 'type' HOT 4
- NotImplementedError: Symbol hook not implemented pthread_create
- Can you help me solve a problem,i can pay.
- Probably find a way to implement JNI methods with unknown args length
- Need help with calling JNIEnv not JavaVM
- so方法种调用java层的参数提示:Could not find field,请问如何定义这个调用参数? HOT 1
- The launch of aarch64 HOT 2
- 关于寻找字段和内部类的处理?
- Error in get_object_array_element HOT 1
- The return value of the emulator.call_symbol function is NONE, and the incoming parameters have no output in the console
- malloc bug Invalid instruction (UC_ERR_INSN_INVALID)
- 请问context参数应该怎么导入?
- AttributeError: 'Emulator' object has no attribute 'uc' HOT 2
- Add Example for native function with context parameter
- Please update package in pypi
- Cannot relocate large libraries HOT 1
- unicorn.unicorn.UcError: Invalid instruction (UC_ERR_INSN_INVALID)
- get_superclass 有一个错误,会导致register_natives 中获取的clazz_id不正确
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidnativeemu.