当前位置: 首页>>代码示例>>C++>>正文


C++ DetourUpdateThread函数代码示例

本文整理汇总了C++中DetourUpdateThread函数的典型用法代码示例。如果您正苦于以下问题:C++ DetourUpdateThread函数的具体用法?C++ DetourUpdateThread怎么用?C++ DetourUpdateThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DetourUpdateThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DllMain

// =============================================================================
// DllMain
// =============================================================================
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved)
{
	if (DetourIsHelperProcess()) {
		return TRUE;
	}

	if (dwReason == DLL_PROCESS_ATTACH) {

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach(&(PVOID&)pWSAStartup, MyWSAStartup);
		DetourAttach(&(PVOID&)pSocket, MySocket);
		DetourAttach(&(PVOID&)pConnect, MyConnect);
		DetourAttach(&(PVOID&)pSend, MySend);
		DetourAttach(&(PVOID&)pClosesocket, MyClosesocket);
		DetourAttach(&(PVOID&)pWSACleanup, MyWSACleanup);
		DetourTransactionCommit();
	}
	else if (dwReason == DLL_PROCESS_DETACH) {
		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourDetach(&(PVOID&)pWSAStartup, MyWSAStartup);
		DetourDetach(&(PVOID&)pSocket, MySocket);
		DetourDetach(&(PVOID&)pConnect, MyConnect);
		DetourDetach(&(PVOID&)pSend, MySend);
		DetourDetach(&(PVOID&)pClosesocket, MyClosesocket);
		DetourDetach(&(PVOID&)pWSACleanup, MyWSACleanup);
		DetourTransactionCommit();
	}
	return TRUE;
}
开发者ID:itayzach,项目名称:BTProxy,代码行数:34,代码来源:dllmain+before+ip+change.cpp

示例2: DllMain

BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved) {
	if (DetourIsHelperProcess()) {
		return TRUE;
	}
	
	char buffer[100];
	if (dwReason == DLL_PROCESS_ATTACH) {
		OutputDebugString("Hooking");	
		DetourRestoreAfterWith();

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());		
		oldDirectInput8Create = (HRESULT(WINAPI *)(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID * ppvOut, LPUNKNOWN punkOuter))DetourFindFunction("dinput8.dll", "DirectInput8Create");
		sprintf_s(buffer, 100, "DirectInput8Create at %x", oldDirectInput8Create);
		OutputDebugString(buffer);
		if(oldDirectInput8Create == NULL)
			OutputDebugString("Failed to find function");
		int error = DetourAttach(&(PVOID&)oldDirectInput8Create, myDirectInput8Create);
		if(error != NO_ERROR)
			OutputDebugString("Failed to detour");
		error = DetourTransactionCommit();
		if(error != NO_ERROR)
			OutputDebugString("Failed to commit");
	}
	else if (dwReason == DLL_PROCESS_DETACH) {
		OutputDebugString("Unhooking");
		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourDetach(&(PVOID&)oldDirectInput8Create, myDirectInput8Create);
		DetourDetach(&(PVOID&)oldCreateDevice, myCreateDevice);
		DetourDetach(&(PVOID&)oldGetDeviceState, myGetDeviceState);
		DetourTransactionCommit();
	}
	return TRUE;
}
开发者ID:sbobovyc,项目名称:WinHookInject,代码行数:35,代码来源:dllmain.cpp

示例3: DllMain

BOOL APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved)
{
    switch(Reason)
    {
    case DLL_PROCESS_ATTACH:
        /* Detour interesting function */
        DisableThreadLibraryCalls(hDLL);
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        DetourAttach(&(PVOID&)detFunc, MyDetourFunction); // actual detour fn_a -> fn_b
        if(DetourTransactionCommit() == NO_ERROR)
            OutputDebugString("function detoured successfully");

        break;


    case DLL_PROCESS_DETACH:
        /* De-Detour interesting function */
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        DetourDetach(&(PVOID&)detFunc, MyDetourFunction); // removing the detour
        if(DetourTransactionCommit() == NO_ERROR)
            OutputDebugString("function detour removed");

        break;


    case DLL_THREAD_ATTACH:
        break;
    case DLL_THREAD_DETACH:
        break;
    }
    return TRUE;
}
开发者ID:carlosgprado,项目名称:Boyka,代码行数:34,代码来源:BoykaDLL.cpp

示例4: 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

示例5: DllMain

BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD dwReason, PVOID)
{
    switch (dwReason)
    {
    case DLL_PROCESS_ATTACH:
        {
            _Module.Init(NULL, hDllHandle);

            HMODULE hKernel32 = GetModuleHandle(_T("kernel32.dll"));
            RawLoadLibraryW = reinterpret_cast<FNLoadLibraryW>(GetProcAddress(hKernel32,
                "LoadLibraryW"));
            DetourTransactionBegin();
            DetourUpdateThread(GetCurrentThread());
            DetourAttach(reinterpret_cast<PVOID *>(&RawLoadLibraryW), HookLoadLibraryW);
            DetourTransactionCommit();

            Globals::Init();
            break;
        }
    case DLL_PROCESS_DETACH:
        {
            Globals::Uninit();

            DetourTransactionBegin();
            DetourUpdateThread(GetCurrentThread());
            DetourDetach(reinterpret_cast<PVOID *>(&RawLoadLibraryW), HookLoadLibraryW);
            DetourTransactionCommit();

            _Module.Term();
            break;
        }
    }
    return TRUE;
}
开发者ID:ArthurJhon,项目名称:SuperF12,代码行数:34,代码来源:DllMain.cpp

示例6: 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

示例7: DllMain

BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved)
{
    LONG error;
    (void)hinst;
    (void)reserved;

    if (DetourIsHelperProcess()) {
        return TRUE;
    }

    if (dwReason == DLL_PROCESS_ATTACH) {
        DetourRestoreAfterWith();

        printf("dslept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
               " Starting.\n");
        Verify("SleepEx", (PVOID)SleepEx);
        printf("\n");
        fflush(stdout);

        // NB: DllMain can't call LoadLibrary, so we hook the app entry point.
        TrueEntryPoint = (int (WINAPI *)(VOID))DetourGetEntryPoint(NULL);
        RawEntryPoint = TrueEntryPoint;

        Verify("EntryPoint", RawEntryPoint);

        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        DetourAttach(&(PVOID&)TrueEntryPoint, TimedEntryPoint);
        error = DetourTransactionCommit();

        Verify("EntryPoint after attach", RawEntryPoint);
        Verify("EntryPoint trampoline", TrueEntryPoint);

        if (error == NO_ERROR) {
            printf("dslept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
                   " Detoured EntryPoint().\n");
        }
        else {
            printf("dslept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
                   " Error detouring EntryPoint(): %d\n", error);
        }
    }
    else if (dwReason == DLL_PROCESS_DETACH) {
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        if (TrueSleepEx != NULL) {
            DetourDetach(&(PVOID&)TrueSleepEx, (PVOID)TimedSleepEx);
        }
        DetourDetach(&(PVOID&)TrueEntryPoint, TimedEntryPoint);
        error = DetourTransactionCommit();

        printf("dslept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
               " Removed Sleep() detours (%d), slept %d ticks.\n", error, dwSlept);

        fflush(stdout);
    }
    return TRUE;
}
开发者ID:qeedquan,项目名称:game_format_dumpers,代码行数:58,代码来源:dslept.cpp

示例8: DetourFunction

void DetourFunction(T &OriginalFunction, U HookFunction)
{
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach(&reinterpret_cast<void*&>(OriginalFunction), reinterpret_cast<void*>(HookFunction));
	DetourTransactionCommit();
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
}
开发者ID:Brandon-T,项目名称:DXI,代码行数:9,代码来源:VTable+D3D9+Hook+LoadLibrary+Intercept.cpp

示例9: main

int main(int argc, char **argv)
{
    HRESULT hr;

    (void)argc;
    (void)argv;

    LPSTREAM pStream = NULL;
    ULARGE_INTEGER ul;
    LARGE_INTEGER li;

    CoInitialize(NULL);

    hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);

    RealIStreamWrite = pStream->lpVtbl->Write;

    ul.QuadPart = 512;
    hr = pStream->lpVtbl->SetSize(pStream, ul);
    li.QuadPart = 0;
    hr = pStream->lpVtbl->Seek(pStream, li, STREAM_SEEK_SET, NULL);

    printf("commem: Calling Write w/o before attach.\n");

    li.QuadPart = 0;
    hr = pStream->lpVtbl->Write(pStream, &ul, sizeof(ul), NULL);

    DetourTransactionBegin();
    DetourUpdateThread(GetCurrentThread());
    DetourAttach(&(PVOID&)RealIStreamWrite, MineIStreamWrite);
    DetourTransactionCommit();

    printf("commem: Calling Write w/o after attach.\n");

    li.QuadPart = 1;
    hr = pStream->lpVtbl->Write(pStream, &li, sizeof(li), NULL);

    DetourTransactionBegin();
    DetourUpdateThread(GetCurrentThread());
    DetourDetach(&(PVOID&)RealIStreamWrite, MineIStreamWrite);
    DetourTransactionCommit();

    printf("commem: Calling Write w/o after detach.\n");

    li.QuadPart = 2;
    hr = pStream->lpVtbl->Write(pStream, &li, sizeof(li), NULL);

    hr = pStream->lpVtbl->Release(pStream);
    pStream = NULL;

    CoUninitialize();

    return 0;
}
开发者ID:HITKIL,项目名称:Ten18,代码行数:54,代码来源:commem.cpp

