Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Visual Basic Programming › [Help] Pattern scanning

[Help] Pattern scanning

Posts 1–15 of 28 · Page 1 of 2
pyton789
pyton789
[Help] Pattern scanning
Hi I have been wondering how to search for a pattern in an array of byte in a process.
For example searching for:
Code:
E8 ???????? 83C4 1C 80???? 10 00 74 39
In CoD.
What it is supposed to do is make it unnessecary to update my program when the game updates, because the program will atomaticly find the new offset.
I actually allready found a way to search for patterns, but it doesn't work since my pattern contains ?'s(wildcards).

Here is the code I found on the web. Credits to iNTANGiBLE.

Code:
Public Declare Function OpenProcess Lib "KERNEL32" _
    (ByVal DesiredAccess As Int32, _
     ByVal InheritHandle As Boolean, _
     ByVal ProcessId As Int32) _
    As Int32

    Private Declare Function ReadProcessMemory Lib "KERNEL32" _
    (ByVal Handle As Int32, _
     ByVal address As Int32, _
     ByRef Value As Int32, _
     Optional ByVal Size As Int32 = 4, _
     Optional ByVal lpNumberOfBytesWritten As Int64 = 0) _
    As Long

    Public PROCESS_VM_OPERATION As Int32 = 8
    Public PROCESS_VM_READ As Int32 = 16
    Public PROCESS_VM_WRITE As Int32 = 32

 Private process_id As Int32 = 0
    Public pHandle As Integer = 0

    Public Function GetProcessId(ByVal game_name As String) As Boolean
        Dim Processes() As Process = Process.GetProcesses
        Dim process_name As String
        Dim i As Byte
        For i = LBound(Processes) To UBound(Processes)
            process_name = Processes(i).ProcessName
            If process_name = game_name Then
                process_id = Processes(i).Id
                pHandle = OpenProcess(PROCESS_VM_OPERATION + PROCESS_VM_WRITE + PROCESS_VM_READ, False, process_id)
                Return True
            End If
        Next
        If process_id = 0 Then
            Return False
        End If
        Return False
    End Function

 Public Function ReadByte(ByVal address As Int32) As Integer
        Dim value As Integer
        ReadProcessMemory(pHandle, address, value, 1, 0)
        Return value
    End Function

Public Function AOBSCAN(ByVal GameName As String, ByVal ModuleName As String, ByVal Signature As Byte()) As Integer
        Dim BaseAddress, EndAddress As Int32
        For Each PM As ProcessModule In Process.GetProcessesByName(GameName)(0).Modules
            If ModuleName = PM.ModuleName Then
                BaseAddress = PM.BaseAddress
                EndAddress = BaseAddress + PM.ModuleMemorySize
            End If
        Next
        Dim curAddr As Int32 = BaseAddress
        Do
            For i As Integer = 0 To Signature.Length - 1
                If ReadByte(curAddr + i) = Signature(i) Then
                    If i = Signature.Length - 1 Then
                        MsgBox(curAddr.ToString("X"))
                        Return curAddr
                    End If
                    Continue For
                End If
                Exit For
            Next
            curAddr += 1
        Loop While curAddr < EndAddress
        Return 0
    End Function
How to use it:

Code:
If GetProcessId("CoD something") = False Then
            Exit Sub
        Else : AOBSCAN("CoD", "CoD.exe", New Byte() {&HFF, &H25, &HBC, &H30, &HF, &H1, &H75, &H2})
        End If
I simply am not a good enough coder to make the code support wildcards so I am hoping that you can help me.
#1 · 15y ago
♪~ ᕕ(ᐛ)ᕗ
♪~ ᕕ(ᐛ)ᕗ
well, try to put em as a string value....
Code:
New Byte() {&H98, "??", &H5, &H6A}
yes it will probably work
#2 · edited 15y ago · 15y ago
pyton789
pyton789
Quote Originally Posted by 3Li0 View Post
well, try to put em as a string value....
Code:
New Byte() {&H98, "??", &H5, &H6A}
yes it will probably work
Thanks but it didn't work.

The error is in danish, but it says: The conversion from the string "??" to byte is invalid.
#3 · 15y ago
♪~ ᕕ(ᐛ)ᕗ
♪~ ᕕ(ᐛ)ᕗ
Quote Originally Posted by pyton789 View Post
Thanks but it didn't work.

The error is in danish, but it says: The conversion from the string "??" to byte is invalid.
well, open Olly and find the addie which is compatible with your siggy.Then right click and go to:
Binary->Copy
And paste the bytes on notepad....The bytes will probably not change during the updates..Depends on your current address
#4 · 15y ago
pyton789
pyton789
Quote Originally Posted by 3Li0 View Post


well, open Olly and find the addie which is compatible with your siggy.Then right click and go to:
Binary->Copy
And paste the bytes on notepad....The bytes will probably not change during the updates..Depends on your current address
The problem is that it is a call so it might change after an update.
Code:
E8 13 9E 29 00
That is what I got from binary copy, but know I don't know if:
Is a calls binary calculate by
1. How far it jumps or.....................(For example the call is at current addres + 13AE)
2. Where it jumps to......................(F.x. call is at 7589AE7)

