mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Device driver loading and unloading utilities.
svn path=/trunk/; revision=6135
This commit is contained in:
parent
85fd5b07a7
commit
bf8e3b5659
6 changed files with 118 additions and 0 deletions
6
reactos/apps/utils/driver/load/.cvsignore
Normal file
6
reactos/apps/utils/driver/load/.cvsignore
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
*.o
|
||||||
|
*.d
|
||||||
|
*.exe
|
||||||
|
*.coff
|
||||||
|
*.sym
|
||||||
|
*.map
|
32
reactos/apps/utils/driver/load/load.c
Normal file
32
reactos/apps/utils/driver/load/load.c
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Load a device driver
|
||||||
|
*/
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ntos/zw.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
UNICODE_STRING ServiceName;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
{
|
||||||
|
printf("Usage: load <ServiceName>\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ServiceName.Length = (strlen(argv[1]) + 52) * sizeof(WCHAR);
|
||||||
|
ServiceName.Buffer = (LPWSTR)malloc(ServiceName.Length + sizeof(UNICODE_NULL));
|
||||||
|
wsprintf(ServiceName.Buffer,
|
||||||
|
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\%S",
|
||||||
|
argv[1]);
|
||||||
|
wprintf(L"%s %d %d\n", ServiceName.Buffer, ServiceName.Length, wcslen(ServiceName.Buffer));
|
||||||
|
Status = NtLoadDriver(&ServiceName);
|
||||||
|
free(ServiceName.Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
printf("Failed: %X\n", Status);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
21
reactos/apps/utils/driver/load/makefile
Normal file
21
reactos/apps/utils/driver/load/makefile
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
PATH_TO_TOP = ../../../..
|
||||||
|
|
||||||
|
TARGET_NORC = yes
|
||||||
|
|
||||||
|
TARGET_TYPE = program
|
||||||
|
|
||||||
|
TARGET_APPTYPE = console
|
||||||
|
|
||||||
|
TARGET_NAME = load
|
||||||
|
|
||||||
|
TARGET_CFLAGS = -DUNICODE -D_UNICODE
|
||||||
|
|
||||||
|
TARGET_SDKLIBS = ntdll.a
|
||||||
|
|
||||||
|
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||||
|
|
||||||
|
include $(PATH_TO_TOP)/rules.mak
|
||||||
|
|
||||||
|
include $(TOOLS_PATH)/helper.mk
|
||||||
|
|
||||||
|
# EOF
|
6
reactos/apps/utils/driver/unload/.cvsignore
Normal file
6
reactos/apps/utils/driver/unload/.cvsignore
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
*.o
|
||||||
|
*.d
|
||||||
|
*.exe
|
||||||
|
*.coff
|
||||||
|
*.sym
|
||||||
|
*.map
|
21
reactos/apps/utils/driver/unload/makefile
Normal file
21
reactos/apps/utils/driver/unload/makefile
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
PATH_TO_TOP = ../../../..
|
||||||
|
|
||||||
|
TARGET_NORC = yes
|
||||||
|
|
||||||
|
TARGET_TYPE = program
|
||||||
|
|
||||||
|
TARGET_APPTYPE = console
|
||||||
|
|
||||||
|
TARGET_NAME = unload
|
||||||
|
|
||||||
|
TARGET_CFLAGS = -DUNICODE -D_UNICODE
|
||||||
|
|
||||||
|
TARGET_SDKLIBS = ntdll.a
|
||||||
|
|
||||||
|
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||||
|
|
||||||
|
include $(PATH_TO_TOP)/rules.mak
|
||||||
|
|
||||||
|
include $(TOOLS_PATH)/helper.mk
|
||||||
|
|
||||||
|
# EOF
|
32
reactos/apps/utils/driver/unload/unload.c
Normal file
32
reactos/apps/utils/driver/unload/unload.c
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Unload a device driver
|
||||||
|
*/
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ntos/zw.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
UNICODE_STRING ServiceName;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
{
|
||||||
|
printf("Usage: unload <ServiceName>\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ServiceName.Length = (strlen(argv[1]) + 52) * sizeof(WCHAR);
|
||||||
|
ServiceName.Buffer = (LPWSTR)malloc(ServiceName.Length + sizeof(UNICODE_NULL));
|
||||||
|
wsprintf(ServiceName.Buffer,
|
||||||
|
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\%S",
|
||||||
|
argv[1]);
|
||||||
|
wprintf(L"%s %d %d\n", ServiceName.Buffer, ServiceName.Length, wcslen(ServiceName.Buffer));
|
||||||
|
Status = NtUnloadDriver(&ServiceName);
|
||||||
|
free(ServiceName.Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
printf("Failed: %X\n", Status);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue