I was wondering if it is possible to call printf for example without declaring the format array in the data segment. This question is regarding x86.
#include <stdio.h>
int main()
{
__asm
{
push 1 ; number to print
push 3710092110 ; format in ascii for %d\n
call printf
add esp, 8
}
return 0;
}
Ok so we need to push the address of the format instead of the format itself so something like this should be close enough right?
#include <stdio.h>
int main()
{
__asm
{
push 3710092110 ; 3710092110 = format in ascii for %d\n
push 1; argument to print
lea edx, dword ptr[esp + 4]; get address of the format on stack
push edx ; push the address of the format
call printf
add esp, 12
}
return 0;
}
Do you guys happen to have the time to demonstrate a working example? Can't find anything on the internet about it.