Commit 01f3cb19 authored by Alejandro Mery's avatar Alejandro Mery
Browse files

bin2fex: sweep sections list

parent 544b9e78
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "sunxi-tools.h" #include "sunxi-tools.h"
#include "bin2fex.h"
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
...@@ -27,12 +28,45 @@ ...@@ -27,12 +28,45 @@
#define errf(...) fprintf(stderr, __VA_ARGS__) #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); int i;
return 0; 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 */
} }
/** /**
......
/*
* 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment