0

I am trying to call this function in a c++ dll:

public static void AskTrade(string traderPartnerId)

What I do to call this is:

auto Trade = reinterpret_cast<void(*)(std::string)>(BaseAddress + 0xDE54B0);
Trade(D39DSAR2);

It is inside of a special void that makes the calling work. Because when I call functions without any variables or functions with int as variables, it does work.
But when I try to call this, nothing happens. The game is c# and I code in c++, that must be the reason I guess. I don't know how to fix it though.
I would very much appreciate it if any of you would know and tell me a solution.

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
  • 2
    where did you take those hexadecimal values ? what makes you think they would work ? – Jeffrey Jul 22 '21 at 21:05
  • @Jeffrey it is the address of what the function has. In this case, it is GameAssembly.dll+DE54B0. I used il2cppdumper and put that into dnspy, that's where I get that function from. And I think this should work because I call functions this way, just strings don't work. – user15816426 Jul 22 '21 at 21:09
  • Are you sure you have the right call convention ? (__cdecl, __stdcall, __fastcall,) – Jeffrey Jul 22 '21 at 21:13
  • 4
    A `C#` String and a `C++` `std::string` are not the same thing. – Retired Ninja Jul 22 '21 at 21:13
  • How can I make it work then? Is there a way for me to do something so I can use strings? @RetiredNinja – user15816426 Jul 22 '21 at 21:17
  • 1
    Handy reading: [Marshaling – what is it and why do we need it?](https://stackoverflow.com/questions/2240804/marshaling-what-is-it-and-why-do-we-need-it) – user4581301 Jul 22 '21 at 21:23

0 Answers0