how to write a function in a file at binary level (after compilation)
-
I know this may look a little more than a little strange! But for a reason I want to write a whole function in a file at run-time. OK, let's do some clarification: see you have a function like:
void foo ()
{
your code ...
}after compilation we have some thing like:
// foo()
push 210
mov eax, ebx
...and in binary level:
// foo()
E8 00 DA 65 00 00 DF
What I need is to write these binary codes in a file. Note 1- There's no such an instruction like
mov eax, eip
orpop eip
in Intel instruction set. Actually there's no instruction to get or set eip directlt.Thank you masters!
-
I know this may look a little more than a little strange! But for a reason I want to write a whole function in a file at run-time. OK, let's do some clarification: see you have a function like:
void foo ()
{
your code ...
}after compilation we have some thing like:
// foo()
push 210
mov eax, ebx
...and in binary level:
// foo()
E8 00 DA 65 00 00 DF
What I need is to write these binary codes in a file. Note 1- There's no such an instruction like
mov eax, eip
orpop eip
in Intel instruction set. Actually there's no instruction to get or set eip directlt.Thank you masters!
Why don't you get the compiler output?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Why don't you get the compiler output?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]because I need to write it anywhere I want. I don't want to use the simple copy-paste method.
-
because I need to write it anywhere I want. I don't want to use the simple copy-paste method.
The you have to write a compiler... :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I know this may look a little more than a little strange! But for a reason I want to write a whole function in a file at run-time. OK, let's do some clarification: see you have a function like:
void foo ()
{
your code ...
}after compilation we have some thing like:
// foo()
push 210
mov eax, ebx
...and in binary level:
// foo()
E8 00 DA 65 00 00 DF
What I need is to write these binary codes in a file. Note 1- There's no such an instruction like
mov eax, eip
orpop eip
in Intel instruction set. Actually there's no instruction to get or set eip directlt.Thank you masters!
As I understand it, you want to include in your executable, a number of Datablocks which you want to use as prototype executable files, to be called by your process. This can be done, and I've done it. If that's what you want, it also requires No ASM Code to implement! :)
Bram van Kampen