IS it possible to do that:

during execution of prog..i would change its flag of section .text. (code) to have read and write..after i modify some instruction in coding..and then put off the flag write of the section....

thanks for help

Frenchy
Posted on 2004-07-03 05:21:04 by Frenchy
You don't have to modify the flag, link your object file with the switch /SECTION:.text,ERW
Posted on 2004-07-03 06:08:19 by Vortex
thks Vortex...but i know that , but i would know if we can change flag section during the execution..i would keep the protect against bad write in section code...

i suppose the flag is loaded in memory but i dont know where exactly ...

i have written a prog in assembly..and i would implement a coding to change flag..i suppose all is possible in programmation, but how resolve this prob..
Posted on 2004-07-03 06:15:01 by Frenchy
To get the writing access to the code section, consider using the OpenProcess function:


HANDLE OpenProcess(

DWORD dwDesiredAccess, // access flag
BOOL bInheritHandle, // handle inheritance flag
DWORD dwProcessId // process identifier
);


I have an old example using this function to modify the code section, you can check the attachment.
Posted on 2004-07-03 06:31:20 by Vortex
thks Vortex i see that...
Posted on 2004-07-03 06:36:32 by Frenchy
Try that

C&P from Win32SDK
The VirtualProtect function changes the access protection on a region of committed pages in the virtual address space of the calling process. This function differs from VirtualProtectEx, which changes the access protection of any process.


BOOL VirtualProtect(

LPVOID lpAddress, // address of region of committed pages
DWORD dwSize, // size of the region
DWORD flNewProtect, // desired access protection
PDWORD lpflOldProtect // address of variable to get old protection
);

More ?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/virtualprotect.asp
Posted on 2004-07-03 11:22:42 by Criminal2