Utils: Introduce helper for opening current process handle
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit is contained in:
parent
065604373f
commit
742f044334
3 changed files with 25 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -497,3 +497,6 @@ LONGLONG MillisecondsTo100Nanoseconds(LONGLONG Milliseconds)
|
|||
{
|
||||
return Milliseconds * 10 * 1000;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
UsbDkCreateCurrentProcessHandle(HANDLE &Handle);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
extern "C"
|
||||
{
|
||||
#include <ntddk.h>
|
||||
#include <ntifs.h>
|
||||
#include <wdf.h>
|
||||
#include <usb.h>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue