Quote: Originally Posted by
DeathArt
Well, the CCastle::SetWarRemainSecondTime don't work :-) Tested it allready.
Making memory pointers to methods is ofcource a option, and rather simple,
but I somehow like to attempt a raw ASM workaround first. Because I really don't like pointers.
And yeah, ASM is simple, say if we define a simple function, like this
PHP Code:
function MyFunction(int arg1,int arg2)
{
__fastcall would be in asm:[/size]
// function here
}
Then the ASM to call it is the following:
(Yes, parameters in revered order, that's how it's surposed to be)
PHP Code:
DWORD myFunction = 0x000000; // memory address
int arg1 = 1;
int arg2 = 2;
__asm {
push arg2
push arg1
call myFunction
}
than I hope for you don't fuck-up the stack .. but don't care
when you really want to use asm .. why don't use macros
PHP Code:
#define Call2Par(x, a, b) __asm{push b; push a; mov edx,x; call edx;}
...
...
Call2Par(0x0000555,Para1,Para2); //would automatical generate your asm ~.~
//should .. I am not sure.. didn't use macros for a long time..
Should work too .. :P ...
It's fast and easy to write some asm codes..
But you wont know what the compiler does before it
and after it..
there are many functiosn types like:
__stdcall
__cdcdel (<-i think it's thisway written)
__fastcall
__thiscall
__stdcall would be in asm:
PHP Code:
push para3
push para2
push para1
call function
in c++ it would be:
PHP Code:
typedef int (* TFunctionType(int,int,int);
__cdcdel would be in asm:
PHP Code:
push para3
push para2
push para1
call function
add esp,0x0C //i think esp need to get moved..
in c++ it would be:
PHP Code:
typedef int (__cdcdel* TFunctionType(int,int,int);
__fastcall would be in asm:
PHP Code:
push para3
push para2
push para1
mov ecx,classe //most time used ECX
mov edx,classe //also able to use, maybe ebx i am not sure xD
call function
in c++ it would be:
PHP Code:
typedef int (__fastcall* TFunctionType(int myECX,int myEDX, int,int,int);
__thiscall.. would be like __fastcall
And the functions in MainSvr are ..yeah most of functions of classes..
mean you need to use "__fastcall" otherwise the function wont know whos the owner..
This also means you first need to steal the owner.. or better get a pointer to the owner.. or you can't use the function right !
Like this:
sampel:
PHP Code:
//i onyl suse this to show basic the parametrs of the functiosn aren't right !!!
void CustomMob()
{
DWORD MyMOB=CMob_Create(...); //you will get a pointer to a class .. this function is i belive a __stdcall
CMob_Spawn(MyMOB,NULL,...); //this function would be a __fastcall
//it's the same like using MyMob->Spawn .. but since we can't use it..
CMob_Delete(MyMOB,NULL); //again __fastcall or the function wont know whos the owner !!
}
/*
I don't know if this functions are existing
or you use these so..
I only wanted to show why it's important to use __fastcall xD
At these functions..
*/