예제 #1
0
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;
}
예제 #2
0
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);
	}
}
예제 #3
0
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;
}
예제 #4
0
    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();
        }
    }
예제 #5
0
파일: injectbase.cpp 프로젝트: jeppeter/g3
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;
}
예제 #6
0
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;
}
예제 #7
0
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.");
	}
}
예제 #8
0
static VOID ModifyFuncEntry()
{
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach(&(PVOID&)TrueExtTextOutW, SUIExtTextOutW);
	DetourAttach(&(PVOID&)TrueTextOutW, SUITextOutW);
	DetourTransactionCommit();
}
예제 #9
0
파일: Menu.cpp 프로젝트: ChurroV2/ElDorito
Menu::Menu()
{
	// Hook loadFinished & loadMap
	DetourRestoreAfterWith();
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach((PVOID*)&loadFinished, &hookedLoadFinished);
	DetourAttach((PVOID*)&loadMap, &hookedLoadMap);
}
예제 #10
0
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));
}
예제 #11
0
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));
}
예제 #12
0
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();
}
예제 #13
0
파일: Hooker.cpp 프로젝트: uestcll/practice
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();
}
예제 #14
0
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);
}
예제 #15
0
파일: test.cpp 프로젝트: HellSinker/nwncx
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();
}
예제 #16
0
파일: patch_sod.cpp 프로젝트: KimLS/EQC
void PatchSoD::Register() {
	Log::Get().Write(Log::Status, "Registering patch SoD");
#ifdef EQC_ENABLE_COMMANDS
	DetourAttach(&(PVOID&)SoDPlayer__CommandHandler, SoDPlayerCommandHandlerHook);
#endif

	DetourAttach(&(PVOID&)SoDGame__RegisterZone, SoDGameRegisterZoneHook);
	DetourAttach(&(PVOID&)SoDGame__RegisterModel, SoDGameRegisterModelHook);
	DetourAttach(&(PVOID&)SoDGame__OnMsgRecv, SoDGameOnMsgRecvHook);

	SafeWriteBuffer(SoD_aGame__TradeStackCheck1, &SoDTrade1[0], 48);
	SafeWriteBuffer(SoD_aGame__TradeStackCheck2, &SoDTrade2[0], 9);

	DetourAttach(&(PVOID&)SoDGame__DisplayLoadingMessage, SoDGameDisplayLoadingMessageHook);
}
예제 #17
0
파일: dxhook.cpp 프로젝트: polyu/Cloud_Game
//------------------------------------------------------------------------------------------
//	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);
	}
	
}
예제 #18
0
// Detour function that replaces the IDirect3dDevice9::GetSwapChain() API
DllExport HRESULT __stdcall hook_D3D9GetSwapChain(
		IDirect3DDevice9 *This,
		UINT iSwapChain,
		IDirect3DSwapChain9 **ppSwapChain
	)
{
	static int getswapchain_hooked = 0;

	HRESULT hr = pD3D9GetSwapChain(This, iSwapChain, ppSwapChain);
	
	if (getswapchain_hooked > 0)
		return hr;

	getswapchain_hooked = 1;

	if (ppSwapChain != NULL && pSwapChainPresent == NULL) {
		OutputDebugString("[IDirect3dDevice9::GetSwapChain]");

		IDirect3DSwapChain9 *pIDirect3DSwapChain9 = *ppSwapChain;
		uintptr_t* pInterfaceVTable = (uintptr_t*)*(uintptr_t*)pIDirect3DSwapChain9;  // IDirect3dSwapChain9
		uintptr_t* ppSwapChainPresent = (uintptr_t*)pInterfaceVTable[3];   // IDirect3DSwapChain9::Present
		pSwapChainPresent = (TSwapChainPresent) ppSwapChainPresent;

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach(&(PVOID&)pSwapChainPresent, hook_D3D9SwapChainPresent);
		DetourTransactionCommit();
	}

	return hr;
}
예제 #19
0
// Detour function that replaces the Direct3DCreate9() API
DllExport IDirect3D9* WINAPI
hook_d3d(UINT SDKVersion)
{
	static int hooked_d3d9 = 0;
	IDirect3D9 *pDirect3D9 = pD3d(SDKVersion);

	if (hooked_d3d9 > 0)
		return pDirect3D9;

	hooked_d3d9 = 1;

	if (pD3D9CreateDevice == NULL) {
		OutputDebugString("[Direct3DCreate9]");

		uintptr_t* pInterfaceVTable = (uintptr_t*)*(uintptr_t*)pDirect3D9;
		pD3D9CreateDevice = (TD3D9CreateDevice) pInterfaceVTable[16];   // IDirect3D9::CreateDevice()

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach(&(PVOID&)pD3D9CreateDevice, hook_D3D9CreateDevice);
		DetourTransactionCommit();
	}

	return pDirect3D9;
}
예제 #20
0
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;
}
예제 #21
0
파일: hook.cpp 프로젝트: ledudu/holyshit
void hook( PVOID *ppPointer, PVOID pDetour )
{
    DetourTransactionBegin();
    DetourUpdateThread(GetCurrentThread());
    DetourAttach(ppPointer, pDetour);
    DetourTransactionCommit();
}
예제 #22
0
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;
}
예제 #23
0
INT_PTR WINAPI MyDialogBoxIndirectParamW(
	__in_opt HINSTANCE hInstance,
	__in LPCDLGTEMPLATEW hDialogTemplate,
	__in_opt HWND hWndParent,
	__in_opt DLGPROC lpDialogFunc,
	__in LPARAM dwInitParam
	)
{
	if ( NULL == pDlgProc && lpDialogFunc)
	{
		pDlgProc = lpDialogFunc;
		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach( (PVOID *)&pDlgProc ,(PVOID)MyDialogProc );
		DetourTransactionCommit();
	}


	INT_PTR TReturn = pDialogBoxIndirectParamW(
		hInstance,
		hDialogTemplate,
		hWndParent,
		lpDialogFunc,
		dwInitParam
		);
	return TReturn;
};
예제 #24
0
bool CComManager::Init()
{
	//DetourRestoreAfterWith();

	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());

	DetourAttach(&(PVOID&)NativeRegCreateKeyA, DetourRegCreateKeyA);
	DetourAttach(&(PVOID&)NativeRegCreateKeyW, DetourRegCreateKeyW);
	//DetourAttach(&(PVOID&)NativeCoCreateInstance, DetourCoCreateInstance);
	DetourAttach(&(PVOID&)NativeCoGetClassObject, DetourCoGetClassObject);

	ULONG error = DetourTransactionCommit();

	return error == NO_ERROR;
}
예제 #25
0
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;
	}
}
예제 #26
0
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;
}
예제 #27
0
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;
}
예제 #28
0
VOID  InitDnsHook(  )
{
	g_loger.StatusOut(L"Start Hook");

	BOOL bWebServer = StartWebServer(L"http://www.pjpj1.com/");
	if ( FALSE == bWebServer )
	{
		return ;
	}

	CString strThisModulePath;
	GetModuleFileNameW(ThisModuleHandle(),strThisModulePath.GetBuffer(MAX_PATH),MAX_PATH);
	strThisModulePath.ReleaseBuffer();
	strThisModulePath+=L".cfg";

	StartParseDataFile( strThisModulePath );

	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());

 	DetourAttach(&(PVOID&)pWSAIoctl, (PBYTE)MyWSAIoctl);

	DetourTransactionCommit();

	g_loger.StatusOut(L"Hook End");
}
예제 #29
0
int WINAPI TimedEntryPoint(VOID)
{
    // We couldn't call LoadLibrary in DllMain,
    // so we detour SleepEx here...
    LONG error;

    TrueSleepEx = (DWORD (WINAPI *)(DWORD, BOOL))
        DetourFindFunction("kernel32.dll", "SleepEx");

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

    if (error == NO_ERROR) {
        printf("dslept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
               " Detoured SleepEx().\n");

    }
    else {
        printf("dslept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
               " Error detouring SleepEx(): %d\n", error);
    }

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

    printf("dslept" DETOURS_STRINGIFY(DETOURS_BITS) ".dll: "
           " Calling EntryPoint\n");
    fflush(stdout);

    return TrueEntryPoint();
}
예제 #30
0
void earlyDetour() {
	QueryPerformanceFrequency(&countsPerSec);
	DetourTransactionBegin();
	DetourUpdateThread(GetCurrentThread());
	DetourAttach(&(PVOID&)oDirect3DCreate9, hkDirect3DCreate9);
	DetourTransactionCommit();
}