Source code of Windows XP (NT5)
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.

130 lines
3.8 KiB

  1. /*************************************************************************
  2. * ICAAPIP.H
  3. *
  4. * This module contains private ICA DLL defines and structures
  5. *
  6. * Copyright 1996, Citrix Systems Inc.
  7. * Copyright (C) 1997-1999 Microsoft Corp.
  8. *
  9. * Author: Brad Pedersen (7/12/96)
  10. *************************************************************************/
  11. /*=============================================================================
  12. == Defines
  13. =============================================================================*/
  14. #ifdef DBG
  15. #define DBGPRINT(_arg) DbgPrint _arg
  16. #else
  17. #define DBGPRINT(_arg)
  18. #endif
  19. #if DBG
  20. #undef TRACE
  21. #undef TRACESTACK
  22. #undef TRACECHANNEL
  23. #define TRACE(_arg) IcaTrace _arg
  24. #define TRACESTACK(_arg) IcaStackTrace _arg
  25. #define TRACECHANNEL(_arg) IcaChannelTrace _arg
  26. #else
  27. #define TRACE(_arg)
  28. #define TRACESTACK(_arg)
  29. #define TRACECHANNEL(_arg)
  30. #endif
  31. #define ICA_SD_MODULE_EXTENTION L".SYS"
  32. /*=============================================================================
  33. == Typedefs
  34. =============================================================================*/
  35. typedef NTSTATUS (APIENTRY * PCDOPEN)( HANDLE, PPDCONFIG, PVOID * );
  36. typedef NTSTATUS (APIENTRY * PCDCLOSE)( PVOID );
  37. typedef NTSTATUS (APIENTRY * PCDIOCONTROL)( PVOID, ULONG, PVOID, ULONG, PVOID, ULONG, PULONG );
  38. typedef NTSTATUS (APIENTRY * PSTACKIOCONTROLCALLBACK)( PVOID, PVOID, ULONG, PVOID, ULONG, PVOID, ULONG, PULONG );
  39. /*=============================================================================
  40. == Semaphores
  41. =============================================================================*/
  42. /*
  43. * Citrical section macros
  44. */
  45. #define INITLOCK( _sem, _status ) { \
  46. _status = RtlInitializeCriticalSection( _sem ); \
  47. TRACE((hIca,TC_ICAAPI,TT_SEM,"INITLOCK: "#_sem"\n")); \
  48. }
  49. #define DELETELOCK( _sem ) { \
  50. RtlDeleteCriticalSection( _sem ); \
  51. TRACESTACK((pStack,TC_ICAAPI,TT_SEM,"DELETELOCK: "#_sem"\n")); \
  52. }
  53. #define LOCK( _sem ) { \
  54. ASSERTUNLOCK( _sem ); \
  55. RtlEnterCriticalSection( _sem ); \
  56. TRACESTACK((pStack,TC_ICAAPI,TT_SEM,"LOCK: "#_sem"\n")); \
  57. }
  58. #define UNLOCK( _sem ) { \
  59. TRACESTACK((pStack,TC_ICAAPI,TT_SEM,"UNLOCK: "#_sem"\n")); \
  60. ASSERTLOCK( _sem ); \
  61. RtlLeaveCriticalSection( _sem ); \
  62. }
  63. #ifdef DBG
  64. // (per JHavens) DWORD ThreadId is comparable to HANDLE OwningThread despite different sizes.
  65. // Objects will still remain in <2GB address speace in Win64.
  66. #define ASSERTLOCK(_sem) { ASSERT( LongToHandle(GetCurrentThreadId()) == (_sem)->OwningThread ); }
  67. #define ASSERTUNLOCK(_sem) { ASSERT( LongToHandle(GetCurrentThreadId()) != (_sem)->OwningThread ); }
  68. #else
  69. #define ASSERTLOCK(_sem)
  70. #define ASSERTUNLOCK(_sem)
  71. #endif
  72. /*=============================================================================
  73. == Structures
  74. =============================================================================*/
  75. /*
  76. * Stack data structure
  77. */
  78. typedef struct _STACK {
  79. /*
  80. * Critical section protecting this structure and the
  81. * connection driver
  82. */
  83. CRITICAL_SECTION CritSec;
  84. ULONG RefCount;
  85. HANDLE hUnloadEvent;
  86. HANDLE hCloseEvent;
  87. /*
  88. * ICA Device driver stack handle
  89. */
  90. HANDLE hStack;
  91. /*
  92. * Data for Connection Driver
  93. */
  94. HANDLE hCdDLL; // connection driver dll handle
  95. PVOID pCdContext; // pointer to connection driver context
  96. PCDOPEN pCdOpen; // pointer to connection driver open
  97. PCDCLOSE pCdClose; // pointer to connection driver close
  98. PCDIOCONTROL pCdIoControl; // pointer to connection driver IoControl
  99. ULONG fStackLoaded: 1; // stack drivers are loaded
  100. ULONG fUnloading: 1; // stack drivers are being unloaded
  101. ULONG fClosing: 1; // stack is being closed
  102. PSTACKIOCONTROLCALLBACK pStackIoControlCallback;
  103. PVOID pCallbackContext;
  104. } STACK, * PSTACK;