WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Data From Memory Address,txt


Question:

Suppose I have a memory location (because I'm messing around with DllCall and such) that points to a string (in C terms, a "char *") The only I know of to get the string into WB is to BinaryAlloc a buffer, then memcpy() from the pointer into the buffer. Then I can use BinaryPeekStr (or the like) to get the data.

Is there another way? I'm just looking to save a step if possible. For example, what would be nice is if I could BinaryAlloc and tell it where the data is. That would save me the copying step.

Note: I am aware of and have used IC(32) - that works, but only for 1,2 or 4 byte values.

Answer:

You can use IntControl(32) to grab 4 bytes at a time and push them into a BinaryBuffer. Thats about the extent of our "outside" memory capabilities.

IntControl(32) set to peek 1 byte at a time in a loop looking for a terminating NULL byte would effectively perform the same thing as the CRTL string copy functions. The key thing is to test for the NULL byte that terminates the string. Of course, a native string copy function that does all of that and returns a WIL string variable would be more efficient than iterative calls to IntControl(32).


Article ID:   W16461
File Created: 2005:02:18:12:20:50
Last Updated: 2005:02:18:12:20:50