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.

332 lines
8.8 KiB

  1. /*****************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1989-1991 **/
  4. /*****************************************************************/
  5. /*
  6. * Windows/Network Interface -- LAN Manager Version
  7. *
  8. * History
  9. * terryk 01-Nov-1991 Add WNetResourceEnum Init and
  10. * term function
  11. * Yi-HsinS 31-Dec-1991 Unicode work
  12. * terryk 03-Jan-1992 Capitalize the manifest
  13. * beng 06-Apr-1992 Unicode conversion
  14. * Yi-HsinS 20-Nov-1992 Added hmodAclEditor and
  15. * pSedDiscretionaryAclEditor
  16. */
  17. #define INCL_WINDOWS
  18. #define INCL_WINDOWS_GDI
  19. #define INCL_DOSERRORS
  20. #define INCL_NETERRORS
  21. #define INCL_NETUSE
  22. #define INCL_NETWKSTA
  23. #define INCL_NETLIB
  24. #define _WINNETWK_
  25. #include <lmui.hxx>
  26. #undef _WINNETWK_
  27. extern "C"
  28. {
  29. #include <dos.h>
  30. //#include <stdlib.h>
  31. #include <wnet1632.h>
  32. #include <winlocal.h>
  33. #include <wninit.h>
  34. #include <uimsg.h> // For range of string IDs used
  35. #include <uirsrc.h>
  36. #include <helpnums.h>
  37. #include <sedapi.h>
  38. }
  39. #ifndef max
  40. #define max(a,b) ((a)>(b)?(a):(b))
  41. #endif
  42. #define INCL_BLT_CONTROL
  43. #define INCL_BLT_DIALOG
  44. #define INCL_BLT_MSGPOPUP
  45. #include <blt.hxx>
  46. #include <uitrace.hxx>
  47. #include <wnetdev.hxx>
  48. #include <string.hxx>
  49. #include <strchlit.hxx> // for STRING_TERMINATOR
  50. #include <wnprop.hxx>
  51. /* Local prototypes */
  52. // reorged these for Glock
  53. extern "C"
  54. {
  55. BOOL NEAR PASCAL LIBMAIN ( HINSTANCE hInst,
  56. UINT wDataSeg,
  57. UINT wHeapSize,
  58. LPSTR lpCmdLine );
  59. /* Under Win32, DllMain simply calls LIBMAIN.
  60. */
  61. BOOL DllMain( HINSTANCE hDll, DWORD dwReason, LPVOID lpvReserved ) ;
  62. void FAR PASCAL Enable ( void );
  63. void FAR PASCAL Disable ( void );
  64. INT FAR PASCAL WEP ( UINT wWord );
  65. void ErrorInitWarning ( APIERR err );
  66. #ifdef DEBUG // debug scratch area
  67. TCHAR CJJRW[64] ;
  68. #endif
  69. }
  70. #define FAR_HEAPS_DLL 5 /* Maximum numbe of far heaps for ::new */
  71. BOOL fRealMode = FALSE;
  72. HINSTANCE hModule = NULL;
  73. typedef DWORD (*PSEDDISCRETIONARYACLEDITOR)( HWND, HANDLE, LPWSTR,
  74. PSED_OBJECT_TYPE_DESCRIPTOR, PSED_APPLICATION_ACCESSES,
  75. LPWSTR, PSED_FUNC_APPLY_SEC_CALLBACK, ULONG_PTR, PSECURITY_DESCRIPTOR,
  76. BOOLEAN, LPDWORD );
  77. HMODULE hmodAclEditor = NULL;
  78. extern "C"
  79. {
  80. PSEDDISCRETIONARYACLEDITOR pSedDiscretionaryAclEditor = NULL;
  81. }
  82. /*****
  83. *
  84. * LIBMAIN
  85. *
  86. * Purpose:
  87. * Initialize DLL, which includes:
  88. * - save away instance handle
  89. * - set current capabilities
  90. *
  91. * Parameters:
  92. * hInst Instance handle of DLL
  93. *
  94. * Returns:
  95. * TRUE Init OK
  96. * FALSE Init failed
  97. */
  98. BOOL /* NEAR PASCAL */ LIBMAIN ( HINSTANCE hInst,
  99. UINT wDataSeg,
  100. UINT wHeapSize,
  101. LPSTR lpCmdLine )
  102. {
  103. UNREFERENCED (wDataSeg);
  104. UNREFERENCED (lpCmdLine);
  105. ::hModule = hInst;
  106. UNREFERENCED( wHeapSize );
  107. /* GetWinFlags goes away under Win32.
  108. */
  109. ::fRealMode = FALSE;
  110. return TRUE;
  111. } /* LIBMAIN */
  112. /*******************************************************************
  113. NAME: DllMain
  114. SYNOPSIS: Win32 DLL Entry point. This function gets called when
  115. a process or thread attaches/detaches itself to this DLL.
  116. We simply call the Win3 appropriate DLL function.
  117. ENTRY: hDll - DLL Module handle
  118. dwReason - Indicates attach/detach
  119. lpvReserved - Not used
  120. EXIT:
  121. RETURNS: TRUE if successful, FALSE otherwise
  122. NOTES: This is the typical Win32 DLL entry style.
  123. This is Win32 only.
  124. HISTORY:
  125. Johnl 01-Nov-1991 Created
  126. ********************************************************************/
  127. BOOL DllMain( HINSTANCE hDll, DWORD dwReason, LPVOID lpvReserved )
  128. {
  129. UNREFERENCED( lpvReserved ) ;
  130. switch ( dwReason )
  131. {
  132. case DLL_PROCESS_ATTACH:
  133. DisableThreadLibraryCalls(hDll);
  134. return LIBMAIN( hDll, 0, 0, NULL ) ;
  135. case DLL_PROCESS_DETACH:
  136. return WEP( 0 ) ;
  137. default:
  138. // Unexpected reason given to Win32LibMain entry point
  139. UIASSERT(FALSE);
  140. break ;
  141. }
  142. return FALSE ;
  143. }
  144. /*******************************************************************
  145. NAME: InitShellUI
  146. SYNOPSIS: The function initializes the UI side of this DLL. This
  147. helps the load time when the dll is used as a network
  148. provider for NT.
  149. RETURNS: NERR_Success if successful, error code otherwise
  150. NOTES: Every UI entrypoint in this DLL should call this function.
  151. It will do the right thing if we've already been initialized.
  152. HISTORY:
  153. Johnl 07-Aug-1992 Created
  154. ********************************************************************/
  155. BOOL fInitialized = FALSE ;
  156. APIERR InitShellUI( void )
  157. {
  158. APIERR err = NERR_Success ;
  159. if ( !fInitialized )
  160. {
  161. ::hmodAclEditor = NULL;
  162. ::pSedDiscretionaryAclEditor = NULL;
  163. if ( (err = BLT::Init(::hModule,
  164. IDRSRC_SHELL_BASE, IDRSRC_SHELL_LAST,
  165. IDS_UI_SHELL_BASE, IDS_UI_SHELL_LAST)) ||
  166. (err = I_PropDialogInit()) ||
  167. (err = BLT::RegisterHelpFile( ::hModule,
  168. IDS_SHELLHELPFILENAME,
  169. HC_UI_SHELL_BASE,
  170. HC_UI_SHELL_LAST)))
  171. {
  172. /* Fall through and don't set the initialized flag
  173. */
  174. }
  175. else
  176. {
  177. fInitialized = TRUE ;
  178. }
  179. }
  180. return err ;
  181. }
  182. /*******************************************************************
  183. NAME: TermShellUI
  184. SYNOPSIS: Frees the memory used to initialize this DLL
  185. NOTES: Should only be called when the DLL is terminated and the
  186. DLL has been initialized (i.e., fInitialized=TRUE).
  187. HISTORY:
  188. Johnl 07-Aug-1992 Created
  189. ********************************************************************/
  190. void TermShellUI( void )
  191. {
  192. if ( fInitialized )
  193. {
  194. I_PropDialogUnInit() ;
  195. BLT::DeregisterHelpFile( ::hModule, 0 );
  196. BLT::Term( ::hModule );
  197. if ( ::hmodAclEditor != NULL )
  198. ::FreeLibrary( ::hmodAclEditor );
  199. }
  200. }
  201. /*
  202. * Enable - must be exported as ordinal @21 in .DEF file
  203. *
  204. * Lanman driver exports this function so that Windows can call
  205. * it whenever Lanman driver is started and each time it is swapped
  206. * back in off disk.
  207. *
  208. * Note: the corresponding function in Windows is Disable() which
  209. * Windows will call it whenever driver is about to swapped
  210. * out the disk and exit Windows. Enable() and Disable()
  211. * were implemented specifically for supporting the popup
  212. * mechanisms, where you need to disengage yourself before
  213. * being swapped to disk so that you won't be called when
  214. * you're not there.
  215. *
  216. */
  217. void Enable ( void )
  218. {
  219. /* This is only to provide a entry point whenever Windows tries
  220. * to call Lanman driver.
  221. */
  222. return;
  223. } /* Enable */
  224. /*
  225. * Disable - must be exported as ordinal @22 in .DEF file
  226. *
  227. * Lanman driver exports this function so that Windows can call
  228. * it whenever Lanman driver is exited and each time it is swapped
  229. * out the disk.
  230. *
  231. */
  232. void Disable ( void )
  233. {
  234. return;
  235. } /* Disable */
  236. /*
  237. * WEP (Windows Export Proc--short and cryptic name because
  238. * this function is not given an ordinal)
  239. *
  240. * When Windows unloads a driver, it calls this function so that
  241. * the driver can do any last minute clean-ups. Then, Windows
  242. * calls the WEP function. All Windows libraries are required to
  243. * contain this function. It should be included in the .def file
  244. * but should not be given an ordinal.
  245. *
  246. */
  247. INT WEP ( UINT wWord )
  248. {
  249. UNREFERENCED( wWord ) ;
  250. TermShellUI() ;
  251. return 1;
  252. } /* WEP */