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.

255 lines
8.4 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: Srvrmain.c Server Main module
  3. *
  4. * Purpose: Includes server intialization and termination code.
  5. *
  6. * Created: Oct 1990.
  7. *
  8. * Copyright (c) 1990 - 1992 Microsoft Corporation
  9. *
  10. * History:
  11. * Raor (../10/1990) Designed, coded
  12. * curts created portable version for WIN16/32
  13. *
  14. \***************************************************************************/
  15. #include "windows.h"
  16. #include "ole.h"
  17. #include "dde.h"
  18. #include "cmacs.h"
  19. #include "srvr.h"
  20. #ifndef WF_WLO
  21. #define WF_WLO 0x8000
  22. #endif
  23. // ordinal number of new Win31 API IsTask
  24. #define ORD_IsTask 320
  25. // ordinal number of new Win31 API SetMetaFileBitsBetter
  26. #define ORD_SetMetaFileBitsBetter 196
  27. // public vars.
  28. // atomes used in the systems
  29. ATOM aStdExit; // "StdExit"
  30. ATOM aStdCreate; // "StdNewDicument"
  31. ATOM aStdOpen; // "StdOpenDocument"
  32. ATOM aStdEdit; // "StdOpenDocument"
  33. ATOM aStdCreateFromTemplate; // "StdNewFromTemplate"
  34. ATOM aStdClose; // "StdCloseDocument"
  35. ATOM aStdShowItem; // "StdShowItem"
  36. ATOM aStdDoVerbItem; // "StddoVerbItem"
  37. ATOM aSysTopic; // "System"
  38. ATOM aOLE; // "OLE"
  39. ATOM aStdDocName; // "StdDocumentName"
  40. ATOM cfBinary; // "Binary format"
  41. ATOM cfNative; // "NativeFormat"
  42. ATOM cfLink; // "ObjectLink"
  43. ATOM cfOwnerLink; // "Ownerlink"
  44. ATOM aChange; // "Change"
  45. ATOM aSave; // "Save"
  46. ATOM aClose; // "Close"
  47. ATOM aProtocols; // "Protocols"
  48. ATOM aTopics; // "Topics"
  49. ATOM aFormats; // "Formats"
  50. ATOM aStatus; // "Status"
  51. ATOM aEditItems; // "Edit items
  52. ATOM aTrue; // "True"
  53. ATOM aFalse; // "False"
  54. // !!! free the proc instances.
  55. FARPROC lpSendRenameMsg; // Call back enum props for rename
  56. FARPROC lpSendDataMsg; // Call back enum props for data
  57. FARPROC lpFindItemWnd; // Callback in enum props of
  58. FARPROC lpItemCallBack; // CallBack for object
  59. FARPROC lpTerminateClients; // Callback in Doc enum properties
  60. FARPROC lpTerminateDocClients; // Callback in Doc enum properties
  61. FARPROC lpDeleteClientInfo; // proc for deleteing each item client
  62. FARPROC lpEnumForTerminate; // proc for terminating clients not in rename list
  63. FARPROC lpfnSetMetaFileBitsBetter = NULL;
  64. FARPROC lpfnIsTask = NULL;
  65. HANDLE hdllInst;
  66. VOID FAR PASCAL WEP(int);
  67. #ifdef WIN32 //WIN32
  68. BOOL LibMain(
  69. HANDLE hInst,
  70. ULONG Reason,
  71. PCONTEXT Context
  72. #endif
  73. ){
  74. WNDCLASS wc;
  75. Puts("LibMain");
  76. #ifdef WIN32
  77. UNREFERENCED_PARAMETER(Context);
  78. if (Reason == DLL_PROCESS_DETACH)
  79. {
  80. WEP(0);
  81. return TRUE;
  82. }
  83. else if (Reason != DLL_PROCESS_ATTACH)
  84. return TRUE;
  85. #endif
  86. hdllInst = hInst;
  87. // !!! Put all this stuff thru soemkind of table so that we can
  88. // save code.
  89. // register all the atoms.
  90. aStdExit = GlobalAddAtom ((LPSTR)"StdExit");
  91. aStdCreate = GlobalAddAtom ((LPSTR)"StdNewDocument");
  92. aStdOpen = GlobalAddAtom ((LPSTR)"StdOpenDocument");
  93. aStdEdit = GlobalAddAtom ((LPSTR)"StdEditDocument");
  94. aStdCreateFromTemplate = GlobalAddAtom ((LPSTR)"StdNewfromTemplate");
  95. aStdClose = GlobalAddAtom ((LPSTR)"StdCloseDocument");
  96. aStdShowItem = GlobalAddAtom ((LPSTR)"StdShowItem");
  97. aStdDoVerbItem = GlobalAddAtom ((LPSTR)"StdDoVerbItem");
  98. aSysTopic = GlobalAddAtom ((LPSTR)"System");
  99. aOLE = GlobalAddAtom ((LPSTR)"OLEsystem");
  100. aStdDocName = GlobalAddAtom ((LPSTR)"StdDocumentName");
  101. aProtocols = GlobalAddAtom ((LPSTR)"Protocols");
  102. aTopics = GlobalAddAtom ((LPSTR)"Topics");
  103. aFormats = GlobalAddAtom ((LPSTR)"Formats");
  104. aStatus = GlobalAddAtom ((LPSTR)"Status");
  105. aEditItems = GlobalAddAtom ((LPSTR)"EditEnvItems");
  106. aTrue = GlobalAddAtom ((LPSTR)"True");
  107. aFalse = GlobalAddAtom ((LPSTR)"False");
  108. aChange = GlobalAddAtom ((LPSTR)"Change");
  109. aSave = GlobalAddAtom ((LPSTR)"Save");
  110. aClose = GlobalAddAtom ((LPSTR)"Close");
  111. // create the proc instances for the required entry pts.
  112. lpSendRenameMsg = (FARPROC)MakeProcInstance (SendRenameMsg, hdllInst);
  113. lpSendDataMsg = (FARPROC)MakeProcInstance (SendDataMsg, hdllInst);
  114. lpFindItemWnd = (FARPROC)MakeProcInstance (FindItemWnd, hdllInst);
  115. lpItemCallBack = (FARPROC)MakeProcInstance (ItemCallBack, hdllInst);
  116. lpTerminateClients = (FARPROC)MakeProcInstance (TerminateClients, hdllInst);
  117. lpTerminateDocClients = (FARPROC)MakeProcInstance (TerminateDocClients, hdllInst);
  118. lpDeleteClientInfo = (FARPROC)MakeProcInstance (DeleteClientInfo, hdllInst);
  119. lpEnumForTerminate = (FARPROC)MakeProcInstance (EnumForTerminate , hdllInst);
  120. // register the clipboard formats
  121. cfNative = (OLECLIPFORMAT)RegisterClipboardFormat("Native");
  122. cfBinary = (OLECLIPFORMAT)RegisterClipboardFormat("Binary");
  123. cfLink = (OLECLIPFORMAT)RegisterClipboardFormat("ObjectLink");
  124. cfOwnerLink = (OLECLIPFORMAT)RegisterClipboardFormat("OwnerLink");
  125. wc.style = 0;
  126. wc.cbClsExtra = 0;
  127. wc.cbWndExtra = sizeof(LONG_PTR) + //Ask for extra space for storing the
  128. //ptr to srvr/doc/iteminfo.
  129. sizeof (WORD) + // for LE chars
  130. sizeof (UINT_PTR); // for keeping the hDLLInst.
  131. wc.hInstance = hInst;
  132. wc.hIcon = NULL;
  133. wc.hCursor = NULL;
  134. wc.hbrBackground= NULL;
  135. wc.lpszMenuName = NULL;
  136. // Srvr window class
  137. wc.lpfnWndProc = SrvrWndProc;
  138. wc.lpszClassName= SRVR_CLASS;
  139. if (!RegisterClass(&wc))
  140. return 0;
  141. // document window class
  142. wc.lpfnWndProc = DocWndProc;
  143. wc.lpszClassName = DOC_CLASS;
  144. if (!RegisterClass(&wc))
  145. return 0;
  146. // Item (object) window class
  147. wc.lpfnWndProc = ItemWndProc;
  148. wc.lpszClassName = ITEM_CLASS;
  149. wc.cbWndExtra = sizeof(LONG_PTR); // for items do not need extra stuff.
  150. if (!RegisterClass(&wc))
  151. return 0;
  152. return 1;
  153. }
  154. VOID APIENTRY WEP (int nParameter)
  155. {
  156. Puts("LibExit");
  157. #ifdef WIN32
  158. UNREFERENCED_PARAMETER(nParameter);
  159. DEBUG_OUT ("---L&E DLL EXIT---",0)
  160. #endif
  161. // free the global atoms.
  162. if (aStdExit)
  163. GlobalDeleteAtom (aStdExit);
  164. if (aStdCreate)
  165. GlobalDeleteAtom (aStdCreate);
  166. if (aStdOpen)
  167. GlobalDeleteAtom (aStdOpen);
  168. if (aStdEdit)
  169. GlobalDeleteAtom (aStdEdit);
  170. if (aStdCreateFromTemplate)
  171. GlobalDeleteAtom (aStdCreateFromTemplate);
  172. if (aStdClose)
  173. GlobalDeleteAtom (aStdClose);
  174. if (aStdShowItem)
  175. GlobalDeleteAtom (aStdShowItem);
  176. if (aStdDoVerbItem)
  177. GlobalDeleteAtom (aStdDoVerbItem);
  178. if (aSysTopic)
  179. GlobalDeleteAtom (aSysTopic);
  180. if (aOLE)
  181. GlobalDeleteAtom (aOLE);
  182. if (aStdDocName)
  183. GlobalDeleteAtom (aStdDocName);
  184. if (aProtocols)
  185. GlobalDeleteAtom (aProtocols);
  186. if (aTopics)
  187. GlobalDeleteAtom (aTopics);
  188. if (aFormats)
  189. GlobalDeleteAtom (aFormats);
  190. if (aStatus)
  191. GlobalDeleteAtom (aStatus);
  192. if (aEditItems)
  193. GlobalDeleteAtom (aEditItems);
  194. if (aTrue)
  195. GlobalDeleteAtom (aTrue);
  196. if (aFalse)
  197. GlobalDeleteAtom (aFalse);
  198. if (aChange)
  199. GlobalDeleteAtom (aChange);
  200. if (aSave)
  201. GlobalDeleteAtom (aSave);
  202. if (aClose)
  203. GlobalDeleteAtom (aClose);
  204. }