On Aug 31, 2004, at 9:49 AM, Charlie Boisseau wrote:
On 31 Aug 2004, at 15:42, Thomas Reed wrote:
What routine are you calling, and what does your code look like? I
have a number of callback routines that are defined to return
MemoryBlocks, and they work just fine. I'd be extremely surprised if
you couldn't use MemoryBlock as a parameter type in a callback as
well.
I looked at Jon's previous post as he suggested. I found that i was
missing the line mb = mb.Ptr(0), but these make the MemoryBlock empty.
Not exactly. The data is what you asked for, but REALbasic has no
knowledge of the pointer returned when you access mb.Ptr(). That memory
is owned by another process. So, mb.Size will return 0. You need to
know the size of the data structures you're trying to access, and you
can still accomplish it.
A few things to note:
Sub got_packet(Args As Integer, Header As Integer, Packet As Integer)
Dim head As New MemoryBlock(1500)
Dim pkt As New MemoryBlock(1500)
...
head.long(0) = Header
pkt.long(0) = Packet
head = head.Ptr(0)
pkt = pkt.Ptr(0)
You're creating 1500 byte memoryblocks, then using the first 4 bytes.
Next, you're throwing away the entire memoryblock by replacing it with
the return value from .Ptr(). The memoryblocks only need to be 4 bytes.
head_str = head.StringValue(0, head.Size)
pkt_str = pkt.StringValue(0, pkt.Size)
Assuming that 1500 is the size you want, you should pass 1500 here
instead of head.Size and pkt.Size. In the process of getting a new
memoryblock from .Ptr(), REALbasic cannot guess what size the returned
pointer really is, so you'll be seeing 0 there.
HTH,
Jon
--
Jonathan Johnson
Testing Department
REAL Software, Inc.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|