Skip to content

Commit

Permalink
Merge pull request #45 from berichan/master
Browse files Browse the repository at this point in the history
Address 13.0.0 changes for session ids, fix detach bug by calling init first
  • Loading branch information
berichan authored Sep 19, 2021
2 parents 6a51b14 + edaf53d commit cc763c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
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
12 changes: 3 additions & 9 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 Down Expand Up @@ -454,6 +447,7 @@ int argmain(int argc, char **argv)
}

// pointerRelative <first (main) jump> <additional jumps> <final jump in pointerexpr>
// returns offset relative to heap
if (!strcmp(argv[0], "pointerRelative"))
{
if(argc < 3)
Expand Down

0 comments on commit cc763c5

Please sign in to comment.