Beispiel #1
0
bool InitializeCallWndProcHook(int threadID, HWND destination)
{
	if (g_appInstance == NULL)
	{
		return false;
	}

	if (GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_CALLWNDPROC") != NULL)
	{
		SendNotifyMessage((HWND)GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_CALLWNDPROC"), RegisterWindowMessage("WILSON_HOOK_CALLWNDPROC_REPLACED"), 0, 0);
	}

	SetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_CALLWNDPROC", destination);

	hookCallWndProc = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)CallWndProcHookCallback, g_appInstance, threadID);
	return hookCallWndProc != NULL;
}
Beispiel #2
0
bool InitializeGetMsgHook(int threadID, HWND destination)
{
	if (g_appInstance == NULL)
	{
		return false;
	}

	if (GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_GETMSG") != NULL)
	{
		SendNotifyMessage((HWND)GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_GETMSG"), RegisterWindowMessage("WILSON_HOOK_GETMSG_REPLACED"), 0, 0);
	}

	SetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_GETMSG", destination);

	hookGetMsg = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)GetMsgHookCallback, g_appInstance, threadID);
	return hookGetMsg != NULL;
}
Beispiel #3
0
bool InitializeMouseHook(int threadID, HWND destination)
{
	if (g_appInstance == NULL)
	{
		return false;
	}

	if (GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_MOUSE") != NULL)
	{
		SendNotifyMessage((HWND)GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_MOUSE"), RegisterWindowMessage("WILSON_HOOK_MOUSE_REPLACED"), 0, 0);
	}

	SetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_MOUSE", destination);

	hookMouse = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)MouseHookCallback, g_appInstance, threadID);
	return hookMouse != NULL;
}
Beispiel #4
0
bool InitializeKeyboardHook(int threadID, HWND destination)
{
	if (g_appInstance == NULL)
	{
		return false;
	}

	if (GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_KEYBOARD") != NULL)
	{
		SendNotifyMessage((HWND)GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_KEYBOARD"), RegisterWindowMessage("WILSON_HOOK_KEYBOARD_REPLACED"), 0, 0);
	}

	SetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_KEYBOARD", destination);

	hookKeyboard = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)KeyboardHookCallback, g_appInstance, threadID);
	return hookKeyboard != NULL;
}
BOOL WINAPI InstallShellHookEx(HWND hWnd, UINT uMsg)  
{
	if (g_hDllInstance == NULL) return FALSE;
	if (g_Index < 0) return FALSE;
	int index = AddShellHookEntry(hWnd);
	if (index < 0 || index >= SHELLHOOK_ENTRY_MAX) return FALSE;
	if (g_hookEntries[index].hWnd) return FALSE;
	g_hookEntries[index].hWnd = hWnd;
	g_hookEntries[index].uMsg = uMsg;
	if (g_hHook == NULL)
	{
		HHOOK hhook = NULL;
		hhook = SetWindowsHookEx(WH_SHELL, ShellHookProcEx, g_hDllInstance, 0);
		InterlockedExchange((PLONG)&g_hHook, (LONG)hhook);
	}
	return TRUE;
}
Beispiel #6
0
bool InitializeShellHook(int threadID, HWND destination)
{
	if (g_appInstance == NULL)
	{
		return false;
	}

	if (GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_SHELL") != NULL)
	{
		SendNotifyMessage((HWND)GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_SHELL"), RegisterWindowMessage("WILSON_HOOK_SHELL_REPLACED"), 0, 0);
	}

	SetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_SHELL", destination);

	hookShell = SetWindowsHookEx(WH_SHELL, (HOOKPROC)ShellHookCallback, g_appInstance, threadID);
	return hookShell != NULL;
}
Beispiel #7
0
void InputHandler::setHook(DWORD tid)
{
  if(tid == NULL)
    tid = GetCurrentThreadId(); // Set the hook on current thread

  std::list<DWORD>::iterator i = hookedThreads.begin();
  while(i != hookedThreads.end()) {
    if(*i == tid) {
      return;
    }
    i++;
  }

  threadHookMsg = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) GetMsgProc, 0, tid);
  hookedThreads.push_back(tid);
  dbg("InputHandler: Installed mouse hook 0x%08X on thread 0x%08X (%d hooks)", threadHookMsg, tid, hookedThreads.size());
}
void MainDialog::ToolbarWithMenu::ShowMenu() {
  button_index = toolbar->SendMessage(TB_GETHOTITEM);

  TBBUTTON tbb;
  toolbar->GetButton(button_index, tbb);
  toolbar->PressButton(tbb.idCommand, TRUE);

  // Calculate point
  RECT rect;
  toolbar->SendMessage(TB_GETITEMRECT, button_index, reinterpret_cast<LPARAM>(&rect));
  POINT pt = {rect.left, rect.bottom};
  ClientToScreen(toolbar->GetWindowHandle(), &pt);

  // Hook
  if (hook) UnhookWindowsHookEx(hook);
  hook = SetWindowsHookEx(WH_MSGFILTER, &HookProc, NULL, GetCurrentThreadId());

  // Display menu
  std::wstring action;
  HWND hwnd = DlgMain.GetWindowHandle();
  #define SHOWUIMENU(id, name) \
    case id: action = ui::Menus.Show(hwnd, pt.x, pt.y, name); break;
  switch (tbb.idCommand) {
    SHOWUIMENU(100, L"File");
    SHOWUIMENU(101, L"Services");
    SHOWUIMENU(102, L"Tools");
    SHOWUIMENU(103, L"View");
    SHOWUIMENU(104, L"Help");
    SHOWUIMENU(kToolbarButtonFolders, L"Folders");
    SHOWUIMENU(kToolbarButtonTools, L"ExternalLinks");
  }
  #undef SHOWUIMENU

  // Unhook
  if (hook) {
    UnhookWindowsHookEx(hook);
    hook = nullptr;
  }

  toolbar->PressButton(tbb.idCommand, FALSE);

  if (!action.empty()) {
    ExecuteAction(action);
    ui::Menus.UpdateAll(DlgAnimeList.GetCurrentItem());
  }
}
int main(int argc, char* argv[])
{
 HMODULE hKernel32=GetModuleHandle("kernel32");
 GetConsoleWindow=(PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsoleWindow");
 hHook=SetWindowsHookEx(14,(HOOKPROC)HookProc,NULL,NULL);
 MSG msg;
 printf("准备工作完成!\n");
 while(GetMessage(&msg,NULL,0,0))
 {
  if(msg.message==WM_USER+1)
  {
   if(MessageBox(NULL,"QUIT?","Console",MB_YESNO)==IDYES) SendMessage(GetConsoleWindow(),WM_CLOSE,NULL,NULL);
  }
 }
 UnhookWindowsHookEx(hHook);
 return 0;
}
Beispiel #10
0
void InitTooltips(HWND h) {
    if (h == NULL)  return;
    memset(&g_tip,0,sizeof(NTOOLTIP));
    g_tip.tip_p = h;
    INITCOMMONCONTROLSEX icx;
    icx.dwSize = sizeof(icx);
    icx.dwICC  = ICC_BAR_CLASSES;
    InitCommonControlsEx(&icx);
    DWORD dwStyle = WS_POPUP | WS_BORDER | TTS_ALWAYSTIP;
    DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
    g_tip.tip = CreateWindowEx(dwExStyle,TOOLTIPS_CLASS,NULL,dwStyle,0,0,0,0,h,NULL,GetModuleHandle(NULL),NULL);
    if (!g_tip.tip) return;
    g_tip.hook = SetWindowsHookEx(WH_GETMESSAGE,TipHookProc,NULL, GetCurrentThreadId());
    AddTip(GetDlgItem(h,IDCANCEL),_T("Close MakeNSISW"));
    AddTip(GetDlgItem(h,IDC_TEST),_T("Test the installer generated by MakeNSISW"));
    AddToolBarTooltips();
}
Beispiel #11
0
int HookKeyboard() {
  if (keyhook) {
    // Keyboard already hooked
    return 1;
  }

  // Set up the hook
  keyhook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, g_hinst, 0);
  if (keyhook == NULL) {
    Error(L"SetWindowsHookEx(WH_KEYBOARD_LL)", L"Could not hook keyboard. Another program might be interfering.", GetLastError());
    return 1;
  }

  // Success
  UpdateTray();
  return 0;
}
Beispiel #12
0
static PyObject *
FreeCADGui_showMainWindow(PyObject * /*self*/, PyObject *args)
{
    PyObject* inThread = Py_False;
    if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &inThread))
        return NULL;

    static GUIThread* thr = 0;
    if (!qApp) {
        if (PyObject_IsTrue(inThread)) {
            if (!thr) thr = new GUIThread();
            thr->start();
        }
        else {
#if defined(Q_OS_WIN)
            static int argc = 0;
            static char **argv = {0};
            (void)new QApplication(argc, argv);
            // When QApplication is constructed
            hhook = SetWindowsHookEx(WH_GETMESSAGE,
                FilterProc, 0, GetCurrentThreadId());
#elif !defined(QT_NO_GLIB)
            static int argc = 0;
            static char **argv = {0};
            (void)new QApplication(argc, argv);
#else
            PyErr_SetString(PyExc_RuntimeError, "Must construct a QApplication before a QPaintDevice\n");
            return NULL;
#endif
        }
    }
    else if (!qobject_cast<QApplication*>(qApp)) {
        PyErr_SetString(PyExc_RuntimeError, "Cannot create widget when no GUI is being used\n");
        return NULL;
    }

    if (!thr) {
        if (!setupMainWindow()) {
            PyErr_SetString(PyExc_RuntimeError, "Cannot create main window\n");
            return NULL;
        }
    }

    Py_INCREF(Py_None);
    return Py_None;
}
Beispiel #13
0
WINERROR LLHookRegister0(IN PLLHOOK pHook)
{
	WINERROR Status = NO_ERROR;
	// Add the window to the clipboard viewer chain. 
	ASSERT(pHook->hHook==NULL);
	pHook->hHook = 
		SetWindowsHookEx(
			WH_KEYBOARD_LL, 
			(HOOKPROC)LLKeyboardProc, 
			g_CurrentProcessModule, 0
			);
	if ( pHook->hHook == NULL ){
		Status = GetLastError();
		DbgPrint("SetWindowsHookEx failed, err=%lu\n",Status);
	}
	return Status;
}
int DisplayDialog ( WStringAutoPtr title, WStringAutoPtr message, WStringAutoPtr button1, WStringAutoPtr button2, WStringAutoPtr button3 )
{
	// set the names to be used for each button
	g_button1_name.swap ( *button1 );
	g_button2_name.swap ( *button2 );
	g_button3_name.swap ( *button3 );

	// the type of dialog displayed varies depends on the nunmber of buttons required
	UINT type = MB_OK;

	if ( g_button2_name != L"" ) {
		type = MB_OKCANCEL;
		if ( g_button3_name != L"" ) {
			type = MB_YESNOCANCEL;
		}
	}

	// set the callback so that the custom button names are installed
	g_window_hook = SetWindowsHookEx ( WH_CBT, &DialogCallback, 0, GetCurrentThreadId() );

	/*
	 get the user's choice and translate that into a response that matches the equivalent
	 choice on OS X
	 */

	int button_clicked = MessageBox ( GetActiveWindow(), message->c_str(), title->c_str(), type );

	unsigned long response = 0;

	switch ( button_clicked ) {
			
		case IDOK:
		case IDYES:
			response = kBE_OKButton;
			break;
		case IDCANCEL:
			response = kBE_CancelButton;
			break;
		case IDNO:
			response = kBE_AlternateButton;
			break;
	}

	return response;

} // DisplayDialog
Beispiel #15
0
MODULE MODULE_EXPORT int
install_hook(const char *ga_root, const char *config, const char *app_exe)
{
	if(ga_root == NULL || config == NULL) {
		ga_error("[install_hook] no ga-root nor configuration were specified.\n");
		return -1;
	}
	
	if((gHook = SetWindowsHookEx(WH_CBT, hook_proc, hInst, 0)) == NULL) {
		ga_error("SetWindowsHookEx filaed (0x%08x)\n", GetLastError());
		return -1;
	}

	ga_error("[install_hook] success.\n");
	
	return 0;
}
Beispiel #16
0
HWND player_impl::create_window(const char *player_name)
{
	WNDCLASSEXA wcex;

	// 得到进程实例句柄.
	m_hinstance = (HINSTANCE)GetModuleHandle(NULL);
	// 创建非纯黑色的画刷, 用于ddraw播放时刷背景色.
	m_brbackground = CreateSolidBrush(RGB(0, 0, 1));
	wcex.cbSize = sizeof(WNDCLASSEXA);

	wcex.style			= CS_CLASSDC/*CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS*/;
	wcex.lpfnWndProc	= player_impl::static_win_wnd_proc;
	wcex.cbClsExtra	= 0;
	wcex.cbWndExtra	= 0;
	wcex.hInstance		= m_hinstance;
	wcex.hIcon			= LoadIcon(m_hinstance, MAKEINTRESOURCE(IDC_ICON));
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= m_brbackground;	// (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName		= NULL;				// MAKEINTRESOURCE(IDC_AVPLAYER);
	wcex.lpszClassName	= player_name;
	wcex.hIconSm			= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDC_ICON));

	if (!RegisterClassExA(&wcex))
	{
		::logger("register window class failed!\n");
		return NULL;
	}

	// 创建hook, 以便在窗口创建之前得到HWND句柄, 使HWND与this绑定.
	HHOOK hook = SetWindowsHookEx(WH_CBT, win_cbt_filter_hook, NULL, GetCurrentThreadId());
	win_data_ptr->set_hook_handle(hook);
	win_data_ptr->set_current_window(this);

	// 创建窗口.
	m_hwnd = CreateWindowExA(/*WS_EX_APPWINDOW*/0,
		player_name, player_name, WS_OVERLAPPEDWINDOW/* | WS_CLIPSIBLINGS | WS_CLIPCHILDREN*/,
		0, 0, 800, 600, NULL, NULL, m_hinstance, NULL);

	// 撤销hook.
	UnhookWindowsHookEx(hook);
	win_data_ptr->set_hook_handle(NULL);

	ShowWindow(m_hwnd, SW_SHOW);

	return m_hwnd;
}
Beispiel #17
0
static
void __cdecl hook_thread(void *arg)
{
    struct hook_data *data = (struct hook_data *)arg;
    MSG msg;
    int ret;

    /* create thread message queue */
    PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);

    hook_thread_id = GetCurrentThreadId();

    mouse_ll_hook = SetWindowsHookEx(WH_MOUSE_LL, mouse_ll_proc,
                                     ctx.instance, 0);
    if(mouse_ll_hook == NULL) {
        hook_thread_id = 0;
        data->ret = 0;
    } else {
        data->ret = 1;
    }
    data->last_error = GetLastError();
    SetEvent(data->start_evt);

    while(hook_thread_id > 0) {
        ret = GetMessage(&msg, NULL, 0, 0);
        if(ret < 0) {
            break;
        }

        if(ret == 0 ||
           msg.message == HOOK_THREAD_END) {
            UnhookWindowsHookEx(mouse_ll_hook);
            mouse_ll_hook = NULL;

            SetEvent(hook_thread_end_evt);
            break;
        }

        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    hook_thread_id = 0;
    _endthread();
}
Beispiel #18
0
/*
MAIN - EINSTIEGSPUNKT
*/
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	HANDLE hMutex = CreateMutex(NULL, true, TRAINERNAME);

	if (GetLastError() == ERROR_ALREADY_EXISTS || hMutex == INVALID_HANDLE_VALUE)
		return FALSE;

	g_hInstance = hInstance;

	// "Software\\Nadeo\\TMUltraTrainer"
	Registration::SetSavePath("Software\\Nadeo\\TMUltraTrainer");

	if (!Registration::CheckRegistration())
	{
		DialogBox(GetDllModule(), MAKEINTRESOURCE(IDD_DIALOG3), NULL, Registration::RegistrationProc);
	}

	if (!Registration::IsRegistered())
		return FALSE;

	InitConsole();

	CSplash splash;
	splash.SetBitmap((HBITMAP)LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, NULL, NULL, NULL));
	splash.SetTransparentColor(RGB(255,255,255));
	splash.ShowSplash();

	g_hLowLevelKeyHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), NULL);
	
	Sleep(2000);
	splash.CloseSplash();
	
	CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
	ShowWindow(g_hWindow, SW_SHOW);

	// Hauptnachrichtenschleife:
	MSG msg;
	while (GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return (int) msg.wParam;
}
DWORD WINAPI ccvv(){
	DWORD dwThreadID;
	
	hGame=FindWindowA("ApolloRuntimeContentWindow","PVP.net 客户端");//PVP.net 客户端 PVP.net Client
	if (!hGame) { 
		g_hGetMsg = NULL;
		return NULL; 
	}
	else {
		if (g_hGetMsg) return (DWORD)g_hGetMsg;
	}
	dwThreadID=GetWindowThreadProcessId(hGame,NULL);
	if(!dwThreadID) return NULL;
	g_hGetMsg=SetWindowsHookEx(WH_GETMESSAGE,GetMsgProc,hInstance,dwThreadID);
	if(!g_hGetMsg) return NULL;
	PostMessageA(hGame,0x801,0,(LPARAM)g_hGetMsg);
	return (DWORD)g_hGetMsg;
}
KEYBOARDHOOK_API BOOL SetHook(HWND hWnd, UINT message)
{
	islogkbdlib::KbdLogs::getInstance()->LogEvent("#SetHook# begins.");
	if (s_hWndServer != NULL)
		return FALSE; // already hooked

	hook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)msghook, __hKbdHookModule, 0);
	if (hook == FALSE)
	{
		islogkbdlib::KbdLogs::getInstance()->LogEvent("#SetHook# Unable to set hook {%d}!", GetLastError());
		return FALSE;
	}

	s_hWndServer = hWnd;
	s_message = message;
	islogkbdlib::KbdLogs::getInstance()->LogEvent("#SetHook# Hook set successfully.");
	return TRUE;
}
	void init(HINSTANCE hInstDll) {
		OutputDebugStringA(__FUNCTION__"\n");
		hook = SetWindowsHookEx(WH_MOUSE_LL, static_hookMouseLl, hInstDll, 0);

		if(hook == 0) {
			DWORD err = GetLastError();
			LPVOID lpMsgBuf;
			FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
						  0, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, 0);
			MessageBox(0, (LPCTSTR)lpMsgBuf, _T("Error"), MB_OK | MB_ICONINFORMATION);
			LocalFree(lpMsgBuf);
		} else {
			prevLeftDownTime	= getCurrentTime();
			prevLeftUpTime		= getCurrentTime();
			prevRightDownTime	= getCurrentTime();
			prevRightUpTime		= getCurrentTime();
		}
	}
