當前位置: 首頁>>代碼示例>>C++>>正文


C++ DetourAttach函數代碼示例

本文整理匯總了C++中DetourAttach函數的典型用法代碼示例。如果您正苦於以下問題:C++ DetourAttach函數的具體用法?C++ DetourAttach怎麽用?C++ DetourAttach使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了DetourAttach函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: InitStopWriteDisk

BOOL WINAPI InitStopWriteDisk()
{
	static BOOL bInit = FALSE;
	if ( FALSE == bInit )
	{
		bInit = TRUE;
		g_bEnableWriteDisk = TRUE;

 		DetourTransactionBegin();
 		DetourUpdateThread(GetCurrentThread());
 		DetourAttach(&(PVOID&)pCreateFileW, (PBYTE)MyCreateFileW);
 		DetourAttach(&(PVOID&)pWriteFile, (PBYTE)MyWriteFile);
 		DetourAttach(&(PVOID&)pReadFile, (PBYTE)MyReadFile);
 		DetourAttach(&(PVOID&)pSetFilePointer, (PBYTE)MySetFilePointer);
 		DetourAttach(&(PVOID&)pCloseHandle, (PBYTE)MyCloseHandle);
 		DetourAttach(&(PVOID&)pDeleteFileW, (PBYTE)MyDeleteFileW);
 		DetourAttach(&(PVOID&)pGetFileSize, (PBYTE)MyGetFileSize);
 		DetourAttach(&(PVOID&)pGetFileSizeEx, (PBYTE)MyGetFileSizeEx);
 		DetourAttach(&(PVOID&)pGetFileInformationByHandle, (PBYTE)MyGetFileInformationByHandle);
 		DetourAttach(&(PVOID&)pFlushViewOfFile, (PBYTE)MyFlushViewOfFile);
 		DetourTransactionCommit();

	}

	return FALSE;
}
開發者ID:gaozan198912,項目名稱:myproject,代碼行數:26,代碼來源:StopWriteDisk.cpp

示例2: InitInstance

void InitInstance(HANDLE hModule) 
{
	logf(0, "InitInstance.");

	// Initialisation
	gl_hOriginalDll        = NULL;
	gl_hThisInstance       = NULL;
	
	// Storing Instance handle into global var
	gl_hThisInstance = (HINSTANCE)  hModule;

	DisableThreadLibraryCalls((HMODULE) hModule);
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach(&(PVOID&)TextOutA_fn, myTextOutA);
	if(DetourTransactionCommit() != NO_ERROR)
	{
		logf(0, "Could not hook TextOutA");
		::ExitProcess(0);
	}
	DetourTransactionBegin();
	DetourAttach(&(PVOID&)CreateWindowEx_fn, myCreateWindowEx);
	if(DetourTransactionCommit() != NO_ERROR)
	{
		logf(0, "Could not hook CreateWindowEx");
		::ExitProcess(0);
	}
	DetourTransactionBegin();
	DetourAttach(&(PVOID&)DrawTextExA_fn, myDrawTextExA);
	if(DetourTransactionCommit() != NO_ERROR)
	{
		logf(0, "Could not hook DrawTextExA");
		::ExitProcess(0);
	}
}
開發者ID:ToadKing,項目名稱:ddhack,代碼行數:35,代碼來源:ddwrapper.cpp

示例3: HookUser32

bool HookUser32()
{
#if defined(DETOURS_VERSION) && DETOURS_VERSION == 20100 

	DetourTransactionBegin();
	DetourAttach(&(PVOID& )Real_GetAsyncKeyState, Mine_GetAsyncKeyState);
	DetourAttach(&(PVOID& )Real_GetKeyState, Mine_GetKeyState);
	DetourAttach(&(PVOID& )Real_GetKeyboardState, Mine_GetKeyboardState);
	DetourTransactionCommit();

#else // #if defined(DETOURS_VERSION) && DETOURS_VERSION == 20100 
	if (!DetourFunctionWithTrampoline((PBYTE)Real_GetAsyncKeyState,	(PBYTE)Mine_GetAsyncKeyState))
		return false;

	_TRACE("HookUser32(), Real_GetAsyncKeyState = %p, Mine_GetAsyncKeyState = %p\n", 
		Real_GetAsyncKeyState, &Mine_GetAsyncKeyState);

	if (!DetourFunctionWithTrampoline((PBYTE)Real_GetKeyState, (PBYTE)Mine_GetKeyState))
		return false;

	_TRACE("HookUser32(), Real_GetKeyState = %p, Mine_GetKeyState = %p\n", 
		Real_GetKeyState, &Mine_GetKeyState);

	DetourFunctionWithTrampoline((PBYTE)Real_GetKeyboardState,
		(PBYTE)Mine_GetKeyboardState);
#endif // #if defined(DETOURS_VERSION) && DETOURS_VERSION == 20100 
	return true;
}
開發者ID:IgorYunusov,項目名稱:mylibs,代碼行數:28,代碼來源:HackInput.cpp

示例4: Apply

    virtual void Apply() override
    {
        TRACE_ENTRYEXIT;

        std::cout << "old addr " << kOldAddr << " new addr " << kNewAddr << std::endl;

        mRealFuncPtr = (TFuncType)kOldAddr;

        LONG err = 0;
#pragma warning(push)
#pragma warning(disable:4127) // conditional expression is constant
        if (convention == eCDecl)
        {
            err = DetourAttach(&(PVOID&)mRealFuncPtr, Cdecl_Static_Hook_Impl);
        }
        else if (convention == eStdCall)
        {
            err = DetourAttach(&(PVOID&)mRealFuncPtr, StdCall_Static_Hook_Impl);
        }
        else
        {
            abort();
        }
#pragma warning(pop)
        if (err != NO_ERROR)
        {
            abort();
        }
    }
開發者ID:paulsapps,項目名稱:msgi,代碼行數:29,代碼來源:MgsFunction.hpp

示例5: DetourCreateProcessFunctions

static int DetourCreateProcessFunctions()
{
    PVOID OldCreatW=NULL,OldCreateA=NULL;

#if 0
    CreateProcessNext =(CreateProcessFunc_t) GetProcAddress(hModule,(LPCSTR)TEXT("CreateProcess"));
    if(CreateProcessNext == NULL)
    {
        ret = LAST_ERROR_CODE();
        ERROR_INFO("could not get process addr for CreateProcess error(%d)\n",ret);
        goto fail;
    }
#endif
    OldCreatW = (PVOID)CreateProcessWNext;
    DEBUG_INFO("CreateProcess Code");
    DEBUG_BUFFER(OldCreatW,5);

    OldCreateA = (PVOID)CreateProcessANext;
    DEBUG_BUFFER(OldCreateA,5);
    DetourTransactionBegin();
    DetourUpdateThread(GetCurrentThread());
    DetourAttach((PVOID*)&CreateProcessWNext,CreateProcessWCallBack);
    DetourAttach((PVOID*)&CreateProcessANext,CreateProcessACallBack);
    DetourTransactionCommit();
    DEBUG_INFO("After Detour Code");
    DEBUG_BUFFER(OldCreatW,5);
    DEBUG_BUFFER(OldCreateA,5);
    DEBUG_INFO("createprocess detour\n");
    return 0;
}
開發者ID:jeppeter,項目名稱:g3,代碼行數:30,代碼來源:injectbase.cpp

示例6: DllMain

BOOL APIENTRY DllMain( HMODULE hModule,
	DWORD  ul_reason_for_call,
	LPVOID lpReserved
	)
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		g_hDll = hModule;
		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach(&(PVOID&)CopyCreateFileW, Bio_CreateFileW);
		DetourAttach(&(PVOID&)CopyMoveFileW, Bio_MoveFileW);
		DetourAttach(&(PVOID&)CopyDeleteFileW, Bio_DeleteFileW);
		DetourAttach(&(PVOID&)CopyRemoveDirectoryW, Bio_RemoveDirectoryW);
		DetourAttach(&(PVOID&)CopyMessageBoxW, Bio_MessageBoxW);
		DetourTransactionCommit();
		break;
	case DLL_THREAD_ATTACH:
		break;
	case DLL_THREAD_DETACH:
		break;
	case DLL_PROCESS_DETACH:
		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourDetach(&(PVOID&)CopyCreateFileW, Bio_CreateFileW);
		DetourDetach(&(PVOID&)CopyMoveFileW, Bio_MoveFileW);
		DetourDetach(&(PVOID&)CopyDeleteFileW, Bio_DeleteFileW);
		DetourDetach(&(PVOID&)CopyRemoveDirectoryW, Bio_RemoveDirectoryW);
		DetourDetach(&(PVOID&)CopyMessageBoxW, Bio_MessageBoxW);
		DetourTransactionCommit();
		break;
	}
	return TRUE;
}
開發者ID:songcser,項目名稱:ALM,代碼行數:35,代碼來源:TEHook32Dll.cpp

