how to allocate code in specific section for C++ program developed in MS VC++ -
how to allocate code in specific section for C++ program developed in MS VC++ -
i trying utilize code allocate piece of code independent section:
#ifdef _msc_ver #pragma section(".evil",execute) #pragma code_seg(".evil") #endif #ifdef __gnuc__ static __attribute__((section (".evil"))) #elif defined _msc_ver static __declspec(allocate(".evil")) #endif void __invoke__start() {//...
but not work , compiler says
the __declspec( allocate()) syntax can used static info only.
i because have write code new file ,and file executable file.
actually can not find way exact address of function in memory when programme running,if programme compiled ms vc++ debug mode total example,please see code : full example
now, above problem has been solved, still want create clear if possible set code independent section. there's other benefit when possible work, after all.
when link 2 object file (coff format), how can create sure different code different obj file in different section? or there way this?
i sorry poor english.
you can find memory address of origin of function inline assembler, phone call function utilize memory address, like:
void foo(){ __asm{ phone call 0h \\put current address on top of stack phone call myfunction \\actually create funciton phone call } ... } int myfunction( int addrfromasm){ \\do addrfromasm+4, rest of foo starts. }
c++ c windows visual-c++ pe
Comments
Post a Comment