Jump to content

Recommended Posts

Posted

Hello,

I need help to translate this code from C to AutoIt. It's pkware uncompress function for compressed files:

// decompression function -- returns zero on success
DWORD (__cdecl *Uncompress)
(
 char   *outputBuffer,
 DWORD *pOutSize,
 char   *inputBuffer,
 DWORD  dwSize
);

// first, load the library
HINSTANCE hDllInst=LoadLibrary("pkware.dll");

// get the decompression function address
Uncompress=(DWORD (__cdecl *)(char*, DWORD*, char*, DWORD))GetProcAddress(hDllInst,"Uncompress");

// decompress file -- it's assumed here that input buffer contains compressed
// file loaded from BLB archive and output buffer is allocated and has proper
// size (that is, (dwOutSize) value from the corresponding directory entry)
Uncompress(outputBuffer,&dwOutSize,inputBuffer,dwSize);

// now (outputBuffer) contains decompressed file and (dwOutSize) is set to
// decompressed file size (you should use directory entry value of output
// size for output buffer allocation)

I have done this example, it returns 0 but still it doesn't work:

$a = DllStructCreate("char[50]")
    $b = DllStructCreate("dword")
    $c = DllStructCreate("char[50]")
    $handle = FileOpen("F00A_compressed",16)

    $data = FileRead($handle)
    DllStructSetData($c,1,$data)
    
    $p1 = DllStructGetPtr($a)
    $p2 = DllStructGetPtr($b)
    $p3 = DllStructGetPtr($c)
    $res = DllCall("pkware.dll","dword","Uncompress","char*",$p1,"dword*",$p2,"char*",$p3,"dword",FileGetSize("F00A_compressed"))
    ConsoleWrite($res)
    $out = DllStructGetData($a,1)
    FileWrite("C:\test.txt", $out)
    FileClose($handle)

ShellExecute("http://www.yuraj.ucoz.com")ProcessClose(@AutoItPID)

Posted

Alternative solution may be less effort:

http://www.autoitscript.com/forum/index.php?showtopic=73425

http://www.autoitscript.com/forum/index.php?showtopic=21004

Posted

Alternative solution may be less effort:

http://www.autoitscript.com/forum/index.php?showtopic=73425

http://www.autoitscript.com/forum/index.php?showtopic=21004

Thanks, but it isn't what I need.

It's a compressed file without any (zip...) header, only compressed stream.

ShellExecute("http://www.yuraj.ucoz.com")ProcessClose(@AutoItPID)

Posted

You forgot to specify the calling convention when calling DllCall() because otherwise __stdcall is assumed. Try calling like this, maybe it'll work:

$res = DllCall("pkware.dll", "dword:cdecl", "Uncompress", _
                "char*", $p1, _
                "dword*", $p2, _
                "char*", $p3, _
                "dword", FileGetSize("F00A_compressed") _
        )

If it'll fail, try to be more specific of the location of the dll or the file to decompress.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...