[Win32utils-devel] strcpy declaration
Daniel Berger
djberg96 at gmail.com
Thu Aug 25 11:24:12 EDT 2011
> -----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 buf
Thanks!
Regards,
Dan
More information about the win32utils-devel
mailing list