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.

159 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1994 - 1995 Microsoft Corporation
  3. Module Name:
  4. Win9x.c
  5. Abstract:
  6. Test pre-migration of Win95 to NT
  7. Author:
  8. MuhuntS
  9. Revision History:
  10. 01-17-97
  11. --*/
  12. #define NOMINMAX
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <windows.h>
  17. #include <stdio.h>
  18. #include <setupapi.h>
  19. #include <plugin.h>
  20. P_QUERY_VERSION QueryVersion;
  21. P_INITIALIZE_9X Initialize9x;
  22. P_MIGRATE_SYSTEM_9X MigrateSystem9x;
  23. P_INITIALIZE_NT InitializeNT;
  24. P_MIGRATE_SYSTEM_NT MigrateSystemNT;
  25. WCHAR szSrcDir[MAX_PATH], szWrkDir[MAX_PATH];
  26. int __cdecl
  27. main (argc, argv)
  28. int argc;
  29. char *argv[];
  30. {
  31. PVENDORINFO pVI;
  32. HMODULE hModule;
  33. HANDLE hAlive = NULL;
  34. DWORD dwLastError;
  35. LPSTR p1, p2, p3, p4, p5;
  36. LONG x;
  37. UINT v;
  38. INT c;
  39. LONG lLastErr;
  40. char error_buffer[300];
  41. p1 = p2 = p3 = p4 = p5 = NULL;
  42. if ( argc < 3 ) {
  43. printf("Usage: %s <working-dir> <source-dir>\n", argv[0]);
  44. return 0;
  45. }
  46. hModule = LoadLibraryA("migrate.dll");
  47. if ( !hModule ) {
  48. lLastErr = GetLastError();
  49. FormatMessageA(
  50. FORMAT_MESSAGE_FROM_SYSTEM, NULL, lLastErr, 0L, error_buffer,
  51. sizeof(error_buffer), NULL );
  52. printf("%s: LoadLibrary failed with %d - %s\n", argv[0], lLastErr, error_buffer);
  53. goto Cleanup;
  54. }
  55. //
  56. // Nt only?
  57. //
  58. if ( argc == 4 && argv[3][0] == '+' )
  59. goto DoNT;
  60. (FARPROC) QueryVersion = GetProcAddress(hModule, "QueryVersion");
  61. (FARPROC) Initialize9x = GetProcAddress(hModule, "Initialize9x");
  62. (FARPROC) MigrateSystem9x = GetProcAddress(hModule, "MigrateSystem9x");
  63. if ( !QueryVersion || !Initialize9x || !MigrateSystem9x )
  64. goto Cleanup;
  65. x = QueryVersion(&p1, (LPUINT)&p2, (LPINT*)&p3, &p4, (PVENDORINFO*)&pVI);
  66. printf("QueryVersion returned %d\n", x);
  67. x = Initialize9x(argv[1], argv[2], 0);
  68. printf("Initialize9x returned %d\n", x);
  69. x = MigrateSystem9x(0, NULL, 0);
  70. printf("MigrateSystem9x returned %d\n", x);
  71. FreeLibrary(hModule);
  72. //
  73. // Win95 only?
  74. //
  75. if ( argc == 4 && argv[3][0] == '-' )
  76. goto Cleanup;
  77. hModule = LoadLibraryA("migrate.dll");
  78. if ( !hModule ) {
  79. lLastErr = GetLastError();
  80. FormatMessageA(
  81. FORMAT_MESSAGE_FROM_SYSTEM, NULL, lLastErr, 0L, error_buffer,
  82. sizeof(error_buffer), NULL );
  83. printf("%s: LoadLibrary II failed with %d - %s\n", argv[0], lLastErr, error_buffer);
  84. goto Cleanup;
  85. }
  86. DoNT:
  87. MultiByteToWideChar(CP_ACP,
  88. MB_PRECOMPOSED,
  89. argv[1],
  90. -1,
  91. szWrkDir,
  92. MAX_PATH);
  93. MultiByteToWideChar(CP_ACP,
  94. MB_PRECOMPOSED,
  95. argv[2],
  96. -1,
  97. szSrcDir,
  98. MAX_PATH);
  99. InitializeNT = (P_INITIALIZE_NT)GetProcAddress(hModule, "InitializeNT");
  100. MigrateSystemNT = (P_MIGRATE_SYSTEM_NT)GetProcAddress(hModule, "MigrateSystemNT");
  101. if ( !InitializeNT || !MigrateSystemNT )
  102. goto Cleanup;
  103. hAlive = CreateEventA(NULL, FALSE, FALSE, "MigDllAlive");
  104. if ( ERROR_SUCCESS == InitializeNT(szWrkDir, szSrcDir, 0) )
  105. MigrateSystemNT(INVALID_HANDLE_VALUE, 0);
  106. FreeLibrary(hModule);
  107. Cleanup:
  108. if ( hModule )
  109. FreeLibrary(hModule);
  110. if ( hAlive )
  111. CloseHandle(hAlive);
  112. return 0;
  113. }