Author Topic: [BNET/RB] How to Hash  (Read 5625 times)

0 Members and 1 Guest are viewing this topic.

Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
[BNET/RB] How to Hash
« on: August 31, 2005, 06:51:00 am »
I am writing a bot, as you know, in REALbasic.

I now have the ability to send, receive and parse packets from battle.net. I just need a way to hash CDKeys.. I don't want to use BNLS for the CDKeys, but I will for everything else, if I have to.

Basically, I would like a way to hash CD-Keys locally, and, if possible, preform all the other functions of BNLS locally.

1. BNCSUtil is a definite option. I need to look at it more to determine if it can be easily made cross platform.
2. BNLS is not an option for CD-Keys.. I refuse to send them to any server besides battle.net.

Thanks in advance!
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00

Offline Newby

  • x86
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: [BNET/RB] How to Hash
« Reply #1 on: August 31, 2005, 09:01:06 am »
Hmm..

How well can you read C/C++?

If the answer is > ok, take a look at BNCSUtil and migrate what you can.
- Newby
http://www.x86labs.org

Quote
[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [BNET/RB] How to Hash
« Reply #2 on: August 31, 2005, 09:20:23 am »
Hmm..

How well can you read Java?

If the answer is > ok, take a look at JavaOp or JBLS and migrate what you can.

(<3 copy and pasting from newby)

EDIT -
Because I'm so totally full of myself and consider my skill in Java mediocre, instead of minimal as others would tell you (Hi LoRd!), I'm porting the hashing stuff from JBLS to VB right now.

EDIT -
'// Author: iago[x86]
'// Source: JavaOp
'// Ported to VB by Joe[x86]

'// This is the only function you will need to call. It will call the other functions on its own.
Public Function HashKey(clientToken As Long, serverToken As Long, key As String) As String
    Select Case Len(key)
        Case 13: Let HashKey = HashSCKey(clientToken, serverToken, key)
        Case 16: Let HashKey = HashD2Key(clientToken, serverToken, key)
        Case 26: Let HashKey = HashWAR3Key(clientToken, serverToken, key)
    End Select
End Function
   
Private Function HashSCKey(clientToken As Long, serverToken As Long, key As String) As String
    Dim SC As New SCKey
    Dim Ret As New HashBuffer
    Call Ret.AddDWORD(Len(key))
    Call Ret.AddDWORD(SC.getProduct)
    Call Ret.AddDWORD(SC.getVal1)
    Call Ret.AddDWORD(0)
    Dim HashedKey(0 To 4) As Long: Let HashedKey = SC.Hash(clientToken, serverToken)
    Dim I As Byte: For I = 0 To 4 Step 1
        Call Ret.AddDWORD(HashedKey(I))
    Next I
    Let HashD2Key = Ret.Ret
End Function

Private Function HashD2Key(clientToken As Long, serverToken As Long, key As String) As String
    Dim D2 As New D2Key
    Dim Ret As New HashBuffer
    Call Ret.AddDWORD(Len(key))
    Call Ret.AddDWORD(D2.getProduct)
    Call Ret.AddDWORD(D2.getVal1)
    Call Ret.AddDWORD(0)
    Dim HashedKey(0 To 4) As Long: Let HashedKey = D2.Hash(clientToken, serverToken)
    Dim I As Byte: For I = 0 To 4 Step 1
        Call Ret.AddDWORD(HashedKey(I))
    Next I
    Let HashD2Key = Ret.Ret
End Function

Private Function HashWAR3Key(clientToken As Long, serverToken As Long, key As String) As String
    Dim WC3 As New WAR3Key
    Dim Ret As New HashBuffer
    Call Ret.AddDWORD(Len(key))
    Call Ret.AddDWORD(WC3.getProduct)
    Call Ret.AddDWORD(WC3.getVal1)
    Call Ret.AddDWORD(0)
    Dim HashedKey(0 To 4) As Long: Let HashedKey = WC3.Hash(clientToken, serverToken)
    Dim I As Byte: For I = 0 To 4 Step 1
        Call Ret.AddDWORD(HashedKey(I))
    Next I
    Let HashWAR3Key = Ret.Ret
End Function


Now its time for the fun stuff!

EDIT -
I've lost interest, due to hunger. That should be a nice start. -sigh-
http://www.quikness.com/fool/JBLS/JBLS.zip
« Last Edit: August 31, 2005, 10:03:04 am by Dishfoot »
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
Re: [BNET/RB] How to Hash
« Reply #3 on: August 31, 2005, 05:56:25 pm »
My Java skills (as iago can tell you) are those of a peanut.

Thanks for porting that stuff! Its really useful, however, I still need the SCKey class, the HashBuffer class, D2Key class, and WC3 class... Anybody who can port that to VB/RB/PHP, please do! If not, can somebody tell me exactly where they would be in the Java project, it would be almost equally helpful...

I know I am a complete and total newb, and I have almost no idea what I am talking about, so thanks in advance for tolerating my ignorance! ;)
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00

Offline Eric

  • Full Member
  • ***
  • Posts: 304
  • I'm new here!
    • View Profile
Re: [BNET/RB] How to Hash
« Reply #4 on: August 31, 2005, 06:01:52 pm »
How well can you read Visual Basic?  I can't paste all of the code here, nor am I willing to explain it all here, but if you were to privately contact me, I'd be glad to go over virtually everything with you.

[code]' Copyright (C) 2005 Eric Evans (RVictim87@GMail.com)

Option Explicit

Private m_War2KeyTable(255)       As Byte
Private m_War3KeyTable(255)       As Byte
Private m_War3TranslateTable(479) As Byte

Private blnWar2KeyTable           As Boolean
Private blnWar3KeyTable           As Boolean
Private blnWar3TranslateTable     As Boolean

