VOID UnDriver(PDRIVER_OBJECT driver)
{
DbgPrint(
"驱动已卸载 \n"
);
}
/
/
PowerBy: LyShark
NTSTATUS DriverEntry(IN PDRIVER_OBJECT Driver, PUNICODE_STRING RegistryPath)
{
UNICODE_STRING uncode_buffer[
10
]
=
{
0
};
wchar_t
*
wchar_string
=
L
"hello lyshark"
;
DbgPrint(
"hello lyshark \n"
);
int
size
=
sizeof(uncode_buffer)
/
sizeof(uncode_buffer[
0
]);
DbgPrint(
"数组长度: %d \n"
, size);
for
(
int
x
=
0
; x < size; x
+
+
)
{
/
/
分配空间
uncode_buffer[x].
Buffer
=
(PWSTR)ExAllocatePool(PagedPool,
1024
);
/
/
设置长度
uncode_buffer[x].MaximumLength
=
1024
;
uncode_buffer[x].Length
=
wcslen(wchar_string)
*
sizeof(WCHAR);
ASSERT(uncode_buffer[x].MaximumLength >
=
uncode_buffer[x].Length);
/
/
拷贝字符串并输出
RtlCopyMemory(uncode_buffer[x].
Buffer
, wchar_string, uncode_buffer[x].Length);
uncode_buffer[x].Length
=
wcslen(wchar_string)
*
sizeof(WCHAR);
DbgPrint(
"循环: %d 输出字符串: %wZ \n"
, x, uncode_buffer[x]);
/
/
释放内存
ExFreePool(uncode_buffer[x].
Buffer
);
uncode_buffer[x].
Buffer
=
NULL;
uncode_buffer[x].Length
=
uncode_buffer[x].MaximumLength
=
0
;
}
DbgPrint(
"驱动加载成功 \n"
);
Driver
-
>DriverUnload
=
UnDriver;
return
STATUS_SUCCESS;
}