[X YOKO] Huffman Compression

Ask for help

Moderators: Murderator+, Murderator

Post Reply
Fonzy
Posts: 32
Joined: 2004-05-03 17:30:45
Location: OR
Contact:

[X YOKO] Huffman Compression

Post 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?
OR
AGRS
Expert!
Posts: 1007
Joined: 2004-04-04 21:40:09
Contact:

Post by AGRS »

Fonzy
Posts: 32
Joined: 2004-05-03 17:30:45
Location: OR
Contact:

Post 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..
OR
AGRS
Expert!
Posts: 1007
Joined: 2004-04-04 21:40:09
Contact:

Post by AGRS »

I don't know about compress, but decompress is 100% correct. My UO Script Client is based on that decompress algoritm.
Necr0Potenc3
Expert!
Posts: 74
Joined: 2004-05-30 00:31:54

Post 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
Fonzy
Posts: 32
Joined: 2004-05-03 17:30:45
Location: OR
Contact:

Post 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..
OR
Fonzy
Posts: 32
Joined: 2004-05-03 17:30:45
Location: OR
Contact:

Post 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?
OR
Fonzy
Posts: 32
Joined: 2004-05-03 17:30:45
Location: OR
Contact:

Post 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?
OR
Fonzy
Posts: 32
Joined: 2004-05-03 17:30:45
Location: OR
Contact:

Post 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?
OR
Fonzy
Posts: 32
Joined: 2004-05-03 17:30:45
Location: OR
Contact:

Post by Fonzy »

ok I converted in VB the Necromancer Compress and Decomoress functions. All working good. Thanks to all.
OR
Post Reply