Skip to content

Commit

Permalink
add support for breeze bookmark
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvita committed May 5, 2022
1 parent b2b0ea4 commit 4b67343
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 29 deletions.
2 changes: 1 addition & 1 deletion server/source/noexs/include/gecko.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define VER_MAJOR (1)
#define VER_MINOR (1)
#define VER_PATCH (155)
#define VER_PATCH (157)

#define GECKO_BUFFER_SIZE (2048 * 32)
#define GECKO_BUFFER_SIZE2 (2048 * 4)
Expand Down
93 changes: 68 additions & 25 deletions server/source/noexs/source/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static u8 outbuffer[GECKO_BUFFER_SIZE * 9 / 8];
static FILE* g_memdumpFile = NULL;
// static FILE* g_bookmarkFile = NULL;
#define HEADERSIZE 135
#define HEADERSIZE2 424
enum t_searchsize {
_8, _16, _32, _64
};
Expand Down Expand Up @@ -264,7 +265,7 @@ static Result _attach(Gecko::Context& ctx){
ctx.status = Gecko::Status::Paused;
} else {
if (ctx.dbg.attached()) {
// dmntchtInitialize();
dmntchtInitialize();
DmntCheatProcessMetadata cht;
dmntchtGetCheatProcessMetadata(&cht);
if (cht.process_id == pid) {
Expand All @@ -276,7 +277,7 @@ static Result _attach(Gecko::Context& ctx){
}
}
else {
// dmntchtExit();
dmntchtExit();
}
}
}
Expand Down Expand Up @@ -723,36 +724,78 @@ static Result _dump_ptr(Gecko::Context& ctx){
static Result _getbookmark(Gecko::Context& ctx){
// printf("_getbookmark\n");
u8 cont = 1;
if (access("/switch/EdiZon/BMDump.dat", F_OK) != 0) {
if ((access("/switch/EdiZon/BMDump.dat", F_OK) != 0) && (access("/switch/Breeze/cheats/BMDump.dat", F_OK) != 0)) {
WRITE_CHECKED(ctx, 0)
READ_CHECKED(ctx, cont);
return FILE_ACCESS_ERROR;
}
g_memdumpFile = fopen("/switch/EdiZon/BMDump.dat", "r+b");
u32 size, len, index;

fseek(g_memdumpFile, 0, SEEK_END);
size = (ftell(g_memdumpFile) - HEADERSIZE);
printf("size = %d\n",size);

index = 0;
while (size > 0) {
len = (size < GECKO_BUFFER_SIZE) ? size : GECKO_BUFFER_SIZE;
fseek(g_memdumpFile, HEADERSIZE + index, SEEK_SET);
fread(outbuffer + outbuffer_offset, 1, len, g_memdumpFile);
// compress option
s32 count = LZ_Compress(outbuffer + outbuffer_offset, outbuffer, len);
//
printf("count = %d\n", count);
WRITE_CHECKED(ctx, count);
WRITE_BUFFER_CHECKED(ctx, outbuffer, count);
READ_CHECKED(ctx,cont); if (!cont) {WRITE_CHECKED(ctx, 0);READ_CHECKED(ctx, cont);fclose(g_memdumpFile); return USER_ABORT;}
index += len;
size -= len;
if (access("/switch/EdiZon/BMDump.dat", F_OK) == 0) {
g_memdumpFile = fopen("/switch/EdiZon/BMDump.dat", "r+b");

u32 size, len, index;

fseek(g_memdumpFile, 0, SEEK_END);
size = (ftell(g_memdumpFile) - HEADERSIZE);
printf("size = %d\n", size);

index = 0;
while (size > 0) {
len = (size < GECKO_BUFFER_SIZE) ? size : GECKO_BUFFER_SIZE;
fseek(g_memdumpFile, HEADERSIZE + index, SEEK_SET);
fread(outbuffer + outbuffer_offset, 1, len, g_memdumpFile);
// compress option
s32 count = LZ_Compress(outbuffer + outbuffer_offset, outbuffer, len);
//
printf("count = %d\n", count);
WRITE_CHECKED(ctx, count);
WRITE_BUFFER_CHECKED(ctx, outbuffer, count);
READ_CHECKED(ctx, cont);
if (!cont) {
WRITE_CHECKED(ctx, 0);
READ_CHECKED(ctx, cont);
fclose(g_memdumpFile);
return USER_ABORT;
}
index += len;
size -= len;
}
fclose(g_memdumpFile);
}
if (access("/switch/Breeze/cheats/BMDump.dat", F_OK) == 0) {
g_memdumpFile = fopen("/switch/Breeze/cheats/BMDump.dat", "r+b");

u32 size, len, index;

fseek(g_memdumpFile, 0, SEEK_END);
size = (ftell(g_memdumpFile) - HEADERSIZE2);
printf("size = %d\n", size);

index = 0;
while (size > 0) {
len = (size < GECKO_BUFFER_SIZE) ? size : GECKO_BUFFER_SIZE;
fseek(g_memdumpFile, HEADERSIZE2 + index, SEEK_SET);
fread(outbuffer + outbuffer_offset, 1, len, g_memdumpFile);
// compress option
s32 count = LZ_Compress(outbuffer + outbuffer_offset, outbuffer, len);
//
printf("count = %d\n", count);
WRITE_CHECKED(ctx, count);
WRITE_BUFFER_CHECKED(ctx, outbuffer, count);
READ_CHECKED(ctx, cont);
if (!cont) {
WRITE_CHECKED(ctx, 0);
READ_CHECKED(ctx, cont);
fclose(g_memdumpFile);
return USER_ABORT;
}
index += len;
size -= len;
}
fclose(g_memdumpFile);
}

WRITE_CHECKED(ctx, 0);
READ_CHECKED(ctx, cont);
fclose(g_memdumpFile);
return 0;
}
//0x1C
Expand Down
9 changes: 6 additions & 3 deletions server/source/noexs/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void __libnx_initheap(void) {
void __appInit(void) {
Result rc;

if (hosversionGet() == 0) {

rc = setsysInitialize();
if (R_SUCCEEDED(rc)) {
SetSysFirmwareVersion fw;
Expand All @@ -47,7 +47,10 @@ void __appInit(void) {
hosversionSet((BIT(31)) | (MAKEHOSVERSION(fw.major, fw.minor, fw.micro)));
setsysExit();
}
}
if (rc!=0) {
printf("version set failed rc=%d",rc);
hosversionSet(6);
};
// SetSysFirmwareVersion hosversion;
// rc = setsysGetFirmwareVersion(&hosversion);
// hosversionSet(hosversion.major);
Expand Down Expand Up @@ -90,7 +93,7 @@ void __appInit(void) {
fatalThrow(rc); // maybe set a variable like noSd or something? It doesn't HAVE to log.
}

rc = dmntchtInitialize();
// rc = dmntchtInitialize();
// if (R_FAILED(rc)) {
// fatalThrow(rc); // maybe set a variable like noSd or something? It doesn't HAVE to log.
// }
Expand Down

0 comments on commit 4b67343

Please sign in to comment.