Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Call function that takes char* as param value in auto assemb

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Full Metal Jacket
Newbie cheater
Reputation: 0

Joined: 11 Jul 2013
Posts: 14

PostPosted: Mon Oct 10, 2016 12:21 am    Post subject: Call function that takes char* as param value in auto assemb Reply with quote

I have following function(its is __cdecl after compiling) and I would like to call it in auto assembler.

Code:
void hello(const char* name)
{
   cout << "Hello " << name << endl;
}


I tried:
Code:
fullaccess(00400500,4)
alloc(MyCode,1024)
CreateThread(MyCode)

mystr:
db 'boi',0

MyCode:
push mystr
call 004016F0
ret // exit thread


in IDA call looks like:
Code:
mov     dword ptr [esp], offset aBoi ; "boi"
call    __Z7helloPKc  ; hello(char const*)


so I tried:
Code:
move dword ptr [esp], mystr
call 004016F0

but it didn't work.

Also would be nice if you could explain me why I'm giving fullaccess (to first 4 bytes?) to 400500 does it count ?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25821
Location: The netherlands

PostPosted: Mon Oct 10, 2016 4:09 am    Post subject: Reply with quote

You havn't described what happens so i assume the target process crashes

Since it's cdecl then you have to sub esp, 4 after the call

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Full Metal Jacket
Newbie cheater
Reputation: 0

Joined: 11 Jul 2013
Posts: 14

PostPosted: Mon Oct 10, 2016 5:35 am    Post subject: Reply with quote

Dark Byte wrote:
You havn't described what happens so i assume the target process crashes

Since it's cdecl then you have to sub esp, 4 after the call


Hey thank you Dark Byte it works when I added sub esp, 4. However it crashes after executing the function. What's the cause?

Before the process didn't crash, nothing happened.

EDIT:

It worked when I did add esp, 4 instead of sub dunno why but it works. Thank you very much Dark Byte you are f*** genius I wish I had knowledge you have.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Oct 10, 2016 2:24 pm    Post subject: Reply with quote

fixed
Quote:
Since it's cdecl then you have to 'add esp,4'


https://msdn.microsoft.com/en-us/library/zkwh89ks.aspx
Code:
Stack-maintenance responsibility: Calling function pops the arguments from the stack.




PS: you don't need fullaccess(00400500,4)

_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites