Source code of Windows XP (NT5)
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.

172 lines
3.0 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. #ifndef UNICODE
  17. #error UNICODE required
  18. #endif
  19. //
  20. // Entry point for DLL
  21. //
  22. BOOL
  23. WINAPI
  24. DllMain (
  25. IN HINSTANCE hInstance,
  26. IN DWORD dwReason,
  27. IN LPVOID lpReserved
  28. )
  29. /*++
  30. Routine Description:
  31. DllMain is the w95upgnt.dll entry point. The OS calls it with
  32. dwReason set to either DLL_PROCESS_ATTACH or DLL_PROCESS_DETACH.
  33. The hInstance and lpReserved parameters are passed to all
  34. libraries used by the DLL.
  35. Arguments:
  36. hInstance - Specifies the instance handle of the DLL (and not the parent EXE or DLL)
  37. dwReason - Specifies DLL_PROCESS_ATTACH or DLL_PROCESS_DETACH. We specifically
  38. disable DLL_THREAD_ATTACH and DLL_THREAD_DETACH.
  39. lpReserved - Unused.
  40. Return Value:
  41. DLL_PROCESS_ATTACH:
  42. TRUE if initialization completed successfully, or FALSE if an error
  43. occurred. The DLL remains loaded only if TRUE is returned.
  44. DLL_PROCESS_DETACH:
  45. Always TRUE.
  46. other:
  47. unexpected, but always returns TRUE.
  48. --*/
  49. {
  50. switch (dwReason) {
  51. case DLL_PROCESS_ATTACH:
  52. //
  53. // Initialize DLL globals
  54. //
  55. if (!FirstInitRoutine (hInstance)) {
  56. return FALSE;
  57. }
  58. //
  59. // Initialize all libraries
  60. //
  61. if (!InitLibs (hInstance, dwReason, lpReserved)) {
  62. return FALSE;
  63. }
  64. //
  65. // Final initialization
  66. //
  67. if (!FinalInitRoutine ()) {
  68. return FALSE;
  69. }
  70. break;
  71. case DLL_PROCESS_DETACH:
  72. //
  73. // Call the cleanup routine that requires library APIs
  74. //
  75. FirstCleanupRoutine();
  76. //
  77. // Clean up all libraries
  78. //
  79. TerminateLibs (hInstance, dwReason, lpReserved);
  80. //
  81. // Do any remaining clean up
  82. //
  83. FinalCleanupRoutine();
  84. break;
  85. }
  86. return TRUE;
  87. }
  88. BOOL
  89. WINAPI
  90. W95UpgNt_Migrate (
  91. IN HWND ProgressBar,
  92. IN PCWSTR UnattendFile,
  93. IN PCWSTR SourceDir // i.e. f:\i386
  94. )
  95. {
  96. SendMessage (ProgressBar, PBM_SETPOS, 0, 0);
  97. if (!SysSetupInit (ProgressBar, UnattendFile, SourceDir)) {
  98. LOG ((LOG_ERROR, "W95UPGNT : Can't init globals"));
  99. return FALSE;
  100. }
  101. return PerformMigration (ProgressBar, UnattendFile, SourceDir);
  102. }
  103. BOOL
  104. WINAPI
  105. W95UpgNt_FileRemoval (
  106. VOID
  107. )
  108. {
  109. // Close all files and make current directory the root of c:
  110. SysSetupTerminate();
  111. DEBUGMSG ((DBG_VERBOSE, "Win95 Migration: Removing temporary files"));
  112. return MigMain_Cleanup();
  113. }