There are two functions registered by this plugin: inject() and startWithDll(). Both functions return true on success, false on failure.
For our examples, we will assume that the DLL we wish to inject is named injectme.dll and is in the micromacro/data folder. The program we wish to launch will be game.exe inside of C:/Game/, and has a window title "Game v1.0".
bool,string inject(window, dll)
Injects into a running process. 'window' should be an HWND, found by using findWindow or similar functions. 'dll' should be the full path to the DLL (Dynamic Link Library) you wish to inject into that process. On error, this function also returns a second value that contains an error string.
Example:
Code: Select all
local success,msg = inject(findWindow("Game v*"), getPath() .. "/data/injectme.dll");
if( success == false ) then
printf("Injecting injectme.dll into Game has failed: %s\n", msg);
end
bool,string startWithDll(dll, target [, command])
Starts 'target' with command line 'command' and injects 'dll' into it at start. 'dll' and 'target' should be the full path (again, use getPath() if relative to MicroMacro's root directory). Specifying 'command' is optional, and should only be used if the application you are injecting into requires certain command line parameters (see below for more information). On error, this function also returns a second value that contains an error string.
Example (basic):
Code: Select all
local success,msg = startWithDll(getPath() .. "/data/injectme.dll", "C:/Game/game.exe");
if( success == false ) then
printf("Injecting injectme.dll into Game has failed: %s\n", msg);
end
Example (command line):
Code: Select all
local success = startWithDll(getPath() .. "/data/injectme.dll", "C:/Game/game.exe", "game.exe start game");
if( success == false ) then
printf("Injecting injectme.dll into Game has failed.\n");
end