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]