Skip to content

Commit ea14dab

Browse files
author
Cosimo Streppone
committed
Merge branch 'patch-1' of github.com:dsteinbrunner/perl5-win32-api
Conflicts: API.pm Resolved conflicts from other edits done by bulkdd on API.pm documentation.
2 parents feb2e23 + ac47459 commit ea14dab

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed

API.pm

+19-19
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ sub parse_prototype {
607607

608608
#
609609
# XXX hack, see the proper implementation in TODO
610-
# The point here is dont let fork children free the parent's DLLs.
611-
# CLONE runs on ::API and ::More, thats bad and causes a DLL leak, make sure
610+
# The point here is don't let fork children free the parent's DLLs.
611+
# CLONE runs on ::API and ::More, that's bad and causes a DLL leak, make sure
612612
# CLONE dups the DLL handles only once per CLONE
613613
# GetModuleHandleEx was not used since that is a WinXP and newer function, not Win2K.
614614
# GetModuleFileName was used to get full DLL pathname incase SxS/multiple DLLs
@@ -794,7 +794,7 @@ readable, GetLastError will be ERROR_NOACCESS.
794794
795795
The C prototype of the function. If you are using a function pointer, the name
796796
of the function should be something "friendly" to you and no attempt is made
797-
to retrive such a name from any DLL's export table. This name for a function
797+
to retrieve such a name from any DLL's export table. This name for a function
798798
pointer is also used for Import().
799799
800800
=back
@@ -830,7 +830,7 @@ readable, GetLastError will be ERROR_NOACCESS.
830830
=item 3.
831831
The name of the function (as exported by the library) or for function pointers
832832
a name that is "friendly" to you. This name for a function pointer is also used
833-
for Import(). No attempt is made to retrive such a name from any DLL's export
833+
for Import(). No attempt is made to retrieve such a name from any DLL's export
834834
table in the 2nd case.
835835
836836
=item 4.
@@ -1006,11 +1006,11 @@ integer C<0>.
10061006
10071007
It is suggested to
10081008
not use P as a return type and instead use N and read the memory yourself, and
1009-
free the pointer if applicable. This pointer is effectivly undefined after the
1009+
free the pointer if applicable. This pointer is effectively undefined after the
10101010
C function returns control to Perl. The C function may not hold onto it after
10111011
the C function returns control. There are exceptions where the pointer will
10121012
remain valid after the C function returns control, but tread at your own risk,
1013-
and at your knowledge of Perl interpretor's C internals.
1013+
and at your knowledge of Perl interpreter's C internals.
10141014
10151015
=item C<T>:
10161016
value is a Win32::API::Struct object, in parameter only, pass by reference
@@ -1021,25 +1021,25 @@ value is a Win32::API::Callback object, in parameter only, (see L<Win32::API::Ca
10211021
10221022
=item C<V>:
10231023
no value, no parameters, stands for C<void>, may not be combined with any other
1024-
letters, equivelent to a ""
1024+
letters, equivalent to a ""
10251025
10261026
=back
10271027
10281028
For beginners, just skip this paragraph.
10291029
Note, all parameter types are little endian. This is probably what you want
1030-
unless the documentation for the C function you are calling explictly says
1030+
unless the documentation for the C function you are calling explicitly says
10311031
the parameters must be big endian. If there is no documentation for your C
1032-
function or no mention of endianess in the doucmentation, this doesn't apply
1033-
to you and skip the rest of this paragraph. There is no inherant support
1032+
function or no mention of endianess in the documentation, this doesn't apply
1033+
to you and skip the rest of this paragraph. There is no inherent support
10341034
for big endian parameters. Perl's scalar numbers model is that numeric
1035-
scalars are effectivly opaque and their machine representation is
1036-
irrelavent. On Windows Perl, scalar numbers are little endian
1035+
scalars are effectively opaque and their machine representation is
1036+
irrelevant. On Windows Perl, scalar numbers are little endian
10371037
internally. So C<$number = 5; print "$number";> will put 5 on the screen.
10381038
C<$number> given to Win32::API will pass little endian integer 5 to the C
10391039
function call. This is almost surly what you want. If you really must pass
10401040
a big endian integer, do C<$number = unpack('L', pack('N', 5));>, then
10411041
C<print "$number";> will put 83886080 on the screen, but this is big endian 5,
1042-
and passing 83886080 to C<-E<gt>Call()> will make sure that that
1042+
and passing 83886080 to C<-E<gt>Call()> will make sure that
10431043
the C function is getting big endian 5. See L<perlpacktut> for more.
10441044
10451045
Our function needs two parameters: a number (C<DWORD>) and a pointer to a
@@ -1166,8 +1166,8 @@ them as parameters to Win32::API functions. A short example follows:
11661166
11671167
Note that this works only when the function wants a
11681168
B<pointer to a structure>, not a "pass by copy" structure. As you can see, our
1169-
structure is named 'POINT', but the API used 'LPPOINT'. Some herustics are
1170-
done to vaildate the argument's type vs the parameter's type if the function
1169+
structure is named 'POINT', but the API used 'LPPOINT'. Some heuristics are
1170+
done to validate the argument's type vs the parameter's type if the function
11711171
has a C prototype definition (not letter definition). First, if the parameter
11721172
type starts with the LP prefix, the LP prefix is stripped, then compared to
11731173
the argument's type. If that fails, the Win32::API::Type database
@@ -1236,10 +1236,10 @@ Probes a memory block for C<$length> bytes for readability. Returns true if
12361236
access violation occurs, otherwise false is returned. This function is useful
12371237
to avoid dereferencing pointers which will crash the perl process. This function
12381238
has many limitations, including not detecting uninitialized memory, not
1239-
detecting freed memory, and not detecting giberrish. It can not tell whether a
1239+
detecting freed memory, and not detecting gibberish. It can not tell whether a
12401240
function pointer is valid x86 machine code. Ideally, you should never use it,
12411241
or remove it once your code is stable. C<$ptr> is in the format of 123456,
1242-
not C<"\x01\x02\x03\x04">. See MS's documentation for alot more
1242+
not C<"\x01\x02\x03\x04">. See MS's documentation for a lot more
12431243
on this function of the same name.
12441244
12451245
=head3 SafeReadWideCString
@@ -1331,7 +1331,7 @@ not called.
13311331
=item buffer overflow protection
13321332
13331333
Introduced in 0.69. If disabling is required, which is highly
1334-
B<not recommended>, set an enviromental variable called
1334+
B<not recommended>, set an environmental variable called
13351335
WIN32_API_SORRY_I_WAS_AN_IDIOT to 1.
13361336
13371337
=item automatic un/pack
@@ -1413,7 +1413,7 @@ See L<http://dev.perl.org/licenses/artistic.html>
14131413
All the credits go to Andrea Frosini for the neat assembler trick
14141414
that makes this thing work. I've also used some work by Dave Roth
14151415
for the prototyping stuff. A big thank you also to Gurusamy Sarathy
1416-
for his unvaluable help in XS development, and to all the Perl
1416+
for his invaluable help in XS development, and to all the Perl
14171417
community for being what it is.
14181418
14191419
Cosimo also wants to personally thank everyone that contributed

Callback.pm

+9-9
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ BEGIN {
5555
*PTRSIZE = *Win32::API::PTRSIZE;
5656
sub PTRLET ();
5757
*PTRLET = *Win32::API::Type::pointer_pack_type;
58-
if(OPV <= 5.008000){ #dont have unpackstring in C
58+
if(OPV <= 5.008000){ #don't have unpackstring in C
5959
eval('sub _CallUnpack {return unpack($_[0], $_[1]);}');
6060
}
6161
}
@@ -133,7 +133,7 @@ sub MakeStruct {
133133
# for(@{$self->{intypes}}){ #elements of intypes are not 1 to 1 with stack params
134134
# my ($typeletter, $packedparam, $finalParam, $unpackletter) = ($_, $arr->[$i]);
135135
#
136-
# #structs dont work, this is broken code from old version
136+
# #structs don't work, this is broken code from old version
137137
# #$self->{intypes} is letters types not C prototype params
138138
# #C prototype support would have to exist for MakeStruct to work
139139
# if( $typeletter eq 'S' || $typeletter eq 's'){
@@ -317,7 +317,7 @@ sub MakeCB{
317317
.("\x50"# push eax
318318
."\xB8").$Stage2FuncPtrPkd # mov eax, 0C0DE0001h
319319
.("\xFF\xD0"# call eax
320-
#since ST(0) is volatile, we dont care if we fill it with garbage
320+
#since ST(0) is volatile, we don't care if we fill it with garbage
321321
."\x80\x7D\xFE\x00"#cmp [ebp+FuncRtnCxtVar.F_Or_D], 0
322322
."\x74\x05"# jz 5 bytes
323323
."\xDD\x45\xF4"# fld qword ptr [ebp+retval] (double)
@@ -326,7 +326,7 @@ sub MakeCB{
326326
#rewind sp to entry sp, no pop push after this point
327327
."\x83\xC4\x24"# add esp, 24h
328328
."\x8B\x45\xF4"# mov eax, dword ptr [ebp+retval]
329-
#edx might be garbage, we dont care, caller only looks at volatile
329+
#edx might be garbage, we don't care, caller only looks at volatile
330330
#registers that the caller's prototype says the caller does
331331
."\x8B\x55\xF8"# mov edx, dword ptr [ebp+retval+4]
332332
#can't use retn op, it requires a immediate count, our count is in a register
@@ -339,7 +339,7 @@ sub MakeCB{
339339

340340

341341
#begin x64 part
342-
#these packs dont constant fold in < 5.17 :-(
342+
#these packs don't constant fold in < 5.17 :-(
343343
#they are here for readability
344344
:(''.pack('C', 0b01000000 #REX base
345345
| 0b00001000 #REX.W
@@ -509,7 +509,7 @@ that causes all quads to be accepted as, and returned as L<Math::Int64>
509509
objects. 4 to 8 byte long pass by copy/return type C aggregate types
510510
are very rare in Windows, but they are supported as "in" and return
511511
types by using 'q'/'Q' on 32 and 64 bits. Converting between the C aggregate
512-
and its representation as a quad is upto the reader. For "out" in
512+
and its representation as a quad is up to the reader. For "out" in
513513
Win32::API::Callback (not "in"), if the argument is a reference, it will
514514
automatically be treated as a Math::Int64 object without having to
515515
previously call this function.
@@ -523,7 +523,7 @@ value is a double precision number (double)
523523
=item C<Unimplemented types>:
524524
Unimplemented in Win32::API::Callback types such as shorts, chars, and
525525
smaller than "machine word size" (32/64bit) numbers can be processed
526-
by specifiying N, then masking off the high bytes.
526+
by specifying N, then masking off the high bytes.
527527
For example, to get a char, specify N, then do C<$numeric_char = $_[2] & 0xFF;>
528528
in your Perl callback sub. To get a short, specify N, then do
529529
C<$numeric_char = $_[2] & 0xFFFF;> in your Perl callback sub.
@@ -539,7 +539,7 @@ C<$numeric_char = $_[2] & 0xFFFF;> in your Perl callback sub.
539539
$CallbackObj = Win32::API::Callback->new( sub { print "hello world";},
540540
$in, $out);
541541
542-
Creates and returns a new Win32::API::Callback object. Calling convetion
542+
Creates and returns a new Win32::API::Callback object. Calling convention
543543
parameter is optional. Calling convention parameter has same behaviour as
544544
Win32::API's calling convention parameter. C prototype parsing of Win32::API
545545
is not available with Win32::API::Callback. If the C caller assumes the
@@ -548,7 +548,7 @@ parameters, if they are floats or doubles they will be garbage. Note there is
548548
no way to create a Win32::API::Callback callback with a vararg prototype.
549549
A workaround is to put "enough" Ns as the in types, and stop looking at the @_
550550
slices in your Perl sub callback after a certain count. Usually the first
551-
parameter will somehow indiciate how many additional stack parameters you are
551+
parameter will somehow indicate how many additional stack parameters you are
552552
receiving. The Ns in @_ will eventually become garbage, technically they are
553553
the return address, saved registers, and C stack allocated variables of the
554554
caller. They are effectivly garbage for your vararg callback. All vararg

IATPatch.pod

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Win32::API::Callback::IATPatch - Hooking and Patching a DLL's Imported C Functio
4040
Win32::API::Callback::IATPatch allows you to hook a compile time dynamic linked
4141
function call from any DLL (or EXE, from now on all examples are from a DLL to
4242
another DLL, but from a EXE to a DLL is implied) in the Perl process, to a
43-
differnt DLL in the same Perl process, by placing a Win32::API::Callback object
43+
different DLL in the same Perl process, by placing a Win32::API::Callback object
4444
in between. This module does B<not> hook B<GetProcAddress> function calls. It
4545
also will not hook a function call from a DLL to another function in the same
4646
DLL. The function you want to hook B<must> appear in the B<import table> of the
@@ -62,13 +62,13 @@ script creates IATPatch object, where calls from that new DLL goto the real
6262
destination function without hooking. If a DLL is unloaded, then reloaded into
6363
the process, you must call C<Unpatch(0)> method on the old IATPatch object, then
6464
create a new IATPatch object. IATPatch has no notification feature that a DLL
65-
is being loaded or unloaded from the process. Unless you completly control, and
65+
is being loaded or unloaded from the process. Unless you completely control, and
6666
have the source code of the caller DLL, and understand all of the source code of
6767
that DLL, there is a high chance that you will B<NOT> hook all calls from that
68-
DLL to the destionation function. If a call to the destination function is
68+
DLL to the destination function. If a call to the destination function is
6969
dangerous or unacceptable, do not use IATPatch. IATPatch is not Microsoft
7070
Detours or the like in any sense. Detours and its brethern will rewrite the
71-
machine code in the begining of the destination function call, hooking all
71+
machine code in the beginning of the destination function call, hooking all
7272
calls to that function call process wide, without exception.
7373

7474
Why this module was created? So I created create mock kernel32 functions to
@@ -82,7 +82,7 @@ unit test Perl's C function calls to Kernel32.
8282
$A_Win32_API_Callback_Obj, $EXE_or_DLL_hmodule_or_name_to_hook,
8383
$import_DLL_name, $import_function_name_or_ordinal);
8484

85-
Creates a new IATPatch object. The Win32::API::Callback will be called aslong
85+
Creates a new IATPatch object. The Win32::API::Callback will be called as long
8686
as the IATPatch object exists. When an IATPatch object is DESTROYed, unless
8787
C<-E<gt>Unpatch(0)> is called first, the patch is undone and the original
8888
function is directly called from then on by that DLL. The DLL is not reference

Struct.pm

+6-6
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ sub getPack {
237237
my @buffer_ptrs = (); #this contains the struct_ptrs that were placed in the
238238
#the struct, its part of "C func changes the struct ptr to a private allocated
239239
#struct" code, it is push/poped only for struct ptrs, it is NOT a 1 to
240-
#1 mapping between all struct members, so dont access it with indexes
240+
#1 mapping between all struct members, so don't access it with indexes
241241

242242
my $align = $self->align();
243243

@@ -411,7 +411,7 @@ else{ #new ptr is true
411411
}
412412
#must fix {buffer} with contents of the new struct, $structptr might be
413413
#null or might be a SVPV from a ::Struct that was ignored, in any case,
414-
#a forign memory allocator is at work here
414+
#a foreign memory allocator is at work here
415415
$$SVMemberRef->{buffer} = Win32::API::ReadMemory($newstructptr, $$SVMemberRef->sizeof)
416416
if($oldstructptr != $newstructptr);
417417
#always must be called, if new ptr is not null, at this point, C func, did
@@ -584,7 +584,7 @@ function takes care of removing the semicolon after the member
584584
name. Win32::API::Struct does B<NOT> support Enums, Unions, or Bitfields.
585585
C<NAME> must not end in C<*>, typedef creates structs, not struct pointers.
586586
See L<Win32::API::Type/"typedef">
587-
on howto create a struct pointer type. Returns true on success, and undef on error.
587+
on how to create a struct pointer type. Returns true on success, and undef on error.
588588
On error it L<warns|perlfunc/warn> with the specific reason.
589589
590590
The synopsis example could be written like this:
@@ -600,7 +600,7 @@ syntax), which is pretty cool:
600600
};
601601
602602
L<Win32::API/Call> automatically knows that an 'LPNAME' type, refers
603-
to a 'NAME' type struct. Also see L<Win32::API::Type/"typedef"> on howto declare
603+
to a 'NAME' type struct. Also see L<Win32::API::Type/"typedef"> on how to declare
604604
pointers to struct types.
605605
606606
Unlike in Win32::API, a single non-array char or CHAR struct member in a
@@ -697,9 +697,9 @@ allocator. Some C APIs give you static global buffers which never are freed or f
697697
automatically in the next call to a function from to that DLL.
698698
699699
With foreign allocators, its best to treat to write a pointer class, bless the
700-
ref to scalar interger (holding the pointer) into that class to ensure that the
700+
ref to scalar integer (holding the pointer) into that class to ensure that the
701701
DESTROY method will free the pointer and you never leak it, and your write
702-
method accesors using L<perlfunc/pack>, L<Win32::API/ReadMemory> and
702+
method accessors using L<perlfunc/pack>, L<Win32::API/ReadMemory> and
703703
L<Win32::API/WriteMemory> around the pointer.
704704
705705

Type.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ LPHANDLE.
412412
=item signed char
413413
414414
These 2 types by name force numeric handling. C<97> not C<"a">. C<UCHAR> is
415-
not a C<unsigned char> for numeric handling purposess.
415+
not a C<unsigned char> for numeric handling purposes.
416416
417417
=back
418418

0 commit comments

Comments
 (0)