Skip to content

Commit

Permalink
- added: output cue file if 2nd language code exists
Browse files Browse the repository at this point in the history
- improved: UDF logging
- fixed: fail to XBOX/XBOX 360 dumping
  • Loading branch information
saramibreak committed Dec 23, 2019
1 parent 5437371 commit 84a40ce
Show file tree
Hide file tree
Showing 15 changed files with 1,027 additions and 583 deletions.
7 changes: 4 additions & 3 deletions DiscImageCreator/execScsiCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,15 +462,16 @@ BOOL ReadTOCText(
}
}

for (INT n = 0; n < 8; n++) {
for (INT n = 0; n < MAX_CDTEXT_LANG; n++) {
if (uiLastSeqNumOfBlock[n + 1]) {
pDisc->SCSI.CDTEXT[n].bExist = TRUE;
if (n == 0) {
SetAndOutputTocCDText(pDisc, pDesc, pTmpText, (WORD)(uiLastSeqNumOfBlock[n + 1] + 1)
, 0, pDesc[uiLastSeqNumOfBlock[n + 1]].Unicode);
, 0, pDesc[uiLastSeqNumOfBlock[n + 1]].Unicode, n);
}
else {
SetAndOutputTocCDText(pDisc, pDesc, pTmpText, (WORD)(uiLastSeqNumOfBlock[n + 1] + 1)
, uiLastSeqNumOfBlock[n] + 1, pDesc[uiLastSeqNumOfBlock[n + 1]].Unicode);
, uiLastSeqNumOfBlock[n] + 1, pDesc[uiLastSeqNumOfBlock[n + 1]].Unicode, n);
}
}
else {
Expand Down
36 changes: 3 additions & 33 deletions DiscImageCreator/execScsiCmdforCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,6 @@ BOOL ProcessCreateBin(
PDEVICE pDevice,
PDISC pDisc,
LPCTSTR pszPath,
FILE* fpCue,
FILE* fpCueForImg,
FILE* fpCcd
) {
FILE* fpImg = NULL;
Expand All @@ -781,7 +779,7 @@ BOOL ProcessCreateBin(
return FALSE;
}
if (!CreateBinCueCcd(pExtArg, pDisc, pszPath, pszImgName,
pDevice->FEATURE.byCanCDText, fpImg, fpCue, fpCueForImg, fpCcd)) {
pDevice->FEATURE.byCanCDText, fpImg, fpCcd)) {
FcloseAndNull(fpImg);
return FALSE;
}
Expand All @@ -808,8 +806,6 @@ BOOL ReadCDAll(
return FALSE;
}
BOOL bRet = TRUE;
FILE* fpCue = NULL;
FILE* fpCueForImg = NULL;
FILE* fpSub = NULL;
LPBYTE pBuf = NULL;
LPBYTE pNextBuf = NULL;
Expand All @@ -821,16 +817,6 @@ BOOL ReadCDAll(

try {
// init start
if (NULL == (fpCue = CreateOrOpenFile(
pszPath, NULL, NULL, NULL, NULL, _T(".cue"), _T(WFLAG), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (NULL == (fpCueForImg = CreateOrOpenFile(
pszPath, _T("_img"), NULL, NULL, NULL, _T(".cue"), _T(WFLAG), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (NULL == (fpSub = CreateOrOpenFile(
pszPath, NULL, NULL, NULL, NULL, _T(".sub"), _T("wb"), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
Expand Down Expand Up @@ -1297,16 +1283,14 @@ BOOL ReadCDAll(
if (!ProcessDescramble(pExtArg, pDisc, pszPath, pszOutScmFile)) {
throw FALSE;
}
if (!ProcessCreateBin(pExtArg, pDevice, pDisc, pszPath, fpCue, fpCueForImg, fpCcd)) {
if (!ProcessCreateBin(pExtArg, pDevice, pDisc, pszPath, fpCcd)) {
throw FALSE;
}
}
catch (BOOL ret) {
bRet = ret;
}
FcloseAndNull(fpImg);
FcloseAndNull(fpCueForImg);
FcloseAndNull(fpCue);
FcloseAndNull(fpSub);
if (pDevice->byAsusDrive) {
FreeAndNull(pDisc->lpCachedBuf);
Expand Down Expand Up @@ -1346,8 +1330,6 @@ BOOL ReadCDForSwap(
return FALSE;
}
BOOL bRet = TRUE;
FILE* fpCue = NULL;
FILE* fpCueForImg = NULL;
FILE* fpSub = NULL;
FILE* fpLeadout = NULL;
LPBYTE pBuf = NULL;
Expand All @@ -1358,16 +1340,6 @@ BOOL ReadCDForSwap(

try {
// init start
if (NULL == (fpCue = CreateOrOpenFile(
pszPath, NULL, NULL, NULL, NULL, _T(".cue"), _T(WFLAG), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
if (NULL == (fpCueForImg = CreateOrOpenFile(
pszPath, _T("_img"), NULL, NULL, NULL, _T(".cue"), _T(WFLAG), 0, 0))) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
throw FALSE;
}
#ifndef __DEBUG
if (NULL == (fpSub = CreateOrOpenFile(
pszPath, NULL, NULL, NULL, NULL, _T(".sub"), _T("wb"), 0, 0))) {
Expand Down Expand Up @@ -1650,7 +1622,7 @@ BOOL ReadCDForSwap(
if (!ProcessDescramble(pExtArg, pDisc, pszPath, pszScmPath)) {
throw FALSE;
}
if (!ProcessCreateBin(pExtArg, pDevice, pDisc, pszPath, fpCue, fpCueForImg, fpCcd)) {
if (!ProcessCreateBin(pExtArg, pDevice, pDisc, pszPath, fpCcd)) {
throw FALSE;
}
if (pExtArg->by74Min) {
Expand Down Expand Up @@ -1707,8 +1679,6 @@ BOOL ReadCDForSwap(
}
FcloseAndNull(fpLeadout);
FcloseAndNull(fpScm);
FcloseAndNull(fpCueForImg);
FcloseAndNull(fpCue);
FcloseAndNull(fpSub);
FreeAndNull(pBuf);

Expand Down
5 changes: 5 additions & 0 deletions DiscImageCreator/execScsiCmdforDVD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ BOOL ReadDVD(
if (!ReadDVDForFileSystem(pExecType, pExtArg, pDevice, pDisc, &cdb, lpBuf)) {
throw FALSE;
}
if (pDisc->SCSI.wCurrentMedia == ProfileDvdRewritable ||
pDisc->SCSI.wCurrentMedia == ProfileBDRSequentialWritable ||
pDisc->SCSI.wCurrentMedia == ProfileBDRewritable) {
nAllLength = pDisc->SCSI.nAllLength;
}

if (*pExecType == xbox) {
if (!ReadXBOXFileSystem(pExtArg, pDevice, pDisc->DVD.dwXboxStartPsn - pDisc->DVD.dwDVDStartPsn)) {
Expand Down
173 changes: 139 additions & 34 deletions DiscImageCreator/execScsiCmdforFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ BOOL ReadVolumeDescriptor(
*lpReadVD = TRUE;
}
OutputCDMain(fileMainInfo, lpBuf, nTmpLBA, DISC_RAW_READ_SIZE);
OutputFsVolumeDescriptor(pExtArg, pDisc, lpBuf, nTmpLBA++);
OutputFsVolumeDescriptor(pExtArg, pDisc, lpBuf, pVolDesc, nTmpLBA++);
}
else {
break;
Expand Down Expand Up @@ -788,14 +788,10 @@ BOOL ReadDVDForFileSystem(
}
}

INT nLBA = 18;
dwTransferLen = 14;
dwTransferLen = 6;
INT nLBA = 16;
REVERSE_BYTES(&cdb->TransferLength, &dwTransferLen);
cdb->LogicalBlock[0] = 0;
cdb->LogicalBlock[1] = 0;
cdb->LogicalBlock[2] = 0;
cdb->LogicalBlock[3] = (UCHAR)nLBA;

REVERSE_BYTES(&cdb->LogicalBlock[0], &nLBA);
#ifdef _WIN32
INT direction = SCSI_IOCTL_DATA_IN;
#else
Expand All @@ -807,38 +803,147 @@ BOOL ReadDVDForFileSystem(
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
for (INT i = 0; i < DISC_RAW_READ_SIZE * 14; i += DISC_RAW_READ_SIZE, nLBA++) {
OutputFsVolumeRecognitionSequence(lpBuf + i, nLBA);
BOOL bUDF = FALSE;
for (UINT i = 0; i < DISC_RAW_READ_SIZE * dwTransferLen; i += DISC_RAW_READ_SIZE, nLBA++) {
OutputFsVolumeRecognitionSequence(lpBuf + i, nLBA, &bUDF);
}

nLBA = 32;
dwTransferLen = pDevice->dwMaxTransferLength / DISC_RAW_READ_SIZE;
REVERSE_BYTES(&cdb->TransferLength, &dwTransferLen);
cdb->LogicalBlock[0] = 0;
cdb->LogicalBlock[1] = 0;
cdb->LogicalBlock[2] = 0;
cdb->LogicalBlock[3] = (UCHAR)nLBA;
if (bUDF) {
// for Anchor Volume Descriptor Pointer
dwTransferLen = 1;
nLBA = 256;
REVERSE_BYTES(&cdb->TransferLength, &dwTransferLen);
REVERSE_BYTES(&cdb->LogicalBlock[0], &nLBA);
if (!ScsiPassThroughDirect(pExtArg, pDevice, cdb, CDB12GENERIC_LENGTH, lpBuf,
direction, DISC_RAW_READ_SIZE * dwTransferLen, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
UDF udf = {};
OutputFsVolumeDescriptorSequence(lpBuf, nLBA, &udf);

// for PVD, IUVD, PD, LVD etc.
dwTransferLen = udf.uiPVDLen / DISC_RAW_READ_SIZE;
nLBA = (INT)udf.uiPVDPos;
REVERSE_BYTES(&cdb->TransferLength, &dwTransferLen);
REVERSE_BYTES(&cdb->LogicalBlock[0], &nLBA);
if (!ScsiPassThroughDirect(pExtArg, pDevice, cdb, CDB12GENERIC_LENGTH, lpBuf,
direction, DISC_RAW_READ_SIZE * dwTransferLen, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}

if (!ScsiPassThroughDirect(pExtArg, pDevice, cdb, CDB12GENERIC_LENGTH, lpBuf,
direction, DISC_RAW_READ_SIZE * dwTransferLen, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
if (lpBuf[20] == 0 && lpBuf[21] == 0 && lpBuf[22] == 0 && lpBuf[23] == 0) {
for (INT i = 0; i < DISC_RAW_READ_SIZE * 32; i += DISC_RAW_READ_SIZE, nLBA++) {
OutputFsVolumeDescriptorSequence(lpBuf + i, nLBA);
DWORD dwTransferLenBak = dwTransferLen;
INT nLBABak = 0;
for (UINT i = 0; i < DISC_RAW_READ_SIZE * dwTransferLen; i += DISC_RAW_READ_SIZE, nLBA++) {
OutputFsVolumeDescriptorSequence(lpBuf + i, nLBA, &udf);
WORD wTagId = MAKEWORD(lpBuf[i], lpBuf[i + 1]);
if (wTagId == 5) {
nLBABak = nLBA;
dwTransferLen = 1;
INT nCnt = 0;
REVERSE_BYTES(&cdb->TransferLength, &dwTransferLen);

for (INT j = 0; j < 512; j++) {
nLBA = (INT)(udf.uiPartitionPos + udf.uiPartitionLen + j);
if (nLBA >= pDisc->SCSI.nAllLength) {
break;
}
REVERSE_BYTES(&cdb->LogicalBlock[0], &nLBA);
if (!ScsiPassThroughDirect(pExtArg, pDevice, cdb, CDB12GENERIC_LENGTH, lpBuf,
direction, DISC_RAW_READ_SIZE * dwTransferLen, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
break;
}
wTagId = MAKEWORD(lpBuf[0], lpBuf[1]);
if (wTagId == 2) {
// NOTE: An AnchorVolumeDescriptorPointer structure shall be recorded in at
// least 2 of the following 3 locations on the media:
// Logical Sector 256.
// Logical Sector (N - 256).
// N
OutputDiscLogA("Detected Anchor Volume Descriptor Pointer: LBA %u\n", nLBA);
pDisc->SCSI.nAllLength = nLBA + 1;
if (++nCnt == 2) {
break;
}
}
}
dwTransferLen = dwTransferLenBak;
nLBA = nLBABak;
}
}
}

cdb->LogicalBlock[2] = 1;
cdb->LogicalBlock[3] = 0;
if (!ScsiPassThroughDirect(pExtArg, pDevice, cdb, CDB12GENERIC_LENGTH, lpBuf,
direction, DISC_RAW_READ_SIZE * dwTransferLen, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
// for Integrity Sequence Extent
dwTransferLen = udf.uiLogicalVolumeIntegrityLen / DISC_RAW_READ_SIZE;
nLBA = (INT)udf.uiLogicalVolumeIntegrityPos;
REVERSE_BYTES(&cdb->TransferLength, &dwTransferLen);
REVERSE_BYTES(&cdb->LogicalBlock[0], &nLBA);
if (!ScsiPassThroughDirect(pExtArg, pDevice, cdb, CDB12GENERIC_LENGTH, lpBuf,
direction, DISC_RAW_READ_SIZE * dwTransferLen, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
for (UINT i = 0; i < DISC_RAW_READ_SIZE * dwTransferLen; i += DISC_RAW_READ_SIZE, nLBA++) {
OutputFsVolumeDescriptorSequence(lpBuf + i, nLBA, &udf);
}
#if 1
// for File Set Descriptor
dwTransferLen = udf.uiFSDLen / DISC_RAW_READ_SIZE;
nLBA = (INT)(udf.uiPartitionPos + udf.uiFSDPos);
REVERSE_BYTES(&cdb->TransferLength, &dwTransferLen);
REVERSE_BYTES(&cdb->LogicalBlock[0], &nLBA);
if (!ScsiPassThroughDirect(pExtArg, pDevice, cdb, CDB12GENERIC_LENGTH, lpBuf,
direction, DISC_RAW_READ_SIZE * dwTransferLen, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
for (UINT i = 0; i < DISC_RAW_READ_SIZE * dwTransferLen; i += DISC_RAW_READ_SIZE, nLBA++) {
OutputFsVolumeDescriptorSequence(lpBuf + i, nLBA, &udf);
}

// for File Entry
dwTransferLen = udf.uiFileEntryLen / DISC_RAW_READ_SIZE;
nLBA = (INT)(udf.uiPartitionPos + udf.uiFileEntryPos);
REVERSE_BYTES(&cdb->TransferLength, &dwTransferLen);
REVERSE_BYTES(&cdb->LogicalBlock[0], &nLBA);
if (!ScsiPassThroughDirect(pExtArg, pDevice, cdb, CDB12GENERIC_LENGTH, lpBuf,
direction, DISC_RAW_READ_SIZE * dwTransferLen, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
for (UINT i = 0; i < DISC_RAW_READ_SIZE * dwTransferLen; i += DISC_RAW_READ_SIZE, nLBA++) {
OutputFsVolumeDescriptorSequence(lpBuf + i, nLBA, &udf);
}
#if 0
// for File Identifier Descriptor
UINT FileLen = uiExtLen / DISC_RAW_READ_SIZE;
UINT FileLenMod = uiExtLen % DISC_RAW_READ_SIZE;
if (FileLenMod != 0) {
FileLen += 1;
}
dwTransferLen = FileLen;
nLBA = (INT)(udf.uiPartitionPos + udf.uiFSDPos);
REVERSE_BYTES(&cdb->TransferLength, &dwTransferLen);
REVERSE_BYTES(&cdb->LogicalBlock[0], &nLBA);
if (!ScsiPassThroughDirect(pExtArg, pDevice, cdb, CDB12GENERIC_LENGTH, lpBuf,
direction, DISC_RAW_READ_SIZE * dwTransferLen, &byScsiStatus, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
for (UINT i = 0; i < DISC_RAW_READ_SIZE * dwTransferLen; i += DISC_RAW_READ_SIZE, nLBA++) {
OutputFsVolumeDescriptorSequence(lpBuf + i, nLBA, &udf);
}
#endif
#endif
}
else {
if (pDisc->SCSI.wCurrentMedia == ProfileDvdRewritable ||
pDisc->SCSI.wCurrentMedia == ProfileBDRSequentialWritable ||
pDisc->SCSI.wCurrentMedia == ProfileBDRewritable) {
pDisc->SCSI.nAllLength = (INT)volDesc.uiVolumeSpaceSize;
}
}
nLBA = 256;
OutputFsVolumeDescriptorSequence(lpBuf, nLBA);
return TRUE;
}

Expand Down
1 change: 1 addition & 0 deletions DiscImageCreator/forwardDeclaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#define META_CATALOG_SIZE (13 + 1)
#define META_ISRC_SIZE (12 + 1)
#define META_CDTEXT_SIZE (160 + 1)
#define MAX_CDTEXT_LANG (8)

#define EXELBA_STORE_SIZE (4096) // TODO
#define EXENAME_STORE_SIZE (64) // TODO
Expand Down
Loading

0 comments on commit 84a40ce

Please sign in to comment.