title: OpenProcess fails for win 7
body: <p>I am using OpenProcess function. The code works perfectly fine in windows XP but fails on win 7 X32 bit.</p>
  
  <p>My code is as follows</p>
  
  <pre><code>void SetDebugPrivileges()
  {
      void* tokenHandle;
  
      TOKEN_PRIVILEGES privilegeToken;
      LookupPrivilegeValue(0, SE_DEBUG_NAME, &amp;privilegeToken.Privileges[0].Luid);
      privilegeToken.PrivilegeCount = 1;
      privilegeToken.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
      OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &amp;tokenHandle);
      AdjustTokenPrivileges(tokenHandle, 0, &amp;privilegeToken, sizeof(TOKEN_PRIVILEGES), 0, 0);
      CloseHandle(tokenHandle);
  }
  
  HANDLE _stdcall MyOpenProcess(DWORD dwAccess, BOOL bInherit, DWORD dwPID)
  {
      SetDebugPrivileges();
  
     HANDLE hRes = OpenProcess(dwAccess | PROCESS_SET_INFORMATION | PROCESS_VM_READ, bInherit, dwPID);
  }
  </code></pre>
  
  <p>OpenProcess fails with error code 5 on win 7 but works fine on XP. It would be great if anyone could help with this issue.</p>