Tweak.xm hook unity method 內的變數。請教高手


#1

需求: hook unity app 內的變數
**代码:

  1. LL2CPP dump method
    public class BattleResultRequest : Request // TypeDefIndex: 3044
    {
    // Fields

    public int result; // 0xAC

    // Methods
    public static BattleResultRequest Create(int stage, int result, long[] assist, string an_info, string item_use, string df_info, int mission_result, int defeat_count, int smn_change, long max_damage); // 0x100121F94

}

  1. My tweak.xm
    %ctor{
    MSHookFunction(((void*)getRealOffset(0x100121F94)),(void )_BattleResultRequest_object, (void*)&BattleResultRequest_object);
    }
    uint64_t getRealOffset(uint64_t offset){
    return _dyld_get_image_vmaddr_slide(0)+offset;
    }
    uint64_t getRealOffset(uint64_t);

void (*BattleResultRequest_object)(void *_this);

void _BattleResultRequest_object(void *_this){
if (_this != NULL)
{
(int *)((uint64_t)_this+0xAC)=1;
NSLog(@"[dx2 tweak] — >>> _BattleResultRequest_object point = %p",_this);
BattleResultRequest_object(_this);
}

}

思維:(求助)

  1. 永遠傳1 (int result) 給 BattleResultRequest Create (0x100121F94)
  2. 變數 public int result; // 0xAC 永遠是1
  3. 我想列印BattleResultRequest的address. 可是這樣做不行。NSLog(@"[dx2 tweak] — >>> _BattleResultRequest_object point = %p",_this);
    請問正確寫法是什麼ㄋㄜ
    ** 环境: iOS 9.3

#2

是我的問題太基本了嗎? 真心求助


#3

没看懂这个问题


#4

@wangdu