| View previous topic :: View next topic |
| Author |
Message |
Full Metal Jacket Newbie cheater
Reputation: 0
Joined: 11 Jul 2013 Posts: 14
|
Posted: Mon Oct 10, 2016 12:21 am Post subject: Call function that takes char* as param value in auto assemb |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25821 Location: The netherlands
|
Posted: Mon Oct 10, 2016 4:09 am Post subject: |
|
|
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 |
|
 |
Full Metal Jacket Newbie cheater
Reputation: 0
Joined: 11 Jul 2013 Posts: 14
|
Posted: Mon Oct 10, 2016 5:35 am Post subject: |
|
|
| 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 |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Mon Oct 10, 2016 2:24 pm Post subject: |
|
|
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 |
|
 |
|