From: Dennis Ranke Date: 2004-01-11T21:41:38+09:00 Subject: Re: dereferencing pointers in Win32 API On Sat, 10 Jan 2004 14:43:19 -0600, Shashank Date wrote: >> If I'm not completely wrong, you should be able to dereference it using >> lpBuffer.unpack('P') where is the size of the buffer in >> bytes. Just remember that unpack returns an array, the first element of >> which will be the dereferenced buffer as a string. > > I tried that and i get: > > C:/atest/tst_netapi32.rb:28:in `unpack': no associated pointer > (ArgumentError) > from C:/atest/tst_netapi32.rb:28 You are right, after reading the relevant ruby source, it seems that you can only dereference pointers that you have written into the string yourself using Array#pack('P'). So the suggestion of Park to use memcpy might be your best bet. As a sidenote to matz: Is it intentional that String#unpack('P') can raise both "no associated pointer" (when the string doesn't have any associates) and "non associated pointer" (then the string does have associates, but this pointer isn't among them)? -- Dennis Ranke