Re: FW: Win32::API help

2006-03-09 Thread willem
Bullock, Howard A. wrote:

Also, I checked the Win32::API docs and the MSDN web and could not find
any information about memcpy that would lead me to:
Win32::API('ntdll.dll', 'memcpy', 'PNN', 'V', '_cdecl'); where can I get
more information about why this was constructed in this manner?
  

memcpy uses the C calling convention,  hence the '_cdecl'  ... it is an
extension to Win32::API i added some time ago.

memcpy normally takes 2 pointers, and an integer length value.
the trick is to specify one of the pointers as an integer, and pass it
the pointer to something you got from another api, as integer value.

willem




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


FW: Win32::API help

2006-03-08 Thread Bullock, Howard A.
The list was originally omitted from the email.

[Bullock, Howard A.] 
I have tried all sorts of interations. Perl 5.8.7.815 blows up every
time I execute memcpy-Call.  At this point I am not sure where to go.
Can anyone confirm that this approach actually works? 

Also, I checked the Win32::API docs and the MSDN web and could not find
any information about memcpy that would lead me to:
Win32::API('ntdll.dll', 'memcpy', 'PNN', 'V', '_cdecl'); where can I get
more information about why this was constructed in this manner?

Willem wrote:
if you read the msdn docs, you will see that this is a pointer to the
timeofday struct.

you can obtain the contents of it using the same 'memcpy(P,N,N)' trick i
posted before.



.

use Win32::API;
use Encode qw(encode);

$GetTOD = new Win32::API('Netapi32','NetRemoteTOD','PP','N');

$native_string = server; #Windows 2003
$Unicode_String = encode(UCS-2LE, uc($native_string));

$todptr= \x00 x 4;
$rc = $GetTOD-Call($Unicode_String, $todptr);
print Returncode =  . $rc . \n;

$todptr= unpack(V, $todptr);

my $toddata= \x00 x 48;

my $memcpy= new Win32::API('ntdll.dll', 'memcpy', 'PNN', 'V', '_cdecl');
$memcpy-Call($toddata, $todptr, length($toddata));

  now you can unpack $toddata

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs