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.

107 lines
2.3 KiB

  1. /*****************************************************************************
  2. * Copyright (c) 1998-2001 Microsoft Corporation, All Rights Reserved
  3. *
  4. * All Rights Reserved
  5. *
  6. * This software is furnished under a license and may be used and copied
  7. * only in accordance with the terms of such license and with the inclusion
  8. * of the above copyright notice. This software or any other copies thereof
  9. * may not be provided or otherwise made available to any other person. No
  10. * title to and ownership of the software is hereby transferred.
  11. *****************************************************************************/
  12. //============================================================================
  13. //
  14. // CKernal.cpp -- Wraper for Kernal functions
  15. //
  16. // Copyright (c) 1998-2001 Microsoft Corporation, All Rights Reserved
  17. //
  18. // Revisions: 6/26/98 a-kevhu Created
  19. //
  20. //============================================================================
  21. #include "precomp.h"
  22. #include "CKernel.h"
  23. CKernel::CKernel()
  24. {
  25. m_hHandle = NULL;
  26. m_dwStatus = ERROR_INVALID_HANDLE;
  27. }
  28. CKernel::~CKernel()
  29. {
  30. if (CIsValidHandle(m_hHandle))
  31. {
  32. ::CloseHandle(m_hHandle);
  33. m_hHandle = NULL;
  34. }
  35. }
  36. void CKernel::ThrowError(DWORD dwStatus)
  37. {
  38. //CThrowError(dwStatus);
  39. LogMessage2(L"CKernel Error: %d", dwStatus);
  40. }
  41. DWORD CKernel::Status() const
  42. {
  43. return m_dwStatus;
  44. }
  45. DWORD CKernel::Wait(DWORD dwMilliseconds)
  46. {
  47. return ::WaitForSingleObject(m_hHandle, dwMilliseconds);
  48. }
  49. // wait on the current object and one other...
  50. DWORD CKernel::WaitForTwo(CWaitableObject &rCWaitableObject,
  51. BOOL bWaitAll,
  52. DWORD dwMilliseconds)
  53. {
  54. HANDLE handles[2];
  55. // the current object...
  56. handles[0] = m_hHandle;
  57. // the parameter object...
  58. handles[1] = rCWaitableObject.GetHandle();
  59. // wait for the objects...
  60. return ::WaitForMultipleObjects(2, handles, bWaitAll, dwMilliseconds);
  61. }
  62. HANDLE CKernel::GetHandle() const
  63. {
  64. if (this != NULL)
  65. {
  66. return m_hHandle;
  67. }
  68. else
  69. {
  70. return NULL;
  71. }
  72. }
  73. CKernel::operator HANDLE() const
  74. {
  75. return GetHandle();
  76. }