Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ cant use functions of .h header file

Tags:

c++

suddenly i couldnt use the new function i wrote which in .h header file and the old functions which i wrote i can use it, i cant believe that :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;
};

Error *error C3861: 'MemoryCopy': identifier not found*

like image 501
beshoy Mounir Avatar asked Dec 17 '25 18:12

beshoy Mounir


1 Answers

This happens usually when you compile and individual file which does not cause the precomplied header to be rebuilt. If you rebuild the solution it will recreate the header. You can also turn off precompled headers and not have to deal with it.

like image 72
rerun Avatar answered Dec 20 '25 06:12

rerun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!