Support for showing if app is 32bit vs 64bit, and support for doing message hooks on both

Added support for message hook viewer to hook both 32 and 64 bit
applications.
Fixed filtering on the msg hook viewer
Added custom filtering on msg hook viewer
Added Process Id targetting on msg hook viewer
Added SetMsgHook.exe command line app as an alternative way of starting
msg hook viewer.
This commit is contained in:
Edward Jakubowski
2014-06-03 06:28:14 -04:00
parent 05748b4582
commit d100d23259
41 changed files with 1232 additions and 72 deletions

View File

@@ -20,12 +20,14 @@ import com.sun.jna.platform.win32.WinDef.*;
import com.sun.jna.platform.win32.Advapi32Util;
import com.sun.jna.platform.win32.BaseTSD.LONG_PTR;
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR;
import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO;
import com.sun.jna.platform.win32.WinDef;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinReg;
import com.sun.jna.platform.win32.WinUser;
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
import com.sun.jna.platform.win32.WinUser.WNDENUMPROC;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
import com.sun.jna.win32.W32APIOptions;
@@ -323,6 +325,9 @@ public class Api {
boolean GetDiskFreeSpaceEx(String lpDirectoryName, LARGE_INTEGER.ByReference lpFreeBytesAvailable, LARGE_INTEGER.ByReference lpTotalNumberOfBytes, LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes);
int GetLastError();
Pointer OpenProcess(int dwDesiredAccess, boolean bInheritHandle, Pointer pointer);
boolean CloseHandle(HANDLE hObject);
void GetNativeSystemInfo(SYSTEM_INFO lpSystemInfo);
boolean IsWow64Process(HANDLE hProcess, IntByReference Wow64Process);
}
@@ -627,6 +632,36 @@ public class Api {
return false;
}
public static boolean isProcess64bit(int pid)
{
try {
SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO();
Kernel32.instance.GetNativeSystemInfo(lpSystemInfo);
if (lpSystemInfo.processorArchitecture.dwOemID.intValue() == 0)
{
System.out.println("intel x86"); //not a 64 bit os
return false;
}
Pointer process = Kernel32.instance.OpenProcess(Api.PROCESS_QUERY_INFORMATION | Api.PROCESS_VM_READ, false, new Pointer(pid));
IntByReference isWow64 = new IntByReference(0);
if (!Kernel32.instance.IsWow64Process(new HANDLE(process), isWow64))
{
//handle error
}
//System.out.println("isProcess64bit " + pid + " = " + isWow64.getValue());
Kernel32.instance.CloseHandle(new HANDLE(process));
if (isWow64.getValue() == 1)
return false;
return true;
//CloseHandle()
} catch(Exception ex)
{
ex.printStackTrace();
}
return false;
}
public static HWND FindMainWindowFromPid(final long targetProcessId) {
final List<HWND> resultList = new ArrayList<HWND>();