Utils: Introduce helper for opening current process handle

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit is contained in:
Dmitry Fleytman 2015-11-16 14:52:19 +02:00
parent 065604373f
commit 742f044334
3 changed files with 25 additions and 1 deletions

View file

@ -159,3 +159,24 @@ PVOID DuplicateStaticBuffer(const void *Buffer, SIZE_T Length, POOL_TYPE PoolTyp
}
return Duplicate;
}
NTSTATUS
UsbDkCreateCurrentProcessHandle(HANDLE &Handle)
{
PAGED_CODE();
auto status = ZwDuplicateObject(ZwCurrentProcess(),
ZwCurrentProcess(),
ZwCurrentProcess(),
&Handle,
PROCESS_DUP_HANDLE,
OBJ_KERNEL_HANDLE,
0);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, TRACE_UTILS, "%!FUNC! failed, error: %!STATUS!", status);
}
return status;
}

View file

@ -497,3 +497,6 @@ LONGLONG MillisecondsTo100Nanoseconds(LONGLONG Milliseconds)
{
return Milliseconds * 10 * 1000;
}
NTSTATUS
UsbDkCreateCurrentProcessHandle(HANDLE &Handle);

View file

@ -11,7 +11,7 @@
extern "C"
{
#include <ntddk.h>
#include <ntifs.h>
#include <wdf.h>
#include <usb.h>