Private Sub InitWar2KeyTable()
    m_War2KeyTable(0) = &HFF
    m_War2KeyTable(1) = &HFF
    m_War2KeyTable(2) = &HFF
    m_War2KeyTable(3) = &HFF
    m_War2KeyTable(4) = &HFF
    m_War2KeyTable(5) = &HFF
    m_War2KeyTable(6) = &HFF
    m_War2KeyTable(7) = &HFF
    m_War2KeyTable(8) = &HFF
    m_War2KeyTable(9) = &HFF
    m_War2KeyTable(10) = &HFF
    m_War2KeyTable(11) = &HFF
    m_War2KeyTable(12) = &HFF
    m_War2KeyTable(13) = &HFF
    m_War2KeyTable(14) = &HFF
    m_War2KeyTable(15) = &HFF
    m_War2KeyTable(16) = &HFF
    m_War2KeyTable(17) = &HFF
    m_War2KeyTable(18) = &HFF
    m_War2KeyTable(19) = &HFF
    m_War2KeyTable(20) = &HFF
    m_War2KeyTable(21) = &HFF
    m_War2KeyTable(22) = &HFF
    m_War2KeyTable(23) = &HFF
    m_War2KeyTable(24) = &HFF
    m_War2KeyTable(25) = &HFF
    m_War2KeyTable(26) = &HFF
    m_War2KeyTable(27) = &HFF
    m_War2KeyTable(28) = &HFF
    m_War2KeyTable(29) = &HFF
    m_War2KeyTable(30) = &HFF
    m_War2KeyTable(31) = &HFF
    m_War2KeyTable(32) = &HFF
    m_War2KeyTable(33) = &HFF
    m_War2KeyTable(34) = &HFF
    m_War2KeyTable(35) = &HFF
    m_War2KeyTable(36) = &HFF
    m_War2KeyTable(37) = &HFF
    m_War2KeyTable(38) = &HFF
    m_War2KeyTable(39) = &HFF
    m_War2KeyTable(40) = &HFF
    m_War2KeyTable(41) = &HFF
    m_War2KeyTable(42) = &HFF
    m_War2KeyTable(43) = &HFF
    m_War2KeyTable(44) = &HFF
    m_War2KeyTable(45) = &HFF
    m_War2KeyTable(46) = &HFF
    m_War2KeyTable(47) = &HFF
    m_War2KeyTable(48) = &HFF
    m_War2KeyTable(49) = &HFF
    m_War2KeyTable(50) = &H0
    m_War2KeyTable(51) = &HFF
    m_War2KeyTable(52) = &H1
    m_War2KeyTable(53) = &HFF
    m_War2KeyTable(54) = &H2
    m_War2KeyTable(55) = &H3
    m_War2KeyTable(56) = &H4
    m_War2KeyTable(57) = &H5
    m_War2KeyTable(58) = &HFF
    m_War2KeyTable(59) = &HFF
    m_War2KeyTable(60) = &HFF
    m_War2KeyTable(61) = &HFF
    m_War2KeyTable(62) = &HFF
    m_War2KeyTable(63) = &HFF
    m_War2KeyTable(64) = &HFF
    m_War2KeyTable(65) = &HFF
    m_War2KeyTable(66) = &H6
    m_War2KeyTable(67) = &H7
    m_War2KeyTable(68) = &H8
    m_War2KeyTable(69) = &H9
    m_War2KeyTable(70) = &HA
    m_War2KeyTable(71) = &HB
    m_War2KeyTable(72) = &HC
    m_War2KeyTable(73) = &HFF
    m_War2KeyTable(74) = &HD
    m_War2KeyTable(75) = &HE
    m_War2KeyTable(76) = &HFF
    m_War2KeyTable(77) = &HF
    m_War2KeyTable(78) = &H10
    m_War2KeyTable(79) = &HFF
    m_War2KeyTable(80) = &H11
    m_War2KeyTable(81) = &HFF
    m_War2KeyTable(82) = &H12
    m_War2KeyTable(83) = &HFF
    m_War2KeyTable(84) = &H13
    m_War2KeyTable(85) = &HFF
    m_War2KeyTable(86) = &H14
    m_War2KeyTable(87) = &H15
    m_War2KeyTable(88) = &H16
    m_War2KeyTable(89) = &HFF
    m_War2KeyTable(90) = &H17
    m_War2KeyTable(91) = &HFF
    m_War2KeyTable(92) = &HFF
    m_War2KeyTable(93) = &HFF
    m_War2KeyTable(94) = &HFF
    m_War2KeyTable(95) = &HFF
    m_War2KeyTable(96) = &HFF
    m_War2KeyTable(97) = &HFF
    m_War2KeyTable(98) = &H6
    m_War2KeyTable(99) = &H7
    m_War2KeyTable(100) = &H8
    m_War2KeyTable(101) = &H9
    m_War2KeyTable(102) = &HA
    m_War2KeyTable(103) = &HB
    m_War2KeyTable(104) = &HC
    m_War2KeyTable(105) = &HFF
    m_War2KeyTable(106) = &HD
    m_War2KeyTable(107) = &HE
    m_War2KeyTable(108) = &HFF
    m_War2KeyTable(109) = &HF
    m_War2KeyTable(110) = &H10
    m_War2KeyTable(111) = &HFF
    m_War2KeyTable(112) = &H11
    m_War2KeyTable(113) = &HFF
    m_War2KeyTable(114) = &H12
    m_War2KeyTable(115) = &HFF
    m_War2KeyTable(116) = &H13
    m_War2KeyTable(117) = &HFF
    m_War2KeyTable(118) = &H14
    m_War2KeyTable(119) = &H15
    m_War2KeyTable(120) = &H16
    m_War2KeyTable(121) = &HFF
    m_War2KeyTable(122) = &H17
    m_War2KeyTable(123) = &HFF
    m_War2KeyTable(124) = &HFF
    m_War2KeyTable(125) = &HFF
    m_War2KeyTable(126) = &HFF
    m_War2KeyTable(127) = &HFF
    m_War2KeyTable(128) = &HFF
    m_War2KeyTable(129) = &HFF
    m_War2KeyTable(130) = &HFF
    m_War2KeyTable(131) = &HFF
    m_War2KeyTable(132) = &HFF
    m_War2KeyTable(133) = &HFF
    m_War2KeyTable(134) = &HFF
    m_War2KeyTable(135) = &HFF
    m_War2KeyTable(136) = &HFF
    m_War2KeyTable(137) = &HFF
    m_War2KeyTable(138) = &HFF
    m_War2KeyTable(139) = &HFF
    m_War2KeyTable(140) = &HFF
    m_War2KeyTable(141) = &HFF
    m_War2KeyTable(142) = &HFF
    m_War2KeyTable(143) = &HFF
    m_War2KeyTable(144) = &HFF
    m_War2KeyTable(145) = &HFF
    m_War2KeyTable(146) = &HFF
    m_War2KeyTable(147) = &HFF
    m_War2KeyTable(148) = &HFF
    m_War2KeyTable(149) = &HFF
    m_War2KeyTable(150) = &HFF
    m_War2KeyTable(151) = &HFF
    m_War2KeyTable(152) = &HFF
    m_War2KeyTable(153) = &HFF
    m_War2KeyTable(154) = &HFF
    m_War2KeyTable(155) = &HFF
    m_War2KeyTable(156) = &HFF
    m_War2KeyTable(157) = &HFF
    m_War2KeyTable(158) = &HFF
    m_War2KeyTable(159) = &HFF
    m_War2KeyTable(160) = &HFF
    m_War2KeyTable(161) = &HFF
    m_War2KeyTable(162) = &HFF
    m_War2KeyTable(163) = &HFF
    m_War2KeyTable(164) = &HFF
    m_War2KeyTable(165) = &HFF
    m_War2KeyTable(166) = &HFF
    m_War2KeyTable(167) = &HFF
    m_War2KeyTable(168) = &HFF
    m_War2KeyTable(169) = &HFF
    m_War2KeyTable(170) = &HFF
    m_War2KeyTable(171) = &HFF
    m_War2KeyTable(172) = &HFF
    m_War2KeyTable(173) = &HFF
    m_War2KeyTable(174) = &HFF
    m_War2KeyTable(175) = &HFF
    m_War2KeyTable(176) = &HFF
    m_War2KeyTable(177) = &HFF
    m_War2KeyTable(178) = &HFF
    m_War2KeyTable(179) = &HFF
    m_War2KeyTable(180) = &HFF
    m_War2KeyTable(181) = &HFF
    m_War2KeyTable(182) = &HFF
    m_War2KeyTable(183) = &HFF
    m_War2KeyTable(184) = &HFF
    m_War2KeyTable(185) = &HFF
    m_War2KeyTable(186) = &HFF
    m_War2KeyTable(187) = &HFF
    m_War2KeyTable(188) = &HFF
    m_War2KeyTable(189) = &HFF
    m_War2KeyTable(190) = &HFF
    m_War2KeyTable(191) = &HFF
    m_War2KeyTable(192) = &HFF
    m_War2KeyTable(193) = &HFF
    m_War2KeyTable(194) = &HFF
    m_War2KeyTable(195) = &HFF
    m_War2KeyTable(196) = &HFF
    m_War2KeyTable(197) = &HFF
    m_War2KeyTable(198) = &HFF
    m_War2KeyTable(199) = &HFF
    m_War2KeyTable(200) = &HFF
    m_War2KeyTable(201) = &HFF
    m_War2KeyTable(202) = &HFF
    m_War2KeyTable(203) = &HFF
    m_War2KeyTable(204) = &HFF
    m_War2KeyTable(205) = &HFF
    m_War2KeyTable(206) = &HFF
    m_War2KeyTable(207) = &HFF
    m_War2KeyTable(208) = &HFF
    m_War2KeyTable(209) = &HFF
    m_War2KeyTable(210) = &HFF
    m_War2KeyTable(211) = &HFF
    m_War2KeyTable(212) = &HFF
    m_War2KeyTable(213) = &HFF
    m_War2KeyTable(214) = &HFF
    m_War2KeyTable(215) = &HFF
    m_War2KeyTable(216) = &HFF
    m_War2KeyTable(217) = &HFF
    m_War2KeyTable(218) = &HFF
    m_War2KeyTable(219) = &HFF
    m_War2KeyTable(220) = &HFF
    m_War2KeyTable(221) = &HFF
    m_War2KeyTable(222) = &HFF
    m_War2KeyTable(223) = &HFF
    m_War2KeyTable(224) = &HFF
    m_War2KeyTable(225) = &HFF
    m_War2KeyTable(226) = &HFF
    m_War2KeyTable(227) = &HFF
    m_War2KeyTable(228) = &HFF
    m_War2KeyTable(229) = &HFF
    m_War2KeyTable(230) = &HFF
    m_War2KeyTable(231) = &HFF
    m_War2KeyTable(232) = &HFF
    m_War2KeyTable(233) = &HFF
    m_War2KeyTable(234) = &HFF
    m_War2KeyTable(235) = &HFF
    m_War2KeyTable(236) = &HFF
    m_War2KeyTable(237) = &HFF
    m_War2KeyTable(238) = &HFF
    m_War2KeyTable(239) = &HFF
    m_War2KeyTable(240) = &HFF
    m_War2KeyTable(241) = &HFF
    m_War2KeyTable(242) = &HFF
    m_War2KeyTable(243) = &HFF
    m_War2KeyTable(244) = &HFF
    m_War2KeyTable(245) = &HFF
    m_War2KeyTable(246) = &HFF
    m_War2KeyTable(247) = &HFF
    m_War2KeyTable(248) = &HFF
    m_War2KeyTable(249) = &HFF
    m_War2KeyTable(250) = &HFF
    m_War2KeyTable(251) = &HFF
    m_War2KeyTable(252) = &HFF
    m_War2KeyTable(253) = &HFF
    m_War2KeyTable(254) = &HFF
    m_War2KeyTable(255) = &HFF
   
    blnWar2KeyTable = True
