Skip to content

Commit

Permalink
Merge pull request #54 from berichan/master
Browse files Browse the repository at this point in the history
Add check for if program is running and build with latest libnx (2.1)
  • Loading branch information
berichan authored Feb 7, 2022
2 parents e4c86a2 + 5a6d921 commit 567310b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions sys-botbase/source/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ MetaData getMetaData(){
return meta;
}

bool getIsProgramOpen(u64 id)
{
u64 pid = 0;
Result rc = pmdmntGetProcessId(&pid, id);
if (pid == 0 || R_FAILED(rc))
return false;

return true;
}

void initController()
{
if(bControllerIsInitialised) return;
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 @@ -44,6 +44,7 @@ u64 getHeapBase(Handle handle);
u64 getTitleId(u64 pid);
void getBuildID(MetaData* meta, u64 pid);
MetaData getMetaData(void);
bool getIsProgramOpen(u64 id);

void poke(u64 offset, u64 size, u8* val);
void writeMem(u64 offset, u64 size, u8* val);
Expand Down
10 changes: 9 additions & 1 deletion sys-botbase/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,14 @@ int argmain(int argc, char **argv)
printf("%016lX\n", meta.heap_base);
}

if(!strcmp(argv[0], "isProgramRunning")){
if(argc != 2)
return 0;
u64 programId = parseStringToInt(argv[1]);
bool isRunning = getIsProgramOpen(programId);
printf("%d\n", isRunning);
}

if(!strcmp(argv[0], "pixelPeek")){
//errors with 0x668CE, unless debugunit flag is patched
u64 bSize = 0x7D000;
Expand All @@ -475,7 +483,7 @@ int argmain(int argc, char **argv)
}

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

// follow pointers and print absolute offset (little endian, flip it yourself if required)
Expand Down

0 comments on commit 567310b

Please sign in to comment.