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.

119 lines
4.0 KiB

  1. /*
  2. * _IMEMX.H
  3. *
  4. * Routines and macros to manage per-instance global variables
  5. * for DLLs under both Win16 and Win32. Allows the per-instance globals
  6. * for different functional areas of a DLL to reside in seperate memory blocks
  7. * Functions are provided to install and retrieve the
  8. * correct block of memory for the current instance/functional_area.
  9. *
  10. * There are only two functions:
  11. *
  12. * PvGetInstanceGlobalsEx Call this to get the address of the
  13. * per-instance globals structure.
  14. * ScSetinstanceGlobalsEx Call this to install the
  15. * per-instance globals structure. It
  16. * may fail if the number of instances
  17. * exceeds a certain limit.
  18. *
  19. * The caller is free to choose the name, size, and allocation
  20. * method of the per-instance global variables structure.
  21. */
  22. #ifndef _IMEMX_H
  23. #define _IMEMX_H
  24. #if defined (WIN32) && !defined (MAC)
  25. /*
  26. * The WIN32 implementation uses a pointer in the DLL's data
  27. * segment. This assumes that the DLL gets a separate instance
  28. * of the default data segment per calling process.
  29. */
  30. #define DefineInstList(Name) VOID FAR *pinst_##Name = NULL
  31. #define DeclareInstList(Name) extern VOID FAR *pinst_##Name;
  32. #define PvGetInstanceGlobalsEx(Name) pinst_##Name
  33. #define ScSetInstanceGlobalsEx(_pv, Name) (pinst_##Name = _pv, 0)
  34. #elif defined (WIN16)
  35. /* InstList
  36. *
  37. * Since more than one independently developed functional areas can be
  38. * combined into a single DLL, the routines for finding instance data in
  39. * WIN16 will take an LPInstList as a parameter. A seperate InstList
  40. * structure is kept for each functional area.
  41. *
  42. * Each InstList has a fixed array of pointers (lprgLpvInstList) and a
  43. * matching fixed array of keys (lprgInstKeyList) unique to the calling
  44. * process. The key for a given process (StackSegment) and the index of this
  45. * key in lprgInstKeyList can be quickly obtained. A pointer to the instance
  46. * data is at the corresponding index of lprgLpvInstList. Though the
  47. * instance key (StackSegment) can be obtained quickly and is guaranteed (in
  48. * WIN16) to be unique at any given moment, it is not guaranteed to be unique
  49. * throughout the life of the DLL. For this reason a "more" unique key may
  50. * be useful at Instance Contruct/Destruct time. lprgdwPidList is a list of
  51. * keys corresponding to lprgInstKeyList which are guaranteed unique through
  52. * the life of the DLL, but which are more time consuming to obtain.
  53. */
  54. typedef struct _InstList
  55. {
  56. WORD cInstEntries;
  57. WORD wCachedKey;
  58. LPVOID lpvCachedInst;
  59. DWORD dwInstFlags;
  60. WORD FAR * lprgwInstKey;
  61. LPVOID FAR * lprglpvInst;
  62. DWORD FAR * lprgdwPID;
  63. HTASK FAR * lprghTask; // raid 31090: used to recycle instance slots
  64. } InstList, FAR * LPInstList;
  65. #define INST_ALLOCATED 1
  66. /*
  67. *
  68. */
  69. #define cInstChunk 50
  70. #define DefineInstList(Name) \
  71. InstList instList_##Name = { 0, 0, NULL, INST_ALLOCATED, NULL, NULL, NULL}
  72. #define DeclareInstList(Name) extern InstList instList_##Name
  73. #define PvGetInstanceGlobalsEx(Name) \
  74. PvGetInstanceGlobalsInt(&instList_##Name)
  75. #define ScSetInstanceGlobalsEx(pv, Name) \
  76. ScSetInstanceGlobalsInt(pv, &instList_##Name)
  77. extern LPVOID PvGetInstanceGlobalsInt(LPInstList lpInstListX);
  78. extern SCODE ScSetInstanceGlobalsInt(LPVOID pv, LPInstList lpInstListX);
  79. #elif defined (MAC)
  80. /*
  81. * The MAC implementation uses a linked list containing unique keys
  82. * to the calling process and pointers to instance data. This linked
  83. * list is n-dimensional because the Mac version often groups several
  84. * dlls into one exe.
  85. */
  86. #define DeclareInstList(Name)
  87. LPVOID FAR PASCAL PvGetInstanceGlobalsMac(WORD dwDataSet);
  88. SCODE FAR PASCAL ScSetInstanceGlobalsMac(LPVOID pv, WORD dwDataSet);
  89. #else
  90. //$ REVIEW: DOS based pst will not compile without these
  91. // definitions
  92. //
  93. #define DeclareInstList(Name) extern VOID FAR *pinst_##Name;
  94. #define PvGetInstanceGlobalsEx(Name) pinst_##Name
  95. #endif /* WIN32, WIN16, Mac */
  96. #endif /* _IMEMX_H */