End Sub

Private Sub InitWar3KeyTable()
    m_War3KeyTable(0) = &HFF
    m_War3KeyTable(1) = &HFF
    m_War3KeyTable(2) = &HFF
    m_War3KeyTable(3) = &HFF
    m_War3KeyTable(4) = &HFF
    m_War3KeyTable(5) = &HFF
    m_War3KeyTable(6) = &HFF
    m_War3KeyTable(7) = &HFF
    m_War3KeyTable(8) = &HFF
    m_War3KeyTable(9) = &HFF
    m_War3KeyTable(10) = &HFF
    m_War3KeyTable(11) = &HFF
    m_War3KeyTable(12) = &HFF
    m_War3KeyTable(13) = &HFF
    m_War3KeyTable(14) = &HFF
    m_War3KeyTable(15) = &HFF
    m_War3KeyTable(16) = &HFF
    m_War3KeyTable(17) = &HFF
    m_War3KeyTable(18) = &HFF
    m_War3KeyTable(19) = &HFF
    m_War3KeyTable(20) = &HFF
    m_War3KeyTable(21) = &HFF
    m_War3KeyTable(22) = &HFF
    m_War3KeyTable(23) = &HFF
    m_War3KeyTable(24) = &HFF
    m_War3KeyTable(25) = &HFF
    m_War3KeyTable(26) = &HFF
    m_War3KeyTable(27) = &HFF
    m_War3KeyTable(28) = &HFF
    m_War3KeyTable(29) = &HFF
    m_War3KeyTable(30) = &HFF
    m_War3KeyTable(31) = &HFF
    m_War3KeyTable(32) = &HFF
    m_War3KeyTable(33) = &HFF
    m_War3KeyTable(34) = &HFF
    m_War3KeyTable(35) = &HFF
    m_War3KeyTable(36) = &HFF
    m_War3KeyTable(37) = &HFF
    m_War3KeyTable(38) = &HFF
    m_War3KeyTable(39) = &HFF
    m_War3KeyTable(40) = &HFF
    m_War3KeyTable(41) = &HFF
    m_War3KeyTable(42) = &HFF
    m_War3KeyTable(43) = &HFF
    m_War3KeyTable(44) = &HFF
    m_War3KeyTable(45) = &HFF
    m_War3KeyTable(46) = &HFF
    m_War3KeyTable(47) = &HFF
    m_War3KeyTable(48) = &HFF
    m_War3KeyTable(49) = &HFF
    m_War3KeyTable(50) = &H0
    m_War3KeyTable(51) = &HFF
    m_War3KeyTable(52) = &H1
    m_War3KeyTable(53) = &HFF
    m_War3KeyTable(54) = &H2
    m_War3KeyTable(55) = &H3
    m_War3KeyTable(56) = &H4
    m_War3KeyTable(57) = &H5
    m_War3KeyTable(58) = &HFF
    m_War3KeyTable(59) = &HFF
    m_War3KeyTable(60) = &HFF
    m_War3KeyTable(61) = &HFF
    m_War3KeyTable(62) = &HFF
    m_War3KeyTable(63) = &HFF
    m_War3KeyTable(64) = &HFF
    m_War3KeyTable(65) = &HFF
    m_War3KeyTable(66) = &H6
    m_War3KeyTable(67) = &H7
    m_War3KeyTable(68) = &H8
    m_War3KeyTable(69) = &H9
    m_War3KeyTable(70) = &HA
    m_War3KeyTable(71) = &HB
    m_War3KeyTable(72) = &HC
    m_War3KeyTable(73) = &HFF
    m_War3KeyTable(74) = &HD
    m_War3KeyTable(75) = &HE
    m_War3KeyTable(76) = &HFF
    m_War3KeyTable(77) = &HF
    m_War3KeyTable(78) = &H10
    m_War3KeyTable(79) = &HFF
    m_War3KeyTable(80) = &H11
    m_War3KeyTable(81) = &HFF
    m_War3KeyTable(82) = &H12
    m_War3KeyTable(83) = &HFF
    m_War3KeyTable(84) = &H13
    m_War3KeyTable(85) = &HFF
    m_War3KeyTable(86) = &H14
    m_War3KeyTable(87) = &H15
    m_War3KeyTable(88) = &H16
    m_War3KeyTable(89) = &H17
    m_War3KeyTable(90) = &H18
    m_War3KeyTable(91) = &HFF
    m_War3KeyTable(92) = &HFF
    m_War3KeyTable(93) = &HFF
    m_War3KeyTable(94) = &HFF
    m_War3KeyTable(95) = &HFF
    m_War3KeyTable(96) = &HFF
    m_War3KeyTable(97) = &HFF
    m_War3KeyTable(98) = &H6
    m_War3KeyTable(99) = &H7
    m_War3KeyTable(100) = &H8
    m_War3KeyTable(101) = &H9
    m_War3KeyTable(102) = &HA
    m_War3KeyTable(103) = &HB
    m_War3KeyTable(104) = &HC
    m_War3KeyTable(105) = &HFF
    m_War3KeyTable(106) = &HD
    m_War3KeyTable(107) = &HE
    m_War3KeyTable(108) = &HFF
    m_War3KeyTable(109) = &HF
    m_War3KeyTable(110) = &H10
    m_War3KeyTable(111) = &HFF
    m_War3KeyTable(112) = &H11
    m_War3KeyTable(113) = &HFF
    m_War3KeyTable(114) = &H12
    m_War3KeyTable(115) = &HFF
    m_War3KeyTable(116) = &H13
    m_War3KeyTable(117) = &HFF
    m_War3KeyTable(118) = &H14
    m_War3KeyTable(119) = &H15
    m_War3KeyTable(120) = &H16
    m_War3KeyTable(121) = &H17
    m_War3KeyTable(122) = &H18
    m_War3KeyTable(123) = &HFF
    m_War3KeyTable(124) = &HFF
    m_War3KeyTable(125) = &HFF
    m_War3KeyTable(126) = &HFF
    m_War3KeyTable(127) = &HFF
    m_War3KeyTable(128) = &HFF
    m_War3KeyTable(129) = &HFF
    m_War3KeyTable(130) = &HFF
    m_War3KeyTable(131) = &HFF
    m_War3KeyTable(132) = &HFF
    m_War3KeyTable(133) = &HFF
    m_War3KeyTable(134) = &HFF
    m_War3KeyTable(135) = &HFF
    m_War3KeyTable(136) = &HFF
    m_War3KeyTable(137) = &HFF
    m_War3KeyTable(138) = &HFF
    m_War3KeyTable(139) = &HFF
    m_War3KeyTable(140) = &HFF
    m_War3KeyTable(141) = &HFF
    m_War3KeyTable(142) = &HFF
    m_War3KeyTable(143) = &HFF
    m_War3KeyTable(144) = &HFF
    m_War3KeyTable(145) = &HFF
    m_War3KeyTable(146) = &HFF
    m_War3KeyTable(147) = &HFF
    m_War3KeyTable(148) = &HFF
    m_War3KeyTable(149) = &HFF
    m_War3KeyTable(150) = &HFF
    m_War3KeyTable(151) = &HFF
    m_War3KeyTable(152) = &HFF
    m_War3KeyTable(153) = &HFF
    m_War3KeyTable(154) = &HFF
    m_War3KeyTable(155) = &HFF
    m_War3KeyTable(156) = &HFF
    m_War3KeyTable(157) = &HFF
    m_War3KeyTable(158) = &HFF
    m_War3KeyTable(159) = &HFF
    m_War3KeyTable(160) = &HFF
    m_War3KeyTable(161) = &HFF
    m_War3KeyTable(162) = &HFF
    m_War3KeyTable(163) = &HFF
    m_War3KeyTable(164) = &HFF
    m_War3KeyTable(165) = &HFF
    m_War3KeyTable(166) = &HFF
    m_War3KeyTable(167) = &HFF
    m_War3KeyTable(168) = &HFF
    m_War3KeyTable(169) = &HFF
    m_War3KeyTable(170) = &HFF
    m_War3KeyTable(171) = &HFF
    m_War3KeyTable(172) = &HFF
    m_War3KeyTable(173) = &HFF
    m_War3KeyTable(174) = &HFF
    m_War3KeyTable(175) = &HFF
    m_War3KeyTable(176) = &HFF
    m_War3KeyTable(177) = &HFF
    m_War3KeyTable(178) = &HFF
    m_War3KeyTable(179) = &HFF
    m_War3KeyTable(180) = &HFF
    m_War3KeyTable(181) = &HFF
    m_War3KeyTable(182) = &HFF
    m_War3KeyTable(183) = &HFF
    m_War3KeyTable(184) = &HFF
    m_War3KeyTable(185) = &HFF
    m_War3KeyTable(186) = &HFF
    m_War3KeyTable(187) = &HFF
    m_War3KeyTable(188) = &HFF
    m_War3KeyTable(189) = &HFF
    m_War3KeyTable(190) = &HFF
    m_War3KeyTable(191) = &HFF
    m_War3KeyTable(192) = &HFF
    m_War3KeyTable(193) = &HFF
    m_War3KeyTable(194) = &HFF
    m_War3KeyTable(195) = &HFF
    m_War3KeyTable(196) = &HFF
    m_War3KeyTable(197) = &HFF
    m_War3KeyTable(198) = &HFF
    m_War3KeyTable(199) = &HFF
    m_War3KeyTable(200) = &HFF
    m_War3KeyTable(201) = &HFF
    m_War3KeyTable(202) = &HFF
    m_War3KeyTable(203) = &HFF
    m_War3KeyTable(204) = &HFF
    m_War3KeyTable(205) = &HFF
    m_War3KeyTable(206) = &HFF
    m_War3KeyTable(207) = &HFF
    m_War3KeyTable(208) = &HFF
    m_War3KeyTable(209) = &HFF
    m_War3KeyTable(210) = &HFF
    m_War3KeyTable(211) = &HFF
    m_War3KeyTable(212) = &HFF
    m_War3KeyTable(213) = &HFF
    m_War3KeyTable(214) = &HFF
    m_War3KeyTable(215) = &HFF
    m_War3KeyTable(216) = &HFF
    m_War3KeyTable(217) = &HFF
    m_War3KeyTable(218) = &HFF
    m_War3KeyTable(219) = &HFF
    m_War3KeyTable(220) = &HFF
    m_War3KeyTable(221) = &HFF
    m_War3KeyTable(222) = &HFF
    m_War3KeyTable(223) = &HFF
    m_War3KeyTable(224) = &HFF
    m_War3KeyTable(225) = &HFF
    m_War3KeyTable(226) = &HFF
    m_War3KeyTable(227) = &HFF
    m_War3KeyTable(228) = &HFF
    m_War3KeyTable(229) = &HFF
    m_War3KeyTable(230) = &HFF
    m_War3KeyTable(231) = &HFF
    m_War3KeyTable(232) = &HFF
    m_War3KeyTable(233) = &HFF
    m_War3KeyTable(234) = &HFF
    m_War3KeyTable(235) = &HFF
    m_War3KeyTable(236) = &HFF
    m_War3KeyTable(237) = &HFF
    m_War3KeyTable(238) = &HFF
    m_War3KeyTable(239) = &HFF
    m_War3KeyTable(240) = &HFF
    m_War3KeyTable(241) = &HFF
    m_War3KeyTable(242) = &HFF
    m_War3KeyTable(243) = &HFF
    m_War3KeyTable(244) = &HFF
    m_War3KeyTable(245) = &HFF
    m_War3KeyTable(246) = &HFF
    m_War3KeyTable(247) = &HFF
    m_War3KeyTable(248) = &HFF
    m_War3KeyTable(249) = &HFF
    m_War3KeyTable(250) = &HFF
    m_War3KeyTable(251) = &HFF
    m_War3KeyTable(252) = &H20
    m_War3KeyTable(253) = &H39
    m_War3KeyTable(254) = &H43
    m_War3KeyTable(255) = &H0
   
    blnWar3KeyTable = True