示例10: DllMain

// DllMain function attaches and detaches the TimedSleep detour to the
// Sleep target function.  The Sleep target function is referred to
// through the TrueSleep target pointer.
//
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved)
{ 	
	if (DetourIsHelperProcess()) {
		return TRUE;
	}
	/*
	hFile = CreateFile(logFile,                // name of the write
		GENERIC_WRITE,          // open for writing
		FILE_SHARE_WRITE,       // share for writing
		NULL,                   // default security
		OPEN_ALWAYS,            // open file only
		FILE_ATTRIBUTE_NORMAL,  // normal file
		NULL);                  // no attr. template

	//_tprintf(TEXT("Start of log file @ %s.\n"), logFile);
	*/

	if (dwReason == DLL_PROCESS_ATTACH) {	
		DetourRestoreAfterWith();

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach(&(PVOID&)TrueSleep, TimedSleep);
		ATTACH(GetProcAddress);
		ATTACH(LoadLibraryA);
		ATTACH(LoadLibraryExA);
		ATTACH(LoadLibraryExW);
		ATTACH(LoadLibraryW);
		ATTACH(VirtualAlloc);
		ATTACH(VirtualAllocEx);
		ATTACH(VirtualProtect);
		ATTACH(VirtualProtectEx);
		DetourTransactionCommit();
	}
	else if (dwReason == DLL_PROCESS_DETACH) {
		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourDetach(&(PVOID&)TrueSleep, TimedSleep);
		DETACH(GetProcAddress);
		DETACH(LoadLibraryA);
		DETACH(LoadLibraryExA);
		DETACH(LoadLibraryExW);
		DETACH(LoadLibraryW);
		DETACH(VirtualAlloc);
		DETACH(VirtualAllocEx);
		DETACH(VirtualProtect);
		DETACH(VirtualProtectEx);
		DetourTransactionCommit();
		//CloseHandle(hFile);
	}
	return TRUE;
}
开发者ID:sumitb,项目名称:the-wall,代码行数:56,代码来源:hook.cpp

示例11: DllMain

BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved)
{
    LONG error;
    (void)hinst;
    (void)reserved;

    if (DetourIsHelperProcess()) {
        return TRUE;
    }

    if (dwReason == DLL_PROCESS_ATTACH) {
        DetourRestoreAfterWith();

        printf("slept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
               " Starting.\n");
        PVOID pbExeEntry = DetourGetEntryPoint(NULL);
        PVOID pbDllEntry = DetourGetEntryPoint(hinst);
        printf("slept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
               " ExeEntry=%p, DllEntry=%p\n", pbExeEntry, pbDllEntry);

        Verify("SleepEx", (PVOID)SleepEx);
        printf("\n");
        fflush(stdout);

        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        DetourAttach(&(PVOID&)TrueSleepEx, TimedSleepEx);
        error = DetourTransactionCommit();

        if (error == NO_ERROR) {
            printf("slept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
                   " Detoured SleepEx() @ %p.\n", TrueSleepEx);
        }
        else {
            printf("slept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
                   " Error detouring SleepEx(): %d\n", error);
        }
    }
    else if (dwReason == DLL_PROCESS_DETACH) {
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        DetourDetach(&(PVOID&)TrueSleepEx, TimedSleepEx);
        error = DetourTransactionCommit();
        printf("slept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
               " Removed SleepEx() detour (%d), slept %d ticks.\n", error, dwSlept);
        fflush(stdout);
    }
    return TRUE;
}
开发者ID:qeedquan,项目名称:game_format_dumpers,代码行数:49,代码来源:slept.cpp

示例12: hook_d9

