Kernel32WriteProcessMemory(IntPtr, UIntPtr, IntPtr, UIntPtr, IntPtr) Method
Writes data to an area of memory in a specified process.
The entire area to be written to must be accessible or the operation fails.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", ExactSpelling = true, SetLastError = true)]
public static bool WriteProcessMemory(
IntPtr hProcess,
UIntPtr baseAddress,
IntPtr buffer,
UIntPtr size,
out IntPtr refNumberOfBytesWritten
)
<DllImportAttribute("Kernel32.dll", ExactSpelling := true, SetLastError := true>]
Public Shared Function WriteProcessMemory (
hProcess As IntPtr,
baseAddress As UIntPtr,
buffer As IntPtr,
size As UIntPtr,
<OutAttribute> ByRef refNumberOfBytesWritten As IntPtr
) As Boolean
Dim hProcess As IntPtr
Dim baseAddress As UIntPtr
Dim buffer As IntPtr
Dim size As UIntPtr
Dim refNumberOfBytesWritten As IntPtr
Dim returnValue As Boolean
returnValue = Kernel32.WriteProcessMemory(hProcess,
baseAddress, buffer, size, refNumberOfBytesWritten)
public:
[DllImportAttribute(L"Kernel32.dll", ExactSpelling = true, SetLastError = true)]
static bool WriteProcessMemory(
[InAttribute] IntPtr hProcess,
[InAttribute] UIntPtr baseAddress,
[InAttribute] IntPtr buffer,
UIntPtr size,
[OutAttribute] IntPtr% refNumberOfBytesWritten
)
[<DllImportAttribute("Kernel32.dll", ExactSpelling = true, SetLastError = true)>]
static member WriteProcessMemory :
hProcess : IntPtr *
baseAddress : UIntPtr *
buffer : IntPtr *
size : UIntPtr *
refNumberOfBytesWritten : IntPtr byref -> bool
No code example is currently available or this language may not be supported.
- hProcess IntPtr
-
A handle to the process memory to be modified.
The handle must have VirtualMemoryWrite
and VirtualMemoryOperation access to the process.
- baseAddress UIntPtr
-
A pointer to the base address in the specified process to which data is written.
Before data transfer occurs, the system verifies that all data in the
base address and memory of the specified size is accessible for write access,
and if it is not accessible, the function fails.
- buffer IntPtr
-
A pointer to the buffer that contains data to be written in the address space of the specified process.
- size UIntPtr
-
The number of bytes to be written to the specified process.
- refNumberOfBytesWritten IntPtr
-
A pointer to a variable that receives the number of bytes transferred into the specified process.
This parameter is optional.
If refNumberOfBytesWritten is Zero, the parameter is ignored.
Boolean
If the function succeeds, the return value is
.
If the function fails, the return value is
.
To get extended error information, call
GetLastWin32Error.