static char *path;
static char *file;
static char *makefile;
-static char *umstubfile;
-static char *kmstubfile;
static char *exestubfile;
static char*
return 0;
}
-static char KMSTUB[] =
- "/* This file is autogenerated. */\n"
- "\n"
- "#include <roskrnl.h>\n"
- "#include <../kmregtests/kmregtests.h>\n"
- "\n"
- "typedef int (*TestRoutine)(int Command, char *Buffer);\n"
- "\n"
- "extern void RegisterTests();\n"
- "\n"
- "static PDEVICE_OBJECT KMRegTestsDeviceObject = NULL;\n"
- "static PFILE_OBJECT KMRegTestsFileObject = NULL;\n"
- "\n"
- "void AddTest(TestRoutine Routine)\n"
- "{\n"
- " UNICODE_STRING DriverName;\n"
- " IO_STATUS_BLOCK IoStatus;\n"
- " NTSTATUS Status;\n"
- " KEVENT Event;\n"
- " PIRP Irp;\n"
- "\n"
- " if (KMRegTestsDeviceObject == NULL)\n"
- " {\n"
- " RtlInitUnicodeString(&DriverName, L\"\\\\Device\\\\KMRegTests\");\n"
- " Status = IoGetDeviceObjectPointer(&DriverName, FILE_WRITE_ATTRIBUTES,\n"
- " &KMRegTestsFileObject, &KMRegTestsDeviceObject);\n"
- " if (!NT_SUCCESS(Status)) return;\n"
- " }\n"
- " KeInitializeEvent(&Event, NotificationEvent, FALSE);\n"
- " Irp = IoBuildDeviceIoControlRequest(IOCTL_KMREGTESTS_REGISTER,\n"
- " KMRegTestsDeviceObject, &Routine, sizeof(TestRoutine), NULL, 0, FALSE, &Event, &IoStatus);\n"
- " Status = IoCallDriver(KMRegTestsDeviceObject, Irp);\n"
- "}\n"
- "\n"
- "void PrepareTests()\n"
- "{\n"
- " RegisterTests();\n"
- "}\n";
-
-static char UMSTUB[] =
- "/* This file is autogenerated. */\n"
- "\n"
- "#include <windows.h>\n"
- "#define NTOS_MODE_USER\n"
- "#include <ntos.h>\n"
- "#include \"regtests.h\"\n"
- "\n"
- "PVOID\n"
- "AllocateMemory(ULONG Size)\n"
- "{\n"
- " return (PVOID) RtlAllocateHeap(RtlGetProcessHeap(), 0, Size);\n"
- "}\n"
- "\n"
- "VOID\n"
- "FreeMemory(PVOID Base)\n"
- "{\n"
- " RtlFreeHeap(RtlGetProcessHeap(), 0, Base);\n"
- "}\n"
- "\n"
- "/* This function will be called several times */\n"
- "void PrepareTests()\n"
- "{\n"
- " static int testsRegistered = 0;\n"
- " if (testsRegistered == 0)\n"
- " {\n"
- " HANDLE hEvent;\n"
- " hEvent = OpenEventW(\n"
- " EVENT_ALL_ACCESS,\n"
- " FALSE,\n"
- " L\"WinRegTests\");\n"
- " if (hEvent != NULL)\n"
- " {\n"
- " SetEvent(hEvent);\n"
- " CloseHandle(hEvent);\n"
- " testsRegistered = 1;\n"
- " InitializeTests();\n"
- " RegisterTests();\n"
- " PerformTests(NULL, NULL);\n"
- " }\n"
- " }\n"
- "}\n";
-
static char EXESTUB[] =
"/* This file is autogenerated. */\n"
"\n"
"{\n"
" InitializeTests();\n"
" RegisterTests();\n"
+ " SetupOnce();\n"
" PerformTests(ConsoleWrite, NULL);\n"
" NtTerminateProcess (NtCurrentProcess(), 0);\n"
" return 0;\n"
"ULONG MaxExternalDependency = ExternalDependencyCount - 1;\n";
static char HELP[] =
- "REGTESTS path file makefile [-u umstubfile] [-k kmstubfile] [-e exestubfile]\n"
+ "REGTESTS path file makefile [-e exestubfile]\n"
"REGTESTS -s stublistfile stubsfile hooksfile\n"
"\n"
" path Path to files\n"
" file Registration file to create\n"
" makefile Makefile to create\n"
- " umstubfile Optional stub for running tests internal to a user-mode module\n"
- " kmstubfile Optional stub for running tests internal to a kernel-mode module\n"
- " exestubfile Optional stub for running tests internal to a module in the build environment\n"
+ " exestubfile Optional stub for running tests in the build environment\n"
" stublistfile File with descriptions of stubs\n"
" stubsfile File with stubs to create\n"
" hooksfile File with hooks to create\n";
return 1;
}
- umstubfile = NULL;
- kmstubfile = NULL;
exestubfile = NULL;
for (i = 4; i < argc; i++)
{
if (argv[i][0] == '-')
{
- if (argv[i][1] == 'u')
- {
- umstubfile = convert_path(argv[++i]);
- if (umstubfile[0] == 0)
- {
- printf("Missing umstubfile\n");
- return 1;
- }
- }
- else if (argv[i][1] == 'k')
- {
- kmstubfile = convert_path(argv[++i]);
- if (kmstubfile[0] == 0)
- {
- printf("Missing kmstubfile\n");
- return 1;
- }
- }
- else if (argv[i][1] == 'e')
- {
- exestubfile = convert_path(argv[++i]);
- if (exestubfile[0] == 0)
- {
- printf("Missing exestubfile\n");
- return 1;
- }
- }
- else
- {
- printf("Unknown switch\n");
- return 1;
- }
+ if (argv[i][1] == 'e')
+ {
+ exestubfile = convert_path(argv[++i]);
+ if (exestubfile[0] == 0)
+ {
+ printf("Missing exestubfile\n");
+ return 1;
+ }
+ }
+ else
+ {
+ printf("Unknown switch -%c\n", argv[i][1]);
+ return 1;
+ }
}
}
fclose(out);
- /* User-mode stubfile */
- if (umstubfile != NULL)
- {
- if (write_file_if_changed(umstubfile, UMSTUB) != 0)
- {
- perror("Cannot create output user-mode stubfile");
- return 1;
- }
- }
-
- /* Kernel-mode stubfile */
- if (kmstubfile != NULL)
- {
- if (write_file_if_changed(kmstubfile, KMSTUB) != 0)
- {
- perror("Cannot create output kernel-mode stubfile");
- return 1;
- }
- }
-
/* Executable stubfile */
if (exestubfile != NULL)
{