Thu Jan 20 01:14:27 2011: Request 55660 was acted upon.
Transaction: Correspondence added by jain_vipin_swm
       Queue: Win32-API
     Subject: [PATCH] Partial win64 support for Win32::API
   Broken in: (no value)
    Severity: (no value)
       Owner: COSIMO
  Requestors: r...@cpan.org, sbenn...@accelrys.com
      Status: open
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=55660 >


On Wed Mar 17 10:09:53 2010, sbenn...@accelrys.com wrote:
> The attached three patches (against Win32-API-0.59) implement initial
>    support for 64-bit Windows in Win32-API.
> 
> I didn't attempt to
>    port Win32::API::Callback. It looks like considerably more effort
>    than Win32::API itself, and as our application doesn't need it I
>    couldn't justify the paid time to spend on it. This is, however,
>    sufficient for Win32::API tests to pass against a 64-bit ActivePerl
>    5.8.9.
> 
> At present, only MSVC++ toolchains will work, as its
>    assembly dialect is different from GNU. I don't have a gcc-based
>    build of Perl to work with to port it, but it should only require a
>    straightforward translation of call_asm_x64_msvc.asm into
>    call_asm_x64_gnu.asm.
> 
> The required changes to Makefile.PL are
>    also somewhat hackish, purely because I don't know of a better way
>    to detect what architecture we're targeting.
> 
> Accelrys Limited
>    (http://accelrys.com)
> Registered office: 334 Cambridge Science
>    Park, Cambridge, CB4 0WN, UK
> Registered in England: 2326316

It seems that call_x64_real assembly function has a bug. It causes a 
perl crash if we call a Windows API needing more than 4 parameters.
Ex. 
Win32::DriveInfo::GetFreeDiskSpace,Win32::DriveInfo::GetFreeDiskSpaceEx.

These APIs expect more than 4 parameter, so some of the parameters 
(nstack = nparams - available_registers) are copied from copystack 
block of assembly code. This code has a bug which I fixed. I attached a 
patch for this.

Basically, we were subtracting before testing for zero, this resulted 
into non-zero value when rax = 0 and instruction "sub rax 1" executed.

-Vipin


diff --git a/call_asm_x64_msvc.asm b/call_asm_x64_msvc.asm
index 7f8b2b0..43e8941 100755
--- a/call_asm_x64_msvc.asm
+++ b/call_asm_x64_msvc.asm
@@ -38,12 +38,11 @@ Call_x64_real PROC FRAME
     ; Except not if there isn't any
     test rax, rax
     jz docall
-    sub rax, 1
 
 copystack:
+    sub rax, 1
     mov r10, qword ptr [rsi+8*rax]
     push r10
-    sub rax, 1
     test rax, rax
     jnz copystack
 

Reply via email to