ReactOS 0.4.16-dev-112-g52265ae
mkhive.c File Reference
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include "mkhive.h"
Include dependency graph for mkhive.c:

Go to the source code of this file.

Macros

#define PATH_MAX   260
 
#define DIR_SEPARATOR_CHAR   '/'
 
#define DIR_SEPARATOR_STRING   "/"
 

Functions

void usage (void)
 
void convert_path (char *dst, char *src)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ DIR_SEPARATOR_CHAR

#define DIR_SEPARATOR_CHAR   '/'

Definition at line 46 of file mkhive.c.

◆ DIR_SEPARATOR_STRING

#define DIR_SEPARATOR_STRING   "/"

Definition at line 47 of file mkhive.c.

◆ PATH_MAX

#define PATH_MAX   260

Definition at line 44 of file mkhive.c.

Function Documentation

◆ convert_path()

void convert_path ( char dst,
char src 
)

Definition at line 66 of file mkhive.c.

67{
68 int i;
69
70 i = 0;
71 while (src[i] != 0)
72 {
73#ifdef _WIN32
74 if (src[i] == '/')
75 {
76 dst[i] = '\\';
77 }
78#else
79 if (src[i] == '\\')
80 {
81 dst[i] = '/';
82 }
83#endif
84 else
85 {
86 dst[i] = src[i];
87 }
88
89 i++;
90 }
91 dst[i] = 0;
92}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by main().

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 94 of file mkhive.c.

95{
96 INT ret;
97 INT i;
98 PSTR ptr;
99 BOOL UpperCaseFileName = FALSE;
100 PCSTR HiveList = NULL;
101 CHAR DestPath[PATH_MAX] = "";
103
104 if (argc < 4)
105 {
106 usage();
107 return -1;
108 }
109
110 printf("Binary hive maker\n");
111
112 /* Read the options */
113 for (i = 1; i < argc && *argv[i] == '-'; i++)
114 {
115 if (argv[i][1] == '?' && argv[i][2] == 0)
116 {
117 usage();
118 return 0;
119 }
120
121 if (argv[i][1] == 'u' && argv[i][2] == 0)
122 {
123 UpperCaseFileName = TRUE;
124 }
125 else
126 if (argv[i][1] == 'h' && (argv[i][2] == ':' || argv[i][2] == '='))
127 {
128 HiveList = argv[i] + 3;
129 }
130 else if (argv[i][1] == 'd' && (argv[i][2] == ':' || argv[i][2] == '='))
131 {
132 convert_path(DestPath, argv[i] + 3);
133 }
134 else
135 {
136 fprintf(stderr, "Unrecognized option: %s\n", argv[i]);
137 return -1;
138 }
139 }
140
141 /* Check whether we have all the parameters needed */
142 if (!HiveList || !*HiveList)
143 {
144 fprintf(stderr, "The mandatory list of hives is missing.\n");
145 return -1;
146 }
147 if (!*DestPath)
148 {
149 fprintf(stderr, "The mandatory output directory is missing.\n");
150 return -1;
151 }
152 if (i >= argc)
153 {
154 fprintf(stderr, "Not enough parameters, or the list of INF files is missing.\n");
155 return -1;
156 }
157
158 /* Initialize the registry */
159 RegInitializeRegistry(HiveList);
160
161 /* Default to failure */
162 ret = -1;
163
164 /* Now we should have the list of INF files: parse it */
165 for (; i < argc; ++i)
166 {
169 goto Quit;
170 }
171
172 for (i = 0; i < MAX_NUMBER_OF_REGISTRY_HIVES; ++i)
173 {
174 /* Skip this registry hive if it's not in the list */
175 if (!strstr(HiveList, RegistryHives[i].HiveName))
176 continue;
177
178 strcpy(FileName, DestPath);
180
182
183 strcat(FileName, RegistryHives[i].HiveName);
184
185 /* Exception for the special setup registry hive */
186 // if (strcmp(RegistryHives[i].HiveName, "SETUPREG") == 0)
187 if (i == 0)
188 strcat(FileName, ".HIV");
189
190 /* Adjust file name case if needed */
191 if (UpperCaseFileName)
192 {
193 for (; *ptr; ++ptr)
194 *ptr = toupper(*ptr);
195 }
196 else
197 {
198 for (; *ptr; ++ptr)
199 *ptr = tolower(*ptr);
200 }
201
203 goto Quit;
204
205 /* If we happen to deal with the special setup registry hive, stop there */
206 // if (strcmp(RegistryHives[i].HiveName, "SETUPREG") == 0)
207 if (i == 0)
208 break;
209 }
210
211 /* Success */
212 ret = 0;
213
214Quit:
215 /* Shut down the registry */
217
218 if (ret == 0)
219 printf(" Done.\n");
220
221 return ret;
222}
static int argc
Definition: ServiceArgs.c:12
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int toupper(int c)
Definition: utclib.c:881
int tolower(int c)
Definition: utclib.c:902
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static BOOL ImportRegistryFile(HWND hWnd)
Definition: framewnd.c:439
HIVE_LIST_ENTRY RegistryHives[]
Definition: registry.c:581
NTSTATUS RegInitializeRegistry(IN PUNICODE_STRING NtSystemRoot)
Definition: registry.c:679
BOOL ExportBinaryHive(IN PCSTR FileName, IN PCMHIVE CmHive)
Definition: binhive.c:34
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define printf
Definition: freeldr.h:97
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define DIR_SEPARATOR_STRING
Definition: mkhive.c:47
void convert_path(char *dst, char *src)
Definition: mkhive.c:66
#define PATH_MAX
Definition: mkhive.c:44
void usage(void)
Definition: mkhive.c:55
static PVOID ptr
Definition: dispmode.c:27
#define argv
Definition: mplay32.c:18
VOID RegShutdownRegistry(VOID)
Definition: registry.c:1193
#define MAX_NUMBER_OF_REGISTRY_HIVES
Definition: registry.h:19
char * PSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
int ret
char CHAR
Definition: xmlstorage.h:175

◆ usage()

void usage ( void  )

Definition at line 55 of file mkhive.c.

56{
57 printf("Usage: mkhive [-?] -h:hive1[,hiveN...] [-u] -d:<dstdir> <inffiles>\n\n"
58 " -h:hiveN - Comma-separated list of hives to create. Possible values are:\n"
59 " SETUPREG, SYSTEM, SOFTWARE, DEFAULT, SAM, SECURITY, BCD.\n"
60 " -u - Generate file names in uppercase (default: lowercase) (TEMPORARY FLAG!).\n"
61 " -d:dstdir - The binary hive files are created in this directory.\n"
62 " inffiles - List of INF files with full path.\n"
63 " -? - Displays this help screen.\n");
64}

Referenced by main().