vb.netReadProcessMemory使用方法

网上好多关于ReadprocessMemory、WriteprocessMemory使用方法的贴子都不能用,下面是本人亲自测过可用的,望对大家有用。

10年积累的网站建设、网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站策划后付款的网站建设流程,更有鹿城免费网站建设让你可以放心的选择与我们合作。

    '''


    ''' 读取内存地址
    '''

    ''' 进程句柄
    ''' 内存地址
    ''' 数据存储变量
    ''' 长度sizeof(lpBuffer)
    ''' 读取长度
    '''
    '''
    Declare Function ReadProcessMemory Lib "kernel32.dll" (ByVal hProcess As Integer, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As IntPtr, ByVal nSize As Integer, ByRef lpNumberOfBytesRead As Integer) As Boolean

    '''


    ''' 写入内存地址
    '''

    ''' 进程句柄
    ''' 写入进程的内存地址
    ''' 数据存储变量
    ''' 长度sizeof(lpBuffer)
    ''' 实际数据的长度
    '''
    '''
    Declare Function WriteProcessMemory Lib "kernel32" Alias "WriteProcessMemory" _
        (ByVal hProcess As Integer, ByVal lpBaseAddress As IntPtr, _
         ByVal lpBuffer As Byte(), ByVal nSize As Integer, ByVal lpNumberOfBytesWritten As IntPtr) As Boolean

Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer

    Friend Const PROCESS_ALL_ACCESS = &H1F0FFF = 2035711
    Friend Const PROCESS_VM_READ = &H10
    Friend Const PROCESS_VM_WRITE = &H20

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim hw As Integer = OpenProcess(PROCESS_VM_READ, False, 4304)
        Dim getstr(12) As Byte
        Dim GetStrIntptr = Marshal.UnsafeAddrOfPinnedArrayElement(getstr, 0)
        Button1.Text = "read结果:" & ReadProcessMemory(hw, CType(&H4D45A0, IntPtr), GetStrIntptr, 12, 0)
        TextBox1.Text = Marshal.PtrToStringUni(GetStrIntptr)
        TextBox3.Text = "GLE:" & GetLastError
        CloseHandle(hw)
    End Sub
‘需要注意:readprocessmemory的lpBuffer放的地数组地址的基址,需要用marshal转化一下。Marshal.PtrToStringUni(GetStrIntptr)输出内容。

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim hw As Integer = OpenProcess(&H1F0FFF, False, 4304)
        Dim Wrtstr(12) As Byte
        Wrtstr = System.Text.Encoding.Unicode.GetBytes("vbWrit")
        Button2.Text = "Write结果:" & WriteProcessMemory(hw, CType(&H4D45A0, IntPtr), Wrtstr, 12, 0)
        TextBox3.Text = "GLE:" & GetLastError
        CloseHandle(hw)
    End Sub


新闻名称:vb.netReadProcessMemory使用方法
本文地址:http://bzwzjz.com/article/jojoeh.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 重庆电商网站建设 成都网站制作 成都网站建设公司 高端网站设计 网站建设开发 网站制作公司 高端品牌网站建设 成都网站设计 企业网站建设 成都网站设计 成都网站制作 高端网站建设 成都网站建设 LED网站设计方案 营销网站建设 成都网站建设推广 网站建设公司 企业网站设计 手机网站制作 成都网站制作 成都定制网站建设 重庆网站建设