Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * fname.c
- * by Reisyukaku
- *
- * Quick and dirty parser for filename.bin in Senran Kagura: EV
- */
- #include <stdio.h>
- #include <stdint.h>
- #include <malloc.h>
- typedef uint32_t u32;
- typedef uintptr_t uPtr;
- int main(int argc, char **argv){
- if(argc < 2){
- printf("Usage: %s <filename.bin>\n", argv[0]);
- return -1;
- }
- FILE *bin;
- size_t fileSize = 0;
- u32 *buf;
- uPtr stringTable = 0;
- u32 totalStrings = 0;
- bin = fopen(argv[1], "rb");
- if(!bin){
- printf("File unable to be opened!\n");
- return -1;
- }
- fseek(bin, 0, SEEK_END);
- fileSize = ftell(bin);
- fseek(bin, 0, SEEK_SET);
- buf = malloc(fileSize);
- fread(buf, 4, fileSize/4, bin);
- fclose(bin);
- stringTable = buf[2];
- totalStrings = buf[1];
- char **stringArray = malloc(totalStrings * sizeof(char*));
- u32 i; for(i = 0; i < totalStrings - 1; i+=2){
- stringArray[i/2] = (void*)buf+((uPtr)buf[i+2]);
- printf("String #%04d [0x%06X] %s\n",
- i/2,
- (uPtr)buf[i+2],
- stringArray[i/2]
- );
- }
- free(buf);
- free(stringArray);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement