-
January 28th, 2012, 09:15 PM
#1
Opcodes in C++
How can you manually input opcodes in C++?
Like 8B is MOV ans so forth. (Compiler having trouble with Asm)
-
January 29th, 2012, 12:55 AM
#2
Re: Opcodes in C++
Watch out for the magic words "inline assembler". In case you're using MS Visual C++: http://msdn.microsoft.com/en-us/library/4ks26t93.aspx
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
January 29th, 2012, 02:35 AM
#3
Re: Opcodes in C++
I suppose you could do something like this:
Code:
int main()
{
const char* code = "\x90\x90\x90\x90";
void (*foo)(void) = (void (*)(void))code;
foo();
}
But I wouldn't advise it. There's also no need to go to such lengths since most compilers support inline assembly which is more useful.
-
January 29th, 2012, 07:59 AM
#4
Re: Opcodes in C++
Originally Posted by Chris_F
I suppose you could do something like this:
[...]
In principle, yes (ignoring the fact that your machine code lacks the RET instruction, causing it to lead to a certain crash ). However exactly this is what DEP is meant to prevent, so it probably won't work on the majority of today's systems.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|