 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Dami Master Cheater
Reputation: 0
Joined: 23 Oct 2006 Posts: 336
|
Posted: Sun Oct 12, 2008 2:14 pm Post subject: [C#] Writing value in to a memory address |
|
|
Hmm last time i had to read, this time i have to write...
1st i wasnt able to write a value at all, but then i found out i have to send it in bytes :O
| Code: | IntPtr muffin = (IntPtr)0x00803570;
int Random = 10;
byte ahmg = Convert.ToByte(Random);
byte[] roflcakes = { ahmg, 0x0 };
pKernel.WriteProcessMemory(muffin, roflcakes); |
This would write value 16 to the specific address, but because i want to write directly from another memoryadress to this (mousefly)
This is just freaking clumsy!
How can i write directly a normal value like 4000 without turning it to a bytes?
Other wrappers or what ever they are...
| Code: | [DllImport("kernel32.dll")]
public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
~~~~~~~~~~
public void WriteProcessMemory(IntPtr MemoryAddress, byte[] bytesToWrite)
{
IntPtr ptrBytesWritten;
UNUSED_APIS.ProcessMemoryReaderApi.WriteProcessMemory(m_hProcess, MemoryAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);
// bytesWritten = ptrBytesWritten.ToInt32();
}
|
I got this workspace from a interwebz, so that is the reason im a bit knocked down
I tried to change some of the wrapper stuff to int, but that would just write always 0, because it fails ?
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Oct 12, 2008 2:25 pm Post subject: |
|
|
| I imagine just writing an Int should be fine as long as you have the right size, and the pinvoke signature is right.
|
|
| Back to top |
|
 |
Dami Master Cheater
Reputation: 0
Joined: 23 Oct 2006 Posts: 336
|
Posted: Sun Oct 12, 2008 4:12 pm Post subject: |
|
|
| slovach wrote: | | I imagine just writing an Int should be fine as long as you have the right size, and the pinvoke signature is right. |
You mean int size 255 or less ?
Pinvoke ? gotta google that one
|
|
| Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Sun Oct 12, 2008 4:57 pm Post subject: |
|
|
| Code: | [DllImport("kernel32.dll")]
static extern bool WriteProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
byte[] lpBuffer,
UIntPtr nSize,
out IntPtr lpNumberOfBytesWritten
);
public bool WriteToMem(IntPtr ProcessHandle)
{
IntPtr bytesout;
//Create Byte array containing a NOP (0×90 in Hexadecimal)
byte[] NewVal = { 0×90 };
//Write To Memory (0×05b9466)
return WriteProcessMemory(ProcessHandle, (IntPtr)0×05b9466 , NewVal, (UIntPtr)NewVal.Length, out bytesout);
} |
| Code: | if (
(WriteToMem(ProcessHandle) == true))
{
MessageBox.Show(”WriteProcessMemory Succeeded!”);
}
else
{
MessageBox.Show(”WriteProcessMemory Failed!”);
}
//Close Handle
CloseHandle(ProcessHandle);
} |
that what you want?
_________________
Blog
| Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Oct 12, 2008 5:19 pm Post subject: |
|
|
| Dami3n wrote: | | slovach wrote: | | I imagine just writing an Int should be fine as long as you have the right size, and the pinvoke signature is right. |
You mean int size 255 or less ?
Pinvoke ? gotta google that one  |
The DLLImport stuff is your PInvoke signature.
Change the declaration from byte array to an int, then just write it as expected.
I swear whatever kind of class / wrapper you're using is just complicating things.
| Code: | using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
public static extern bool WriteProcessMemory(IntPtr hProcess,
IntPtr lpBaseAddress,
UInt32 lpBuffer,
UInt32 nSize,
ref UInt32 lpNumberOfBytesWritten);
Process[] p = Process.GetProcessesByName("winmine");
WriteProcessMemory(p[0].Handle, 0x100579C, 500, sizeof(UInt32), 0); |
|
|
| Back to top |
|
 |
Dami Master Cheater
Reputation: 0
Joined: 23 Oct 2006 Posts: 336
|
Posted: Mon Oct 13, 2008 4:39 am Post subject: |
|
|
| slovach wrote: | | Dami3n wrote: | | slovach wrote: | | I imagine just writing an Int should be fine as long as you have the right size, and the pinvoke signature is right. |
You mean int size 255 or less ?
Pinvoke ? gotta google that one  |
The DLLImport stuff is your PInvoke signature.
Change the declaration from byte array to an int, then just write it as expected.
I swear whatever kind of class / wrapper you're using is just complicating things.
| Code: | using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
public static extern bool WriteProcessMemory(IntPtr hProcess,
IntPtr lpBaseAddress,
UInt32 lpBuffer,
UInt32 nSize,
ref UInt32 lpNumberOfBytesWritten);
Process[] p = Process.GetProcessesByName("winmine");
WriteProcessMemory(p[0].Handle, 0x100579C, 500, sizeof(UInt32), 0); |
|
Did i change something wrong?
| Code: | Error 1 The best overloaded method match for 'DamiInfo.frmMain.WriteProcessMemory(System.IntPtr, System.IntPtr, uint, uint, ref uint)' has some invalid arguments
Error 2 Argument '5': cannot convert from 'int' to 'ref uint'
~~~~~~~~~~
IntPtr MOUSEADDRESS = (IntPtr)0x00803570;
WriteProcessMemory(p[0].Handle, MOUSEADDRESS, 500, sizeof(UInt32), 0);
~~~~~~~~~~
[DllImport("kernel32.dll")]
public static extern bool WriteProcessMemory(IntPtr hProcess,
IntPtr lpBaseAddress,
UInt32 lpBuffer,
UInt32 nSize,
ref UInt32 lpNumberOfBytesWritten);
|
Edit: Soz didnt notice your reply overload...
i want to write normal value, not hex
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Mon Oct 13, 2008 7:10 am Post subject: |
|
|
there's a tool on the internet that helped me a lot with reading / writing to memory it calls trainer maker helper
refresh to see attachment
edit: almost forgot, it comes along with this class too ProcessMemoryReaderLib
_________________
Stylo
Last edited by Stylo on Mon Oct 13, 2008 7:16 am; edited 2 times in total |
|
| Back to top |
|
 |
Dami Master Cheater
Reputation: 0
Joined: 23 Oct 2006 Posts: 336
|
Posted: Mon Oct 13, 2008 7:14 am Post subject: |
|
|
| 1qaz wrote: | there's a tool on the internet that helped me a lot with reading / writing to memory it calls trainer maker helper
refresh to see attachment |
Nnnnnnice
Il take a look at it, and see if i can get something made
Ok i checked it, ITS FREAKING NICE!!!!!!!!!!!!!!!!!!!!!!!!!!
I didnt expect this much help for c# from here, my god
Thank you all, cya soon when i get something else to ask
Last edited by Dami on Mon Oct 13, 2008 7:24 am; edited 1 time in total |
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Mon Oct 13, 2008 7:16 am Post subject: |
|
|
watch edit...
_________________
Stylo |
|
| Back to top |
|
 |
Dami Master Cheater
Reputation: 0
Joined: 23 Oct 2006 Posts: 336
|
Posted: Mon Oct 13, 2008 7:25 am Post subject: |
|
|
| 1qaz wrote: | | watch edit... |
Yep, got it
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Mon Oct 13, 2008 12:30 pm Post subject: |
|
|
| Dami3n wrote: | | Code: | Error 1 The best overloaded method match for 'DamiInfo.frmMain.WriteProcessMemory(System.IntPtr, System.IntPtr, uint, uint, ref uint)' has some invalid arguments
Error 2 Argument '5': cannot convert from 'int' to 'ref uint'
IntPtr MOUSEADDRESS = (IntPtr)0x00803570;
WriteProcessMemory(p[0].Handle, MOUSEADDRESS, 500, sizeof(UInt32), 0);
~~~~~~~~~~
[DllImport("kernel32.dll")]
public static extern bool WriteProcessMemory(IntPtr hProcess,
IntPtr lpBaseAddress,
UInt32 lpBuffer,
UInt32 nSize,
ref UInt32 lpNumberOfBytesWritten);
|
Edit: Soz didnt notice your reply overload...
i want to write normal value, not hex  |
My bad, try | Quote: | | out IntPtr lpNumberOfBytesWritten |
|
|
| Back to top |
|
 |
Dami Master Cheater
Reputation: 0
Joined: 23 Oct 2006 Posts: 336
|
Posted: Mon Oct 13, 2008 1:11 pm Post subject: |
|
|
| slovach wrote: | | Dami3n wrote: | | Code: | Error 1 The best overloaded method match for 'DamiInfo.frmMain.WriteProcessMemory(System.IntPtr, System.IntPtr, uint, uint, ref uint)' has some invalid arguments
Error 2 Argument '5': cannot convert from 'int' to 'ref uint'
IntPtr MOUSEADDRESS = (IntPtr)0x00803570;
WriteProcessMemory(p[0].Handle, MOUSEADDRESS, 500, sizeof(UInt32), 0);
~~~~~~~~~~
[DllImport("kernel32.dll")]
public static extern bool WriteProcessMemory(IntPtr hProcess,
IntPtr lpBaseAddress,
UInt32 lpBuffer,
UInt32 nSize,
ref UInt32 lpNumberOfBytesWritten);
|
Edit: Soz didnt notice your reply overload...
i want to write normal value, not hex  |
My bad, try | Quote: | | out IntPtr lpNumberOfBytesWritten |
|
Hmm i already took 1qaz method, and its working
But yeah, that is way much better than what i had before
|
|
| 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
|
|