mirror of
https://github.com/reactos/reactos.git
synced 2025-07-13 07:44:16 +00:00

Also: - Set ServiceName.MaximumLength. - Fix MSVC warnings: '...\load\load.c(19): warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data '...\unload\unload.c(19): warning C4267: '=': conversion from 'size_t' to 'USHORT', possible loss of data' '...\unload\unload.c(24): warning C4476: 'wprintf' : unknown type field character 'U' in format specifier' '...\unload\unload.c(24): warning C4474: 'wprintf' : too many arguments passed for format string'
37 lines
861 B
C
37 lines
861 B
C
/*
|
|
* Unload a device driver
|
|
*/
|
|
#define WIN32_NO_STATUS
|
|
#include <windows.h>
|
|
#include <stdlib.h>
|
|
#include <ntndk.h>
|
|
|
|
int wmain(int argc, WCHAR * argv[])
|
|
{
|
|
NTSTATUS Status;
|
|
UNICODE_STRING ServiceName;
|
|
|
|
if (argc != 2)
|
|
{
|
|
wprintf(L"Usage: unload <ServiceName>\n");
|
|
return 0;
|
|
}
|
|
|
|
ServiceName.Length = (USHORT)((52 + wcslen(argv[1])) * sizeof(WCHAR));
|
|
ServiceName.MaximumLength = ServiceName.Length + sizeof(UNICODE_NULL);
|
|
ServiceName.Buffer = malloc(ServiceName.MaximumLength);
|
|
wsprintf(ServiceName.Buffer,
|
|
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\%s",
|
|
argv[1]);
|
|
wprintf(L"Unloading %wZ\n", &ServiceName);
|
|
|
|
Status = NtUnloadDriver(&ServiceName);
|
|
free(ServiceName.Buffer);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
wprintf(L"Failed: 0x%08lx\n", Status);
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|