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

时间:2013-02-22 19:47:10

标签: c++

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

stdafx.h中

#include "function.h"

Hook.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);

    }
}

function.h

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

function.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':未找到标识符 *

1 个答案:

答案 0 :(得分:2)

通常在编译和单个文件时会发生这种情况,这不会导致重建预编译的头文件。如果重建解决方案,它将重新创建标头。您也可以关闭预先填充的标题,而不必处理它。