GCF File Format - NemPosted: Feb 1st, 2004 - 12:40:07 pm

Jed of wunderboy.org and I have contributed on a GCF file format specification complete with source code snippets from GCFScape. You can check it out here. You can also find an open source implementation of the GCF file format in the HLLib package library found here.

Modified: Sep 11th, 2005 - 11:18:22 am[ 15534 Views ]

1. sabbathPosted: Feb 8th, 2004 - 1:26:42 pm

=]

2. joe Tha mofoPosted: Jul 26th, 2004 - 12:58:28 pm

yelling Where can i get the m$ .net framework?

3. NemModified: Jul 26th, 2004 - 1:28:41 pm

4. Da_FileServerModified: Mar 2nd, 2006 - 12:43:49 am
Not sure if this is where to put it, but I figured out the GCF checksum algorithm and wrote an implementation in C.

Note that the adler32 and crc32 functions were used from the zlib source code.

Code:

// actual checksum algorithm
unsigned long gcf_checksum(unsigned long checksum, unsigned char * buffer, unsigned long buffersize)
{
return adler32(checksum, buffer, buffersize) ^ crc32(checksum, bufer, bufersize);
}

#define CHUNK_SIZE 32768
int main(int argc, char * argv[])
{
if(argc >= 2)
{
int i;
long file_size;
unsigned char file_chunk[CHUNK_SIZE];
FILE * file = NULL;
file = fopen(argv[1], "rb");
if(file == NULL)
{
printf("File could not be opened.\r\n");
goto END;
}
// get file size
fseek(file, 0, SEEK_END);
file_size = ftell(file);
fseek(file, 0, SEEK_SET);

// calculate checksums for every 32768 bytes
for(i = 0; i < file_size / CHUNK_SIZE; i++)
{
fread(file_chunk, CHUNK_SIZE, 1, file);
printf("Checksum: 0x%08X\r\n", gcf_checksum(0, file_chunk, CHUNK_SIZE));
}
// checksum any straggler bytes at the end
file_size = file_size % CHUNK_SIZE;
if(file_size > 0)
{
fread(file_chunk, 1, file_size, file);
printf("Checksum: 0x%08X\r\n", gcf_checksum(0, file_chunk, file_size));
}

// finally, close the handle
fclose(file);
}

END:
#ifdef _DEBUG
printf("\r\nPress any key to continue...");
getchar();
printf("\r\n");
#endif
return 0;
}

You must be logged in to post a comment.
New users can register here.
Nem's Tools v2.0 © 2006 Ryan Gregg.
Execution time: 0.027929s; Queries: 17.
dishes served.
Powered by The Wavelength.

Valid XHTML 1.0 Transitional Valid CSS
π