· 11 years ago · Sep 24, 2015, 12:44 PM
1MZ;
2#!!!!WARNING do not edit this file!!!!
3 <<e_lfanew;
4H��
5e_lfanew
6
7# See the bottom of this file for the POD documentation. Search for the
8# string '=head'.
9
10#######################################################################
11#
12# Win32::API - Perl Win32 API Import Facility
13#
14# Author: Aldo Calpini <dada@perl.it>
15# Maintainer: Cosimo Streppone <cosimo@cpan.org>
16#
17# Changes for gcc/cygwin: Daniel Risacher <magnus@alum.mit.edu>
18# ported from 0.41 based on Daniel's patch by Reini Urban <rurban@x-ray.at>
19#
20#######################################################################
21
22package Win32::API;
23 use strict;
24 use warnings;
25BEGIN {
26 require Exporter; # to export the constants to the main:: space
27
28 sub ISCYG ();
29 if($^O eq 'cygwin') {
30 BEGIN{warnings->unimport('uninitialized')}
31 die "Win32::API on Cygwin requires the cygpath tool on PATH"
32 if index(`cygpath --help`,'Usage: cygpath') == -1;
33 require File::Basename;
34 eval "sub ISCYG () { 1 }";
35 } else {
36 eval "sub ISCYG () { 0 }";
37 }
38
39
40 use vars qw( $DEBUG $sentinal @ISA @EXPORT_OK $VERSION );
41
42 @ISA = qw( Exporter );
43 @EXPORT_OK = qw( ReadMemory IsBadReadPtr MoveMemory
44 WriteMemory SafeReadWideCString ); # symbols to export on request
45
46 use Scalar::Util qw( looks_like_number weaken);
47
48 sub ERROR_NOACCESS () { 998 }
49 sub ERROR_NOT_ENOUGH_MEMORY () { 8 }
50 sub ERROR_INVALID_PARAMETER () { 87 }
51 sub APICONTROL_CC_STD () { 0 }
52 sub APICONTROL_CC_C () { 1 }
53 sub APICONTROL_CC_mask () { 0x7 }
54 sub APICONTROL_UseMI64 () { 0x8 }
55 sub APICONTROL_is_more () { 0x10 }
56 sub APICONTROL_has_proto() { 0x20 }
57 eval ' *Win32::API::Type::PTRSIZE = *Win32::API::More::PTRSIZE = *PTRSIZE = sub () { '.length(pack('p', undef)).' };'.
58 #Win64 added in 5.7.3
59 ' *Win32::API::Type::IVSIZE = *Win32::API::More::IVSIZE = *IVSIZE = sub () { '.length(pack($] >= 5.007003 ? 'J' : 'I' ,0)).' };'.
60 ' *Win32::API::Type::DEBUGCONST = *Win32::API::Struct::DEBUGCONST = *DEBUGCONST = sub () { '.(!!$DEBUG+0).' };'
61}
62
63sub DEBUG {
64 #checking flag redundant now, but keep in case of an accidental unprotected call
65 if ($Win32::API::DEBUG) {
66 printf @_ if @_ or return 1;
67 }
68 else {
69 return 0;
70 }
71}
72
73use Win32::API::Type ();
74use Win32::API::Struct ();
75
76#######################################################################
77# STATIC OBJECT PROPERTIES
78#
79#### some package-global hash to
80#### keep track of the imported
81#### libraries and procedures
82my %Libraries = ();
83my %Procedures = ();
84
85
86#######################################################################
87# dynamically load in the API extension module.
88# BEGIN required for constant subs in BOOT:
89BEGIN {
90 $VERSION = '0.82';
91 require XSLoader;
92 XSLoader::load 'Win32::API', $VERSION;
93}
94
95#######################################################################
96# PUBLIC METHODS
97#
98sub new {
99 die "Win32::API/More::new/Import is a class method that takes 2 to 6 parameters, see POD"
100 if @_ < 3 || @_ > 7;
101 my ($class, $dll, $hproc, $ccnum, $outnum) = (shift, shift);
102 if(! defined $dll){
103 $hproc = shift;
104 }
105 my ($proc, $in, $out, $callconvention) = @_;
106 my ($hdll, $freedll, $proto, $stackunwind) = (0, 0, 0, 0);
107 my $self = {};
108 if(! defined $hproc){
109 if (ISCYG() and $dll ne File::Basename::basename($dll)) {
110
111 # need to convert $dll to win32 path
112 # isn't there an API for this?
113 my $newdll = `cygpath -w "$dll"`;
114 chomp $newdll;
115 DEBUG "(PM)new: converted '$dll' to\n '$newdll'\n" if DEBUGCONST;
116 $dll = $newdll;
117 }
118
119 #### avoid loading a library more than once
120 if (exists($Libraries{$dll})) {
121 DEBUG "Win32::API::new: Library '$dll' already loaded, handle=$Libraries{$dll}\n" if DEBUGCONST;
122 $hdll = $Libraries{$dll};
123 }
124 else {
125 DEBUG "Win32::API::new: Loading library '$dll'\n" if DEBUGCONST;
126 $hdll = Win32::API::LoadLibrary($dll);
127 $freedll = 1;
128 # $Libraries{$dll} = $hdll;
129 }
130
131 #### if the dll can't be loaded, set $! to Win32's GetLastError()
132 if (!$hdll) {
133 $! = Win32::GetLastError();
134 DEBUG "FAILED Loading library '$dll': $^E\n" if DEBUGCONST;
135 return undef;
136 }
137 }
138 else{
139 if(!looks_like_number($hproc) || IsBadReadPtr($hproc, 4)){
140 Win32::SetLastError(ERROR_NOACCESS);
141 DEBUG "FAILED Function pointer '$hproc' is not a valid memory location\n" if DEBUGCONST;
142 return undef;
143 }
144 }
145 #### determine if we have a prototype or not, outtype is for future use in XS
146 if ((not defined $in) and (not defined $out)) {
147 ($proc, $self->{in}, $self->{intypes}, $outnum, $self->{outtype},
148 $ccnum) = parse_prototype($class, $proc);
149 if( ! $proc ){
150 Win32::API::FreeLibrary($hdll) if $freedll;
151 Win32::SetLastError(ERROR_INVALID_PARAMETER);
152 return undef;
153 }
154 $proto = 1;
155 }
156 else {
157 $self->{in} = [];
158 my $self_in = $self->{in}; #avoid hash derefing
159 if (ref($in) eq 'ARRAY') {
160 foreach (@$in) {
161 push(@{$self_in}, $class->type_to_num($_));
162 }
163 }
164 else {
165 my @in = split '', $in;
166 foreach (@in) {
167 push(@{$self_in}, $class->type_to_num($_));
168 }
169 }#'V' must be one and ONLY letter for "in"
170 foreach(@{$self_in}){
171 if($_ == 0){
172 if(@{$self_in} != 1){
173 Win32::API::FreeLibrary($hdll) if $freedll;
174 die "Win32::API 'V' for in prototype must be the only parameter";
175 } else {undef(@{$self_in});} #empty arr, as if in param was ""
176 }
177 }
178 $outnum = $class->type_to_num($out, 1);
179 $ccnum = calltype_to_num($callconvention);
180 }
181
182 if(!$hproc){ #if not non DLL func
183 #### first try to import the function of given name...
184 $hproc = Win32::API::GetProcAddress($hdll, $proc);
185
186 #### ...then try appending either A or W (for ASCII or Unicode)
187 if (!$hproc) {
188 my $tproc = $proc;
189 $tproc .= (IsUnicode() ? "W" : "A");
190
191 # print "Win32::API::new: procedure not found, trying '$tproc'...\n";
192 $hproc = Win32::API::GetProcAddress($hdll, $tproc);
193 }
194
195 #### ...if all that fails, give up, $! setting is back compat, $! is deprecated
196 if (!$hproc) {
197 my $err = $! = Win32::GetLastError();
198 DEBUG "FAILED GetProcAddress for Proc '$proc': $^E\n" if DEBUGCONST;
199 Win32::API::FreeLibrary($hdll) if $freedll;
200 Win32::SetLastError($err);
201 return undef;
202 }
203 DEBUG "GetProcAddress('$proc') = '$hproc'\n" if DEBUGCONST;
204 }
205 else {
206 DEBUG "Using non-DLL function pointer '$hproc' for '$proc'\n" if DEBUGCONST;
207 }
208 if(PTRSIZE == 4 && $ccnum == APICONTROL_CC_C) {#fold out on WIN64
209 #calculate add to ESP amount, in units of 4, will be *4ed later
210 $stackunwind += $_ == T_QUAD || $_ == T_DOUBLE ? 2 : 1 for(@{$self->{in}});
211 if($stackunwind > 0xFFFF) {
212 goto too_many_in_params;
213 }
214 }
215 # if a prototype has 8 byte types on 32bit, $stackunwind will be higher than
216 # length of {in} letter array, so 2 different checks need to be done
217 if($#{$self->{in}} > 0xFFFF) {
218 too_many_in_params:
219 DEBUG "FAILED This function has too many parameters (> ~65535) \n" if DEBUGCONST;
220 Win32::API::FreeLibrary($hdll) if $freedll;
221 Win32::SetLastError(ERROR_NOT_ENOUGH_MEMORY);
222 return undef;
223 }
224 #### ok, let's stuff the object
225 $self->{procname} = $proc;
226 $self->{dll} = $hdll;
227 $self->{dllname} = $dll;
228
229 $outnum &= ~T_FLAG_NUMERIC;
230 my $control;
231 $self->{weakapi} = \$control;
232 weaken($self->{weakapi});
233 $control = pack( 'L'
234 .'L'
235 .(PTRSIZE == 8 ? 'Q' : 'L')
236 .(PTRSIZE == 8 ? 'Q' : 'L')
237 .(PTRSIZE == 8 ? 'Q' : 'L')
238 .(PTRSIZE == 8 ? '' : 'L')
239 ,($class eq "Win32::API::More" ? APICONTROL_is_more : 0)
240 | ($proto ? APICONTROL_has_proto : 0)
241 | $ccnum
242 | (PTRSIZE == 8 ? 0 : $stackunwind << 8)
243 | $outnum << 24
244 , scalar(@{$self->{in}}) * PTRSIZE #in param count, in SV * units
245 , $hproc
246 , \($self->{weakapi})+0 #weak api obj ref
247 , (exists $self->{intypes} ? ($self->{intypes})+0 : 0)
248 , 0); #padding to align to 8 bytes on 32 bit only
249 #align to 16 bytes
250 $control .= "\x00" x ((((length($control)+ 15) >> 4) << 4)-length($control));
251 #make a APIPARAM template array
252 my ($i, $arr_end) = (0, scalar(@{$self->{in}}));
253 for(; $i< $arr_end; $i++) {
254 my $tin = $self->{in}[$i];
255 #unsigned meaningless no sign vs zero extends are done bc uv/iv is
256 #the biggest native integer on the cpu, big to small is truncation
257 #numeric is implemented as T_NUMCHAR for in, keeps asm jumptable clean
258 $tin &= ~(T_FLAG_UNSIGNED|T_FLAG_NUMERIC);
259 $tin--; #T_VOID doesn't exist as in param in XS
260 #put index of param array slice in unused space for croaks, why not?
261 $control .= "\x00" x 8 . pack('CCSSS', $tin, 0, 0, $i, $i+1);
262 }
263 _Align($control, 16); #align the whole PVX to 16 bytes for SSE moves
264
265 #### keep track of the imported function
266 if(defined $dll){
267 $Libraries{$dll} = $hdll;
268 $Procedures{$dll}++;
269 }
270 DEBUG "Object blessed!\n" if DEBUGCONST;
271
272 my $ref = bless(\$control, $class);
273 SetMagicSV($ref, $self);
274 return $ref;
275}
276
277sub Import {
278 my $closure = shift->new(@_)
279 or return undef;
280 my $procname = ${Win32::API::GetMagicSV($closure)}{procname};
281 #dont allow "sub main:: {0;}"
282 Win32::SetLastError(ERROR_INVALID_PARAMETER), return undef if $procname eq '';
283 _ImportXS($closure, (caller)[0].'::'.$procname);
284 return $closure;
285}
286
287#######################################################################
288# PRIVATE METHODS
289#
290sub DESTROY {
291 my ($self) = GetMagicSV($_[0]);
292
293 return if ! defined $self->{dllname};
294 #### decrease this library's procedures reference count
295 $Procedures{$self->{dllname}}--;
296
297 #### once it reaches 0, free it
298 if ($Procedures{$self->{dllname}} == 0) {
299 DEBUG "Win32::API::DESTROY: Freeing library '$self->{dllname}'\n" if DEBUGCONST;
300 Win32::API::FreeLibrary($Libraries{$self->{dllname}});
301 delete($Libraries{$self->{dllname}});
302 }
303}
304
305# Convert calling convention string (_cdecl|__stdcall)
306# to a C const. Unknown counts as __stdcall
307#
308sub calltype_to_num {
309 my $type = shift;
310
311 if (!$type || $type eq "__stdcall" || $type eq "WINAPI" || $type eq "NTAPI"
312 || $type eq "CALLBACK" ) {
313 return APICONTROL_CC_STD;
314 }
315 elsif ($type eq "_cdecl" || $type eq "__cdecl" || $type eq "WINAPIV") {
316 return APICONTROL_CC_C;
317 }
318 else {
319 warn "unknown calling convention: '$type'";
320 return APICONTROL_CC_STD;
321 }
322}
323
324
325sub type_to_num {
326 die "wrong class" if shift ne "Win32::API";
327 my $type = shift;
328 my $out = shift;
329 my ($num, $numeric);
330 if(index($type, 'num', 0) == 0){
331 substr($type, 0, length('num'), '');
332 $numeric = 1;
333 }
334 else{
335 $numeric = 0;
336 }
337
338 if ( $type eq 'N'
339 or $type eq 'n'
340 or $type eq 'l'
341 or $type eq 'L'
342 or ( PTRSIZE == 8 and $type eq 'Q' || $type eq 'q'))
343 {
344 $num = T_NUMBER;
345 }
346 elsif ($type eq 'P'
347 or $type eq 'p')
348 {
349 $num = T_POINTER;
350 }
351 elsif ($type eq 'I'
352 or $type eq 'i')
353 {
354 $num = T_INTEGER;
355 }
356 elsif ($type eq 'f'
357 or $type eq 'F')
358 {
359 $num = T_FLOAT;
360 }
361 elsif ($type eq 'D'
362 or $type eq 'd')
363 {
364 $num = T_DOUBLE;
365 }
366 elsif ($type eq 'c'
367 or $type eq 'C')
368 {
369 $num = $numeric ? T_NUMCHAR : T_CHAR;
370 }
371 elsif (PTRSIZE == 4 and $type eq 'q' || $type eq 'Q')
372 {
373 $num = T_QUAD;
374 }
375 elsif($type eq '>'){
376 die "Win32::API does not support pass by copy structs as function arguments";
377 }
378 else {
379 $num = T_VOID; #'V' takes this branch, which is T_VOID in C
380 }#not valid return types of the C func
381 if(defined $out) {#b/B remains private/undocumented
382 die "Win32::API invalid return type, structs and ".
383 "callbacks as return types not supported"
384 if($type =~ m/^s|S|t|T|b|B|k|K$/);
385 }
386 else {#in type
387 if ($type eq 's' or $type eq 'S' or $type eq 't' or $type eq 'T')
388 {
389 $num = T_STRUCTURE;
390 }
391 elsif ($type eq 'b'
392 or $type eq 'B')
393 {
394 $num = T_POINTERPOINTER;
395 }
396 elsif ($type eq 'k'
397 or $type eq 'K')
398 {
399 $num = T_CODE;
400 }
401 }
402 $num |= T_FLAG_NUMERIC if $numeric;
403 return $num;
404}
405
406package Win32::API::More;
407
408use vars qw( @ISA );
409@ISA = qw ( Win32::API );
410sub type_to_num {
411 die "wrong class" if shift ne "Win32::API::More";
412 my $type = shift;
413 my $out = shift;
414 my ($num, $numeric);
415 if(index($type, 'num', 0) == 0){
416 substr($type, 0, length('num'), '');
417 $numeric = 1;
418 }
419 else{
420 $numeric = 0;
421 }
422
423 if ( $type eq 'N'
424 or $type eq 'n'
425 or $type eq 'l'
426 or $type eq 'L'
427 or ( PTRSIZE == 8 and $type eq 'Q' || $type eq 'q')
428 or (! $out and # in XS short 'in's are interger/numbers code
429 $type eq 'S'
430 || $type eq 's'))
431 {
432 $num = Win32::API::T_NUMBER;
433 if(defined $out && ($type eq 'N' || $type eq 'L'
434 || $type eq 'S' || $type eq 'Q')){
435 $num |= Win32::API::T_FLAG_UNSIGNED;
436 }
437 }
438 elsif ($type eq 'P'
439 or $type eq 'p')
440 {
441 $num = Win32::API::T_POINTER;
442 }
443 elsif ($type eq 'I'
444 or $type eq 'i')
445 {
446 $num = Win32::API::T_INTEGER;
447 if(defined $out && $type eq 'I'){
448 $num |= Win32::API::T_FLAG_UNSIGNED;
449 }
450 }
451 elsif ($type eq 'f'
452 or $type eq 'F')
453 {
454 $num = Win32::API::T_FLOAT;
455 }
456 elsif ($type eq 'D'
457 or $type eq 'd')
458 {
459 $num = Win32::API::T_DOUBLE;
460 }
461 elsif ($type eq 'c'
462 or $type eq 'C')
463 {
464 $num = $numeric ? Win32::API::T_NUMCHAR : Win32::API::T_CHAR;
465 if(defined $out && $type eq 'C'){
466 $num |= Win32::API::T_FLAG_UNSIGNED;
467 }
468 }
469 elsif (PTRSIZE == 4 and $type eq 'q' || $type eq 'Q')
470 {
471 $num = Win32::API::T_QUAD;
472 if(defined $out && $type eq 'Q'){
473 $num |= Win32::API::T_FLAG_UNSIGNED;
474 }
475 }
476 elsif ($type eq 's') #4 is only used for out params
477 {
478 $num = Win32::API::T_SHORT;
479 }
480 elsif ($type eq 'S')
481 {
482 $num = Win32::API::T_SHORT | Win32::API::T_FLAG_UNSIGNED;
483 }
484 elsif($type eq '>'){
485 die "Win32::API does not support pass by copy structs as function arguments";
486 }
487 else {
488 $num = Win32::API::T_VOID; #'V' takes this branch, which is T_VOID in C
489 } #not valid return types of the C func
490 if(defined $out) {#b/B remains private/undocumented
491 die "Win32::API invalid return type, structs and ".
492 "callbacks as return types not supported"
493 if($type =~ m/^t|T|b|B|k|K$/);
494 }
495 else {#in type
496 if ( $type eq 't'
497 or $type eq 'T')
498 {
499 $num = Win32::API::T_STRUCTURE;
500 }
501 elsif ($type eq 'b'
502 or $type eq 'B')
503 {
504 $num = Win32::API::T_POINTERPOINTER;
505 }
506 elsif ($type eq 'k'
507 or $type eq 'K')
508 {
509 $num = Win32::API::T_CODE;
510 }
511 }
512 $num |= Win32::API::T_FLAG_NUMERIC if $numeric;
513 return $num;
514}
515package Win32::API;
516
517sub parse_prototype {
518 my ($class, $proto) = @_;
519
520 my @in_params = ();
521 my @in_types = (); #one day create a BNF-ish formal grammer parser here
522 if ($proto =~ /^\s*((?:(?:un|)signed\s+|) #optional signedness
523 \S+)(?:\s*(\*)\s*|\s+) #type and maybe a *
524 (?:(\w+)\s+)? # maybe a calling convention
525 (\S+)\s* #func name
526 \(([^\)]*)\) #param list
527 /x) {
528 my $ret = $1.(defined($2)?$2:'');
529 my $callconvention = $3;
530 my $proc = $4;
531 my $params = $5;
532
533 $params =~ s/^\s+//;
534 $params =~ s/\s+$//;
535
536 DEBUG "(PM)parse_prototype: got PROC '%s'\n", $proc if DEBUGCONST;
537 DEBUG "(PM)parse_prototype: got PARAMS '%s'\n", $params if DEBUGCONST;
538
539 foreach my $param (split(/\s*,\s*/, $params)) {
540 my ($type, $name);
541 #match "in_t* _var" "in_t * _var" "in_t *_var" "in_t _var" "in_t*_var" supported
542 #unsigned or signed or nothing as prefix supported
543 # "in_t ** _var" and "const in_t* var" not supported
544 if ($param =~ /((?:(?:un|)signed\s+|)\w+)(?:\s*(\*)\s*|\s+)(\w+)/) {
545 ($type, $name) = ($1.(defined($2)? $2:''), $3);
546 }
547 {
548 BEGIN{warnings->unimport('uninitialized')}
549 if($type eq '') {goto BADPROTO;} #something very wrong, bail out
550 }
551 my $packing = Win32::API::Type::packing($type);
552 if (defined $packing && $packing ne '>') {
553 if (Win32::API::Type::is_pointer($type)) {
554 DEBUG "(PM)parse_prototype: IN='%s' PACKING='%s' API_TYPE=%d\n",
555 $type,
556 $packing,
557 $class->type_to_num('P') if DEBUGCONST;
558 push(@in_params, $class->type_to_num('P'));
559 }
560 else {
561 DEBUG "(PM)parse_prototype: IN='%s' PACKING='%s' API_TYPE=%d\n",
562 $type,
563 $packing,
564 $class->type_to_num(Win32::API::Type->packing($type, undef, 1)) if DEBUGCONST;
565 push(@in_params, $class->type_to_num(Win32::API::Type->packing($type, undef, 1)));
566 }
567 }
568 elsif (Win32::API::Struct::is_known($type)) {
569 DEBUG "(PM)parse_prototype: IN='%s' PACKING='%s' API_TYPE=%d\n",
570 $type, 'T', Win32::API::More->type_to_num('T') if DEBUGCONST;
571 push(@in_params, Win32::API::More->type_to_num('T'));
572 }
573 else {
574 warn
575 "Win32::API::parse_prototype: WARNING unknown parameter type '$type'";
576 push(@in_params, $class->type_to_num('I'));
577 }
578 push(@in_types, $type);
579
580 }
581 DEBUG "parse_prototype: IN=[ @in_params ]\n" if DEBUGCONST;
582
583
584 if (Win32::API::Type::is_known($ret)) {
585 if (Win32::API::Type::is_pointer($ret)) {
586 DEBUG "parse_prototype: OUT='%s' PACKING='%s' API_TYPE=%d\n",
587 $ret,
588 Win32::API::Type->packing($ret),
589 $class->type_to_num('P') if DEBUGCONST;
590 return ($proc, \@in_params, \@in_types, $class->type_to_num('P', 1),
591 $ret, calltype_to_num($callconvention));
592 }
593 else {
594 DEBUG "parse_prototype: OUT='%s' PACKING='%s' API_TYPE=%d\n",
595 $ret,
596 Win32::API::Type->packing($ret),
597 $class->type_to_num(Win32::API::Type->packing($ret, undef, 1), 1) if DEBUGCONST;
598 return (
599 $proc, \@in_params, \@in_types,
600 $class->type_to_num(Win32::API::Type->packing($ret, undef, 1), 1),
601 $ret, calltype_to_num($callconvention)
602 );
603 }
604 }
605 else {
606 warn
607 "Win32::API::parse_prototype: WARNING unknown output parameter type '$ret'";
608 return ($proc, \@in_params, \@in_types, $class->type_to_num('I', 1),
609 $ret, calltype_to_num($callconvention));
610 }
611
612 }
613 else {
614 BADPROTO:
615 warn "Win32::API::parse_prototype: bad prototype '$proto'";
616 return undef;
617 }
618}
619
620#
621# XXX hack, see the proper implementation in TODO
622# The point here is don't let fork children free the parent's DLLs.
623# CLONE runs on ::API and ::More, that's bad and causes a DLL leak, make sure
624# CLONE dups the DLL handles only once per CLONE
625# GetModuleHandleEx was not used since that is a WinXP and newer function, not Win2K.
626# GetModuleFileName was used to get full DLL pathname incase SxS/multiple DLLs
627# with same file name exist in the process. Even if the dll was loaded as a
628# relative path initially, later SxS can load a DLL with a different full path
629# yet same file name, and then LoadLibrary'ing the original relative path
630# might increase the refcount on the wrong DLL or return a different HMODULE
631sub CLONE {
632 return if $_[0] ne "Win32::API";
633
634 _my_cxt_clone();
635 foreach( keys %Libraries){
636 if($Libraries{$_} != Win32::API::LoadLibrary(Win32::API::GetModuleFileName($Libraries{$_}))){
637 die "Win32::API::CLONE unable to clone DLL \"$Libraries{$_}\" Unicode Problem??";
638 }
639 }
640}
641
6421;
643
644__END__
645
646#######################################################################
647# DOCUMENTATION
648#
649
650=head1 NAME
651
652Win32::API - Perl Win32 API Import Facility
653
654=head1 SYNOPSIS
655
656 #### Method 1: with prototype
657
658 use Win32::API;
659 $function = Win32::API::More->new(
660 'mydll', 'int sum_integers(int a, int b)'
661 );
662 #### $^E is non-Cygwin only
663 die "Error: $^E" if ! $function;
664 #### or on Cygwin and non-Cygwin
665 die "Error: ".(Win32::FormatMessage(Win32::GetLastError())) if ! $function;
666 ####
667 $return = $function->Call(3, 2);
668
669 #### Method 2: with prototype and your function pointer
670
671 use Win32::API;
672 $function = Win32::API::More->new(
673 undef, 38123456, 'int name_ignored(int a, int b)'
674 );
675 die "Error: $^E" if ! $function; #$^E is non-Cygwin only
676 $return = $function->Call(3, 2);
677
678 #### Method 3: with parameter list
679
680 use Win32::API;
681 $function = Win32::API::More->new(
682 'mydll', 'sum_integers', 'II', 'I'
683 );
684 die "Error: $^E" if ! $function; #$^E is non-Cygwin only
685 $return = $function->Call(3, 2);
686
687 #### Method 4: with parameter list and your function pointer
688
689 use Win32::API;
690 $function = Win32::API::More->new(
691 undef, 38123456, 'name_ignored', 'II', 'I'
692 );
693 die "Error: $^E" if ! $function; #$^E is non-Cygwin only
694 $return = $function->Call(3, 2);
695
696 #### Method 5: with Import (slightly faster than ->Call)
697
698 use Win32::API;
699 $function = Win32::API::More->Import(
700 'mydll', 'int sum_integers(int a, int b)'
701 );
702 die "Error: $^E" if ! $function; #$^E is non-Cygwin only
703 $return = sum_integers(3, 2);
704
705
706=for LATER-UNIMPLEMENTED
707 #### or
708 use Win32::API mydll => 'int sum_integers(int a, int b)';
709 $return = sum_integers(3, 2);
710
711
712=head1 ABSTRACT
713
714With this module you can import and call arbitrary functions
715from Win32's Dynamic Link Libraries (DLL) or arbitrary functions for
716which you have a pointer (MS COM, etc), without having
717to write an XS extension. Note, however, that this module
718can't do everything. In fact, parameters input and output is
719limited to simpler cases.
720
721A regular B<XS> extension is always safer and faster anyway.
722
723The current version of Win32::API is always available at your
724nearest CPAN mirror:
725
726 http://search.cpan.org/dist/Win32-API/
727
728A short example of how you can use this module (it just gets the PID of
729the current process, eg. same as Perl's internal C<$$>):
730
731 use Win32::API;
732 Win32::API::More->Import("kernel32", "int GetCurrentProcessId()");
733 $PID = GetCurrentProcessId();
734
735Starting with 0.69. Win32::API initiated objects are deprecated due to numerous
736bugs and improvements, use Win32::API::More now. The use statement remains
737as C<use Win32::API;>.
738
739The possibilities are nearly infinite (but not all are good :-).
740Enjoy it.
741
742=head1 DESCRIPTION
743
744To use this module put the following line at the beginning of your script:
745
746 use Win32::API;
747
748You can now use the C<new()> function of the Win32::API module to create a
749new Win32::API::More object (see L<IMPORTING A FUNCTION>) and then invoke the
750C<Call()> method on this object to perform a call to the imported API
751(see L<CALLING AN IMPORTED FUNCTION>).
752
753Starting from version 0.40, you can also avoid creating a Win32::API::More object
754and instead automatically define a Perl sub with the same name of the API
755function you're importing. This 2nd way using C<Import> to create a sub instead
756of an object is slightly faster than doing C<-E<gt>Call()>. The details of the
757API definitions are the same, just the method name is different:
758
759 my $GetCurrentProcessId = Win32::API::More->new(
760 "kernel32", "int GetCurrentProcessId()"
761 );
762 die "Failed to import GetCurrentProcessId" if !$GetCurrentProcessId;
763 $GetCurrentProcessId->UseMI64(1);
764 my $PID = $GetCurrentProcessId->Call();
765
766 #### vs.
767
768 my $UnusedGCPI = Win32::API::More->Import("kernel32", "int GetCurrentProcessId()");
769 die "Failed to import GetCurrentProcessId" if !$UnusedGCPI;
770 $UnusedGCPI->UseMI64(1);
771 $PID = GetCurrentProcessId();
772
773Note that C<Import> returns the Win32::API obj on success and false on failure
774(in which case you can check the content of C<$^E>). This allows some settings
775to be set through method calls that can't be specified as a parameter to Import,
776yet still have the convience of not writing C<-E<gt>Call()>. The Win32::API obj
777does not need to be assigned to a scalar. C<unless(Win32::API::More-E<gt>Import>
778is fine. Prior to v0.76_02, C<Import> returned returned 1 on success and 0 on
779failure.
780
781=head2 IMPORTING A FUNCTION
782
783You can import a function from a 32 bit Dynamic Link Library (DLL) file with
784the C<new()> function or, starting in 0.69, supply your own function pointer.
785This will create a Perl object that contains the reference to that function,
786which you can later C<Call()>.
787
788What you need to know is the prototype of the function you're going to import
789(eg. the definition of the function expressed in C syntax).
790
791Starting from version 0.40, there are 2 different approaches for this step:
792(the preferred) one uses the prototype directly, while the other (now deprecated)
793one uses Win32::API's internal representation for parameters.
794
795=head2 IMPORTING A FUNCTION BY PROTOTYPE
796
797You need to pass 2 or 3 parameters:
798
799=over 4
800
801=item 1.
802
803The name of the library from which you want to import the function. If the
804name is undef, you are requesting a object created from a function pointer,
805and must supply item 2.
806
807=item 2.
808
809This parameter is optional, most people should skip it, skip does not mean
810supplying undef. Supply a function pointer in the format of number 1234, not
811string "\x01\x02\x03\x04". Undef will be returned if the pointer is not
812readable, L<Win32::GetLastError|Win32/Win32::GetLastError()>/L<perlvar/"$^E">
813will be C<ERROR_NOACCESS>.
814
815=item 3.
816
817The C prototype of the function. If you are using a function pointer, the name
818of the function should be something "friendly" to you and no attempt is made
819to retrieve such a name from any DLL's export table. This name for a function
820pointer is also used for Import().
821
822=back
823
824When calling a function imported with a prototype, if you pass an
825undefined Perl scalar to one of its arguments, it will be
826automatically turned into a C C<NULL> value.
827
828See L<Win32::API::Type> for a list of the known parameter types and
829L<Win32::API::Struct> for information on how to define a structure.
830
831If a prototype type is exactly C<signed char> or C<unsigned char> for an
832"in" parameter or the return parameter, and for "in" parameters only
833C<signed char *> or C<unsigned char *> the parameters will be treated as a
834number, C<0x01>, not C<"\x01">. "UCHAR" is not "unsigned char". Change the
835C prototype if you want numeric handling for your chars.
836
837=head2 IMPORTING A FUNCTION WITH A PARAMETER LIST
838
839You need to pass at minimum 4 parameters.
840
841=over 4
842
843=item 1.
844The name of the library from which you want to import the function.
845
846=item 2.
847This parameter is optional, most people should skip it, skip does not mean
848supplying undef. Supply a function pointer in the format of number C<1234>,
849not string C<"\x01\x02\x03\x04">. Undef will be returned if the pointer is not
850readable, L<Win32::GetLastError|Win32/Win32::GetLastError()>/L<perlvar/"$^E">
851will be C<ERROR_NOACCESS>.
852
853=item 3.
854The name of the function (as exported by the library) or for function pointers
855a name that is "friendly" to you. This name for a function pointer is also used
856for Import(). No attempt is made to retrieve such a name from any DLL's export
857table in the 2nd case.
858
859=item 4.
860The number and types of the arguments the function expects as input.
861
862=item 5.
863The type of the value returned by the function.
864
865=item 6.
866And optionally you can specify the calling convention, this defaults to
867'__stdcall', alternatively you can specify '_cdecl' or '__cdecl' (API > v0.68)
868or (API > v0.70_02) 'WINAPI', 'NTAPI', 'CALLBACK' (__stdcall), 'WINAPIV' (__cdecl) .
869False is __stdcall. Vararg functions are always cdecl. MS DLLs are typically
870stdcall. Non-MS DLLs are typically cdecl. If API > v0.75, mixing up the calling
871convention on 32 bits is detected and Perl will C<croak> an error message and
872C<die>.
873
874=back
875
876To better explain their meaning, let's suppose that we
877want to import and call the Win32 API C<GetTempPath()>.
878This function is defined in C as:
879
880 DWORD WINAPI GetTempPathA( DWORD nBufferLength, LPSTR lpBuffer );
881
882This is documented in the B<Win32 SDK Reference>; you can look
883for it on the Microsoft's WWW site, or in your C compiler's
884documentation, if you own one.
885
886=over 4
887
888=item B<1.>
889
890The first parameter is the name of the library file that
891exports this function; our function resides in the F<KERNEL32.DLL>
892system file.
893
894When specifying this name as parameter, the F<.DLL> extension
895is implicit, and if no path is given, the file is searched through
896a couple of directories, including:
897
898=over 4
899
900=item 1. The directory from which the application loaded.
901
902=item 2. The current directory.
903
904=item 3. The Windows system directory (eg. c:\windows\system or system32).
905
906=item 4. The Windows directory (eg. c:\windows).
907
908=item 5. The directories that are listed in the PATH environment variable.
909
910=back
911
912You may, but don't have to write F<C:\windows\system\kernel32.dll>; or
913F<kernel32.dll>, only F<kernel32> is enough:
914
915 $GetTempPath = new Win32::API::More('kernel32', ...
916
917=item B<2.>
918
919Since this function is from a DLL, skip the 2nd parameter. Skip does not
920mean supplying undef.
921
922=item B<3.>
923
924Now for the real second parameter: the name of the function.
925It must be written exactly as it is exported
926by the library (case is significant here).
927If you are using Windows 95 or NT 4.0, you can use the B<Quick View>
928command on the DLL file to see the function it exports.
929Remember that you can only import functions from 32 or 64 bit DLLs:
930in Quick View, the file's characteristics should report
931somewhere "32 bit word machine"; as a rule of thumb,
932when you see that all the exported functions are in upper case,
933the DLL is a 16 bit one and you can't use it. You also can not load a 32 bit
934DLL into a 64 bit Perl, or vice versa. If you try, C<new>/C<Import> will fail
935and C<$^E> will be C<ERROR_BAD_EXE_FORMAT>.
936If their capitalization looks correct, then it's probably a 32 bit
937DLL. If you have Platform SDK or Visual Studio, you can use the Dumpbin
938tool. Call it as C<dumpbin /exports name_of_dll.dll> on the command line.
939If you have Mingw GCC, use objdump as
940C<objdump -x name_of_dll.dll E<gt> dlldump.txt> and search for the word exports
941in the very long output.
942
943Also note that many Win32 APIs are exported twice, with the addition of
944a final B<A> or B<W> to their name, for - respectively - the ASCII
945and the Unicode version.
946When a function name is not found, Win32::API will actually append
947an B<A> to the name and try again; if the extension is built on a
948Unicode system, then it will try with the B<W> instead.
949So our function name will be:
950
951 $GetTempPath = new Win32::API::More('kernel32', 'GetTempPath', ...
952
953In our case C<GetTempPath> is really loaded as C<GetTempPathA>.
954
955=item B<4.>
956
957The third parameter, the input parameter list, specifies how many
958arguments the function wants, and their types. It can be passed as
959a single string, in which each character represents one parameter,
960or as a list reference. The following forms are valid:
961
962 "abcd"
963 [a, b, c, d]
964 \@LIST
965
966But those are not:
967
968 (a, b, c, d)
969 @LIST
970
971The number of characters, or elements in the list, specifies the number
972of parameters, and each character or element specifies the type of an
973argument; allowed types are:
974
975=over 4
976
977=item C<I>:
978value is an unsigned integer (unsigned int)
979
980=item C<i>:
981value is an signed integer (signed int or int)
982
983=item C<N>:
984value is a unsigned pointer sized number (unsigned long)
985
986=item C<n>:
987value is a signed pointer sized number (signed long or long)
988
989=item C<Q>:
990value is a unsigned 64 bit integer number (unsigned long long, unsigned __int64)
991See next item for details.
992
993=item C<q>:
994value is a signed 64 bit integer number (long long, __int64)
995If your perl has 'Q'/'q' quads support for L<perlfunc/pack> then Win32::API's 'q'
996is a normal perl numeric scalar. All 64 bit Perls have quad support. Almost no
99732 bit Perls have quad support. On 32 bit Perls, without quad support,
998Win32::API's 'q'/'Q' letter is a packed 8 byte string. So C<0x8000000050000000>
999from a perl with native Quad support would be written as
1000C<"\x00\x00\x00\x50\x00\x00\x00\x80"> on a 32 bit Perl without Quad support.
1001To improve the use of 64 bit integers with Win32::API on a 32 bit Perl without
1002Quad support, there is a per Win32::API::* object setting called L</UseMI64>
1003that causes all quads to be accepted as, and returned as L<Math::Int64> objects.
1004For "in" params in Win32::API and Win32::API::More and "out" in
1005Win32::API::Callback only, if the argument is a reference, it will automatically
1006be treated as a Math::Int64 object without having to previously call
1007L</UseMI64>.
1008
1009=item C<F>:
1010value is a single precision (4 bytes) floating point number (float)
1011
1012=item C<D>:
1013value is a double precision (8 bytes) floating point number (double)
1014
1015=item C<S>:
1016value is a unsigned short (unsigned short)
1017
1018=item C<s>:
1019value is a signed short (signed short or short)
1020
1021=item C<C>:
1022value is a char (char), pass as C<"a">, not C<97>, C<"abc"> will truncate to C<"a">
1023
1024=item C<P>:
1025value is a pointer (to a string, structure, etc...)
1026padding out the buffer string is required, buffer overflow detection is
1027performed. Pack and unpack the data yourself. If P is a return type, only
1028null terminated strings or NULL pointer are supported. If P is an in type, NULL
1029is integer C<0>. C<undef>, C<"0">, and C<""+0> are not integer C<0>, C<"0"+0> is
1030integer C<0>.
1031
1032It is suggested to
1033not use P as a return type and instead use N and read the memory yourself, and
1034free the pointer if applicable. This pointer is effectively undefined after the
1035C function returns control to Perl. The C function may not hold onto it after
1036the C function returns control. There are exceptions where the pointer will
1037remain valid after the C function returns control, but tread at your own risk,
1038and at your knowledge of Perl interpreter's C internals.
1039
1040=item C<T>:
1041value is a Win32::API::Struct object, in parameter only, pass by reference
1042(pointer) only, pass by copy not implemented, see other sections for more
1043
1044=item C<K>:
1045value is a Win32::API::Callback object, in parameter only, (see L<Win32::API::Callback>)
1046
1047=item C<V>:
1048no value, no parameters, stands for C<void>, may not be combined with any other
1049letters, equivalent to a ""
1050
1051=back
1052
1053For beginners, just skip this paragraph.
1054Note, all parameter types are little endian. This is probably what you want
1055unless the documentation for the C function you are calling explicitly says
1056the parameters must be big endian. If there is no documentation for your C
1057function or no mention of endianess in the documentation, this doesn't apply
1058to you and skip the rest of this paragraph. There is no inherent support
1059for big endian parameters. Perl's scalar numbers model is that numeric
1060scalars are effectively opaque and their machine representation is
1061irrelevant. On Windows Perl, scalar numbers are little endian
1062internally. So C<$number = 5; print "$number";> will put 5 on the screen.
1063C<$number> given to Win32::API will pass little endian integer 5 to the C
1064function call. This is almost surly what you want. If you really must pass
1065a big endian integer, do C<$number = unpack('L', pack('N', 5));>, then
1066C<print "$number";> will put 83886080 on the screen, but this is big endian 5,
1067and passing 83886080 to C<-E<gt>Call()> will make sure that
1068the C function is getting big endian 5. See L<perlpacktut> for more.
1069
1070Our function needs two parameters: a number (C<DWORD>) and a pointer to a
1071string (C<LPSTR>):
1072
1073 $GetTempPath = new Win32::API('kernel32', 'GetTempPath', 'NP', ...
1074
1075=item B<4.>
1076
1077The fourth is the type of the value returned by the
1078function. It can be one of the types seen above, plus another type named B<V>
1079(for C<void>), used for functions that do not return a value.
1080In our example the value returned by GetTempPath() is a C<DWORD>, which is a
1081typedef for unsigned long, so our return type will be B<N>:
1082
1083 $GetTempPath = new Win32::API::More('kernel32', 'GetTempPath', 'NP', 'N');
1084
1085Now the line is complete, and the GetTempPath() API is ready to be used
1086in Perl. Before calling it, you should test that $GetTempPath is
1087L<perlfunc/defined>, otherwise errors such as the function or the library could
1088not be loaded or the C prototype was unparsable happened, and no object was
1089created. If the return value is undefined, to get detailed error status, use
1090L<perlvar/"$^E"> or L<Win32::GetLastError|Win32/Win32::GetLastError()>. C<$^E>
1091is slower than C<Win32::GetLastError> and useless on Cygwin, but C<$^E> in
1092string context provides a readable description of the error. In numeric context,
1093C<$^E> is equivelent to C<Win32::GetLastError>. C<Win32::GetLastError> always
1094returns an integer error code. You may use
1095L<Win32::FormatMessage|Win32/Win32::FormatMessage()> to convert an integer error
1096code to a readable description on Cygwin and Native builds of Perl.
1097
1098Our definition, with error checking added, should then look like this:
1099
1100 $GetTempPath = new Win32::API::More('kernel32', 'GetTempPath', 'NP', 'N');
1101 if(not defined $GetTempPath) {
1102 die "Can't import API GetTempPath: $^E\n";
1103 }
1104
1105=back
1106
1107=head2 CALLING AN IMPORTED FUNCTION
1108
1109To effectively make a call to an imported function you must use the
1110Call() method on the Win32::API object you created.
1111Continuing with the example from the previous paragraph,
1112the GetTempPath() API can be called using the method:
1113
1114 $GetTempPath->Call(...
1115
1116Of course, parameters have to be passed as defined in the import phase.
1117In particular, if the number of parameters does not match (in the example,
1118if GetTempPath() is called with more or less than two parameters),
1119Perl will C<croak> an error message and C<die>.
1120
1121The two parameters needed here are the length of the buffer
1122that will hold the returned temporary path, and a pointer to the
1123buffer itself.
1124For numerical parameters except for char, you can use either a constant expression
1125or a variable, it will be numified similar to the expression C<($var+0)>.
1126For pointers, also note that B<memory must be allocated before calling the function>,
1127just like in C.
1128For example, to pass a buffer of 80 characters to GetTempPath(),
1129it must be initialized before with:
1130
1131 $lpBuffer = " " x 80;
1132
1133This allocates a string of 80 characters. If you don't do so, you'll
1134probably get a fatal buffer overflow error starting in 0.69.
1135The call should therefore include:
1136
1137 $lpBuffer = " " x 80;
1138 $GetTempPath->Call(80, $lpBuffer);
1139
1140And the result will be stored in the $lpBuffer variable.
1141Note that you never need to pass a reference to the variable
1142(eg. you B<don't need> C<\$lpBuffer>), even if its value will be set
1143by the function.
1144
1145A little problem here is that Perl does not trim the variable,
1146so $lpBuffer will still contain 80 characters in return; the exceeding
1147characters will be spaces, because we said C<" " x 80>.
1148
1149In this case we're lucky enough, because the value returned by
1150the GetTempPath() function is the length of the string, so to get
1151the actual temporary path we can write:
1152
1153 $lpBuffer = " " x 80;
1154 $return = $GetTempPath->Call(80, $lpBuffer);
1155 $TempPath = substr($lpBuffer, 0, $return);
1156
1157If you don't know the length of the string, you can usually
1158cut it at the C<\0> (ASCII zero) character, which is the string
1159delimiter in C:
1160
1161 $TempPath = ((split(/\0/, $lpBuffer))[0];
1162 # or
1163 $lpBuffer =~ s/\0.*$//;
1164
1165=head2 USING STRUCTURES
1166
1167Starting from version 0.40, Win32::API comes with a support package
1168named Win32::API::Struct. The package is loaded automatically with
1169Win32::API, so you don't need to use it explicitly.
1170
1171With this module you can conveniently define structures and use
1172them as parameters to Win32::API functions. A short example follows:
1173
1174
1175 # the 'POINT' structure is defined in C as:
1176 # typedef struct {
1177 # LONG x;
1178 # LONG y;
1179 # } POINT;
1180
1181
1182 #### define the structure
1183 Win32::API::Struct->typedef( POINT => qw{
1184 LONG x;
1185 LONG y;
1186 });
1187
1188 #### import an API that uses this structure
1189 Win32::API->Import('user32', 'BOOL GetCursorPos(LPPOINT lpPoint)');
1190
1191 #### create a 'POINT' object
1192 my $pt = Win32::API::Struct->new('POINT');
1193
1194 #### call the function passing our structure object
1195 GetCursorPos($pt);
1196
1197 #### and now, access its members
1198 print "The cursor is at: $pt->{x}, $pt->{y}\n";
1199
1200Note that this works only when the function wants a
1201B<pointer to a structure>, not a "pass by copy" structure. As you can see, our
1202structure is named 'POINT', but the API used 'LPPOINT'. Some heuristics are
1203done to validate the argument's type vs the parameter's type if the function
1204has a C prototype definition (not letter definition). First, if the parameter
1205type starts with the LP prefix, the LP prefix is stripped, then compared to
1206the argument's type. If that fails, the Win32::API::Type database
1207(see L<Win32::API::Type/typedef>)
1208will be used to convert the parameter type to the base type. If that fails,
1209the parameter type will be stripped of a trailing whitespace then a '*', and
1210then checked against the base type. L<Dies|perlfunc/die> if the parameter and
1211argument types do not match after 3 attempts.
1212
1213For more information, see also L<Win32::API::Struct>.
1214
1215If you don't want (or can't) use the C<Win32::API::Struct> facility,
1216you can still use the low-level approach to use structures:
1217
1218=over 4
1219
1220=item 1.
1221
1222you have to L<pack()|perlfunc/pack> the required elements in a variable:
1223
1224 $lpPoint = pack('ll', 0, 0); # store two LONGs
1225
1226=item 2.
1227
1228to access the values stored in a structure, L<unpack()|perlfunc/unpack> it as required:
1229
1230 ($x, $y) = unpack(';;', $lpPoint); # get the actual values
1231
1232=back
1233
1234The rest is left as an exercise to the reader...
1235
1236=head2 EXPORTED FUNCTIONS
1237
1238=head3 ReadMemory
1239
1240 $copy_of_memblock = ReadMemory($SourcePtr, $length);
1241
1242Reads the source pointer for C<$length> number of bytes. Returns a copy of
1243the memory block in a scalar. No readability checking is done on C<$SourcePtr>.
1244C<$SourcePtr>'s format is 123456, not C<"\x01\x02\x03\x04">.
1245
1246=head3 WriteMemory
1247
1248 WriteMemory($DestPtr, $sourceScalar, $length);
1249
1250Copies the string contents of the C<$sourceScalar> scalar to C<$DestPtr> for
1251C<$length> bytes. $length must be less than or equal to the length of
1252C<$sourceScalar>, otherwise the function croaks. No readability checking is
1253done on C<$DestPtr>. C<$DestPtr>'s format is 123456, not
1254C<"\x01\x02\x03\x04">. Returns nothing.
1255
1256=head3 MoveMemory
1257
1258 MoveMemory($destPtr, $sourcePtr, $length);
1259
1260Copies a block of memory from one location to another. The source and
1261destination blocks may overlap. All pointers are in the format of 123456,
1262not C<"\x01\x02\x03\x04">. No readability checking is done. Returns nothing.
1263
1264=head3 IsBadReadPtr
1265
1266 if(IsBadReadPtr($ptr, $length)) {die "bad ptr";}
1267
1268Probes a memory block for C<$length> bytes for readability. Returns true if
1269access violation occurs, otherwise false is returned. This function is useful
1270to avoid dereferencing pointers which will crash the perl process. This function
1271has many limitations, including not detecting uninitialized memory, not
1272detecting freed memory, and not detecting gibberish. It can not tell whether a
1273function pointer is valid x86 machine code. Ideally, you should never use it,
1274or remove it once your code is stable. C<$ptr> is in the format of 123456,
1275not C<"\x01\x02\x03\x04">. See MS's documentation for a lot more
1276on this function of the same name.
1277
1278=head3 SafeReadWideCString
1279
1280 $source = Encode::encode("UTF-16LE","Just another perl h\x{00E2}cker\x00");
1281 $string = SafeReadWideCString(unpack('J',pack('p', $source)));
1282 die "impossible" if $source ne "Just another perl h\x{00E2}cker";
1283
1284Safely (SEH aware) reads a utf-16 wide null terminated string (the first and
1285only parameter), into a scalar. Returns undef, if an access violation happens
1286or null pointer (same thing). The string pointer is in the format of 123456,
1287not C<"\x01\x02\x03\x04">. The returned scalar will be UTF8 marked if the string
1288can not be represented in the system's ANSI codepage. Conversion is done with
1289WideCharToMultiByte. Returns a 0 length scalar string if WideCharToMultiByte fails.
1290This function was created because L<pack's|perlfunc/pack> p letter won't read UTF16
1291and L</ReadMemory> and L</IsBadReadPtr> require an explicit length.
1292
1293=head2 CONSTRUCTORS
1294
1295=head3 new
1296
1297 $obj = Win32::API::More->new([$dllname | (undef , $funcptr)], [$c_proto | ($in, $out [, $calling_convention])]);
1298
1299See L</DESCRIPTION>.
1300
1301=head3 Import
1302 $obj = Win32::API::More->Import([$dllname | (undef , $funcptr)], [$c_proto | ($in, $out [, $calling_convention])]);
1303
1304See L</DESCRIPTION>.
1305
1306=head2 METHODS
1307
1308=head3 Call
1309
1310The main method of a Win32::API object. Documented elsewhere in this document.
1311
1312=head3 UseMI64
1313
1314 $bool = $APIObj->UseMI64();
1315 $oldbool = $APIObj->UseMI64($newbool);
1316
1317Turns on Quads as L<Math::Int64> objects support for a particular object
1318instance. You must call L<perlfunc/use>/L<perlfunc/require> on Math::Int64
1319before calling UseMI64. Win32::API does not C<use> Math::Int64 for you.
1320Works on Win32::API and Win32::API::Callback objects. This method
1321does not exist if your Perl natively supports Quads (64 bit Perl for example).
1322Takes 1 optional parameter, which is a true or false value to use or don't use
1323Math::Int64, returns the old setting, which is a true or false value. If called
1324without any parameters, returns current setting, which is a true or false value,
1325without setting the option. As discussed in L</q>, if you are not using
1326Math::Int64 you must supply/will receive 8 byte scalar strings for quads.
1327For "in" params in Win32::API and Win32::API::More and "out" in
1328Win32::API::Callback only, if the argument is a reference, it will automatically
1329be treated as a Math::Int64 object without having to previously call this
1330function.
1331
1332=head2 VERBOSE DEBUGGING
1333
1334If using C<Win32::GetLastError> and C<$^E> does not reveal the problem with your
1335use of Win32::API, you may turn on Win32::API's very verbose debugging mode as
1336follows
1337
1338 BEGIN {
1339 $Win32::API::DEBUG = 1;
1340 }
1341 use Win32::API;
1342 $function = Win32::API::More->new(
1343 'mydll', 'int sum_integers(int a, int b)'
1344 );
1345
1346=head1 HISTORY
1347
1348=over 4
1349
1350=item UseMI64 API change
1351
1352Starting in 0.71, UseMI64 on a set returns old value, not previously
1353new value.
1354
1355=item fork safe
1356
1357Starting in 0.71, a Win32::API object can go through a fork and work
1358correctly in the child and parent psuedo-processes. Previously when either
1359psuedo-processes exited, the DLL would be unloaded and the other
1360psuedo-processes would crash if a Call() was done on the object.
1361
1362=item return value signedness
1363
1364Prior to 0.69, for numeric integer types, the return scalar was always signed.
1365Unsigned-ness was ignored.
1366
1367=item shorts
1368
1369Prior to 0.69, shorts were not supported. 'S' meant a sturct. To fix this
1370Win32::API::More class was created for 0.69. 'S'/'s' now means short, per pack's
1371letters. Struct has been moved to letter 'T'. Win32::API will continue to exist
1372for legacy code.
1373
1374=item float return types
1375
1376Prior to 0.69, if a function had a return type of float, it was silently
1377not called.
1378
1379=item buffer overflow protection
1380
1381Introduced in 0.69. If disabling is required, which is highly
1382B<not recommended>, set an environmental variable called
1383WIN32_API_SORRY_I_WAS_AN_IDIOT to 1.
1384
1385=item automatic un/pack
1386
1387Starting with 0.69, when using Win32::API::More, there is automatic un/packing
1388of pointers to numbers-ish things for in parameters when using the C
1389prototype interface.
1390
1391=item Quads on 32 bit
1392
1393Added in 0.70.
1394
1395=item __stdcall vs __cdecl checking on 32 bits
1396
1397Added in 0.76_01
1398
1399=item Import returns an api obj on success, undef on failure, instead of 1 or 0
1400
1401Added in 0.76_02
1402
1403=item checking C<$!> for C<new>/C<Import> failure is broken and deprecated
1404
1405Starting in 0.76_06, due to many bugs with C<new> and C<Import> not setting
1406L<perlvar/$!> or Win32 and C error codes overlapping and Win32 error codes being
1407stringified as different C error codes, checking C<$!> is deprecated and the
1408existing, partial setting of C<$!>, maybe removed in the future. Only check
1409C<Win32::GetLastError()> or C<$^E> to find out why the call failed.
1410
1411=back
1412
1413See the C<Changes> file for more details, many of which not mentioned here.
1414
1415=head1 BUGS AND LIMITATIONS
1416
1417=over 4
1418
1419=item E<nbsp> Unicode DLL paths
1420
1421Untested.
1422
1423=item E<nbsp> ithreads
1424
1425Minimally tested.
1426
1427=item E<nbsp> C functions getting utf8 scalars vs byte scalars
1428
1429Untested and undefined.
1430
1431=back
1432
1433=head1 SEE ALSO
1434
1435L<Math::Int64>
1436
1437L<Win32::API::Struct>
1438
1439L<Win32::API::Type>
1440
1441L<Win32::API::Callback>
1442
1443L<Win32::API::Callback::IATPatch>
1444
1445L<http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/function-calling-conventions.html>
1446
1447=head1 AUTHOR
1448
1449Aldo Calpini ( I<dada@perl.it> ).
1450
1451=head1 MAINTAINER
1452
1453Cosimo Streppone ( I<cosimo@cpan.org> )
1454
1455=head1 MAJOR CONTRIBUTOR
1456
1457Daniel Dragan ( I<bulkdd@cpan.org> )
1458
1459=head1 LICENSE
1460
1461To finally clarify this, C<Win32::API> is OSI-approved free software;
1462you can redistribute it and/or modify it under the same terms as Perl
1463itself.
1464
1465See L<http://dev.perl.org/licenses/artistic.html>
1466
1467=head1 CREDITS
1468
1469All the credits go to Andrea Frosini for the neat assembler trick
1470that makes this thing work. I've also used some work by Dave Roth
1471for the prototyping stuff. A big thank you also to Gurusamy Sarathy
1472for his invaluable help in XS development, and to all the Perl
1473community for being what it is.
1474
1475Cosimo also wants to personally thank everyone that contributed
1476to Win32::API with complaints, emails, patches, RT bug reports
1477and so on.
1478
1479=cut
1480
1481������™Àe™áÊáÊÃ¡ÊØÂVÊß¡ÊØÂÊÜ¡Ê^©VÊß¡ÊS¶VÊÞ¡Êá
1482Ê™¡ÊS¶hÊÜ¡ÊS¶ÊÜ¡ÊS¶WÊÜ¡ÊS¶QÊÜ¡ÊRicháÊ����������������PE��L�VïV��������à �!
1483����������!à ���à �����������������������������@��Ò����������������������������€�J��� �P����������������������������0�D�� �������������������������������������������������������������������������.text������à ������Ò�������������� ��`.rdata��%����������������������@��@.data������� �������������������@��À.reloc����0������������������@��B��������������������������������…Ét‹AƒøvH‰AÃPQÿt$ÿÌ�ƒÄËD$Huÿt$ÿ�…Àt3À@Â�‹ƒ@D‹PDW‹ù+xÆ’ÃÃÿ‰:‹T$‰‹T$ă‹T$㉋L$j‰LQPÿX�ƒÄ_ËGö@Vt‹@‹O‹4Âë
1484WÿÄ�Y‹ð÷F�Ât
1485jVWÿ¬�ƒÄÂfÿ�ÿ_öFtVÿ¼�Y‹Æ^ÃUܓēV3öƒøÿ‰uø‰Eü‰uðuÿuÿ@�@Y‰Eü‹EW‹}üÿf9tþth(hüÿx�9CuWÿà �Wÿu‰EðPèÈ��ƒÄ‰E‹=,�VVVVÿuüPh���Vÿ×PSÿu‰Eôÿ �ƒÄÂMøQVÿuôPÿuüÿuh���Vë<€K VVVVÿuü‰uøÿuVhéý��ÿ×PSÿu‰Eôÿ �ƒÄVVÿuôPÿuüÿuVhéý��ÿ×9uøu½;Æ_t€K D‹H‰AëÂcÿ�ÿ_öCtSÿ¼�Y9uð^t
1486ÿuðÿp�YÉÃjhäÿt$ÿP�‹L$ƒÄ‰Ãö@
1487€th<j~Pÿ´�ƒÄ…Àt‹@Ã3ÀÃöC
1488€V¾<t Vj~Sÿ´�ƒÄ…ÀtÿG‹H‰x^é¦ýÿÿj�j�Vj~WSÿt$ ÿ�ƒÄ^ËPÿt$·I‹Rÿt$‹ŠQÿp‹D$è¨ýÿÿƒÄÂ�ƒL$���Uܓē$SVW‰eä‹u‹FD‹8ƒÀü‰FDƒÀÃç;FHuVÿ\�Y‹‹N+ȃáüƒù}jPPVÿ¨�ƒÄ‹V‹]+Â+ǃNj˃á‰}ìu‹ƒe�‹Ië(…ÀuhØ3ËQÿÈ�‹:jY+Ãù‰M‹J‹I‰}ì‰M‹I;ÃtÃèPÃéQh¤é}��‹E‹PÃâ„z��ƒeð�ÂD‰Uè‰Eø‹Ä$ð‹à ‹Mø+Eèÿqÿqÿqÿ1;à ÂIðuî‰Eô‹]ôÃê׉}ø‰Uè‰]ü¶Cƒø‹V‹}ø‹<:¹���‡��ÿ$…Üê�‹Eö�u…Ot1‹ƒFD‹ND‹Ø+ÚjƒÀÃû‰h„‰8V‰ÿX�‹‹8‹]üƒÄ‹G%� �=���u‹Gëjj�WVÿÂ�ƒÄ‹ƒy…{��‹‰‹@‰CéU��‹G%� �=���u‹Gëjj�WVÿÂ�ƒÄ¾�é(��‹G%� �=���u‹Š@ë
1489jWVÿ¸�ƒÄ¾Àéý��‹G%� �=���u‹Ã@ë
1490jWVÿœ�ƒÄÙéÕ��‹G%� �=���u‹Ã@ë
1491jWVÿœ�ƒÄÃ��f÷G
1492tjWVÿô�‹Mø‹ø‹FƒÄ‰<‹E‹öà ‹Gt.öÄÿu<t%ÿÀ�=
1493��…e��öÃt>‹EjWV‹Ëè.ýÿÿë.¹���…Ãt%%� �;Ãu‹‹@ë
1494jWVÿ¸�ƒÄ…À„"��ƒ}ð�u‹â€
1495��‹
1496� ‹ˆ‹�‰EðjÿuðWVÿ‹GƒÄƒMéê��ƒM…O„ý��‹€…ð��j�j�WVÿt�‹ø‹‹HƒÄöÅt*Âá� �Âù���u‹�‹@ë
1497jPVÿ¸�ƒÄ…À„Â��‹é��‹G%� �=���u
1498‹‹@ék��jWéY��ƒM…O„}��‹G€x…p��jPPÿì�…ÀYYt‹x‹F‹Mø‰<WVÿ¤�…ÀYY„C��‹Eö� t[j�j�j jhìÿwVÿÜ�‹Ø‹Eü·@Āj0PVÿÔ�PVÿ‹M‹I‹IĀP‹Eü·@ÿ4‹Æÿ3ègùÿÿ‹]üƒÄ‹ƒFD‹ND‹Ã+VjÃúƒÀ‰hä‰8V‰ÿð�j�j�j jhÜÿwVÿÜ�ƒÄ(…Àtu‹�‹HÂá� �Âù���u‹@ë[jj�PVÿÂ�ƒÄëJ…Otsj�j�j jh´ÿwVÿÜ�ƒÄ…ÀtU‹�‹HÂá� �Âù���u‹�éšþÿÿjPVÿ¸�ƒÄ‰ƒEø‹EøƒÃ;Eè‰]üs8éöûÿÿh8ëhøëh¼ëhâ€Â·CPhÿx�Péu��‹]ô‹UôÂEÜPÿu‹Ëè“��‹E¨„3��‹Eì‹]ô‰Eø‰]ü‹N‹<¶CďtiHt4H…ó���‹jWVÿÃ�‹¶�PVÿÔ�PjWVÿ°�ƒÄ$éÆ���‹ƒFD‹VD‹Ø+ÙjƒÀÃû‰hü‰8V‰ÿð�‹]üƒÄéâ€ï¿½ï¿½ï¿½Æ’;�„‹���‹‹Eð‹@‹W‹IjÂL
1499ôPQè\��ƒÄ…ÀtJjh\Vÿh�3ÉQQj Qjh<QPVÿL�ƒÄ0…Àtÿ0Vÿ`�…ÀYYu·CPhéb��‹ƒ@ô‹E�$0<0u‹Ej�WV‹Ëè^ùÿÿ‹EøƒÀƒÃ;Eè‰Eø‰]ü‚Üþÿÿ‹E‹}ìƒà +ø~‹E‰>€x�„Ã���‹Fö@t‹@‹N‹Âë
1500VÿÄ�Y‹Ø‹E‰¶H¸Â���;ȇ¹���„0��ƒùw6t.‹ÃHt$Ht!HtH…µ���jÂEÜPSVÿë9¿EÜPëYÿuÜëT¾EÃœÃ«Ã²â€¹ÃÆ’èt(ďtHtHëÃEÜëÙEÜQQÃ$SVÿd�ƒÄéÔ���ƒ}�tjÿÿuÜÿ �…Àt$‹Eö�uj�SVÿä�é¥���ÂƤ���‰7é«���ÿuÜSVÿH�éˆ���‹Ã-‚���ttHtjH„SÿÿÿHtZďtQh`ÿx�jÂEÜPSVÿ‹MƒÄötK+~Æ’FD‹FDĕÃÿ‰8‹Ãè÷؃à jPPVÿX�ƒÄë+¶EÜë·EÜPëÿuÜSVÿl�ƒÄöC
1501@t
1502SVÿˆ�YY‹eä_^[ÉÃÂI�æ�æ�×ç�Aä�lä�ëä�1æ�ªå�Jç�—ä�Ãä�Åã�‹D$‹HD‹SÆ’ÃüV‹pW‹8‰HD–‹Ã+ËÃù‹Ù÷ÛBƒùÂ<Ÿ|zƒùu‹ÚÃã‹4öF tR‹v‹VÂâ�Â�Âú�Â�u>‹vöÂÂ���u´���ƒÇƒù‰‰8u‹HÿtPÿ`�Ãà 3YÆ’Ã 1Y_^[Ãhà hÃŒh ÿx�hèÿt$ÿÈ�ÌU‹ìSV‹u‹FD‹‹ƒÀü‰FD‹FÂËœ+ȃáüCƒùWth˜ÿuÿÈ�‹Fö@t‹@‹N‹<Âë
1503VÿÄ�Y‹ø‹FÃã‹‹HÂá� �Âù���u‹@ëjj�PVÿÂ�ƒÄPÿ�‹NPÂLüWV‰Mÿä�ƒÄöG
1504@t
1505WVÿˆ�YY‹E‰x‹FÃ_‰^[]ÃU‹ìSV‹u‹FD‹W‹8ƒÀü‰FD‹F¸+ȃáüGƒùthˆÿuÿÈ�‹Fö@t‹@‹N‹Âë
1506VÿÄ�Y‹Ø‹FÃç‹‹HÂá� �Âù���u‹�‹@ë
1507jPVÿ¸�ƒÄ‰E‹F‹D8‹HÂá� �Âù���u‹@ëjj�PVÿÂ�ƒÄPÿuÿ��‹NPÂL9üSV‰Mÿä�ƒÄöC
1508@t
1509SVÿˆ�YY‹E‰X‹FÇ_‰^[]ÃV‹t$‹ND‹ƒÃüW‹>‰ND‹NÂÂ+úƒçü@ƒÿth€ÿt$ÿÈ�‹øÃç‹9‹A%� �=���u‹‹@ë
1510jQVÿ¸�ƒÄPÿ�„À†Ä���u†´���‹N‰‹FÇ_‰^ÃV‹t$‹ND‹ƒÃüW‹>‰ND‹NÂÂ+úƒçü@ƒÿthxÿt$ÿÈ�‹øÃç‹9‹AU%� �3Ã=���u‹AëjUQVÿÂ�ƒÄSUUjÿPUU‰D$,ÿ$�‹Ø;ÃtNÂPÿà �YS‹èUjÿÿt$ 3ÛSSÿ$�…Àt#SUVÿPVÿ‹NU‰ÿp�ƒÄëUÿp�Y‹N†´���‰‹F[]Ç_‰^ÃQUV‹t$‹ND‹ƒÃüW‹>‰ND‹NÂÂ+úƒçü@ƒÿthpÿt$ÿÈ�‹øÃç‹9‹AS%� �3Û=���u‹AëjSQVÿÂ�ƒÄSSSSjÿPSS‰D$8ÿ,�;ÉD$tNPÿà �YSSÿt$‹èUjÿÿt$,SSÿ,�…Àt#SUVÿPVÿ‹NU‰ÿp�ƒÄëUÿp�Y‹N†´���‰‹F[Ç_‰^]YÃV‹t$‹ND‹÷ØÃà +FW‹>ǃÃüƒà üƒø‰NDthhÿt$ÿÈ�‹‹HÂá� �Âù���u‹@ëjj�PVÿÂ�ƒÄPVÿÔ�PVÿƒÄ‰_^ÃV‹t$‹ND‹ƒÃüW‹>‰ND‹NÂÂ+úƒçü@ƒÿth`ÿt$ÿÈ�‹øÃç‹9‹A%� �=���u‹‹@ë
1511jQVÿ¸�ƒÄj�PVÿPVÿ‹N‰‹FƒÄÇ_‰^ÃU‹ìSV‹u‹FD‹‹VƒÀü‰FDW‹>Š‹Ç+Ë]‹‹[ÃøAƒø‰]thTÿuÿÈ�‹ÙÃã‹‹B%� �ƒï=���u‹‹@ë
1512jRVÿ¸�ƒÄ‰E‹F‹\‹C%� €=��€u‹‹@ë
1513jSVÿƒÄƒ}�Pÿutÿ �…Àu†´���ƒÇ‰‰>_^[]Ãÿ�ëâ†Ä���ëäVW‹|$‹OD‹‹7֯Ãà +GÆ’Ãüƃà üƒø‰ODthTÿt$ÿÈ�‹‹HS‹¸�UÂá� �½���ƒî;Ãu‹�‹@ë jPWÿӃĉD$‹‹HÂá� �;Ãu‹�‹XëjPWÿӃċØèsîÿÿÿt$‰SPW‰7ÿè�ƒÄ][_^ÃU‹ìQSV‹u‹FD‹W‹8ƒÀü‰FD‹F¸‹Ê+ËÃùGƒùth8ÿuÿÈ�ƒÂô‰Â¸‹X‹�‹HÂá� �Âù���u‹�‹@ë
1514jPVÿ¸�ƒÄ‰Eü‹F‹|¸‹G%� €=��€u‹‹xëjWVÿƒÄ‹ø‹C%� �=���u
1515‹‹@‰E‹CëjÂEPSVÿÂ�ƒÄ;}vh h�ÿx�WPÿuüèé��ƒÄ_^[ÉÃU‹ìSV‹u‹FD‹W‹8ƒÀü‰FD‹F¸‹Ê+ËÃùGƒùthäÿuÿÈ�ƒÂô‰‹¸‹HÂá� �»���;Ëu‹�‹@ë
1516jPVÿ¸�ƒÄ‰E‹F‹D¸‹HÂá� �;Ëu‹�‹XëjPVÿ¸�ƒÄ‹Ø‹F‹|¸‹G%� €=��€u‹‹@ë
1517jWVÿƒÄPSÿuÿ4�ƒÄ_^[]ÃUܓēSVW‹}‹GD‹‹‹WƒÀü‰GD‹ÃÃà ‹ð‹Ã+Æ+ÂÃøƒøthÜÿuÿÈ�‹LŠ‹A%� �ƒë=���u‹‹@ë
1518jQWÿ¸�ƒÄ‰Eüè-ìÿÿƒÃ‹ð‰3‰‹}ü3Û;û„Ê���jÿWÿ�…À…¹���Wÿ@�=ÿÿÿY‰Eð‰]øvh¼hâ€Ã¿x�SSSSPW‹=,�h���Sÿ׉Eô@PVÿuÿ �ƒÄÂMøQSÿuôPÿuðÿuüh���Së=€N SSSSÿuð‰]øÿuüShéý��ÿ׉Eô@PVÿuÿ �ƒÄSSÿuôPÿuðÿuüShéý��ÿ×9]øu¼;Ãt‹‰A‹Nˆ€N DöF
1519@tVÿuÿˆ�YY_^[ÉÃUܓēSVW‹}‹GD‹‹7ƒÀü‰Mü‰GD‹ÃÃà ‹Î+È+OƒáüƒùthŒÿuÿÈ�èóêÿÿ‰Eø»��¸��‰]ôèG��‹Mü‹G‹Dˆ‹HÂá� �Âù���‰eu‹�‹@ë
1520jPWÿ¸�ƒÄSÿu‰Eü‹Eøÿuü‰‰7‹5(�ÿÖ…Àt<‹]ô;Ãu&ÂÃƒï¿½ï¿½ï¿½ÂÆ’Àƒà üèÃ��‰eSÿuÿuüÿÖ…ÀuØëÿu‹]ø@Wè£êÿÿYYÂeè_^[ÉÃV‹t$Æ’FDüWjVÿâ€ï¿½â€¹x‹
1521� ‹â€
1522��ˆ‹jQW‰8èÂ��WVè}ëÿÿƒÄ_^ËL$‹V‹qD‹÷ÚÃâ+QÆ’Ã†Ã¼ÃÆ’âüƒú‰qDth|ÿt$ë7‹0ƒè‹ƒÀü‰¸���…Bt…FtS‹ZW‹~Qè\ëÿÿY_[^Ãh|ÿt$ÿÈ�ÌV‹t$‹ND‹÷ØÃà +FW‹>ǃÃüƒà üƒø‰NDu‹ö@ t‹@èðêÿÿ…Àuhpÿt$ÿÈ�PVÿ˜�PVÿƒÄ‰_^ÃSV‹t$‹ƒFDü‹‹IWhhƒè‹8h¤â�QƒÀüV‰ÿØ�‹O‹‹IV‹Ø‰Jè¦êÿÿƒÄ_^[ÃU‹ìSV‹u‹ND‹‹ƒÃüW‹~‰ND‡‹Ê+ËÃù@ƒùthXÿuÿÈ�‡‹‹@‹HĐÂá� €Âù��€‰Uu‹�‹xëjPVÿ‹UƒÄ‹ø‰‹C3Ò÷÷…ÒtH‹‹@ÂD8ÿPSVÿ �3Ò‰E÷÷ƒÄ…Òt(‹‹H+úÂ9‰P‹EøAQPWÿ4�WSVÿ€�ƒÄ_^[]ÃUܓēSVW‹}hPhHhhWhç¨
1523ÿü�‹5T�hë�hÃŒW‰EüÿÖhÄë�h0WÿÖh„ì�hWÿÖhvÃ�hüW؅ĀDhûÃ�häWÿÖhÙî�hÃŒWÿÖh½ï�h´WÿÖh0ð�hÅ“WÿÖ»³ð�Sh€WÿÖ‹�ƒ`�ShdWÿÖ‹�ƒÄHh†ñ�3ÛhLCW‰XÿÖh,ò�h WÿÖhó�h4WÿÖhèó�h¼WÿÖhPõ�hWÿÖh;ö�høW؅ĀHhzö�hà WÿÖhçö�hÈWÿÖhG÷�h°WÿÖhÂ÷�hÅ“WÿÖhhhšâ�hˆWÿØ�ƒÄ@ÂEôPÿ�…Àuhdÿx�‹EôfÆ’eè�fÆ’eê�j‰Eì‹Eøh� W‰Eðÿ„�PWèôçÿÿjÂMèQPWÿShXWÿÀ�‹5ø�Ÿ´���ShLPW‰E؅Ā@ShDÿuWÿփĻ‹¶CPWÿŒ�PÂCPÿuWÿÖ¶Â\ĀÂûAr×ÿuüWÿ|�YY_^[ÉÃÌÌU‹ìVW‹uëƒéŠA<
1524rÿqÿ1;ÊwË}ÿV¶NĎ
1525tIt‰‰WëÃëÙ‹Ãè%üÿ�à _^;ìu]Â�ÿ�…Àu
1526TUh˜ÿx�÷ØÄ$ðâ€â€¹ï¿½PÃÿ%<�ÿ%8�ÌÌÌÌÌÌÌÌÌÌ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������â�V�d�~� ��ô�D�Ã�º�¤�Ž�����L�V�B�`�����Î�Þ�ð�þ��$�:�J�Z�h�x�Œ�œ�´�Ê�Ú�î�¾�
1527�
1528�.
1529�<
1530�P
1531�`
1532�t
1533�â€
1534�¤
1535�´
1536�Æ
1537�Ú
1538�ì
1539�þ
1540��(�¬�œ�Ž�t�^�N�:�*��ú
1541�æ
1542�Ò
1543�¾
1544�¨
1545�â€
1546�‚
1547�ü�p
1548�������������VïV�������Y���Ì�Ìý����������������������Math::Int64::native_to_int64�Math::Int64::native_to_uint64��T_VOID�T_NUMBER� T_POINTER� T_INTEGER�T_SHORT�T_QUAD�T_CHAR� T_NUMCHAR�
1549T_FLOAT�T_DOUBLE�T_STRUCTURE�T_POINTERPOINTER� T_CODE�€T_FLAG_UNSIGNED�@T_FLAG_NUMERIC����IsGCC���IsUnicode���Win32::API��Win32::API::boot: internal error
1550���Win32::API::Call����Win32::API::_Align��Win32::API::_ImportXS���Win32::API::GetMagicSV��Win32::API::SetMagicSV��Win32::API::_my_cxt_clone���Win32::API::GetModuleFileName���Win32::API::MoveMemory��Win32::API::ReadMemory��Win32::API::IsBadStringPtr��Win32::API::IsBadReadPtr����Win32::API::PointerAt���Win32::API::PointerTo���Win32::API::FromUnicode�Win32::API::ToUnicode���Win32::API::FreeLibrary�Win32::API::GetProcAddress��Win32::API::LoadLibrary�v5.23.2�0.82����sv, boundary����API.c���reference���outside, inside�module��%s wide string overflowed >2147483647���Win32::API::SafeReadWideCString�wstr����Destination, Source, Length�%s, $length > length($source)���Win32::API::WriteMemory�destPtr, sourceSV, length���addr, len���addr����Target��uString�string��library�library, name���name����%s: %s is not of type Win32::API [::More]���Win32::API::UseMI64�self����self [, FlagBool]���Unpack��Win32::API::Call: parameter %d had a buffer overflow����WIN32_API_SORRY_I_WAS_AN_IDIOT��ENV�Win32::API::Call: (internal error) unknown type %u
1551� Win32::API::Callback object!
1552��code���� Win32::API::Struct object!
1553����buffer��Pack����__typedef__�n array reference!
1554�Win32::API::Call: parameter %d must be a%s�� packed 8 bytes long string, it is a 64 bit integer (Math::Int64 broken?)���Math::Int64::int64_to_native����Wrong number of parameters: expected %d, got %d.
1555���api, ...����Win32::API::sentinal����(XS) Win32::API::w32sv_setwstr panic: %s����wide string is not null terminated
1556�Win32::API::Type::Unpack�Win32::API::Type::Pack�Win32::API::Struct::ck_type�Win32::API a function was called with the wrong prototype and caused a C stack inconsistency EBP=%p ESP=%p��œ ���������8�H��T ���������4����ˆ ���������j�4����������������������â�V�d�~� ��ô�D�Ã�º�¤�Ž�����L�V�B�`�����Î�Þ�ð�þ��$�:�J�Z�h�x�Œ�œ�´�Ê�Ú�î�¾�
1557�
1558�.
1559�<
1560�P
1561�`
1562�t
1563�â€
1564�¤
1565�´
1566�Æ
1567�Ú
1568�ì
1569�þ
1570��(�¬�œ�Ž�t�^�N�:�*��ú
1571�æ
1572�Ò
1573�¾
1574�¨
1575�â€
1576�‚
1577�ü�p
1578�����ýPerl_sv_setpvn��‹Perl_sv_2mortal�•Perl_sv_2uv_flags�¤Perl_sv_catsv_flags�ÃPerl_sv_magicext��mPerl_xs_handshake�„Perl_newCONSTSUB��ÓPerl_sv_mortalcopy_flags��Perl_call_method��OPerl_mg_find��þPerl_sv_setpvn_mg�ñPerl_sv_setiv�:Perl_safesysmalloc��ÃPerl_hv_common_key_len��½Perl_newXS��ÂPerl_newSViv��Perl_av_extend��¸Perl_newSVuv��õPerl_sv_setpv�ÌPerl_hv_common��ŽPerl_get_sv�¾Perl_newXS_deffile��Perl_call_pv��GPerl_markstack_grow�Perl_sv_true��óPerl_sv_setnv�‰Perl_get_hv�Perl_sv_setuv�9Perl_safesysfree��Perl_av_fetch�0Perl_croak_nocontext��lPerl_xs_boot_epilog�¦Perl_sv_chop��fPerl_my_cxt_init��WPerl_mg_set�¯Perl_newSVpv��ŽPerl_sv_2pv_flags�¨Perl_newSV��£Perl_newRV��ŒPerl_sv_2nv_flags�ÅPerl_sv_grow��ËPerl_sv_isobject��ƒPerl_stack_grow�ÀPerl_sv_force_normal_flags��
1579Perl_av_store�QPerl_mg_findext�ŠPerl_sv_2iv_flags�–Perl_sv_backoff�ÄPerl_gv_stashpv�ÔPerl_sv_newmortal�3Perl_croak_xs_usage�ÂPerl_sv_free2�perl523.dll�+IsBadStringPtrW�ï�FreeLibrary�—QueryPerformanceCounter�)IsBadReadPtr��‡WideCharToMultiByte�vGetModuleFileNameW��kMultiByteToWideChar�*IsBadStringPtrA�˜GetProcAddress��„�DisableThreadLibraryCalls�HLoadLibraryA��/IsDebuggerPresent�KERNEL32.dll��åmemcpy��æmemmove�ämemcmp��4wcslen��MSVCR71.dll���������������VïV����²����������¨�¬�°�Xø��º���API.dll�boot_Win32__API���RSDS{Œ¸1YB„«ÂÂÛ˜0���C:\Documents and Settings\Owner\Desktop\cpan libs\w32a\g\API.pdb��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ÿÿÿÿ�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������à ��0��0.0u0}0ž0´0Ë0ð0
1580111!1:1X1â„¢1Ú1ê1ô1þ12242@2i2ÃŒ2ç233K3Ã3ê3õ34]4ˆ4³4Ã4ù4e5‚5—5ÃŒ5ú5P6j6‰6“6©6±6ô6ÿ677A7X7b7Â7®7µ7¼7Ã7Ã7Ó7*878B8f8q8®8µ8Ã8ÃŒ8Ü8ì8`9¦9á9ú9:-:S:Y:g:•:Â:º:Ë:Ü:à :ä:è:ì:ð:ô:ø:ü:�;;;‹; ;Â¥;ª;°;µ;¿;ì;õ;<><H<[<l<¬<µ<Ã<þ<-=:=M=^=›=Â¥=Ã=×= >*>T>i>y>Ž>›>£>°>¼>�?
1581?4?J?Y?q?~?†?“?Ÿ?ã?Ã?�����00$0U0_0‡0â€0Å“0è0ñ01I1\1x1¬1¶1Â1 2W2`2Â2¼2ë2ø2ý23C3L3w3¢3ÃŽ3Ü34#4J4t4Æ’4–4›4¡4Â4Ä45E5Â5Å 5Ó5Ã5J6S6Ÿ6Ø6â6!7+737;7Z7d7q7¹7Â7ò78C8L8e8j8o8{8Â8†8‹8–8›8£8¨8°8µ8À8Ã…8Ã8Ã’8Ú8ß8ç8ì8ô8ú8 999)9.969;9C9H9P9U9]9b9m9r9z99‡9Å’9â€9â„¢9¡9¦9«9²9¿9È9ÃŽ9è9ò9:
1582:::&:6:D:P:k:w:Ø:ã:é:ü:;������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������