Click here to Skip to main content
13,764,268 members
Rate this:
 
Please Sign up or sign in to vote.
Hi, i write a dll that is injected on game and return my localplayer and listArrayplayer on server. Ok work fine
code dll project:

__int64 RerturnLocalPlayer() {

    __int64 player = GetLocalPlayer_EX();// __Int64 GetLocalPlayer_EX is function that return my player
    return player;
}
in my main.h:
extern "C" {

	__declspec(dllexport) __int64 RerturnLocalPlayer();
}
in my C# code:
[System.Runtime.InteropServices.DllImportAttribute("my.dll", EntryPoint = "RerturnLocalPlayer",
        CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
        public static extern Int64 RerturnLocalPlayer();

// and try return:

 Int64 localp = NativeMemory.Read<Int64> (RerturnLocalPlayer());

 Console.WriteLine("LocalPlayer " + localp.ToString("X"));

the problem is when i run my c# application my console open and after 3 seconds close and sometimes get error: "
"Attempt to read or write to protected memory. Usually, this is an indication that another memory is damaged.".
"

What I have tried:

__int64 RerturnLocalPlayer() {

		__int64 player = GetLocalPlayer_EX();// __Int64 GetLocalPlayer_EX is function that return my player
		return player;
	}

in my main.h:
extern "C" {

	__declspec(dllexport) __int64 RerturnLocalPlayer();

}

        [System.Runtime.InteropServices.DllImportAttribute("my.dll", EntryPoint = "RerturnLocalPlayer",
        CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
        public static extern Int64 RerturnLocalPlayer();

// and try return:

 Int64 localp = NativeMemory.Read<Int64> (RerturnLocalPlayer());

 Console.WriteLine("LocalPlayer " + localp.ToString("X"));
Posted 3 days ago
Updated 3 days ago
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Int64 localp = RerturnLocalPlayer();
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06-2016 | 2.8.181113.4 | Last Updated 11 Nov 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100