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.

133 lines
3.7 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 2001-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dp8simipc.h
  6. *
  7. * Content: Header for interprocess communication object class.
  8. *
  9. * History:
  10. * Date By Reason
  11. * ======== ======== =========
  12. * 04/25/01 VanceO Created.
  13. *
  14. ***************************************************************************/
  15. //=============================================================================
  16. // Defines
  17. //=============================================================================
  18. #define DP8SIM_IPC_VERSION 2
  19. #define DP8SIM_IPC_MUTEXNAME _T("DP8Sim IPC Mutex")
  20. #define DP8SIM_IPC_FILEMAPPINGNAME _T("DP8Sim IPC File Mapping")
  21. //=============================================================================
  22. // Structures
  23. //=============================================================================
  24. typedef struct _DP8SIM_SHAREDMEMORY
  25. {
  26. DWORD dwVersion; // shared memory version
  27. DP8SIM_PARAMETERS dp8spSend; // current send settings
  28. DP8SIM_PARAMETERS dp8spReceive; // current receive settings
  29. DP8SIM_STATISTICS dp8ssSend; // current send statistics
  30. DP8SIM_STATISTICS dp8ssReceive; // current receive statistics
  31. } DP8SIM_SHAREDMEMORY, * PDP8SIM_SHAREDMEMORY;
  32. //=============================================================================
  33. // Send object class
  34. //=============================================================================
  35. class CDP8SimIPC
  36. {
  37. public:
  38. CDP8SimIPC(void); // constructor
  39. ~CDP8SimIPC(void); // destructor
  40. inline BOOL IsValidObject(void)
  41. {
  42. if ((this == NULL) || (IsBadWritePtr(this, sizeof(CDP8SimIPC))))
  43. {
  44. return FALSE;
  45. }
  46. if (*((DWORD*) (&this->m_Sig)) != 0x494d4953) // 0x49 0x4d 0x49 0x53 = 'IMIS' = 'SIMI' in Intel order
  47. {
  48. return FALSE;
  49. }
  50. return TRUE;
  51. };
  52. HRESULT Initialize(void);
  53. void Close(void);
  54. void GetAllParameters(DP8SIM_PARAMETERS * const pdp8spSend,
  55. DP8SIM_PARAMETERS * const pdp8spReceive);
  56. void GetAllSendParameters(DP8SIM_PARAMETERS * const pdp8sp);
  57. void GetAllReceiveParameters(DP8SIM_PARAMETERS * const pdp8sp);
  58. void SetAllParameters(const DP8SIM_PARAMETERS * const pdp8spSend,
  59. const DP8SIM_PARAMETERS * const pdp8spReceive);
  60. void GetAllStatistics(DP8SIM_STATISTICS * const pdp8ssSend,
  61. DP8SIM_STATISTICS * const pdp8ssReceive);
  62. void ClearAllStatistics(void);
  63. void IncrementStatsSendTransmitted(DWORD dwBytes, DWORD dwDelay);
  64. void IncrementStatsSendDropped(DWORD dwBytes);
  65. void IncrementStatsReceiveTransmitted(DWORD dwBytes, DWORD dwDelay);
  66. void IncrementStatsReceiveDropped(DWORD dwBytes);
  67. private:
  68. BYTE m_Sig[4]; // debugging signature ('SIMI')
  69. HANDLE m_hMutex; // handle to mutex protecting shared memory
  70. HANDLE m_hFileMapping; // handle to shared memory
  71. DP8SIM_SHAREDMEMORY * m_pdp8ssm; // pointer to mapped view of shared memory
  72. #undef DPF_MODNAME
  73. #define DPF_MODNAME "CDP8SimIPC::LockSharedMemory"
  74. inline void LockSharedMemory(void)
  75. {
  76. DNASSERT(this->m_hMutex != NULL);
  77. WaitForSingleObject(this->m_hMutex, INFINITE);
  78. }
  79. #undef DPF_MODNAME
  80. #define DPF_MODNAME "CDP8SimIPC::UnlockSharedMemory"
  81. inline void UnlockSharedMemory(void)
  82. {
  83. DNASSERT(this->m_hMutex != NULL);
  84. ReleaseMutex(this->m_hMutex);
  85. }
  86. void LoadDefaultParameters(DP8SIM_PARAMETERS * const pdp8spSend,
  87. DP8SIM_PARAMETERS * const pdp8spReceive);
  88. void SaveDefaultParameters(const DP8SIM_PARAMETERS * const pdp8spSend,
  89. const DP8SIM_PARAMETERS * const pdp8spReceive);
  90. };