Reviews by Richard Shomin


Win32-API (0.46) ****

This works well, but there is an upgrade that handles "cdecl"
calling convention, This one only handles the "stdcall" similar
to the pascal calling convention .
Expect a crash(stack overflow exception) if you call a dll that uses

__cdecl calling convention such as the functions inside msvcrt.dll
, msvcr71.dll or msvcp71.dll.

Without using __cdecl ,
your stack pointer will not be balanced after the call. You still
have to pop (or add esp, ???) the arguments you passed off the stack.
Many of the Microsoft dll's like kernel32.dll,user32.dll use the __stdcall calling convention. The C libraries use the C calling convention.
Also the upgrade will compile under 2003 see: by Willem Jan Hengeveld
There is an extra option after the return type parameter for your
calling convention in your prototype '__stdcall' or '_cdecl',
the default is '__stdcall' .
I might develop another optional parameter that tests the stack
pointer before and after the call to print an error message if
the stack isn't balanced.

C-DynaLib (0.55) *****

I got this module to work under Win32 (XP) with msvc 7.0 , Perl5.8 .
I had to tweek for Win32 specifics. Added a Peek()
routine to Dynalib.xs and got all the tests to run successfully ,even
the Win32 GUI test in the distribution !!!!
I might contact the author, about the changes , after I get it running to my satisfaction - there are things to iron out.
I will add one more test script - calling an inline assembly
language routine - this on simply returns a value to the caller.

###### ##########
###### tested on Win32 x86 machine
use C::DynaLib ();

sub DeclareSub { &C::DynaLib::DeclareSub }
sub PTR_TYPE { &C::DynaLib::PTR_TYPE }

$asm = "\x90\xb8\x05\x00\x00\x00\xc3\x90\x90";
# 90 nop - replace with cc for debugger
# b805000000 mov eax, 5 # RETURN VALUE of 5
# c3 ret cdecl call return - caller adjust stack
# 90 90 (2)nop 2 nops for room(stdcall stack adjsut)

$asmptr = unpack(PTR_TYPE, pack("P", $asm)); # get pointer to routine
$AsmFunc = DeclareSub($asmptr , "i"); # define sub(returns int)
$ret = &$AsmFunc(); # call asm routine
print '&$AsmFunc() returned: ',$ret,"\n";
##### END OF CODE ######

And it prints 5 as expected.

I am having fun with tweeking this anyway....

Here are some things I did to get it to work:

Find and Edit the 2 lines in to read :
# inline-able constants?
sub PTR_TYPE(){i};

Then run:
c:\temp> perl DECL=hack30
c:\temp> nmake test

My other noted changes:

Minor edits in added Microsoft's legacy dll search order (allows

msvcrt.dll to be loaded in

DynaLib.xs: added Peek() routine - now have both Poke and Peek,

two very useful memory routines for use in Perl. added $^O test for Win32 for redirection (> NUL:)

along with UNIX (>/dev/null) - call simple assembly language routine.

IDEAS: Try and make it fully compile with MSVC++ compiler with cdecl

calling convention instaed of hack30.

Add the stdcall or pascal calling convention. Since this

already calls assembly routines the

"nakedcall" could be considered - you write your own

prologue/epilog code.