none
VB2008 将数值写入记忆体位置问题 RRS feed

  • 问题

  • 麻烦会的人帮忙解答~

    下面是看一些VB6教学在自己改过的
    但是就是一直没办法写到"&H5435A8"这内存记忆体位置去

     

    Code Snippet

    Imports System.Runtime.InteropServices
    Public Class Form1

        <DllImport("kernel32.dll")> _
        Shared Function WriteProcessMemory(ByVal hProcess As Int32, ByVal lpBaseAddress As Int32, _
                                                             ByRef lpBuffer As Object, ByVal nSize As Int32, _
                                                             ByRef lpNumberOfBytesWritten As Int32) As Int32

        End Function
        Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, ByVal lpdwProcessId As Long) As Long
         Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long   
        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 Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
        Private Const PROCESS_ALL_ACCESS = &H1F0FFF
        Public hProcess As Long
        Const BaseAddr = &H5435A8

     

     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim MyAddr& = &H5435A8
            Dim i As Byte
            i = TextBox1.Text
            WriteProcessMemory(hProcess, MyAddr, i, 2, 0&)


        End Sub
    End Class

     

    2008年10月13日 13:57

全部回复