[align=center]
[b][SIZE=4]هذان موقعان قويان
مواقع التحويل بين VB.NET و #C
تأكد من اختيار التحويل ،، من و الى
http://www.carlosag.net/Tools/CodeTranslator
http://www.developerfusion.com/tools/con...harp-to-vb
هذا كود التحويل من الموقع الاول
كود :
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Diagnostics
Imports System.Threading
Imports System.Runtime.InteropServices
Namespace Sojaner.WindowsFormsApplication1
Public Class RegularMemoryScan
Private Const ReadStackSize As Integer = 20480
'A byte is 8 bits long memory defined variable.
'A 16 bit variable (Like char) is made up of 16 bits of memory and so 16/8 = 2 bytes of memory.
Private Const Int16BytesCount As Integer = (16 / 8)
'A 32 bit variable (Like int) is made up of 32 bits of memory and so 32/8 = 4 bytes of memory.
Private Const Int32BytesCount As Integer = (32 / 8)
'A 34 bit variable (Like long) is made up of 64 bits of memory and so 64/8 = 8 bytes of memory.
Private Const Int64BytesCount As Integer = (64 / 8)
#End Region
#Region "Global fields"
Private reader As ProcessMemoryReader
'Start and End addresses to be scaned.
Private baseAddress As IntPtr
Private lastAddress As IntPtr
'New thread object to run the scan in
Private thread As Thread
#End Region
#Region "Delegate and Event objects"
Public Delegate Sub ScanProgressedEventHandler(ByVal sender As Object, ByVal e As ScanProgressChangedEventArgs)
Public Event ScanProgressChanged As ScanProgressedEventHandler
'Delegate and Event objects for raising the ScanCompleted event.
Public Delegate Sub ScanCompletedEventHandler(ByVal sender As Object, ByVal e As ScanCompletedEventArgs)
Public Event ScanCompleted As ScanCompletedEventHandler
'Delegate and Event objects for raising the ScanCanceled event.
Public Delegate Sub ScanCanceledEventHandler(ByVal sender As Object, ByVal e As ScanCanceledEventArgs)
Public Event ScanCanceled As ScanCanceledEventHandler
#End Region
#Region "Methods"
Public Sub New(ByVal process As Process, ByVal StartAddress As Integer, ByVal EndAddress As Integer)
MyBase.New
'Set the reader object an instant of the ProcessMemoryReader class.
reader = New ProcessMemoryReader
'Set the ReadProcess of the reader object to process passed to this method
'to define the process we are going to scan its memory.
reader.ReadProcess = process
'Set the Start and End addresses of the scan to what is wanted.
baseAddress = CType(StartAddress,IntPtr)
lastAddress = CType(EndAddress,IntPtr)
'The scan starts from baseAddress,
'and progresses up to EndAddress.
End Sub
#Region "Public methods"
Public Sub StartScanForInt16(ByVal Int16Value As Int16)
'Check if the thread is already defined or not.
If (Not (thread) Is Nothing) Then
'If the thread is already defined and is Alive,
If thread.IsAlive Then
'raise the event that shows that the last scan task is canceled
'(because a new task is going to be started as wanted),
Dim cancelEventArgs As ScanCanceledEventArgs = New ScanCanceledEventArgs
ScanCanceled(Me, cancelEventArgs)
'and then abort the alive thread and so cancel last scan task.
thread.Abort
End If
End If
'Set the thread object as a new instant of the Thread class and pass
'a new ParameterizedThreadStart class object with the needed method passed to it
'to run in the new thread.
thread = New Thread(New ParameterizedThreadStart(Int16Scaner))
'Start the new thread and set the 32 bit value to look for.
thread.Start(Int16Value)
End Sub
'Get ready to scan the memory for the 32 bit value.
Public Sub StartScanForInt32(ByVal Int32Value As Int32)
'Check if the thread is already defined or not.
If (Not (thread) Is Nothing) Then
'If the thread is already defined and is Alive,
If thread.IsAlive Then
'raise the event that shows that the last scan task is canceled
'(because a new task is going to be started as wanted),
Dim cancelEventArgs As ScanCanceledEventArgs = New ScanCanceledEventArgs
ScanCanceled(Me, cancelEventArgs)
'and then abort the alive thread and so cancel last scan task.
thread.Abort
End If
End If
'Set the thread object as a new instant of the Thread class and pass
'a new ParameterizedThreadStart class object with the needed method passed to it
'to run in the new thread.
thread = New Thread(New ParameterizedThreadStart(Int32Scaner))
'Start the new thread and set the 32 bit value to look for.
thread.Start(Int32Value)
End Sub
'Get ready to scan the memory for the 64 bit value.
Public Sub StartScanForInt64(ByVal Int64Value As Int64)
'Check if the thread is already defined or not.
If (Not (thread) Is Nothing) Then
'If the thread is already defined and is Alive,
If thread.IsAlive Then
'raise the event that shows that the last scan task is canceled
'(because a new task is going to be started as wanted),
Dim cancelEventArgs As ScanCanceledEventArgs = New ScanCanceledEventArgs
ScanCanceled(Me, cancelEventArgs)
'and then abort the alive thread and so cancel last scan task.
thread.Abort
End If
End If
'Set the thread object as a new instant of the Thread class and pass
'a new ParameterizedThreadStart class object with the needed method passed to it
'to run in the new thread.
thread = New Thread(New ParameterizedThreadStart(Int64Scaner))
'Start the new thread and set the 32 bit value to look for.
thread.Start(Int64Value)
End Sub
'Cancel the scan started.
Public Sub CancelScan()
'Raise the event that shows that the last scan task is canceled as user asked,
Dim cancelEventArgs As ScanCanceledEventArgs = New ScanCanceledEventArgs
ScanCanceled(Me, cancelEventArgs)
'and then abort the thread that scanes the memory.
thread.Abort
End Sub
#End Region
#Region "Private methods"
Private Sub Int16Scaner(ByVal int16Object As Object)
'The difference of scan start point in all loops except first loop,
'that doesn't have any difference, is type's Bytes count minus 1.
Dim arraysDifference As Integer = (Int16BytesCount - 1)
'Get the short value out of the object to look for it.
Dim int16Value As Int16 = CType(int16Object,Int16)
'Define a List object to hold the found memory addresses.
Dim finalList As List(Of Integer) = New List(Of Integer)
'Open the pocess to read the memory.
reader.OpenProcess
'Create a new instant of the ScanProgressEventArgs class to be used to raise the
'ScanProgressed event and pass the percentage of scan, during the scan progress.
Dim scanProgressEventArgs As ScanProgressChangedEventArgs
'Calculate the size of memory to scan.
Dim memorySize As Integer = CType((CType(lastAddress,Integer) - CType(baseAddress,Integer)),Integer)
'If more that one block of memory is requered to be read,
If (memorySize >= ReadStackSize) Then
'Count of loops to read the memory blocks.
Dim loopsCount As Integer = (memorySize / ReadStackSize)
'Look to see if there is any other bytes let after the loops.
Dim outOfBounds As Integer = (memorySize Mod ReadStackSize)
'Set the currentAddress to first address.
Dim currentAddress As Integer = CType(baseAddress,Integer)
'This will be used to check if any bytes have been read from the memory.
Dim bytesReadSize As Integer
'Set the size of the bytes blocks.
Dim bytesToRead As Integer = ReadStackSize
'An array to hold the bytes read from the memory.
Dim array() As Byte
'Progress percentage.
Dim progress As Integer
Dim i As Integer = 0
Do While (i < loopsCount)
'Calculte and set the progress percentage.
'Prepare and set the ScanProgressed event and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(progress)
ScanProgressChanged(Me, scanProgressEventArgs)
'Read the bytes from the memory.
array = reader.ReadProcessMemory(CType(currentAddress,IntPtr), CType(bytesToRead,UInteger), bytesReadSize)
'If any byte is read from the memory (there has been any bytes in the memory block),
If (bytesReadSize > 0) Then
'Loop through the bytes one by one to look for the values.
Dim j As Integer = 0
Do While (j _
< (array.Length - arraysDifference))
'If any value is equal to what we are looking for,
If (BitConverter.ToInt16(array, j) = int16Value) Then
'add it's memory address to the finalList.
finalList.Add((j + CType(currentAddress,Integer)))
End If
j = (j + 1)
Loop
End If
'Move currentAddress after the block already scaned, but
'move it back some steps backward (as much as arraysDifference)
'to avoid loosing any values at the end of the array.
currentAddress = (currentAddress _
+ (array.Length - arraysDifference))
'Set the size of the read block, bigger, to the steps backward.
'Set the size of the read block, to fit the back steps.
bytesToRead = (ReadStackSize + arraysDifference)
i = (i + 1)
Loop
'If there is any more bytes than the loops read,
If (outOfBounds > 0) Then
'Read the additional bytes.
Dim outOfBoundsBytes() As Byte = reader.ReadProcessMemory(CType(currentAddress,IntPtr), CType((CType(lastAddress,Integer) - currentAddress),UInteger), bytesReadSize)
'If any byte is read from the memory (there has been any bytes in the memory block),
If (bytesReadSize > 0) Then
'Loop through the bytes one by one to look for the values.
Dim j As Integer = 0
Do While (j _
< (outOfBoundsBytes.Length - arraysDifference))
'If any value is equal to what we are looking for,
If (BitConverter.ToInt16(outOfBoundsBytes, j) = int16Value) Then
'add it's memory address to the finalList.
finalList.Add((j + CType(currentAddress,Integer)))
End If
j = (j + 1)
Loop
End If
End If
End If
'If the block could be read in just one read,
'Calculate the memory block's size.
Dim blockSize As Integer = (memorySize Mod ReadStackSize)
'Set the currentAddress to first address.
Dim currentAddress As Integer = CType(baseAddress,Integer)
'Holds the count of bytes read from the memory.
Dim bytesReadSize As Integer
'If the memory block can contain at least one 16 bit variable.
If (blockSize > Int16BytesCount) Then
'Read the bytes to the array.
Dim array() As Byte = reader.ReadProcessMemory(CType(currentAddress,IntPtr), CType(blockSize,UInteger), bytesReadSize)
'If any byte is read,
If (bytesReadSize > 0) Then
'Loop through the array to find the values.
Dim j As Integer = 0
Do While (j _
< (array.Length - arraysDifference))
'If any value equals the value we are looking for,
If (BitConverter.ToInt16(array, j) = int16Value) Then
'add it to the finalList.
finalList.Add((j + CType(currentAddress,Integer)))
End If
j = (j + 1)
Loop
End If
End If
'Close the handle to the process to avoid process errors.
reader.CloseHandle
'Prepare the ScanProgressed and set the progress percentage to 100% and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(100)
ScanProgressChanged(Me, scanProgressEventArgs)
'Prepare and raise the ScanCompleted event.
Dim scanCompleteEventArgs As ScanCompletedEventArgs = New ScanCompletedEventArgs(finalList.ToArray)
ScanCompleted(Me, scanCompleteEventArgs)
End Sub
'The memory scan method for the 32 bit values.
Private Sub Int32Scaner(ByVal int32Object As Object)
'The difference of scan start point in all loops except first loop,
'that doesn't have any difference, is type's Bytes count minus 1.
Dim arraysDifference As Integer = (Int32BytesCount - 1)
'Get the int value out of the object to look for it.
Dim int32Value As Int32 = CType(int32Object,Int32)
'Define a List object to hold the found memory addresses.
Dim finalList As List(Of Integer) = New List(Of Integer)
'Open the pocess to read the memory.
reader.OpenProcess
'Create a new instant of the ScanProgressEventArgs class to be used to raise the
'ScanProgressed event and pass the percentage of scan, during the scan progress.
Dim scanProgressEventArgs As ScanProgressChangedEventArgs
'Calculate the size of memory to scan.
Dim memorySize As Integer = CType((CType(lastAddress,Integer) - CType(baseAddress,Integer)),Integer)
'If more that one block of memory is requered to be read,
If (memorySize >= ReadStackSize) Then
'Count of loops to read the memory blocks.
Dim loopsCount As Integer = (memorySize / ReadStackSize)
'Look to see if there is any other bytes let after the loops.
Dim outOfBounds As Integer = (memorySize Mod ReadStackSize)
'Set the currentAddress to first address.
Dim currentAddress As Integer = CType(baseAddress,Integer)
'This will be used to check if any bytes have been read from the memory.
Dim bytesReadSize As Integer
'Set the size of the bytes blocks.
Dim bytesToRead As Integer = ReadStackSize
'An array to hold the bytes read from the memory.
Dim array() As Byte
'Progress percentage.
Dim progress As Integer
Dim i As Integer = 0
Do While (i < loopsCount)
'Calculte and set the progress percentage.
'Prepare and set the ScanProgressed event and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(progress)
ScanProgressChanged(Me, scanProgressEventArgs)
'Read the bytes from the memory.
array = reader.ReadProcessMemory(CType(currentAddress,IntPtr), CType(bytesToRead,UInteger), bytesReadSize)
'If any byte is read from the memory (there has been any bytes in the memory block),
If (bytesReadSize > 0) Then
'Loop through the bytes one by one to look for the values.
Dim j As Integer = 0
Do While (j _
< (array.Length - arraysDifference))
'If any value is equal to what we are looking for,
If (BitConverter.ToInt32(array, j) = int32Value) Then
'add it's memory address to the finalList.
finalList.Add((j + CType(currentAddress,Integer)))
End If
j = (j + 1)
Loop
End If
'Move currentAddress after the block already scaned, but
'move it back some steps backward (as much as arraysDifference)
'to avoid loosing any values at the end of the array.
currentAddress = (currentAddress _
+ (array.Length - arraysDifference))
'Set the size of the read block, bigger, to the steps backward.
'Set the size of the read block, to fit the back steps.
bytesToRead = (ReadStackSize + arraysDifference)
i = (i + 1)
Loop
'If there is any more bytes than the loops read,
If (outOfBounds > 0) Then
'Read the additional bytes.
Dim outOfBoundsBytes() As Byte = reader.ReadProcessMemory(CType(currentAddress,IntPtr), CType((CType(lastAddress,Integer) - currentAddress),UInteger), bytesReadSize)
'If any byte is read from the memory (there has been any bytes in the memory block),
If (bytesReadSize > 0) Then
'Loop through the bytes one by one to look for the values.
Dim j As Integer = 0
Do While (j _
< (outOfBoundsBytes.Length - arraysDifference))
'If any value is equal to what we are looking for,
If (BitConverter.ToInt32(outOfBoundsBytes, j) = int32Value) Then
'add it's memory address to the finalList.
finalList.Add((j + CType(currentAddress,Integer)))
End If
j = (j + 1)
Loop
End If
End If
End If
'If the block could be read in just one read,
'Calculate the memory block's size.
Dim blockSize As Integer = (memorySize Mod ReadStackSize)
'Set the currentAddress to first address.
Dim currentAddress As Integer = CType(baseAddress,Integer)
'Holds the count of bytes read from the memory.
Dim bytesReadSize As Integer
'If the memory block can contain at least one 32 bit variable.
If (blockSize > Int32BytesCount) Then
'Read the bytes to the array.
Dim array() As Byte = reader.ReadProcessMemory(CType(currentAddress,IntPtr), CType(blockSize,UInteger), bytesReadSize)
'If any byte is read,
If (bytesReadSize > 0) Then
'Loop through the array to find the values.
Dim j As Integer = 0
Do While (j _
< (array.Length - arraysDifference))
'If any value equals the value we are looking for,
If (BitConverter.ToInt32(array, j) = int32Value) Then
'add it to the finalList.
finalList.Add((j + CType(currentAddress,Integer)))
End If
j = (j + 1)
Loop
End If
End If
'Close the handle to the process to avoid process errors.
reader.CloseHandle
'Prepare the ScanProgressed and set the progress percentage to 100% and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(100)
ScanProgressChanged(Me, scanProgressEventArgs)
'Prepare and raise the ScanCompleted event.
Dim scanCompleteEventArgs As ScanCompletedEventArgs = New ScanCompletedEventArgs(finalList.ToArray)
ScanCompleted(Me, scanCompleteEventArgs)
End Sub
'The memory scan method for the 64 bit values.
Private Sub Int64Scaner(ByVal int64Object As Object)
'The difference of scan start point in all loops except first loop,
'that doesn't have any difference, is type's Bytes count minus 1.
Dim arraysDifference As Integer = (Int64BytesCount - 1)
'Get the long value out of the object to look for it.
Dim int64Value As Int64 = CType(int64Object,Int64)
'Define a List object to hold the found memory addresses.
Dim finalList As List(Of Integer) = New List(Of Integer)
'Open the pocess to read the memory.
reader.OpenProcess
'Create a new instant of the ScanProgressEventArgs class to be used to raise the
'ScanProgressed event and pass the percentage of scan, during the scan progress.
Dim scanProgressEventArgs As ScanProgressChangedEventArgs
'Calculate the size of memory to scan.
Dim memorySize As Integer = CType((CType(lastAddress,Integer) - CType(baseAddress,Integer)),Integer)
'If more that one block of memory is requered to be read,
If (memorySize >= ReadStackSize) Then
'Count of loops to read the memory blocks.
Dim loopsCount As Integer = (memorySize / ReadStackSize)
'Look to see if there is any other bytes let after the loops.
Dim outOfBounds As Integer = (memorySize Mod ReadStackSize)
'Set the currentAddress to first address.
Dim currentAddress As Integer = CType(baseAddress,Integer)
'This will be used to check if any bytes have been read from the memory.
Dim bytesReadSize As Integer
'Set the size of the bytes blocks.
Dim bytesToRead As Integer = ReadStackSize
'An array to hold the bytes read from the memory.
Dim array() As Byte
'Progress percentage.
Dim progress As Integer
Dim i As Integer = 0
Do While (i < loopsCount)
'Calculte and set the progress percentage.
'Prepare and set the ScanProgressed event and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(progress)
ScanProgressChanged(Me, scanProgressEventArgs)
'Read the bytes from the memory.
array = reader.ReadProcessMemory(CType(currentAddress,IntPtr), CType(bytesToRead,UInteger), bytesReadSize)
'If any byte is read from the memory (there has been any bytes in the memory block),
If (bytesReadSize > 0) Then
'Loop through the bytes one by one to look for the values.
Dim j As Integer = 0
Do While (j _
< (array.Length - arraysDifference))
'If any value is equal to what we are looking for,
If (BitConverter.ToInt64(array, j) = int64Value) Then
'add it's memory address to the finalList.
finalList.Add((j + CType(currentAddress,Integer)))
End If
j = (j + 1)
Loop
End If
'Move currentAddress after the block already scaned, but
'move it back some steps backward (as much as arraysDifference)
'to avoid loosing any values at the end of the array.
currentAddress = (currentAddress _
+ (array.Length - arraysDifference))
'Set the size of the read block, bigger, to the steps backward.
'Set the size of the read block, to fit the back steps.
bytesToRead = (ReadStackSize + arraysDifference)
i = (i + 1)
Loop
'If there is any more bytes than the loops read,
If (outOfBounds > 0) Then
'Read the additional bytes.
Dim outOfBoundsBytes() As Byte = reader.ReadProcessMemory(CType(currentAddress,IntPtr), CType((CType(lastAddress,Integer) - currentAddress),UInteger), bytesReadSize)
'If any byte is read from the memory (there has been any bytes in the memory block),
If (bytesReadSize > 0) Then
'Loop through the bytes one by one to look for the values.
Dim j As Integer = 0
Do While (j _
< (outOfBoundsBytes.Length - arraysDifference))
'If any value is equal to what we are looking for,
If (BitConverter.ToInt64(outOfBoundsBytes, j) = int64Value) Then
'add it's memory address to the finalList.
finalList.Add((j + CType(currentAddress,Integer)))
End If
j = (j + 1)
Loop
End If
End If
End If
'If the block could be read in just one read,
'Calculate the memory block's size.
Dim blockSize As Integer = (memorySize Mod ReadStackSize)
'Set the currentAddress to first address.
Dim currentAddress As Integer = CType(baseAddress,Integer)
'Holds the count of bytes read from the memory.
Dim bytesReadSize As Integer
'If the memory block can contain at least one 64 bit variable.
If (blockSize > Int64BytesCount) Then
'Read the bytes to the array.
Dim array() As Byte = reader.ReadProcessMemory(CType(currentAddress,IntPtr), CType(blockSize,UInteger), bytesReadSize)
'If any byte is read,
If (bytesReadSize > 0) Then
'Loop through the array to find the values.
Dim j As Integer = 0
Do While (j _
< (array.Length - arraysDifference))
'If any value equals the value we are looking for,
If (BitConverter.ToInt64(array, j) = int64Value) Then
'add it to the finalList.
finalList.Add((j + CType(currentAddress,Integer)))
End If
j = (j + 1)
Loop
End If
End If
'Close the handle to the process to avoid process errors.
reader.CloseHandle
'Prepare the ScanProgressed and set the progress percentage to 100% and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(100)
ScanProgressChanged(Me, scanProgressEventArgs)
'Prepare and raise the ScanCompleted event.
Dim scanCompleteEventArgs As ScanCompletedEventArgs = New ScanCompletedEventArgs(finalList.ToArray)
ScanCompleted(Me, scanCompleteEventArgs)
End Sub
#End Region
#End Region
End Class
Public Class IrregularMemoryScan
Private Const Int16BytesCount As Integer = (16 / 8)
'A 32 bit variable (Like int) is made up of 32 bits of memory and so 32/8 = 4 bytes of memory.
Private Const Int32BytesCount As Integer = (32 / 8)
'A 34 bit variable (Like long) is made up of 64 bits of memory and so 64/8 = 8 bytes of memory.
Private Const Int64BytesCount As Integer = (64 / 8)
#End Region
#Region "Global fields"
Private reader As ProcessMemoryReader
'New thread object to run the scan in
Private thread As Thread
'An array to hold the addresses.
Private addresses() As Integer
#End Region
#Region "Delegate and Event objects"
Public Delegate Sub ScanProgressedEventHandler(ByVal sender As Object, ByVal e As ScanProgressChangedEventArgs)
Public Event ScanProgressChanged As ScanProgressedEventHandler
'Delegate and Event objects for raising the ScanCompleted event.
Public Delegate Sub ScanCompletedEventHandler(ByVal sender As Object, ByVal e As ScanCompletedEventArgs)
Public Event ScanCompleted As ScanCompletedEventHandler
'Delegate and Event objects for raising the ScanCanceled event.
Public Delegate Sub ScanCanceledEventHandler(ByVal sender As Object, ByVal e As ScanCanceledEventArgs)
Public Event ScanCanceled As ScanCanceledEventHandler
#End Region
#Region "Methods"
Public Sub New(ByVal process As Process, ByVal AddressesList() As Integer)
MyBase.New
'Set the reader object an instant of the ProcessMemoryReader class.
reader = New ProcessMemoryReader
'Set the ReadProcess of the reader object to process passed to this method
'to define the process we are going to scan its memory.
reader.ReadProcess = process
'Take the addresses list and store them in local array.
addresses = AddressesList
End Sub
#Region "Public methods"
Public Sub StartScanForInt16(ByVal Int16Value As Int16)
'Check if the thread is already defined or not.
If (Not (thread) Is Nothing) Then
'If the thread is already defined and is Alive,
If thread.IsAlive Then
'raise the event that shows that the last scan task is canceled
'(because a new task is going to be started as wanted),
Dim cancelEventArgs As ScanCanceledEventArgs = New ScanCanceledEventArgs
ScanCanceled(Me, cancelEventArgs)
'and then abort the alive thread and so cancel last scan task.
thread.Abort
End If
End If
'Set the thread object as a new instant of the Thread class and pass
'a new ParameterizedThreadStart class object with the needed method passed to it
'to run in the new thread.
thread = New Thread(New ParameterizedThreadStart(Int16Scaner))
'Start the new thread and set the 32 bit value to look for.
thread.Start(Int16Value)
End Sub
'Get ready to scan the memory for the 32 bit value.
Public Sub StartScanForInt32(ByVal Int32Value As Int32)
'Check if the thread is already defined or not.
If (Not (thread) Is Nothing) Then
'If the thread is already defined and is Alive,
If thread.IsAlive Then
'raise the event that shows that the last scan task is canceled
'(because a new task is going to be started as wanted),
Dim cancelEventArgs As ScanCanceledEventArgs = New ScanCanceledEventArgs
ScanCanceled(Me, cancelEventArgs)
'and then abort the alive thread and so cancel last scan task.
thread.Abort
End If
End If
'Set the thread object as a new instant of the Thread class and pass
'a new ParameterizedThreadStart class object with the needed method passed to it
'to run in the new thread.
thread = New Thread(New ParameterizedThreadStart(Int32Scaner))
'Start the new thread and set the 32 bit value to look for.
thread.Start(Int32Value)
End Sub
'Get ready to scan the memory for the 64 bit value.
Public Sub StartScanForInt64(ByVal Int64Value As Int64)
'Check if the thread is already defined or not.
If (Not (thread) Is Nothing) Then
'If the thread is already defined and is Alive,
If thread.IsAlive Then
'raise the event that shows that the last scan task is canceled
'(because a new task is going to be started as wanted),
Dim cancelEventArgs As ScanCanceledEventArgs = New ScanCanceledEventArgs
ScanCanceled(Me, cancelEventArgs)
'and then abort the alive thread and so cancel last scan task.
thread.Abort
End If
End If
'Set the thread object as a new instant of the Thread class and pass
'a new ParameterizedThreadStart class object with the needed method passed to it
'to run in the new thread.
thread = New Thread(New ParameterizedThreadStart(Int64Scaner))
'Start the new thread and set the 32 bit value to look for.
thread.Start(Int64Value)
End Sub
'Cancel the scan started.
Public Sub CancelScan()
'Raise the event that shows that the last scan task is canceled as user asked,
Dim cancelEventArgs As ScanCanceledEventArgs = New ScanCanceledEventArgs
ScanCanceled(Me, cancelEventArgs)
'and then abort the thread that scanes the memory.
thread.Abort
End Sub
#End Region
#Region "Private methods"
Private Sub Int16Scaner(ByVal int16Object As Object)
'Get the short value out of the object to look for it.
Dim int16Value As Int16 = CType(int16Object,Int16)
'Define a List object to hold the found memory addresses.
Dim finalList As List(Of Integer) = New List(Of Integer)
'Open the pocess to read the memory.
reader.OpenProcess
'Create a new instant of the ScanProgressEventArgs class to be used to raise the
'ScanProgressed event and pass the percentage of scan, during the scan progress.
Dim scanProgressEventArgs As ScanProgressChangedEventArgs
'Progress percentage.
Dim progress As Integer
'This will be used to check if any bytes have been read from the memory.
Dim bytesReadSize As Integer
'An array to hold the bytes read from the memory.
Dim array() As Byte
Dim i As Integer = 0
Do While (i < addresses.Length)
'Calculte and set the progress percentage.
'Prepare and set the ScanProgressed event and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(progress)
ScanProgressChanged(Me, scanProgressEventArgs)
'Read the bytes from the memory.
array = reader.ReadProcessMemory(CType(addresses(i),IntPtr), Int16BytesCount, bytesReadSize)
'If any byte is read from the memory (there has been any bytes in the memory block),
If (bytesReadSize > 0) Then
'If any value is equal to what we are looking for,
If (BitConverter.ToInt16(array, 0) = int16Value) Then
'add it's memory address to the finalList.
finalList.Add(addresses(i))
End If
End If
i = (i + 1)
Loop
'Close the handle to the process to avoid process errors.
reader.CloseHandle
'Prepare the ScanProgressed and set the progress percentage to 100% and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(100)
ScanProgressChanged(Me, scanProgressEventArgs)
'Prepare and raise the ScanCompleted event.
Dim scanCompleteEventArgs As ScanCompletedEventArgs = New ScanCompletedEventArgs(finalList.ToArray)
ScanCompleted(Me, scanCompleteEventArgs)
End Sub
'The memory scan method for the 32 bit values.
Private Sub Int32Scaner(ByVal int32Object As Object)
'Get the int value out of the object to look for it.
Dim int32Value As Int32 = CType(int32Object,Int32)
'Define a List object to hold the found memory addresses.
Dim finalList As List(Of Integer) = New List(Of Integer)
'Open the pocess to read the memory.
reader.OpenProcess
'Create a new instant of the ScanProgressEventArgs class to be used to raise the
'ScanProgressed event and pass the percentage of scan, during the scan progress.
Dim scanProgressEventArgs As ScanProgressChangedEventArgs
'Progress percentage.
Dim progress As Integer
'This will be used to check if any bytes have been read from the memory.
Dim bytesReadSize As Integer
'An array to hold the bytes read from the memory.
Dim array() As Byte
Dim i As Integer = 0
Do While (i < addresses.Length)
'Calculte and set the progress percentage.
'Prepare and set the ScanProgressed event and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(progress)
ScanProgressChanged(Me, scanProgressEventArgs)
'Read the bytes from the memory.
array = reader.ReadProcessMemory(CType(addresses(i),IntPtr), Int32BytesCount, bytesReadSize)
'If any byte is read from the memory (there has been any bytes in the memory block),
If (bytesReadSize > 0) Then
'If any value is equal to what we are looking for,
If (BitConverter.ToInt32(array, 0) = int32Value) Then
'add it's memory address to the finalList.
finalList.Add(addresses(i))
End If
End If
i = (i + 1)
Loop
'Close the handle to the process to avoid process errors.
reader.CloseHandle
'Prepare the ScanProgressed and set the progress percentage to 100% and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(100)
ScanProgressChanged(Me, scanProgressEventArgs)
'Prepare and raise the ScanCompleted event.
Dim scanCompleteEventArgs As ScanCompletedEventArgs = New ScanCompletedEventArgs(finalList.ToArray)
ScanCompleted(Me, scanCompleteEventArgs)
End Sub
'The memory scan method for the 64 bit values.
Private Sub Int64Scaner(ByVal int64Object As Object)
'Get the long value out of the object to look for it.
Dim int64Value As Int64 = CType(int64Object,Int64)
'Define a List object to hold the found memory addresses.
Dim finalList As List(Of Integer) = New List(Of Integer)
'Open the pocess to read the memory.
reader.OpenProcess
'Create a new instant of the ScanProgressEventArgs class to be used to raise the
'ScanProgressed event and pass the percentage of scan, during the scan progress.
Dim scanProgressEventArgs As ScanProgressChangedEventArgs
'Progress percentage.
Dim progress As Integer
'This will be used to check if any bytes have been read from the memory.
Dim bytesReadSize As Integer
'An array to hold the bytes read from the memory.
Dim array() As Byte
Dim i As Integer = 0
Do While (i < addresses.Length)
'Calculte and set the progress percentage.
'Prepare and set the ScanProgressed event and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(progress)
ScanProgressChanged(Me, scanProgressEventArgs)
'Read the bytes from the memory.
array = reader.ReadProcessMemory(CType(addresses(i),IntPtr), Int64BytesCount, bytesReadSize)
'If any byte is read from the memory (there has been any bytes in the memory block),
If (bytesReadSize > 0) Then
'If any value is equal to what we are looking for,
If (BitConverter.ToInt64(array, 0) = int64Value) Then
'add it's memory address to the finalList.
finalList.Add(addresses(i))
End If
End If
i = (i + 1)
Loop
'Close the handle to the process to avoid process errors.
reader.CloseHandle
'Prepare the ScanProgressed and set the progress percentage to 100% and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(100)
ScanProgressChanged(Me, scanProgressEventArgs)
'Prepare and raise the ScanCompleted event.
Dim scanCompleteEventArgs As ScanCompletedEventArgs = New ScanCompletedEventArgs(finalList.ToArray)
ScanCompleted(Me, scanCompleteEventArgs)
End Sub
#End Region
#End Region
End Class
Public Class MemoryFreeze
Public Structure MemoryRecords
'Internal fields.
Friend address As Integer
Friend value As Object
Friend type As DataType
'Public properties.
Public ReadOnly Property Address As Integer
Get
Return address
End Get
End Property
Public ReadOnly Property Value As Object
Get
Return value
End Get
End Property
Public ReadOnly Property Type As DataType
Get
Return type
End Get
End Property
End Structure
'A struct to hold the memory address, value and data type.
Structure memoryRecord
Public address As Integer
Public type As DataType
Public value As Object
End Structure
'Enum of data types(16 bit, 32 bit or 64 bit).
Public Enum DataType As Integer
Int16 = 2
Int32 = 4
Int64 = 8
End Enum
#End Region
#Region "Fields"
Private records As List(Of memoryRecord)
'A ProcessMemoryReader object to write the values to the memory addresses.
Private writer As ProcessMemoryReader
'Timer object to tick and freeze.
Private timer As System.Timers.Timer
#End Region
#Region "Property"
Public ReadOnly Property FreezedMemoryAddresses As MemoryRecords()
Get
'Create an array of MemoryRecords by the lenght of
'records.Count (the number of memory addresses are being freezed).
Dim memoryRecords() As MemoryRecords = New MemoryRecords((records.Count) - 1) {}
'Loop and set the information.
Dim i As Integer = 0
Do While (i < memoryRecords.Length)
memoryRecords(i).address = records(i).address
memoryRecords(i).type = records(i).type
memoryRecords(i).value = records(i).value
i = (i + 1)
Loop
'Return the array.
Return memoryRecords
End Get
End Property
#End Region
#Region "Methods"
#Region "Public methods"
Public Sub New(ByVal process As Process)
MyBase.New
timer = New System.Timers.Timer
writer = New ProcessMemoryReader
writer.ReadProcess = process
records = New List(Of memoryRecord)
AddHandler timer.Elapsed, AddressOf Me.timer_Elapsed
End Sub
'Add a memory address and a 16 bit value to be written in the address.
Public Overloads Sub AddMemoryAddress(ByVal MemoryAddress As Integer, ByVal Value As Int16)
Dim item As memoryRecord
item.address = MemoryAddress
item.type = DataType.Int16
item.value = Value
records.Add(item)
End Sub
'Add a memory address and a 32 bit value to be written in the address.
Public Overloads Sub AddMemoryAddress(ByVal MemoryAddress As Integer, ByVal Value As Int32)
Dim item As memoryRecord
item.address = MemoryAddress
item.type = DataType.Int32
item.value = Value
records.Add(item)
End Sub
'Add a memory address and a 64 bit value to be written in the address.
Public Overloads Sub AddMemoryAddress(ByVal MemoryAddress As Integer, ByVal Value As Int64)
Dim item As memoryRecord
item.address = MemoryAddress
item.type = DataType.Int64
item.value = Value
records.Add(item)
End Sub
'Start the timer with the given Interval to start looping and so start freezing.
Public Sub StartFreezing(ByVal Interval As Double)
timer.Interval = Interval
timer.Start
End Sub
'Stop the timer and so stop the freezing loops.
Public Sub StopFreezing()
timer.Stop
End Sub
#End Region
#Region "Private method"
Private Sub timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
'Open the process.
writer.OpenProcess
'This is used, just to make the write process work but the value is not used.
Dim bytesWritten As Integer
'Loop and set the value of all addresses.
Dim i As Integer = 0
Do While (i < records.Count)
'If the value type for the current address is 16 bit so take the Int16 out of the object,
'and write the memory with the given value.
If (records(i).type = DataType.Int16) Then
writer.WriteProcessMemory(CType(records(i).address,IntPtr), BitConverter.GetBytes(CType(records(i).value,Int16)), bytesWritten)
End If
'If the value type for the current address is 32 bit so take the Int32 out of the object,
'and write the memory with the given value.
If (records(i).type = DataType.Int32) Then
writer.WriteProcessMemory(CType(records(i).address,IntPtr), BitConverter.GetBytes(CType(records(i).value,Int32)), bytesWritten)
End If
'If the value type for the current address is 64 bit so take the Int64 out of the object,
'and write the memory with the given value.
If (records(i).type = DataType.Int64) Then
writer.WriteProcessMemory(CType(records(i).address,IntPtr), BitConverter.GetBytes(CType(records(i).value,Int64)), bytesWritten)
End If
i = (i + 1)
Loop
'Close the handle to the process.
writer.CloseHandle
End Sub
#End Region
#End Region
End Class
Public Class ScanProgressChangedEventArgs
Inherits EventArgs
Public Sub New(ByVal Progress As Integer)
MyBase.New
progress = Progress
End Sub
Private progress As Integer
Public Property Progress As Integer
Get
Return progress
End Get
Set
progress = value
End Set
End Property
End Class
Public Class ScanCompletedEventArgs
Inherits EventArgs
Public Sub New(ByVal MemoryAddresses() As Integer)
MyBase.New
memoryAddresses = MemoryAddresses
End Sub
Private memoryAddresses() As Integer
Public Property MemoryAddresses As Integer()
Get
Return memoryAddresses
End Get
Set
memoryAddresses = value
End Set
End Property
End Class
Public Class ScanCanceledEventArgs
Inherits EventArgs
Public Sub New()
MyBase.New
End Sub
End Class
Class class
End Class
End Namespace
set
{m_ReadProcess = value
UnknownUnknownDim m_ReadProcess As Process = Nothing
Dim m_hProcess As IntPtr = IntPtr.Zero
''' <summary>
''' ProcessMemoryReader is a class that enables direct reading a process memory
''' </summary>
Class ProcessMemoryReaderApi
' constants information can be found in <winnt.h>
<Flags()> _
Public Enum ProcessAccessType
PROCESS_TERMINATE = 1
PROCESS_CREATE_THREAD = 2
PROCESS_SET_SESSIONID = 4
PROCESS_VM_OPERATION = 8
PROCESS_VM_READ = 16
PROCESS_VM_WRITE = 32
PROCESS_DUP_HANDLE = 64
PROCESS_CREATE_PROCESS = 128
PROCESS_SET_QUOTA = 256
PROCESS_SET_INFORMATION = 512
PROCESS_QUERY_INFORMATION = 1024
End Enum
' function declarations are found in the MSDN and in <winbase.h>
' HANDLE OpenProcess(
' DWORD dwDesiredAccess, // access flag
' BOOL bInheritHandle, // handle inheritance option
' DWORD dwProcessId // process identifier
' );
Public Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As UInt32, ByVal bInheritHandle As Int32, ByVal dwProcessId As UInt32) As IntPtr
' BOOL CloseHandle(
' HANDLE hObject // handle to object
' );
Public Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As IntPtr) As Int32
' BOOL ReadProcessMemory(
' HANDLE hProcess, // handle to the process
' LPCVOID lpBaseAddress, // base of memory area
' LPVOID lpBuffer, // data buffer
' SIZE_T nSize, // number of bytes to read
' SIZE_T * lpNumberOfBytesRead // number of bytes read
' );
Public Declare Function ReadProcessMemory Lib "kernel32.dll" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal buffer() As Byte, ByVal size As UInt32, ByRef lpNumberOfBytesRead As IntPtr) As Int32
' BOOL WriteProcessMemory(
' HANDLE hProcess, // handle to process
' LPVOID lpBaseAddress, // base of memory area
' LPCVOID lpBuffer, // data buffer
' SIZE_T nSize, // count of bytes to write
' SIZE_T * lpNumberOfBytesWritten // count of bytes written
' );
Public Declare Function WriteProcessMemory Lib "kernel32.dll" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal buffer() As Byte, ByVal size As UInt32, ByRef lpNumberOfBytesWritten As IntPtr) As Int32
End Class
Unknown#
endregion
Unknown
Public Sub OpenProcess()
' m_hProcess = ProcessMemoryReaderApi.OpenProcess(ProcessMemoryReaderApi.PROCESS_VM_READ, 1, (uint)m_ReadProcess.Id);
Dim access As ProcessMemoryReaderApi.ProcessAccessType
access = (ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_READ _
Or (ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_WRITE Or ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_OPERATION))
m_hProcess = ProcessMemoryReaderApi.OpenProcess(CType(access,UInteger), 1, CType(m_ReadProcess.Id,UInteger))
End Sub
Public Sub CloseHandle()
Try
Dim iRetValue As Integer
iRetValue = ProcessMemoryReaderApi.CloseHandle(m_hProcess)
If (iRetValue = 0) Then
Throw New Exception("CloseHandle failed")
End If
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message, "error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)
End Try
End Sub
Public Function ReadProcessMemory(ByVal MemoryAddress As IntPtr, ByVal bytesToRead As UInteger, ByRef bytesRead As Integer) As Byte()
Dim buffer() As Byte = New Byte((bytesToRead) - 1) {}
Dim ptrBytesRead As IntPtr
ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, ptrBytesRead)
bytesRead = ptrBytesRead.ToInt32
Return buffer
End Function
Public Sub WriteProcessMemory(ByVal MemoryAddress As IntPtr, ByVal bytesToWrite() As Byte, ByRef bytesWritten As Integer)
Dim ptrBytesWritten As IntPtr
ProcessMemoryReaderApi.WriteProcessMemory(m_hProcess, MemoryAddress, bytesToWrite, CType(bytesToWrite.Length,UInteger), ptrBytesWritten)
bytesWritten = ptrBytesWritten.ToInt32
End Sub
وهذا من الموقع الثاني
[CODE]
Imports System.Collections.Generic
Imports System.Text
Imports System.Diagnostics
Imports System.Threading
Imports System.Runtime.InteropServices
Namespace Sojaner.WindowsFormsApplication1
Public Class RegularMemoryScan
#Region "Constant fields"
'Maximum memory block size to read in every read process.
'Experience tells me that,
'if ReadStackSize be bigger than 20480, there will be some problems
'retrieving correct blocks of memory values.
Const ReadStackSize As Integer = 20480
'A byte is 8 bits long memory defined variable.
'A 16 bit variable (Like char) is made up of 16 bits of memory and so 16/8 = 2 bytes of memory.
Const Int16BytesCount As Integer = 16 / 8
'A 32 bit variable (Like int) is made up of 32 bits of memory and so 32/8 = 4 bytes of memory.
Const Int32BytesCount As Integer = 32 / 8
'A 34 bit variable (Like long) is made up of 64 bits of memory and so 64/8 = 8 bytes of memory.
Const Int64BytesCount As Integer = 64 / 8
#End Region
#Region "Global fields"
'Instance of ProcessMemoryReader class to be used to read the memory.
Private reader As ProcessMemoryReader
'Start and End addresses to be scaned.
Private baseAddress As IntPtr
Private lastAddress As IntPtr
'New thread object to run the scan in
Private thread As Thread
#End Region
#Region "Delegate and Event objects"
'Delegate and Event objects for raising the ScanProgressChanged event.
Public Delegate Sub ScanProgressedEventHandler(sender As Object, e As ScanProgressChangedEventArgs)
Public Event ScanProgressChanged As ScanProgressedEventHandler
'Delegate and Event objects for raising the ScanCompleted event.
Public Delegate Sub ScanCompletedEventHandler(sender As Object, e As ScanCompletedEventArgs)
Public Event ScanCompleted As ScanCompletedEventHandler
'Delegate and Event objects for raising the ScanCanceled event.
Public Delegate Sub ScanCanceledEventHandler(sender As Object, e As ScanCanceledEventArgs)
Public Event ScanCanceled As ScanCanceledEventHandler
#End Region
#Region "Methods"
'Class entry point.
'The process, StartAddress and EndAdrress will be defined in the class definition.
Public Sub New(process As Process, StartAddress As Integer, EndAddress As Integer)
'Set the reader object an instant of the ProcessMemoryReader class.
reader = New ProcessMemoryReader()
'Set the ReadProcess of the reader object to process passed to this method
'to define the process we are going to scan its memory.
reader.ReadProcess = process
'Set the Start and End addresses of the scan to what is wanted.
baseAddress = CType(StartAddress, IntPtr)
'The scan starts from baseAddress,
'and progresses up to EndAddress.
lastAddress = CType(EndAddress, IntPtr)
End Sub
#Region "Public methods"
'Get ready to scan the memory for the 16 bit value.
Public Sub StartScanForInt16(Int16Value As Int16)
'Check if the thread is already defined or not.
If thread IsNot Nothing Then
'If the thread is already defined and is Alive,
If thread.IsAlive Then
'raise the event that shows that the last scan task is canceled
'(because a new task is going to be started as wanted),
Dim cancelEventArgs As New ScanCanceledEventArgs()
RaiseEvent ScanCanceled(Me, cancelEventArgs)
'and then abort the alive thread and so cancel last scan task.
thread.Abort()
End If
End If
'Set the thread object as a new instant of the Thread class and pass
'a new ParameterizedThreadStart class object with the needed method passed to it
'to run in the new thread.
thread = New Thread(New ParameterizedThreadStart(AddressOf Int16Scaner))
'Start the new thread and set the 32 bit value to look for.
thread.Start(Int16Value)
End Sub
'Get ready to scan the memory for the 32 bit value.
Public Sub StartScanForInt32(Int32Value As Int32)
'Check if the thread is already defined or not.
If thread IsNot Nothing Then
'If the thread is already defined and is Alive,
If thread.IsAlive Then
'raise the event that shows that the last scan task is canceled
'(because a new task is going to be started as wanted),
Dim cancelEventArgs As New ScanCanceledEventArgs()
RaiseEvent ScanCanceled(Me, cancelEventArgs)
'and then abort the alive thread and so cancel last scan task.
thread.Abort()
End If
End If
'Set the thread object as a new instant of the Thread class and pass
'a new ParameterizedThreadStart class object with the needed method passed to it
'to run in the new thread.
thread = New Thread(New ParameterizedThreadStart(AddressOf Int32Scaner))
'Start the new thread and set the 32 bit value to look for.
thread.Start(Int32Value)
End Sub
'Get ready to scan the memory for the 64 bit value.
Public Sub StartScanForInt64(Int64Value As Int64)
'Check if the thread is already defined or not.
If thread IsNot Nothing Then
'If the thread is already defined and is Alive,
If thread.IsAlive Then
'raise the event that shows that the last scan task is canceled
'(because a new task is going to be started as wanted),
Dim cancelEventArgs As New ScanCanceledEventArgs()
RaiseEvent ScanCanceled(Me, cancelEventArgs)
'and then abort the alive thread and so cancel last scan task.
thread.Abort()
End If
End If
'Set the thread object as a new instant of the Thread class and pass
'a new ParameterizedThreadStart class object with the needed method passed to it
'to run in the new thread.
thread = New Thread(New ParameterizedThreadStart(AddressOf Int64Scaner))
'Start the new thread and set the 32 bit value to look for.
thread.Start(Int64Value)
End Sub
'Cancel the scan started.
Public Sub CancelScan()
'Raise the event that shows that the last scan task is canceled as user asked,
Dim cancelEventArgs As New ScanCanceledEventArgs()
RaiseEvent ScanCanceled(Me, cancelEventArgs)
'and then abort the thread that scanes the memory.
thread.Abort()
End Sub
#End Region
#Region "Private methods"
'The memory scan method for the 16 bit values.
Private Sub Int16Scaner(int16Object As Object)
'The difference of scan start point in all loops except first loop,
'that doesn't have any difference, is type's Bytes count minus 1.
Dim arraysDifference As Integer = Int16BytesCount - 1
'Get the short value out of the object to look for it.
Dim int16Value As Int16 = CType(int16Object, Int16)
'Define a List object to hold the found memory addresses.
Dim finalList As New List(Of Integer)()
'Open the pocess to read the memory.
reader.OpenProcess()
'Create a new instant of the ScanProgressEventArgs class to be used to raise the
'ScanProgressed event and pass the percentage of scan, during the scan progress.
Dim scanProgressEventArgs As ScanProgressChangedEventArgs
'Calculate the size of memory to scan.
Dim memorySize As Integer = CInt(CInt(lastAddress) - CInt(baseAddress))
'If more that one block of memory is requered to be read,
If memorySize >= ReadStackSize Then
'Count of loops to read the memory blocks.
Dim loopsCount As Integer = memorySize \ ReadStackSize
'Look to see if there is any other bytes let after the loops.
Dim outOfBounds As Integer = memorySize Mod ReadStackSize
'Set the currentAddress to first address.
Dim currentAddress As Integer = CInt(baseAddress)
'This will be used to check if any bytes have been read from the memory.
Dim bytesReadSize As Integer
'Set the size of the bytes blocks.
Dim bytesToRead As Integer = ReadStackSize
'An array to hold the bytes read from the memory.
Dim array As Byte()
'Progress percentage.
Dim progress As Integer
For i As Integer = 0 To loopsCount - 1
'Calculte and set the progress percentage.
progress = CInt(Math.Truncate((CDbl(currentAddress - CInt(baseAddress)) / CDbl(memorySize)) * 100.0))
'Prepare and set the ScanProgressed event and raise the event.
scanProgressEventArgs = New ScanProgressChangedEventArgs(progress)
RaiseEvent ScanProgressChanged(Me, scanProgressEventArgs)
'Read the bytes from the memory.
array = reader.ReadProcessMemory(CType(currentAddress, IntPtr), CU...