-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdlb2doj.cpp
75 lines (61 loc) · 1.72 KB
/
dlb2doj.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <ctype.h>
#include "functionblocks.h"
#include "functions.h"
#include "dlbreader.h"
#define ERR -1
#define MAX_PATH 512
int main(int argc, char *argv[])
{
char *filename, outdir[MAX_PATH]="";
int c;
printf("VisualDSP Elf Reverse Engineering Toolkit by Andreas Schuler (andreas at schulerdev.de)\n");
while((c=getopt(argc,argv,"o:"))!=-1)
{
switch(c)
{
case 'o':
strncpy(outdir,optarg,MAX_PATH-2);
if(outdir[strlen(outdir)-1]!='/')
strcat(outdir,"/");
break;
case '?':
/* if ( optopt=='o')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
else if (isprint (optopt))
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
else
fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
*/
printf("Exit with errors...\n");
return 1;
default:
printf("Usage: dlb2doj -o outputdir filename\n");
abort();
}
}
if(optind<argc)
filename=argv[optind];
else
{
printf("Usage: dlb2doj -o outputdir filename\n");
abort();
}
if(strlen(outdir))
mkdir(outdir,0777);
//extract dlb lib
dlbreader *dlb=new dlbreader(filename,outdir,1);
char name[256];
while(dlb->write_next_file(name,256))
{
printf("Extracting %s%s\n",outdir,name);
}
}