Tutorial Hooking Tutorial/Template For Ted's Menu Template

·҉ dollaz·҉. .

Approved iModder
Original poster
Approved iModder
Mar 26, 2021
159
1,819
193
Somewhere
aight guys so this is my first post on dis account.
wanted to start off with something useful.

here are a bunch of templates for different function types plus a slider template.

float:
C++:
float(*old_@Function@)(void *_this);

float @Function@(void *_this){


if([switches isSwitchOn:@"@SwitchName@"]) {

//float must return a decimal so add a .0f after any number you wish to return

return 999999999.0f;

}

return old_@Function@(_this);
}


%ctor {

    MSHookFunction((void *)getRealOffset(@FunctionOffset@), (void *)@Function@, (void **)&old_@Function@);
}
int:
C++:
int(*old_@Function@)(void *_this);

int @Function@(void *_this){


if([switches isSwitchOn:@"@SwitchName@"]) {

return 999999999;

}

return old_@Function@(_this);
}


%ctor {

    MSHookFunction((void *)getRealOffset(@FunctionOffset@), (void *)@Function@, (void **)&old_@Function@);
}
bool:
C++:
bool(*old_@Function@)(void *_this);

bool @Function@(void *_this){


if([switches isSwitchOn:@"@SwitchName@"]) {

//make this true or false based on what you want it to do

return true;

}

return old_@Function@(_this);
}


%ctor {

    MSHookFunction((void *)getRealOffset(@FunctionOffset@), (void *)@Function@, (void **)&old_@Function@);
}
Slider Switch Hook:

C++:
@FunctionType@(*old_@Function@)(void *_this);

@FunctionType@ @Function@(void *_this){


if([switches isSwitchOn:@"@SwitchName@"]) {

return old_@Function@(_this) * [[switches getValueFromSwitch:@"@SwitchName@"] floatValue];

}

return old_@Function@(_this);
}


%ctor {

    MSHookFunction((void *)getRealOffset(@FunctionOffset@), (void *)@Function@, (void **)&old_@Function@);
}
Field:
C++:
/*use instance to prevent crashing, idk if you have that problem too

hook to the update, start or awake function, if you use start or awake it wont update instantly, so turn those on before joining a game
*/

void(*old_Update)(void *instance);

void Update(void *instance){

if([switches isSwitchOn:@"@SWITCHNAME@"]) {

//type is the function type, float,int ect

*(TYPE *) ((uint64_t)instance + @FIELDOFFSET@) = @VALUE@;

}
return old_Update(instance);
}

%ctor {
   
    MSHookFunction((void *)getRealOffset(@UPDATE OFFSET@), (void *)Update, (void **)&old_Update);
}
Field With Multiple Switches:
C++:
/*use instance to prevent crashing, idk if you have that problem too

hook to the update, start or awake function, if you use start or awake it wont update instantly, so turn those on before joining a game
*/

void(*old_Update)(void *instance);

void Update(void *instance){

if([switches isSwitchOn:@"@SWITCHNAME@"]) {

//type is the function type, float,int ect

*(TYPE *) ((uint64_t)instance + @FIELDOFFSET@) = @VALUE@;

}

if([switches isSwitchOn:@"@SWITCHNAME@"]) {

//type is the function type, float,int ect

*(TYPE *) ((uint64_t)instance + @FIELDOFFSET@) = @VALUE@;

}

if([switches isSwitchOn:@"@SWITCHNAME@"]) {

//type is the function type, float,int ect

*(TYPE *) ((uint64_t)instance + @FIELDOFFSET@) = @VALUE@;

}
return old_Update(instance);
}

%ctor {
   
    MSHookFunction((void *)getRealOffset(@UPDATE OFFSET@), (void *)Update, (void **)&old_Update);
}

UNITY FRAMEWORK HOOK
Use this under your void setup() {, the mshookfunction will cause the game to crash, this method wont

Code:
HOOK(@OFFSET@, @FUNCTION@, old_@FUNCTION);

how to use:

you can copy and paste the template above your setup function (below the import lines)
and fill in the info. What you do next is add your switches. Here are the Ted2 Switches available

C++:
//patching offsets directly, without switch
  patchOffset(0x1002DB3C8, "0xC0035FD6");
  patchOffset(0x10020D2D4, "0x00008052C0035FD6");

  // You can write as many bytes as you want to an offset
  patchOffset(0x10020D3A8, "0x00F0271E0008201EC0035FD6");
  // or
  patchOffset(0x10020D3A8, "00F0271E0008201EC0035FD6");
  // spaces are fine too
  patchOffset(0x10020D3A8, "00 F0 27 1E 00 08 20 1E C0 03 5F D6");


  // Empty switch - usefull with hooking
  [switches addSwitch:@"Masskill"
              description:@"Teleport all enemies to you without them knowing"];

  // Offset Switch with one patch
  [switches addOffsetSwitch:@"God Mode"
              description:@"You can't die"
                offsets:{0x1005AB148}
                  bytes:{"0x00E0BF12C0035FD6"}];

  // Offset switch with multiple patches
  [switches addOffsetSwitch:@"One Hit Kill"
              description:@"Enemy will die instantly"
                offsets:{0x1001BB2C0, 0x1002CB3B0, 0x1002CB3B8}
                  bytes:{"0x00E0BF12C0035FD6", "0xC0035FD6", "0x00F0271E0008201EC0035FD6"}];

  // Textfield Switch - used in hooking
  [switches addTextfieldSwitch:@"Custom Gold"
              description:@"Here you can enter your own gold amount"
                inputBorderColor:UIColorFromHex(0xBD0000)];

  // Slider Switch - used in hooking
  [switches addSliderSwitch:@"Custom Move Speed"
              description:@"Set your custom move speed"
                minimumValue:0
                  maximumValue:10
                    sliderColor:UIColorFromHex(0xBD0000)];
}
hope this helps
 
Last edited:
Apr 11, 2021
2
0
1
24
Poland
Nice, but doesn’t seem to work on UnityFramework games (game crashing) u know how to fix it or how to hook in UnityFramework games so the game wont crash?
 

·҉ dollaz·҉. .

Approved iModder
Original poster
Approved iModder
Mar 26, 2021
159
1,819
193
Somewhere
where should I learn to be more proficient in mod games
You should start off looking at source codes on github to get an idea of how it works

then use thisTemplate to make your first tweak. You need to put the nic.tar file in the theos templates folder and run theos. (Assuming you have theos installed) if you dont then just look that part up. Its a simple process. If you have more questions let me know

heres a repository you can look at to get an idea of what you need to do:

Repository link
 

Poison Modz

Approved Modder
Approved Modder
Aug 27, 2020
158
11,046
1,193
India
Hi brother can you tell me how to put offsets for radiobutton for mod menu please tell me i request you
 
  • Like
Reactions: Dczoo09