You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

107 lines
3.8 KiB

Module Services
Public sRunTimeDir As String = getRunTimeDir() & "\LVNC-RS"
Public sConfigFile As String = sRunTimeDir & "\lvnc-rs.ini"
Public lSupportID As Long = 0
Private aExecResources(,) As String = {
{"lvnc_rs_ini", "\lvnc_rs.ini"},
{"ultravnc_ini", "\UltraVNC\ultravnc.ini"},
{"setpasswd_exe", "\UltraVNC\setpasswd.exe"},
{"winvnc_exe", "\UltraVNC\winvnc.exe"},
{"authadmin_dll", "\UltraVNC\authadmin.dll"},
{"ddengine_dll", "\UltraVNC\ddengine.dll"},
{"SCHook_dll", "\UltraVNC\SCHook.dll"},
{"vnchooks_dll", "\UltraVNC\vnchooks.dll"},
{"SecureVNCPlugin_dsm", "\UltraVNC\SecureVNCPlugin.dsm"}
}
Private Function getRunTimeDir() As String
Dim sRegShellPath As String = "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
Dim sAllUsersDir As String
Dim regKey As Global.Microsoft.Win32.RegistryKey
Dim sCommonDesktop As String
Try
regKey = Global.Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sRegShellPath, False)
sCommonDesktop = regKey.GetValue("Common Desktop")
Catch ex As Exception
sCommonDesktop = ""
End Try
If sCommonDesktop.Length > 0 Then
Dim a() = sCommonDesktop.Split("\")
Dim l As Integer = a.Length - 2
ReDim Preserve a(l)
sAllUsersDir = String.Join("\", a)
Else
sAllUsersDir = ""
End If
Return sAllUsersDir
End Function
Public Sub checkRunTimeComponents()
Dim resItem As Object
Dim resContent As Byte()
With My.Computer.FileSystem
If Not .DirectoryExists(sRunTimeDir) Then
.CreateDirectory(sRunTimeDir)
End If
If Not .DirectoryExists(sRunTimeDir & "\UltraVNC") Then
.CreateDirectory(sRunTimeDir & "\UltraVNC")
End If
For i As Integer = 0 To UBound(aExecResources)
resItem = My.Resources.ResourceManager.GetObject(aExecResources(i, 0))
If TypeOf (resItem) Is String Then
resContent = System.Text.Encoding.Default.GetBytes(resItem.ToString)
Else
resContent = resItem
End If
Using file As New IO.FileStream(sRunTimeDir & aExecResources(i, 1), IO.FileMode.Create)
file.Write(resContent, 0, resContent.Length)
End Using
Next
End With
End Sub
Public Sub getSupportID()
Dim aNics() As Net.NetworkInformation.NetworkInterface = Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
Dim sMAC As String = String.Empty
Dim lID As Long = 0
For Each nic As Net.NetworkInformation.NetworkInterface In aNics
If (nic.NetworkInterfaceType = Net.NetworkInformation.NetworkInterfaceType.Ethernet Or
nic.NetworkInterfaceType = Net.NetworkInformation.NetworkInterfaceType.Wireless80211) And
nic.OperationalStatus = Net.NetworkInformation.OperationalStatus.Up Then
sMAC = nic.GetPhysicalAddress.ToString
Exit For
End If
Next
Dim strBuilder As New Text.StringBuilder(sMAC)
Dim startIndex As Integer = strBuilder.Length - (strBuilder.Length Mod 2) - 2
For i As Integer = startIndex To 2 Step -2
strBuilder.Insert(i, ":"c)
Next i
Dim aMAC() = strBuilder.ToString.Split(":")
Dim n As Long = 0
For i As Integer = 0 To UBound(aMAC)
n = Convert.ToInt32(aMAC(i), 16)
Debug.Print(n)
lID = ((lID * 16) + n) Mod 99999999
If lID < 99999999 Then
lID = lID + 10000000
End If
Next
lSupportID = lID
End Sub
End Module