示例#1
0
// DLL被加载、卸载时调用
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	TCHAR processPath[MAX_PATH];
	TCHAR msg[MAX_PATH + 20];

	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		GetModuleFileName(GetModuleHandle(NULL), processPath, MAX_PATH);
		_tcscpy_s(msg, _T("注入了进程 "));
		_tcscat_s(msg, processPath);
		MessageBox(NULL, msg, _T(""), MB_OK);

		hook(GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "TerminateProcess"), MyTerminateProcess, terminateProcessOldCode);
		break;

	case DLL_PROCESS_DETACH:
		MessageBox(NULL, _T("DLL卸载中"), _T(""), MB_OK);

		// 卸载时记得unhook
		unhook(GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "TerminateProcess"), terminateProcessOldCode);
		break;

	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
		break;
	}
	return TRUE;
}
示例#2
0
void
gui_mouse_event_end ()
{
    const char *mouse_key;

    gui_mouse_event_pending = 0;

    /* end mouse event timer */
    if (gui_mouse_event_timer)
    {
        unhook (gui_mouse_event_timer);
        gui_mouse_event_timer = NULL;
    }

    /* get key from mouse code */
    mouse_key = gui_mouse_event_code2key (gui_key_combo_buffer);
    if (mouse_key && mouse_key[0])
    {
        if (gui_mouse_grab)
        {
            gui_mouse_grab_end (mouse_key);
        }
        else
        {
            /* execute command (if found) */
            (void) gui_key_focus (mouse_key,
                                  GUI_KEY_CONTEXT_MOUSE);
        }
        gui_mouse_event_reset ();
    }

    gui_key_combo_buffer[0] = '\0';
}
static HRESULT STDMETHODCALLTYPE hook_present_swap(IDirect3DSwapChain9 *swap,
		CONST RECT *src_rect, CONST RECT *dst_rect,
		HWND override_window, CONST RGNDATA *dirty_region, DWORD flags)
{
	IDirect3DSurface9 *backbuffer = nullptr;
	IDirect3DDevice9 *device = nullptr;
	HRESULT hr;

	if (!present_recurse) {
		hr = swap->GetDevice(&device);
		if (SUCCEEDED(hr)) {
			device->Release();
		}
	}

	if (device) {
		if (!hooked_reset)
			setup_reset_hooks(device);

		present_begin(device, backbuffer);
	}

	unhook(&present_swap);
	present_swap_t call = (present_swap_t)present_swap.call_addr;
	hr = call(swap, src_rect, dst_rect, override_window, dirty_region,
			flags);
	rehook(&present_swap);

	if (device)
		present_end(device, backbuffer);

	return hr;
}
示例#4
0
void hook_exit(void) {
	int i;
	lock_kernel();
	for (i = 0; g_hi[i].newfunc; ++i) {
		unhook(&g_hi[i]);
	}
	unlock_kernel();
}
示例#5
0
HookController::~HookController()
{
	unhook();

	if(hookDllHandle)
	{
		FreeLibrary(hookDllHandle);
		hookDllHandle = 0;
	}
}
示例#6
0
void
hook_timer_exec ()
{
    struct timeval tv_time;
    struct t_hook *ptr_hook, *next_hook;

    if (!weechat_hooks[HOOK_TYPE_TIMER])
        return;

    hook_timer_check_system_clock ();

    gettimeofday (&tv_time, NULL);

    hook_exec_start ();

    ptr_hook = weechat_hooks[HOOK_TYPE_TIMER];
    while (ptr_hook)
    {
        next_hook = ptr_hook->next_hook;

        if (!ptr_hook->deleted
            && !ptr_hook->running
            && (util_timeval_cmp (&HOOK_TIMER(ptr_hook, next_exec),
                                  &tv_time) <= 0))
        {
            ptr_hook->running = 1;
            (void) (HOOK_TIMER(ptr_hook, callback))
                (ptr_hook->callback_pointer,
                 ptr_hook->callback_data,
                 (HOOK_TIMER(ptr_hook, remaining_calls) > 0) ?
                  HOOK_TIMER(ptr_hook, remaining_calls) - 1 : -1);
            ptr_hook->running = 0;
            if (!ptr_hook->deleted)
            {
                HOOK_TIMER(ptr_hook, last_exec).tv_sec = tv_time.tv_sec;
                HOOK_TIMER(ptr_hook, last_exec).tv_usec = tv_time.tv_usec;

                util_timeval_add (
                    &HOOK_TIMER(ptr_hook, next_exec),
                    ((long long)HOOK_TIMER(ptr_hook, interval)) * 1000);

                if (HOOK_TIMER(ptr_hook, remaining_calls) > 0)
                {
                    HOOK_TIMER(ptr_hook, remaining_calls)--;
                    if (HOOK_TIMER(ptr_hook, remaining_calls) == 0)
                        unhook (ptr_hook);
                }
            }
        }

        ptr_hook = next_hook;
    }

    hook_exec_end ();
}
示例#7
0
文件: radio.c 项目: cjxgm/dewox
void wradio_click(WRadio * w, int button, int state, int x, int y)
{
	if (button == MOUSE_LEFT && state == MOUSE_DOWN)
		if (w->state == WSTATE_HOVERED) {
			w->selected = w->tmp;
			hook(w, (ClickFunc)&wradio_click, NULL, NULL, NULL);
		}

	if (button == MOUSE_LEFT && state == MOUSE_UP)
		if (hooked == w)
			unhook();
}
示例#8
0
void
gui_mouse_event_init ()
{
    gui_mouse_event_pending = 1;

    if (gui_mouse_event_timer)
        unhook (gui_mouse_event_timer);

    gui_mouse_event_timer = hook_timer (NULL,
                                        CONFIG_INTEGER(config_look_mouse_timer_delay),
                                        0, 1,
                                        &gui_mouse_event_timer_cb, NULL);
}
示例#9
0
void EdbusDict::remove(const EdbusData& key) {
	unhook();

	EdbusDict::iterator it = impl->lst.begin(), it_end = impl->lst.end();
	while(it != it_end) {
		if((*it).key == key) {
			impl->lst.erase(it);
			break;
		}

		++it;
	}
}
示例#10
0
static HRESULT STDMETHODCALLTYPE hook_present(IDXGISwapChain *swap,
        UINT sync_interval, UINT flags)
{
    IUnknown *backbuffer = nullptr;
    bool capture_overlay = global_hook_info->capture_overlay;
    bool test_draw = (flags & DXGI_PRESENT_TEST) != 0;
    bool capture;
    HRESULT hr;

    if (!data.swap && !capture_active()) {
        setup_dxgi(swap);
    }

    capture = !test_draw && swap == data.swap && !!data.capture;
    if (capture && !capture_overlay) {
        backbuffer = get_dxgi_backbuffer(swap);

        if (!!backbuffer) {
            data.capture(swap, backbuffer, capture_overlay);
            backbuffer->Release();
        }
    }

    unhook(&present);
    present_t call = (present_t)present.call_addr;
    hr = call(swap, sync_interval, flags);
    rehook(&present);

    if (capture && capture_overlay) {
        /*
         * It seems that the first call to Present after ResizeBuffers
         * will cause the backbuffer to be invalidated, so do not
         * perform the post-overlay capture if ResizeBuffers has
         * recently been called.  (The backbuffer returned by
         * get_dxgi_backbuffer *will* be invalid otherwise)
         */
        if (resize_buffers_called) {
            resize_buffers_called = false;
        } else {
            backbuffer = get_dxgi_backbuffer(swap);

            if (!!backbuffer) {
                data.capture(swap, backbuffer, capture_overlay);
                backbuffer->Release();
            }
        }
    }

    return hr;
}
示例#11
0
//driver unload dispatch handler
VOID __stdcall DdkHookUnload(PDRIVER_OBJECT DriverObject) {
	UNICODE_STRING Win32NameString;

	KdPrint(("%s >> enter\n",__FUNCTION__));	

	// 설치된 훅을 제거
	unhook();

	// symbolic link 제거 및 디바이스 객체 삭제
	RtlInitUnicodeString(&Win32NameString,DOS_DEVICE_NAME);	
	IoDeleteSymbolicLink(&Win32NameString);	
	IoDeleteDevice(DriverObject->DeviceObject);

	KdPrint(("%s >> leave\n",__FUNCTION__));
}
示例#12
0
static HRESULT STDMETHODCALLTYPE hook_reset_ex(IDirect3DDevice9 *device,
		D3DPRESENT_PARAMETERS *params, D3DDISPLAYMODEEX *dmex)
{
	HRESULT hr;

	if (capture_active())
		d3d9_free();

	unhook(&reset_ex);
	reset_ex_t call = (reset_ex_t)reset_ex.call_addr;
	hr = call(device, params, dmex);
	rehook(&reset_ex);

	return hr;
}
示例#13
0
static HRESULT STDMETHODCALLTYPE hook_reset(IDirect3DDevice8 *device,
		D3DPRESENT_PARAMETERS *parameters)
{
	HRESULT hr;

	if (capture_active())
		d3d8_free();

	unhook(&reset);
	reset_t call = (reset_t)reset.call_addr;
	hr = call(device, parameters);
	rehook(&reset);

	return hr;
}
示例#14
0
void
gui_main_loop ()
{
    struct t_hook *hook_fd_keyboard;

    /* catch SIGWINCH signal: redraw screen */
    util_catch_signal (SIGWINCH, &gui_main_signal_sigwinch);

    /* hook stdin (read keyboard) */
    hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0,
                                &gui_key_read_cb, NULL);

    gui_window_ask_refresh (1);

    while (!dogechat_quit)
    {
        /* execute timer hooks */
        hook_timer_exec ();

        /* auto reset of color pairs */
        if (gui_color_pairs_auto_reset)
        {
            gui_color_reset_pairs ();
            gui_color_pairs_auto_reset_last = time (NULL);
            gui_color_pairs_auto_reset = 0;
            gui_color_pairs_auto_reset_pending = 1;
        }

        gui_main_refreshs ();
        if (gui_window_refresh_needed && !gui_window_bare_display)
            gui_main_refreshs ();

        if (gui_signal_sigwinch_received)
        {
            (void) hook_signal_send ("signal_sigwinch",
                                     DOGECHAT_HOOK_SIGNAL_STRING, NULL);
            gui_signal_sigwinch_received = 0;
        }

        gui_color_pairs_auto_reset_pending = 0;

        /* execute fd hooks */
        hook_fd_exec ();
    }

    /* remove keyboard hook */
    unhook (hook_fd_keyboard);
}
示例#15
0
static BOOL WINAPI hook_wgl_swap_layer_buffers(HDC hdc, UINT planes)
{
	BOOL ret;

	if (!global_hook_info->capture_overlay)
		gl_capture(hdc);

	unhook(&wgl_swap_layer_buffers);
	BOOL (WINAPI *call)(HDC, UINT) = wgl_swap_layer_buffers.call_addr;
	ret = call(hdc, planes);
	rehook(&wgl_swap_layer_buffers);

	if (global_hook_info->capture_overlay)
		gl_capture(hdc);

	return ret;
}
示例#16
0
static BOOL WINAPI hook_swap_buffers(HDC hdc)
{
	BOOL ret;

	if (!global_hook_info->capture_overlay)
		gl_capture(hdc);

	unhook(&swap_buffers);
	BOOL (WINAPI *call)(HDC) = swap_buffers.call_addr;
	ret = call(hdc);
	rehook(&swap_buffers);

	if (global_hook_info->capture_overlay)
		gl_capture(hdc);

	return ret;
}
示例#17
0
EDELIB_NS_BEGIN