static int
hook_d9(const char *hook_type, const char *hook_method) {
	HMODULE hMod;
	// GetCreateDeviceAddress
	//ga_error("Start to hook Direct3DCreate9 ...");
	//
	if((hMod = GetModuleHandle("d3d9.dll")) == NULL) {
		if((hMod = LoadLibrary("d3d9.dll")) == NULL) {
			ga_error("Load d3d9.dll failed.\n");
			return -1;
		}
	}
	// Direct3DCreate9()
	pD3d = (TDirect3DCreate9)
		GetProcAddress(hMod, "Direct3DCreate9");
	if(pD3d == NULL) {
		ga_error("GetProcAddress(Direct3DCreate9) failed.\n");
		return -1;
	}
	//
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach(&(PVOID&)pD3d, hook_d3d);
	DetourTransactionCommit();
	//
	return 0;
}
开发者ID:hillaker,项目名称:AdvancedNetworking,代码行数:27,代码来源:ga-hook.cpp

示例13: Hook_R_DrawViewModel

bool Hook_R_DrawViewModel()
{
	static bool firstRun = true;
	static bool firstResult = true;
	if (!firstRun) return firstResult;
	firstRun = false;

	if (HL_ADDR_GET(R_DrawViewModel))
	{
		LONG error = NO_ERROR;

		g_Old_R_DrawViewModel = (R_DrawViewModel_t)AFXADDR_GET(R_DrawViewModel);

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach(&(PVOID&)g_Old_R_DrawViewModel, New_R_DrawViewModel);
		error = DetourTransactionCommit();

		if (NO_ERROR != error)
		{
			firstResult = false;
			ErrorBox("Interception failed:\nHook_R_DrawViewModel");
		}
	}
	else
		firstResult = false;

	return firstResult;
}
开发者ID:ripieces,项目名称:advancedfx,代码行数:29,代码来源:R_DrawViewModel.cpp

示例14: HookAPI

//------------------------------------------------------------------------------------------
//	Function name:	HookAPI
//	Description:	Hooking the real functions and our intercepted ones.
//------------------------------------------------------------------------------------------
void HookAPI()
{
	if(DetourTransactionBegin() != NO_ERROR)
	{
		LOGFILE("Hook Transcation Failed");	
		exit(-1);
	}
	DetourUpdateThread(GetCurrentThread());
	if(DetourAttach(&(PVOID&)Real_Direct3DCreate9, Mine_Direct3DCreate9) != NO_ERROR)
	{
		LOGFILE("Hook Directx 3d Failed");	
		exit(-1);
	}
	/*if(DetourAttach(&(PVOID&)Real_CreateWindowExA,Mine_CreateWindowExA) != NO_ERROR)
	{
		LOGFILE("Hook CreateWindowsExA Failed");	
		exit(-1);
	}
	if(DetourAttach(&(PVOID&)Real_CreateWindowExW, Mine_CreateWindowExW) != NO_ERROR)
	{
		LOGFILE("Hook CreateWindowsExw Failed");	
		exit(-1);
	}*/

	if(DetourTransactionCommit() != NO_ERROR)
	{
		LOGFILE("Hook Transcation Commit Failed");	
		exit(-1);
	}
	
}
开发者ID:polyu,项目名称:Cloud_Game,代码行数:35,代码来源:dxhook.cpp

示例15: FileFilter_Load

void FileFilter_Load()
{
	CreateInterfaceFn engineFactory =  Sys_GetFactory("engine.dll");

	netstringtables = (INetworkStringTableContainer *)engineFactory(INTERFACENAME_NETWORKSTRINGTABLESERVER, NULL);
	if(netstringtables == NULL)
	{
		Msg("Unable to find string tables!\n");
		return;
	}

	CSigScan::sigscan_dllfunc = engineFactory;
	bool scan = CSigScan::GetDllMemInfo();

	sigcheckfileext_Sig.Init((unsigned char *)SIG_CHECKFILE, SIG_CHECKFILEMASK, SIG_CHECKFILELEN);

	Msg("CheckFile signature %x\n", sigcheckfileext_Sig.sig_addr);

	if(sigcheckfileext_Sig.sig_addr)
	{
		checkext_trampoline = (checkext_t)sigcheckfileext_Sig.sig_addr;

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
			DetourAttach(&(PVOID&)checkext_trampoline, (PVOID)(&(PVOID&)checkext_hook));
		DetourTransactionCommit();
	}
	else
	{
		Msg("Couldn't find CheckFile function!\n");
		return;
	}
}
开发者ID:MerlinStarfinder,项目名称:gmodmodules,代码行数:33,代码来源:filecheck.cpp


注:本文中的DetourUpdateThread函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。