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.

116 lines
3.4 KiB

  1. /****************************************************************************/
  2. // nshmdisp.c
  3. //
  4. // RDP Shared Memory header
  5. //
  6. // Copyright (C) 1996-2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #include <precmpdd.h>
  9. #pragma hdrstop
  10. #define TRC_FILE "nshmdisp"
  11. #include <adcg.h>
  12. #include <nshmapi.h>
  13. #define DC_INCLUDE_DATA
  14. #include <ndddata.c>
  15. #undef DC_INCLUDE_DATA
  16. #include <nbadisp.h>
  17. #include <noadisp.h>
  18. #include <noedisp.h>
  19. #include <ncmdisp.h>
  20. #include <nschdisp.h>
  21. #include <npmdisp.h>
  22. #include <nssidisp.h>
  23. #include <nsbcdisp.h>
  24. #include <compress.h>
  25. /****************************************************************************/
  26. /* Name: SHM_Init */
  27. /* */
  28. /* Purpose: Initialize the shared memory */
  29. /* */
  30. /* Returns: TRUE if successful, FALSE otherwise */
  31. /* */
  32. /* NB Address is passed to the DD on a later IOCtl. */
  33. /****************************************************************************/
  34. BOOLEAN RDPCALL SHM_Init(PDD_PDEV pPDev)
  35. {
  36. BOOLEAN rc;
  37. DC_BEGIN_FN("SHM_Init");
  38. pddShm = (PSHM_SHARED_MEMORY)EngAllocMem(0, sizeof(SHM_SHARED_MEMORY),
  39. WD_ALLOC_TAG);
  40. if (pddShm != NULL) {
  41. TRC_ALT((TB, "Allocated shared memory OK(%p -> %p) size(%#x)",
  42. pddShm, ((BYTE *)pddShm) + sizeof(SHM_SHARED_MEMORY) - 1,
  43. sizeof(SHM_SHARED_MEMORY)));
  44. #ifdef DC_DEBUG
  45. memset(pddShm, 0, sizeof(SHM_SHARED_MEMORY));
  46. #endif
  47. // Init non-component members that need known initial values.
  48. // We DO NOT zero the shm on alloc (except in debug) to reduce paging
  49. // and cache flushing. Each component is responsible for initializing
  50. // its Shm memory.
  51. pddShm->shareId = 0;
  52. pddShm->guardVal1 = SHM_CHECKVAL;
  53. pddShm->guardVal2 = SHM_CHECKVAL;
  54. pddShm->guardVal3 = SHM_CHECKVAL;
  55. pddShm->guardVal4 = SHM_CHECKVAL;
  56. pddShm->guardVal5 = SHM_CHECKVAL;
  57. pddShm->pShadowInfo = NULL;
  58. // Now call each of the SHM component owners to init its memory.
  59. BA_InitShm();
  60. OA_InitShm();
  61. OE_InitShm();
  62. CM_InitShm();
  63. SCH_InitShm();
  64. PM_InitShm(pPDev);
  65. SSI_InitShm();
  66. SBC_InitShm();
  67. // BC does not need to be initialized.
  68. #ifdef DC_DEBUG
  69. // Init trace info.
  70. memset(&pddShm->trc, 0, sizeof(pddShm->trc));
  71. #endif
  72. rc = TRUE;
  73. }
  74. else {
  75. TRC_ERR((TB, "Failed to allocate %d bytes of shared memory",
  76. sizeof(SHM_SHARED_MEMORY)));
  77. rc = FALSE;
  78. }
  79. DC_END_FN();
  80. return rc;
  81. }
  82. /****************************************************************************/
  83. // SHM_Term
  84. /****************************************************************************/
  85. void RDPCALL SHM_Term(void)
  86. {
  87. DC_BEGIN_FN("SHM_Term");
  88. if (pddShm != NULL) {
  89. TRC_DBG((TB, "Freeing shared memory at %p", pddShm));
  90. EngFreeMem(pddShm);
  91. pddShm = NULL;
  92. }
  93. DC_END_FN();
  94. }