Log in

View Full Version : winApi CopyMemory



Mrzout
03-30-2016, 05:10 AM
Hi, its possible pass length as reference? I have function what get BSTRptr (pointer to BSTR struct), so length pointer is BSTRptr - 4. Its possible pass this pointer directly, or its necessary do somethig as...

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, Length As Long)

.....
dim i as long
CopyMemory i, byval BSTRptr - 4, byval 4
.....

... dereference and pass value?

Paul_Hossler
04-04-2016, 07:32 AM
Maybe 2 steps?

But your second CopyMemory looks like it will put too much at the location of the 4 byte "I", overwriting what follows




Option Explicit

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, Length As Long)

Sub test()
Dim i As Long, L As Long
CopyMemory L, ByVal BSTRptr - 4, 4

CopyMemory i, ByVal BSTRptr - 4, L
End Sub

Mrzout
04-08-2016, 01:10 AM
I know, but is possible do it in one step? When i know address where is length saved?