Best way to call external function from another process memory?

Skuzzi tobias2222 at
Thu Nov 23 11:35:18 UTC 2017

Hi, I am new to D and I want to use it to create some tools that 
call certain functions from the process of a game, using an 
injected DLL written in D. I have reverse engineered the 
addresses and arguments of the function. Typically this kind of 
stuff is done with C++ and almost all the available resources 
online focus on C++. I was not able to find anything specific to 
this done in D.

This is what a function prototype might look like in C++:
typedef void (__stdcall* _function) (const char *text);
_function function;

Which you would then call using the address of the function in 
function = (_function)(ADDRESS_OF_FUNCTION);
function("Some text");

I want to do this in D. I understand that D uses "extern (C)" and 
does away with specifying calling conventions. However, how does 
D know the calling convention required? What if it is a 
__thiscall or something else, will it always be handled properly 
by D, just be specifying "extern (C)"?

Does anyone know of a proper and recommended way to achieve this 
in D? Or is this a task better suited for C++? I hope to be able 
to use D for this, as I am enjoying learning the language. Any 
help is deeply appreciated, thank you very much.

More information about the Digitalmars-d-learn mailing list