End Sub

Private Sub InitWar3TranslateTable()
    m_War3TranslateTable(0) = &H9
    m_War3TranslateTable(1) = &H4
    m_War3TranslateTable(2) = &H7
    m_War3TranslateTable(3) = &HF
    m_War3TranslateTable(4) = &HD
    m_War3TranslateTable(5) = &HA
    m_War3TranslateTable(6) = &H3
    m_War3TranslateTable(7) = &HB
    m_War3TranslateTable(8) = &H1
    m_War3TranslateTable(9) = &H2
    m_War3TranslateTable(10) = &HC
    m_War3TranslateTable(11) = &H8
    m_War3TranslateTable(12) = &H6
    m_War3TranslateTable(13) = &HE
    m_War3TranslateTable(14) = &H5
    m_War3TranslateTable(15) = &H0
    m_War3TranslateTable(16) = &H9
    m_War3TranslateTable(17) = &HB
    m_War3TranslateTable(18) = &H5
    m_War3TranslateTable(19) = &H4
    m_War3TranslateTable(20) = &H8
    m_War3TranslateTable(21) = &HF
    m_War3TranslateTable(22) = &H1
    m_War3TranslateTable(23) = &HE
    m_War3TranslateTable(24) = &H7
    m_War3TranslateTable(25) = &H0
    m_War3TranslateTable(26) = &H3
    m_War3TranslateTable(27) = &H2
    m_War3TranslateTable(28) = &HA
    m_War3TranslateTable(29) = &H6
    m_War3TranslateTable(30) = &HD
    m_War3TranslateTable(31) = &HC
    m_War3TranslateTable(32) = &HC
    m_War3TranslateTable(33) = &HE
    m_War3TranslateTable(34) = &H1
    m_War3TranslateTable(35) = &H4
    m_War3TranslateTable(36) = &H9
    m_War3TranslateTable(37) = &HF
    m_War3TranslateTable(38) = &HA
    m_War3TranslateTable(39) = &HB
    m_War3TranslateTable(40) = &HD
    m_War3TranslateTable(41) = &H6
    m_War3TranslateTable(42) = &H0
    m_War3TranslateTable(43) = &H8
    m_War3TranslateTable(44) = &H7
    m_War3TranslateTable(45) = &H2
    m_War3TranslateTable(46) = &H5
    m_War3TranslateTable(47) = &H3
    m_War3TranslateTable(48) = &HB
    m_War3TranslateTable(49) = &H2
    m_War3TranslateTable(50) = &H5
    m_War3TranslateTable(51) = &HE
    m_War3TranslateTable(52) = &HD
    m_War3TranslateTable(53) = &H3
    m_War3TranslateTable(54) = &H9
    m_War3TranslateTable(55) = &H0
    m_War3TranslateTable(56) = &H1
    m_War3TranslateTable(57) = &HF
    m_War3TranslateTable(58) = &H7
    m_War3TranslateTable(59) = &HC
    m_War3TranslateTable(60) = &HA
    m_War3TranslateTable(61) = &H6
    m_War3TranslateTable(62) = &H4
    m_War3TranslateTable(63) = &H8
    m_War3TranslateTable(64) = &H6
    m_War3TranslateTable(65) = &H2
    m_War3TranslateTable(66) = &H4
    m_War3TranslateTable(67) = &H5
    m_War3TranslateTable(68) = &HB
    m_War3TranslateTable(69) = &H8
    m_War3TranslateTable(70) = &HC
    m_War3TranslateTable(71) = &HE
    m_War3TranslateTable(72) = &HD
    m_War3TranslateTable(73) = &HF
    m_War3TranslateTable(74) = &H7
    m_War3TranslateTable(75) = &H1
    m_War3TranslateTable(76) = &HA
    m_War3TranslateTable(77) = &H0
    m_War3TranslateTable(78) = &H3
    m_War3TranslateTable(79) = &H9
    m_War3TranslateTable(80) = &H5
    m_War3TranslateTable(81) = &H4
    m_War3TranslateTable(82) = &HE
    m_War3TranslateTable(83) = &HC
    m_War3TranslateTable(84) = &H7
    m_War3TranslateTable(85) = &H6
    m_War3TranslateTable(86) = &HD
    m_War3TranslateTable(87) = &HA
    m_War3TranslateTable(88) = &HF
    m_War3TranslateTable(89) = &H2
    m_War3TranslateTable(90) = &H9
    m_War3TranslateTable(91) = &H1
    m_War3TranslateTable(92) = &H0
    m_War3TranslateTable(93) = &HB
    m_War3TranslateTable(94) = &H8
    m_War3TranslateTable(95) = &H3
    m_War3TranslateTable(96) = &HC
    m_War3TranslateTable(97) = &H7
    m_War3TranslateTable(98) = &H8
    m_War3TranslateTable(99) = &HF
    m_War3TranslateTable(100) = &HB
    m_War3TranslateTable(101) = &H0
    m_War3TranslateTable(102) = &H5
    m_War3TranslateTable(103) = &H9
    m_War3TranslateTable(104) = &HD
    m_War3TranslateTable(105) = &HA
    m_War3TranslateTable(106) = &H6
    m_War3TranslateTable(107) = &HE
    m_War3TranslateTable(108) = &H2
    m_War3TranslateTable(109) = &H4
    m_War3TranslateTable(110) = &H3
    m_War3TranslateTable(111) = &H1
    m_War3TranslateTable(112) = &H3
    m_War3TranslateTable(113) = &HA
    m_War3TranslateTable(114) = &HE
    m_War3TranslateTable(115) = &H8
    m_War3TranslateTable(116) = &H1
    m_War3TranslateTable(117) = &HB
    m_War3TranslateTable(118) = &H5
    m_War3TranslateTable(119) = &H4
    m_War3TranslateTable(120) = &H2
    m_War3TranslateTable(121) = &HF
    m_War3TranslateTable(122) = &HD
    m_War3TranslateTable(123) = &HC
    m_War3TranslateTable(124) = &H6
    m_War3TranslateTable(125) = &H7
    m_War3TranslateTable(126) = &H9
    m_War3TranslateTable(127) = &H0
    m_War3TranslateTable(128) = &HC
    m_War3TranslateTable(129) = &HD
    m_War3TranslateTable(130) = &H1
    m_War3TranslateTable(131) = &HF
    m_War3TranslateTable(132) = &H8
    m_War3TranslateTable(133) = &HE
    m_War3TranslateTable(134) = &H5
    m_War3TranslateTable(135) = &HB
    m_War3TranslateTable(136) = &H3
    m_War3TranslateTable(137) = &HA
    m_War3TranslateTable(138) = &H9
    m_War3TranslateTable(139) = &H0
    m_War3TranslateTable(140) = &H7
    m_War3TranslateTable(141) = &H2
    m_War3TranslateTable(142) = &H4
    m_War3TranslateTable(143) = &H6
    m_War3TranslateTable(144) = &HD
    m_War3TranslateTable(145) = &HA
    m_War3TranslateTable(146) = &H7
    m_War3TranslateTable(147) = &HE
    m_War3TranslateTable(148) = &H1
    m_War3TranslateTable(149) = &H6
    m_War3TranslateTable(150) = &HB
    m_War3TranslateTable(151) = &H8
    m_War3TranslateTable(152) = &HF
    m_War3TranslateTable(153) = &HC
    m_War3TranslateTable(154) = &H5
    m_War3TranslateTable(155) = &H2
    m_War3TranslateTable(156) = &H3
    m_War3TranslateTable(157) = &H0
    m_War3TranslateTable(158) = &H4
    m_War3TranslateTable(159) = &H9
    m_War3TranslateTable(160) = &H3
    m_War3TranslateTable(161) = &HE
    m_War3TranslateTable(162) = &H7
    m_War3TranslateTable(163) = &H5
    m_War3TranslateTable(164) = &HB
    m_War3TranslateTable(165) = &HF
    m_War3TranslateTable(166) = &H8
    m_War3TranslateTable(167) = &HC
    m_War3TranslateTable(168) = &H1
    m_War3TranslateTable(169) = &HA
    m_War3TranslateTable(170) = &H4
    m_War3TranslateTable(171) = &HD
    m_War3TranslateTable(172) = &H0
    m_War3TranslateTable(173) = &H6
    m_War3TranslateTable(174) = &H9
    m_War3TranslateTable(175) = &H2
    m_War3TranslateTable(176) = &HB
    m_War3TranslateTable(177) = &H6
    m_War3TranslateTable(178) = &H9
    m_War3TranslateTable(179) = &H4
    m_War3TranslateTable(180) = &H1
    m_War3TranslateTable(181) = &H8
    m_War3TranslateTable(182) = &HA
    m_War3TranslateTable(183) = &HD
    m_War3TranslateTable(184) = &H7
    m_War3TranslateTable(185) = &HE
    m_War3TranslateTable(186) = &H0
    m_War3TranslateTable(187) = &HC
    m_War3TranslateTable(188) = &HF
    m_War3TranslateTable(189) = &H2
    m_War3TranslateTable(190) = &H3
    m_War3TranslateTable(191) = &H5
    m_War3TranslateTable(192) = &HC
    m_War3TranslateTable(193) = &H7
    m_War3TranslateTable(194) = &H8
    m_War3TranslateTable(195) = &HD
    m_War3TranslateTable(196) = &H3
    m_War3TranslateTable(197) = &HB
    m_War3TranslateTable(198) = &H0
    m_War3TranslateTable(199) = &HE
    m_War3TranslateTable(200) = &H6
    m_War3TranslateTable(201) = &HF
    m_War3TranslateTable(202) = &H9
    m_War3TranslateTable(203) = &H4
    m_War3TranslateTable(204) = &HA
    m_War3TranslateTable(205) = &H1
    m_War3TranslateTable(206) = &H5
    m_War3TranslateTable(207) = &H2
    m_War3TranslateTable(208) = &HC
    m_War3TranslateTable(209) = &H6
    m_War3TranslateTable(210) = &HD
    m_War3TranslateTable(211) = &H9
    m_War3TranslateTable(212) = &HB
    m_War3TranslateTable(213) = &H0
    m_War3TranslateTable(214) = &H1
    m_War3TranslateTable(215) = &H2
    m_War3TranslateTable(216) = &HF
    m_War3TranslateTable(217) = &H7
    m_War3TranslateTable(218) = &H3
    m_War3TranslateTable(219) = &H4
    m_War3TranslateTable(220) = &HA
    m_War3TranslateTable(221) = &HE
    m_War3TranslateTable(222) = &H8
    m_War3TranslateTable(223) = &H5
    m_War3TranslateTable(224) = &H3
    m_War3TranslateTable(225) = &H6
    m_War3TranslateTable(226) = &H1
    m_War3TranslateTable(227) = &H5
    m_War3TranslateTable(228) = &HB
    m_War3TranslateTable(229) = &HC
    m_War3TranslateTable(230) = &H8
    m_War3TranslateTable(231) = &H0
    m_War3TranslateTable(232) = &HF
    m_War3TranslateTable(233) = &HE
    m_War3TranslateTable(234) = &H9
    m_War3TranslateTable(235) = &H4
    m_War3TranslateTable(236) = &H7
    m_War3TranslateTable(237) = &HA
    m_War3TranslateTable(238) = &HD
    m_War3TranslateTable(239) = &H2
    m_War3TranslateTable(240) = &HA
    m_War3TranslateTable(241) = &H7
    m_War3TranslateTable(242) = &HB
    m_War3TranslateTable(243) = &HF
    m_War3TranslateTable(244) = &H2
    m_War3TranslateTable(245) = &H8
    m_War3TranslateTable(246) = &H0
    m_War3TranslateTable(247) = &HD
    m_War3TranslateTable(248) = &HE
    m_War3TranslateTable(249) = &HC
    m_War3TranslateTable(250) = &H1
    m_War3TranslateTable(251) = &H6
    m_War3TranslateTable(252) = &H9
    m_War3TranslateTable(253) = &H3
    m_War3TranslateTable(254) = &H5
    m_War3TranslateTable(255) = &H4
    m_War3TranslateTable(256) = &HA
    m_War3TranslateTable(257) = &HB
    m_War3TranslateTable(258) = &HD
    m_War3TranslateTable(259) = &H4
    m_War3TranslateTable(260) = &H3
    m_War3TranslateTable(261) = &H8
    m_War3TranslateTable(262) = &H5
    m_War3TranslateTable(263) = &H9
    m_War3TranslateTable(264) = &H1
    m_War3TranslateTable(265) = &H0
    m_War3TranslateTable(266) = &HF
    m_War3TranslateTable(267) = &HC
    m_War3TranslateTable(268) = &H7
    m_War3TranslateTable(269) = &HE
    m_War3TranslateTable(270) = &H2
    m_War3TranslateTable(271) = &H6
    m_War3TranslateTable(272) = &HB
    m_War3TranslateTable(273) = &H4
    m_War3TranslateTable(274) = &HD
    m_War3TranslateTable(275) = &HF
    m_War3TranslateTable(276) = &H1
    m_War3TranslateTable(277) = &H6
    m_War3TranslateTable(278) = &H3
    m_War3TranslateTable(279) = &HE
    m_War3TranslateTable(280) = &H7
    m_War3TranslateTable(281) = &HA
    m_War3TranslateTable(282) = &HC
    m_War3TranslateTable(283) = &H8
    m_War3TranslateTable(284) = &H9
    m_War3TranslateTable(285) = &H2
    m_War3TranslateTable(286) = &H5
    m_War3TranslateTable(287) = &H0
    m_War3TranslateTable(288) = &H9
    m_War3TranslateTable(289) = &H6
    m_War3TranslateTable(290) = &H7
    m_War3TranslateTable(291) = &H0
    m_War3TranslateTable(292) = &H1
    m_War3TranslateTable(293) = &HA
    m_War3TranslateTable(294) = &HD
    m_War3TranslateTable(295) = &H2
    m_War3TranslateTable(296) = &H3
    m_War3TranslateTable(297) = &HE
    m_War3TranslateTable(298) = &HF
    m_War3TranslateTable(299) = &HC
    m_War3TranslateTable(300) = &H5
    m_War3TranslateTable(301) = &HB
    m_War3TranslateTable(302) = &H4
    m_War3TranslateTable(303) = &H8
    m_War3TranslateTable(304) = &HD
    m_War3TranslateTable(305) = &HE
    m_War3TranslateTable(306) = &H5
    m_War3TranslateTable(307) = &H6
    m_War3TranslateTable(308) = &H1
    m_War3TranslateTable(309) = &H9
    m_War3TranslateTable(310) = &H8
    m_War3TranslateTable(311) = &HC
    m_War3TranslateTable(312) = &H2
    m_War3TranslateTable(313) = &HF
    m_War3TranslateTable(314) = &H3
    m_War3TranslateTable(315) = &H7
    m_War3TranslateTable(316) = &HB
    m_War3TranslateTable(317) = &H4
    m_War3TranslateTable(318) = &H0
    m_War3TranslateTable(319) = &HA
    m_War3TranslateTable(320) = &H9
    m_War3TranslateTable(321) = &HF
    m_War3TranslateTable(322) = &H4
    m_War3TranslateTable(323) = &H0
    m_War3TranslateTable(324) = &H1
    m_War3TranslateTable(325) = &H6
    m_War3TranslateTable(326) = &HA
    m_War3TranslateTable(327) = &HE
    m_War3TranslateTable(328) = &H2
    m_War3TranslateTable(329) = &H3
    m_War3TranslateTable(330) = &H7
    m_War3TranslateTable(331) = &HD
    m_War3TranslateTable(332) = &H5
    m_War3TranslateTable(333) = &HB
    m_War3TranslateTable(334) = &H8
    m_War3TranslateTable(335) = &HC
    m_War3TranslateTable(336) = &H3
    m_War3TranslateTable(337) = &HE
    m_War3TranslateTable(338) = &H1
    m_War3TranslateTable(339) = &HA
    m_War3TranslateTable(340) = &H2
    m_War3TranslateTable(341) = &HC
    m_War3TranslateTable(342) = &H8
    m_War3TranslateTable(343) = &H4
    m_War3TranslateTable(344) = &HB
    m_War3TranslateTable(345) = &H7
    m_War3TranslateTable(346) = &HD
    m_War3TranslateTable(347) = &H0
    m_War3TranslateTable(348) = &HF
    m_War3TranslateTable(349) = &H6
    m_War3TranslateTable(350) = &H9
    m_War3TranslateTable(351) = &H5
    m_War3TranslateTable(352) = &H7
    m_War3TranslateTable(353) = &H2
    m_War3TranslateTable(354) = &HC
    m_War3TranslateTable(355) = &H6
    m_War3TranslateTable(356) = &HA
    m_War3TranslateTable(357) = &H8
    m_War3TranslateTable(358) = &HB
    m_War3TranslateTable(359) = &H0
    m_War3TranslateTable(360) = &HF
    m_War3TranslateTable(361) = &H4
    m_War3TranslateTable(362) = &H3
    m_War3TranslateTable(363) = &HE
    m_War3TranslateTable(364) = &H9
    m_War3TranslateTable(365) = &H1
    m_War3TranslateTable(366) = &HD
    m_War3TranslateTable(367) = &H5
    m_War3TranslateTable(368) = &HC
    m_War3TranslateTable(369) = &H4
    m_War3TranslateTable(370) = &H5
    m_War3TranslateTable(371) = &H9
    m_War3TranslateTable(372) = &HA
    m_War3TranslateTable(373) = &H2
    m_War3TranslateTable(374) = &H8
    m_War3TranslateTable(375) = &HD
    m_War3TranslateTable(376) = &H3
    m_War3TranslateTable(377) = &HF
    m_War3TranslateTable(378) = &H1
    m_War3TranslateTable(379) = &HE
    m_War3TranslateTable(380) = &H6
    m_War3TranslateTable(381) = &H7
    m_War3TranslateTable(382) = &HB
    m_War3TranslateTable(383) = &H0
    m_War3TranslateTable(384) = &HA
    m_War3TranslateTable(385) = &H8
    m_War3TranslateTable(386) = &HE
    m_War3TranslateTable(387) = &HD
    m_War3TranslateTable(388) = &H9
    m_War3TranslateTable(389) = &HF
    m_War3TranslateTable(390) = &H3
    m_War3TranslateTable(391) = &H0
    m_War3TranslateTable(392) = &H4
    m_War3TranslateTable(393) = &H6
    m_War3TranslateTable(394) = &H1
    m_War3TranslateTable(395) = &HC
    m_War3TranslateTable(396) = &H7
    m_War3TranslateTable(397) = &HB
    m_War3TranslateTable(398) = &H2
    m_War3TranslateTable(399) = &H5
    m_War3TranslateTable(400) = &H3
    m_War3TranslateTable(401) = &HC
    m_War3TranslateTable(402) = &H4
    m_War3TranslateTable(403) = &HA
    m_War3TranslateTable(404) = &H2
    m_War3TranslateTable(405) = &HF
    m_War3TranslateTable(406) = &HD
    m_War3TranslateTable(407) = &HE
    m_War3TranslateTable(408) = &H7
    m_War3TranslateTable(409) = &H0
    m_War3TranslateTable(410) = &H5
    m_War3TranslateTable(411) = &H8
    m_War3TranslateTable(412) = &H1
    m_War3TranslateTable(413) = &H6
    m_War3TranslateTable(414) = &HB
    m_War3TranslateTable(415) = &H9
    m_War3TranslateTable(416) = &HA
    m_War3TranslateTable(417) = &HC
    m_War3TranslateTable(418) = &H1
    m_War3TranslateTable(419) = &H0
    m_War3TranslateTable(420) = &H9
    m_War3TranslateTable(421) = &HE
    m_War3TranslateTable(422) = &HD
    m_War3TranslateTable(423) = &HB
    m_War3TranslateTable(424) = &H3
    m_War3TranslateTable(425) = &H7
    m_War3TranslateTable(426) = &HF
    m_War3TranslateTable(427) = &H8
    m_War3TranslateTable(428) = &H5
    m_War3TranslateTable(429) = &H2
    m_War3TranslateTable(430) = &H4
    m_War3TranslateTable(431) = &H6
    m_War3TranslateTable(432) = &HE
    m_War3TranslateTable(433) = &HA
    m_War3TranslateTable(434) = &H1
    m_War3TranslateTable(435) = &H8
    m_War3TranslateTable(436) = &H7
    m_War3TranslateTable(437) = &H6
    m_War3TranslateTable(438) = &H5
    m_War3TranslateTable(439) = &HC
    m_War3TranslateTable(440) = &H2
    m_War3TranslateTable(441) = &HF
    m_War3TranslateTable(442) = &H0
    m_War3TranslateTable(443) = &HD
    m_War3TranslateTable(444) = &H3
    m_War3TranslateTable(445) = &HB
    m_War3TranslateTable(446) = &H4
    m_War3TranslateTable(447) = &H9
    m_War3TranslateTable(448) = &H3
    m_War3TranslateTable(449) = &H8
    m_War3TranslateTable(450) = &HE
    m_War3TranslateTable(451) = &H0
    m_War3TranslateTable(452) = &H7
    m_War3TranslateTable(453) = &H9
    m_War3TranslateTable(454) = &HF
    m_War3TranslateTable(455) = &HC
    m_War3TranslateTable(456) = &H1
    m_War3TranslateTable(457) = &H6
    m_War3TranslateTable(458) = &HD
    m_War3TranslateTable(459) = &H2
    m_War3TranslateTable(460) = &H5
    m_War3TranslateTable(461) = &HA
    m_War3TranslateTable(462) = &HB
    m_War3TranslateTable(463) = &H4
    m_War3TranslateTable(464) = &H3
    m_War3TranslateTable(465) = &HA
    m_War3TranslateTable(466) = &HC
    m_War3TranslateTable(467) = &H4
    m_War3TranslateTable(468) = &HD
    m_War3TranslateTable(469) = &HB
    m_War3TranslateTable(470) = &H9
    m_War3TranslateTable(471) = &HE
    m_War3TranslateTable(472) = &HF
    m_War3TranslateTable(473) = &H6
    m_War3TranslateTable(474) = &H1
    m_War3TranslateTable(475) = &H7
    m_War3TranslateTable(476) = &H2
    m_War3TranslateTable(477) = &H0
    m_War3TranslateTable(478) = &H5
    m_War3TranslateTable(479) = &H8
   
    blnWar3TranslateTable = True
