I'm using a endscene hook in order to inject some asm code and use DoString. I'm just annoyed that I don't really understand what was going on so I read a bit. I've learned a lot, although I'm still a noob. But I have a few questions.
This is the asm code provided in one the examples for DoString :
Code:
"mov eax, " + DoStringArg_Codecave, //Put the CodeCave pointer in the EAX register
"push 0", //Push 0 in the stack
"push eax", //Push the code cave pointer
"push eax", //Push the code cave pointer again
"mov eax, " + FrameScript__Execute, // move the FS_execute pointer to eax
"call eax", //we call the function located at the pointer address, DoString in our case
"add esp, 0xC", //clean the space that arguments used on the stack
"retn", //we return to the parent
Looking at the FS Execute function in IDA, I can see that it takes three arguments. However, I don't know how to find out what type the arguments should be ? From looking at DoString, I guess it looks this way DoString(codecave pointer, codecavepointer, bool ?).
That's all right, but if I wanna call a function that is not DoString or GetlocalizedText, how would I go about finding what arguments I should put on the stack for my function call to work properly ?
As an example, GetQuestTitle takes one argument, how do I trace the type of arguments and what it should be in order to be able to call it ?
One last question if I may,
Code:
"call " + (uint)ClntObjMgrGetActivePlayerObj,
"mov ecx, eax", //EAX contains the return value from the previous call
"push -1",
"mov edx, " + Lua_GetLocalizedText_Space + "",
"push edx",
"call " + (uint)FrameScript__GetLocalizedText,
"retn",
Why do we call ClntObjMgrGetActivePlayerObj ? We put the return value in EAX, then in ECX, but if we look at the function itself
Code:
FrameScript__GetLocalizedText proc near
arg_0= dword ptr 8
arg_4= dword ptr 0Ch
push ebp
mov ebp, esp
push ebx
push esi
mov esi, ecx
mov eax, [esi+8]
mov ebx, [eax+4]
push edi
mov edi, [eax]
call ClntObjMgrGetActivePlayer
It never uses the value in ECX, it justs erases it the next block after the conditional jump "mov ecx, [esi+0F8h]".
What am I missing ? Thx for any tips, sorry it this has been asked before but I haven't found anything about it in the numerous DoString thread. I want to understand how this works before going further in my learnings.