OUT parameters in inline asm
-
Hey guys. Lets say, i have such function, like:
void Stuff(int A, int *B);
So as you can see,
B
is OUT parameter. The question is, how would you call it from inline assembly code? Something like this:void Some(int A){ //do something with a }
__asm
{
push 1
call dword ptr Some
}// or this
int Some(int A, int B){ // do something with variables and return some integer }
__asm
{
push 2
push 5
call dword ptr Some
// now the function result is in eax, so we can grab it and store in some variable, and do something with it later
}but how to do it with this: void Stuff(int A, int *B) ? How to get
B
? Thanks011011010110000101100011011010000110100101101110 0110010101110011
-
Hey guys. Lets say, i have such function, like:
void Stuff(int A, int *B);
So as you can see,
B
is OUT parameter. The question is, how would you call it from inline assembly code? Something like this:void Some(int A){ //do something with a }
__asm
{
push 1
call dword ptr Some
}// or this
int Some(int A, int B){ // do something with variables and return some integer }
__asm
{
push 2
push 5
call dword ptr Some
// now the function result is in eax, so we can grab it and store in some variable, and do something with it later
}but how to do it with this: void Stuff(int A, int *B) ? How to get
B
? Thanks011011010110000101100011011010000110100101101110 0110010101110011
Ok, solved it myself.
#include <windows.h>
#include <iostream>using namespace std;
void Func(int A, int *B, int *C)
{
*B += ++A;
*C *= *B + 1;
}int main()
{
int B = 3;
int C = 6;
__asm
{
lea ecx, C
push ecx
xor ecx, ecx
lea ecx, B
push ecx
push 3
call dword ptr Func
add esp, 12
}
cout << B << " : " << C << endl;
}011011010110000101100011011010000110100101101110 0110010101110011