分配内存_释放内存

来源:互联网 发布:软件测试外包 转型 编辑:程序博客网 时间:2024/05/21 10:55
#include "ntddk.h"#define lisaisai1 'MyTt'VOID MyUnload(PDRIVER_OBJECT pDriverObject){KdPrint(("驱动卸载 成功\n"));}NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING Reg_Path){UNICODE_STRING str1 = { 0 };UNICODE_STRING str2 = RTL_CONSTANT_STRING(L"邱坤小美女 我爱你\n");str1.Buffer = ExAllocatePoolWithTag(NonPagedPool, str2.Length, lisaisai1);if (str1.Buffer == NULL){return STATUS_INSUFFICIENT_RESOURCES;}str1.Length = str1.MaximumLength = str2.Length;RtlCopyUnicodeString(&str1, &str2);KdPrint(("%wZ", &str1));ExFreePool(str1.Buffer);str1.Buffer = NULL;str1.Length = str1.MaximumLength = 0;pDriverObject->DriverUnload = MyUnload;return STATUS_SUCCESS;}