add a little tool
This commit is contained in:
parent
94e96392fe
commit
0e58e9e8c4
4
Makefile
4
Makefile
@ -1,7 +1,7 @@
|
|||||||
DATA = $(word 1,$(wildcard ./data ../data))
|
DATA = $(word 1,$(wildcard ./data ../data))
|
||||||
include $(DATA)/Makefile.common
|
include $(DATA)/Makefile.common
|
||||||
|
|
||||||
BINS := check_sanity make_kernel_patchfile apply_patchfile sandboxc.c
|
BINS := check_sanity make_kernel_patchfile apply_patchfile dump_range sandboxc.c
|
||||||
all: .settings .data $(BINS)
|
all: .settings .data $(BINS)
|
||||||
.data:
|
.data:
|
||||||
make -C $(DATA)
|
make -C $(DATA)
|
||||||
@ -18,6 +18,8 @@ apply_patchfile: apply_patchfile.o $(DATA)/libdata.a
|
|||||||
$(GCC) -o $@ $^ $(DATA)/libdata.a
|
$(GCC) -o $@ $^ $(DATA)/libdata.a
|
||||||
make_kernel_patchfile: make_kernel_patchfile.o sandboxc.o $(DATA)/libdata.a
|
make_kernel_patchfile: make_kernel_patchfile.o sandboxc.o $(DATA)/libdata.a
|
||||||
$(GCC) -o $@ $^ $(DATA)/libdata.a
|
$(GCC) -o $@ $^ $(DATA)/libdata.a
|
||||||
|
dump_range: dump_range.o $(DATA)/libdata.a
|
||||||
|
$(GCC) -o $@ $^ $(DATA)/libdata.a
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(BINS) *.o
|
rm -f $(BINS) *.o
|
||||||
|
@ -52,7 +52,7 @@ int main(int argc, char **argv) {
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("%s\n", name);
|
printf("%s (0x%x)\n", name, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy((char *) kernel.start + range_to_off_range((range_t) {&binary, addr, size}).start, stuff, size);
|
memcpy((char *) kernel.start + range_to_off_range((range_t) {&binary, addr, size}).start, stuff, size);
|
||||||
|
15
dump_range.c
Normal file
15
dump_range.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <data/common.h>
|
||||||
|
#include <data/binary.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if(argc != 4) {
|
||||||
|
fprintf(stderr, "Usage: dump_range binary start len\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
struct binary binary;
|
||||||
|
b_init(&binary);
|
||||||
|
b_load_macho(&binary, argv[1], false);
|
||||||
|
prange_t pr = rangeconv((range_t) {&binary, parse_hex_uint32(argv[2]), parse_hex_uint32(argv[3])});
|
||||||
|
write(1, pr.start, pr.size);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user