/****************************************************************
0WINCEOS.BIN -> 1ST_READ.BIN Converter v1
usage: bincon <0WINCEOS.BIN file> <new 1ST_READ.BIN to create>
example: bincon 0WINCEOS.BIN 1ST_READ.BIN
It does what it says it does. I gave the option of
naming the file names just incase someone didn't want
them to have the exact names.
Works on: Midway Aracde Classics - 100%
Sega Rally 2 - 100%
Rearview Mirror WinCE Dev Kit Demo - 100%
Source released under the GNU General Public License:
http://www.fsf.org/copyleft/gpl.html
by dopefish on 7/28/00
bincon.c
*****************************************************************/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *buffer;
FILE *infile, *outfile;
long lsize;
/* Argument check */
if (argc != 3) {
fprintf(stderr, "Usage: bincon <0WINCEOS.BIN file> <new 1ST_READ.BIN to create>\n");
fprintf(stderr, "Example: bincon 0WINCEOS.BIN 1ST_READ.BIN\n");
return 0;
}
/* Open 0winceos.bin + error check*/
infile = fopen(argv[1], "rb");
if (infile == NULL) {
fprintf(stderr, "Error: cannot open %s.\n", argv[1]);
return 0;
}
/* Get size of 0winceos.bin */
fseek(infile, 0, SEEK_END);
lsize = ftell(infile);
rewind(infile);
/* Malloc + error check */
buffer = (char *) malloc(lsize);
if (buffer == NULL) {
fprintf(stderr, "Not enough free memory or memory allocation error.\n");
return 0;
}
/* Move ptr to point we want to start at, read to mem, close 0winceos.bin */
fseek(infile, 2048, SEEK_SET);
fread(buffer, 1, lsize, infile);
fclose(infile);
/* Create file to write to w/ error check */
outfile = fopen(argv[2], "wb");
if (outfile == NULL) {
fprintf(stderr, "Error: cannot create %s.\n", argv[2]);
return 0;
}
/* Write full buffer to file then the last 2k again */
fwrite(buffer, 1, lsize-2048, outfile);
fwrite(buffer + (lsize - 4096), 1, 2048, outfile);
/* Free memory, close up the last file */
free(buffer);
fclose(outfile);
return 0;
}
Click to expand...