openprocess

VC++ 2008, OpenProcess always returning error 5 (Access Denied)

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? ...

How to find & close all open file handles on a removable drive (before ejecting)

I'm trying to eject a (virtual) removable drive, and it fails because there are some file handles open, maybe explorer windows. What's the best way to get all the open handles to files on that drive and close them? Is it also feasible (within user-mode) to find any processes running off that drive, so I can warn the user with the proces...

How to check if process is still running on Windows server 2008?

We have two services: one service is 32-bit (process1) and the other is 64-bit (process2). We have code that process1 is using to check if process2 is running: HANDLE hProcess; RESET_WIN_ERRNO; hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ProcessId); if (hProcess == NULL) { os_SetWinErr(err_code); return FALS...

OpenProcess / SetProcessAffinityMask on process started by my service

In my manager.exe, I'm trying to change the CPU usage of my worker.exe, which is started by my service.exe. Service.exe is running under the System Account, while manager.exe is running under the logged in user's account. When I call OpenProcess in manager.exe with worker.exe's PID, I get NULL for procHandle: HANDLE procHandle = O...

Windows Vista/Win7 Privilege Problem: SeDebugPrivilege & OpenProcess

Everything I've been able to find about escalating to the appropriate privileges for my needs has agreed with my current methods, but the problem exists. I'm hoping maybe someone has some Windows Vista/Win7 internals experience that might shine some light where there is only darkness. I'm sure this will get long, but please bare with me....

C# OpenProcess fail in Release but not in Debug

Hi, I have encountered a problem with OpenProcess using PROCESS_ALL_ACCESS, it will work in debug mode but not in release mode. Why is this? ...

GetProcessName in C++

I have a function with blow detail. typedef part typedef DWORD (WINAPI *GETMODULEFILENAMEEX)(HANDLE hProcess, HMODULE hModule, LPTSTR lpBaseName,DWORD nSize); typedef BOOL (WINAPI *PFNTERMINATEPROCESS)(HANDLE hProcess,UINT uExitCode); /// GetProcessName function void GetProcessName(DWORD PID, PTSTR szProcessName, size_t c...

Vista/7 compile and XP/2000 execution issues with OpenProcess in C++

I've been using OpenProcess with PROCESS_ALL_ACCESS rights for the following functions: -EnumProcessModules -GetModuleFileNameEx -ReadProcessMemory -WriteProcessMemory which works fine on Windows Vista/7. However, in Windows XP/2000, it won't open the process with PROCESS_ALL_ACCESS because according to the MSDN library: The size of t...