End Sub

' WARNING: Before attempting to decode a CD-Key, make sure that the CD-Key contains no dashes or spaces
Public Function RunCDKeyDecode(ByVal strKey As String, ByRef lngGmeID As Long, ByRef lngPubVal As Long, ByRef lngPrivVal As Long) As Long
    strKey = UCase$(strKey)
   
    Select Case Len(strKey)
        Case 13:   RunCDKeyDecode = DecodeStarCraftKey(strKey, lngGmeID, lngPubVal, lngPrivVal, True)
        Case 16:   RunCDKeyDecode = DecodeWarCraft2Key(strKey, lngGmeID, lngPubVal, lngPrivVal, True)
        Case 26:   RunCDKeyDecode = DecodeWarCraft3Key(strKey, lngGmeID, lngPubVal, lngPrivVal, True)
        Case Else: Exit Function
    End Select
End Function

Private Function DecodeStarCraftKey(ByVal strKey As String, ByRef lngGmeID As Long, ByRef lngPubVal As Long, ByRef lngPrivVal As Long, ByVal blnVerifyKey As Boolean) As Long
    Dim arrKey(0 To 12) As String
    Dim i               As Integer
   
    Dim eax             As Long
    Dim ebx             As Long
    Dim ecx             As Long
    Dim edx             As Long
    Dim edi             As Long
    Dim esi             As Long
    Dim al              As Byte
    Dim bl              As Byte
    Dim cl              As Byte
    Dim dl              As Byte
   
    ' Check CD-Key length
    If (Len(strKey) <> 13) Then
        Exit Function
    End If

    ' Store CD-Key in array
    For i = 0 To 12
        arrKey(i) = Mid$(strKey, (i + 1), 1)
    Next i

    ' CD-Key verification
    If (blnVerifyKey = True) Then
        eax = 3
       
        For ecx = 0 To 11 Step 1
            edx = arrKey(ecx)
           
            If ((Asc(edx) < Asc("0")) Or _
                (Asc(edx) > Asc("9"))) Then
               
                Exit Function
            End If
           
            edx = (Asc(edx) - Asc("0"))
           
            ' esi = (eax + eax)
            ' Optimization:
            esi = modGlobals.LShift(eax, 1)
           
            edx = (edx Xor esi)
            eax = (eax + edx)
        Next ecx

        eax = ((eax Mod &HA) + Asc("0"))
       
        If (eax <> Asc(arrKey(12))) Then
            Exit Function
        End If
    End If
   
    ' CD-Key shuffling

    esi = 11
    ecx = &HC2
   
    Do:
        eax = ecx
   
        edx = (eax Mod &HC)
   
        bl = arrKey(esi)
        dl = arrKey(edx)
   
        arrKey(esi) = dl
        arrKey(edx) = bl

        ' Decrease loop counters
       
        ecx = (ecx - &H11)
        esi = (esi - 1)
    Loop Until (ecx < &H7)
   
    edx = &H13AC9741
    ecx = 11
   
    Do:
        al = arrKey(ecx)
   
        If (Asc(al) > Asc("7")) Then
            dl = ((ecx And 1) Xor al)
   
            arrKey(ecx) = dl
        ElseIf (Asc(al) < Asc("A")) Then
            dl = (edx And &HFF)
            dl = ((dl And 7) Xor al)
   
            edx = modGlobals.RShift(edx, 3)
   
            arrKey(ecx) = dl
        End If
   
        ecx = (ecx - 1)
    Loop Until (ecx < 0)

    strKey = Join(arrKey(), vbNullString)
   
    lngGmeID = Val(Left$(strKey, 2))
    lngPubVal = Val(Mid$(strKey, 3, 7))
    lngPrivVal = Val(Mid$(strKey, 10, 3))
   
    DecodeStarCraftKey = 1
   
    Erase arrKey()