void EdbusDict::append(const EdbusData& key, const EdbusData& value) {
	if(!EdbusData::basic_type(key))
		return;

	/*
	 * Assure all keys are the same type. The same applies with the values.
	 * This is done by checking first added entry, if exists. 
	 * We can accept keys (or values) with different types, but D-Bus does not
	 * like it.
	 */
	if(size() > 0) {
		if(key.type() != key_type() || value.type() != value_type()) {
			E_WARNING("Key or value is different type than I already have. Ignoring...");
			return;
		}
	}

	unhook();

	/*
	 * If entry with the same key already exists, just replace value. Opposite
	 * add as new entry.
	 *
	 * Not efficient at all, but this will assure dict contains unique keys.
	 * Dbus specs tolerates duplicate keys in dict, but it can mark data parts
	 * with them as invalid.
	 */
	EdbusDict::iterator it = impl->lst.begin(), it_end = impl->lst.end();
	while(it != it_end) {
		if((*it).key == key) {
			(*it).value = value;
			return;
		}

		++it;
	}

	EdbusDictEntry n;
	n.key = key;
	n.value = value;

	impl->lst.push_back(n);
}
示例#18
0
文件: button.c 项目: cjxgm/dewox
void wbutton_click(WButton * w, int button, int state, int x, int y)
{
	if (button == MOUSE_LEFT && state == MOUSE_DOWN)
		if (w->state == WSTATE_HOVERED) {
			w->state = WSTATE_PRESSED;
			hook(w, (ClickFunc)&wbutton_click,
					(DragFunc)&wbutton_drag, NULL, NULL);
		}

	if (button == MOUSE_LEFT && state == MOUSE_UP)
		if (hooked == w) {
			unhook();
			if (w->toggleable && w->state == WSTATE_PRESSED)
				w->toggled = !w->toggled;
			w->clicked = (w->state == WSTATE_PRESSED);
			w->state = (w->clicked ? WSTATE_HOVERED : WSTATE_NORMAL);
		}
}
示例#19
0
void
gui_color_switch_colors ()
{
    if (gui_color_hook_timer)
    {
        unhook (gui_color_hook_timer);
        gui_color_hook_timer = NULL;
    }

    /*
     * when we press alt-c many times quickly, this just adds some time for
     * display of terminal colors
     */
    if (gui_color_use_term_colors
        && (gui_color_timer > 0) && (gui_color_timer % 10 == 0))
    {
        if (gui_color_timer < 120)
            gui_color_timer += 10;
        gui_color_buffer_display_timer ();
    }
    else
    {
        gui_color_use_term_colors ^= 1;

        if (gui_color_use_term_colors)
            gui_color_init_pairs_terminal ();
        else
            gui_color_init_pairs_weechat ();

        gui_color_buffer_refresh_needed = 1;
        gui_window_ask_refresh (1);

        if (gui_color_use_term_colors)
            gui_color_timer = GUI_COLOR_TIMER_TERM_COLORS;
    }

    if (gui_color_use_term_colors)
    {
        gui_color_hook_timer = hook_timer (NULL, 1000, 0, 0,
                                           &gui_color_timer_cb, NULL);
    }
}
示例#20
0
int
network_connect_child_timer_cb (void *arg_hook_connect, int remaining_calls)
{
    struct t_hook *hook_connect;

    /* make C compiler happy */
    (void) remaining_calls;

    hook_connect = (struct t_hook *)arg_hook_connect;

    HOOK_CONNECT(hook_connect, hook_child_timer) = NULL;

    (void) (HOOK_CONNECT(hook_connect, callback))
        (hook_connect->callback_data,
         WEECHAT_HOOK_CONNECT_TIMEOUT,
         0, NULL, NULL);
    unhook (hook_connect);

    return WEECHAT_RC_OK;
}
示例#21
0
static BOOL WINAPI hook_wgl_delete_context(HGLRC hrc)
{
	BOOL ret;

	if (capture_active()) {
		HDC last_hdc = jimglGetCurrentDC();
		HGLRC last_hrc = jimglGetCurrentContext();

		jimglMakeCurrent(data.hdc, hrc);
		gl_free();
		jimglMakeCurrent(last_hdc, last_hrc);
	}

	unhook(&wgl_delete_context);
	BOOL (WINAPI *call)(HGLRC) = wgl_delete_context.call_addr;
	ret = call(hrc);
	rehook(&wgl_delete_context);

	return ret;
}
示例#22
0
static HRESULT STDMETHODCALLTYPE hook_present(IDirect3DDevice8 *device,
		CONST RECT *src_rect, CONST RECT *dst_rect,
		HWND override_window, CONST RGNDATA *dirty_region)
{
	IDirect3DSurface8 *backbuffer;
	HRESULT hr;

	backbuffer = d3d8_get_backbuffer(device);
	if (backbuffer) {
		d3d8_capture(device, backbuffer);
		backbuffer->Release();
	}

	unhook(&present);
	present_t call = (present_t)present.call_addr;
	hr = call(device, src_rect, dst_rect, override_window, dirty_region);
	rehook(&present);

	return hr;
}
示例#23
0
static HRESULT STDMETHODCALLTYPE hook_present(IDirect3DDevice9 *device,
		CONST RECT *src_rect, CONST RECT *dst_rect,
		HWND override_window, CONST RGNDATA *dirty_region)
{
	IDirect3DSurface9 *backbuffer = nullptr;
	HRESULT hr;

	if (!hooked_reset)
		setup_reset_hooks(device);

	present_begin(device, backbuffer);

	unhook(&present);
	present_t call = (present_t)present.call_addr;
	hr = call(device, src_rect, dst_rect, override_window, dirty_region);
	rehook(&present);

	present_end(device, backbuffer);

	return hr;
}
示例#24
0
文件: player.cpp 项目: inkooboo/areks
void Player::onTargetTouch(action::TouchPtr &touch)
{
	if( isAvatarCreated() )
	{
		switch( _head->getState() )
		{
		case objects::player::Head::REST:
			{
				View& view = master_t::subsystem<View>();
				shoot( view.toWorldCoordinates(touch->end) );
				break;
			}
		case objects::player::Head::HOOK:
			{
				unhook();
				break;
			}
		}
	}

}
示例#25
0
static HRESULT STDMETHODCALLTYPE hook_resize_buffers(IDXGISwapChain *swap,
        UINT buffer_count, UINT width, UINT height, DXGI_FORMAT format,
        UINT flags)
{
    HRESULT hr;

    if (!!data.free)
        data.free();

    data.swap = nullptr;
    data.free = nullptr;
    data.capture = nullptr;

    unhook(&resize_buffers);
    resize_buffers_t call = (resize_buffers_t)resize_buffers.call_addr;
    hr = call(swap, buffer_count, width, height, format, flags);
    rehook(&resize_buffers);

    resize_buffers_called = true;

    return hr;
}
示例#26
0
int
network_connect_gnutls_handshake_timer_cb (void *arg_hook_connect,
                                           int remaining_calls)
{
    struct t_hook *hook_connect;

    /* make C compiler happy */
    (void) remaining_calls;

    hook_connect = (struct t_hook *)arg_hook_connect;

    HOOK_CONNECT(hook_connect, handshake_hook_timer) = NULL;

    (void) (HOOK_CONNECT(hook_connect, callback))
            (hook_connect->callback_data,
             WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR,
             GNUTLS_E_EXPIRED,
             gnutls_strerror (GNUTLS_E_EXPIRED),
             HOOK_CONNECT(hook_connect, handshake_ip_address));
    unhook (hook_connect);

    return WEECHAT_RC_OK;
}
示例#27
0
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  fdwReason,
                       LPVOID lpReserved
					 )
{
	switch (fdwReason)
	{
	case DLL_PROCESS_ATTACH:
		
		if(hook())
			DebugMessageW(L"hook install Success\n");
		else
			DebugMessageW(L"hook install failed\n");
		
		break;
	case DLL_PROCESS_DETACH:		
		unhook();
		DebugMessageW(L"hook uninstall Success\n");
		
		break;
	}
	return TRUE;
}
示例#28
0
 virtual ~DBG_Hooks() { unhook(); }