If it is 1 then will the new sig work, but if its 2 then I need to use wildcards.



Edit: I guess that will work, but I have another problem:
How to use the address after the program has found it. I mean the function will display the function in a msgBox, but I need to use for memory hacking.
So how should I do this?
It would be nice if it was possible to do something like this:
Code:
Dim Something = "&H" + AOBSCAN("BlackOps", "BlackOps.exe", New Byte() {&HE8, &H13, &H9E, &H29, &H0, &H83, &HC4, &H1C})
#5 · edited 15y ago · 15y ago
♪~ ᕕ(ᐛ)ᕗ
♪~ ᕕ(ᐛ)ᕗ
Quote Originally Posted by pyton789 View Post
The problem is that it is a call so it might change after an update.
Code:
E8 13 9E 29 00
That is what I got from binary copy, but know I don't know if:
Is a calls binary calculate by
1. How far it jumps or.....................(For example the call is at current addres + 13AE)
2. Where it jumps to......................(F.x. call is at 7589AE7)

If it is 1 then will the new sig work, but if its 2 then I need to use wildcards.



Edit: I guess that will work, but I have another problem:
How to use the address after the program has found it. I mean the function will display the function in a msgBox, but I need to use for memory hacking.
So how should I do this?
It would be nice if it was possible to do something like this:
Code:
Dim Something = "&H" + AOBSCAN("BlackOps", "BlackOps.exe", New Byte() {&HE8, &H13, &H9E, &H29, &H0, &H83, &HC4, &H1C})
delete the msgbox func and you're done. If it doesn't have the &H when it will be returned, then add the "&H" & Hex(blablabla)
#6 · 15y ago
pyton789
pyton789
Quote Originally Posted by 3Li0 View Post


delete the msgbox func and you're done. If it doesn't have the &H when it will be returned, then add the "&H" & Hex(blablabla)
Thanks 3lio It works but I have one last problem:
Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If GetProcessId("BlackOps") = False Then
            Exit Sub
        Else
            Dim a = AOBSCAN("BlackOps", "BlackOps.exe", New Byte() {&HE8, &H13, &H9E, &H29, &H0, &H83, &HC4, &H1C})
            Dim aa = a + &H40
            Dim ab = a + &HF7
        End If
    End Sub
If I dim it inside of a sub then I won't be able to use it inside of another sub.
Is there anything I can use instead of "dim" or do I need to put the code somewhere else?
#7 · 15y ago
Jason
Jason
To create a global variable declare it at class level rather than in a method body. I.e

[highlight=vb.net]
Public Class Form1
Private a = AOBSCAN("BlackOps", "BlackOps.exe", New Byte() {&HE8, &H13, &H9E, &H29, &H0, &H83, &HC4, &H1C})

'...
End Class
[/highlight]
#8 · 15y ago
pyton789
pyton789
Quote Originally Posted by Jason View Post
To create a global variable declare it at class level rather than in a method body. I.e

[highlight=vb.net]
Public Class Form1
Private a = AOBSCAN("BlackOps", "BlackOps.exe", New Byte() {&HE8, &H13, &H9E, &H29, &H0, &H83, &HC4, &H1C})

'...
End Class
[/highlight]
[highlight=vb.net]
Private a = AOBSCAN("BlackOps", "BlackOps.exe", New Byte() {&HE8, &H13, &H9E, &H29, &H0, &H83, &HC4, &H1C})[/highlight]

But I did
[highlight=vb.net]MsgBox(a)[/highlight]
And it was zero
#9 · 15y ago
♪~ ᕕ(ᐛ)ᕗ
♪~ ᕕ(ᐛ)ᕗ
Quote Originally Posted by pyton789 View Post
[highlight=vb.net]
Private a = AOBSCAN("BlackOps", "BlackOps.exe", New Byte() {&HE8, &H13, &H9E, &H29, &H0, &H83, &HC4, &H1C})[/highlight]

But I did
[highlight=vb.net]MsgBox(a)[/highlight]
And it was zero
It won't solve anything but try to put 'Dim' instead of Public, and make it as a Integer...
Code:
Dim a As Integer = blalblablalblalbla
You can use Dim outside Sub's or function's....
#10 · 15y ago
Jason
Jason
Did you make sure to actually re-assign the value of a in the sub-procedure? All class-level variables evaluate original values as the form is starting up. If you want to update it's value, you'll have to reassign it.
#11 · 15y ago
master131
[MPGH]master131
Replace AOBScan with this:
Code:
Public Function AOBSCAN(ByVal GameName As String, ByVal ModuleName As String, ByVal Signature As Byte(), ByVal Mask As Byte()) As Integer
        Dim BaseAddress, EndAddress As Int32
        For Each PM As ProcessModule In Process.GetProcessesByName(GameName)(0).Modules
            If ModuleName = PM.ModuleName Then
                BaseAddress = PM.BaseAddress
                EndAddress = BaseAddress + PM.ModuleMemorySize
            End If
        Next
        Dim curAddr As Int32 = BaseAddress
        Do
            For i As Integer = 0 To Signature.Length - 1
                If ReadByte(curAddr + i) = Signature(i) or Mask(i) = &H0 Then
                    If i = Signature.Length - 1 Then
                        MsgBox(curAddr.ToString("X"))
                        Return curAddr
                    End If
                    Continue For
                End If
                Exit For
            Next
            curAddr += 1
        Loop While curAddr < EndAddress
        Return 0
    End Function
