WriteProcessMemory() Api Help
I have a problem with WriteProcessMemory() that I am trying to use. My code looks like this:
Public
DeclareFunction WriteProcessMemoryLib"kernel32" (ByVal hProcessAsInteger,ByVal lpBaseAddressAsObject,ByVal lpBufferAsObject,ByVal nSizeAsInteger,ByVal lpNumberOfBytesWrittenAsInteger)AsInteger
Dim appProcess as Process
*gets the process* ' I know it works
Dim offsetAsLong = 29689060Dim valueAsLong = 3WriteProcessMemory(appProcess.Handle(), offset, value, 4, 0&)
What I am trying to do is to write the memory adress (01C504E4, decimal value 29689060) with the value of 3. The data type is a long, (4 bytes). Is there anything I am doing wrong since I do not see that memory adress changing at all with a trusted debugger when I run the code?
[2583 byte] By [
VBWorker] at [2007-12-24]
To he honest with you, for reasons of OS security, I hope this is not possible.
I wonder if you are not going to have to call an API routine to open the process and get a process handle. Often than call requires certain levels of security, but it also gives to access to a lot more than I think you're ever going to have using the process class.
Well, look at a memory editing program. It can open any process, and edit any memory adress within it. I am looking to opena process and modify 1 offset as well.
I got it working, but, i need to know how to get the memory address of a variable within my own program and pass it in. Does anyone know the method of getting the memory address of a variable within your program. I saw some IntPtr(variable) but thats no longer supportedd by .net
Could you please explain what you are trying to accomplish here?
In the managed world, variables can move around in memory, and you need to pin the variable to prevent it from moving:
http://msdn.microsoft.com/msdnmag/issues/04/10/NET/
Please note that I'm far from convinced that this is the right technique for what you are trying to do, and that you may be barking up the wrong tree here...
Best regards,
Johan Stenberg