示例#29
0
 virtual ~UI_Hooks()
 {
   unhook();
 }
示例#30
0
void
gui_main_loop ()
{
    struct t_hook *hook_fd_keyboard;
    struct timeval tv_timeout;
    fd_set read_fds, write_fds, except_fds;
    int max_fd;
    int ready;

    /* catch SIGTERM signal: quit program */
    util_catch_signal (SIGTERM, &gui_main_signal_sigterm);
    util_catch_signal (SIGQUIT, &gui_main_signal_sigquit);

    /* catch SIGHUP signal: reload configuration */
    util_catch_signal (SIGHUP, &gui_main_signal_sighup);

    /* catch SIGWINCH signal: redraw screen */
    util_catch_signal (SIGWINCH, &gui_main_signal_sigwinch);

    /* hook stdin (read keyboard) */
    hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0,
                                &gui_key_read_cb, NULL);

    gui_window_ask_refresh (1);

    while (!weechat_quit)
    {
        /* reload config, if SIGHUP received */
        if (gui_reload_config)
        {
            gui_reload_config = 0;
            log_printf (_("Signal SIGHUP received, reloading configuration "
                          "files"));
            command_reload (NULL, NULL, 0, NULL, NULL);
        }

        /* execute hook timers */
        hook_timer_exec ();

        /* auto reset of color pairs */
        if (gui_color_pairs_auto_reset)
        {
            gui_color_reset_pairs ();
            gui_color_pairs_auto_reset_last = time (NULL);
            gui_color_pairs_auto_reset = 0;
            gui_color_pairs_auto_reset_pending = 1;
        }

        gui_main_refreshs ();
        if (gui_window_refresh_needed && !gui_window_bare_display)
            gui_main_refreshs ();

        if (gui_signal_sigwinch_received)
        {
            (void) hook_signal_send ("signal_sigwinch",
                                     WEECHAT_HOOK_SIGNAL_STRING, NULL);
            gui_signal_sigwinch_received = 0;
        }

        gui_color_pairs_auto_reset_pending = 0;

        /* wait for keyboard or network activity */
        FD_ZERO (&read_fds);
        FD_ZERO (&write_fds);
        FD_ZERO (&except_fds);
        max_fd = hook_fd_set (&read_fds, &write_fds, &except_fds);
        hook_timer_time_to_next (&tv_timeout);
        ready = select (max_fd + 1, &read_fds, &write_fds, &except_fds,
                        &tv_timeout);
        if (ready > 0)
        {
            hook_fd_exec (&read_fds, &write_fds, &except_fds);
        }
    }

    /* remove keyboard hook */
    unhook (hook_fd_keyboard);
}