Commit e4af8592 authored by swift_gan's avatar swift_gan

fix C++

parent af878e60
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <jni.h>
#include "arch.h" #include "arch.h"
#include "utils.h" #include "utils.h"
...@@ -74,10 +75,11 @@ namespace SandHook { ...@@ -74,10 +75,11 @@ namespace SandHook {
}; };
template<typename PType> template<typename PType>
class ArrayMember : IMember<PType, void*> { class ArrayMember : public IMember<PType, void*> {
public: public:
virtual void init(JNIEnv *jniEnv, PType p, Size parentSize) override : IMember::init(jniEnv, p, parentSize) { virtual void init(JNIEnv *jniEnv, PType p, Size parentSize) override {
IMember<PType,void*>::init(jniEnv, p, parentSize);
elementSize = calElementSize(jniEnv, p); elementSize = calElementSize(jniEnv, p);
} }
...@@ -85,17 +87,15 @@ namespace SandHook { ...@@ -85,17 +87,15 @@ namespace SandHook {
return elementSize; return elementSize;
} }
virtual void* arrayStart(PType parent) { virtual Size arrayStart(PType parent) {
return get(parent); return reinterpret_cast<Size>(IMember<PType,void*>::get(parent));
} }
Size getParentSize() : IMember::getParentSize() = default; using IMember<PType,void*>::getParentSize;
public:
virtual void setElement(PType parent, int position, void* elementPoint) { virtual void setElement(PType parent, int position, void* elementPoint) {
void* array = arrayStart(parent); Size array = arrayStart(parent);
memcpy(array + position * getElementSize(), elementPoint, getElementSize()); memcpy(reinterpret_cast<void*>(array + position * getElementSize()), elementPoint, getElementSize());
} }
private: private:
......
//
// Created by SwiftGan on 2019/1/17.
//
#ifndef SANDHOOK_BASE_H
#define SANDHOOK_BASE_H
#define FUNCTION_START(x) .global x; x:
#define FUNCTION_END(x) . - x
#endif //SANDHOOK_BASE_H
//
// Created by SwiftGan on 2019/1/17.
//
#ifndef SANDHOOK_TRAMPOLINE_H
#define SANDHOOK_TRAMPOLINE_H
#endif //SANDHOOK_TRAMPOLINE_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment