Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of ReadProcessMemory in VB.NET

Shulou Source: shulou.com Published: 2022-06-02 08:49:04 09月20日 Update

This article mainly introduces how to solve the problem of ReadProcessMemory in VB.NET. It is very detailed and has a certain reference value. Friends who are interested must finish it!

In the course of VB.NET at school, VB had learned a little bit before and could only read and not write, but there was no way. The school opened it, so a few people formed a group to write an antivirus software under VB.NET. They wanted to use VB.NET ReadProcessMemory to read the memory of other processes. No matter how they could be called, goole and baidu looked for N hours. There are a lot of people who have raised this problem, but no one has solved it, but it also gives me some. In fact, with the help of my friend freecat, I found out where the problem lies, mainly the problem stated by VB.NET ReadProcessMemory. We should declare this.

Public Declare Function ReadProcessMemory Lib "kernel32"

(ByVal hProcess As Integer, ByVal lpBaseAddress As Integer

ByVal lpBuffer () As Byte, ByVal nSize As Integer

ByRef lpNumberOfBytesWritten As Integer) As Integer

The main one, ByVal lpBaseAddress As Integer, ByVal lpBuffer () As Byte, should be set to byval instead of byref, so that the call can get the return value.

Private Declare Function OpenProcess Lib "kernel32.dll" _

(ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer

ByVal dwProcessId As Integer) As Integer

Public Declare Function ReadProcessMemory Lib "kernel32"

(ByVal hProcess As Integer, ByVal lpBaseAddress As Integer

ByVal lpBuffer () As Byte, ByVal nSize As Integer

ByRef lpNumberOfBytesWritten As Integer) As Integer

Private Const PROCESS_VM_READ As Long = & H10

Dim ph As Integer

Dim i As Integer

Dim h As Integer

Dim buffer (20) As Byte

Dim bytesRead As Integer

'get the process

Ph = OpenProcess (PROCESS_ALL_ACCESS, False, 1832)

If ph Then

MessageBox.Show ("true")

H = ReadProcessMemory (ph, & H403000, buffer, buffer.Length, bytesRead)

For I = 0 To buffer.Length-1

TempMem + = buffer (I) .ToString

Next

Else

MessageBox.Show ("false")

End If

The above is all the contents of the article "how to solve the problem of ReadProcessMemory in VB.NET". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Questions content schools articles processes help no individuals values but interests memory methods piles friends guys buddies hours groups that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Xiaomi vpn Shulou Technology macOS