编译出来出错。。
我把文件代码贴出来,麻烦大哥帮我帮看看怎么不行呢。
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 头文件
#include <Windows.h>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 导出函数
#pragma comment(linker, "/EXPORT:WahCloseApcHelper=_AheadLib_WahCloseApcHelper,@1")
#pragma comment(linker, "/EXPORT:WahCloseHandleHelper=_AheadLib_WahCloseHandleHelper,@2")
#pragma comment(linker, "/EXPORT:WahCloseNotificationHandleHelper=_AheadLib_WahCloseNotificationHandleHelper,@3")
#pragma comment(linker, "/EXPORT:WahCloseSocketHandle=_AheadLib_WahCloseSocketHandle,@4")
#pragma comment(linker, "/EXPORT:WahCloseThread=_AheadLib_WahCloseThread,@5")
#pragma comment(linker, "/EXPORT:WahCompleteRequest=_AheadLib_WahCompleteRequest,@6")
#pragma comment(linker, "/EXPORT:WahCreateHandleContextTable=_AheadLib_WahCreateHandleContextTable,@7")
#pragma comment(linker, "/EXPORT:WahCreateNotificationHandle=_AheadLib_WahCreateNotificationHandle,@8")
#pragma comment(linker, "/EXPORT:WahCreateSocketHandle=_AheadLib_WahCreateSocketHandle,@9")
#pragma comment(linker, "/EXPORT:WahDestroyHandleContextTable=_AheadLib_WahDestroyHandleContextTable,@10")
#pragma comment(linker, "/EXPORT:WahDisableNonIFSHandleSupport=_AheadLib_WahDisableNonIFSHandleSupport,@11")
#pragma comment(linker, "/EXPORT:WahEnableNonIFSHandleSupport=_AheadLib_WahEnableNonIFSHandleSupport,@12")
#pragma comment(linker, "/EXPORT:WahEnumerateHandleContexts=_AheadLib_WahEnumerateHandleContexts,@13")
#pragma comment(linker, "/EXPORT:WahInsertHandleContext=_AheadLib_WahInsertHandleContext,@14")
#pragma comment(linker, "/EXPORT:WahNotifyAllProcesses=_AheadLib_WahNotifyAllProcesses,@15")
#pragma comment(linker, "/EXPORT:WahOpenApcHelper=_AheadLib_WahOpenApcHelper,@16")
#pragma comment(linker, "/EXPORT:WahOpenCurrentThread=_AheadLib_WahOpenCurrentThread,@17")
#pragma comment(linker, "/EXPORT:WahOpenHandleHelper=_AheadLib_WahOpenHandleHelper,@18")
#pragma comment(linker, "/EXPORT:WahOpenNotificationHandleHelper=_AheadLib_WahOpenNotificationHandleHelper,@19")
#pragma comment(linker, "/EXPORT:WahQueueUserApc=_AheadLib_WahQueueUserApc,@20")
#pragma comment(linker, "/EXPORT:WahReferenceContextByHandle=_AheadLib_WahReferenceContextByHandle,@21")
#pragma comment(linker, "/EXPORT:WahRemoveHandleContext=_AheadLib_WahRemoveHandleContext,@22")
#pragma comment(linker, "/EXPORT:WahWaitForNotification=_AheadLib_WahWaitForNotification,@23")
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 宏定义
#define EXTERNC extern "C"
#define NAKED __declspec(naked)
#define EXPORT __declspec(dllexport)
#define ALCPP EXPORT NAKED
#define ALSTD EXTERNC EXPORT NAKED void __stdcall
#define ALCFAST EXTERNC EXPORT NAKED void __fastcall
#define ALCDECL EXTERNC NAKED void __cdecl
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AheadLib 命名空间
namespace AheadLib
{
HMODULE m_hModule = NULL; // 原始模块句柄
DWORD m_dwReturn[23] = {0}; // 原始函数返回地址
// 加载原始模块
inline BOOL WINAPI Load()
{
TCHAR tzPath[MAX_PATH];
TCHAR tzTemp[MAX_PATH * 2];
GetSystemDirectory(tzPath, MAX_PATH);
lstrcat(tzPath, TEXT("\\ws2help1"));
m_hModule = LoadLibrary(tzPath);
if (m_hModule == NULL)
{
wsprintf(tzTemp, TEXT("无法加载 %s,程序无法正常运行。"), tzPath);
MessageBox(NULL, tzTemp, TEXT("AheadLib"), MB_ICONSTOP);
}
return (m_hModule != NULL);
}
// 释放原始模块
inline VOID WINAPI Free()
{
if (m_hModule)
{
FreeLibrary(m_hModule);
}
}
// 获取原始函数地址
FARPROC WINAPI GetAddress(PCSTR pszProcName)
{
FARPROC fpAddress;
CHAR szProcName[16];
TCHAR tzTemp[MAX_PATH];
fpAddress = GetProcAddress(m_hModule, pszProcName);
if (fpAddress == NULL)
{
if (HIWORD(pszProcName) == 0)
{
wsprintf(szProcName, "%d", pszProcName);
pszProcName = szProcName;
}
wsprintf(tzTemp, TEXT("无法找到函数 %hs,程序无法正常运行。"), pszProcName);
MessageBox(NULL, tzTemp, TEXT("AheadLib"), MB_ICONSTOP);
ExitProcess(-2);
}
return fpAddress;
}
}
using namespace AheadLib;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DWORD _stdcall buding1(LPVOID lParam)
{
HMODULE k = NULL;
BYTE a[5] = {0xE8,0xBC,0x5E,0x2B,0x7C};
DWORD oldProtect=0;
VirtualProtect((LPVOID)((DWORD)0x00566C51),5,PAGE_READWRITE,&oldProtect);
memcpy((LPVOID)((DWORD)0x00566C51),a,5);
VirtualProtect((LPVOID)((DWORD)0x00566C51),5,oldProtect,&oldProtect);
return 0;
}
出错部分
--------------------------------------------------------
--------------------Configuration: ws2help - Win32 Release--------------------
Compiling...
123.cpp
F:\C++系统函数源码\x\ws2help\123.cpp(128) : error C2065: 'hProcess' : undeclared identifier
F:\C++系统函数源码\x\ws2help\123.cpp(128) : error C2065: 'dwOldProt' : undeclared identifier
F:\C++系统函数源码\x\ws2help\123.cpp(131) : error C2146: syntax error : missing ';' before identifier 'WriteProcessMemory'
F:\C++系统函数源码\x\ws2help\123.cpp(131) : error C2065: 'dwPatchLen' : undeclared identifier
F:\C++系统函数源码\x\ws2help\123.cpp(134) : error C2146: syntax error : missing ';' before identifier 'VirtualProtectEx'
F:\C++系统函数源码\x\ws2help\123.cpp(134) : error C2065: 'dwNewProt' : undeclared identifier
F:\C++系统函数源码\x\ws2help\123.cpp(136) : error C2143: syntax error : missing ';' before 'return'
执行 cl.exe 时出错.
123.obj - 1 error(s), 0 warning(s)