Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot General Programming How to call a function an address?

 
  • 0 Vote(s) - 0 Average
How to call a function an address?
oukibt
Offline

Burgershot Member
Posts: 1
Threads: 1
Joined: Jul 2020
Reputation: 0
Location: Ukraine
#1
2021-07-06, 09:36 PM (This post was last modified: 2021-07-06, 09:37 PM by oukibt.)
Hi I am trying to call a function at an address from a plugin but I am getting a crash.

Code:
PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX* amx)
{
    VirtualUnlock((LPVOID)0x48B5B0, 0x20);

    ((int(__fastcall*)(char*))0x48B5B0)("query");
    return 1;
}

https://cdn.discordapp.com/attachments/5...nknown.png

I think, this is GetConsoleVariableInt function
SimoSbara
Offline

Burgershot Member
Posts: 14
Threads: 0
Joined: Apr 2019
Reputation: 2
#2
2021-07-14, 08:53 PM
(2021-07-06, 09:36 PM)oukibt Wrote: Hi I am trying to call a function at an address from a plugin but I am getting a crash.

Code:
PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX* amx)
{
    VirtualUnlock((LPVOID)0x48B5B0, 0x20);

    ((int(__fastcall*)(char*))0x48B5B0)("query");
    return 1;
}

https://cdn.discordapp.com/attachments/5...nknown.png

I think, this is GetConsoleVariableInt function

Hi, can you show the crash log, if there is one.

Maybe you should try to cast the address with __stdcall. Another thing you can check is the return value of VirtualUnlock, if the return value is zero then you should look at GetLastError(). 

I suggest to read this documentation before doing this kind of stuff: https://docs.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-160.
3D modeler on Blender - OOP and functional programming programmer
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode