Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
01f3cb19
Commit
01f3cb19
authored
May 02, 2012
by
Alejandro Mery
Browse files
bin2fex: sweep sections list
parent
544b9e78
Changes
2
Hide whitespace changes
Inline
Side-by-side
bin2fex.c
View file @
01f3cb19
...
...
@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sunxi-tools.h"
#include "bin2fex.h"
#include <errno.h>
#include <unistd.h>
...
...
@@ -27,12 +28,45 @@
#define errf(...) fprintf(stderr, __VA_ARGS__)
static
int
decompile
(
void
*
bin
,
size_t
bin_size
,
int
out
,
const
char
*
out_name
);
static
int
decompile_section
(
void
*
bin
,
size_t
bin_size
,
struct
script_section
*
section
,
int
out
,
const
char
*
out_named
);
/**
*/
static
int
decompile
(
const
char
*
bin
,
size_t
bin_size
,
int
out
,
const
char
*
out_name
)
static
int
decompile
(
void
*
bin
,
size_t
bin_size
,
int
out
,
const
char
*
out_name
)
{
errf
(
"bin size: %zu
\n
"
,
bin_size
);
return
0
;
int
i
;
struct
{
struct
script_head
head
;
struct
script_section
sections
[];
}
*
script
=
bin
;
errf
(
"bin format: %d.%d.%d
\n
"
,
script
->
head
.
version
[
0
],
script
->
head
.
version
[
1
],
script
->
head
.
version
[
2
]);
errf
(
"bin size: %zu (%d sections)
\n
"
,
bin_size
,
script
->
head
.
sections
);
/* TODO: SANITY: compare head.sections with bin_size */
for
(
i
=
0
;
i
<
script
->
head
.
sections
;
i
++
)
{
struct
script_section
*
section
=
&
script
->
sections
[
i
];
errf
(
"%s: (section:%d, length:%d, offset:%d)
\n
"
,
section
->
name
,
i
+
1
,
section
->
length
,
section
->
offset
);
if
(
!
decompile_section
(
bin
,
bin_size
,
section
,
out
,
out_name
))
return
1
;
/* failure */
}
return
0
;
/* success */
}
/**
*/
static
int
decompile_section
(
void
*
bin
,
size_t
bin_size
,
struct
script_section
*
section
,
int
out
,
const
char
*
out_named
)
{
return
1
;
/* success */
}
/**
...
...
bin2fex.h
0 → 100644
View file @
01f3cb19
/*
* Copyright (C) 2012 Alejandro Mery <amery@geeks.cl>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SUNXI_TOOLS_BIN2FEX_H
#define _SUNXI_TOOLS_BIN2FEX_H
#include <stdint.h>
struct
script_head
{
int32_t
sections
;
int32_t
version
[
3
];
};
struct
script_section
{
char
name
[
32
];
int32_t
length
;
int32_t
offset
;
};
struct
script_section_entry
{
char
name
[
32
];
int32_t
offset
;
int32_t
pattern
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment