Would anyone know why MSVC++ 2008 always returns error 5 on GetLastError() when I try to call OpenProcess with PROCESS_ALL_ACCESS as my desired access? PROCESS_VM_READ works just fine. I'm an administrator on this computer and it is working fine in Dev C++.
Do I need to set an option somewhere?
Which process is it? Opening a service or a process in another user session is likely to return Access Denied (5). A process in another session will open for read but you wouldn't be able to debug it. It's one reason why Windbg has the non-intrusive attach. It works across user sessions. You're not actually debugging. It suspends all the threads and is reading the memory.
Another thing that might be causing this is new to Vista:
Opening a process with full access rights can be a highly privileged operation if it's not a process running under you credentials or in your logon session - you'll need to follow this bit of documentation from MSDN:
Remember that even if you have a privilege, in most cases the privilege is not enabled - it has to be specifically enabled in the code that's attempting to use the privilege.