问题描述
我真的不明白为什么这不适用于64位应用程序读取32位应用程序模块。
与32位完美配合 - > 32位
当使用dwFlags& H8时,这非常适合从32位进程到其他32位进程的模块获取
但是64位到32位它失败,dwFlags设置为& H10,因为MSDN说
我似乎无法看到在64位编译中使用它时我需要更改的内容。
[b] API:[/ b]
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682489(v=vs。 85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684218(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684221(v=vs.85).aspx
[b]代码:[/ b]
[code]
I really don't get why this doesn't work for 64bit applications to read 32bit applications modules.
Works perfect with 32bit -> 32bit
Well this works perfect to grab modules from 32bit process to other 32bit process when using dwFlags &H8
But with 64bit to 32bit it fails with dwFlags set to &H10 as MSDN says
I can't seem to see what I have to change more when using it in a 64bit compile.
[b]API's:[/b]
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682489(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684218(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684221(v=vs.85).aspx
[b]Code:[/b]
[code]
Structure MODULEENTRY32
Dim U32Size As UInteger
Dim Th32ModuleId As UInteger
Dim Th32ProcessId As UInteger
Dim GlblcntUsage As UInteger
Dim ProccntUsage As UInteger
Dim ModBaseAddr As Byte
Dim ModBaseSize As UInteger
Dim HModule As Integer
<marshalas(unmanagedtype.byvaltstr,> Dim SzModule As String
<marshalas(unmanagedtype.byvaltstr,> Dim SzeExePath As String
End Structure
Private Function ModuleBase(ByVal strModule As String) As Integer
Dim p() As Process = Process.GetProcessesByName(Gname)
Dim hSnapshot As IntPtr = CreateToolhelp32Snapshot(&H10, CUInt(p(0).Id))
If hSnapshot = IntPtr.Zero Then Return Nothing
Dim me32Modules As New MODULEENTRY32
me32Modules.U32Size = CUInt(Marshal.SizeOf(me32Modules))
If Module32First(hSnapshot, me32Modules) Then
Do
If strModule = (me32Modules.SzModule) Then Return me32Modules.HModule
Loop While (Module32Next(hSnapshot, me32Modules))
End If
Return Nothing
End Function
[/ code]
推荐答案
这篇关于64位到32位的CreateToolHelp32Snapshot(VB.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!