Hi all,
I'm trying to create a trainer for a flash game.
I have an AxShockwaveFlash component to play the flash game in a windows form.
With an other program (cheat engine) I found the memory place of the money-value in the game.
How can I change this value in C# .NET? When I click a button for example.
Thanks
8 1448
You will have to use some unsafe code to do it.
Possible even create an unmanaged DLL that contains methods for doing that.
Yes, I already thought it would be unsave. Writing directly into a programs memory, but any idea how to do this?
Honestly, I recomend using an unmanged DLL to do it. Less messy then trying to do unsafe stuff.
Create a function that say takes in two integers. One integer will be an address, one will be the value to set it to. Your unmanaged function would set the memory to be that value.
That way your C# just needs to know the memory location and the value.
OK, I found something that works for writing into the memory:
To use the C/C++ functions I called these parts: - [DllImport("kernel32.dll")]
-
public static extern Int32 CloseHandle(IntPtr hObject);
-
[DllImport("kernel32.dll")]
-
public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
-
[DllImport("kernel32.dll")]
-
public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, uint[] lpBuffer, UInt32 nSize, IntPtr lpNumberOfBytesWritten);
-
[DllImport("kernel32.dll")]
-
public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
And I used them as followed: - Process proc = Process.GetCurrentProcess();
-
IntPtr procHandle = OpenProcess(0x1F0FFF, 0, (UInt32)proc.Id);
-
WriteProcessMemory(procHandle, (IntPtr)0x038C3148, new uint[] { 0x08 }, 4, (IntPtr)0);
-
byte[] b = null;
-
IntPtr i;
-
if((ReadProcessMemory(procHandle, (IntPtr)0x038C3148, b, 4, out i) != 0))
-
MessageBox.Show(b.ToString());
The writing works (because the money value changes), but I don't get a messagebox, so the reading doesn't work. What am I doing wrong?
To 0x1F0FFF parameter to open the handle is "enables all possible access rights to the process specified by the Process ID."
The return value is the value it is reading from the memory address right?
And the out variable tells you how many bytes it's reading, is it reading any bytes?
no, the variable 'i' is always 0
It might have something to do with how you initialized b. Seems like b is supposed to return the data read?
Try setting b to an array that has enough bytes to read, then see if i changes?
Nope, still doesn't return anything and i stays 0
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Daniel |
last post by:
how to make two references to one string that stay refered to the same
string reguardless of the changing value in the string?
|
by: Jeremy Ames |
last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated...
|
by: Siah |
last post by:
Hi,
I wanted to dynamically update pieces of my page in the following
fashion. Look at the following html code:
<span id='person_23_name'> Mike </span>
<span id='person_28_name'> Siah </span>...
|
by: andychambers2002 |
last post by:
I'm working on a "TempFile" class that stores the data in memory until
it gets larger than a specified threshold (as per PEP 42). Whilst
trying to implement it, I've come across some strange...
|
by: Rob Prins |
last post by:
{ This is probably a non-environment-specific problem buried in an
environment-specific context; thus accepted. -mod }
L.S.
For a couple of days I've been trying to write a small Windows...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |