一个很奇怪的问题

rockago 2010-05-30 09:05:09
我编译了Detours 2.1 然后把东西都拷贝了 vc6.0编译下面这段代码:

#include <windows.h>
#include "detours.h"
#include <string.h>
#include <fstream>
using namespace std;

#pragma comment(lib, "detours.lib")
#pragma comment(lib, "detoured.lib")
// must have at lease one export function
_declspec(dllexport) void exportfunc()
{
}

// target pointer for the uninstrumented MessageBox API
int (WINAPI *SysMessageBox)(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
= MessageBox;

// detour function that replaces the MessageBox API
int WINAPI HookMessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
{
ofstream ofs("record.txt", ios::app);
ofs.write(lpText, strlen(lpText));
ofs.close();
return SysMessageBox(hWnd, lpText, lpCaption, uType);
}

// DLLMain function attaches and detaches the HookMessageBox detour to the
// MessageBox target function. The MessageBox target function is referred to
// through the SysMessageBox target pointer
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
{
if (DLL_PROCESS_ATTACH == fdwReason)
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)SysMessageBox, HookMessageBox);
DetourTransactionCommit();
}
else if (DLL_PROCESS_DETACH == fdwReason)
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)SysMessageBox, HookMessageBox);
DetourTransactionCommit();
}
return TRUE;
}


会报错。。。
--------------------Configuration: Test - Win32 Debug--------------------
Compiling...
Hook.cpp
Linking...
Creating library Debug/Test.lib and object Debug/Test.exp
detours.lib(detours.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
detours.lib(detours.obj) : error LNK2001: unresolved external symbol __except_handler4
detours.lib(detours.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
detours.lib(detours.obj) : error LNK2001: unresolved external symbol ___security_cookie
detours.lib(disasm.obj) : error LNK2001: unresolved external symbol ___security_cookie
detours.lib(detours.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
detours.lib(disasm.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
Debug/Test.dll : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.

Test.dll - 8 error(s), 0 warning(s)


后来试了vc2008 却发现 一样的代码 却编译成功,,请问各位大侠 这是为什么。。。
...全文
180 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jingzhongrong 2010-05-31
  • 打赏
  • 举报
回复
看错误提示中的__SEH_epilog4,__except_handler4,___security_cookie,你的这个detours.lib应该不是VC6编译的,这些都是VS05以后用于防止函数溢出等安全方面的改进,你应该找一个VC6支持的库,或者直接使用VS08开发。
rockago 2010-05-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 jennyvenus 的回复:]
2008默认加载了一些库?
[/Quote]
vc6报detours.lib错
似乎我把detours的库都丢到系统目录了(丢到自己文件目录也试了)
但还是会错 不知道为啥。。求高人解答。。
用户 昵称 2010-05-30
  • 打赏
  • 举报
回复
2008默认加载了一些库?

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