| View previous topic :: View next topic |
| Author |
Message |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Thu Feb 25, 2010 3:30 pm Post subject: Getting variable value from a pointer |
|
|
hello,
i need some help to get a value from a pointer:
I use the api PostMessageA
| Code: |
%W = OK
%L = OK
%R = @LIB(USER32,PostMessageA,INT:,%%handle,%M,%W,@addr("%L"))
|
I receive the massage with
| Code: |
:MessageEvent
%L = @msgparams(L)
%W = @msgparams(W)
info L = %L / W = %W
info L = @val(%L) / W = @val(%W)
info L = @val(@addr("%L")) / W = @val(@addr("%W"))
|
They all give me some different decimal numbers but not the expected "OK".
Edit: I should mention that sending and receiveing are two different applications.
Thank you in advance
marcus |
|
| Back to top |
|
 |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Mon Mar 01, 2010 1:24 pm Post subject: |
|
|
Here is a solution that works well.
You can compile it to a dsu to easyly use it in other scripts
Example:
| Code: |
#
# Function bsMemCopy - bornSoft
# -------------------------------
#
# This function copies a number of bytes directly from RAM into a variable
# using the RtlMoveMemory API from KERNEL32.DLL.
#
# Usage: %%Variable = @bsMemCopy( <Pointer> [, Size] )
#
# Pointer is the starting address in memory where the bytes to copy are located
#
# Size is the size in bytes of the data to receive.
# If this is not specified, the buffer is sized to 1 kB by default.
# If the result is shorter it will be trimmed.
# Use it only if you know, that the result will be longer than 1024 bytes.
#
#
#INCLUDE,bsMemCopy.dsu
# to test we first need any pointer
%x = "Hello VDSWorld!"
%%Pointer = @addr("%x")
# now let's see what is at this location
%%Result = @bsMemcopy(%%Pointer)
info "The variable %%Result now contains: "%%Result@tab()
exit
|
and here the function:
| Code: |
#DEFINE FUNCTION,bsMemCopy
:bsMemCopy
if @not(%1) @not(@numeric(%1)) @not(@equal(@len(%1),8))
%E = 13
%%bsError = "Error in function [ bsMemCopy ]"@tab()@cr()@cr()"Invalid pointer to memory location "
goto bsMemCopy_Error
end
if %2
if @not(@numeric(%2))
%E = 25
%%bsError = "Error in function [ bsMemCopy ]"@tab()@cr()@cr()"Buffer-size is not numeric "
goto bsMemCopy_Error
end
end
%L = %2
if @not(%L)
%L = 1024
end
%R = @fill(%L,,Z)
loadlib kernel32.dll
%x = @lib(kernel32,RtlMoveMemory,INT:,INT:@addr("%R"),INT:%1,INT:@len(%R))
if @not(@zero(%x))
%R = @trim(@adjust(%R))
end
exit %R
:bsMemCopy_Error
if %%Debug
warn %%bsError
end
Error %E
stop
|
|
|
| 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 can attach files in this forum You can download files in this forum
|
|