From: Park Heesob Date: 2006-03-19T12:30:24+09:00 Subject: Re: Win32API struct member help Hi, >From: "Daniel Berger" >Reply-To: ruby-talk@ruby-lang.org >To: ruby-talk@ruby-lang.org (ruby-talk ML) >Subject: Re: Win32API struct member help >Date: Sun, 19 Mar 2006 03:08:48 +0900 > >Park Heesob wrote: > > Hi, > > > > > memcpy is required for pointer reference,try this: > > > > memcpy = Win32API.new('msvcrt','memcpy','PLL','P') > > acl_buf = "\0" * 8 > > memcpy.call(acl_buf,acl_ptr.unpack('L')[0],8) > > p acl_buf.unpack('CCSSS') > >Ok, along the same lines, I'm having some trouble with GetAce(). Using >'acl_buf' from above: > >GetAce = Win32API.new('advapi32', 'GetAce', 'PLP', 'I') > GetAce = Win32API.new('advapi32', 'GetAce', 'LLP', 'I') >ace_count = acl_buf.unpack('CCSSS')[3] # 4 >ace_ptr = [0].pack('L') > >0.upto(ace_count - 1){ |i| > if GetAce.call(acl_buf, i, ace_ptr) == 0 if GetAce.call(acl_ptr.unpack('L')[0], i, ace_ptr) == 0 > next > end > > ace_buf = 0.chr * 4 # 2 BYTE, 1 WORD > memcpy.call(ace_buf, ace_ptr.unpack('L').first, 4) > > # This doesn't return the values I would have expected > p ace_buf.unpack('CCS') >} > >I would have expected somewhere between 20 and 40 for the third element >of the array returned by ace_buf.unpack('CCS'), but instead I'm getting >0. What am I doing wrong this time? > I guess GetAce requires more than acl buffer. GetAce works with original pointer ace_ptr. Regards, Park Heesob