Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Write and Read Process Memory

I have a question can someone help me please. I'd like to convert this C++ code into VB.
BYTE SearchMem[6] = {0xE9,0x5C,0x01,0x00,0x00,0x90};
Does anyone know how to convert that into VB. Please help me.
[226 byte] By [rocrfella] at [2007-11-11 10:04:44]
# 1 Re: Write and Read Process Memory
Dim SearchMem(5) As Byte
SearchMem(0) = &HE9
SearchMem(1) = &H5C
SearchMem(2) = &H1
SearchMem(3) = &H0
SearchMem(4) = &H0
SearchMem(5) = &H90
Amahdy at 2007-11-11 17:23:18 >
# 2 Re: Write and Read Process Memory
Thank you very much :)
rocrfella at 2007-11-11 17:24:18 >
# 3 Re: Write and Read Process Memory
I have another question. When I tried to write an array, I get a mismatch. Can you help me on how to to write an array to memory please.

In C++ i just use Write SearchMem but in VB6 I get an error.
rocrfella at 2007-11-11 17:25:16 >
# 4 Re: Write and Read Process Memory
I don't understand what u want exactly ? after initializing the array it's allready writen in the memory , do u mean specify address for each member of the array ? vb haven't the power to use adress like c++ .
Amahdy at 2007-11-11 17:26:21 >
# 5 Re: Write and Read Process Memory
I'm trying to write the array byte into a specific offset.

WriteProcessMemory(hand, (void*)(0x13EDE5), &data, 6, &bytes);

in C++ it will write the byte array into that specific offset, but in VB i'm keep getting type mismatch.

Dim a(1 To 3) As Byte

a(1) = &H38
a(2) = &H46
a(3) = &HD9

Call WriteProcessMemory(pi32.hProcess, &H13EDE5, a, 3, 0&)

I'm trying to write "a" into the &H13EDE5 offset, but it says type mismatch.

is there a code that would make the array shows each of the member? help me out please.
rocrfella at 2007-11-11 17:27:22 >
# 6 Re: Write and Read Process Memory
"a" is a literal value, to write it into a specific element of the array you need to convert it to it's ascii value and assign that to the element of the array where you want it. Like So:
a(3) = Asc("a")
Now if you are trying to write the entire contents of the "a" array into the specific memory location and the function needs the address of where the a array starts then you need to pass it the first element a(1). Like So:
Call WriteProcessMemory(pi32.hProcess, &H13EDE5, a(1), 3, 0&)
Ron Weller at 2007-11-11 17:28:21 >
# 7 Re: Write and Read Process Memory
try the keyword : "AdressOf" ;

... ,adressof a, ...
Amahdy at 2007-11-11 17:29:25 >