• Welcome to Valhalla Legends Archive.
 

S->C 0x50 problems...

Started by Don Cullen, February 25, 2007, 02:45 PM

Previous topic - Next topic

Don Cullen

this is what i have so far:

Public Sub SID_AUTH_INFO(ByVal ProdID As Long) '0x50
    Dim lServerToken As Long, UDPValue As Long
    Select Case ProdID
        Case &H53455850
            AC "Client identified as SEXP"
            lServerToken = GetTickCount()
            UDPValue = CLng("&H" & Replace(StrToHex("bnet"), " ", vbNullString))
            With PacketBuf
                .InsertDWORD &H0
                .InsertDWORD lServerToken
                .InsertDWORD UDPValue
                .InsertBYTE &HF3
                .InsertBYTE &H8C
                .InsertBYTE &H60
                .InsertBYTE &H2
                .InsertBYTE &H0
                .InsertBYTE &H0
                .InsertBYTE &H81
                .InsertBYTE &H8F
                .InsertBYTE &H83
                .InsertBYTE &H91
                .InsertBYTE &HE7
                .InsertBYTE &HC3
                .InsertNTString "IX86ver7.mpq"
                .InsertNTString "A=290027319 B=709764025 C=42718536 4 A=A+S B=B^C C=C^A A=A^B"
                .SendBNETPacket Winsock1, &H50
            End With
        Case Else
            AC "Product ID: &H" & Hex$(ProdID)
            AC "Unknown client. Rejected connection."
            Winsock1.Close
            Winsock1.Listen
            AC "Listening for incoming connections..."
            Exit Sub
    End Select
End Sub


But I don't like the way it is right now. For one, I think I'm screwing up the file time. For two, it makes my starcraft client crash. No idea why. It just does.

So, my question here is:

How exactly would I get the file time for IX86ver7.mpq, and how exactly would I send it to the client? I found a IX86ver7.mpq packet via searching the forums, and I pretty much did a cut/paste. Dirty, but whatever. Suggestions?
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Ringo


Private Type FILETIMESTRUT
    dwLowDateTime As Long
    dwHighDateTime As Long
End Type
Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIMESTRUT, lpLastAccessTime As FILETIMESTRUT, lpLastWriteTime As FILETIMESTRUT) As Long
Private Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIMESTRUT, lpLastAccessTime As FILETIMESTRUT, lpLastWriteTime As FILETIMESTRUT) As Long

The time to get/send is the lpLastWriteTime :)
Im guessing your making somthing to gather the lockdown results? :P

Don Cullen

Quote from: Ringo on February 25, 2007, 03:02 PMThe time to get/send is the lpLastWriteTime :)

I don't understand. Mind clarifying?

QuoteIm guessing your making somthing to gather the lockdown results? :P

Haha, nothing quite so ambitious. I'm just tinkering to see if I can't get my starcraft client to connect to a self-made bncs server. it's just mainly for the sheer novelty of it. :P
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

Ringo

#3
Kinda like this:

Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIMESTRUT, lpLastAccessTime As FILETIMESTRUT, lpLastWriteTime As FILETIMESTRUT) As Long
Private Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIMESTRUT, lpLastAccessTime As FILETIMESTRUT, lpLastWriteTime As FILETIMESTRUT) As Long
Private Declare Function CreateFile Lib "Kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "Kernel32.dll" (ByVal hObject As Long) As Long
Private Declare Function WriteFile Lib "Kernel32.dll" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBYTEsToWrite As Long, lpNumberOfBYTEsWritten As Long, ByVal lpOverlapped As Any) As Long


Private Const CREATE_ALWAYS = 2
Private Const OPEN_EXISTING = 3
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const FILE_ATTRIBUTE_TEMPORARY = &H100
Private Const FILE_FLAG_DELETE_ON_CLOSE = &H4000000


Public Function GetFileTimeString(ByVal FilePath As String, ByRef strFileTime8 As String) As Boolean
    Dim Hdl&, Ret&, FT(2) As FILETIMESTRUT
    Hdl = CreateFile(FilePath, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0&, 0&)
    strFileTime8 = String(8, 0)
    If GetFileTime(Hdl, FT(0), FT(1), FT(2)) Then
        CopyMemory ByVal strFileTime8, FT(2), 8
        GetFileTimeString = True
    Else
        GetFileTimeString = False
    End If
    Call CloseHandle(Hdl)
    Erase FT()
End Function

It could use some optimizing tho :P


dim strFileTime as string * 8
If GetFileTimeString(app.path & "\IX86ver7.mpq",strFileTime) Then
   
End if

Don Cullen

Mmm... What about this:

Private Const OF_READ = &H0

Private Type OFSTRUCT
    cBytes As Byte
    fFixedDisk As Byte
    nErrCode As Integer
    Reserved1 As Integer
    Reserved2 As Integer
    szPathName(OFS_MAXPATHNAME) As Byte
End Type
Private Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
End Type

Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public Function PullFileTime(sPath As String) As FILETIME
    Dim hFile As Long, rval As Long
    Dim buff As OFSTRUCT
    Dim ctime As FILETIME, atime As FILETIME, wtime As FILETIME
   
    hFile = OpenFile(sPath, buff, OF_READ)
    If hFile Then
        rval = GetFileTime(hFile, ctime, atime, wtime)
        rval = CloseHandle(hFile)
        PullFileTime = wtime
    End If
End Function


What do you think?
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.