1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-22 18:26:39 +00:00

Update to v1.0.2.

This commit is contained in:
Pablo Curiel 2018-06-22 05:45:41 -04:00
parent a122605b6e
commit db3f5698e7
5 changed files with 127 additions and 106 deletions

View file

@ -33,9 +33,9 @@ include $(DEVKITPRO)/libnx/switch_rules
VERSION_MAJOR := 1
VERSION_MINOR := 0
VERSION_MICRO := 1
VERSION_MICRO := 2
APP_TITLE := Game Card Dump Tool
APP_TITLE := gcdumptool
APP_AUTHOR := MCMrARM, DarkMatterCore
APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}

View file

@ -25,6 +25,10 @@ Thanks to
Changelog
--------------
**v1.0.2:**
* Fixed a silly bug in the file splitting code.
**v1.0.1:**
* Minor UI fixes and tweaks.

View file

@ -380,7 +380,7 @@ bool dumpGameCartridge(FsDeviceOperator* fsOperator, bool isFat32, bool dumpCert
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);
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 (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);
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 (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);
uiDrawString(strbuf, 0, (breaks + 4) * 8, 255, 0, 0);
@ -989,11 +989,14 @@ bool copyFile(const char* source, const char* dest, bool doSplitting)
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);
uiDrawString(strbuf, 0, (breaks + 7) * 8, 255, 0, 0);
break;
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);
uiDrawString(strbuf, 0, (breaks + 7) * 8, 255, 0, 0);
break;
}
}
} else {
if (fwrite(buf, 1, n, outFile) != n)

View file

@ -2,7 +2,6 @@
#include <malloc.h>
#include <switch.h>
#include <memory.h>
#include <switch/services/ns.h>
#include "dumper.h"
#include "ncmext.h"
@ -37,127 +36,142 @@ int main(int argc, char **argv)
currentFB = gfxGetFramebuffer(&currentFBWidth, &currentFBHeight);
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;
while(appletMainLoop())
if (R_SUCCEEDED(result = nsInitialize()))
{
currentFB = gfxGetFramebuffer(&currentFBWidth, &currentFBHeight);
bool exitLoop = false;
uiPrintHeadline();
gameCardInserted = isGameCardInserted(&fsOperatorInstance);
if (gameCardInserted)
while(appletMainLoop())
{
if (hfs0_header == NULL)
currentFB = gfxGetFramebuffer(&currentFBWidth, &currentFBHeight);
uiPrintHeadline();
gameCardInserted = isGameCardInserted(&fsOperatorInstance);
if (gameCardInserted)
{
// Don't access the gamecard immediately to avoid conflicts with the fs-srv, ncm and ns services
uiPleaseWait();
getRootHfs0Header(&fsOperatorInstance);
getGameCardTitleID(&gameCardTitleID);
getGameCardControlNacp(gameCardTitleID, gameCardName, sizeof(gameCardName), gameCardAuthor, sizeof(gameCardAuthor), gameCardVersion, sizeof(gameCardVersion));
uiPrintHeadline();
uiUpdateStatusMsg();
if (hfs0_header == NULL)
{
// Don't access the gamecard immediately to avoid conflicts with the fsp-srv, ncm and ns services
uiPleaseWait();
getRootHfs0Header(&fsOperatorInstance);
getGameCardTitleID(&gameCardTitleID);
getGameCardControlNacp(gameCardTitleID, gameCardName, sizeof(gameCardName), gameCardAuthor, sizeof(gameCardAuthor), gameCardVersion, sizeof(gameCardVersion));
uiPrintHeadline();
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;
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));
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();
}
hidScanInput();
u32 keysDown = hidKeysDown(CONTROLLER_P1_AUTO);
UIResult result = uiLoop(keysDown);
switch(result)
{
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();
nsExit();
} else {
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Failed to initialize the ns service! (0x%08x)", result);
uiDrawString(strbuf, 0, 0, 255, 255, 255);
delay(5);
ret = -4;
}
fsDeviceOperatorClose(&fsOperatorInstance);
ncmExit();
} 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);
ret = -3;
}
nsExit();
fsDeviceOperatorClose(&fsOperatorInstance);
} 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);
ret = -2;
}
ncmExit();
fsExit();
} 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);
ret = -1;
}

View file

@ -5,7 +5,7 @@
#include <switch.h>
#define APP_VERSION "1.0.1"
#define APP_VERSION "1.0.2"
#define NAME_BUF_LEN 4096
bool isGameCardInserted(FsDeviceOperator* o);