示例#1
0
void UninstallD3D8Hook()
{
	if(m_pfnDirect3DCreate8)
	{
		DetourRemove((PBYTE)m_pfnDirect3DCreate8, (PBYTE)Direct3DCreate8);
	}

	if(m_pfnDirectInput8Create)
	{
		DetourRemove((PBYTE)m_pfnDirectInput8Create, (PBYTE)DirectInput8Create);
	}
}
示例#2
0
文件: lac.cpp 项目: Leystryku/lac
GMOD_MODULE_CLOSE()
{
	preparedextension = false;
	Msg("[LAC] Unloading LAC Extension!\n");

	DetourRemove(ExecuteStringCmd);
	DetourRemove(ProcessRespondCvarValue);

	//ExecuteStringCmd = (OrigExecuteStringCmd)DetourCreate((BYTE*)executestringcmd, (BYTE*)hooked_ExecuteStringCmd, 6);
	//ProcessRespondCvarValue = (OrigProcessRespondCvarValue)DetourCreate((BYTE*)onquerycvarval, (BYTE*)hooked_ProcessRespondCvarValue, 6);

	return 0;
}
示例#3
0
// 卸载拦截
void UnIntercept()
{
	// 调用DetourRemove来去掉对一个目标函数的截获
	DetourRemove((PBYTE)Real_RegCreateKeyExA,(PBYTE)Replace_RegCreateKeyExA);
	DetourRemove((PBYTE)Real_RegCreateKeyExW,(PBYTE)Replace_RegCreateKeyExW);
	DetourRemove((PBYTE)Real_RegSetValueExA,(PBYTE)Replace_RegSetValueExA);
	DetourRemove((PBYTE)Real_RegSetValueExW,(PBYTE)Replace_RegSetValueExW);
	DetourRemove((PBYTE)Real_RegDeleteKeyA, (PBYTE)Replace_RegDeleteKeyA);
	DetourRemove((PBYTE)Real_RegDeleteKeyW, (PBYTE)Replace_RegDeleteKeyW);
	DetourRemove((PBYTE)Real_RegDeleteValueA, (PBYTE)Replace_RegDeleteValueA);
	DetourRemove((PBYTE)Real_RegDeleteValueW, (PBYTE)Replace_RegDeleteValueW);
	DetourRemove((PBYTE)Real_RegQueryValueExA, (PBYTE)Replace_RegQueryValueExA);
	DetourRemove((PBYTE)Real_RegQueryValueExW, (PBYTE)Replace_RegQueryValueExW);
}
示例#4
0
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
	switch(fdwReason)
	{
		case DLL_PROCESS_ATTACH:
		{
		set_score=(int (__stdcall*)(int))DetourFunction((PBYTE)0x01013C89, (PBYTE)SetCustomScore);
			break;
		}
		case DLL_PROCESS_DETACH:
		{
			DetourRemove((PBYTE)0x01013C89, (PBYTE)set_score);
			break;
		}
		case DLL_THREAD_ATTACH:
		{
			break;
		}
		case DLL_THREAD_DETACH:
		{
			break;
		}
	}
	
	/* Return TRUE on success, FALSE on failure */
	return TRUE;
}
void RemoveDetour(DWORD address)
{
    CAutoLock Lock(&gDetourCS);
    DebugSpew("RemoveDetour(%X)",address);
    OurDetours *detour = ourdetours;
    while (detour)
    {
        if (detour->addr==address)
        {
            if (detour->pfDetour)
            {
                DetourRemove(detour->pfTrampoline, 
                    detour->pfDetour);         
            }
            if (detour->pLast)
                detour->pLast->pNext=detour->pNext;
            else
                ourdetours=detour->pNext;

            if (detour->pNext)
                detour->pNext->pLast=detour->pLast;
            delete detour;
            DebugSpew("Detour removed.");
            return;
        }
        detour=detour->pNext;
    }
    DebugSpew("Detour not found in RemoveDetour()");
}
void CDirect3D9Hook::Uninstall()
{
	if(m_bHookInstalled)
    {
        if ( m_pfnDirect3DCreate9 )
		{
			DetourRemove ( reinterpret_cast < PBYTE > ( m_pfnDirect3DCreate9 ), reinterpret_cast < PBYTE > ( Direct3DCreate9_Hook ) );
		}
		
		if ( m_pfnDirect3DCreate9Ex )
		{
			DetourRemove ( reinterpret_cast < PBYTE > ( m_pfnDirect3DCreate9Ex ), reinterpret_cast < PBYTE > ( Direct3DCreate9Ex_Hook ) );
		}
                        
        m_bHookInstalled = false;
    }
}
void CDirectInput8Hook::Uninstall( )
{
	if( !m_bInstalled )
		return;

	DetourRemove( (PBYTE)m_pDirectInput8Create, (PBYTE)DirectInput8Create__Hook );

	m_bInstalled = false;
}
示例#8
0
void CSetCursorPosHook::RemoveHook()
{
    // Remove hook
    if (m_pfnSetCursorPos)
    {
        DetourRemove(reinterpret_cast<PBYTE>(m_pfnSetCursorPos), reinterpret_cast<PBYTE>(API_SetCursorPos));
    }

    // Reset variables
    m_pfnSetCursorPos = NULL;
    m_bCanCall = true;
}
void CDirectInput8Hook::Uninstall( )
{
	// Is the proxy not installed?
	if( !m_bInstalled )
		return;

	// Uninstall the detour patch
	DetourRemove( (PBYTE)m_pDirectInput8Create, (PBYTE)DirectInput8Create__Hook );

	// Mark as not installed
	m_bInstalled = false;
}
示例#10
0
int CGamePlaceApp::ExitInstance()
{
	// 卸载钩子
	DetourRemove((PBYTE)SetScrollInfoT, (PBYTE)SetScrollInfoD);
	DetourRemove((PBYTE)SetScrollPosT, (PBYTE)SetScrollPosD);
	DetourRemove((PBYTE)GetScrollInfoT, (PBYTE)GetScrollInfoD);
	DetourRemove((PBYTE)GetScrollPosT, (PBYTE)GetScrollPosD);
	DetourRemove((PBYTE)SetScrollRangeT, (PBYTE)SetScrollRangeD);
	DetourRemove((PBYTE)GetScrollRangeT, (PBYTE)GetScrollRangeD);
	DetourRemove((PBYTE)ShowScrollBarT, (PBYTE)ShowScrollBarD);
	DetourRemove((PBYTE)EnableScrollBarT, (PBYTE)EnableScrollBarD);

	return CWinApp::ExitInstance();
}
示例#11
0
int CMusicApp::ExitInstance()
{
	// TODO: Add your specialized code here and/or call the base class
	GdiplusShutdown(m_GdiplusToken);

	DetourRemove((PBYTE)SetScrollInfoT, (PBYTE)SetScrollInfoD);
	DetourRemove((PBYTE)SetScrollPosT, (PBYTE)SetScrollPosD);
	DetourRemove((PBYTE)GetScrollInfoT, (PBYTE)GetScrollInfoD);
	DetourRemove((PBYTE)GetScrollPosT, (PBYTE)GetScrollPosD);
	DetourRemove((PBYTE)SetScrollRangeT, (PBYTE)SetScrollRangeD);
	DetourRemove((PBYTE)GetScrollRangeT, (PBYTE)GetScrollRangeD);
	DetourRemove((PBYTE)ShowScrollBarT, (PBYTE)ShowScrollBarD);
	DetourRemove((PBYTE)EnableScrollBarT, (PBYTE)EnableScrollBarD);
	return CWinApp::ExitInstance();
}
示例#12
0
void RemoveOurDetours()
{
	CAutoLock Lock(&gDetourCS);
	DebugSpew("RemoveOurDetours()");
	if (!ourdetours)
		return;
	while (ourdetours)
	{
		if (ourdetours->pfDetour)
		{
			DebugSpew("RemoveOurDetours() -- Removing %s (%X)", ourdetours->Name, ourdetours->addr);
			DetourRemove(ourdetours->pfTrampoline, ourdetours->pfDetour);
		}

		OurDetours *pNext = ourdetours->pNext;
		delete ourdetours;
		ourdetours = pNext;
	}
}
BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        OutputDebugString("Detour dll Load!");
        DetourFunctionWithTrampoline((PBYTE)CopyOpenProcess, (PBYTE)MyOpenProcess);
        break;
    case DLL_THREAD_ATTACH:
        break;
    case DLL_THREAD_DETACH:
        break;
    case DLL_PROCESS_DETACH:
        OutputDebugString("Detour dll Exit!");
        DetourRemove((PBYTE)CopyOpenProcess, (PBYTE)MyOpenProcess);
        break;
    }
    return TRUE;
}
示例#14
0
void RemoveDetour(DWORD address)
{
	CAutoLock Lock(&gDetourCS);
	OurDetours *detour = ourdetours;
	while (detour)
	{
		if (detour->addr == address)
		{
			if (detour->pfDetour)
			{
				DebugSpew("DetourRemove %s (%X)", detour->Name, ((DWORD)GetModuleHandle(NULL) - address + 0x400000));
				DetourRemove(detour->pfTrampoline, detour->pfDetour);
				//sometimes its useful to add and then remove a detour and then add it again... and so on...
				//the following 2 lines fixes a detours "bug"
				//I don't know if this was MS intention
				//but if we don't set these to nop
				//we cant detour the same function more than once. -eqmule
				//so dont remove these.
				DWORD oldperm = 0,tmp;
				VirtualProtectEx(GetCurrentProcess(), (LPVOID)detour->pfTrampoline, 2, PAGE_EXECUTE_READWRITE, &oldperm);
				detour->pfTrampoline[0] = 0x90;
				detour->pfTrampoline[1] = 0x90;
				VirtualProtectEx(GetCurrentProcess(), (LPVOID)detour->pfTrampoline, 2, oldperm, &tmp);
			}
			if (detour->pLast)
				detour->pLast->pNext = detour->pNext;
			else
				ourdetours = detour->pNext;

			if (detour->pNext)
				detour->pNext->pLast = detour->pLast;
			delete detour;
			return;
		}
		detour = detour->pNext;
	}
	DebugSpew("Detour for %x not found in RemoveDetour()",((DWORD)GetModuleHandle(NULL) - address + 0x400000));
}
示例#15
0
void TSX_Client::Uninit()
{
	if (ini->GetInt("HookFileLoading",1)) {
		DetourRemove(oCreateFileW);
	}
}