0 Members and 1 Guest are viewing this topic.
Public Function CreateLogin(buffer() As Byte) As Byte() Dim wLen As Long Dim strTemp As String Dim lngLen As Long Dim lngTemp As Long Dim i As Long 'Login-Request: (Client) '0x0064][00:1][RoomName:N][LineType:2][Room-IP-Address:4][UDP-Port:2][SharedFiles:4][Username:N][00:1] 'wLen = Util::FormatMXMessage(0x0064, (char*)&buffer, "SWDWDS", ' (LPCTSTR)m_strRoom, ' m_wLineType, ' m_dwClientIP, ' m_wClientUDPPort, ' m_dwFiles, ' (LPCTSTR)m_strUser); 'Prepare login buffer... ReDim buffer(1024) '*(WORD*)buffer = 0x0064; lngTemp = &H64 buffer(0) = lngTemp And 255 buffer(1) = (lngTemp \ 256) And 255 wLen = 4 'lstrcpy(buffer + nLen, m_strRoom) strTemp = RTrim(m_strRoom) lngLen = Len(strTemp) For i = 0 To lngLen - 1 buffer(wLen + i) = Asc(Mid$(strTemp, i + 1, 1)) Next buffer(wLen + lngLen + 1) = &H0 'wLen+=strlen(m_strUser)+1; wLen = wLen + (lngLen + 1) 'memcpy(buffer+wLen, &m_wLineType, 2); lngTemp = m_wLineType buffer(wLen) = lngTemp And 255 buffer(wLen + 1) = (lngTemp \ 256) And 255 wLen = wLen + 2 'memcpy(buffer+wLen, &m_dwClientIP, 4); lngTemp = m_dwClientIP buffer(wLen) = lngTemp And 255 buffer(wLen + 1) = (lngTemp \ 256) And 255 buffer(wLen + 2) = (lngTemp \ 65536) And 255 buffer(wLen + 3) = (lngTemp \ 16777216) And 255 wLen = wLen + 4 'memcpy(buffer+wLen, &m_wClientUDPPort, 2); lngTemp = m_wClientUDPPort buffer(wLen) = lngTemp And 255 buffer(wLen + 1) = (lngTemp \ 256) And 255 wLen = wLen + 2 'memcpy(buffer+wLen, &m_dwFiles, 4); lngTemp = m_dwFiles buffer(wLen) = lngTemp And 255 buffer(wLen + 1) = (lngTemp \ 256) And 255 buffer(wLen + 2) = (lngTemp \ 65536) And 255 buffer(wLen + 3) = (lngTemp \ 16777216) And 255 wLen = wLen + 4 'lstrcpy(buffer+wLen, m_strUser); strTemp = RTrim(m_strUser) lngLen = Len(strTemp) For i = 0 To lngLen - 1 buffer(wLen + i) = Asc(Mid$(strTemp, i + 1, 1)) Next buffer(wLen + lngLen + 1) = &H0 'wLen+=strlen(m_strUser)+1; wLen = wLen + (lngLen + 1) '*(WORD*)(buffer+2) = wLen-4; lngTemp = wLen - 4 'length buffer(2) = lngTemp And 255 buffer(3) = (lngTemp \ 256) And 255 ReDim Preserve buffer(wLen) CreateLogin = buffer()End Function