示例7: DetourRestoreAfterWith

void DirectXHook::hookDirectX()
{
	horizontalRes = (uint32_t*)0x2301D08;
	verticalRes = (uint32_t*)0x2301D0C;

	uint32_t* directXVTable = **((uint32_t***)0x50DADDC);	// d3d9 interface ptr
	origEndScenePtr = (HRESULT(__stdcall *) (LPDIRECT3DDEVICE9)) directXVTable[42];
	origDrawIndexedPrimitivePtr = (HRESULT(__stdcall *) (LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, INT, UINT, UINT, UINT, UINT)) directXVTable[82];

	DetourRestoreAfterWith();
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach((PVOID*)&origEndScenePtr, &DirectXHook::hookedEndScene); // redirect origEndScenePtr to newEndScene

	if (DetourTransactionCommit() != NO_ERROR)
	{
		OutputDebugString("DirectX EndScene hook failed.");
	}

	DetourRestoreAfterWith();
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach((PVOID*)&origDrawIndexedPrimitivePtr, &DirectXHook::hookedDrawIndexedPrimitive); // redirect DrawIndexedPrimitive to newDrawIndexedPrimitive

	if (DetourTransactionCommit() != NO_ERROR)
	{
		OutputDebugString("DirectX DrawIndexedPrimitive hook failed.");
	}
}
開發者ID:ChurroV2,項目名稱:ElDorito,代碼行數:29,代碼來源:DirectXHook.cpp

示例8: ModifyFuncEntry

static VOID ModifyFuncEntry()
{
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach(&(PVOID&)TrueExtTextOutW, SUIExtTextOutW);
	DetourAttach(&(PVOID&)TrueTextOutW, SUITextOutW);
	DetourTransactionCommit();
}
開發者ID:tlswkdgb1,項目名稱:smartui-common,代碼行數:8,代碼來源:SUIGrabWord.cpp

示例9: DetourRestoreAfterWith

Menu::Menu()
{
	// Hook loadFinished & loadMap
	DetourRestoreAfterWith();
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach((PVOID*)&loadFinished, &hookedLoadFinished);
	DetourAttach((PVOID*)&loadMap, &hookedLoadMap);
}
開發者ID:ChurroV2,項目名稱:ElDorito,代碼行數:9,代碼來源:Menu.cpp

示例10: HookArmor

void HookArmor()
{
	DetourAttach((void**)MyClass::_UNKNOWN_0046F0B0_GetPtr(), (void*)GetFnAddr(&MyClass::TEST_0046F0B0));
	DetourAttach((void**)MyClass::_UNKNOWN_0046E720_GetPtr(), (void*)GetFnAddr(&MyClass::TEST_0046E720));
	//DetourAttach((void**)MyClass::_UNKNOWN_00432070_GetPtr(), *(void**)(&TEST_00432070));
	//auto TEST_00734F50 = &MyClass::TEST_00734F50;
	//auto TEST_00AB53E0 = &MyClass::TEST_00AB53E0;
	//DetourAttach((void**)MyClass::_UNKNOWN_00734F50_GetPtr(), *(void**)(&TEST_00734F50));
	//DetourAttach((void**)MyClass::_UNKNOWN_00AB53E0_GetPtr(), *(void**)(&TEST_00AB53E0));
}
開發者ID:MagneticHourglass,項目名稱:hdt-pe,代碼行數:10,代碼來源:HookArmor.cpp

示例11: HookMemory

void HookMemory()
{
	//DetourAttach((void**)&OLD_0042C840, TEST_0042C840);
	//DetourAttach((void**)&OLD_0042C870, TEST_0042C870);
	//DetourAttach((void**)&OLD_00BE70B0, TEST_00BE70B0);
	DetourAttach((void**)HookHeap::_Allocate_GetPtr(), (void*)GetFnAddr(&HookHeap::Allocate));
	DetourAttach((void**)hkSkyrimMemoryAllocator::_blockAlloc_GetPtr(), (void*)GetFnAddr(&hkSkyrimMemoryAllocator::blockAllocGuard));
	DetourAttach((void**)hkSkyrimMemoryAllocator::_blockFree_GetPtr(), (void*)GetFnAddr(&hkSkyrimMemoryAllocator::blockFreeGuard));
	DetourAttach((void**)UnkRCManager::_WaitForRun_GetPtr(), (void*)GetFnAddr(&UnkRCManager::WaitForRun));
	DetourAttach((void**)UnkHeapStruct1::_Unknown00436740_GetPtr(), (void*)GetFnAddr(&UnkHeapStruct1::TEST_00436740));
}
開發者ID:MagneticHourglass,項目名稱:hdt-pe,代碼行數:11,代碼來源:HookMemory.cpp

