VB实现CE的AobScan功能,仿CE字节组内存搜索.'这里的东西写模块里面,具体怎么写,我不告诉你 Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function GetProcessMemoryInfo Lib "PSAPI.DLL" (ByVal hProcess As Long, ppsmemCounters As PROCESS_MEMORY_COUNTERS, ByVal cb As Long) As Long Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Public Declare Function VirtualQueryEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, lpBuffer As MEMORY_BASIC_INFORMATION, ByVal dwLength As Long) As Long Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long Public Type MEMORY_BASIC_INFORMATION BaseAddress As Long AllocationBase As Long AllocationProtect As Long RegionSize As Long State As Long Protect As Long lType As Long End Type Type PROCESS_MEMORY_COUNTERS cb As Long PageFaultCount As Long PeakWorkingSetSize As Long WorkingSetSize As Long QuotaPeakPagedPoolUsage As Long QuotaPagedPoolUsage As Long QuotaPeakNonPagedPoolUsage As Long QuotaNonPagedPoolUsage As Long PagefileUsage As Long PeakPagefileUsage As Long End Type Public Function GetPid(lpClassName As String, lpWindowName As String) As Long GetWindowThreadProcessId FindWindow(lpClassName, lpWindowName), GetPid End Function Public Function GetMemoryByPID(ByVal Pid As Integer) As String Dim tPMC As PROCESS_MEMORY_COUNTERS Dim lProcessID Dim hProcess lProcessID = Pid hProcess = OpenProcess(&H1F0FFF, False, lProcessID) If (GetProcessMemoryInfo(hProcess, tPMC, Len(tPMC)) <> 0) Then GetMemoryByPID = Hex(tPMC.WorkingSetSize) End If CloseHandle hProcess End Function'程序窗体定义一个局部变量 Dim GamePid As String Dim Rst(2000000) As Long Private Sub Form_Load() GamePid = GetPid(vbNullString, "程序名写到这里,你知道的!") End Sub '把字节数组转换的函数 Function Fz(Str As String) As String Dim a As String a = Replace(Str, " ", "") Dim i As Integer Dim b As String For i = Len(a) To 2 Step -2 b = b & Mid(a, i - 1, 2) Next Fz = b End FunctionFunction AobScan(Pid As String, ZJSZ As String) As String ReDim da(1023) As Byte Dim z As Long Dim zr As Long Dim Srge As Long Dim hpid As Long Dim Minf As MEMORY_BASIC_INFORMATION Dim Mbsize As Long Dim Dda(100) As Byte Dim Zfr As Long Dim Zed As Long Dim Siz As Integer Dim Csiz As Integer Dim Shsiz As Integer Dim Mlng As Long Mbsize = Len(Minf) Zfr = 0 Zed = CLng("&H" & GetMemoryByPID(GamePid)) LRsc = Rsc Rsc = -1 Siz = 2 Shsiz = 2 mstr = Fz(ZJSZ) '循环看数组的长度,并转换成字节数组 Dim i As Integer For i = Len(mstr) To 2 Step -2 Dda((i / 2) - 1) = CInt("&h" & Mid$(mstr, Len(mstr) - i + 1, 2)) Next hpid = OpenProcess(&H1F0FFF, False, CLng(Pid)) z = Zfr '设置开始内存 Do While z < Zed - 1 '判断是否小于结束内存 ret = VirtualQueryEx(hpid, z, Minf, Mbsize) '查询地址空间中内存地址的信息 If ret = 0 Then Srge = 1023 zr = z Else Srge = Minf.RegionSize - 1 zr = Minf.BaseAddress If (Minf.Protect And 4) And Minf.State = 4096 Then ReDim da(Srge) As Byte a = ReadProcessMemory(hpid, zr, da(0), Srge + 1, ByVal 0&) If a <> 0 Then For zz = 0 To Srge Step Shsiz If Srge - zz < Siz - 1 Then Exit For For bj = 0 To Siz - 1 If da(zz + bj) <> Dda(bj) Then Exit For Next bj If bj = Siz Then Rsc = Rsc + 1: Rst(Rsc) = zr + zz Next zz End If End If End If z = zr + Srge + 1 DoEvents Loop CloseHandle (hpid) AobScan = Hex$(Rst(0)) End Function Private Sub Command3_Click() MsgBox AobScan(GamePid, "1d 8e 25 00 19") End Sub