Skip to content

Instantly share code, notes, and snippets.

@nattybear
Last active December 22, 2016 01:37
Show Gist options
  • Save nattybear/ff3c89a15c24643327293ba4f441b92d to your computer and use it in GitHub Desktop.
Save nattybear/ff3c89a15c24643327293ba4f441b92d to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
unsigned int convertendian(unsigned int x) {
unsigned int result = (x & 0xFF) << 24;
result| = ((x >> 8) & 0xFF) << 16;
result| = ((x >> 16) & 0xFF) << 8;
result| = ((x >> 24) & 0xFF);
return result;
}
int main(void) {
FILE *fp = fopen("sss.gba", "rb");
int offset = 0;
long filesize = 0;
unsigned int fourbite = 0;
int pointerset[2][65535] = {0};
char bite = 0;
int i;
long n = 1;
if(fp == NULL) {
printf("파일을 열 수 없습니다!\n");
return -1;
}
fseek(fp, 0, SEEK_END);
filesize = ftell(fp);
printf("filesize = 0x%X\n", filesize);
for(i = 0; i <= filesize - 3; i++) {
fseek(fp,i, SEEK_SET);
fread(&fourbite, 4, 1, fp);
convertendian(fourbite);
if(fourbite >= 0x08000000& & fourbite <= filesize + 0x08000000 - 1) {
fseek(fp, fourbite - 0x08000000 - 1, SEEK_SET);
fread(&bite, 1, 1, fp);
if(bite == 0x00) {
fseek(fp, fourbite - 0x08000000, SEEK_SET);
fread(&bite, 1, 1, fp);
if(bite >= 0x30 && bite <= 0x39 || bite == 0x3c || bite == 0x5b || bite == 0x5c || bite == 0x7b || bite == 0x81 || bite == 0x82 || bite == 0x87) {
pointerset[1][n] = i;
pointerset[2][n] = fourbite;
printf("%ld : 0x%-6X : %-8X\n", n, pointerset[1][n], pointerset[2][n]);
n = n + 1;
}
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment