PDA

View Full Version : Example Extractor Source


snOop2k2
08-16-2002, 10:23 PM
Here is an example source from the Transworld Surf Extractor by me and Bart

:lol:


#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <direct.h>
#include <ctype.h>


void ps2convert (char original[8]);
long hex2dec (void);
char ps2conv[8];

void main()
{

unsigned char Byte1, Byte2, Byte3, Byte4;
char temp, filesize[9], filestart[9], file_number[5], gen_name[5];
long size_count, file_pos, file_size;
int filenum=0, loop;


FILE *bigfile_ptr, *output_ptr, *table_ptr;


printf("Transworld Surfing TWSAUD.DAT Extractor");
printf("\nProgrammed by snOop2k2 and Bart");
printf("\nPress Enter to start extraction");
temp=getchar();
bigfile_ptr=fopen("TWSAUD.DAT", "rb");
table_ptr=fopen("TWSAUD.DAT", "rb");

_mkdir("extracted");
_chdir("extracted");
_mkdir("music");
_chdir("music");

//Go to Position where table starts
fseek(table_ptr,12580,SEEK_SET);

for(loop=0; loop<69; loop++) // THIS IS WHERE THE LOOP STARTS
{

//Read next 4 bytes, this is the File Position
fread(&Byte1,sizeof (char), 1, table_ptr);
fread(&Byte2,sizeof (char), 1, table_ptr);
fread(&Byte3,sizeof (char), 1, table_ptr);
fread(&Byte4,sizeof (char), 1, table_ptr);

//Remember 4 bytes in HEXBYTES
sprintf (filestart, "%02X%02X%02X%02X", (unsigned long) Byte1, Byte2, Byte3, Byte4);

ps2convert(filestart); //Sony Reverse File_pos
file_pos=hex2dec(); //Convert that to DECIMAL

//We have the FileStart now, the next 4 bytes is the FileSize
fread(&Byte1,sizeof (char), 1, table_ptr);
fread(&Byte2,sizeof (char), 1, table_ptr);
fread(&Byte3,sizeof (char), 1, table_ptr);
fread(&Byte4,sizeof (char), 1, table_ptr);
sprintf (filesize, "%02X%02X%02X%02X", (unsigned long) Byte1, Byte2, Byte3, Byte4);
ps2convert(filesize);
file_size=hex2dec();
//We got both
//Lets extract!
itoa(filenum, file_number, 10);
strcpy(gen_name, "music");
strcat(gen_name, file_number);
strcat(gen_name, ".stm");
filenum++;
printf("Extracting %s" ,gen_name);
output_ptr=fopen(gen_name, "wb");
fseek(bigfile_ptr, file_pos, SEEK_SET);
size_count=0;

while(size_count<file_size)
{
fread(&Byte1,sizeof (char), 1, bigfile_ptr);
fwrite (&Byte1,sizeof (char), 1, output_ptr);
size_count=size_count+1;
};
fclose(output_ptr);

fseek(table_ptr, 8, SEEK_CUR); // Move 8 bytes forward in the table before starting next loop


} // END OF LOOP

}






void ps2convert (char original[8]) // Function To Swap Bytes To/From PS2 Format
{

ps2conv[0]=original[6];
ps2conv[1]=original[7];
ps2conv[2]=original[4];
ps2conv[3]=original[5];
ps2conv[4]=original[2];
ps2conv[5]=original[3];
ps2conv[6]=original[0];
ps2conv[7]=original[1];
ps2conv[8]='\0';



}



long hex2dec (void) // Converts Hex To Decimal
{

long temp=0, temp2[8];
int convert[8], indx;


for(indx=0;indx<8;indx++)
{
if(ps2conv[indx]=='0') convert[indx]=0;
if(ps2conv[indx]=='1') convert[indx]=1;
if(ps2conv[indx]=='2') convert[indx]=2;
if(ps2conv[indx]=='3') convert[indx]=3;
if(ps2conv[indx]=='4') convert[indx]=4;
if(ps2conv[indx]=='5') convert[indx]=5;
if(ps2conv[indx]=='6') convert[indx]=6;
if(ps2conv[indx]=='7') convert[indx]=7;
if(ps2conv[indx]=='8') convert[indx]=8;
if(ps2conv[indx]=='9') convert[indx]=9;
if(ps2conv[indx]=='A') convert[indx]=10;
if(ps2conv[indx]=='B') convert[indx]=11;
if(ps2conv[indx]=='C') convert[indx]=12;
if(ps2conv[indx]=='D') convert[indx]=13;
if(ps2conv[indx]=='E') convert[indx]=14;
if(ps2conv[indx]=='F') convert[indx]=15;


}

temp2[7]=convert[7];
temp2[6]=(convert[6]*16);
temp2[5]=((convert[5]*16)*16);
temp2[4]=(((convert[4]*16)*16)*16);
temp2[3]=((((convert[3]*16)*16)*16)*16);
temp2[2]=(((((convert[2]*16)*16)*16)*16)*16);
temp2[1]=((((((convert[1]*16)*16)*16)*16)*16)*16);
temp2[0]=(((((((convert[0]*16)*16)*16)*16)*16)*16)*16);


for(indx=0;indx<8;indx++)
temp=temp+temp2[indx];

return temp;

}

FlyingDutchman
09-23-2002, 12:43 PM
nobody replied as of yet?
what a shame! :)
good stuff man! now finally my C knowlegde is going to be put to use! :D

Trailer Trash
12-16-2002, 09:04 PM
I'm near the end on my first semester of C++ and I can read some of that. Strange!!

You do any other code?

bolbort
02-26-2003, 08:57 AM
:) Thanks snoop buddy :)

BOLBORT

Simon Tibbett
05-10-2003, 10:46 AM
What about you make one for Gran Turismo Concept?;) PLEASE!:D

gmeak
05-17-2003, 12:14 AM
hey im doin enter the matrix ntsc cd version and i already removed the dvd protection using hex workshop

now i have 2 large .dfu files i need to be opened so i can get in them and make thing smaller then seal it back up can that code above be used?

psxnomad
05-24-2003, 09:03 PM
now what exactly does this do?

darkman1
09-02-2003, 08:39 PM
i like that guys name^^^^^^^^^^^^^

bounce...bounce...bounce


sweetness

KRISHNAMURTI
10-21-2003, 05:57 AM
HE! HE!...BOUNCE!....HU?....SORRY!...I WONDER IS ANY ONE KNOW HOW TO BURN FROM COMPUTER OR RUN ANY DISK DVD OR MAYBE A CLUE?...........I NEED HELP?

Zen_pt
03-18-2004, 10:31 AM
Only saw this post today, quite nifty code.
Maybe i'll start developing some tools also.

Oldskool Obscure C++:

void ps2convert (char original[8])
{
for (int i=0; i<8; i++)
ps2conv[i]=original[ 6 - i + 2*(i%2) ];

ps2conv[8]=''; //maybe not needed
}

Haven't tested it yet, but it *should* work :lol: