c++不能使用.h头文件的函数

c++ cant use functions of .h header file

本文关键字:文件 函数 不能 c++      更新时间:2023-10-16

突然我无法使用我在.h头文件中编写的新函数,而我编写的旧函数我可以使用它,我简直不敢相信:S

stdafx.h

#include "function.h"

挂钩

#include "stdafx.h"
    namespace DragoN_Hook
    {
            void EditOrginalCastleWar(int StartHour,int EndHour){
            unsigned char lol[4] = {0x83, 0x7A, 0x08,(unsigned char)StartHour};
            MemoryCopy((DWORD)0x00411A05,(DWORD)&lol,4);
    }
}

函数.h

LPVOID MemoryCopy(DWORD destination, DWORD source, int length);

函数.cpp

LPVOID MemoryCopy(DWORD destination, DWORD source, int length)
{
    DWORD oldSource      = 0;
    DWORD oldDestination = 0;
    VirtualProtect((LPVOID)source,length,PAGE_EXECUTE_READWRITE,&oldSource);
    VirtualProtect((LPVOID)destination,length,PAGE_EXECUTE_READWRITE,&oldDestination);
    memcpy((void*)destination,(void*)source,length);
    VirtualProtect((LPVOID)destination,length,oldDestination,&oldDestination);
    VirtualProtect((LPVOID)source,length,oldSource,&oldSource);
    return (LPVOID)destination;
};

错误*错误C3861:"MemoryCopy":找不到标识符*

这通常发生在编译单个文件时,而该文件不会导致重新生成预编译的标头。如果重新生成解决方案,它将重新生成标头。您也可以关闭预编译的头文件,而不必处理它。