示例#1
0
void CJobObject::AssignProcess(CProcess& Process) {
   BOOL bRet;
   CMutex::CEnter MutexEnter(m_Mutex);

   bRet = AssignProcessToJobObject(GetHandle(), Process.GetHandle());   
   if (bRet == 0) {
      throw CCodineException(CError::GetErrorMessage(GetLastError()), __FILE__, __LINE__);
   }
}
示例#2
0
void CUser::LogonCurrentUser(void) {
   CTrace::CEnter Enter(CTrace::Layer::KERNEL, L"User::LogonCurrentUser()");
   static const DWORD dwMaxUsername = 4096;
   CProcess ThisProcess;
   DWORD dwLengthUsername = dwMaxUsername;
   WCHAR szUsername[dwMaxUsername];
   BOOL bRet;
   HANDLE hToken;

   bRet = OpenProcessToken(ThisProcess.GetHandle(), TOKEN_ALL_ACCESS, &hToken);
   if (bRet == 0) {
      throw CCodineException(CError::GetErrorMessage(GetLastError()), __FILE__, __LINE__);
   } else {
      SetHandle(hToken);
   }
   bRet = ::GetUserName(szUsername, &dwLengthUsername);
   if (bRet == 0) {
      throw CCodineException(CError::GetErrorMessage(GetLastError()), __FILE__, __LINE__);
   }   
   m_Username = szUsername;
}