So I've been screwing around with the __asm block in VS2010 and I haven't been able to find a better way to get the pointer to the start of the assembly block.
The only way I know how to do this, is to declare a void function. One problem with this is that the void function will have its own assembly before and after my assembly block and I would have to compensate by getting the real address of the function and adding an offset.
Example:
c++
void myfunc(){
__asm{
nop
nop
nop
ret
}
}
Would result in assembly similar to this:
push ebp
mov ebp,esp
add esp,8
nop
nop
nop
retn
mov esp,ebp
pop ebp
retn
myfunc() would most likely error if executed.
You basically want to enable __declspec(naked) on your function, to avoid the compiler-generated prologue and epilog.
See also: http://msdn.microsoft.com/en-us/library/h5w10wxs(v=vs.80).aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.