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.

174 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. dllentry.c
  5. Abstract:
  6. Code that implements the external DLL routines that interface with
  7. SYSSETUP.DLL.
  8. Author:
  9. Jim Schmidt (jimschm) 01-Oct-1996
  10. Revision History:
  11. Jim Schmidt (jimschm) 31-Dec-1997 Moved most of the code to initnt.lib
  12. Jim Schmidt (jimschm) 21-Nov-1997 Updated for NEC98, some cleaned up and
  13. code commenting
  14. --*/
  15. #include "pch.h"
  16. #include "master.h"
  17. #include "masternt.h"
  18. #ifndef UNICODE
  19. #error UNICODE required
  20. #endif
  21. //
  22. // Entry point for DLL
  23. //
  24. BOOL
  25. WINAPI
  26. DllMain (
  27. IN HINSTANCE hInstance,
  28. IN DWORD dwReason,
  29. IN LPVOID lpReserved
  30. )
  31. /*++
  32. Routine Description:
  33. DllMain is the w95upgnt.dll entry point. The OS calls it with
  34. dwReason set to either DLL_PROCESS_ATTACH or DLL_PROCESS_DETACH.
  35. The hInstance and lpReserved parameters are passed to all
  36. libraries used by the DLL.
  37. Arguments:
  38. hInstance - Specifies the instance handle of the DLL (and not the parent EXE or DLL)
  39. dwReason - Specifies DLL_PROCESS_ATTACH or DLL_PROCESS_DETACH. We specifically
  40. disable DLL_THREAD_ATTACH and DLL_THREAD_DETACH.
  41. lpReserved - Unused.
  42. Return Value:
  43. DLL_PROCESS_ATTACH:
  44. TRUE if initialization completed successfully, or FALSE if an error
  45. occurred. The DLL remains loaded only if TRUE is returned.
  46. DLL_PROCESS_DETACH:
  47. Always TRUE.
  48. other:
  49. unexpected, but always returns TRUE.
  50. --*/
  51. {
  52. switch (dwReason) {
  53. case DLL_PROCESS_ATTACH:
  54. //
  55. // Initialize DLL globals
  56. //
  57. if (!FirstInitRoutine (hInstance)) {
  58. return FALSE;
  59. }
  60. //
  61. // Initialize all libraries
  62. //
  63. if (!InitLibs (hInstance, dwReason, lpReserved)) {
  64. return FALSE;
  65. }
  66. //
  67. // Final initialization
  68. //
  69. if (!FinalInitRoutine ()) {
  70. return FALSE;
  71. }
  72. break;
  73. case DLL_PROCESS_DETACH:
  74. //
  75. // Call the cleanup routine that requires library APIs
  76. //
  77. FirstCleanupRoutine();
  78. //
  79. // Clean up all libraries
  80. //
  81. TerminateLibs (hInstance, dwReason, lpReserved);
  82. //
  83. // Do any remaining clean up
  84. //
  85. FinalCleanupRoutine();
  86. break;
  87. }
  88. return TRUE;
  89. }
  90. BOOL
  91. WINAPI
  92. W95UpgNt_Migrate (
  93. IN HWND ProgressBar,
  94. IN PCWSTR UnattendFile,
  95. IN PCWSTR SourceDir // i.e. f:\i386
  96. )
  97. {
  98. SendMessage (ProgressBar, PBM_SETPOS, 0, 0);
  99. if (!SysSetupInit (ProgressBar, UnattendFile, SourceDir)) {
  100. LOG ((LOG_ERROR, "W95UPGNT : Can't init globals"));
  101. return FALSE;
  102. }
  103. return PerformMigration (ProgressBar, UnattendFile, SourceDir);
  104. }
  105. BOOL
  106. WINAPI
  107. W95UpgNt_FileRemoval (
  108. VOID
  109. )
  110. {
  111. // Close all files and make current directory the root of c:
  112. SysSetupTerminate();
  113. DEBUGMSG ((DBG_VERBOSE, "Win95 Migration: Removing temporary files"));
  114. return MigMain_Cleanup();
  115. }