mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-23 02:36:41 +00:00
Update to v1.0.2.
This commit is contained in:
parent
a122605b6e
commit
db3f5698e7
5 changed files with 127 additions and 106 deletions
4
Makefile
4
Makefile
|
@ -33,9 +33,9 @@ include $(DEVKITPRO)/libnx/switch_rules
|
||||||
|
|
||||||
VERSION_MAJOR := 1
|
VERSION_MAJOR := 1
|
||||||
VERSION_MINOR := 0
|
VERSION_MINOR := 0
|
||||||
VERSION_MICRO := 1
|
VERSION_MICRO := 2
|
||||||
|
|
||||||
APP_TITLE := Game Card Dump Tool
|
APP_TITLE := gcdumptool
|
||||||
APP_AUTHOR := MCMrARM, DarkMatterCore
|
APP_AUTHOR := MCMrARM, DarkMatterCore
|
||||||
APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}
|
APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,10 @@ Thanks to
|
||||||
Changelog
|
Changelog
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
**v1.0.2:**
|
||||||
|
|
||||||
|
* Fixed a silly bug in the file splitting code.
|
||||||
|
|
||||||
**v1.0.1:**
|
**v1.0.1:**
|
||||||
|
|
||||||
* Minor UI fixes and tweaks.
|
* Minor UI fixes and tweaks.
|
||||||
|
|
|
@ -380,7 +380,7 @@ bool dumpGameCartridge(FsDeviceOperator* fsOperator, bool isFat32, bool dumpCert
|
||||||
|
|
||||||
if (new_file_chunk_size > 0)
|
if (new_file_chunk_size > 0)
|
||||||
{
|
{
|
||||||
if (fwrite(buf, 1, new_file_chunk_size, outFile) != new_file_chunk_size)
|
if (fwrite(buf + old_file_chunk_size, 1, new_file_chunk_size, outFile) != new_file_chunk_size)
|
||||||
{
|
{
|
||||||
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to write chunk to offset 0x%016lX", fileOffset + old_file_chunk_size);
|
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to write chunk to offset 0x%016lX", fileOffset + old_file_chunk_size);
|
||||||
uiDrawString(strbuf, 0, (breaks + 7) * 8, 255, 0, 0);
|
uiDrawString(strbuf, 0, (breaks + 7) * 8, 255, 0, 0);
|
||||||
|
@ -517,7 +517,7 @@ bool dumpGameCartridge(FsDeviceOperator* fsOperator, bool isFat32, bool dumpCert
|
||||||
|
|
||||||
if (new_file_chunk_size > 0)
|
if (new_file_chunk_size > 0)
|
||||||
{
|
{
|
||||||
if (fwrite(buf, 1, new_file_chunk_size, outFile) != new_file_chunk_size)
|
if (fwrite(buf + old_file_chunk_size, 1, new_file_chunk_size, outFile) != new_file_chunk_size)
|
||||||
{
|
{
|
||||||
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to write chunk to offset 0x%016lX", fileOffset + old_file_chunk_size);
|
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to write chunk to offset 0x%016lX", fileOffset + old_file_chunk_size);
|
||||||
uiDrawString(strbuf, 0, (breaks + 7) * 8, 255, 0, 0);
|
uiDrawString(strbuf, 0, (breaks + 7) * 8, 255, 0, 0);
|
||||||
|
@ -770,7 +770,7 @@ bool dumpRawPartition(FsDeviceOperator* fsOperator, u32 partition, bool doSplitt
|
||||||
|
|
||||||
if (new_file_chunk_size > 0)
|
if (new_file_chunk_size > 0)
|
||||||
{
|
{
|
||||||
if (fwrite(buf, 1, new_file_chunk_size, outFile) != new_file_chunk_size)
|
if (fwrite(buf + old_file_chunk_size, 1, new_file_chunk_size, outFile) != new_file_chunk_size)
|
||||||
{
|
{
|
||||||
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to write chunk to offset 0x%016lX", off + old_file_chunk_size);
|
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to write chunk to offset 0x%016lX", off + old_file_chunk_size);
|
||||||
uiDrawString(strbuf, 0, (breaks + 4) * 8, 255, 0, 0);
|
uiDrawString(strbuf, 0, (breaks + 4) * 8, 255, 0, 0);
|
||||||
|
@ -989,11 +989,14 @@ bool copyFile(const char* source, const char* dest, bool doSplitting)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite(buf, 1, new_file_chunk_size, outFile) != new_file_chunk_size)
|
if (new_file_chunk_size > 0)
|
||||||
{
|
{
|
||||||
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to write chunk to offset 0x%016lX", off + old_file_chunk_size);
|
if (fwrite(buf + old_file_chunk_size, 1, new_file_chunk_size, outFile) != new_file_chunk_size)
|
||||||
uiDrawString(strbuf, 0, (breaks + 7) * 8, 255, 0, 0);
|
{
|
||||||
break;
|
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to write chunk to offset 0x%016lX", off + old_file_chunk_size);
|
||||||
|
uiDrawString(strbuf, 0, (breaks + 7) * 8, 255, 0, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (fwrite(buf, 1, n, outFile) != n)
|
if (fwrite(buf, 1, n, outFile) != n)
|
||||||
|
|
202
source/main.c
202
source/main.c
|
@ -2,7 +2,6 @@
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <switch/services/ns.h>
|
|
||||||
|
|
||||||
#include "dumper.h"
|
#include "dumper.h"
|
||||||
#include "ncmext.h"
|
#include "ncmext.h"
|
||||||
|
@ -37,127 +36,142 @@ int main(int argc, char **argv)
|
||||||
currentFB = gfxGetFramebuffer(¤tFBWidth, ¤tFBHeight);
|
currentFB = gfxGetFramebuffer(¤tFBWidth, ¤tFBHeight);
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
Result result;
|
||||||
|
char strbuf[512] = {'\0'};
|
||||||
|
|
||||||
if (R_SUCCEEDED(ncmInitialize()))
|
if (R_SUCCEEDED(result = fsInitialize()))
|
||||||
{
|
{
|
||||||
if (R_SUCCEEDED(nsInitialize()))
|
if (R_SUCCEEDED(result = fsOpenDeviceOperator(&fsOperatorInstance)))
|
||||||
{
|
{
|
||||||
if (R_SUCCEEDED(fsOpenDeviceOperator(&fsOperatorInstance)))
|
if (R_SUCCEEDED(result = ncmInitialize()))
|
||||||
{
|
{
|
||||||
bool exitLoop = false;
|
if (R_SUCCEEDED(result = nsInitialize()))
|
||||||
|
|
||||||
while(appletMainLoop())
|
|
||||||
{
|
{
|
||||||
currentFB = gfxGetFramebuffer(¤tFBWidth, ¤tFBHeight);
|
bool exitLoop = false;
|
||||||
|
|
||||||
uiPrintHeadline();
|
while(appletMainLoop())
|
||||||
|
|
||||||
gameCardInserted = isGameCardInserted(&fsOperatorInstance);
|
|
||||||
|
|
||||||
if (gameCardInserted)
|
|
||||||
{
|
{
|
||||||
if (hfs0_header == NULL)
|
currentFB = gfxGetFramebuffer(¤tFBWidth, ¤tFBHeight);
|
||||||
|
|
||||||
|
uiPrintHeadline();
|
||||||
|
|
||||||
|
gameCardInserted = isGameCardInserted(&fsOperatorInstance);
|
||||||
|
|
||||||
|
if (gameCardInserted)
|
||||||
{
|
{
|
||||||
// Don't access the gamecard immediately to avoid conflicts with the fs-srv, ncm and ns services
|
if (hfs0_header == NULL)
|
||||||
uiPleaseWait();
|
{
|
||||||
|
// Don't access the gamecard immediately to avoid conflicts with the fsp-srv, ncm and ns services
|
||||||
|
uiPleaseWait();
|
||||||
|
|
||||||
getRootHfs0Header(&fsOperatorInstance);
|
getRootHfs0Header(&fsOperatorInstance);
|
||||||
getGameCardTitleID(&gameCardTitleID);
|
getGameCardTitleID(&gameCardTitleID);
|
||||||
getGameCardControlNacp(gameCardTitleID, gameCardName, sizeof(gameCardName), gameCardAuthor, sizeof(gameCardAuthor), gameCardVersion, sizeof(gameCardVersion));
|
getGameCardControlNacp(gameCardTitleID, gameCardName, sizeof(gameCardName), gameCardAuthor, sizeof(gameCardAuthor), gameCardVersion, sizeof(gameCardVersion));
|
||||||
|
|
||||||
uiPrintHeadline();
|
uiPrintHeadline();
|
||||||
uiUpdateStatusMsg();
|
uiUpdateStatusMsg();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (hfs0_header != NULL)
|
||||||
|
{
|
||||||
|
gameCardSize = 0;
|
||||||
|
memset(gameCardSizeStr, 0, sizeof(gameCardSizeStr));
|
||||||
|
|
||||||
|
free(hfs0_header);
|
||||||
|
hfs0_header = NULL;
|
||||||
|
hfs0_offset = hfs0_size = 0;
|
||||||
|
hfs0_partition_cnt = 0;
|
||||||
|
|
||||||
|
gameCardTitleID = 0;
|
||||||
|
|
||||||
|
memset(gameCardName, 0, sizeof(gameCardName));
|
||||||
|
memset(gameCardAuthor, 0, sizeof(gameCardAuthor));
|
||||||
|
memset(gameCardVersion, 0, sizeof(gameCardVersion));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (hfs0_header != NULL)
|
hidScanInput();
|
||||||
|
u32 keysDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||||
|
|
||||||
|
UIResult result = uiLoop(keysDown);
|
||||||
|
switch(result)
|
||||||
{
|
{
|
||||||
gameCardSize = 0;
|
case resultShowMainMenu:
|
||||||
memset(gameCardSizeStr, 0, sizeof(gameCardSizeStr));
|
uiSetState(stateMainMenu);
|
||||||
|
break;
|
||||||
free(hfs0_header);
|
case resultShowXciDumpMenu:
|
||||||
hfs0_header = NULL;
|
uiSetState(stateXciDumpMenu);
|
||||||
hfs0_offset = hfs0_size = 0;
|
break;
|
||||||
hfs0_partition_cnt = 0;
|
case resultDumpXci:
|
||||||
|
uiSetState(stateDumpXci);
|
||||||
gameCardTitleID = 0;
|
break;
|
||||||
|
case resultShowRawPartitionDumpMenu:
|
||||||
memset(gameCardName, 0, sizeof(gameCardName));
|
uiSetState(stateRawPartitionDumpMenu);
|
||||||
memset(gameCardAuthor, 0, sizeof(gameCardAuthor));
|
break;
|
||||||
memset(gameCardVersion, 0, sizeof(gameCardVersion));
|
case resultDumpRawPartition:
|
||||||
|
uiSetState(stateDumpRawPartition);
|
||||||
|
break;
|
||||||
|
case resultShowPartitionDataDumpMenu:
|
||||||
|
uiSetState(statePartitionDataDumpMenu);
|
||||||
|
break;
|
||||||
|
case resultDumpPartitionData:
|
||||||
|
uiSetState(stateDumpPartitionData);
|
||||||
|
break;
|
||||||
|
case resultShowViewGameCardFsMenu:
|
||||||
|
uiSetState(stateViewGameCardFsMenu);
|
||||||
|
break;
|
||||||
|
case resultShowViewGameCardFsGetList:
|
||||||
|
uiSetState(stateViewGameCardFsGetList);
|
||||||
|
break;
|
||||||
|
case resultShowViewGameCardFsBrowser:
|
||||||
|
uiSetState(stateViewGameCardFsBrowser);
|
||||||
|
break;
|
||||||
|
case resultViewGameCardFsBrowserCopyFile:
|
||||||
|
uiSetState(stateViewGameCardFsBrowserCopyFile);
|
||||||
|
break;
|
||||||
|
case resultDumpGameCardCertificate:
|
||||||
|
uiSetState(stateDumpGameCardCertificate);
|
||||||
|
break;
|
||||||
|
case resultExit:
|
||||||
|
exitLoop = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exitLoop) break;
|
||||||
|
|
||||||
|
syncDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
hidScanInput();
|
nsExit();
|
||||||
u32 keysDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
} else {
|
||||||
|
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to initialize the ns service! (0x%08x)", result);
|
||||||
UIResult result = uiLoop(keysDown);
|
uiDrawString(strbuf, 0, 0, 255, 255, 255);
|
||||||
switch(result)
|
delay(5);
|
||||||
{
|
ret = -4;
|
||||||
case resultShowMainMenu:
|
|
||||||
uiSetState(stateMainMenu);
|
|
||||||
break;
|
|
||||||
case resultShowXciDumpMenu:
|
|
||||||
uiSetState(stateXciDumpMenu);
|
|
||||||
break;
|
|
||||||
case resultDumpXci:
|
|
||||||
uiSetState(stateDumpXci);
|
|
||||||
break;
|
|
||||||
case resultShowRawPartitionDumpMenu:
|
|
||||||
uiSetState(stateRawPartitionDumpMenu);
|
|
||||||
break;
|
|
||||||
case resultDumpRawPartition:
|
|
||||||
uiSetState(stateDumpRawPartition);
|
|
||||||
break;
|
|
||||||
case resultShowPartitionDataDumpMenu:
|
|
||||||
uiSetState(statePartitionDataDumpMenu);
|
|
||||||
break;
|
|
||||||
case resultDumpPartitionData:
|
|
||||||
uiSetState(stateDumpPartitionData);
|
|
||||||
break;
|
|
||||||
case resultShowViewGameCardFsMenu:
|
|
||||||
uiSetState(stateViewGameCardFsMenu);
|
|
||||||
break;
|
|
||||||
case resultShowViewGameCardFsGetList:
|
|
||||||
uiSetState(stateViewGameCardFsGetList);
|
|
||||||
break;
|
|
||||||
case resultShowViewGameCardFsBrowser:
|
|
||||||
uiSetState(stateViewGameCardFsBrowser);
|
|
||||||
break;
|
|
||||||
case resultViewGameCardFsBrowserCopyFile:
|
|
||||||
uiSetState(stateViewGameCardFsBrowserCopyFile);
|
|
||||||
break;
|
|
||||||
case resultDumpGameCardCertificate:
|
|
||||||
uiSetState(stateDumpGameCardCertificate);
|
|
||||||
break;
|
|
||||||
case resultExit:
|
|
||||||
exitLoop = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exitLoop) break;
|
|
||||||
|
|
||||||
syncDisplay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fsDeviceOperatorClose(&fsOperatorInstance);
|
ncmExit();
|
||||||
} else {
|
} else {
|
||||||
uiDrawString("Failed to open device operator.", 0, 0, 255, 255, 255);
|
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to initialize the ncm service! (0x%08x)", result);
|
||||||
|
uiDrawString(strbuf, 0, 0, 255, 255, 255);
|
||||||
delay(5);
|
delay(5);
|
||||||
ret = -3;
|
ret = -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsExit();
|
fsDeviceOperatorClose(&fsOperatorInstance);
|
||||||
} else {
|
} else {
|
||||||
uiDrawString("Failed to initialize the NS service.", 0, 0, 255, 255, 255);
|
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to open device operator! (0x%08x)", result);
|
||||||
|
uiDrawString(strbuf, 0, 0, 255, 255, 255);
|
||||||
delay(5);
|
delay(5);
|
||||||
ret = -2;
|
ret = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ncmExit();
|
fsExit();
|
||||||
} else {
|
} else {
|
||||||
uiDrawString("Failed to initialize the NCM service.", 0, 0, 255, 255, 255);
|
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to initialize the fsp-srv service! (0x%08x)", result);
|
||||||
|
uiDrawString(strbuf, 0, 0, 255, 255, 255);
|
||||||
delay(5);
|
delay(5);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
#define APP_VERSION "1.0.1"
|
#define APP_VERSION "1.0.2"
|
||||||
#define NAME_BUF_LEN 4096
|
#define NAME_BUF_LEN 4096
|
||||||
|
|
||||||
bool isGameCardInserted(FsDeviceOperator* o);
|
bool isGameCardInserted(FsDeviceOperator* o);
|
||||||
|
|
Loading…
Reference in a new issue