-
大小: 570KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-11
- 語(yǔ)言: C/C++
- 標(biāo)簽: detoursbin??
資源簡(jiǎn)介
detours2.1在vc6中編譯方法
1.在純VC6環(huán)境中新建 win32 static library 項(xiàng)目名設(shè)為detours
2.把detours2.1 scr目錄中的源文件全部添加到項(xiàng)目
3.在Project->Seting->C/C++->Preprocessor definitions中添加DETOURS_X86
4.打開項(xiàng)目中detoured.cpp把里面DllMain函數(shù)名修改為L(zhǎng)engFeng(否則使用時(shí)會(huì)出現(xiàn)DllMain沖突)error LNK2005: _DllMain@12 already defined in ***.obj
5.直接編譯就可以生成detours.lib
6.在需要的項(xiàng)目中使用detours.lib和detours.h 就可以了
7.附件中提供了編譯好的detours.lib和系統(tǒng)源代碼
注意:需要在沒有安裝SDK的環(huán)境編譯,如果安裝過SDK,請(qǐng)把SDK的順序調(diào)到最后
detour_2.1 為源碼
detours_bin 為BIN
hook_send 為例子
2012-7-12 冷風(fēng) QQ 121121606

代碼片段和文件信息
//////////////////////////////////////////////////////////////////////////////
//
//??Detour?functions?of?a?COM?interface?(commem.cpp?of?commem.exe)
//
//??Microsoft?Research?Detours?Package?Version?2.1.
//
//??Copyright?(c)?Microsoft?Corporation.??All?rights?reserved.
//
//
//
#include?
//////////////////////////////////////////////////////////////////////////////
//
//??WARNING:
//
//??CINTERFACE?must?be?defined?so?that?the?lpVtbl?pointer?is?visible
//??on?COM?interfaces.??However?once?we‘ve?defined?it?we?must?use
//??coding?conventions?when?accessing?interface?members?for?example:
//??????i->lpVtbl->Write
//??instead?of?the?C++?syntax:
//??????i->Write.
//??We?must?also?pass?the?implicit?“this“?parameter?explicitly:
//??????i->lpVtbl->Write(i?pb?0?NULL)
//??instead?of?the?C++?syntax:
//??????i->Write(pb?0?NULL)
//
#define?CINTERFACE
#include?
#include?
#include?
//////////////////////////////////////////////////////////////////////////////
//
HRESULT?(STDMETHODCALLTYPE?*RealIStreamWrite)(IStream?*?This
??????????????????????????????????????????????const?void?*pv
??????????????????????????????????????????????ULONG?cb
??????????????????????????????????????????????ULONG?*pcbWritten)?=?NULL;
HRESULT?STDMETHODCALLTYPE?MineIStreamWrite(IStream?*?This
???????????????????????????????????????????const?void?*pv
???????????????????????????????????????????ULONG?cb
???????????????????????????????????????????ULONG?*pcbWritten)
{
????HRESULT?hr;
????ULONG?cbWritten?=?0;
????if?(pcbWritten?==?NULL)?{
????????pcbWritten?=?&cbWritten;
????}
????printf(“commem:???%p->IStreamWrite(pv=%p?cb=%d)\n“?This?pv?cb);
????hr?=?RealIStreamWrite(This?pv?cb?pcbWritten);
????printf(“commem:???%p->IStreamWrite?->?%08x?(pcbWritten=%d)\n“?This?hr?*pcbWritten);
????return?hr;
}
//////////////////////////////////////////////////////////////////////////////
//
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(GetCurrentThrea
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????237659??2012-07-12?10:46??hook_send\Debug\hook_send.dll
?????文件??????19203??2006-10-16?15:56??hook_send\detours.h
?????文件??????81708??2012-07-12?10:46??hook_send\detours.lib
?????文件??????81608??2012-07-12?10:38??hook_send\detours.lib.bak
?????文件???????1396??2012-07-12?10:34??hook_send\hook_send.cpp
?????文件???????4204??2012-07-12?10:46??hook_send\hook_send.dsp
?????文件????????543??2012-07-12?08:59??hook_send\hook_send.dsw
?????文件??????33792??2012-07-12?10:46??hook_send\hook_send.ncb
?????文件??????53760??2012-07-12?10:46??hook_send\hook_send.opt
?????文件????????252??2012-07-12?10:46??hook_send\hook_send.plg
?????文件??????97473??2006-09-18?12:23??detours_2.1\detours\Detours.chm
?????文件????????892??2006-10-16?15:55??detours_2.1\detours\Makefile
?????文件??????15931??2006-11-03?16:15??detours_2.1\detours\README.TXT
?????文件???????2233??2006-05-02?11:57??detours_2.1\detours\REDIST.TXT
?????文件???????3368??2006-10-16?15:55??detours_2.1\detours\samples\commem\commem.cpp
?????文件????????972??2006-10-16?15:55??detours_2.1\detours\samples\commem\Makefile
?????文件???????2886??2006-10-16?15:55??detours_2.1\detours\samples\common.mak
?????文件??????68135??2006-10-16?15:55??detours_2.1\detours\samples\cping\cping.cpp
?????文件??????????0??2006-05-02?11:57??detours_2.1\detours\samples\cping\cping.dat
?????文件????????718??2006-10-16?15:55??detours_2.1\detours\samples\cping\iping.idl
?????文件???????2544??2006-10-16?15:55??detours_2.1\detours\samples\cping\Makefile
?????文件???????1585??2006-10-16?15:55??detours_2.1\detours\samples\cping\ReadMe.Txt
?????文件???????7194??2006-11-03?16:15??detours_2.1\detours\samples\disas\disas.cpp
?????文件??????29571??2006-10-16?15:55??detours_2.1\detours\samples\disas\ia64.asm
?????文件???????1389??2006-10-16?15:55??detours_2.1\detours\samples\disas\Makefile
?????文件??????12034??2006-10-16?15:55??detours_2.1\detours\samples\disas\x64.asm
?????文件???????1451??2006-10-16?15:55??detours_2.1\detours\samples\disas\x86.cpp
?????文件??????11178??2006-10-16?15:55??detours_2.1\detours\samples\dtest\dtarget.cpp
?????文件???????3548??2006-10-16?15:55??detours_2.1\detours\samples\dtest\dtarget.h
?????文件??????24427??2006-10-16?15:55??detours_2.1\detours\samples\dtest\dtest.cpp
............此處省略142個(gè)文件信息
評(píng)論
共有 條評(píng)論