It appears you have not registered with our community. To register please click here ...
Username
Password
Make a clsWarden file, with the following (trimmed and updated) code:Code:Option ExplicitPrivate Declare Function StandardSHA Lib "RSHA.dll" (sVal As String) As StringPrivate Position As LongPrivate RandomData() As BytePrivate RandomSource1() As BytePrivate RandomSource2() As BytePrivate Function RShift(ByVal pnValue As Double, ByVal pnShift As Long) As LongDim Shft As String Shft = Str$(pnValue / (2 ^ pnShift)) If InStr(Shft, ".") > 0 Then RShift = CLng(Left$(Shft, InStr(Shft, ".") - 1)) Else RShift = CLng(Shft) End IfEnd FunctionPublic Sub Initialize(Seed As String)Dim Length1 As LongDim Length2 As LongDim Seed1() As ByteDim Seed2() As ByteDim I As Long Length1 = RShift(Len(Seed), 1) Length2 = Len(Seed) - Length1 ReDim Seed1(Length1 - 1) ReDim Seed2(Length2 - 1) StrToByteArray Mid$(Seed, 1, Length1), Seed1 StrToByteArray Mid$(Seed, Length1 + 1, Length2), Seed2 ReDim RandomData(&H13) As Byte StrToByteArray StandardSHA(ByteArrayToStr(Seed1)), RandomSource1 StrToByteArray StandardSHA(ByteArrayToStr(Seed2)), RandomSource2 Update Position = 0End SubPrivate Sub Update() StrToByteArray StandardSHA(ByteArrayToStr(RandomSource1) & ByteArrayToStr(RandomData) & ByteArrayToStr(RandomSource2)), RandomDataEnd SubPrivate Function GetByte() As Byte GetByte = RandomData(Position) Position = Position + 1 If Position >= &H14 Then Position = 0 Update End IfEnd FunctionPublic Function GetBytes(ByVal bytes As Long) As StringDim I As IntegerDim Buffer() As Byte ReDim Buffer(bytes) As Byte For I = 0 To bytes Buffer(I) = GetByte Next I GetBytes = ByteArrayToStr(Buffer)End FunctionPublic Sub StrToByteArray(ByVal sStr As String, ByRef Ary() As Byte)Dim I As Integer ReDim Ary(Len(sStr) - 1) As Byte RtlMoveMemory Ary(0), ByVal sStr, Len(sStr)End SubPublic Function ByteArrayToStr(ByRef bByt() As Byte, Optional ByVal lLoc As Long = 0) As StringDim sStr As StringDim I As Integer sStr = String$(UBound(bByt) + 1, 0) RtlMoveMemory ByVal sStr, bByt(lLoc), UBound(bByt) + 1 ByteArrayToStr = sStrEnd FunctionPublic Sub SimpleCrypt(ByRef bBase() As Byte, ByRef bKey() As Byte)Dim lVal As LongDim I As LongDim lPos As LongDim temp As Byte ReDim bKey(&H101) As Byte For I = 0 To &HFF bKey(I) = I Next I For I = 1 To &H40 lVal = lVal + bKey(I * 4 - 4) + bBase(lPos Mod (UBound(bBase) + 1)) lPos = lPos + 1 temp = bKey(I * 4 - 4) bKey(I * 4 - 4) = bKey(lVal And &HFF) bKey(lVal And &HFF) = temp lVal = lVal + bKey(I * 4 - 3) + bBase(lPos Mod (UBound(bBase) + 1)) lPos = lPos + 1 temp = bKey(I * 4 - 3) bKey(I * 4 - 3) = bKey(lVal And &HFF) bKey(lVal And &HFF) = temp lVal = lVal + bKey(I * 4 - 2) + bBase(lPos Mod (UBound(bBase) + 1)) lPos = lPos + 1 temp = bKey(I * 4 - 2) bKey(I * 4 - 2) = bKey(lVal And &HFF) bKey(lVal And &HFF) = temp lVal = lVal + bKey(I * 4 - 1) + bBase(lPos Mod (UBound(bBase) + 1)) lPos = lPos + 1 temp = bKey(I * 4 - 1) bKey(I * 4 - 1) = bKey(lVal And &HFF) bKey(lVal And &HFF) = temp Next IEnd SubPublic Sub DoCrypt(ByRef bData() As Byte, ByRef bKey() As Byte, ByRef bRet() As Byte)Dim I As LongDim temp As ByteDim Y As LongDim Z As Long ReDim bRet(UBound(bData)) RtlMoveMemory bRet(0), bData(0), UBound(bData) + 1 Y = bKey(&H100) Z = bKey(&H101) For I = 0 To UBound(bData) Y = (Y + 1) And &HFF Z = (Z + bKey(Y)) And &HFF temp = bKey(Y) bKey(Y) = bKey(Z) bKey(Z) = temp bRet(I) = bRet(I) Xor bKey((CInt(bKey(Y)) + CInt(bKey(Z))) And &HFF) Next I bKey(&H100) = Y bKey(&H101) = ZEnd SubIn your BNCS connection code, add the following private declarations:Code:Private cWarden As New clsWardenPrivate wKeyOut() As BytePrivate wKeyIn() As ByteIn SID_AUTH_CHECK, somewhere after hashing your CDKey, add:Code: cWarden.Initialize Left$(KeyHash, 4) cWarden.StrToByteArray cWarden.GetBytes(&HF), bRet() cWarden.SimpleCrypt bRet(), wKeyOut() cWarden.StrToByteArray cWarden.GetBytes(&HF), bRet() cWarden.SimpleCrypt bRet(), wKeyIn()To handle SID_Warden (5E):Code:Private Sub SID_Recv_Warden()Dim bData() As ByteDim bRet() As ByteDim sData As StringDim lPos As LongDim nFile As IntegerDim EventNo As ByteDim I As LongDim Loops As LongDim Vals() As StringDim addr() As LongDim readlen As ByteDim ToSend As StringDim Checksum As LongConst Req1 As Long = &H497FB0Const Req2 As Long = &H49C33DConst Req3 As Long = &H4A2FF7 sData = Packet.GetNull cWarden.StrToByteArray sData, bData() cWarden.DoCrypt bData(), wKeyIn(), bRet() Select Case bRet(0) Case &H0 Packet.ClearOutbound ReDim bData(0) bData(0) = &H1 cWarden.DoCrypt bData(), wKeyOut(), bRet() Packet.InsertString cWarden.ByteArrayToStr(bRet()) AddQueue Packet.SendBNCSPacket(SID_WARDEN) Case &H2 If LenB(Dir$(CFm_HashPath & "\StarCraft.exe")) > 0 Then EventNo = bRet(1) Loops = (Len(sData) - 3) / 7 ReDim Vals(Loops - 1) As String ReDim addr(Loops - 1) As Long nFile = FreeFile Open CFm_HashPath & "\StarCraft.exe" For Binary Access Read As #nFile lPos = 2 For I = 0 To Loops - 1 lPos = lPos + 2 RtlMoveMemory addr(I), bRet(lPos), 4 lPos = lPos + 4 readlen = bRet(lPos) lPos = lPos + 1 Vals(I) = String$(readlen, 0) Get #nFile, addr(I) - &H400000 + 1, Vals(I) Next I Close #nFile If addr(0) = Req1 And addr(1) = Req2 And addr(2) = Req3 Then Checksum = &H193E73E8 ElseIf addr(0) = Req2 And addr(1) = Req1 And addr(2) = Req3 Then Checksum = &HD6557DEF ElseIf addr(0) = Req1 And addr(1) = Req3 And addr(2) = Req2 Then Checksum = &H2183172A ElseIf addr(0) = Req2 And addr(1) = Req3 And addr(2) = Req1 Then Checksum = &HCA841860 ElseIf addr(0) = Req3 And addr(1) = Req2 And addr(2) = Req1 Then Checksum = &H9F2AD2C3 ElseIf addr(0) = Req3 And addr(1) = Req1 And addr(2) = Req2 Then Checksum = &HC04CF757 Else RaiseEvent BNetError("Unknown Warden Request! You will be disconnected in two minutes.") Exit Sub End If Packet.ClearOutbound For I = 0 To Loops - 1 Packet.InsertByte &H0 Packet.InsertString Vals(I) Next I ToSend = Packet.GetOutbound ToSend = Chr$(&H2) & Packet.CreateWORD(Len(ToSend)) & Packet.CreateDWORD(Checksum) & ToSend cWarden.StrToByteArray ToSend, bData() Packet.ClearOutbound cWarden.DoCrypt bData(), wKeyOut(), bRet() Packet.InsertString cWarden.ByteArrayToStr(bRet()) AddQueue Packet.SendBNCSPacket(SID_WARDEN) Else RaiseEvent BNetError("Can't respond to Warden without StarCraft.exe!") End If Case Else RaiseEvent BNetError("Unknown Warden Packet: " & StH(sData)) End SelectEnd SubThat may make things a bit easier to understand.