能力值:
( LV3,RANK:30 )
2 楼
是要释放滴,用RtlFreeUnicodeString
能力值:
( LV2,RANK:10 )
3 楼
DDK中说
The RtlFreeUnicodeString routine releases storage that was allocated by RtlAnsiStringToUnicodeString or RtlUpcaseUnicodeString.
并没说可以用来释放RtlInitUnicodeString初始化的UNICODE_STRING,这样用可靠吗?
能力值:
( LV13,RANK:1050 )
4 楼
呵呵,不需要,看看RtlInitUnicodeString 做的事情就知道。
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING;
例如: RtlInitUnicodeString(&ntName, L"\\Device\\CallDevice");
lkd> u RtlInitUnicodeString l 30
ntdll!RtlInitUnicodeString:
7c9212d6 57 push edi
7c9212d7 8b7c240c mov edi,dword ptr [esp+0Ch] ;参数L"\\Device\\CallDevice"
7c9212db 8b542408 mov edx,dword ptr [esp+8] ;参数&ntName
7c9212df c70200000000 mov dword ptr [edx],0 ;ntName.Length = 0,ntName.MaximumLength = 0;
7c9212e5 897a04 mov dword ptr [edx+4],edi;ntName.Buffer 指向 L"\\Device\\CallDevice"
7c9212e8 0bff or edi,edi; 判断参数2,L"\\Device\\CallDevice"是否为空
7c9212ea 7422 je ntdll!RtlInitUnicodeString+0x38 (7c92130e); = 0,退出
7c9212ec 83c9ff or ecx,0FFFFFFFFh ;开始计算长度
7c9212ef 33c0 xor eax,eax
7c9212f1 f266af repne scas word ptr es:[edi]
7c9212f4 f7d1 not ecx
7c9212f6 d1e1 shl ecx,1 ;ecx保存长度
7c9212f8 81f9feff0000 cmp ecx,0FFFEh
7c9212fe 7605 jbe ntdll!RtlInitUnicodeString+0x2f (7c921305)
7c921300 b9feff0000 mov ecx,0FFFEh
7c921305 66894a02 mov word ptr [edx+2],cx ;ntName.MaximumLength = cx
7c921309 49 dec ecx
7c92130a 49 dec ecx
7c92130b 66890a mov word ptr [edx],cx ;ntName.Length = cx
7c92130e 5f pop edi
7c92130f c20800 ret 8
能力值:
( LV2,RANK:10 )
5 楼
如果你是RtlInitUnicodeString(&usMyInfo,L"This my info")
这样的话unicode_string中的buf指向的是&"This my info" 这个全局变量
所以不用释放