Hi,
i have 2 project c++ a dll and C# .exe, the dll is injected in a game and return a data like this: http://prntscr.com/lctkmb
this stay returning while dll is runing . Now i trying get this return in my C# aplication, i tried Dynamically calling an unmanaged dll, but not work, get this error "Attempt to read or write to protected memory. Usually, this is an indication that another memory is damaged. '"
My function on dll that return data:
INT64 GetLocalPlayer_EX() { DWORD64 pClientGameContext = *(DWORD64*)OFFSET_CLIENTGAMECONTEXT; if (!(pClientGameContext)) return 0; DWORD64 pPlayerManager = *(DWORD64*)(pClientGameContext + 0x68); if (!(pPlayerManager)) return 0; DWORD64 pObfuscationMgr = *(DWORD64*)OFFSET_ObfuscationMgr; if (!(pObfuscationMgr)) return 0; DWORD64 LocalPlayerListXorValue = *(DWORD64*)((DWORD64)pPlayerManager + 0xF0); DWORD64 LocalPlayerListKey = LocalPlayerListXorValue ^ *(DWORD64 *)(pObfuscationMgr + 0x70); hashtable<DWORD64>* table = (hashtable<DWORD64>*)(pObfuscationMgr + 8); hashtable_iterator<DWORD64> iterator = { 0 }; hashtable_find(table, &iterator, LocalPlayerListKey); if (iterator.mpNode == table->mpBucketArray[table->mnBucketCount]) return 0; DWORD64 EncryptedPlayerMgr = (DWORD64)iterator.mpNode->mValue.second; if (!(EncryptedPlayerMgr)) return 0; DWORD MaxPlayerCount = *(DWORD *)(EncryptedPlayerMgr + 0x18); if (MaxPlayerCount != 1) return 0; return EncryptedPlayerMgr__GetPlayer(EncryptedPlayerMgr, 0); }
DWORD WINAPI InitThread(LPVOID)
{
CreateConsole();
while (true)
{
printf("LocalPlayer = %I64X\n", GetLocalPlayer_EX());
Sleep(100);
}
return 0;
}extern "C" __declspec(dllexport) INT64 GetLocalPlayer_EX();
In my C# code:
[System.Runtime.InteropServices.DllImportAttribute("BFClient1.dll", EntryPoint = "GetLocalPlayer_EX", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)] public static extern int GetLocalPlayer_EX(); [STAThread] static void Main(string[] args) { Int64 localp = NativeMemory.Read<In64t>(GetLocalPlayer_EX()); //read type int64 Console.WriteLine("LocalPlayer " + localp.toSctring("X")); //"Attempt to read or write to protected memory. Usually, this is an indication that another memory is damaged. '" Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); Application.Run(); Console.ReadKey(); }
have away to call that return ?