lvcabral wrote:author renamed the DAT files, I assume they hack the PRINCE.EXE
I don't know exactly what you want to do, but I'll give an example of how to figure out the name of the file with levels (default: LEVELS.DAT).
The file princehack.xml (
latest version) used by CusPop contains this section:
Code: Select all
<read name="Levels" readoperation="tolower;" default="levels.dat" writeoperation="toupper;" type="string" size="10"/>
<offset file="p0" value="0x1ae28"/>
<offset file="p3" value="0x1bb26"/>
<offset file="p4" value="0x17eaa"/>
<offset file="u0" value="0x1c984"/>
<offset file="u3" value="0x1c742"/>
<offset file="u4" value="0x1909e"/>
It gives you offsets to where the string of 10 characters is inside the executable that give you the name of the file with levels.
It lists 6 offsets: packed and unpacked variants of PoP1 executables for versions 1.0, 1.3 and 1.4. (2 x 3 = 6)
The file apoplexy.c contains this code:
Code: Select all
stat (POP1_EXECUTABLE, &stStatus);
switch ((int)stStatus.st_size)
{
case 123335:
snprintf (sEXEType, MAX_EXETYPE, "%s", "p0");
iEXEType = 0; iEXEPacked = 1; break;
case 129504:
snprintf (sEXEType, MAX_EXETYPE, "%s", "u0");
iEXEType = 1; iEXEPacked = 0; break;
case 125115:
snprintf (sEXEType, MAX_EXETYPE, "%s", "p3");
iEXEType = 2; iEXEPacked = 1; break;
case 129472:
snprintf (sEXEType, MAX_EXETYPE, "%s", "u3");
iEXEType = 3; iEXEPacked = 0; break;
case 110855:
snprintf (sEXEType, MAX_EXETYPE, "%s", "p4");
iEXEType = 4; iEXEPacked = 1; break;
case 115008:
snprintf (sEXEType, MAX_EXETYPE, "%s", "u4");
iEXEType = 5; iEXEPacked = 0; break;
default:
snprintf (sEXEType, MAX_EXETYPE, "%s", "unknown"); break;
}
It checks the number of bytes of the executable, to determine the variant.
(Careful with the different order here, e.g. p0 p3 etc. for XML, and p0 u0 etc. for C.)
This should be enough to determine the name of the file with levels.
Of course, something similar could be done with other file names.
The program
diffpop does something similar.