91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

vb.net ReadProcessMemory使用方法

發布時間:2020-07-25 12:05:21 來源:網絡 閱讀:647 作者:wang5159029 欄目:編程語言

網上好多關于ReadprocessMemory、WriteprocessMemory使用方法的貼子都不能用,下面是本人親自測過可用的,望對大家有用。

    ''' <summary>
    ''' 讀取內存地址
    ''' </summary>
    ''' <param name="hProcess">進程句柄</param>
    ''' <param name="lpBaseAddress">內存地址</param>
    ''' <param name="lpBuffer">數據存儲變量</param>
    ''' <param name="nSize">長度sizeof(lpBuffer)</param>
    ''' <param name="lpNumberOfBytesRead">讀取長度</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    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

    ''' <summary>
    ''' 寫入內存地址
    ''' </summary>
    ''' <param name="hProcess">進程句柄</param>
    ''' <param name="lpBaseAddress">寫入進程的內存地址</param>
    ''' <param name="lpBuffer">數據存儲變量</param>
    ''' <param name="nSize">長度sizeof(lpBuffer)</param>
    ''' <param name="lpNumberOfBytesWritten">實際數據的長度</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    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

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

莱州市| 禄劝| 田东县| 铜山县| 瑞金市| 怀安县| 昌乐县| 惠水县| 洛阳市| 西安市| 连城县| 广汉市| 都昌县| 宣汉县| 城固县| 湾仔区| 廉江市| 天柱县| 普洱| 原平市| 长垣县| 留坝县| 临沧市| 嘉义县| 阿克| 金塔县| 巴南区| 湘阴县| 兴国县| 皮山县| 五指山市| 商城县| 高尔夫| 天水市| 化州市| 新宾| 青岛市| 岳普湖县| 松阳县| 景宁| 彰武县|