Page 1 of 1
[X YOKO] Huffman Compression
Posted: 2004-10-27 21:13:56
by Fonzy
I was trying to do a software with Visual Basic and studiing the UO protocol i've seen it uses the Huffman Compression Metod.
Yoko do you have a Visual Basic port for the Compressor/Decompressor functions in Injection DLL, or maybe a dll usable with vb?
Posted: 2004-10-27 21:34:58
by AGRS
Posted: 2004-10-27 21:46:16
by Fonzy
i tried it a lot, but the class which decompress has a little bug. I've contacted the author, but no answer.
The problem is that it doesn't decompress well certain strings, and it is for sure, because i tried to compress a string, decompress the result, and the obtainer string wasn't equal to the first.
Any other help? It's very important for me..
Posted: 2004-10-27 22:17:13
by AGRS
I don't know about compress, but decompress is 100% correct. My UO Script Client is based on that decompress algoritm.
Posted: 2004-10-28 00:43:47
by Necr0Potenc3
dl this:
http://uo.elitecoder.net/phpBB/viewtopic.php?t=281
use the exported functions... since you are using VB, set the struct pointer to NULL
Posted: 2004-10-28 00:46:29
by Fonzy
i'm working on a client which is able to change the packets sent by the server. It's something like a proxy, it receive, modify packets, and send them to the real client. The compression i really important. In the injection.dll there is a compressor, it's written in c++. Unfortunately i'm not skilled enough to convert it in Visual Basic, and also a lot of things used in the code is natively unportable.. The best way is to use in VB a dll compiled in c++, using the Yoko Code. Only Yoko can do something like this, i hope he'll answer..
Posted: 2004-10-28 01:16:13
by Fonzy
Necr0Potenc3 seems what i need, but i didn't understand how to use the dll, when i try to call compress it crashes. Can you hint me how to do a packet compression, maybe with a sample?
Posted: 2004-10-28 01:39:23
by Fonzy
This is the code i've written. Is there any error?
Private Declare Sub Compress Lib "UOEncryption.dll" (Dest() As Byte, Source() As Byte, DestSize As Integer, SrcSize As Integer)
Private Sub Form_Load()
Dim src() As Byte, dst() As Byte
String2Array "hello", src()
Compress dst, src, 1000, 5
End Sub
Private Function String2Array(Text, ByRef ar() As Byte) As Long
On Error Resume Next
ReDim ar(Len(Text) - 1)
For i = 0 To Len(Text) - 1
ar(i) = Asc(Mid(Text, i + 1, 1))
Next i
End Function
When I run the program, VB Crashes. Any help?
Posted: 2004-10-28 02:05:24
by Fonzy
ok, new things i've done, but still not working. There's something wrong with memory:
'IN A MODULE
Public Declare Sub Compress Lib "UOEncryption.dll" (ByRef Dest() As Byte, ByRef Source() As Byte, ByRef DestSize As Integer, ByRef SrcSize As Integer)
Public Src() As Byte
Public Dst() As Byte
Public SrcLength As Integer
Public DestLength As Integer
'IN MAIN FORM
Private Sub Form_Load()
String2Array "ciao", Src()
SrcLength = 4
DestLength = 1000
Compress Dst, Src, DestLength, SrcLength
End Sub
Private Function String2Array(Text, ByRef ar() As Byte) As Long
On Error Resume Next
ReDim ar(Len(Text) - 1)
For i = 0 To Len(Text) - 1
ar(i) = Asc(Mid(Text, i + 1, 1))
Next i
End Function
When i run it says Error 49: Bad DLL calling convention. If i debug Src, DestLength and SrclLength, everything works, if I debug Dst it crashes saying memory could not be read. Someone can help?
Posted: 2004-10-28 23:28:56
by Fonzy
ok I converted in VB the Necromancer Compress and Decomoress functions. All working good. Thanks to all.