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.

239 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. defs.h
  5. Abstract:
  6. Main definitions of the jetconv.exe process
  7. Author:
  8. Sanjay Anand (SanjayAn) Nov. 14, 1995
  9. Environment:
  10. User mode
  11. Revision History:
  12. Sanjay Anand (SanjayAn) Nov. 14, 1995
  13. Created
  14. --*/
  15. #include <nt.h>
  16. #include <ntrtl.h>
  17. #include <nturtl.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <windows.h>
  21. #include "locmsg.h"
  22. #define NUM_SERVICES 3
  23. #define MAX_NAME_LEN 20
  24. #define PAD 44444
  25. #define JCONVMUTEXNAME TEXT("JCMUTEX")
  26. #define JCONVSHAREDMEMNAME TEXT("JCSHAREDMEM")
  27. #define SYSTEM_ROOT TEXT("%systemroot%\\system32\\")
  28. #define CONVERT_EXE_PATH TEXT("%systemroot%\\system32\\upg351db.exe")
  29. #define JCONV_LOG_KEY_PREFIX TEXT("System\\CurrentControlSet\\Services\\EventLog\\Application\\")
  30. #define WINS_REGISTRY_SERVICE_PATH TEXT("System\\CurrentControlSet\\Services\\Wins")
  31. #define DHCP_REGISTRY_SERVICE_PATH TEXT("System\\CurrentControlSet\\Services\\DHCPServer")
  32. #define RPL_REGISTRY_SERVICE_PATH TEXT("System\\CurrentControlSet\\Services\\RemoteBoot")
  33. #define WINS_REGISTRY_PARAMETERS_PATH TEXT("System\\CurrentControlSet\\Services\\Wins\\Parameters")
  34. #define DHCP_REGISTRY_PARAMETERS_PATH TEXT("System\\CurrentControlSet\\Services\\DHCPServer\\Parameters")
  35. #define RPL_REGISTRY_PARAMETERS_PATH TEXT("System\\CurrentControlSet\\Services\\RemoteBoot\\Parameters")
  36. #define WINS_REGISTRY_DBFILE_PATH TEXT("DbFileNm")
  37. #define DHCP_REGISTRY_DBFILE_PATH TEXT("DatabasePath")
  38. #define DHCP_REGISTRY_DBFILE_NAME TEXT("DatabaseName")
  39. #define RPL_REGISTRY_DBFILE_PATH TEXT("Directory")
  40. #define WINS_REGISTRY_LOGFILE_PATH TEXT("LogFilePath")
  41. #define DHCP_REGISTRY_LOGFILE_PATH TEXT("LogFilePath")
  42. // no such path
  43. // #define RPL_REGISTRY_LOGFILE_PATH TEXT("LogFilePath")
  44. #define WINS_REGISTRY_BACKUP_PATH TEXT("BackupDirPath")
  45. #define DHCP_REGISTRY_BACKUP_PATH TEXT("BackupDatabasePath")
  46. // no such path
  47. // #define RPL_REGISTRY_BACKUP_PATH TEXT("BackupDatabasePath")
  48. #define DEFAULT_WINS_DBFILE_PATH TEXT("%systemroot%\\system32\\Wins\\wins.mdb")
  49. #define DEFAULT_DHCP_DBFILE_PATH TEXT("%systemroot%\\system32\\Dhcp\\dhcp.mdb")
  50. #define DEFAULT_RPL_DBFILE_PATH TEXT("%systemroot%\\Rpl\\rplsvc.mdb")
  51. #define DEFAULT_WINS_LOGFILE_PATH TEXT("%systemroot%\\system32\\Wins")
  52. #define DEFAULT_DHCP_LOGFILE_PATH TEXT("%systemroot%\\system32\\Dhcp")
  53. #define DEFAULT_RPL_LOGFILE_PATH TEXT("%systemroot%\\Rpl")
  54. #define DEFAULT_WINS_BACKUP_PATH TEXT("")
  55. #define DEFAULT_DHCP_BACKUP_PATH TEXT("%systemroot%\\system32\\Dhcp\\Backup")
  56. #define DEFAULT_RPL_BACKUP_PATH TEXT("%systemroot%\\Rpl\\Backup")
  57. #define DEFAULT_WINS_SYSTEM_PATH TEXT("%systemroot%\\system32\\Wins\\system.mdb")
  58. #define DEFAULT_DHCP_SYSTEM_PATH TEXT("%systemroot%\\system32\\Dhcp\\system.mdb")
  59. #define DEFAULT_RPL_SYSTEM_PATH TEXT("%systemroot%\\Rpl\\system.mdb")
  60. //
  61. // Jet500 to Jet600 definitions, etc.
  62. //
  63. #define CONVERT_EXE_PATH_ESE TEXT("%systemroot%\\system32\\esentutl.exe")
  64. #define DEFAULT_WINS_BACKUP_PATH_ESE TEXT("") // TEXT("%systemroot%\\system32\\Wins\\winsb.mdb")
  65. #define DEFAULT_DHCP_BACKUP_PATH_ESE TEXT("%systemroot%\\system32\\Dhcp\\Backup\\dhcp.mdb")
  66. #define DEFAULT_RPL_BACKUP_PATH_ESE TEXT("%systemroot%\\Rpl\\Backup\\rplsvc.mdb")
  67. #define DEFAULT_WINS_PRESERVE_PATH_ESE TEXT("%systemroot%\\system32\\Wins\\40Db\\wins.mdb")
  68. #define DEFAULT_DHCP_PRESERVE_PATH_ESE TEXT("%systemroot%\\system32\\Dhcp\\40Db\\dhcp.mdb")
  69. #define DEFAULT_RPL_PRESERVE_PATH_ESE TEXT("")
  70. #if DBG
  71. #define MYDEBUG(_Print) { \
  72. if (JCDebugLevel == 1) { \
  73. DbgPrint ("JCONV: "); \
  74. DbgPrint _Print; \
  75. } else { \
  76. printf ("JCONV: "); \
  77. printf _Print; \
  78. }\
  79. }
  80. #else
  81. #define MYDEBUG(_Print)
  82. #endif
  83. typedef enum _SERVICES {
  84. DHCP,
  85. WINS,
  86. RPL
  87. } SERVICES, *PSERVICES;
  88. typedef struct _SERVICE_INFO {
  89. TCHAR ServiceName[MAX_NAME_LEN];
  90. BOOLEAN Installed;
  91. BOOLEAN DefaultDbPath;
  92. BOOLEAN DefaultLogFilePath;
  93. BOOLEAN DBConverted;
  94. BOOLEAN ServiceStarted;
  95. TCHAR DBPath[MAX_PATH];
  96. TCHAR SystemFilePath[MAX_PATH];
  97. TCHAR LogFilePath[MAX_PATH];
  98. TCHAR BackupPath[MAX_PATH];
  99. //
  100. // ESE has a different backup path specification format
  101. // Which gives rise to the following spud.
  102. //
  103. TCHAR ESEBackupPath[MAX_PATH];
  104. TCHAR ESEPreservePath[MAX_PATH];
  105. LARGE_INTEGER DBSize;
  106. } SERVICE_INFO, *PSERVICE_INFO;
  107. typedef struct _SHARED_MEM {
  108. BOOLEAN InvokedByService[NUM_SERVICES];
  109. } SHARED_MEM, *PSHARED_MEM;
  110. extern TCHAR SystemDrive[4];
  111. extern LONG JCDebugLevel;
  112. extern HANDLE EventLogHandle;
  113. extern PSHARED_MEM shrdMemPtr;
  114. extern HANDLE hMutex;
  115. extern HANDLE hFileMapping;
  116. extern BOOLEAN Jet200;
  117. //
  118. // Prototypes
  119. //
  120. NTSTATUS
  121. JCRegisterEventSrc();
  122. NTSTATUS
  123. JCDeRegisterEventSrc();
  124. VOID
  125. JCLogEvent(
  126. IN DWORD EventId,
  127. IN LPSTR MsgTypeString1,
  128. IN LPSTR MsgTypeString2,
  129. IN LPSTR MsgTypeString3
  130. );
  131. VOID
  132. JCReadRegistry(
  133. IN PSERVICE_INFO pServiceInfo
  134. );
  135. VOID
  136. JCGetMutex (
  137. IN HANDLE mutex,
  138. IN DWORD To
  139. );
  140. VOID
  141. JCFreeMutex (
  142. IN HANDLE mutex
  143. );
  144. NTSTATUS
  145. JCCallUpg(
  146. IN SERVICES Id,
  147. IN PSERVICE_INFO pServiceInfo
  148. );
  149. DWORD
  150. JCConvert(
  151. IN PSERVICE_INFO pServiceInfo
  152. );
  153. NTSTATUS
  154. DeleteLogFiles(
  155. TCHAR * LogFilePath
  156. );
  157. DWORD
  158. PreserveCurrentDb( TCHAR * szBasePath,
  159. TCHAR * szSourceDb,
  160. TCHAR * szPreserveDbPath,
  161. TCHAR * szPreserveDB
  162. );