Let compiler handle ABI

This commit is contained in:
kotori0 2021-01-04 18:40:34 +08:00
parent 60a1e52f10
commit ebe9f19dae
No known key found for this signature in database
GPG Key ID: 3FEE57ED0385A6B2
1 changed files with 4 additions and 20 deletions

View File

@ -6,29 +6,13 @@
namespace art { namespace art {
class Thread : public edxp::HookedObject { class Thread : public edxp::HookedObject {
struct ObjPtr { void *data; ObjPtr(ObjPtr const &) = delete; } ;
#ifdef __i386__ CREATE_FUNC_SYMBOL_ENTRY(ObjPtr, DecodeJObject, void *thiz, jobject obj) {
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) if (DecodeJObjectSym)
return DecodeJObjectSym(thiz, obj); return DecodeJObjectSym(thiz, obj);
else else
return nullptr; return ObjPtr{nullptr};
} }
#endif
public: public:
Thread(void *thiz) : HookedObject(thiz) {} Thread(void *thiz) : HookedObject(thiz) {}
@ -40,7 +24,7 @@ namespace art {
void *DecodeJObject(jobject obj) { void *DecodeJObject(jobject obj) {
if (thiz_ && DecodeJObjectSym) { if (thiz_ && DecodeJObjectSym) {
return DecodeJObject(thiz_, obj); return DecodeJObject(thiz_, obj).data;
} }
return nullptr; return nullptr;
} }