Skip to content

Commit

Permalink
Let compiler handle ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
kotori2 committed Jan 4, 2021
1 parent 60a1e52 commit ebe9f19
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions edxp-core/src/main/cpp/main/include/art/runtime/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,13 @@
namespace art {

class Thread : public edxp::HookedObject {

#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) {
struct ObjPtr { void *data; ObjPtr(ObjPtr const &) = delete; } ;
CREATE_FUNC_SYMBOL_ENTRY(ObjPtr, DecodeJObject, void *thiz, jobject obj) {
if (DecodeJObjectSym)
return DecodeJObjectSym(thiz, obj);
else
return nullptr;
return ObjPtr{nullptr};
}
#endif

public:
Thread(void *thiz) : HookedObject(thiz) {}
Expand All @@ -40,7 +24,7 @@ namespace art {

void *DecodeJObject(jobject obj) {
if (thiz_ && DecodeJObjectSym) {
return DecodeJObject(thiz_, obj);
return DecodeJObject(thiz_, obj).data;
}
return nullptr;
}
Expand Down

0 comments on commit ebe9f19

Please sign in to comment.