Re: How to locate compiled binary code relative to source code?
From: Gerry Quinn (gerryq_at_DELETETHISindigo.ie)
Date: 07/13/04
- Next message: Eric: "Re: OOP and memory management"
- Previous message: Corey Murtagh: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- In reply to: John Doe: "How to locate compiled binary code relative to source code?"
- Next in thread: Corey Murtagh: "Re: How to locate compiled binary code relative to source code?"
- Reply: Corey Murtagh: "Re: How to locate compiled binary code relative to source code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 13 Jul 2004 22:03:10 +0100
In article <10f7vjmj90o9173@corp.supernews.com>, nope@nospam.com says...
> Win32. I am learning about the guts of the PE format to implement modifying
> an exe
> after distribution. As an exercise I want to solve the following problem:
>
> I need to be able to identify in the compiled EXE a specific location
> relative to the source code.
>
> When it compiles, I need to be able to locate in the binary exe the offsets
> of IDENTIFIER1 and IDENTIFIER2 such that in between these offsets in the
> compiled exe image are the instructions for "some code a, b and c". I don't
> really care about IDENTIFIERs themselves - really all I want is to know is:
> exactly where the instructions are (in the binary) that are in between them
> (a,b,c).
> I thought about using a unique series of inline assembly (that does
> effectively nothing), and searching for the compiled opcodes that
> correspond - but this is very awkward since I may need numerous sequences
> which all have to be unique.
All the same, that's probably what you need. However, I don't think the
problem is as bad as you think. Let's say you identify one unique
series of assembly that does nothing, and that can get compiled reliably
by the compiler (you might have to switch off optimisations around it).
Then it should be easy to make as many unique sequences as you want.
For the sake of argument, say you can identify the following sequence:
Push register A on stack
Load A, 555555555
Pop register A from stack
You probably can, because constants of 555555555 will not appear very
often in code.
Then if you add another line after loading 5555555555:
Load A, n
..you have a distinguishable identifier for every value of n.
I don't know if the exact example above will work, but it should be
possible to do something of the kind.
- Gerry Quinn
- Next message: Eric: "Re: OOP and memory management"
- Previous message: Corey Murtagh: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- In reply to: John Doe: "How to locate compiled binary code relative to source code?"
- Next in thread: Corey Murtagh: "Re: How to locate compiled binary code relative to source code?"
- Reply: Corey Murtagh: "Re: How to locate compiled binary code relative to source code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|