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.

113 lines
2.7 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: libmain.c
  6. * Content: entry points in the DLL
  7. *@@BEGIN_MSINTERNAL
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 20-jan-95 craige initial implementation
  12. * 03-jul-95 craige export instance handle
  13. *@@END_MSINTERNAL
  14. *
  15. ***************************************************************************/
  16. #include "ddraw16.h"
  17. // in gdihelp.c
  18. extern void GdiHelpCleanUp(void);
  19. extern BOOL GdiHelpInit(void);
  20. // in modex.c
  21. extern UINT ModeX_Width;
  22. extern WORD hselSecondary;
  23. HINSTANCE hInstApp;
  24. HGLOBAL hAlloc = 0;
  25. int FAR PASCAL LibMain(HINSTANCE hInst, WORD wHeapSize, LPCSTR lpCmdLine)
  26. {
  27. hInstApp = hInst;
  28. pWin16Lock = GetWin16Lock();
  29. GdiHelpInit();
  30. DPFINIT();
  31. hAlloc = GlobalAlloc(GMEM_FIXED | GMEM_SHARE, 65536);
  32. hselSecondary = (WORD) hAlloc;
  33. if( hselSecondary )
  34. {
  35. LocalInit(hselSecondary, 16, 65536-4); // Keep DWORD aligned
  36. }
  37. return 1;
  38. }
  39. BOOL FAR PASCAL _loadds WEP( WORD wParm )
  40. {
  41. DPF( 1, "WEP" );
  42. //
  43. // clean up DCI
  44. //
  45. if( wFlatSel )
  46. {
  47. VFDEndLinearAccess();
  48. SetSelLimit( wFlatSel, 0 );
  49. FreeSelector( wFlatSel );
  50. wFlatSel = 0;
  51. }
  52. if( hAlloc )
  53. {
  54. GlobalFree( hAlloc );
  55. }
  56. //
  57. // let gdihelp.c cleaup global objects
  58. //
  59. GdiHelpCleanUp();
  60. //
  61. // if we are still in ModeX, leave now
  62. //
  63. if( ModeX_Width )
  64. {
  65. ModeX_RestoreMode();
  66. }
  67. return 1;
  68. }
  69. extern BOOL FAR PASCAL thk3216_ThunkConnect16( LPSTR pszDll16, LPSTR pszDll32, WORD hInst, DWORD dwReason);
  70. extern BOOL FAR PASCAL thk1632_ThunkConnect16( LPSTR pszDll16, LPSTR pszDll32, WORD hInst, DWORD dwReason);
  71. #define DLL_PROCESS_ATTACH 1
  72. #define DLL_THREAD_ATTACH 2
  73. #define DLL_THREAD_DETACH 3
  74. #define DLL_PROCESS_DETACH 0
  75. static char __based(__segname("LIBMAIN_TEXT")) szDll16[] = DDHAL_DRIVER_DLLNAME;
  76. static char __based(__segname("LIBMAIN_TEXT")) szDll32[] = DDHAL_APP_DLLNAME;
  77. BOOL FAR PASCAL __export DllEntryPoint(
  78. DWORD dwReason,
  79. WORD hInst,
  80. WORD wDS,
  81. WORD wHeapSize,
  82. DWORD dwReserved1,
  83. WORD wReserved2)
  84. {
  85. DPF( 1, "DllEntryPoint: dwReason=%ld, hInst=%04x, dwReserved1=%08lx, wReserved2=%04x",
  86. dwReason, hInst, wDS, dwReserved1, wReserved2 );
  87. if( !thk3216_ThunkConnect16( szDll16, szDll32, hInst, dwReason))
  88. {
  89. return FALSE;
  90. }
  91. if( !thk1632_ThunkConnect16( szDll16, szDll32, hInst, dwReason))
  92. {
  93. return FALSE;
  94. }
  95. return TRUE;
  96. }