This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Trying to use libbfd to lookup symbol offset in PE/COFF (Windows) library.



> -----Original Message-----
> From: Zac Salwasser [mailto:zsalwasser@gmail.com]
> Sent: Thursday, July 22, 2010 16:52
> To: Pavel Pavlov
> Cc: binutils@sourceware.org
> Subject: Re: Trying to use libbfd to lookup symbol offset in PE/COFF
> (Windows) library.
> 
> Thanks for your prompt reply.
> 
> I read what you wrote in the thread titled "read/write header characteristics
> of Win32/PE executable."  I believe that using the WinAPI, isn't an option as
> I'm trying to unpack a Windows library on a Linux host.  Using the reference
> documentation to roll my own solution
> *was* an option on the table, but just this afternoon I figured out how to
> extend libbfd to do what I want, so barring any last minute answers along the
> lines of "oh, yeah, just call "bfd_get_symbol_offset(bfd *abfd, char
> *symbol_name)," I think I'm going to finish my 9/10th's complete extension
> of libbfd.


If eventually it isn't going to work for you may try the winapi route. Winapi route doesn't mean that you need to be on windows or to use any winapi package at all!
To do your task you will need definition of 5-10 structures only. You can simply copy them over to your code.
Look at ontl image.hxx, line 56:
http://code.google.com/p/ontl/source/browse/trunk/ntl/pe/image.hxx
the definition of dos_header is a simple structure. When you read a winpe dll or exe, the first 40 or so bytes are actually this dos_header structure, which is defined as IMAGE_DOS_HEADER struct in winnt.h:
http://www.google.com/codesearch/p?hl=en#t4cUIrRdV2U/gnu/mingw/w32api-2.2.tar.gz|_bfdnCOqqH0/include/winnt.h&q=IMAGE_DOS_HEADER&l=2245




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]