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.

312 lines
9.5 KiB

  1. // Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1993 Microsoft Corporation,
  3. // All rights reserved.
  4. // This source code is only intended as a supplement to the
  5. // Microsoft Foundation Classes Reference and Microsoft
  6. // QuickHelp and/or WinHelp documentation provided with the library.
  7. // See these sources for detailed information regarding the
  8. // Microsoft Foundation Classes product.
  9. // afxdll_.h - extensions to AFXWIN.H used for the 'AFXDLL' version
  10. // This file contains MFC library implementation details as well
  11. // as APIs for writing MFC Extension DLLs.
  12. // Please refer to Technical Note 033 (TN033) for more details.
  13. /////////////////////////////////////////////////////////////////////////////
  14. #ifndef _AFXDLL
  15. #error illegal file inclusion
  16. #endif
  17. #undef AFXAPP_DATA
  18. #define AFXAPP_DATA AFXAPI_DATA
  19. /////////////////////////////////////////////////////////////////////////////
  20. // get best fitting resource
  21. HINSTANCE AFXAPI AfxFindResourceHandle(LPCSTR lpszName, LPCSTR lpszType);
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CDynLinkLibrary - for implementation of MFC Extension DLLs
  24. struct AFX_EXTENSION_MODULE
  25. {
  26. HMODULE hModule;
  27. CRuntimeClass* pFirstSharedClass;
  28. };
  29. // Call in DLL's LibMain
  30. void AFXAPI AfxInitExtensionModule(AFX_EXTENSION_MODULE& state, HMODULE hMod);
  31. // there is one CDynLinkLibrary in each client application using an
  32. // MFC Extension DLL
  33. class CDynLinkLibrary : public CCmdTarget
  34. {
  35. DECLARE_DYNAMIC(CDynLinkLibrary)
  36. public:
  37. // Constructor
  38. CDynLinkLibrary(AFX_EXTENSION_MODULE& state);
  39. // Attributes
  40. HMODULE m_hModule;
  41. HMODULE m_hResource; // for shared resources
  42. CRuntimeClass* m_pFirstSharedClass; // for shared CRuntimeClasses
  43. #ifdef _AFXCTL
  44. BOOL m_bSystem; // TRUE only for MFC DLLs
  45. #endif
  46. // Implementation
  47. public:
  48. CDynLinkLibrary* m_pNextDLL; // simple singly linked list
  49. virtual ~CDynLinkLibrary();
  50. #ifdef _DEBUG
  51. virtual void AssertValid() const;
  52. virtual void Dump(CDumpContext& dc) const;
  53. #endif //_DEBUG
  54. };
  55. /////////////////////////////////////////////////////////////////////////////
  56. // Diagnostic support (exported by App, used by MFC250D.DLL)
  57. class COleDebugMalloc;
  58. #ifdef _DEBUG
  59. //WARNING: Do not change this structure since AFXDLL.ASM depends on
  60. // the specific structure layout and size
  61. struct AFX_APPDEBUG
  62. {
  63. // Trace output
  64. void (CALLBACK* lpfnTraceV)(LPCSTR lpszFormat, const void FAR* lpArgs);
  65. // Assert failure reporting
  66. void (CALLBACK* lpfnAssertFailed)(LPCSTR lpszFileName, int nLine);
  67. BOOL appTraceEnabled;
  68. int appTraceFlags;
  69. // state for current memory allocation ('bAllocObj' used for free as well)
  70. LPCSTR lpszAllocFileName; // source file name (NULL => unknown)
  71. UINT nAllocLine; // source line number
  72. BOOL bAllocObj; // allocating CObject derived object
  73. BOOL bMemoryTracking; // tracking on
  74. // state for OLE debug allocations
  75. COleDebugMalloc* appDebugMalloc; // OLE 2.0 debug allocator
  76. };
  77. #define _AfxGetAppDebug() (_AfxGetAppData()->pAppDebug)
  78. #define afxTraceEnabled (_AfxGetAppDebug()->appTraceEnabled)
  79. #define afxTraceFlags (_AfxGetAppDebug()->appTraceFlags)
  80. #endif //_DEBUG
  81. /////////////////////////////////////////////////////////////////////////////
  82. // App specific data for _AFXDLL version
  83. class CHandleMap; // not NEAR in _AFXDLL version
  84. struct AFX_VBSTATE; // VB State
  85. struct AFX_FRSTATE; // Find/Replace state (for CEditView)
  86. struct AFX_OLESTATE; // OLE State
  87. struct AFX_SOCKSTATE; // Socket State
  88. typedef void FAR* HENV; // must match SQL.H
  89. #ifndef _AFXCTL
  90. //WARNING: Do not change this structure since the assembler DLL init
  91. // the specific structure layout and size
  92. struct AFX_APPDATA // starts at SS:0010
  93. {
  94. WORD cbSize; // size of this structure
  95. WORD wVersion; // 0x0250 for MFC 250
  96. #ifdef _DEBUG
  97. AFX_APPDEBUG BASED_STACK* pAppDebug;
  98. UINT wReserved;
  99. #else
  100. DWORD dwReserved;
  101. #endif
  102. DWORD dwReserved2;
  103. DWORD dwReserved3;
  104. FARPROC lpfnVBApiEntry; // must be at SS:0020
  105. // App provided/exported memory allocation interface etc
  106. void (CALLBACK* lpfnAppAbort)(); // SS:0024
  107. FARPROC (CALLBACK* lpfnAppSetNewHandler)(FARPROC); // SS:0028
  108. void* (CALLBACK* lpfnAppAlloc)(size_t nBytes); // SS:002C
  109. void (CALLBACK* lpfnAppFree)(void*); // SS:0030
  110. void* (CALLBACK* lpfnAppReAlloc)(void* pOld, size_t nSize); // SS:0034
  111. DWORD dwReserved4; // SS:0038
  112. DWORD dwReserved5; // SS:0040
  113. // app state
  114. CWinApp* appCurrentWinApp;
  115. HINSTANCE appCurrentInstanceHandle;
  116. HINSTANCE appCurrentResourceHandle;
  117. AFX_EXCEPTION_CONTEXT appExceptionContext;
  118. const char* appCurrentAppName;
  119. DWORD appTempMapLock;
  120. // internal App initialization and state
  121. HBRUSH appDlgBkBrush;
  122. COLORREF appDlgTextClr;
  123. HHOOK appHHookOldMsgFilter;
  124. HHOOK appHHookOldCbtFilter;
  125. BOOL appUserAbort; // for printing and other app modal states
  126. // splitter window state (used in winsplit.cpp)
  127. HCURSOR hcurSplitLast;
  128. HCURSOR hcurSplitDestroy;
  129. UINT idcSplitPrimaryLast;
  130. // linkage to shared resources/classes
  131. CDynLinkLibrary* pFirstDLL; // order is important for resource loads
  132. CRuntimeClass* pFirstAppClass; // CRuntimeClass support
  133. CFrameWnd* appFirstFrameWnd; // first frame window for this app
  134. // sub-system state storage
  135. // handle maps
  136. CHandleMap* appMapHGDIOBJ;
  137. CHandleMap* appMapHDC;
  138. CHandleMap* appMapHMENU;
  139. CHandleMap* appMapHWND;
  140. AFX_VBSTATE FAR* appVBState;
  141. AFX_FRSTATE FAR* appLastFRState;
  142. AFX_OLESTATE FAR* appOleState;
  143. WORD appWaitForDataSource; // semaphore for async database access
  144. BOOL bDBExtensionDLL;
  145. HENV appHenvAllConnections;
  146. int appAllocatedConnections;
  147. HINSTANCE appInstMail; // handle to MAPI.DLL
  148. AFX_SOCKSTATE FAR* appSockState;
  149. };
  150. #define _AfxGetAppData() ((AFX_APPDATA BASED_STACK*)0x10)
  151. #else
  152. struct AFX_APPDATA_MODULE
  153. {
  154. AFX_APPDATA_MODULE* m_pID; // Uniquely identify where this data came from.
  155. // app state
  156. CWinApp* appCurrentWinApp;
  157. HINSTANCE appCurrentInstanceHandle;
  158. HINSTANCE appCurrentResourceHandle;
  159. const char* appCurrentAppName;
  160. // linkage to shared resources/classes
  161. CDynLinkLibrary* pFirstDLL; // order is important for resource loads
  162. CFrameWnd* appFirstFrameWnd; // first frame window for this app
  163. CRuntimeClass* pFirstAppClass; // CRuntimeClass support
  164. AFX_OLESTATE FAR* appOleState;
  165. // dialog state
  166. HBRUSH appDlgBkBrush;
  167. COLORREF appDlgTextClr;
  168. };
  169. struct AFX_APPDATA : AFX_APPDATA_MODULE
  170. {
  171. #ifdef _DEBUG
  172. AFX_APPDEBUG *pAppDebug;
  173. #endif
  174. // splitter window state (used in winsplit.cpp)
  175. HCURSOR hcurSplitLast;
  176. HCURSOR hcurSplitDestroy;
  177. UINT idcSplitPrimaryLast;
  178. AFX_EXCEPTION_CONTEXT appExceptionContext;
  179. // internal App initialization and state
  180. HHOOK appHHookOldMsgFilter;
  181. HHOOK appHHookOldCbtFilter;
  182. BOOL appUserAbort; // for printing and other app modal states
  183. // sub-system state storage
  184. WORD appWaitForDataSource; // semaphore for async database access
  185. BOOL bDBExtensionDLL;
  186. // handle maps
  187. DWORD appTempMapLock;
  188. CHandleMap* appMapHGDIOBJ;
  189. CHandleMap* appMapHDC;
  190. CHandleMap* appMapHMENU;
  191. CHandleMap* appMapHWND;
  192. // App provided/exported memory allocation interface etc
  193. void (CALLBACK* lpfnAppAbort)();
  194. FARPROC (CALLBACK* lpfnAppSetNewHandler)(FARPROC);
  195. void* (CALLBACK* lpfnAppAlloc)(size_t nBytes);
  196. void (CALLBACK* lpfnAppFree)(void*);
  197. void* (CALLBACK* lpfnAppReAlloc)(void* pOld, size_t nSize);
  198. AFX_FRSTATE FAR* appLastFRState;
  199. WORD cbSize; // size of this structure
  200. WORD wVersion; // 0x0251 for OC 251
  201. HINSTANCE appLangDLL; // Localized resources
  202. BOOL bLangDLLInit; // TRUE if language DLL is initialized
  203. CMapPtrToPtr* appMapExtra; // Extra data for controls
  204. HENV appHenvAllConnections;
  205. int appAllocatedConnections;
  206. };
  207. extern AFX_APPDATA_MODULE* AFXAPI AfxGetBaseModuleContext();
  208. extern AFX_APPDATA_MODULE* AFXAPI AfxGetCurrentModuleContext();
  209. extern AFX_APPDATA* _AfxGetAppData();
  210. #define AfxGetExtraDataMap() (_AfxGetAppData()->appMapExtra);
  211. #define _afxOleState (*_AfxGetAppData()->appOleState)
  212. #define _afxFirstFactory (_AfxGetAppData()->appOleState->pFirstFactory)
  213. #define _afxModuleAddrCurrent AfxGetCurrentModuleContext()
  214. #define AFX_MANAGE_STATE(pData) AFX_MAINTAIN_STATE _ctlState(pData);
  215. #define METHOD_MANAGE_STATE(theClass, localClass) \
  216. METHOD_PROLOGUE(theClass, localClass) \
  217. AFX_MANAGE_STATE(pThis->m_pModuleState)
  218. extern AFX_APPDATA_MODULE* AFXAPI AfxPushModuleContext(AFX_APPDATA_MODULE* psIn);
  219. extern void AFXAPI AfxPopModuleContext(AFX_APPDATA_MODULE* psIn,
  220. BOOL bCopy = FALSE);
  221. // When using this object, or the macros above that use this object
  222. // it is necessary to insure that the object's destructor cannot be
  223. // thrown past, by an unexpected exception.
  224. class AFX_MAINTAIN_STATE
  225. {
  226. private:
  227. AFX_APPDATA_MODULE* m_psPrevious;
  228. public:
  229. AFX_MAINTAIN_STATE(AFX_APPDATA_MODULE* psData);
  230. ~AFX_MAINTAIN_STATE();
  231. };
  232. #endif
  233. #define afxTempMapLock (_AfxGetAppData()->appTempMapLock)
  234. // Extra Initialization
  235. extern "C" int PASCAL AfxWinMain(HINSTANCE, HINSTANCE, LPSTR, int);
  236. #undef AFXAPP_DATA
  237. #define AFXAPP_DATA NEAR
  238. /////////////////////////////////////////////////////////////////////////////