冰楓論壇

 找回密碼
 立即註冊
搜索
查看: 1766|回覆: 0
打印 上一主題 下一主題

[VB.Net] Write64

[複製鏈接]

192

主題

10

好友

2485

積分

高級贊助會員

Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20

UID
286196
帖子
1238
主題
192
精華
0
積分
2485
楓幣
4991
威望
1944
存款
0
贊助金額
1950
推廣
0
GP
230
閱讀權限
150
在線時間
1072 小時
註冊時間
2020-7-11
最後登入
2024-12-17

Apple勳章 性別(女) 屁孩勳章 懶人勳章 2021中秋節紀念勳章 太陽勳章 神手勳章 解說達人 論壇粉絲 論壇支持王 VIP會員 積分勳章 發帖達人 長老勳章 2021聖誕節紀念勳章 管理者 版主勳章 2022年紀念勳章 核心勳章 Android勳章 在線終極王 2023聖誕節紀念勳章

跳轉到指定樓層
1
發表於 2024-6-4 22:38:44 |只看該作者 |倒序瀏覽
本帖最後由 BeeBan 於 2024-6-4 22:39 編輯

Imports System.Runtime.InteropServices
Imports System
Module ReadWritingMemory

    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
    Private Declare Function WriteProcessMemory1 Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As UInt64, ByRef lpBuffer As UInt64, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    Private Declare Function WriteProcessMemory2 Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As UInt64, ByRef lpBuffer As Single, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Single
    Private Declare Function WriteProcessMemory3 Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As UInt64, ByRef lpBuffer As UInt64, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Long
    Private Declare Function WriteProcessMemory4 Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As UInt64, ByRef lpBuffer As UInt64, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As UInt64

    Private Declare Function ReadProcessMemory1 Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As UInt64, ByRef lpBuffer As UInt64, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    Private Declare Function ReadProcessMemory2 Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As UInt64, ByRef lpBuffer As Single, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Single
    Private Declare Function ReadProcessMemory3 Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As UInt64, ByRef lpBuffer As UInt64, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Long
    Private Declare Function ReadProcessMemory4 Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As UInt64, ByRef lpBuffer As UInt64, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As UInt64

    Const PROCESS_ALL_ACCESS = &H1F0FF

    Private Function UnicodeBytesToString(
    ByVal bytes() As Byte) As String
        Return System.Text.Encoding.Unicode.GetString(bytes)
    End Function



    Public Function WriteDMAInteger(ByVal Process As String, ByVal Address As UInt64, ByVal Offsets As UInt64(), ByVal Value As UInt64, ByVal Level As Integer, Optional ByVal nsize As Integer = 8) As Boolean
        Try
            Dim lvl As UInt64 = Address
            For i As Integer = 1 To Level
                lvl = ReadInteger(Process, lvl, nsize) + Offsets(i - 1)
            Next
            WriteInteger(Process, lvl, Value, nsize)
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function ReadDMAInteger(ByVal Process As String, ByVal Address As UInt64, ByVal Offsets As UInt64(), ByVal Level As Integer, Optional ByVal nsize As Integer = 8) As UInt64
        Try
            Dim lvl As UInt64 = Address
            For i As Integer = 1 To Level
                lvl = ReadInteger(Process, lvl, nsize) + Offsets(i - 1)
            Next
            Dim vBuffer As UInt32
            vBuffer = ReadInteger(Process, lvl, nsize)
            Return vBuffer
        Catch ex As Exception

        End Try
    End Function

    Public Function WriteDMAFloat(ByVal Process As String, ByVal Address As UInt64, ByVal Offsets As UInt64(), ByVal Value As Single, ByVal Level As Integer, Optional ByVal nsize As Integer = 8) As Boolean
        Try
            Dim lvl As UInt64 = Address
            For i As Integer = 1 To Level
                lvl = ReadInteger(Process, lvl, nsize) + Offsets(i - 1)
            Next
            WriteFloat(Process, lvl, Value, nsize)
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function ReadDMAFloat(ByVal Process As String, ByVal Address As UInt64, ByVal Offsets As UInt64(), ByVal Level As Integer, Optional ByVal nsize As Integer = 8) As Boolean
        Try
            Dim lvl As UInt64 = Address
            For i As Integer = 1 To Level
                lvl = ReadFloat(Process, lvl, nsize) + Offsets(i - 1)
            Next
            Dim vBuffer As Single
            vBuffer = ReadFloat(Process, lvl, nsize)
            Return vBuffer
        Catch ex As Exception

        End Try
    End Function

    Public Function WriteDMALong(ByVal Process As String, ByVal Address As UInt64, ByVal Offsets As Integer(), ByVal Value As Long, ByVal Level As Integer, Optional ByVal nsize As Integer = 8) As Boolean
        Try
            Dim lvl As UInt64 = Address
            For i As Integer = 1 To Level
                lvl = ReadLong(Process, lvl, nsize) + Offsets(i - 1)
            Next
            WriteLong(Process, lvl, Value, nsize)

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function ReadDMALong(ByVal Process As String, ByVal Address As UInt64, ByVal Offsets As Integer(), ByVal Level As Integer, Optional ByVal nsize As Integer = 8) As Long

        Try
            Dim lvl As UInt64 = Address
            For i As Integer = 1 To Level
                lvl = ReadLong(Process, lvl, nsize) + Offsets(i - 1)
            Next
            Dim vBuffer As UInt64
            vBuffer = ReadLong(Process, lvl, nsize)
            Return vBuffer
        Catch ex As Exception

        End Try
    End Function

    Public Sub WriteNOPs(ByVal ProcessName As String, ByVal Address As UInt64, ByVal NOPNum As Integer)
        On Error Resume Next
        Dim C As Integer
        Dim B As Integer
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)

        B = 0
        For C = 1 To NOPNum
            Call WriteProcessMemory1(hProcess, Address + B, &H90, 1, 0&)
            B = B + 1
        Next C
        Resume
    End Sub

    Public Sub WriteXBytes(ByVal ProcessName As String, ByVal Address As UInt64, ByVal Value As String)
        On Error Resume Next
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)


        Dim C As Integer
        Dim B As Integer
        Dim D As Integer
        Dim V As Byte

        B = 0
        D = 1
        For C = 1 To Math.Round((Len(Value) / 2))
            V = Val("&H" & Mid$(Value, D, 2))
            Call WriteProcessMemory1(hProcess, Address + B, V, 1, 0&)
            B = B + 1
            D = D + 2
        Next C
        Resume
    End Sub

    Public Sub WriteInteger(ByVal ProcessName As String, ByVal Address As UInt64, ByVal Value As Integer, Optional ByVal nsize As Integer = 8)
        On Error Resume Next
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)

        Dim vBuffer As UInt64
        Dim hAddress As UInt64
        hAddress = Address
        vBuffer = Value
        WriteProcessMemory1(hProcess, hAddress, CInt(vBuffer), nsize, 0)
        Resume
    End Sub

    Public Sub WriteInt64(ByVal ProcessName As String, ByVal Address As UInt64, ByVal Value As Integer, Optional ByVal nsize As Integer = 8)
        On Error Resume Next
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)

        Dim vBuffer As UInt64
        Dim hAddress As UInt64
        hAddress = Address
        vBuffer = Value
        WriteProcessMemory4(hProcess, hAddress, CInt(vBuffer), nsize, 0)
        Resume
    End Sub

    Public Sub WriteFloat(ByVal ProcessName As String, ByVal Address As UInt64, ByVal Value As Single, Optional ByVal nsize As Integer = 8)
        On Error Resume Next
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)


        Dim hAddress As UInt64
        Dim vBuffer As Single

        hAddress = Address
        vBuffer = Value
        WriteProcessMemory2(hProcess, hAddress, vBuffer, nsize, 0)
        Resume
    End Sub

    Public Sub WriteLong(ByVal ProcessName As String, ByVal Address As UInt64, ByVal Value As Long, Optional ByVal nsize As Integer = 8)
        On Error Resume Next
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)

        Dim hAddress As UInt64
        Dim vBuffer As Uint64

        hAddress = Address
        vBuffer = Value
        WriteProcessMemory3(hProcess, hAddress, vBuffer, nsize, 0)
        Resume
    End Sub

    Public Function ReadInteger(ByVal ProcessName As String, ByVal Address As UInt64, ByVal Value As UInt64, Optional ByVal nsize As Integer = 8) As UInt64
        On Error Resume Next
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
        Dim vBuffer As UInt64
        Dim hAddress As UInt64
        hAddress = Address
        vBuffer = Value


        ReadProcessMemory1(hProcess, hAddress, vBuffer, nsize, 0)
        Return vBuffer
        Resume
    End Function


    Public Function ReadInt64(ByVal ProcessName As String, ByVal Address As UInt64, Optional ByVal nsize As Integer = 8) As UInt64
        On Error Resume Next
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)

        Dim vBuffer As UInt64
        Dim hAddress As UInt64
        hAddress = Address
        ReadProcessMemory4(hProcess, hAddress, vBuffer, nsize, 0)
        Return vBuffer
        Resume
    End Function

    Public Function ReadFloat(ByVal ProcessName As String, ByVal Address As UInt64, Optional ByVal nsize As Integer = 8) As Single
        On Error Resume Next
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
        Dim hAddress As UInt64
        Dim vBuffer As Single

        hAddress = Address
        ReadProcessMemory2(hProcess, hAddress, vBuffer, nsize, 0)
        Return vBuffer
        Resume
    End Function

    Public Function ReadLong(ByVal ProcessName As String, ByVal Address As UInt64, Optional ByVal nsize As Integer = 8) As Long
        On Error Resume Next
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)

        Dim hAddress As UInt64
        Dim vBuffer As UInt64

        hAddress = Address
        ReadProcessMemory3(hProcess, hAddress, vBuffer, nsize, 0)
        Return vBuffer
        Resume
    End Function
End Module

----------------------------------此模組可用於編寫64位元的遊戲外掛----------------------------------------------------

Write64.vb

12.33 KB, 下載次數: 1

收藏收藏0 推0 噓0


把本文推薦給朋友或其他網站上,每次被點擊增加您在本站積分: 1鑰匙
我就只是個垃圾
複製連結並發給好友,以賺取推廣點數
簡單兩步驟,註冊、分享網址,即可獲得獎勵! 一起推廣文章換商品、賺$$
高級模式
B Color Image Link Quote Code Smilies |上傳

廣告刊登意見回饋關於我們管群招募本站規範DMCA隱私權政策

Copyright © 2011-2024 冰楓論壇, All rights reserved

免責聲明:本網站是以即時上載留言的方式運作,本站對所有留言的真實性、完整性及立場等,不負任何法律責任。

而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。

小黑屋|手機版|冰楓論壇

GMT+8, 2024-12-18 12:22

回頂部