找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 17161|回复: 2

进程内存写入工具-WriteProcessMemory

[复制链接]
发表于 2017-9-9 22:46:42 | 显示全部楼层 |阅读模式
老刘制作——进程内存写入工具

用法:
        WriteProcessMemory      <ProcessID>     <BaseAddress>   <HEX>   ...
        ProcessID               指定需写入进程的PID
        BaseAddress             指定需写入进程内数据的起始地址
        HEXs                    需写入的数据(至少一个,数值范围:0~255)

提示:
传入数据时,十六进制请用"&H"前缀表示

姊妹工具:http://www.bathome.net/thread-45156-1-1.html
  1. Option Explicit
  2. Module WriteProcessMemory
  3.         Public Class WriteProcessMemory_Main
  4.                 Public Shared Sub Main(ByVal cmdArgs() As String)
  5.                         Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
  6.                         Const PAGE_EXECUTE_READWRITE As Long = &H40
  7.                         If CmdArgs.Length > 2 Then
  8.                                 If IsNumeric(cmdArgs(0)) And IsNumeric(cmdArgs(1)) Then
  9.                                         Dim ProcessHandle,OldProtect,ReturnValue(2),Conter(1) As Long
  10.                                         Dim Bytes() As Byte
  11.                                         Conter(1) = 0
  12.                                         Rem 获取HEXs并生成数组
  13.                                         For Conter(0) = 2 to CmdArgs.Length - 1
  14.                                                 If IsNumeric(CmdArgs(Conter(0))) Then
  15.                                                         If CLng(CmdArgs(Conter(0))) >= 0 And _
  16.                                                                 CLng(CmdArgs(Conter(0))) <= &HFF Then
  17.                                                                         ReDim Preserve Bytes(Conter(1))
  18.                                                                         Bytes(Conter(1)) = CByte(CmdArgs(Conter(0)))
  19.                                                                         Conter(1) = Conter(1) + 1
  20.                                                         End If
  21.                                                 End If
  22.                                         Next
  23.                                         Rem 以最高权限附加到目标进程
  24.                                         ProcessHandle = Win32.OpenProcess( _
  25.                                                 PROCESS_ALL_ACCESS, _
  26.                                                 False, _
  27.                                                 Clng(CmdArgs(0)))
  28.                                         Rem 更改内存属性为读+写+执行
  29.                                         ReturnValue(0) = Win32.VirtualProtectEx( _
  30.                                                 ProcessHandle, _
  31.                                                 Clng(CmdArgs(1)), _
  32.                                                 Conter(1), _
  33.                                                 PAGE_EXECUTE_READWRITE, _
  34.                                                 OldProtect)
  35.                                         Rem 写入数据
  36.                                         ReturnValue(1) = Win32.WriteProcessMemory( _
  37.                                                 ProcessHandle, _
  38.                                                 Clng(CmdArgs(1)), _
  39.                                                 Bytes,Conter(1),0)
  40.                                         If ReturnValue(1) <> 1 Then
  41.                                                 Console.WriteLine("写入失败!")
  42.                                         End If
  43.                                         If ReturnValue(0) <> 0 Then
  44.                                                 Rem 还原内存属性
  45.                                                 ReturnValue(2) = Win32.VirtualProtectEx( _
  46.                                                         ProcessHandle, _
  47.                                                         Clng(CmdArgs(1)), _
  48.                                                         Conter(1), _
  49.                                                         OldProtect,0)
  50.                                         End If
  51.                                 Else
  52.                                         Console.WriteLine("输入的值不合法!")
  53.                                 End If
  54.                         Else
  55.                                 Console.WriteLine("老刘制作——进程内存写入工具")
  56.                                 Console.WriteLine()
  57.                                 Console.WriteLine("用法:")
  58.                                 Console.WriteLine("        WriteProcessMemory        <ProcessID>        <BaseAddress>        <HEX>        ...")
  59.                                 Console.WriteLine("        ProcessID                指定需写入进程的PID")
  60.                                 Console.WriteLine("        BaseAddress                指定需写入进程内数据的起始地址")
  61.                                 Console.WriteLine("        HEXs                        需写入的数据(至少一个,数值范围:0~255)")
  62.                                 Console.WriteLine()
  63.                                 Console.WriteLine("提示:")
  64.                                 Console.WriteLine("传入数据时,十六进制请用""&H""前缀表示")
  65.                         End If
  66.                 End Sub
  67.         End Class       
  68.         Public Class Win32
  69.                 Declare Function OpenProcess Lib "KERNEL32" ( _
  70.                         ByVal dwDesiredAccess As Long, _
  71.                         ByVal bInheritHandle As Long, _
  72.                         ByVal dwProcessId As Long ) _
  73.                         As Long
  74.                 Declare Function WriteProcessMemory Lib "KERNEL32" ( _
  75.                         ByVal hProcess As Long, _
  76.                         ByVal lpBaseAddress As Long, _
  77.                         ByVal lpBuffer As Byte(), _
  78.                         ByVal nSize As Long, _
  79.                         ByRef lpNumberOfBytesWritten As Long) _
  80.                         As Long
  81.                 Declare Function VirtualProtectEx Lib "KERNEL32" ( _
  82.                         ByVal hProcess As Long, _
  83.                         ByVal lpAddress As Long, _
  84.                         ByVal dwSize As Long, _
  85.                         ByVal flNewProtect As Long, _
  86.                         ByRef lpflOldProtect As Long) _
  87.                         As Long
  88.         End Class
  89. End Module
复制代码
链接: https://pan.baidu.com/s/1YCSEiRd7Y6dbdz47QmASZA?pwd=3rwf

评分

参与人数 1技术 +1 收起 理由
happy886rr + 1 666

查看全部评分

发表于 2017-9-10 21:44:46 | 显示全部楼层
回复 1# 老刘1号
不错,好工具,你的体积越来越小了,也做到了几KB。可以用来游戏作弊了。
 楼主| 发表于 2017-9-10 22:25:12 | 显示全部楼层
回复 2# happy886rr


    感谢支持
哈哈,表面看来是几kb,其实windows自带着几G的运行库
游戏修改的话

水果忍者红叉修改

植物大战僵尸,NOP掉种植物时的阳光耗费机制

评分

参与人数 1技术 +1 收起 理由
happy886rr + 1 图文并茂666

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-16 23:25 , Processed in 0.018053 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表