I am trying to calling a game functions with code injection. after some try I find a dll that did what I want.
so i saw the dll with ILSpy but cannot understand the code.
class <Module>
{
[SecurityCritical, SuppressUnmanagedCodeSecurity]
[DllImport("", CallingConvention = CallingConvention.ThisCall, SetLastError = true)]
[MethodImpl(MethodImplOptions.Unmanaged)]
internal unsafe static extern float* GetHealth(AttackableUnit*);
}
--------------------------
namespace Native
{
[NativeCppClass]
[StructLayout(LayoutKind.Sequential, Size = 1)]
internal struct AttackableUnit
{
}
}
---------------------
public unsafe float MaxHealth
{
get
{
Native.AttackableUnit* ptr = (Native.AttackableUnit*)base.GetPtr();
if (ptr != null)
{
return *<Module>.Native.AttackableUnit.GetMaxHealth(ptr);
}
return 0f;
}
}
Seems the dll inject c# code to the target app with a c++ dll and bootstrap .net in target.
And now I cannot understand what is the meaning of
[DllImport("", CallingConvention = CallingConvention.ThisCall, SetLastError = true)]
Why is the file path empty? How does the dll manage class and function call? I mean what technique the programmer use?
EDIT : The name of library that I am trying to understand is Elobuddy perhaps helps.