mmavipc Posted July 17, 2008 Share Posted July 17, 2008 (edited) okay so yeah. I have this dll and heres part of the readme EncryptWithHeaderToClient : Function(Version:Integer;InitializeVector,inBuf,outBuf:Pointer;_Len:Integer):Integer; Stdcall; {RETURNS ERRORCODE} { This is encryption with extended function: generate header. Client's header differs } { from server's header, so this should not be tingled up together } { inBuf and outBuf is pointers to FIRST BYTE of input and output } { Version is version of maple client/server my question: how do I pass the inBuf and outBuf to the dll? here my current non working code func encrypt($data,byref $ivsend) $output = "" $dll = DllOpen("maplecrypt.dll") DllCall($dll,"int","Initialize") $output = DllCall($dll,"int","EncryptWithHeaderToClient","int",55,"int*",$ivsend,"int*",$data,"int*",$output,"int",StringLen($data)) ConsoleWrite($output & @lf) DllClose($dll) return $output EndFunc edit: uploaded dllMapleCrypt.dll Edited July 17, 2008 by mmavipc [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
monoceres Posted July 17, 2008 Share Posted July 17, 2008 Hi! I'm not sure since I cannot test with the dll but I think you need to store your data in a DllStruct and then pass the pointer to the struct to the dll. muttley Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
mmavipc Posted July 17, 2008 Author Share Posted July 17, 2008 Hi!I'm not sure since I cannot test with the dll but I think you need to store your data in a DllStruct and then pass the pointer to the struct to the dll.muttleycan you give me an example of this? [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
monoceres Posted July 17, 2008 Share Posted July 17, 2008 (edited) I managed to get something working, don't know if it's correct: $data="Andreas!"&Chr(0) $output = "" $dll = DllOpen("maplecrypt.dll") DllCall($dll,"int","Initialize") $indata=DllStructCreate("char data["&StringLen($data)&"];") $outdata=DllStructCreate("char data["&StringLen($data)&"];") DllStructSetData($indata,"data",$data) $output = DllCall($dll,"int","EncryptWithHeaderToClient","int",55,"int*",0,"ptr",DllStructGetPtr($indata),"ptr",DllStructGetPtr($outdata),"int",StringLen($data)) MsgBox(0,"",DllStructGetData($outdata,"data")) DllClose($dll) Edited July 17, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
mmavipc Posted July 17, 2008 Author Share Posted July 17, 2008 Hi! I managed to get something working, don't know if it's correct: $data="Andreas!"&Chr(0) $output = "" $dll = DllOpen("maplecrypt.dll") DllCall($dll,"int","Initialize") $indata=DllStructCreate("char data["&StringLen($data)&"];") $outdata=DllStructCreate("char data["&StringLen($data)&"];") DllStructSetData($indata,"data",$data) $output = DllCall($dll,"int","EncryptWithHeaderToClient","int",55,"int*",0,"ptr",DllStructGetPtr($indata),"ptr",DllStructGetPtr($outdata),"int",StringLen($data)) MsgBox(0,"",DllStructGetData($outdata,"data")) DllClose($dll)you are god [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
mmavipc Posted July 17, 2008 Author Share Posted July 17, 2008 this is what i have so far and autoit closes with the "Autoit has stopped working" error #include-once Dim $iv[4] $iv[0] = 0x46 $iv[1] = 0x72 $iv[2] = 0x7A $iv[3] = 0xF0 $lol = encrypt("0D", $iv) MsgBox(0,@error,$lol) Func encrypt($data, ByRef $ivsend) $output = "" $dll = DllOpen("maplecrypt.dll") DllCall($dll, "int", "Initialize") $indata = DllStructCreate("char data[" & StringLen($data) & "];") $outdata = DllStructCreate("char data[" & StringLen($data) & "];") $ivdata = DllStructCreate("chr data[" & StringLen($ivsend) & "];") DllStructSetData($indata, "data", $data) DllStructSetData($ivdata,"data",$ivsend) DllCall($dll, "int", "EncryptWithHeaderToClient", "int", 55, "ptr", DllStructGetPtr($ivdata), "ptr", DllStructGetPtr($indata), "ptr", DllStructGetPtr($outdata), "int", StringLen($data)) $output = DllStructGetData($outdata, "data") DllClose($dll) return $output EndFunc ;==>encrypt ;Func decrypt($data [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
monoceres Posted July 17, 2008 Share Posted July 17, 2008 (edited) Since your dealing with int's, use an array of ints: Dim $iv[4] $iv[0] = 0x46 $iv[1] = 0x72 $iv[2] = 0x7A $iv[3] = 0xF0 $data="Andreas!"&Chr(0) $output = "" $dll = DllOpen("maplecrypt.dll") DllCall($dll,"int","Initialize") $indata=DllStructCreate("char data["&StringLen($data)&"];") $outdata=DllStructCreate("char data["&StringLen($data)&"];") DllStructSetData($indata,"data",$data) $ivstruct=DllStructCreate("byte key["&UBound($iv)&"];") For $i=0 To UBound($iv)-1 DllStructSetData($ivstruct,"key",$iv[$i],$i+1) Next $output = DllCall($dll,"int","EncryptWithHeaderToClient","int",55,"ptr",DllStructGetPtr($ivstruct),"ptr",DllStructGetPtr($indata),"ptr",DllStructGetPtr($outdata),"int",StringLen($data)) MsgBox(0,"",DllStructGetData($outdata,"data")) DllClose($dll) muttley Edited July 17, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
mmavipc Posted July 17, 2008 Author Share Posted July 17, 2008 Since your dealing with int's, use an array of ints: Dim $iv[4] $iv[0] = 0x46 $iv[1] = 0x72 $iv[2] = 0x7A $iv[3] = 0xF0 $data="Andreas!"&Chr(0) $output = "" $dll = DllOpen("maplecrypt.dll") DllCall($dll,"int","Initialize") $indata=DllStructCreate("char data["&StringLen($data)&"];") $outdata=DllStructCreate("char data["&StringLen($data)&"];") DllStructSetData($indata,"data",$data) $ivstruct=DllStructCreate("byte key["&UBound($iv)&"];") For $i=0 To UBound($iv)-1 DllStructSetData($ivstruct,"key",$iv[$i],$i+1) Next $output = DllCall($dll,"int","EncryptWithHeaderToClient","int",55,"ptr",DllStructGetPtr($ivstruct),"ptr",DllStructGetPtr($indata),"ptr",DllStructGetPtr($outdata),"int",StringLen($data)) MsgBox(0,"",DllStructGetData($outdata,"data")) DllClose($dll) muttleythank you [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N Link to comment Share on other sites More sharing options...
mmavipc Posted July 18, 2008 Author Share Posted July 18, 2008 okay here's my new script: expandcollapse popup#include-once #include <string.au3> Dim $iv[4] $iv[0] = 0x00 $iv[1] = 0x00 $iv[2] = 0x00 $iv[3] = 0x00 $lol = encrypt(_HexToString("1b0007000000000000000600000000000000000000000009FF7E7800000000A845000000000200"), $iv) ConsoleWrite($lol & @lf) $decrypt = decrypt($lol,$iv) ConsoleWrite("decryptlen: " & StringLen($decrypt) & @lf) ConsoleWrite("decrypted: " & $decrypt & @lf) FileWrite("lolz.hex",$decrypt) Func encryptwh($data, ByRef $ivsend) $output = "" $dll = DllOpen("maplecrypt.dll") DllCall($dll, "int", "Initialize") $indata = DllStructCreate("char data[" & StringLen($data) & "];") $outdata = DllStructCreate("char data[" & StringLen($data)+4 & "];") DllStructSetData($indata, "data", $data) $ivstruct = DllStructCreate("byte key[" & UBound($ivsend) & "];") For $i = 0 To UBound($iv) - 1 DllStructSetData($ivstruct, "key", $ivsend[$i], $i + 1) Next DllCall($dll,"int","EncryptWithHeaderToClient","int",55,"ptr",DllStructGetPtr($ivstruct),"ptr",DllStructGetPtr($indata),"ptr",DllStructGetPtr($outdata),"int",StringLen($data)) $output = DllStructGetData($outdata, "data") DllClose($dll) Return $output EndFunc ;==>encrypt Func encrypt($data, ByRef $ivsend) $output = "" $dll = DllOpen("maplecrypt.dll") DllCall($dll, "int", "Initialize") $indata = DllStructCreate("char data[" & StringLen($data) & "];") $outdata = DllStructCreate("char data[" & StringLen($data)+4 & "];") DllStructSetData($indata, "data", $data) $ivstruct = DllStructCreate("byte key[" & UBound($ivsend) & "];") For $i = 0 To UBound($iv) - 1 DllStructSetData($ivstruct, "key", $ivsend[$i], $i + 1) Next DllCall($dll,"int","Encrypt","ptr",DllStructGetPtr($ivstruct),"ptr",DllStructGetPtr($indata),"ptr",DllStructGetPtr($outdata),"int",StringLen($data)) $output = DllStructGetData($outdata, "data") DllClose($dll) Return $output EndFunc ;==>encrypt Func decrypt($data, ByRef $ivsend) $output = "" $dll = DllOpen("maplecrypt.dll") DllCall($dll, "int", "Initialize") $indata = DllStructCreate("char data[" & StringLen($data) & "];") $outdata = DllStructCreate("char data[" & StringLen($data) & "];") DllStructSetData($indata, "data", $data) $ivstruct = DllStructCreate("byte key[" & UBound($ivsend) & "];") For $i = 0 To UBound($iv) - 1 DllStructSetData($ivstruct, "key", $ivsend[$i], $i + 1) Next DllCall($dll,"int","Decrypt","ptr",DllStructGetPtr($ivstruct),"ptr",DllStructGetPtr($indata),"ptr",DllStructGetPtr($outdata),"int",StringLen($data)) $output = DllStructGetData($outdata, "data") DllClose($dll) Return $output EndFuncAll that returns when decrypted is the 0x1B. does autoit have a problem with nullbytes? [size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N 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