Fix DecodeJObject crash on x86 and close #783

This commit is contained in:
kotori0 2021-01-04 18:13:41 +08:00
parent 6bb00dfcc4
commit 60a1e52f10
No known key found for this signature in database
GPG Key ID: 3FEE57ED0385A6B2
1 changed files with 17 additions and 2 deletions

View File

@ -7,13 +7,28 @@ namespace art {
class Thread : public edxp::HookedObject {
CREATE_FUNC_SYMBOL_ENTRY(void *, DecodeJObject, void *thiz,
jobject obj) {
#ifdef __i386__
typedef void (*DecodeJObjectType)(void **, void *thiz, jobject obj);
inline static void (*DecodeJObjectSym)(void **, void *thiz, jobject obj);
static void *DecodeJObject(void *thiz, jobject obj) {
if (LIKELY(DecodeJObjectSym)) {
// Special call conversion
void *ret = nullptr;
DecodeJObjectSym(&ret, thiz, obj);
// Stack unbalanced since we faked return value as 1st param
__asm__("sub $0x4, %esp");
return ret;
} else
return nullptr;
}
#else
CREATE_FUNC_SYMBOL_ENTRY(void *, DecodeJObject, void *thiz, jobject obj) {
if (DecodeJObjectSym)
return DecodeJObjectSym(thiz, obj);
else
return nullptr;
}
#endif
public:
Thread(void *thiz) : HookedObject(thiz) {}