Usage:
AOBScan("BlackOps", "BlackOps.exe", New Byte() {&HFF, &H25, &HBC, &H30, &HF, &H1, &H75, &H2}, New Byte() {&HFF, &H0, &HFF, &H0, &HFF, &H0, &H0, &H0})

The last parameter is a masking parameter. &H0 means that the byte is optional and &HFF (or any byte value other than &H0) means that the byte is required. Make sure the Signature and the Mask are the same length. I don't understand why the logic in that is so hard to figure out. :/
#12 · edited 15y ago · 15y ago
pyton789
pyton789
Thanks master131.
[highlight=VB.net]Module Module3
Public Declare Function OpenProcess Lib "KERNEL32" (ByVal DesiredAccess As Int32, ByVal InheritHandle As Boolean, ByVal ProcessId As Int32) As Int32
Private Declare Function ReadProcessMemory Lib "KERNEL32" (ByVal Handle As Int32, ByVal address As Int32, ByRef Value As Int32, Optional ByVal Size As Int32 = 4, Optional ByVal lpNumberOfBytesWritten As Int64 = 0) As Long

Public PROCESS_VM_OPERATION As Int32 = 8
Public PROCESS_VM_READ As Int32 = 16
Public PROCESS_VM_WRITE As Int32 = 32

Private process_id As Int32 = 0
Public pHandle As Integer = 0

Public Function GetProcessId(ByVal game_name As String) As Boolean
Dim Processes() As Process = Process.GetProcesses
Dim process_name As String
Dim i As Byte
For i = LBound(Processes) To UBound(Processes)
process_name = Processes(i).ProcessName
If process_name = game_name Then
process_id = Processes(i).Id
pHandle = OpenProcess(PROCESS_VM_OPERATION + PROCESS_VM_WRITE + PROCESS_VM_READ, False, process_id)
Return True
End If
Next
If process_id = 0 Then
Return False
End If
Return False
End Function

Public Function ReadByte(ByVal address As Int32) As Integer
Dim value As Integer
ReadProcessMemory(pHandle, address, value, 1, 0)
Return value
End Function


Public Function AOBSCAN(ByVal GameName As String, ByVal ModuleName As String, ByVal Signature As Byte(), ByVal Mask As Byte()) As Integer
Dim BaseAddress, EndAddress As Int32
For Each PM As ProcessModule In Process.GetProcessesByName(GameName)(0).Modules
If ModuleName = PM.ModuleName Then
BaseAddress = PM.BaseAddress
EndAddress = BaseAddress + PM.ModuleMemorySize
End If
Next
Dim curAddr As Int32 = BaseAddress
Do
For i As Integer = 0 To Signature.Length - 1
If ReadByte(curAddr + i) = Signature(i) Or Mask(i) = &H0 Then
If i = Signature.Length - 1 Then
MsgBox(curAddr.ToString("X"))
Return curAddr
End If
Continue For
End If
Exit For
Next
curAddr += 1
Loop While curAddr < EndAddress
Return 0
End Function

End Module[/highlight]
That is how the module looks. It can scan for patterns and it supports wildcards.

How to use:
[highlight=VB.net]If GetProcessId("BlackOps") = False Then
Exit Sub
Else : AOBSCAN("BlackOps", "BlackOps.exe", New Byte() {&HE8, &H13, &H9E, &H29, &H0, &H83, &HC4, &H1C}, New Byte() {&HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF})
End If[/highlight]

The problem is:
It returns the address in a msgbox without "&H" in front of it.
I would like it to be returned like readmemory.(You know Return Buff*)
That would allow me to use the function like this:
[highlight=VB.net]Dim a as integer = AOBSCAN("BlackOps", "BlackOps.exe", New Byte() {&HE8, &H13, &H9E, &H29, &H0, &H83, &HC4, &H1C}, New Byte() {&HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF})[/highlight]
#13 · 15y ago
Jason
Jason
You declared a as an Integer, which automatically evaluates the hex (&Hxxxxx) into an integer value. If you want it to be returned as Hex create it as string so it doesn't evaluate the hex.
#14 · 15y ago
Hassan
Hassan
Simply Use Built-In Hex Function:

Code:
Hex(Number / String To Convert)
#15 · 15y ago
Posts 1–15 of 28 · Page 1 of 2

Post a Reply

Tags for this Thread

None