+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Data removal from a large file
Pages: [1]
Author Topic: Data removal from a large file  (Read 391 times)
Gideon Zhi
Guest
« on: October 24, 2006, 11:41:19 pm »

So I've got this 932 megabyte superbinary that contains a ton of smaller binaries, and I need to chop the first $10800 bytes off of the front of it. It's a pointer table to all of the files inside the file; the pointer addresses, I believe, are relative as of $10800, so I'd like to chop it out to make things easier. Anyone have any suggestions for how to do this that don't involve Hex Workshop? It bitched at me when I tried to save the file.
DaMarsMan
Guest
« Reply #1 on: October 25, 2006, 12:00:58 am »

I had to do this for DQ5. Just read in the filenames and pointers using c# and output them to files. Then code a program to put them all together. Probably will only take a half hour or so.
D
Guest
« Reply #2 on: October 25, 2006, 12:14:05 am »

Gid: Please look at my Heroine Anthem or Langrisser 1 tools, or that universal resource extractor code I posted before.

They are all exactly what you need.
tomaitheous
Guest
« Reply #3 on: October 25, 2006, 09:37:41 am »

I'd just write a C++ console program - open input and output files, fseek pass $10800 on the source, and then start copying bytes until EOF on source.
byuu
Guest
« Reply #4 on: October 25, 2006, 10:33:04 am »



Code:
#include <stdio.h>

int main(int argc, char *argv[]) {
  if(argc != 3) { printf("usage: chop <input> <output>\\n"); return 0; }
FILE *fp = fopen(argv[1], "rb");
FILE *wr = fopen(argv[2], "wb");
  fseek(fp, 0, SEEK_END);
int filesize = ftell(fp);
  fseek(fp, 0x10800, SEEK_SET); //feof() annoys me for some reason
  for(int i = 0x10800; i < filesize; i++) {
    fputc(fgetc(fp), wr);
  }
  fclose(fp);
  fclose(wr);
  printf("finished\\n");
  return 0;
}
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC