Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Making a trainer in c#?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
cheatenginenoob
Cheater
Reputation: 0

Joined: 03 Jan 2007
Posts: 45
Location: behind you

PostPosted: Mon Dec 19, 2011 1:52 am    Post subject: Making a trainer in c#? Reply with quote

I remember seeing some tutorials for making trainers, but I didn't know how to program then.

I'm looking for something in c# with VS.

_________________


"I wish my lawn was emo so it would cut itself"
Back to top
View user's profile Send private message
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Mon Dec 19, 2011 8:31 am    Post subject: Reply with quote

You want to change memory? Use WriteProcessMemory() api for that.
Back to top
View user's profile Send private message
Unbr0ken
Advanced Cheater
Reputation: 2

Joined: 10 Aug 2011
Posts: 67

PostPosted: Mon Dec 19, 2011 2:43 pm    Post subject: Reply with quote

NoMercy wrote:
You want to change memory? Use WriteProcessMemory() api for that.


And...

Code:
using System.Diagnostics;
using System.Runtime.InteropServices;

OpenProcess()
VirtualProtectEx()
CloseHandle()


PInvoke can help you a lot.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Mon Dec 19, 2011 3:54 pm    Post subject: Reply with quote

Unbr0ken wrote:
NoMercy wrote:
You want to change memory? Use WriteProcessMemory() api for that.


And...

Code:
using System.Diagnostics;
using System.Runtime.InteropServices;

OpenProcess()
VirtualProtectEx()
CloseHandle()


PInvoke can help you a lot.

It can also be done without using
OpenProcess()
VirtualProtectEx()
CloseHandle()

I only use
WriteProcessMemory
ReadProcessMemory

_________________
Back to top
View user's profile Send private message
Unbr0ken
Advanced Cheater
Reputation: 2

Joined: 10 Aug 2011
Posts: 67

PostPosted: Mon Dec 19, 2011 4:20 pm    Post subject: Reply with quote

Pingo wrote:
Unbr0ken wrote:
NoMercy wrote:
You want to change memory? Use WriteProcessMemory() api for that.


And...

Code:
using System.Diagnostics;
using System.Runtime.InteropServices;

OpenProcess()
VirtualProtectEx()
CloseHandle()


PInvoke can help you a lot.

It can also be done without using
OpenProcess()
VirtualProtectEx()
CloseHandle()

I only use
WriteProcessMemory
ReadProcessMemory


Why not use the correct way?...

By the way, how do you establish the access to the handle of the process?... to my knowledge, if you don't set the correct access (PROCESS_VM_WRITE or PROCESS_VM_READ) you couldn't read/write memory (If the chunk of memory haven't read/write access).
Back to top
View user's profile Send private message Send e-mail MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Mon Dec 19, 2011 4:23 pm    Post subject: Reply with quote

OpenProcess / CloseHandle aren't absolutely needed in .NET except for extreme conditions with some applications. The Process class exposes a handle for you that you can use rather then needing API or worrying about closing the handle yourself.

Assuming you are using VS2010, you can use Linq for making queries easy on the running processes for example:

Code:

            Process p = (from Process proc in Process.GetProcessesByName("winmine")
                         select proc).FirstOrDefault();

            if (p != null)
            {
                // Do stuff with our process here..
                // p.Handle for anything that requires a
                // process handle to be used.
            }


Then for example if you need a base address from this process for something like, 'winmine.exe'+15123, you can do:

Code:

            Process p = (from Process proc in Process.GetProcessesByName("winmine")
                         select proc).FirstOrDefault();

            if (p != null)
            {
                IntPtr lpBaseAddress = (from ProcessModule mod in p.Modules
                                        where mod.ModuleName == "winmine.exe"
                                        select mod.BaseAddress).SingleOrDefault();
            }


And so on, then you can just use pinvoke for ReadProcessMemory/WriteProcessMemory.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Mon Dec 19, 2011 7:01 pm    Post subject: Reply with quote

Blame Wiccaan, he converted me ages ago. At one point i did use these api's but iv not had many problems since, except for those rare occasions.
Alot less code needed, and when i find cleaner ways of coding, i stick with it.

_________________
Back to top
View user's profile Send private message
cheatenginenoob
Cheater
Reputation: 0

Joined: 03 Jan 2007
Posts: 45
Location: behind you

PostPosted: Tue Dec 20, 2011 10:49 pm    Post subject: Reply with quote

Woah. A little more info than that please. I have no idea which memory I need to edit. How do I find the location of the variables? How did you guys learn this stuff?
_________________


"I wish my lawn was emo so it would cut itself"
Back to top
View user's profile Send private message
Unbr0ken
Advanced Cheater
Reputation: 2

Joined: 10 Aug 2011
Posts: 67

PostPosted: Tue Dec 20, 2011 11:54 pm    Post subject: Reply with quote

cheatenginenoob wrote:
Woah. A little more info than that please. I have no idea which memory I need to edit. How do I find the location of the variables? How did you guys learn this stuff?


Start use the CE...

Do the CE Tutorial, and then go modify the memory of some game.

You must not run if you can't walk.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites