|
CONTENTS Home Projects Electronics Graphics Java Java Mobile Other Stuff Resume Music Links To Friends Pictures Contact |
anal_elf (ELF File Format Analyzer)Related pages on www.mikekohn.net: anal_pe, anal_elf, dump_fat, amiga_explorer
The ELF File Format Key Features (from the version below)
Loading an ELF On Windows So I updated test_lib.c so instead of calling elf_open() it mallocs a chunk of memory the size of test32.so, dumps the entire library into a memory buffer, and calls elf_open_from_mem() on the buffer. Because I was running this on Windows XP with a CPU that doesn't support the NX bit, it's possible to run code out of malloc()'d RAM. Had this been done on a CPU with the NX bit and Windows supports NX, the memory would have to had been allocated using VirtualAlloc() or CreateFileMapping() with execute permissiong on the memory pages. So, after doing an elf_open_from_mem() I could find the address of my int add_nums(int,int) function using the same find_symbol_address() call and since the library was compiled as position independant code (-fPIC) I was able to call this function on Windows. Cool eh? :). The only thing left is to replace external libraries with Windows libraries. For example if printf() is on rh library import list, i could automatically replace it with a LoadLIbrary to msvcrt.dll's printf(). How To Use So after typing "make" in the anal_elf directory, 3 things will be
built: anal_elf, test.so, and test32.so. The anal_elf program is
just a simple program to parse out sections from an elf file and display
them similar to objdump and readelf. So to test this, type: So lastly, anal_elf can be compiled as a library and used in other programs also. Typing "make lib" will create a libanal_elf.so that can be linked into other programs. I included a sample program called test_lib.c that demonstrates simply opening up a library, returning a pointer to a function, and calling that function. Download
Copyright 1997-2010 - Michael Kohn
This page was designed to work with all standard HTML compatible web browsers including Firefox, IE, Safari, and Links. |