I need help with code in C# and C++ 🙏

avatar frame
VerdunLayer
1 Posts
12/28/2023
2
274

Hello everyone. I am a newbie and I have a question on changing the memory of any game. Kind coders, please help me as a beginner. In C#, I want to write a function "Infinite HP + One Shot Kill". In the nuget for memory editing I use  "Memory.dll.x64"


Here's a script from the Cheat Engine:


[ENABLE]

//code from here to '[DISABLE]' will be used to enable the cheat

alloc(newmem,2048,"GameAssembly.dll"+13AC7CF) 

label(returnhere)

label(originalcode)

label(exit)


newmem:

cmp [rbx+40],0 <-- enemy

jne originalcode

mov [rbx+18],0 <-- me

jmp exit


originalcode:

mov [rbx+18],(float)9999 <-- me


exit:

jmp returnhere


"GameAssembly.dll"+13AC7CF:

jmp newmem

returnhere:

 

[DISABLE]

//code from here till the end of the code will be used to disable the cheat

dealloc(newmem)

"GameAssembly.dll"+13AC7CF:

movss [rbx+18],xmm0

//Alt: db F3 0F 11 43 18


When I use the script in the Cheat Engine the bytes: F3 0F 11 43 18 change to this value: E9 2C 38 C4 FE and it works fine.

In C#, I write the code:


                // Infinite HP + One Shot Kill

                if (Button1.Checked)

                {

                    n.WriteMemory("GameAssembly.dll+13AC7CF", "bytes", "E9 2C 38 C4 FE");

                }

                else

                {

                    n.WriteMemory("GameAssembly.dll+13AC7CF", "bytes", "F3 0F 11 43 18");

                }


But after I turn on the cheat, created in C#, the game crashes. And it happens in any game in which I do the same thing. But if I change these bytes F3 0F 11 43 18 to 90 90 90 90 90 then the game will not crash. But the function won't work well, not like in the cheat engine. I've tried to change different values from "float" to "int" but it didn't work. The game keeps crashing. What am I doing wrong? Help me, please. 😢🙏

12/28/2023
2
274
avatar frame
VerdunLayer
1 posts

Hello everyone. I am a newbie and I have a question on changing the memory of any game. Kind coders, please help me as a beginner. In C#, I want to write a function "Infinite HP + One Shot Kill". In the nuget for memory editing I use  "Memory.dll.x64"


Here's a script from the Cheat Engine:


[ENABLE]

//code from here to '[DISABLE]' will be used to enable the cheat

alloc(newmem,2048,"GameAssembly.dll"+13AC7CF) 

label(returnhere)

label(originalcode)

label(exit)


newmem:

cmp [rbx+40],0 <-- enemy

jne originalcode

mov [rbx+18],0 <-- me

jmp exit


originalcode:

mov [rbx+18],(float)9999 <-- me


exit:

jmp returnhere


"GameAssembly.dll"+13AC7CF:

jmp newmem

returnhere:

 

[DISABLE]

//code from here till the end of the code will be used to disable the cheat

dealloc(newmem)

"GameAssembly.dll"+13AC7CF:

movss [rbx+18],xmm0

//Alt: db F3 0F 11 43 18


When I use the script in the Cheat Engine the bytes: F3 0F 11 43 18 change to this value: E9 2C 38 C4 FE and it works fine.

In C#, I write the code:


                // Infinite HP + One Shot Kill

                if (Button1.Checked)

                {

                    n.WriteMemory("GameAssembly.dll+13AC7CF", "bytes", "E9 2C 38 C4 FE");

                }

                else

                {

                    n.WriteMemory("GameAssembly.dll+13AC7CF", "bytes", "F3 0F 11 43 18");

                }


But after I turn on the cheat, created in C#, the game crashes. And it happens in any game in which I do the same thing. But if I change these bytes F3 0F 11 43 18 to 90 90 90 90 90 then the game will not crash. But the function won't work well, not like in the cheat engine. I've tried to change different values from "float" to "int" but it didn't work. The game keeps crashing. What am I doing wrong? Help me, please. 😢🙏

avatar frame
Matze500
9245 Posts
Achivement: Forum Grandmaster
Achivement: I'm feeling retro!
Achivement: Good old times!
#1
12/29/2023

You have to do it completely different.

You have to allocate memory in the remote process write newmem somewhere. calculate the distance to your code cave where newmem is and then write the injection with dynamic byte code.


Currently you just jmp into nowhere. in your c# code.

You forgot nearly everything which cheat engine does.


You only currently do this part of the script:


"GameAssembly.dll"+13AC7CF:

jmp newmem

0
0
#1
12/29/2023
avatar frame
Matze500
9245 Posts
Achivement: Forum Grandmaster
Achivement: I'm feeling retro!
Achivement: Good old times!

You have to do it completely different.

You have to allocate memory in the remote process write newmem somewhere. calculate the distance to your code cave where newmem is and then write the injection with dynamic byte code.


Currently you just jmp into nowhere. in your c# code.

You forgot nearly everything which cheat engine does.


You only currently do this part of the script:


"GameAssembly.dll"+13AC7CF:

jmp newmem

0
0
You have to be signed in and registered to post a comment!
An error has occurred. This app may no longer respond until reloaded. Reload 🗙