Archive for the ‘Hack’ Tag

Vb Net Article – Medal of Honour Allied Assault Basic Hacks

Medal of Honour Allied Assault Basic Hacks.

I got bored a while back and made some basic hacks for MoHAA.

I made a class (Well a few classes) that I used to read the console, send text to the console, and a few memory hacks.

I then stuck this into a global key hook and set up the hotkeys.

The classes are all contained inside Public Class MoHFunctions

Public Class WindowFunctions

<DllImport(“user32.dll”, SetLastError:=True, CharSet:=CharSet.Auto)> Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As Int32) As Boolean

End Function

Private Enum WindowShowStyle As UInteger

Hide = 0

ShowMinimized = 2

Minimize = 6

ShowMinNoActivate = 7

ForceMinimized = 11

End Enum

Private Declare Auto Function FindWindow Lib “user32″ (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Public Shared Sub MinimiseWindow()

Dim MoHWnd As IntPtr = FindWindow(0, “Medal of Honor Allied Assult”)

ShowWindow(MoHWnd, WindowShowStyle.Minimize)

End Sub

End Class

That class is basically for minimising the MoHAA Window, I never got round to adding anything else to it. Maybe one day…

Now for a long class, the console stuff.

Public Class Console

<DllImport(“User32.dll”)> Private Shared Function EnumChildWindows(ByVal WindowHandle As IntPtr, ByVal Callback As EnumWindowProcess, ByVal lParam As IntPtr) As Boolean

End Function

<DllImport(“user32.dll”, CharSet:=CharSet.Auto)> Private Shared Sub GetClassName(ByVal hWnd As System.IntPtr, ByVal lpClassName As System.Text.StringBuilder, ByVal nMaxCount As Integer)

End Sub

Private Shared Function GetChildWindows(ByVal ParentHandle As IntPtr) As IntPtr()

Dim ChildrenList As New List(Of IntPtr)

Dim ListHandle As GCHandle = GCHandle.Alloc(ChildrenList)

Try

EnumChildWindows(ParentHandle, AddressOf EnumWindow, GCHandle.ToIntPtr(ListHandle))

Finally

If ListHandle.IsAllocated Then ListHandle.Free()

End Try

Return ChildrenList.ToArray

End Function

Private Shared Function EnumWindow(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean

Dim ChildrenList As List(Of IntPtr) = GCHandle.FromIntPtr(Parameter).Target

If ChildrenList Is Nothing Then Throw New Exception(“GCHandle Target could not be cast as List(Of IntPtr)”)

ChildrenList.Add(Handle)

Return True

End Function

Private Declare Auto Function SendMessage Lib “user32″ (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wparam As Integer, ByVal lparam As System.Text.StringBuilder) As IntPtr

Private Declare Auto Function SendMessage Lib “user32″ (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr

Private Declare Auto Function FindWindow Lib “user32″ (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Private Delegate Function EnumWindowProcess(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean

Private Const WM_GETTEXT = &HD

Private Const WM_GETTEXTLENGTH As Integer = &HE

Private Const WM_SETTEXT = &HC

Private Const WM_CHAR = &H102

These functions are to get a list of the windows inside of the MoHAA console, and to get the text from it.

Private Shared Function FindMoH() As IntPtr

FindMoH = FindWindow(“mohaa winconsole”, vbNullString)

End Function

This function gets the window handle for the MoHAA console, which is then used to get the consoles edit controls handle.

Now, for the sending to the console:

Public Shared Function SendText(ByVal Text As String) As Boolean

Dim handle As IntPtr = FindMoH()

If handle = 0 Then

MessageBox.Show(“Medal of Honor Allied Assult Console not found.”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error)

Return “Error;”

Exit Function

End If

For Each child As IntPtr In GetChildWindows(handle)

Dim sClassName As New System.Text.StringBuilder(“”, 256)

Call GetClassName(child, sClassName, 256)

If sClassName.ToString = “Edit” Then

Dim sb As New System.Text.StringBuilder(Text)

SendMessage(child, WM_SETTEXT, 0, sb)

SendMessage(child, WM_CHAR, 13, 1)

Return True

End If

Next

End Function

This finds the Edit control by looping through the handles until if finds one with the class name “Edit”. It then uses SendMessage to set the text in the window, and then sends the Return character to the window to set it

(child, WM_CHAR, 13, 1)

Reading text from the console isnt much different:

Public Shared Function ReadText() As String

ReadText = “”

Dim handle As IntPtr = FindMoH()

If handle = 0 Then

MessageBox.Show(“Medal of Honor Allied Assult Console not found.”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error)

Return “Error;”

Exit Function

End If

For Each child As IntPtr In GetChildWindows(handle)

Dim sClassName As New System.Text.StringBuilder(“”, 256)

Call GetClassName(child, sClassName, 256)

If sClassName.ToString = “Edit” Then

Dim conLength As IntPtr

conLength = SendMessage(child, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero)

Dim sbText As New System.Text.StringBuilder(conLength.ToInt32 + 1)

Dim ptrRet As IntPtr

ptrRet = SendMessage(child, WM_GETTEXT, conLength.ToInt32 + 1, sbText)

If Not sbText.ToString = “” Then

Return sbText.ToString

End If

End If

Next

End Function

This again loops through the handles, until it finds the edit control.

It then sends the GETTEXTLENGTH in order to get the length of the text in the console and then sends GETTEXT to the window to the length that was previously returned.

It then builds the string; if it’s not blank then it returns the value.

Now what can we actually do with these functions? Well to be honest, I didn’t use the ReadText function because I figured the only way to use it would be to check it on a loop, then if a specific string came up you could then do whatever, but I couldn’t be bothered with that…

Public Shared Sub SilentShot()

SendText(“echo Silent Shot”)

SendText(“+attackprimary; weapdrop”)

End Sub

Public Shared Sub Time()

SendText(“echo “ & Now.Hour & “:” & Now.Minute & “:” & Now.Second)

SendText(“locationprint 6 29 “ & Now.Hour & “:” & Now.Minute & “:” & Now.Second)

End Sub

Public Shared Sub Connect(ByVal Ip As String)

SendText(“connect “ & Ip)

End Sub

Public Shared Sub Specator()

SendText(“echo Gone Spectator”)

SendText(“spectator”)

End Sub

Public Shared Sub Reconnect()

SendText(“reconnect”)

End Sub

Now, that’s just some basic stuff, but you could create some more advanced scripts such as:

SendText(“+forward”)

System.Threading.Thread.Sleep(50)

SendText(“-forward”)

SendText(“+moveup”)

System.Threading.Thread.Sleep(400)

SendText(“-moveup”)

System.Threading.Thread.Sleep(10)

SendText(“+forward”)

System.Threading.Thread.Sleep(20)

SendText(“+moveup”)

System.Threading.Thread.Sleep(200)

SendText(“-moveup”)

SendText(“+forward”)

System.Threading.Thread.Sleep(200)

SendText(“+moveup”)

System.Threading.Thread.Sleep(100)

SendText(“-moveup”)

System.Threading.Thread.Sleep(20)

SendText(“+moveleft”)

SendText(“-forward”)

SendText(“-moveleft”)

Now I just came up with that and gave it a quick test, so I can’t guarantee that it works every time (It was just a bind that I made and converted, and it was made quickly so there ARE errors)

bind 9 “+forward;wait 50;-forward;+moveup;say jumped;wait 400;-moveup;wait 10;+forward;say forward;wait 20;+moveup;say jumped;+wait 200; -moveup;+forward;wait 200; say jumped;+moveup; wait 100; -moveup;wait 20;+moveleft;-forward;-moveleft;-moveup”

For example, one noticeable error: say jumped;+wait 200;

Now, off of the console stuff, and onto some fun stuff, memory editing!

Public Class Memory

<DllImport(“kernel32.dll”)> Private Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As Byte(), ByVal nSize As UIntPtr, <Runtime.InteropServices.Out()> ByRef lpNumberOfBytesWritten As IntPtr) As Boolean

End Function

My favourite APIJ, well not really but what you gonna do?

So, anyway, in the main part of the program we have a variable named MoHProchWnd, that’s where I store MoHAA’s PiD using the sub below

Public Shared Sub onLoad()

Try

Dim Processes() As System.Diagnostics.Process

Processes = System.Diagnostics.Process.GetProcessesByName(“MOHAA”)

Main.MoHProchWnd = Processes(0).Handle

Catch ex As Exception

Main.MoHProchWnd = 0

End Try

End Sub

So, anyway below is a basic function for enabling cheats in MoHAA (“Cvars”)

Public Shared Sub EnableCheats()

If Main.MoHProchWnd = 0 Then

onLoad()

End If

Dim bytes As Byte() = New Byte(0) {&H86}

WriteProcessMemory(Main.MoHProchWnd, New IntPtr(&H44F999), bytes, New UIntPtr(CType(bytes.Length, UInt32)), New IntPtr(0))

KeyHook.Cheats = True

End Sub

And then to disable them

Public Shared Sub DisableCheats()

If Main.MoHProchWnd = 0 Then

onLoad()

End If

Dim bytes As Byte() = New Byte(0) {&H85}

WriteProcessMemory(Main.MoHProchWnd, New IntPtr(&H44F999), bytes, New UIntPtr(CType(bytes.Length, UInt32)), New IntPtr(0))

KeyHook.Cheats = False

End Sub

And a quick example of what else can be done:

Public Shared Sub EnableThirdPerson()

If Main.MoHProchWnd = 0 Then

onLoad()

End If

Dim bytes As Byte() = New Byte(0) {&H1}

WriteProcessMemory(Main.MoHProchWnd, New IntPtr(&HECCAF0), bytes, New UIntPtr(CType(bytes.Length, UInt32)), New IntPtr(0))

KeyHook.ThirdPerson = True

Console.SendText(“cg_cameraverticaldisplacement -18″)

Console.SendText(“echo 3rd Person Camera Position Fixed”)

End Sub

Public Shared Sub DisableThirdPerson()

If Main.MoHProchWnd = 0 Then

onLoad()

End If

Dim bytes As Byte() = New Byte(0) {&H0}

WriteProcessMemory(Main.MoHProchWnd, New IntPtr(&HECCAF0), bytes, New UIntPtr(CType(bytes.Length, UInt32)), New IntPtr(0))

KeyHook.ThirdPerson = False

Console.SendText(“cg_cameraverticaldisplacement -2″)

Console.SendText(“echo 1st Person Camera Position Fixed”)

End Sub

That uses the console class to correct the camera position, and edits the programs memory to enable the third person – Note, that since it directly pokes an address, cheats do not need to be enabled to toggle 3rd person.

Now, onto the usage of these classes further. As I previously stated, I set this up on a global key hook. Below is the sub that I use to carry out the above functions.

Private Shared Sub KeyCheck()

If n0Down = True Then

If Cheats = True Then

Cheats = False

Memory.DisableCheats()

Else

Cheats = True

Memory.EnableCheats()

End If

ElseIf n1Down = True Then

If ThirdPerson = True Then

ThirdPerson = False

Memory.DisableThirdPerson()

Else

ThirdPerson = True

Memory.EnableThirdPerson()

End If

ElseIf n2Down = True Then

Console.SilentShot()

ElseIf n3Down = True Then

Console.Specator()

ElseIf n4Down = True Then

Console.Time()

ElseIf n5Down = True Then

Console.Reconnect()

ElseIf n6Down = True Then

Console.Connect(“213.251.176.208:28305″)

Console.SendText(“Echo Connecting to LCA V2 Sniper only”)

Console.SendText(“Echo IP: 213.251.176.208:28305″)

Exit Sub

ElseIf n7Down = True Then

Console.Connect(“213.251.176.208:12000″)

Console.SendText(“Echo Connecting to LCA Stalingrad Sniper only”)

Console.SendText(“Echo IP: 213.251.176.208:12000″)

ElseIf n8Down = True Then

Console.Connect(“217.79.181.142:27001″)

Console.SendText(“Echo Connecting to [NAG] Stalingrad Sniper only 1″)

Console.SendText(“Echo IP: 217.79.181.142:27001″)

ElseIf n9Down = True Then

Console.Connect(“213.133.101.46:27001″)

Console.SendText(“Echo Connecting to [NAG] Stalingrad Sniper only 2″)

Console.SendText(“Echo IP: 213.133.101.46:27001″)

ElseIf minusDown = True Then

WindowFunctions.MinimiseWindow()

End If

End Sub

As you can see, it just checks what key is down, and then if the specified one is, it carries out the function. n0 and n1 toggle the two memory functions by checking a Boolean to see if the function is enabled or not.

I was playing again earlier and thought about making a more accurate sniper rifle.

I tried to just make a bind:

bind MOUSE1 “+attacksecondary; +attackprimary; -attacksecondary”

However, due to the way that MoHAA works, this would not carry out the zoom out function. So, I looked through the cmdlist, and found the zoomoff function, and made a new bind:

bind MOUSE1 “+attacksecondary; +attackprimary; zoomoff”

Whilst this worked when playing on a local server, I tried it on another server and it did not work.

So now, I have not actually done this, but I would also hook the mouse, then if the mouse is clicked I would send these messages to console, after unbinding Mouse1 in game:

Console.SendText(“+attacksecondary”)

Console.SendText(“+attackprimary”)

Console.SendText(“-attacksecondary”)

But that however would do that for every single gun in the game, so I looked further for a console command that would give me the name of the gun currently in use. I searched both the cmdlist and the cvarslist, to no avail.

I then went searching in the memory, and found a number of helpful addresses:

010EEEF0 – Text[22] – The name of the gun as a string

010EEF40 – 4 Bytes – The gun as an integer

I decided that the best way to do it would be using the integer, and then a list of values to see what gun is currently in use. I tested all the weapons and created this list

Value/Weapon

1 – Papers

2 – Colt 45

3 – Walther P38

4 – Hi Standard Silenced

5 – M1 Garand

6 – Mauser KAR 98K

7 – KAR98 – Sniper

8 – Springfield

9 – Thompson

10 – MP40

11 – BAR

12 – StG 44

13 – Frag Grenade

14 – Stielhandgranate

15 – Bazooka

16 – Panzerschreck

Now, I can read the memory at that address, and if the current weapon is either 7 or 8, it will send the zoom in, shoot, zoom out function for a 100% accurate shot.

VB Net – MSN Xfire Personal Message

Imports System.Runtime.InteropServices

Public Class Form1

#Region “APIS+CONST”

”Here are the API Functions needed

<DllImport(“User32.dll”)> Private Shared Function EnumChildWindows(ByVal WindowHandle As IntPtr, ByVal Callback As EnumWindowProcess, ByVal lParam As IntPtr) As Boolean

End Function

<DllImport(“user32.dll”, CharSet:=CharSet.Auto)> Private Shared Sub GetClassName(ByVal hWnd As System.IntPtr, ByVal lpClassName As System.Text.StringBuilder, ByVal nMaxCount As Integer)

End Sub

Private Declare Auto Function FindWindow Lib “user32″ (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Private Declare Auto Function SendMessage Lib “user32″ (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wparam As Integer, ByVal lparam As System.Text.StringBuilder) As IntPtr

Private Declare Auto Function SendMessage Lib “user32″ (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr

Private Declare Function SendMessage2 Lib “user32.dll” Alias “SendMessageA” (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As IntPtr) As Int32

Private Declare Function FindWindowEx Lib “user32.dll” Alias “FindWindowExA” (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32

Private Const WM_GETTEXT = &HD

Private Const WM_GETTEXTLENGTH As Integer = &HE

Private Const WM_SETTEXT = &HC

Private Structure COPYDATASTRUCT

Public dwData As Int32

Public cbData As Int32

Public lpData As IntPtr

End Structure

Private Const WM_COPYDATA As Int32 = &H4A

#End Region

#Region “Functions/Enums not to edit”

Private Delegate Function EnumWindowProcess(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean

Private Enum IconType

Music

Games

Office

End Enum ”This contains the values for the different MSN now playing icons

Private Shared Function GetChildWindows(ByVal ParentHandle As IntPtr) As IntPtr() ”Gets the list of child windows from the parent window

Dim ChildrenList As New List(Of IntPtr)

Dim ListHandle As GCHandle = GCHandle.Alloc(ChildrenList)

Try

EnumChildWindows(ParentHandle, AddressOf EnumWindow, GCHandle.ToIntPtr(ListHandle)) ”Enumerates the windows

Finally

If ListHandle.IsAllocated Then ListHandle.Free()

End Try

Return ChildrenList.ToArray ”Returns the list of windows as a collection on IntPrt, which is then searched in

End Function

Private Shared Function EnumWindow(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean

Dim ChildrenList As List(Of IntPtr) = GCHandle.FromIntPtr(Parameter).Target

If ChildrenList Is Nothing Then Throw New Exception(“GCHandle Target could not be cast as List(Of IntPtr)”)

ChildrenList.Add(Handle) ”Adds a list of window handles

Return True

End Function

Private Shared Function FindXfire() As IntPtr

FindXfire = FindWindow(“SkinWnd”, vbNullString) ”Finds handle of the Xfire class window

End Function

Private Shared Function SendText(ByVal Text As String) As Boolean

Shell(“xfire:status?text=” & Text) ”Sets the Xfire status

End Function

Private Shared Function ReadText() As String

ReadText = “”

Dim handle As IntPtr = FindXfire()

If handle = 0 Then ”If the window isnt found

MessageBox.Show(“Xfire window not found.”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error)

Return “Error;”

Exit Function

End If

For Each child As IntPtr In GetChildWindows(handle) ”Loop through list of windows

Dim sClassName As New System.Text.StringBuilder(“”, 256)

Call GetClassName(child, sClassName, 256)

If sClassName.ToString = “Edit” Then ”Reads the class name of the handle

Dim conLength As IntPtr

conLength = SendMessage(child, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero) ”Gets the length of the text

Dim sbText As New System.Text.StringBuilder(conLength.ToInt32 + 1)

Dim ptrRet As IntPtr

ptrRet = SendMessage(child, WM_GETTEXT, conLength.ToInt32 + 1, sbText) ”Reads the text from the handle

If Not sbText.ToString = “” Then

Return sbText.ToString ”returns the text

End If

End If

Next

End Function

Private Shared Sub SetPlayingInfo(ByVal Artist As String, ByVal Album As String, ByVal Title As String, Optional ByVal Icon As IconType = IconType.Music, Optional ByVal WMContentID As String = vbNullString, Optional ByVal Format As String = “{0} – {1}”, Optional ByVal Show As Boolean = True)

”Not my function

Dim mess As String = String.Format(“{0}{1}{2}{3}{4}{5}{6}” & vbNullChar, Icon.ToString, Math.Abs(CInt(Show)), Format, Artist, Title, Album, WMContentID)

Dim lpMess As GCHandle = GCHandle.Alloc(mess, GCHandleType.Pinned)

Dim CD As COPYDATASTRUCT

With CD

.dwData = &H547

.cbData = mess.Length * 2

.lpData = lpMess.AddrOfPinnedObject

End With

Dim lpCD As GCHandle = GCHandle.Alloc(CD, GCHandleType.Pinned)

Dim hMSGRUI As Integer

Do

hMSGRUI = FindWindowEx(0, hMSGRUI, “MsnMsgrUIManager”, vbNullString)

If (hMSGRUI > 0) Then

SendMessage2(hMSGRUI, WM_COPYDATA, 0, lpCD.AddrOfPinnedObject)

End If

Loop Until (hMSGRUI = 0)

lpMess.Free()

lpCD.Free()

End Sub

#End Region

Private Xfolder As IO.FileSystemWatcher = New System.IO.FileSystemWatcher()

Private work As Boolean = True

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim path As String = My.Computer.FileSystem.GetParentPath(My.Computer.FileSystem.GetParentPath(My.Computer.FileSystem.GetParentPath(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData)))

Xfolder.Path = path & “\Xfire”

Xfolder.NotifyFilter = IO.NotifyFilters.Attributes

AddHandler Xfolder.Changed, AddressOf Changed ”Creates the fsw, to the sub Changed

Xfolder.EnableRaisingEvents = True ”Starts watching

End Sub

Private Sub Changed(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)

If e.Name = “status.ini” Then ”If the modified file is status.ini

Dim Str As String = ReadText() ”reads the window text

If Not Str = “Online” Or Str = “(AFK) Away From Keyboard” Then ”if its not a default one

SetPlayingInfo(“Now Playing”, “i__h4x Logger”, ReadText(), IconType.Games) ”Sets the msn pm to the game

If BackgroundWorker1.IsBusy = False Then ”Starts the bgw which sets the personal message (Incase other programs change it)

BackgroundWorker1.RunWorkerAsync()

work = True

End If

End If

End If

End Sub

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

Do

Dim Str As String = ReadText()

If Not Str = “Online” Or Str = “(AFK) Away From Keyboard” Then

SetPlayingInfo(“Now Playing”, “i__h4x Logger”, ReadText(), IconType.Games)

Else ”Does same as in Changed

SetPlayingInfo(“Now Playing”, “i__h4x Logger”, “Nothing”, IconType.Games)

work = False ”If the game has been closed, then it ends the bgw

End If

System.Threading.Thread.Sleep(200) ”pauses the loop

Loop Until work = False

BackgroundWorker1.WorkerSupportsCancellation = True

BackgroundWorker1.CancelAsync() ”ends the bgw

End Sub

End Class

This will change your MSN personal message to whatever you have in Xfire, you can see it change as you type, expect to see a full project released soon.

VB Net – MSN Nudger Full Project

Imports System.Runtime.InteropServicesImports MessengerAPIPublic Class Form1 <DllImport(“kernel32.dll”)> Public Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As Byte(), ByVal nSize As UIntPtr, <Out()> ByRef lpNumberOfBytesWritten As IntPtr) As Boolean End Function ‘@The fucnction to allow us to disable the timer Public Declare Function SendMessage Lib “user32.dll” Alias “SendMessageA” (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As IntPtr) As Int32 <DllImport(“user32.dll”, EntryPoint:=“FindWindow”)> Private Shared Function FindWindowByCaption(ByVal zero As IntPtr, ByVal lpWindowName As String) As IntPtr End Function Public Const CMD_NUDGE = &H2B1 Public Const WM_COMMAND As Long = &H111 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Processes() As System.Diagnostics.Process ”get processes Processes = System.Diagnostics.Process.GetProcessesByName(“msnmsgr”) ”find messenger If Processes.Length = 0 Then ”check that the process was found MessageBox.Show(“Windows Live Messenger process was not found”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If Dim msnpath As String = Processes(0).MainModule.FileName Dim msnversion As String = System.Diagnostics.FileVersionInfo.GetVersionInfo(msnpath).FileVersion ”get the version of user If Not msnversion = “8.1.0178.00″ Then ”my version is 8.1…. If MessageBox.Show(“The version of Windows Live Messenger you are running is not the same that this program was intended, you are running:” & vbNewLine & msnversion & vbNewLine & “The intended version is 8.1.0178.00, you can try and enable nudging if you wish but it may crash WLM” & vbNewLine & “Do you want to enable?”, “Error: Wrong version, continue?”, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.No Then Exit Sub End If End If Dim nops As Byte() = New Byte(6 – 1) {&H90, &H90, &H90, &H90, &H90, &H90} ”create our data to write ”&H90 = NOP in ASM, which stands for No OPeration WriteProcessMemory(Processes(0).Handle, New IntPtr(&H61F239), nops, New UIntPtr(CType(nops.Length, UInt32)), New IntPtr(0)) ”Write the data to the proocess,—————–the address——————-size————————-length MessageBox.Show(“Windows Live Messenger was sucessfully modified” & vbNewLine & “6 Bytes written at address 0061F239″, “Done:”, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ”checks that the fields are filled in correctly If TextBox1.Text = “” Then MessageBox.Show(“Please enter a valid contact email address”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub ElseIf InStr(TextBox1.Text, “@”) = 0 Then MessageBox.Show(“Please enter a valid contact email address”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub ElseIf NumericUpDown1.Value = 0 Then MessageBox.Show(“Please enter a number of times to send the nudge”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If Dim oMessenger As Messenger oMessenger = New Messenger Dim msncontact As IMessengerContact Dim msncontacts As IMessengerContacts ”gets the msn contacts msncontacts = oMessenger.MyContacts For Each msncontact In msncontacts ”loop through them If msncontact.SigninName = TextBox1.Text Then ”till it finds a matching contact oMessenger.InstantMessage(msncontact) ”open window Dim times As Integer = 0 Dim wnd As Integer = 0 wnd = FindWindowByCaption(0, msncontact.FriendlyName & ” – Conversation”) ”finds the window If wnd = 0 Then Dim Processes() As System.Diagnostics.Process ”if it dosnt find the window (contact may have weird symbols) Processes = System.Diagnostics.Process.GetProcessesByName(“msnmsgr”) If Processes.Length = 0 Then ”check that the process was found MessageBox.Show(“Windows Live Messenger process was not found”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If wnd = Processes(0).MainWindowHandle ’sets the handle to the window End If Do times += 1 SendMessage(wnd, WM_COMMAND, CMD_NUDGE, 0) ‘’sends a nudge Loop Until times = NumericUpDown1.Value ”x amount of times MessageBox.Show(“Done”, “MSN Nudge Spam”, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If Next MessageBox.Show(“Error, contact matching that email was not found”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error) End SubEnd Class

Example form:

nudger.jpg

Download @

http://cid-50c4db1f234d8c02.skydrive.live.com/self.aspx/Public/Windows%20Live%20Messenger%208.1%20Nudger.exe
http://cid-50c4db1f234d8c02.skydrive.live.com/self.aspx/Public/Interop.MessengerAPI.dll

VB Net – Removing MSN Nudge Limit

    <DllImport(“kernel32.dll”)> Public Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As Byte(), ByVal nSize As UIntPtr, <Out()> ByRef lpNumberOfBytesWritten As IntPtr) As Boolean
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Processes() As System.Diagnostics.Process ”get processes
Processes = System.Diagnostics.Process.GetProcessesByName(“-msnmsgr”) ”find messenger
Dim nops As Byte() = New Byte(6 – 1) {&H90, &H90, &H90, &H90, &H90, &H90} ”create our data to write
WriteProcessMemory(Processes(0).Handle, New IntPtr(&H61F239), nops, New UIntPtr(CType(nops.Length, UInt32)), New IntPtr(0))
”Write the data to the proocess,—————–the address——————-size————————-length
End Sub
Thats some example code for Windows Live Messenger V8.1.0178.00, there is a newer version out so you will need to update the address for that.

What this does is overwrites the timer at the address 0061F239
The original bytes = 8986DC020000
The written bytes = 909090909090

If you wanted to do it by patching the exe, it is the address 0021E630 (for v8.1…)

VB Net – Basic MSN Logging Program

Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form

Public myHandle As Integer
Dim playing As Boolean
Dim timeplaying As Integer
Dim timeinit As Integer

Function WinMinePID() As Integer
Dim Processes() As System.Diagnostics.Process
”Sets the function to -1 for use in the Gamestate function
WinMinePID = -1
”Gets the process using system diagnostics
Processes = System.Diagnostics.Process.GetProcessesByName(“winmine”)
”If the process exists then it sets the function to the process ID, else the function
‘’still = -1
If Processes.Length > 0 Then WinMinePID = Processes(0).Id
End Function
Sub StatExist()
Dim fileExists As Boolean
Dim stats As String = Application.StartupPath & “/stats.txt”
fileExists = My.Computer.FileSystem.FileExists(stats)
If fileExists = True Then
Else
My.Computer.FileSystem.WriteAllText(stats, (0) & ControlChars.NewLine & 0, False)
End If
Dim times As String = Application.StartupPath & “/times.txt”
fileExists = My.Computer.FileSystem.FileExists(times)
If fileExists = True Then
Else
My.Computer.FileSystem.WriteAllText(times, 0, False)
End If
End Sub
Function GameState() As Integer
”Gamestate Function
”<—0 = Normal—>
”<—1 = Mouse Down—>
”<—2 = Lost—>
”<—3 = Won—>
”<—4 = Face Down—>

”Declerations
Dim buffer As String : Dim addr, readlen, pid As Integer
On Error Resume Next
”Set pid to the process ID of minesweeper using the WinMinePID function
pid = WinMinePID()
stat.Text = “Process Not Found”
”Checks that the process exists
If pid = -1 Then Exit Function
‘Open the proccess with permissions (1F0FFF)
myHandle = OpenProcess(&H1F0FFF, False, pid)
buffer = Space(1)
addr = &H1005160
”Reads the memory at the address above
Call ReadProcessMemory(myHandle, addr, buffer, 1, readlen)
stat.Text = “Logging…”
”Sets the function to equal the value stored at the memory location
GameState = Asc(buffer)
End Function
Sub InitialTime()
Dim times As String = Application.StartupPath & “/times.txt”
timeinit = My.Computer.FileSystem.ReadAllText(times)
End Sub
Sub WriteLog()
StatExist()
Dim gs As Integer = (GameState())
If gs = 2 Then
TimeSave()
If playing = True Then playing = False : LostSave()
ElseIf gs = 3 Then
TimeSave()
If playing = True Then playing = False : WonSave()
Dim readlen As Integer
Dim buffer As String = Space(1)
Dim addr As Integer = &H100579C
”Reads the memory at the address above
Call ReadProcessMemory(myHandle, addr, buffer, 1, readlen)
MsgBox(Asc(buffer))
Else
playing = True
End If
End Sub
Function LostLoad() As Double
StatExist()
Dim stats As String = My.Computer.FileSystem.CurrentDirectory & “/stats.txt”
Dim line As String
Dim lineno As Integer = 0
Dim reader As New IO.StringReader(My.Computer.FileSystem.ReadAllText(stats))
While True
lineno += 1
line = reader.ReadLine()
If lineno = 2 Then LostLoad = line : Exit While
End While
End Function
Sub LostSave()
StatExist()
Dim stats As String = My.Computer.FileSystem.CurrentDirectory & “/stats.txt”
Dim Won As Integer = winsl.Text
Dim Lost As Integer = lossesl.Text
Lost += 1
My.Computer.FileSystem.WriteAllText(stats, (Won) & ControlChars.NewLine & Lost, False)
lossesl.Text = Lost

Dim times As String = My.Computer.FileSystem.CurrentDirectory & “/times.txt”

LostLoad()
End Sub
Function WonLoad() As Double
StatExist()
Dim stats As String = My.Computer.FileSystem.CurrentDirectory & “/stats.txt”
Dim line As String
Dim lineno As Integer = 0
Dim reader As New IO.StringReader(My.Computer.FileSystem.ReadAllText(stats))
While True
lineno += 1
line = reader.ReadLine()
If lineno = 1 Then WonLoad = line : Exit While
End While
End Function
Sub WonSave()
StatExist()
Dim stats As String = My.Computer.FileSystem.CurrentDirectory & “/stats.txt”
Dim Won As Integer = winsl.Text
Dim Lost As Integer = lossesl.Text
Won += 1
My.Computer.FileSystem.WriteAllText(stats, (Won) & ControlChars.NewLine & Lost, False)
winsl.Text = Won
WonLoad()
End Sub

Sub TimeSave()
Dim readlen As Integer
Dim buffer As String = Space(1)
Dim addr As Integer = &H100579C
Call ReadProcessMemory(myHandle, addr, buffer, 1, readlen)
Dim times As String = Application.StartupPath & “/times.txt”
timeplaying = buffer + timeinit
MsgBox(timeplaying)
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
WriteLog()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
StatExist()
winsl.Text = WonLoad()
lossesl.Text = LostLoad()
InitialTime()
End Sub

Private Sub TextChangde(ByVal sender As Object, ByVal e As System.EventArgs) Handles winsl.TextChanged, lossesl.TextChanged
If WonLoad() = 0 And LostLoad() = 0 Then
wrl.Text = 0 & “%”
Else
Dim oneperc As Double
oneperc = (WonLoad() + LostLoad()) / 100
Dim percent As Double
percent = WonLoad() / oneperc
wrl.Text = percent & “%”
End If

End Sub
End Class

Needs a lot of redoing, it works but its very inefficiently coded

VB Net – Add Menus To Minesweeper

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
‘*********************************************************************************’
‘***********************************Add Menus*************************************’
‘*********************************************************************************’
MenuHook.SetHook(“Minesweeper”)
Dim menus As New Collection
menus.Add(“Stats”)
menus.Add(“Cheats”)
menus.Add(“About”)
MenuHook.AddMenus(“Other”, menus)
End Sub

Then, for the menuhook class, these are the functions:

Public Class MenuHook

Private Const MF_BYCOMMAND As Integer = &H0
Private Const MF_BYPOSITION As Integer = &H400
Private Const MF_POPUP As Integer = &H10
Private Const MF_STRING As Integer = &H0
Shared Offset As Integer = 2000
Private Const WM_COMMAND As Integer = &H111S
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Declare Function AppendMenu Lib “user32″ Alias “AppendMenuA” (ByVal hMenu As Integer, ByVal wFlags As Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As String) As Integer
Private Declare Function CreatePopupMenu Lib “user32″ () As Integer
Private Declare Function DrawMenuBar Lib “user32″ (ByVal hwnd As Integer) As Integer
Public Declare Function FindWindow Lib “user32″ Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function GetMenu Lib “user32″ (ByVal hwnd As Integer) As Integer
Private Declare Function GetSubMenu Lib “user32″ (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
Private Declare Function GetMenuState Lib “user32″ (ByVal hMenu As Integer, ByVal wID As Integer, ByVal wFlags As Integer) As Integer
Private Declare Function GetMenuItemCount Lib “user32″ (ByVal hMenu As Integer) As Integer
Private Declare Function InsertMenu Lib “user32″ Alias “InsertMenuA” (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As String) As Integer
Private Declare Function IsWindow Lib “user32″ (ByVal hwnd As Integer) As Integer
Private Delegate Function SubClassProcDelegate(ByVal hwnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Declare Function SetCWPMSGHook Lib “dscwpmsg” (ByVal hwnd As Integer, ByVal AdrCWP As Integer, ByVal AdrMSG As SubClassProcDelegate) As Integer
Declare Function OpenProcess Lib “kernel32″ (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Declare Function CloseHandle Lib “kernel32″ Alias “CloseHandle” (ByVal hObject As Integer) As Integer
Declare Function ReadProcessMemory Lib “kernel32″ (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As String, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Private Shared hmen, hNote, hsub As Integer

Private Enum WindowStyles
WS_OVERLAPPED = &H0
WS_POPUP = &H80000000
WS_CHILD = &H40000000
WS_MINIMIZE = &H20000000
WS_VISIBLE = &H10000000
WS_DISABLED = &H8000000
WS_CLIPSIBLINGS = &H4000000
WS_CLIPCHILDREN = &H2000000
WS_MAXIMIZE = &H1000000
WS_BORDER = &H800000
WS_DLGFRAME = &H400000
WS_VSCROLL = &H200000
WS_HSCROLL = &H100000
WS_SYSMENU = &H80000
WS_THICKFRAME = &H40000
WS_GROUP = &H20000
WS_TABSTOP = &H10000
WS_MINIMIZEBOX = &H20000
WS_MAXIMIZEBOX = &H10000
WS_CAPTION = WS_BORDER Or WS_DLGFRAME
WS_TILED = WS_OVERLAPPED
WS_ICONIC = WS_MINIMIZE
WS_SIZEBOX = WS_THICKFRAME
WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
WS_OVERLAPPEDWINDOW = WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
WS_POPUPWINDOW = WS_POPUP Or WS_BORDER Or WS_SYSMENU
WS_CHILDWINDOW = WS_CHILD
End Enum

Public Enum Gameover
WON = 1
LOST = 2
End Enum

Public Shared Sub AddMenus(ByVal MenuTitle As String, ByVal MenuItems As Collection)
hmen = GetMenu(hNote)
hsub = CreatePopupMenu
For Each menuitem As String In MenuItems
Offset += 1
AppendMenu(hsub, MF_STRING, Offset, menuitem)
Next
InsertMenu(hmen, 10, MF_BYPOSITION Or MF_POPUP, hsub, MenuTitle)
DrawMenuBar(hNote)
Offset = 2000
End Sub

Public Shared Sub SetHook(ByVal WindowTitle As String)
hNote = FindWindow(vbNullString, WindowTitle)
If IsWindow(hNote) = 0 Then
Do Until IsWindow(hNote)
hNote = FindWindow(WindowTitle, vbNullString)
System.Windows.Forms.Application.DoEvents()
Loop
End If
Call SetCWPMSGHook(hNote, 0, AddressOf Callback)
End Sub

Private Shared Function Callback(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Select Case wMsg
Case WM_COMMAND
Debug.Print(wParam)
If wParam = 2001 Then
MsgBox(“a”)
ElseIf wParam = 2002 Then
MsgBox(“b”)
ElseIf wParam = 2003 Then
MsgBox(“c”)
ElseIf wParam = 2004 Then
MsgBox(“d”)
End If
End Select
End Function

End Class

VB Net – Change MSN Status (Status Spam)

Public Shared Sub ChangeStatus(ByVal count As Integer)
Dim oMessenger As MessengerAPI.Messenger
oMessenger = New MessengerAPI.Messenger
Dim times As Integer = 0
Do
times += 1
oMessenger.MyStatus = MISTATUS.MISTATUS_ONLINE
System.Threading.Thread.Sleep(100)
oMessenger.MyStatus = MISTATUS.MISTATUS_INVISIBLE
System.Threading.Thread.Sleep(100)
Loop Until times = count
End Sub

Usage:  ChangeStatus(20)

VB Net – MSN Block Spam

Public Shared Sub BlockSpam(ByVal count As Integer, ByVal contact As String)
Dim done As Boolean = False
Dim oMessenger As MessengerAPI.Messenger
oMessenger = New MessengerAPI.Messenger
Dim msncontact As IMessengerContact
Dim msncontacts As IMessengerContacts
msncontacts = oMessenger.MyContacts
For Each msncontact In msncontacts
If msncontact.SigninName = contact Then
Dim times As Integer = 0
done = True
Do
times += 1
msncontact.Blocked = True
System.Threading.Thread.Sleep(400)
msncontact.Blocked = False
System.Threading.Thread.Sleep(400)
Loop Until times = count
MessageBox.Show(“Done”, “MSN Block Spam”, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Next
MessageBox.Show(“Error, contact matching that email was not found”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Sub

Usage: BlockSpam(10, “spiderman@hotmail.com”)

VB Net – MSN Nudge Spam

Public Shared Sub NudgeSpam(ByVal count As String, ByVal contact As String)
Dim oMessenger As MessengerAPI.Messenger
oMessenger = New MessengerAPI.Messenger
Dim msncontact As IMessengerContact
Dim msncontacts As IMessengerContacts
msncontacts = oMessenger.MyContacts
For Each msncontact In msncontacts
If msncontact.SigninName = contact Then
Dim times As Integer = 0
Dim wnd As Integer = “0″
wnd = FindWindowByCaption(0, msncontact.FriendlyName & ” – Conversation”)
If wnd = 0 Then
Dim Processes() As System.Diagnostics.Process
Processes = System.Diagnostics.Process.GetProcessesByName(“msnmsgr”)
wnd = Processes(0).MainWindowHandle
End If
Do
times += 1
SendMessage(wnd, WM_COMMAND, CMD_NUDGE, 0)
Loop Until times = count
MessageBox.Show(“Done”, “MSN Nudge Spam”, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
Next
MessageBox.Show(“Error, contact matching that email was not found”, “Error:”, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Sub

Usage: NudgeSpam(100, “spiderman@hotmail.com”)

Note: Need to have a patched MSN that removes nudge timer

VB Net – List MSN Contacts

Public Shared Sub Getcontacts(ByVal ListViewAdd As ListView)
ListViewAdd.View = View.Details
ListViewAdd.FullRowSelect = True
ListViewAdd.GridLines = True
ListViewAdd.Columns.Clear()
ListViewAdd.Items.Clear()
ListViewAdd.Columns.Add(“Friendly Name”, 1, HorizontalAlignment.Left)
ListViewAdd.Columns.Add(“Status”, 1, HorizontalAlignment.Left)
ListViewAdd.Columns.Add(“Email Address”, 1, HorizontalAlignment.Left)
ListViewAdd.Columns.Add(“Something”, 1, HorizontalAlignment.Left)
ListViewAdd.Columns.Item(0).Width = ListViewAdd.Width – 160 – 5
ListViewAdd.Columns.Item(1).Width = 60
Dim oMessenger As MessengerAPI.Messenger
oMessenger = New MessengerAPI.Messenger
Dim msncontact As IMessengerContact
Dim msncontacts As IMessengerContacts
msncontacts = oMessenger.MyContacts

Dim Awaylist As New ListViewGroup
Dim BRBlist As New ListViewGroup
Dim Busylist As New ListViewGroup
Dim Idlelist As New ListViewGroup
Dim Invisilist As New ListViewGroup
Dim Offlist As New ListViewGroup
Dim Phonelist As New ListViewGroup
Dim Lunchlist As New ListViewGroup
Dim Unklist As New ListViewGroup
For Each msncontact In msncontacts
Dim item1 As New ListViewItem(msncontact.FriendlyName)
Dim Status As String = “Offline”
If msncontact.Status = MISTATUS.MISTATUS_AWAY Then
Status = “Away”
ElseIf msncontact.Status = MISTATUS.MISTATUS_BE_RIGHT_BACK Then
Status = “BRB”
ElseIf msncontact.Status = MISTATUS.MISTATUS_BUSY Then
Status = “Busy”
ElseIf msncontact.Status = MISTATUS.MISTATUS_IDLE Then
Status = “Idle”
ElseIf msncontact.Status = MISTATUS.MISTATUS_INVISIBLE Then
Status = “Invisible”
ElseIf msncontact.Status = MISTATUS.MISTATUS_OFFLINE Then
Status = “Offline”
ElseIf msncontact.Status = MISTATUS.MISTATUS_ON_THE_PHONE Then
Status = “On Phone”
ElseIf msncontact.Status = MISTATUS.MISTATUS_ONLINE Then
Status = “Online”
ElseIf msncontact.Status = MISTATUS.MISTATUS_OUT_TO_LUNCH Then
Status = “Lunch”
ElseIf msncontact.Status = MISTATUS.MISTATUS_UNKNOWN Then
Status = “Unknown”
End If
item1.SubItems.Add(Status)
item1.SubItems.Add(msncontact.SigninName)
If Status = “Away” Then
Awaylist.Items.Add(item1)
item1.SubItems(0).BackColor = Color.Red
ElseIf Status = “BRB” Then
BRBlist.Items.Add(item1)
item1.SubItems(0).BackColor = Color.LightGray
ElseIf Status = “Busy” Then
Busylist.Items.Add(item1)
item1.SubItems(0).BackColor = Color.Orange
ElseIf Status = “Idle” Then
Idlelist.Items.Add(item1)
item1.SubItems(0).BackColor = Color.Red
ElseIf Status = “Invisible” Then
Invisilist.Items.Add(item1)
item1.SubItems(0).BackColor = Color.Peru
ElseIf Status = “Offline” Then
Offlist.Items.Add(item1)
item1.SubItems(0).BackColor = Color.Peru
ElseIf Status = “On Phone” Then
Phonelist.Items.Add(item1)
item1.SubItems(0).BackColor = Color.Blue
item1.SubItems(0).ForeColor = Color.Pink
ElseIf Status = “Online” Then
ListViewAdd.Items.Add(item1)
item1.SubItems(0).BackColor = Color.Black
item1.SubItems(0).ForeColor = Color.Orange
ElseIf Status = “Lunch” Then
item1.SubItems(0).BackColor = Color.Blue
item1.SubItems(0).ForeColor = Color.Pink
Lunchlist.Items.Add(item1)
ElseIf Status = “Unknown” Then
Unklist.Items.Add(item1)
item1.SubItems(0).BackColor = Color.Black
item1.SubItems(0).ForeColor = Color.Red
End If

Next
ListViewAdd.Items.AddRange(BRBlist.Items)
ListViewAdd.Items.AddRange(Busylist.Items)
ListViewAdd.Items.AddRange(Awaylist.Items)
ListViewAdd.Items.AddRange(Idlelist.Items)
ListViewAdd.Items.AddRange(Phonelist.Items)
ListViewAdd.Items.AddRange(Lunchlist.Items)
ListViewAdd.Items.AddRange(Invisilist.Items)
ListViewAdd.Items.AddRange(Unklist.Items)
ListViewAdd.Items.AddRange(Offlist.Items)
ListViewAdd.Columns.Item(2).AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent)
End Sub

Usage:

Getcontacts(ListView1)
ListView1.Columns(0).Width = ListView1.Width – ListView1.Columns(1).Width – ListView1.Columns(2).Width – 19
ListView1.Height = Me.Height – GroupBox2.Height – 50

Next Page »