1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-09 12:11:44 +00:00

poc: cancel USB xfer on NSP dump error.

This commit is contained in:
Pablo Curiel 2023-11-11 12:16:29 +01:00
parent 1445faf17f
commit 98ed7d1c29
3 changed files with 6 additions and 8 deletions

View file

@ -5279,11 +5279,7 @@ static void nspThreadFunc(void *arg)
bool cancelled = nsp_thread_data->transfer_cancelled;
mutexUnlock(&g_fileMutex);
if (cancelled)
{
if (dev_idx == 1) usbCancelFileTransfer();
goto end;
}
if (cancelled) goto end;
if ((cur_nca_ctx->content_size - offset) < blksize) blksize = (cur_nca_ctx->content_size - offset);
@ -5563,7 +5559,7 @@ end:
{
fclose(fd);
if (!success && dev_idx != 1)
if (!success)
{
if (dev_idx == 0)
{
@ -5575,6 +5571,8 @@ end:
}
}
if (!success && dev_idx == 1) usbCancelFileTransfer();
pfsFreeImageContext(&pfs_img_ctx);
if (raw_cert_chain) free(raw_cert_chain);

View file

@ -346,7 +346,7 @@ bool pfsWriteImageContextHeaderToMemoryBuffer(PartitionFileSystemImageContext *c
header_size = (sizeof(PartitionFileSystemHeader) + (header->entry_count * sizeof(PartitionFileSystemEntry)) + header->name_table_size);
/* Calculate padded header size and padding size. */
padded_header_size = (IS_ALIGNED(header_size, PFS_HEADER_PADDING_ALIGNMENT) ? ALIGN_UP(header_size + 1, PFS_HEADER_PADDING_ALIGNMENT) : ALIGN_UP(header_size, PFS_HEADER_PADDING_ALIGNMENT));
padded_header_size = (IS_ALIGNED(header_size, PFS_HEADER_PADDING_ALIGNMENT) ? (header_size + PFS_HEADER_PADDING_ALIGNMENT) : ALIGN_UP(header_size, PFS_HEADER_PADDING_ALIGNMENT));
padding_size = (u32)(padded_header_size - header_size);
/* Check buffer size. */

View file

@ -32,7 +32,7 @@
#define USB_CMD_HEADER_MAGIC 0x4E584454 /* "NXDT". */
#define USB_TRANSFER_ALIGNMENT 0x1000 /* 4 KiB. */
#define USB_TRANSFER_TIMEOUT 5 /* 5 seconds. */
#define USB_TRANSFER_TIMEOUT 10 /* 10 seconds. */
#define USB_DEV_VID 0x057E /* VID officially used by Nintendo in usb:ds. */
#define USB_DEV_PID 0x3000 /* PID officially used by Nintendo in usb:ds. */