Jump to content
Sign in to follow this  
Yuraj

DllCall and PKware Uncompress function

Recommended Posts

Yuraj

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)

Share this post


Link to post
Share on other sites
Confuzzled

Alternative solution may be less effort:

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

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

Share this post


Link to post
Share on other sites
Yuraj

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)

Share this post


Link to post
Share on other sites
Yuraj

Ok, if nobody, then please somebody write my an C/++ example of PKWARE.dll usage of Uncompress function . I can't get it >_

Edited by Yuraj

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

Share this post


Link to post
Share on other sites
Authenticity

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.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.