Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.1 KiB

  1. /*++
  2. Copyright (C) 1999-2002 Microsoft Corporation
  3. Module Name:
  4. scopecheck.h
  5. Abstract:
  6. check if a thread has a token or not
  7. History:
  8. ivanbrug 6 Jan 2002 Created
  9. --*/
  10. #ifndef __SCOPECHECK_H__
  11. #define __SCOPECHECK_H__
  12. #include <helper.h>
  13. class CTestNullTokenOnScope {
  14. private:
  15. DWORD Line_;
  16. char * File_;
  17. void TokenTest(bool bIsDestruct)
  18. {
  19. IServerSecurity *oldContext = NULL ;
  20. HRESULT result = CoGetCallContext ( IID_IServerSecurity , ( void ** ) & oldContext ) ;
  21. if ( SUCCEEDED ( result ) )
  22. {
  23. _DBG_ASSERT(!oldContext->IsImpersonating ());
  24. oldContext->Release();
  25. }
  26. HANDLE hThreadTok = NULL;
  27. if (OpenThreadToken(GetCurrentThread(),TOKEN_QUERY,FALSE,&hThreadTok))
  28. {
  29. if (bIsDestruct) { DBG_PRINTFA((pBuff, "~CTestNullTokenOnExit %d : %s\n",Line_,File_)); }
  30. DebugBreak();
  31. CloseHandle(hThreadTok);
  32. };
  33. };
  34. public:
  35. CTestNullTokenOnScope(DWORD Line,char * FileName):Line_(Line),File_(FileName){ TokenTest(false); };
  36. ~CTestNullTokenOnScope(){ TokenTest(true); };
  37. };
  38. #endif /*__SCOPECHECK_H__*/