Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
Added support for 13.0.0, credits to Berichan
Browse files Browse the repository at this point in the history
  • Loading branch information
Manu098vm committed Sep 21, 2021
1 parent 86135e3 commit e0ba965
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 25 deletions.
3 changes: 0 additions & 3 deletions sys-botbase/source/.vs/ProjectSettings.json

This file was deleted.

7 changes: 0 additions & 7 deletions sys-botbase/source/.vs/VSWorkspaceState.json

This file was deleted.

Binary file removed sys-botbase/source/.vs/slnx.sqlite
Binary file not shown.
Binary file removed sys-botbase/source/.vs/source/v16/.suo
Binary file not shown.
Binary file removed sys-botbase/source/.vs/source/v16/Browse.VC.db
Binary file not shown.
20 changes: 18 additions & 2 deletions sys-botbase/source/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ u64 buttonClickSleepTime = 50;
u64 keyPressSleepTime = 25;
u64 pollRate = 17; // polling is linked to screen refresh rate (system UI) or game framerate. Most cases this is 1/60 or 1/30
u32 fingerDiameter = 50;
HiddbgHdlsSessionId sessionId = {0};

void attach()
{
Expand All @@ -42,6 +43,22 @@ void detach(){
svcCloseHandle(debughandle);
}

void detachController()
{
initController();

Result rc = hiddbgDetachHdlsVirtualDevice(controllerHandle);
if (R_FAILED(rc) && debugResultCodes)
printf("hiddbgDetachHdlsVirtualDevice: %d\n", rc);
rc = hiddbgReleaseHdlsWorkBuffer(sessionId);
if (R_FAILED(rc) && debugResultCodes)
printf("hiddbgReleaseHdlsWorkBuffer: %d\n", rc);
hiddbgExit();
bControllerIsInitialised = false;

sessionId.id = 0;
}

u64 getMainNsoBase(u64 pid){
LoaderModuleInfo proc_modules[2];
s32 numModules = 0;
Expand Down Expand Up @@ -140,7 +157,7 @@ void initController()
controllerState.analog_stick_l.y = -0x0;
controllerState.analog_stick_r.x = 0x0;
controllerState.analog_stick_r.y = -0x0;
rc = hiddbgAttachHdlsWorkBuffer();
rc = hiddbgAttachHdlsWorkBuffer(&sessionId);
if (R_FAILED(rc) && debugResultCodes)
printf("hiddbgAttachHdlsWorkBuffer: %d\n", rc);
rc = hiddbgAttachHdlsVirtualDevice(&controllerHandle, &controllerDevice);
Expand All @@ -151,7 +168,6 @@ void initController()
bControllerIsInitialised = true;
}


void poke(u64 offset, u64 size, u8* val)
{
attach();
Expand Down
1 change: 1 addition & 0 deletions sys-botbase/source/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef struct {

void attach();
void detach();
void detachController();
u64 getMainNsoBase(u64 pid);
u64 getHeapBase(Handle handle);
u64 getTitleId(u64 pid);
Expand Down
37 changes: 24 additions & 13 deletions sys-botbase/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,7 @@ int argmain(int argc, char **argv)
//detachController
if(!strcmp(argv[0], "detachController"))
{
Result rc = hiddbgDetachHdlsVirtualDevice(controllerHandle);
if (R_FAILED(rc) && debugResultCodes)
printf("hiddbgDetachHdlsVirtualDevice: %d\n", rc);
rc = hiddbgReleaseHdlsWorkBuffer();
if (R_FAILED(rc) && debugResultCodes)
printf("hiddbgReleaseHdlsWorkBuffer: %d\n", rc);
hiddbgExit();
bControllerIsInitialised = false;
detachController();
}

//configure <mainLoopSleepTime or buttonClickSleepTime> <time in ms>
Expand Down Expand Up @@ -421,7 +414,7 @@ int argmain(int argc, char **argv)
}

if(!strcmp(argv[0], "getVersion")){
printf("1.8\n");
printf("1.9\n");
}

// follow pointers and print absolute offset (little endian, flip it yourself if required)
Expand All @@ -443,7 +436,7 @@ int argmain(int argc, char **argv)
{
if(argc < 3)
return 0;
u64 finalJump = parseStringToSignedLong(argv[argc-1]);
s64 finalJump = parseStringToSignedLong(argv[argc-1]);
u64 count = argc - 2;
s64 jumps[count];
for (int i = 1; i < argc-1; i++)
Expand All @@ -452,14 +445,32 @@ int argmain(int argc, char **argv)
solved += finalJump;
printf("%016lX\n", solved);
}

// pointerRelative <first (main) jump> <additional jumps> <final jump in pointerexpr>
// returns offset relative to heap
if (!strcmp(argv[0], "pointerRelative"))
{
if(argc < 3)
return 0;
s64 finalJump = parseStringToSignedLong(argv[argc-1]);
u64 count = argc - 2;
s64 jumps[count];
for (int i = 1; i < argc-1; i++)
jumps[i-1] = parseStringToSignedLong(argv[i]);
u64 solved = followMainPointer(jumps, count);
solved += finalJump;
MetaData meta = getMetaData();
solved -= meta.heap_base;
printf("%016lX\n", solved);
}

// pointerPeek <amount of bytes in hex or dec> <first (main) jump> <additional jumps> <final jump in pointerexpr>
if (!strcmp(argv[0], "pointerPeek"))
{
if(argc < 4)
return 0;

u64 finalJump = parseStringToSignedLong(argv[argc-1]);
s64 finalJump = parseStringToSignedLong(argv[argc-1]);
u64 size = parseStringToInt(argv[1]);
u64 count = argc - 3;
s64 jumps[count];
Expand All @@ -476,7 +487,7 @@ int argmain(int argc, char **argv)
if(argc < 4)
return 0;

u64 finalJump = parseStringToSignedLong(argv[argc-1]);
s64 finalJump = parseStringToSignedLong(argv[argc-1]);
u64 count = argc - 3;
s64 jumps[count];
for (int i = 2; i < argc-1; i++)
Expand Down Expand Up @@ -756,7 +767,7 @@ int main()
mutexInit(&clickMutex);
rc = threadCreate(&clickThread, sub_click, (void*)currentClick, NULL, THREAD_SIZE, 0x2C, -2);
if (R_SUCCEEDED(rc))
{rc = threadStart(&clickThread);} // curly brackets remove compiler warning
rc = threadStart(&clickThread);

flashLed();

Expand Down

0 comments on commit e0ba965

Please sign in to comment.