Beispiel #22
0
/// install keyboard hook
DllExport int installKeyboardHook(INPUT_DETOUR i_keyboardDetour, Engine *i_engine, bool i_install)
{
    if (i_install) {
        if (!g.m_isInitialized)
            initialize(true);

        g.m_keyboardDetour = i_keyboardDetour;
        g.m_engine = i_engine;
        g.m_hHookKeyboardProc =
            SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)lowLevelKeyboardProc,
                             g.m_hInstDLL, 0);
    } else {
        if (g.m_hHookKeyboardProc)
            UnhookWindowsHookEx(g.m_hHookKeyboardProc);
        g.m_hHookKeyboardProc = NULL;
    }
    return 0;
}
Beispiel #23
0
int kbd_init(HWND hWnd_, HINSTANCE hInstance) {
	HHOOK ret;
	DWORD err;

	odprintf("kbd[init]");

	SetLastError(0);
	ret = SetWindowsHookEx(WH_KEYBOARD_LL, kbd_hook, hInstance, 0);
	err = GetLastError();
	odprintf("SetWindowsHookEx: %p (%d)", ret, err);
	if (ret == NULL)
		return 1;

	hWnd = hWnd_;
	hHook = ret;

	return 0;
}
__declspec(dllexport) BOOL InstallMyKeyHook(HWND hWnd, UINT message_to_call)
    {
     if(hWndServerKey != NULL)
	return FALSE; // already hooked!
     //hook = SetWindowsHookEx(WH_GETMESSAGE,
	 hookKey = SetWindowsHookEx(WH_KEYBOARD,
			    (HOOKPROC)hookkeyproc,
			    hInst,
			    0);
     if(hookKey != NULL)
	{ /* success */
	 hWndServerKey = hWnd;
	 nMsgKey = message_to_call;
	 
	 return TRUE;
	} /* success */
     return FALSE; // failed to set hook
    } // setMyHook
