So I feel like this is very straightforward, but I'm trying to hook this function:
Code:
int _Format_string(int arg0, ...)
{
int result; // eax@2
va_list va; // [sp+34h] [bp+Ch]@1
int *v3; // [sp+38h] [bp+10h]@2
va_start(va, arg0);
if ( *(_BYTE *)(arg0 + 4) & 0x40 )
result = sub_4F49E6(arg0, 4u, *(const char **)va, &v3);
return result;
}
I can hook it just fine, but I don't understand how I can actually print out the variable it is formatting. Note: in the particular instance I'm debugging, it never gets to sub_4F49E6.
Here is the assembly:

This is what I've *tried* to do:
Code:
int (*_real_Format_string)(int destination, ...);
int _hook_Format_string(int destination, ...)
{
printf("--- _Format_string ---\n");
printf(" 0x%X at 0x%X \n", destination, (unsigned int)&destination);
int res = (int)(*_real_Format_string)( destination );
printf( " Result: 0x%X 0x%X\n", res, &res);
return res;
}
And it hooks the function just fine, but I have NO idea how to actually print out the string that is being passed to it. (Note: I actually call a breakpoint w/GDB, then view the memory location in a GUI, and it's not a string, so I'm thoroughly confused).
Here is calling the actual function:
Code:
_Format_string(v8, "Revision %d, Version %d.%d.%d.%d\n", *(_DWORD *)(v8 + 4336), 4, 26, 1, 8);
Thanks in advance, I have literally been trying to figure this out for the past 2 hours.