私はこのビジネスに不慣れです
コード:
Dim info As StructLib.MEMORY_BASIC_INFORMATION
Dim size = CUInt(Marshal.SizeOf(GetType(StructLib.MEMORY_BASIC_INFORMATION)))
Dim address = IntPtr.Zero
Dim handle = Api.kernel32.OpenProcess(EnumLib.ProcessAccessFlags.All, False, Helper.EnumProcess.Process().First(Function(res) res.szExeFile = "chrome.exe").th32ProcessID)
Dim lookFor As Object = "google.co.il", replaceWith As Object = "boogle.co.il"
Dim done As UInteger
Dim lookData As Byte() = Nothing
If TypeOf lookFor Is String Then
lookData = Encoding.Unicode.GetBytes(DirectCast(lookFor, String))
ElseIf TypeOf lookFor Is Byte Then
lookData = New Byte(0) {}
lookData(0) = CByte(lookFor)
ElseIf TypeOf lookFor Is Short Then
lookData = BitConverter.GetBytes(CShort(lookFor))
ElseIf TypeOf lookFor Is Integer Then
lookData = BitConverter.GetBytes(CInt(lookFor))
ElseIf TypeOf lookFor Is Long Then
lookData = BitConverter.GetBytes(CLng(lookFor))
End If
While Api.kernel32.VirtualQueryEx(handle, address, info, size) > 0
If info.Valid Then
Dim data = info.getData(handle)
For i As var = 0 To data.Length - 1
Dim index = -1
While System.Threading.Interlocked.Increment(index) < lookData.Length
Try
If data(i + index) = lookData(index) Then
If index = lookData.Length - 1 Then
If TypeOf replaceWith Is String Then
Api.kernel32.WriteProcessMemory(handle, address + i, Marshal.StringToHGlobalUni(DirectCast(replaceWith, String)), Convert.ToUInt32(DirectCast(replaceWith, String).Length * 2), done)
i += (index + DirectCast(replaceWith, String).Length)
Else
Dim replace As Byte() = Nothing
If TypeOf replaceWith Is Long Then
replace = BitConverter.GetBytes(CLng(replaceWith))
ElseIf TypeOf replaceWith Is Integer Then
replace = BitConverter.GetBytes(CInt(replaceWith))
ElseIf TypeOf replaceWith Is Short Then
replace = BitConverter.GetBytes(CShort(replaceWith))
ElseIf TypeOf replaceWith Is Byte Then
replace = New Byte() {CByte(replaceWith)}
End If
If True Then
Dim gc = GCHandle.Alloc(replace, GCHandleType.Pinned)
Api.kernel32.WriteProcessMemory(handle, address + i, gc.AddrOfPinnedObject(), 1, done)
gc.Free()
End If
If TypeOf replaceWith Is Long Then
i += (index + 8)
ElseIf TypeOf replaceWith Is Integer Then
i += (index + 4)
ElseIf TypeOf replaceWith Is Short Then
i += (index + 2)
ElseIf TypeOf replaceWith Is Byte Then
i += (index + 1)
End If
End If
Exit Try
End If
Else
i += index
Exit Try
End If
Catch
i += index
Exit Try
End Try
End While
Next
End If
If CLng(address) <= &H7FFFFFFF Then
If info.[Next] = address Then
Exit While
End If
address = info.[Next]
Else
Exit While
End If
End While
それは認識しません:
Api.kernel32
For i As var
StructLib.MEMORY_BASIC_INFORMATION
Dim size = CUInt(Marshal.SizeOf(GetType(**StructLib.MEMORY_BASIC_INFORMATION**)))
EnumLib.ProcessAccessFlags.All
helper.EnumProcess.Process().First(Function(res) res.szExeFile = "chrome.exe"
- 構造とは何ですか?
- ライブラリとは何ですか?