Code:
PDWORD old_protection; // this is a pointer
if (!VirtualProtectEx(hProcess, currentpage, size, PAGE_NOACCESS, old_protection)) {
And the pointer is pointing to...?
You can't set breakpoints that way. Dlls can load at different addresses in different processes. The address of printf in your debugger program is just that. It's not a universal value valid for every program. It might be, but then again, you might be able to write to a piece of memory after you free it, doesn't mean you always will.
There isn't a GetProcAddressEx function. To get the address in a remote process, you need the offset of the function in the dll* and the base address of the dll in the target process, add the two together and there you go. Or you can use the Sym* api's which wrap this and other things up for you. Or the IDebugClient and related interfaces which pretty much give you access to everything a debugger needs, including breakpoints.
* you can use GetProcAddress and GetModuleHandle and subtract the difference for this value