Yuraj Posted July 31, 2009 Share Posted July 31, 2009 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) Link to comment Share on other sites More sharing options...
Confuzzled Posted August 1, 2009 Share Posted August 1, 2009 Alternative solution may be less effort: http://www.autoitscript.com/forum/index.php?showtopic=73425 http://www.autoitscript.com/forum/index.php?showtopic=21004 Link to comment Share on other sites More sharing options...
Yuraj Posted August 1, 2009 Author Share Posted August 1, 2009 Alternative solution may be less effort:http://www.autoitscript.com/forum/index.php?showtopic=73425http://www.autoitscript.com/forum/index.php?showtopic=21004Thanks, 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) Link to comment Share on other sites More sharing options...
Yuraj Posted August 1, 2009 Author Share Posted August 1, 2009 (edited) Ok, if nobody, then please somebody write my an C/++ example of PKWARE.dll usage of Uncompress function . I can't get it >_ Edited August 1, 2009 by Yuraj ShellExecute("http://www.yuraj.ucoz.com")ProcessClose(@AutoItPID) Link to comment Share on other sites More sharing options...
Authenticity Posted August 1, 2009 Share Posted August 1, 2009 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now