Skip to content

Commit

Permalink
- Hook DVDCheckDisk.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Mar 10, 2019
1 parent 028a9d7 commit 6123f7c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions cube/swiss/source/patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,12 @@ void Patch_DVDLowLevelReadAlt(u32 *data, u32 length, int dataType)
{ 43, 10, 4, 4, 6, 3, NULL, 0, "DVDGetDriveStatus A" },
{ 43, 10, 4, 4, 6, 4, NULL, 0, "DVDGetDriveStatus B" } // SN Systems ProDG
};
FuncPattern DVDCheckDiskSigs[4] = {
{ 61, 16, 2, 2, 10, 7, NULL, 0, "DVDCheckDiskD A" },
{ 57, 19, 3, 2, 10, 5, NULL, 0, "DVDCheckDisk A" },
{ 61, 19, 3, 2, 12, 5, NULL, 0, "DVDCheckDisk B" }, // SN Systems ProDG
{ 62, 20, 3, 2, 12, 5, NULL, 0, "DVDCheckDisk C" }
};
u32 _SDA2_BASE_ = 0, _SDA_BASE_ = 0;

for (i = 0; i < length / sizeof(u32); i++) {
Expand Down Expand Up @@ -898,6 +904,30 @@ void Patch_DVDLowLevelReadAlt(u32 *data, u32 length, int dataType)
break;
}
}

for (j = 0; j < sizeof(DVDCheckDiskSigs) / sizeof(FuncPattern); j++) {
if (!DVDCheckDiskSigs[j].offsetFoundAt && compare_pattern(&fp, &DVDCheckDiskSigs[j])) {
switch (j) {
case 1:
if (findx_pattern(data, dataType, i + 4, length, &OSDisableInterruptsSig) &&
findx_pattern(data, dataType, i + 50, length, &OSRestoreInterruptsSig))
DVDCheckDiskSigs[j].offsetFoundAt = i;
break;
case 0:
case 2:
if (findx_pattern(data, dataType, i + 4, length, &OSDisableInterruptsSig) &&
findx_pattern(data, dataType, i + 54, length, &OSRestoreInterruptsSig))
DVDCheckDiskSigs[j].offsetFoundAt = i;
break;
case 3:
if (findx_pattern(data, dataType, i + 4, length, &OSDisableInterruptsSig) &&
findx_pattern(data, dataType, i + 55, length, &OSRestoreInterruptsSig))
DVDCheckDiskSigs[j].offsetFoundAt = i;
break;
}
break;
}
}
i += fp.Length - 1;
}

Expand Down Expand Up @@ -1222,6 +1252,23 @@ void Patch_DVDLowLevelReadAlt(u32 *data, u32 length, int dataType)
}
}

for (j = 0; j < sizeof(DVDCheckDiskSigs) / sizeof(FuncPattern); j++)
if (DVDCheckDiskSigs[j].offsetFoundAt) break;

if (j < sizeof(DVDCheckDiskSigs) / sizeof(FuncPattern) && (i = DVDCheckDiskSigs[j].offsetFoundAt)) {
u32 *DVDCheckDisk = Calc_ProperAddress(data, dataType, i * sizeof(u32));

if (DVDCheckDisk) {
switch (j) {
case 1: data[i + 50] = branchAndLink(TICKLE_READ_HOOK, DVDCheckDisk + 50); break;
case 0:
case 2: data[i + 54] = branchAndLink(TICKLE_READ_HOOK, DVDCheckDisk + 54); break;
case 3: data[i + 55] = branchAndLink(TICKLE_READ_HOOK, DVDCheckDisk + 55); break;
}
print_gecko("Found:[%s] @ %08X\n", DVDCheckDiskSigs[j].Name, DVDCheckDisk);
}
}

PatchDetectLowMemUsage(data, length, dataType);
}

Expand Down

0 comments on commit 6123f7c

Please sign in to comment.