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.

209 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. usermig.c
  5. Abstract:
  6. User migration test tool
  7. Author:
  8. <full name> (<alias>) <date>
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. #include "pch.h"
  13. BOOL
  14. Init (
  15. VOID
  16. )
  17. {
  18. HINSTANCE hInstance;
  19. DWORD dwReason;
  20. PVOID lpReserved;
  21. //
  22. // Simulate DllMain
  23. //
  24. hInstance = GetModuleHandle (NULL);
  25. dwReason = DLL_PROCESS_ATTACH;
  26. lpReserved = NULL;
  27. //
  28. // Initialize DLL globals
  29. //
  30. if (!FirstInitRoutine (hInstance)) {
  31. return FALSE;
  32. }
  33. //
  34. // Initialize all libraries
  35. //
  36. if (!InitLibs (hInstance, dwReason, lpReserved)) {
  37. return FALSE;
  38. }
  39. //
  40. // Final initialization
  41. //
  42. if (!FinalInitRoutine ()) {
  43. return FALSE;
  44. }
  45. return TRUE;
  46. }
  47. VOID
  48. Terminate (
  49. VOID
  50. )
  51. {
  52. HINSTANCE hInstance;
  53. DWORD dwReason;
  54. PVOID lpReserved;
  55. //
  56. // Simulate DllMain
  57. //
  58. hInstance = GetModuleHandle (NULL);
  59. dwReason = DLL_PROCESS_DETACH;
  60. lpReserved = NULL;
  61. //
  62. // Call the cleanup routine that requires library APIs
  63. //
  64. FirstCleanupRoutine();
  65. //
  66. // Clean up all libraries
  67. //
  68. TerminateLibs (hInstance, dwReason, lpReserved);
  69. //
  70. // Do any remaining clean up
  71. //
  72. FinalCleanupRoutine();
  73. }
  74. INT
  75. __cdecl
  76. wmain (
  77. INT argc,
  78. WCHAR *argv[]
  79. )
  80. {
  81. LONG rc;
  82. TCHAR DefaultUserHive[MAX_TCHAR_PATH];
  83. DWORD Size;
  84. if (!Init()) {
  85. wprintf (L"Unable to initialize!\n");
  86. return 255;
  87. }
  88. //
  89. // Initialize Win95Reg
  90. //
  91. rc = Win95RegInit (TEXT("c:\\windows\\setup\\defhives"), TRUE);
  92. if (rc != ERROR_SUCCESS) {
  93. SetLastError (rc);
  94. LOG ((LOG_ERROR, "Init Processor: Win95RegInit failed, check your temp files in c:\\windows\\setup"));
  95. return FALSE;
  96. }
  97. if (!MemDbLoad (TEXT("c:\\windows\\setup\\ntsetup.dat"))) {
  98. LOG ((LOG_ERROR, "Init Processor: MemDbLoad failed, check your temp files in c:\\windows\\setup"));
  99. return FALSE;
  100. }
  101. g_DomainUserName = TEXT("NTDEV\\jimschm");
  102. g_Win9xUserName = TEXT("jimschm");
  103. g_FixedUserName = TEXT("jimschm");
  104. //
  105. // Logon prompt -- make everything NULL
  106. //
  107. if (0) {
  108. g_DomainUserName = NULL;
  109. g_Win9xUserName = NULL;
  110. g_FixedUserName = NULL;
  111. }
  112. //
  113. // Map in the default user hive
  114. //
  115. Size = ARRAYSIZE(DefaultUserHive)- 12;
  116. if (!GetDefaultUserProfileDirectory (DefaultUserHive, &Size)) {
  117. LOG ((
  118. LOG_ERROR,
  119. "Process User: Can't get default user profile directory",
  120. DefaultUserHive
  121. ));
  122. return FALSE;
  123. }
  124. StringCopy (AppendWack (DefaultUserHive), TEXT("ntuser.dat"));
  125. pSetupEnablePrivilege (SE_BACKUP_NAME, TRUE);
  126. pSetupEnablePrivilege (SE_RESTORE_NAME, TRUE);
  127. RegUnLoadKey (HKEY_LOCAL_MACHINE, S_MAPPED_DEFAULT_USER_KEY);
  128. rc = RegLoadKey (
  129. HKEY_LOCAL_MACHINE,
  130. S_MAPPED_DEFAULT_USER_KEY,
  131. DefaultUserHive
  132. );
  133. if (rc != ERROR_SUCCESS) {
  134. SetLastError (rc);
  135. LOG ((
  136. LOG_ERROR,
  137. "Process User: RegLoadKey could not load NT Default User from %s",
  138. DefaultUserHive
  139. ));
  140. return FALSE;
  141. }
  142. InitializeProgressBar (NULL, NULL, NULL, NULL);
  143. g_hKeyRootNT = HKEY_CURRENT_USER;
  144. g_hKeyRoot95 = HKEY_CURRENT_USER;
  145. SetRegRoot (g_hKeyRoot95);
  146. MergeRegistry (TEXT("d:\\i386\\usermig.inf"), g_DomainUserName ? g_DomainUserName : TEXT(""));
  147. RegUnLoadKey (HKEY_LOCAL_MACHINE, S_MAPPED_DEFAULT_USER_KEY);
  148. Terminate();
  149. return 0;
  150. }