End Function

Private Function DecodeWarCraft2Key(ByVal strKey As String, ByRef lngGmeID As Long, ByRef lngPubVal As Long, ByRef lngPrivVal As Long, ByVal blnVerifyKey As Boolean) As Long
    Dim arrKey(0 To 15) As String
    Dim lngChecksum     As Long
    Dim i               As Integer
   
    Dim eax             As Long
    Dim ebx             As Long
    Dim ecx             As Long
    Dim edx             As Long
    Dim edi             As Long
    Dim esi             As Long
    Dim al              As Byte
    Dim bl              As Byte
    Dim cl              As Byte
    Dim dl              As Byte
   
    ' Initialize key table
   
    If (blnWar2KeyTable = False) Then
        Call InitWar2KeyTable
    End If
   
    ' Check CD-Key length
   
    If (Len(strKey) <> 16) Then
        Exit Function
    End If
   
    ' Store CD-Key in array
   
    For i = 0 To 15
        arrKey(i) = Mid$(strKey, (i + 1), 1)
    Next i
   
    ebx = 1

    Do:
        eax = m_War2KeyTable(Asc(arrKey(ecx)))
       
        ' esi = (eax + (eax * 2))
        ' Optimization:
        esi = (eax + modGlobals.LShift(eax, 1))
       
        eax = m_War2KeyTable(Asc(arrKey(ecx + 1)))
       
        ' esi = (eax + (esi * 8))
        ' Optimization:
        esi = (eax + modGlobals.LShift(esi, 3))
       
        If (esi >= 256) Then
            esi = (esi - 256)
            lngChecksum = (lngChecksum Or ebx)
        End If
       
        eax = modGlobals.RShift(esi, 4)
       
        arrKey(ecx) = GetHexVal(eax)
        arrKey(ecx + 1) = GetHexVal(esi)
       
        ebx = modGlobals.LShift(ebx, 1)
       
        ' Increase loop counter
        ecx = (ecx + 2)
    Loop Until (ecx = 16)
   
    ecx = 0

    If (blnVerifyKey = True) Then
        eax = 3
       
        Do:
            edx = GetNumVal(arrKey(ecx))
           
            ' esi = (eax + eax)
            ' Optimization:
            esi = modGlobals.LShift(eax, 1)
           
            edx = (edx Xor esi)
            eax = (eax + edx)
           
            ecx = (ecx + 1)
        Loop Until (ecx = 16)
       
        eax = (eax And &HFF)
       
        If (eax <> lngChecksum) Then
            Exit Function
        End If
    End If

    ' Shuffle
   
    edi = (7 - 16)
    esi = 15

    Do:
        dl = Asc(arrKey(esi))

        ecx = ((esi + edi) And &HF)

        bl = Asc(arrKey(ecx))
       
        arrKey(esi) = Chr$(bl)
        arrKey(ecx) = Chr$(dl)
       
        esi = (esi - 1)
    Loop Until (esi < 0)
 
    ecx = &H13AC9741
    ebx = 15
   
    Do:
        al = Asc(UCase$(arrKey(ebx)))
   
        If (al <= Asc("7")) Then
            dl = (ecx And &HFF)
            dl = ((dl And 7) Xor al)
   
            ecx = modGlobals.RShift(ecx, 3)
   
            arrKey(ebx) = Chr$(dl)
        ElseIf (al < Asc("A")) Then
            dl = ((ebx And 1) Xor al)

            arrKey(ebx) = Chr$(dl)
        End If
   
        ebx = (ebx - 1)
    Loop Until (ebx < 0)

    strKey = Join(arrKey(), vbNullString)
   
    lngGmeID = Val(Left$(strKey, 2))
    lngPubVal = Val("&H" & Mid$(strKey, 3, 6))
    lngPrivVal = Val("&H" & Mid$(strKey, 9))
   
    DecodeWarCraft2Key = 1
   
    Erase arrKey()
End Function

' To do:<
« Last Edit: August 31, 2005, 06:06:02 pm by LoRd[nK] »

Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
Re: [BNET/RB] How to Hash
« Reply #5 on: August 31, 2005, 06:05:20 pm »
Thats all nice and dandy..

Bur I am pretty sure I want to encode CDKeys, not decode them... Right?
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00

Offline Eric

  • Full Member
  • ***
  • Posts: 304
  • I'm new here!
    • View Profile
Re: [BNET/RB] How to Hash
« Reply #6 on: August 31, 2005, 06:08:50 pm »
Thats all nice and dandy..

Bur I am pretty sure I want to encode CDKeys, not decode them... Right?

You have to decode the CD-Key before you can hash it.

Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
Re: [BNET/RB] How to Hash
« Reply #7 on: August 31, 2005, 06:14:34 pm »
Ummmm... Maybe I will use BNLS..
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [BNET/RB] How to Hash
« Reply #8 on: August 31, 2005, 06:29:07 pm »
Essentially, they are public/private/product values that are generated and then encoded by Blizzard into the alphanumeric values you see on your jewel case.  Your work is to decode these values back into their original state.

The values, decoded, is what you hash to send to Battle.net.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.