In windows-pr strcpy is declared with a prototype of "PL". However, I can''t make that work: require ''win32/api'' include Win32 Strcpy_p = Win32::API.new(''strcpy'', ''PP'', ''L'', ''msvcrt'') Strcpy_l = Win32::API.new(''strcpy'', ''PL'', ''L'', ''msvcrt'') buf = 0.chr * 4 str = "hello" Strcpy_p.call(buf, str) # works p buf buf = 0.chr * 4 str = "hello" Strcpy_l.call(buf, str.unpack(''L'').first) # fails, segfault p buf I would think either declaration would work but apparently not. Have we simply not been using this function all this time? Regards, Dan
Hi, 2011/8/25 Daniel Berger <djberg96 at gmail.com>> In windows-pr strcpy is declared with a prototype of "PL". However, I can''t > make that work: > > require ''win32/api'' > include Win32 > > Strcpy_p = Win32::API.new(''strcpy'', ''PP'', ''L'', ''msvcrt'') > Strcpy_l = Win32::API.new(''strcpy'', ''PL'', ''L'', ''msvcrt'') > > buf = 0.chr * 4 > str = "hello" > > Strcpy_p.call(buf, str) # works > p buf > > buf = 0.chr * 4 > str = "hello" > > Strcpy_l.call(buf, str.unpack(''L'').first) # fails, segfault > p buf > > I would think either declaration would work but apparently not. > > Have we simply not been using this function all this time? > > >This works: buf = 0.chr * 5 str = "hello" Strcpy_l.call(buf, [str].pack(''p'').unpack(''L'').first) p buf Regards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/win32utils-devel/attachments/20110825/5e334b54/attachment.html>
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org [mailto:win32utils-devel- > bounces at rubyforge.org] On Behalf Of Heesob Park > Sent: Thursday, August 25, 2011 7:28 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] strcpy declaration > > Hi, > > > 2011/8/25 Daniel Berger <djberg96 at gmail.com> > > > In windows-pr strcpy is declared with a prototype of "PL". > However, I can''t > make that work: > > require ''win32/api'' > include Win32 > > Strcpy_p = Win32::API.new(''strcpy'', ''PP'', ''L'', ''msvcrt'') > Strcpy_l = Win32::API.new(''strcpy'', ''PL'', ''L'', ''msvcrt'') > > buf = 0.chr * 4 > str = "hello" > > Strcpy_p.call(buf, str) # works > p buf > > buf = 0.chr * 4 > str = "hello" > > Strcpy_l.call(buf, str.unpack(''L'').first) # fails, segfault > p buf > > I would think either declaration would work but apparently not. > > Have we simply not been using this function all this time? > > > > > > This works: > > buf = 0.chr * 5 > str = "hello" > Strcpy_l.call(buf, [str].pack(''p'').unpack(''L'').first) > p bufThanks! Regards, Dan