 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
aataqah How do I cheat?
Reputation: 0
Joined: 29 Nov 2009 Posts: 3
|
Posted: Sun Nov 29, 2009 1:34 pm Post subject: [C#] Reading a value from memory address |
|
|
Hello!
I would like to make a program that reads a value from another application. What I want is to create a program that reads the current voltage from the UPS application PowerChute, so I can log it to a file (PowerChute does not have this function). Using cheat engine I have found the memory address of this value:
Process: 00000E68-PowerChute.exe
Address: 00A12320 (type: Double)
How can I achieve this? I have some knowledge about C# and C++ programming, but only for microprocessors. I am using visual C# and C++ express.
I have already searched the forum, and tried some things, but it does not compile. I am probably missing something in the header, but don't know what.
To conclude, I am asking for help to create a C# GUI application using windows forms that displays the value read from the memory address. How and where to start?
|
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
|
Back to top |
|
 |
aataqah How do I cheat?
Reputation: 0
Joined: 29 Nov 2009 Posts: 3
|
Posted: Mon Nov 30, 2009 3:45 am Post subject: |
|
|
I read the links, but I don't know how to use any of it. On the 1. link I didn't find any function that gives me the PID of the process. Also, the other two I don't know how to use.
Can you be a little more specific please?
Like I said, my programming knowledge is very limited. I am an electrical engineer, not a software engineer
|
|
Back to top |
|
 |
iPromise Grandmaster Cheater
Reputation: -1
Joined: 27 Jun 2009 Posts: 529 Location: Canada
|
Posted: Mon Nov 30, 2009 6:30 pm Post subject: |
|
|
Example Code in C++:
Code: |
HWND TARGET = FindWindowA(NULL, "PowerChute");
DWORD PID ;
GetWindowThreadProcessId(TARGET, &PID);
HANDLE HTARGET = OpenProcess(PROCESS_ALL_ACCESS, false, PID);
DWORD BUFFER:
WriteProcessMemory(HTARGET, (LPVOID) 0x00A12320, &BUF, 4, NULL);
|
Try to convert this to C#.
|
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Mon Nov 30, 2009 6:52 pm Post subject: |
|
|
iPromise wrote: | Example Code in C++:
Code: |
HWND TARGET = FindWindowA(NULL, "PowerChute");
DWORD PID ;
GetWindowThreadProcessId(TARGET, &PID);
HANDLE HTARGET = OpenProcess(PROCESS_ALL_ACCESS, false, PID);
DWORD BUFFER:
WriteProcessMemory(HTARGET, (LPVOID) 0x00A12320, &BUF, 4, NULL);
|
Try to convert this to C#. |
Code: | HANDLE hProcess = GetProcessHandleFromHwnd( FindWindow( NULL, _T("PowerChute") ) );
ReadProcessMemory( hProcess( hProcess, X, Y, nSize, NULL ) );
CloseHandle( hProcess ); |
|
|
Back to top |
|
 |
aataqah How do I cheat?
Reputation: 0
Joined: 29 Nov 2009 Posts: 3
|
Posted: Fri Dec 04, 2009 7:09 am Post subject: |
|
|
I tried, but I cannot get this thing to work.
Can someone be so nice and make a simple c++ console application that displays the requested value and post it here (with source)? Once I have a working code, that compiles without errors, I will work on that.
Thank you!
|
|
Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Fri Dec 04, 2009 9:16 am Post subject: |
|
|
Code: |
[DllImport("Kernel32.Dll")]
public static extern IntPtr OpenProcess(DWORD dwDesiredAccess, bool bInheritance, DWORD dwProcessId);
[DllImport("Kernel32.Dll")]
public static extern bool ReadProcessMemory(IntPtr hProcess,IntPtr BaseAddress, out byte[] buffer, Int32 b_size, out Int32 dwBytesRead);
/* class implementation */
IntPtr hProc = IntPtr.Zero;
Int32 dwBytesRead, Value;
hProc = OpenProcess(0x0010 /* PROCESS_VM_READ access */, false,iPID); // iPID is your process id get it by your self using Process class
byte[] memory = new byte[6]; // can be more than 6 depends how many bytes you're interesting to read
ReadProcessMemory(hProc,(IntPtr)0xFFFFFFFF /* your address */, out memory, memory.Length,out dwBytesRead);
Value = BitConvert.ToInt32(memory);
|
haven't tested it but should do the job :]
BTW: It's C#
|
|
Back to top |
|
 |
|
|
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
|
|