RE: Pointer contents

new topic     » topic index » view thread      » older message » newer message

jjnick at cvn.com wrote:
> Ok, what's the best way to access pointer contents?
> 
> For example:
> 
>   ptr = allocate_string( "              " )
> 
> and then I use this to pass on to a WINAPI function . . .  but then, how 
> do I retrieve what the API function put into the pointer, I guess more 
> appropriately, address of . . .?
> 
> 
> 
Hello jj,

It really depends on the function called, but a lot of functions
simply replace the contents of the string, starting at the
ptr address.  For example, if Windows returns a string
starting at address ptr then
peek(ptr)=first char
peek(ptr+1)=second char
peek(ptr+2)=third char
etc
etc

and if its a zero terminated string the last char
is zero (that is, 0x00).
If the function returns multiple strings, the individual
strings are terminated by zero (0x00) and the last string
is terminated by two zeros in succession (0x00 0x00).

For example, "name" would be returned as
    'n','a','m','e',0
while nameA and nameB would be returned as
    'n','a','m','e',A',0,'n','a','m','e','B',0,0

Its always a good idea to check the actual function
description first though.


Also, dont confuse 0x00 hex with ascii zero '0' which is hex 0x30.

Also, there was a function in winlib that was called
peek_string() im not sure if its still there or not.

Good luck with it.
--Al

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu