Esempio n. 1
0
ULONG STDMETHODCALLTYPE IDirect3D9_Release_Hook(IDirect3D9* This) {
	auto count = IDirect3D9_Release_Orig(This);
	if (count == 1 && --IDirect3D9_HookCount == 0) {
		UNHOOK(IDirect3D9, This, CreateDevice);
		UNHOOK(IDirect3D9, This, Release);
		count = IDirect3D9_Release(This);
	}
	return count;
}
Esempio n. 2
0
ULONG STDMETHODCALLTYPE IDirect3D9Ex_Release_Hook(IDirect3D9Ex* This) {
	auto count = IDirect3D9Ex_Release_Orig(This);
	if (count == 1 && --IDirect3D9Ex_HookCount == 0) {
		UNHOOK(IDirect3D9, reinterpret_cast<IDirect3D9*>(This), CreateDevice);
		UNHOOK(IDirect3D9Ex, This, CreateDeviceEx);
		UNHOOK(IDirect3D9Ex, This, Release);
		count = IDirect3D9Ex_Release(This);
	}
	return count;
}
Esempio n. 3
0
/// Helper function to unhook the CreateFactory2 interface
/// \param hDXGI Input DXGI module
void UnhookCreateDXGIFactory2Function(HMODULE hDXGI)
{
    LogTrace(traceENTER, "");

    // don't detach twice
    if (Real_CreateDXGIFactory2 == NULL)
    {
        Log(logERROR, "Attempting to call UnhookCreateDXGIFactory2() twice\n");
        LogTrace(traceEXIT, "");
        return;
    }

    if (hDXGI != NULL)
    {
        LONG error;
        AMDT::BeginHook();

        LogTrace(traceEXIT, "UnhookCreateDXGIFactory2");

        UNHOOK(Real_CreateDXGIFactory2, Mine_CreateDXGIFactory2);

        if (AMDT::EndHook() != NO_ERROR)
        {
            Log(logERROR, "UnhookCreateDXGIFactory2 Failed\n");
        }
    }

    Real_CreateDXGIFactory2 = NULL;

    LogTrace(traceEXIT, "");

    return;
}
Esempio n. 4
0
void LoopFunction()
{
	if (hooked == false)
	{
		DWORD VTable[3] = { 0 };
		while (GetModuleHandleA("d3d9.dll") == NULL)
		{
			Sleep(250);
		}
		DX_Init(VTable);
		HOOK(EndScene, VTable[0]);
		while (!nm_pD3Ddev)
		{
			Sleep(50);
		}
		UNHOOK(EndScene, VTable[0]);
		*(PDWORD)&pEndScene = VTable[0];
		CreateThread(NULL, 0, &VMT_Patching, NULL, 0, NULL); //Create hooking thread
		hooked = true;
	}
}
Esempio n. 5
0
//-----------------------------------------------------------------------------
/// Calls Unhook on all the real-mine function pairs
/// \return the ref count
//-----------------------------------------------------------------------------
bool HookBase::Detach()
{
    ScopeLock t(&m_mtx);

    if (m_dwAttached == 1)
    {
        LONG error;
        AMDT::BeginHook();

        for (DWORD i = 0; i < m_Real.size(); i++)
        {
            UNHOOK(*m_Real[i], m_Mine[i]);
        }

        error = AMDT::EndHook();

        if (error != NO_ERROR)
        {
            Log(logERROR, "Detaching to %s failed\n", m_Name.c_str());
            return false;
        }
        else
        {
            m_dwAttached--;
        }
    }
    else if (m_dwAttached > 1)
    {
        m_dwAttached--;
    }
    else // m_dwAttached is less than 0
    {
        Log(logERROR, "Detaching %s refcount < 0 !!\n", m_Name.c_str());
        return false;
    }

    return true;
}
Esempio n. 6
0
void RegTree::Unhook( void )
{
	UNHOOK(RegCloseKey);
	UNHOOK(RegCreateKeyExW);
	UNHOOK(RegDeleteKeyW);
	UNHOOK(RegDeleteValueW);
	UNHOOK(RegEnumKeyW);
	UNHOOK(RegEnumKeyExW);
	UNHOOK(RegEnumValueW);
	UNHOOK(RegFlushKey);
	UNHOOK(RegGetKeySecurity);
	UNHOOK(RegLoadKeyW);
	UNHOOK(RegNotifyChangeKeyValue);
	UNHOOK(RegOpenKeyExW);
	UNHOOK(RegOverridePredefKey);
	UNHOOK(RegQueryInfoKeyW);
	UNHOOK(RegQueryMultipleValuesW);
	UNHOOK(RegQueryValueExW);
	UNHOOK(RegReplaceKeyW);
	UNHOOK(RegRestoreKeyW);
	UNHOOK(RegSaveKeyW);
	UNHOOK(RegSaveKeyExW);
	UNHOOK(RegSetKeySecurity);
	UNHOOK(RegSetValueExW);
	UNHOOK(RegUnLoadKeyW);
}