Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Help with VirtualProtectEx

  • 22-05-2002 10:31AM
    #1
    Closed Accounts Posts: 1,567 ✭✭✭


    I'm trying to use VirtualProtectEx on processes in Windows operating system but cannot calculate the cbSize + lpvAddress properly.
    I've tried many ways to do this, all have ended with errors, usually invalid parameter or memory reference.

    BOOL VirtualProtectEx(

    HANDLE hProcess, // handle of process
    LPVOID lpvAddress, // address of region of committed pages
    DWORD cbSize, // size of region
    DWORD fdwNewProtect, // desired access protection
    PDWORD pfdwOldProtect // address of variable to get old protection
    );

    I already have a handle to the process from OpenProcess, its opened with PROCESS_ALL_ACCESS and have information on it using VirtualQueryEx.
    I know the problem is with lpvAddress + cbSize..this is what I'm stuck on.
    All processes are enumerated with Process32First/Process32Next
    I open each process seperately, use VirtualQueryEx to get information on it, and then what I want to do next is modify the memory access of those processes with different options..like PAGE_GUARD or PAGE_READONLY, PAGE_NOACCESS...etc

    If Anyone can help, thanks, I already have Win32 API documentation, but I don't understand the description for calculating cbSize.


Advertisement