Luigi Auriemma

aluigi.org (ARCHIVE-ONLY FORUM!)
It is currently 19 Jul 2012 19:09

All times are UTC [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Calling convention
PostPosted: 11 Mar 2009 01:33 

Joined: 10 Mar 2009 00:59
Posts: 10
hi,
Just a quick question :
Which arguments and which calling convention to use to call this function from CPP code,
Code:
0044BF9A  |.  8B55 C4       MOV EDX,DWORD PTR SS:[EBP-3C]
0044BF9D  |.  8D4D C8       LEA ECX,DWORD PTR SS:[EBP-38]
0044BFA0  |.  51            PUSH ECX                                 ; /Arg2
0044BFA1  |.  52            PUSH EDX                                 ; |Arg1
0044BFA2  |.  8BCB          MOV ECX,EBX                              ; |
0044BFA4  |.  E8 17F8FFFF   CALL bf2_w32d.0044B7C0                   ; \bf2_w32d.0044B7C0


Thanks :)


Top
 Profile  
 
 
 Post subject: Re: Calling convention
PostPosted: 11 Mar 2009 05:04 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
it should be __cdecl

in fact usually it's often __cdecl except the Windows APIs and some rare cases.
for example some hours ago I was taking a look to the SteamUser function of steam_api.dll where it returns a structure where is located also a pointer to a function then used by the main program to get the path of "userdata".

well in this case I needed to wrote a proxy dll for doing a test (curiosity without a purpose... ah freetime) and found that while all the exported functions in steam_api.dll must be __cdecl the internal one which gives the path of "userdata" must be __stdcall (aka WINAPI) otherwise the stack says bye bye


Top
 Profile  
 
 Post subject: Re: Calling convention
PostPosted: 12 Mar 2009 06:06 

Joined: 10 Mar 2009 00:59
Posts: 10
ok, I've tried the calling convention, but I think that my code is not correct.
I'm not an assembly expert, so here come your handy help.
I've located where a player is added to the list on the server assembly, and I think that protocol is not handled by this "player list" (connections are handled elsewhere and associated with a player?)
So, I want to connect a "ghost" on the server, yes, that do nothing but idle on the server and no connection behind that player.
Here from OllyDBG, a calling sample
Image
the parameters seem to be a pointer to a std::string or a C$tring containing the player name and a dword that appear to be always 0
Hmmm, is it depending from others value from the stack than these?


Top
 Profile  
 
 Post subject: Re: Calling convention
PostPosted: 12 Mar 2009 21:50 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
uhmm if you want to add the ghost isn't simpler to add the missing packets to bf2fp?
because I have not understood how you want to call or reach that function.


Top
 Profile  
 
 Post subject: Re: Calling convention
PostPosted: 16 Mar 2009 22:10 

Joined: 22 Dec 2007 15:57
Posts: 10
post what follows after call. if there is addition to esp, then this is cdecl. if theres no addition, its prolly stdcall.

also you can check inside callin function what it does with stack. you can read differences between stdcall, cdecl, fastcall on wiki.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: