Raised This Month: $51 Target: $400
 12% 

Solved SDKCall with CPU register parameters


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
helloworlds
Junior Member
Join Date: Oct 2022
Old 09-05-2023 , 21:55   SDKCall with CPU register parameters
Reply With Quote #1

I'm trying to call a C++ method from a class that doesn't derive from CBaseEntity/CBasePlayer, but since it's using Microsoft's thiscall convention, I'd presumably have to pass the "this" pointer in ECX for this to work. Is there any way to achieve this in pure SourceMod, or am I out of luck? I did find this issue, but the related PR seems dead years ago: https://github.com/alliedmodders/sourcemod/issues/1850

If SDKCall is no go, is there any way to use DHooks for this? I know it allows me to specify parameter CPU registers, but I'm interested in calling the function, not detouring it.

Last edited by helloworlds; 09-11-2023 at 21:32. Reason: solved
helloworlds is offline
Vit_amin
Senior Member
Join Date: Dec 2015
Location: Russian Federation
Old 09-06-2023 , 08:40   Re: SDKCall with CPU register parameters
Reply With Quote #2

Hello. Currently you may use this method, until moment when SDKCall get support for registers as params

Last edited by Vit_amin; 09-06-2023 at 08:40.
Vit_amin is offline
helloworlds
Junior Member
Join Date: Oct 2022
Old 09-11-2023 , 21:31   Re: SDKCall with CPU register parameters
Reply With Quote #3

Thanks! It turned out in my case I could simply use SDKCall_Raw, and pass the "this" pointer address as my parameter (instead of some entity index), but the malloc trampoline trick pointed me in the right direction.
helloworlds is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode