Code:
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Public Class Form1
Dim Processes() As System.Diagnostics.Process
Dim baseAddress As IntPtr
Dim ResolutionPointerOffsets() As IntPtr = {&H8C}
Dim ResolutionPointer As IntPtr = &HECC4B0
Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer() As Byte, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As IntPtr
Private Declare Function ReadIntegerMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Private Declare Function WriteIntegerMemory Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Processes = System.Diagnostics.Process.GetProcessesByName("sc2")
End Sub
Public Function FollowPointer(ByVal BaseAddress As IntPtr, ByVal StartAddrress As IntPtr, ByVal offsets() As IntPtr) As IntPtr
If Processes.Length > 0 Then
If Processes(0).HasExited = False Then
Dim NextAddress As IntPtr = -1
Dim i As Integer
For i = 0 To UBound(offsets)
Dim output(3) As Byte
If NextAddress = -1 Then
ReadProcessMemory(Processes(0).Handle, (BaseAddress + StartAddrress), output, 4, 0)
ElseIf NextAddress = 0 Then
Else
ReadProcessMemory(Processes(0).Handle, (NextAddress), output, 4, 0)
End If
NextAddress = BitConverter.ToInt32(output, 0) + offsets(i)
Next
FollowPointer = NextAddress
Else
End If
End If
End Function
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Processes.Length = 0 Then
Processes = System.Diagnostics.Process.GetProcessesByName("sc2")
Label5.Text = "Searching for SC2 Process!"
ElseIf Processes.Length > 0 Then
If Processes(0).HasExited = True Then
Array.Resize(Processes, 0)
Else
Label5.Text = "SC2 Process Found!"
baseAddress = Processes(0).MainModule.BaseAddress
Dim targetAddress As IntPtr = FollowPointer(baseAddress, ResolutionPointer, ResolutionPointerOffsets)
Dim tHor, tVer As Integer
ReadIntegerMemory(Processes(0).Handle, targetAddress, tHor, 4, 4)
ReadIntegerMemory(Processes(0).Handle, targetAddress + 4, tVer, 4, 4)
If tHor = TextBox1.Text And tVer = TextBox2.Text Then
Label6.Text = "Found Resolution, Rewriting"
tHor = TextBox3.Text
tVer = TextBox4.Text
WriteIntegerMemory(Processes(0).Handle, targetAddress, tHor, 4, 4)
WriteIntegerMemory(Processes(0).Handle, targetAddress + 4, tVer, 4, 4)
ElseIf tHor = TextBox3.Text And tVer = TextBox4.Text Then
Label6.Text = "Rewrite Successful"
Else
Label6.Text = "Cant Find Resolution"
End If
End If
End If
End Sub
End Class
modified the address to support new patch - http://theinterwebs.doesntexist.org/CustomRes.exe
_________________
Resident Jester -
Flawless Widescreen -
Widescreen gaming the way it should be.
[
Steam Profile]
Want to keep Flawless Widescreen alive?
Donate Here