示例12: HookFunctions

void HookFunctions()
{
    DetourTransactionBegin();
    DetourUpdateThread(GetCurrentThread());
    *(DWORD*)&CGameSpyClient__JoinGroupRoom = 0x00805080;
    *(DWORD*)&CConnectionLib__UpdateGameSpyClient = 0x008027A0;
    int success = DetourAttach(&(PVOID&)CGameSpyClient__JoinGroupRoom, CGameSpyClient__JoinGroupRoom_Hook)==0  &&
                  DetourAttach(&(PVOID&)CConnectionLib__UpdateGameSpyClient, CConnectionLib__UpdateGameSpyClient_Hook)==0;

    fprintf(logFile, "Hooked: %d\n", success);
    DetourTransactionCommit();
}
開發者ID:addicted2rpg,項目名稱:NWNCX,代碼行數:12,代碼來源:serverlist.cpp

示例13: DetourRestoreAfterWith

void Hooker::Hook()
{
	DetourRestoreAfterWith();
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	
	
	DetourAttach(&(PVOID&)Real_TextOutA,Fake_TextOutA);
	DetourAttach(&(PVOID&)Real_TextOutW,Fake_TextOutW);
	DetourAttach(&(PVOID&)Real_ExtTextOutA,Fake_ExtTextOutA);
	DetourAttach(&(PVOID&)Real_ExtTextOutW,Fake_ExtTextOutW);	
	
	DetourTransactionCommit();
}
開發者ID:uestcll,項目名稱:practice,代碼行數:14,代碼來源:Hooker.cpp

示例14: DetourAttach

void PatchTitanium::Register() {
	Log::Get().Write(Log::Status, "Registering patch Titanium");
#ifdef EQC_ENABLE_COMMANDS
	DetourAttach(&(PVOID&)TitaniumPlayer__CommandHandler, TitaniumPlayerCommandHandlerHook);
#endif

	DetourAttach(&(PVOID&)TitaniumGame__RegisterZone, TitaniumGameRegisterZoneHook);
	DetourAttach(&(PVOID&)TitaniumGame__RegisterModel, TitaniumGameRegisterModelHook);
	DetourAttach(&(PVOID&)TitaniumGame__OnMsgRecv, TitaniumGameOnMsgRecvHook);

	SafeWriteBuffer(Titanium_aGame__TradeStackCheck1, &TitaniumTrade1[0], 39);
	SafeWriteBuffer(Titanium_aGame__TradeStackCheck2, &TitaniumTrade2[0], 6);

	DetourAttach(&(PVOID&)TitaniumGame__DisplayLoadingMessage, TitaniumGameDisplayLoadingMessageHook);
}
開發者ID:KimLS,項目名稱:EQC,代碼行數:15,代碼來源:patch_titanium.cpp

示例15: HookFunctions

void HookFunctions()
{
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	*(DWORD*)&CGuiInGame__AppendToMsgBuffer = 0x00493BD0;
	int success = DetourAttach(&(PVOID&)CGuiInGame__AppendToMsgBuffer, CGuiInGame__AppendToMsgBuffer_Hook)==0;
	*(DWORD*)&CClientExoAppInternal__Initialize = 0x00409D50;
	DetourAttach(&(PVOID&)CClientExoAppInternal__Initialize, CClientExoAppInternal__InitializeHook);

	*(DWORD*)&CClientExoApp__SetCaptureEvents = 0x00407FA0;
	*(DWORD*)&CClientExoApp__SetCaptureEventPlayBack = 0x00408000;

	fprintf(logFile, "Hooked: %d\n", success);
	DetourTransactionCommit();
}
開發者ID:HellSinker,項目名稱:nwncx,代碼行數:15,代碼來源:test.cpp


注:本文中的DetourAttach函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。