bin2fex: sweep sections list
This commit is contained in:
parent
544b9e7882
commit
01f3cb194e
40
bin2fex.c
40
bin2fex.c
@ -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 */
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
39
bin2fex.h
Normal file
39
bin2fex.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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
|
||||
Loading…
x
Reference in New Issue
Block a user