Beispiel #25
0
AT_API BOOL AT_HK_Initialise(HWND hWnd)
{
  // Calling process: Initialise(m_hWnd)
  if (hWndServer != NULL)
    return FALSE;

  m_shl_hook = SetWindowsHookEx(WH_SHELL,
                            (HOOKPROC)ShellProc,
                            m_hInstance,
                            0);

  if (m_shl_hook != NULL) {
    hWndServer = hWnd;
    return TRUE;
  }

  return FALSE;
}
DWORD WINAPI vmsIeTabsHookFitter::_threadHookFitter(LPVOID pv)
{
	vmsTab* tab = (vmsTab*)pv;

	Sleep (1000);
	extern HWND find_ie_server (HWND hwnd);
	HWND hwnd = find_ie_server (tab->hwndTab);
	if (hwnd == NULL)
		return 0;

	tab->dwTabThreadId = GetWindowThreadProcessId (hwnd, NULL);
	tab->hHook = SetWindowsHookEx (WH_CALLWNDPROC, _hookProc, NULL, tab->dwTabThreadId);

	WaitForSingleObject (tab->hevShutdown, INFINITE);
	UnhookWindowsHookEx (tab->hHook);

	return 0;
}
Beispiel #27
0
bool InitializeSysMsgFilterHook(int threadID, HWND destiantion)
{
	if(g_appInstance == NULL)
	{
		return false;
	}

	if (GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_SYSMSGFILTER") != NULL)
	{
		SendNotifyMessage((HWND)GetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_SYSMSGFILTER"), RegisterWindowMessage("WILSON_HOOK_SYSMSGFILTER_REPLACED"), 0, 0);
	}

	SetProp(GetDesktopWindow(), "WILSON_HOOK_HWND_SYSMSGFILTER", destiantion);

	hookSysMsgFilter = SetWindowsHookEx(WH_SYSMSGFILTER,(HOOKPROC)SysMsgFilterHookCallback,g_appInstance,threadID);

	return hookSysMsgFilter != NULL;
}
Beispiel #28
0
THelp :: THelp   ( TWindow *	win )
   {
	register int		i ;


// Vérifier si un objet de ce type a déjà été déclaré
	if  ( TheHelpObject  !=  NULL )
		throw  xmsg ( string ( "Un objet de type THelp a été déclaré une seconde fois !" ) ) ;

	TheHelpObject = this ;


// Fenêtre parente de WinHelp
	MainWindow = win ;


// Initialisation des touches d'appel; on est sympa, on en fait une par défaut
	memset ( Hotkeys, 0, sizeof ( Hotkeys ) ) ;
	Hotkeys [0]. KeyCode 	=  VK_F1 ;
	Hotkeys [0]. Modifiers  =  None ;
	Hotkeys [0]. Type	=  Normal ;
	HotkeyCount = 1 ;

// Autres initialisations
	memset ( HelpTable, 0, sizeof ( HelpTable ) ) ;
	memset ( HelpFileNames, 0, sizeof ( HelpFileNames ) ) ;

	for  ( i = 0 ; i < MAX_HELP_ENTRIES ; i ++ )
		HelpTable [i]. HelpFileIndex = -1 ;

	HelpTableCount = 0 ;

	LastSelectedMenu	=  0 ;
	LastSelectedMenuType	=  0 ;
	LastSelectedMenuHandle 	=  0 ;


// Puis d'installer le hook qui va nous permettre de récupérer la même chose,
// mais pour les menus et les boîtes de dialogue
	MsgFilterHookId =  SetWindowsHookEx ( WH_MSGFILTER, 
				( HOOKPROC )  MsgFilterHookProc,
				* ( MainWindow -> GetModule ( ) ), 
					GetCurrentTask ( ) ) ;
    }
	// Menu Screen Shot
	JNIEXPORT JHANDLE JNICALL OS_NATIVE(_1fetchPopupMenuVisualData)(JNIEnv *env, jclass that, JHANDLE jshell, JHANDLE jmenu, jintArray jsizes) {
		// initializing
		HWND oldFocused = GetFocus();
		hCallWndHook = NULL;
		hwndPopupMenu = NULL;
		hdefaultDC = NULL;
		hDC = NULL;
		hBitmap = NULL;
		wpOrigEditProc = NULL;
		calcSizeDone = false;
		hWnd = (HWND)unwrap_pointer(env, jshell);
		hMenu = (HMENU)unwrap_pointer(env, jmenu);
		// install hook
//		DWORD ourThreadID = GetWindowThreadProcessId(hWnd, NULL);
		DWORD ourThreadID = GetCurrentThreadId();
		hCallWndHook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)CallWndProc,	NULL, ourThreadID);
		if (hCallWndHook == NULL) {
			return NULL;
		}
		// prepare dimensions array elements
		jsize sizesSize = env->GetArrayLength(jsizes);
		sizes = new jint[sizesSize];
		// display menu window
		SetForegroundWindow(hWnd);
		TrackPopupMenuEx(hMenu, TPM_HORIZONTAL | TPM_LEFTALIGN | TPM_NOANIMATION, 100, 100, hWnd, NULL);
		// copy dimensions into java array
		env->SetIntArrayRegion(jsizes, 0, sizesSize, sizes);
		// remove hook and clean up
		UnhookWindowsHookEx(hCallWndHook);
		hCallWndHook = NULL;
		if (hdefaultDC) {
			ReleaseDC(NULL, hdefaultDC);
		}
		if (hDC) {
			DeleteDC(hDC);
		}
		delete []sizes;
		// restore focus
		if (oldFocused != NULL) {
			SetFocus(oldFocused);
		}
		// return bitmap (may be NULL)
		return wrap_pointer(env, hBitmap);
	}
Beispiel #30
0
extern "C" __declspec(dllexport) void __cdecl InstallHooks() {
	DWORD dwWaitResult = WaitForSingleObject(hHookMutex, 1000L);
	if (dwWaitResult == WAIT_OBJECT_0) {
		if (sd != NULL && ! sd->bHooked) {
			HMODULE hSelf = NULL;
			GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (char *) &InstallHooks, &hSelf);
			if (hSelf == NULL) {
				ods("Lib: Failed to find myself");
			} else {
				hhookWnd = SetWindowsHookEx(WH_CBT, CallWndProc, hSelf, 0);
				if (hhookWnd == NULL)
					ods("Lib: Failed to insert WNDProc hook");
			}

			sd->bHooked = true;
		}
		ReleaseMutex(hHookMutex);
	}
}