阅读:1835回复:5
UNICODE_STRING 用法
我在用UNICODE_STRING 时,用RtlFreeUnicodeString时总死机,请问UNICODE_STRING 应该怎样用?
UNICODE_STRING name; RtlInitUnicodeString(&name,L\"\\\\Device\\\\ParallelPort0\"); if(name.Length == 0) goto end; status = IoGetDeviceObjectPointer( &name, FILE_ALL_ACCESS, &pdx->FilePar, &pdx->DevicePar ); if(status != STATUS_SUCCESS) goto end; RtlFreeUnicodeString(&name); |
|
|
沙发#
发布于:2003-07-16 23:48
用错了 !!
RtlFreeUnicodeString The RtlFreeUnicodeString routine releases storage that was allocated by RtlAnsiStringToUnicodeString or RtlUpcaseUnicodeString. VOID RtlFreeUnicodeString( IN PUNICODE_STRING UnicodeString ); Parameters UnicodeString Pointer to the Unicode string buffer previously allocated by RtlAnsiStringToUnicodeString or RtlUpcaseUnicodeString. |
|
板凳#
发布于:2003-07-17 08:17
用UNICODE_STRING name;定义的串用不用释放?
|
|
|
地板#
发布于:2003-07-17 13:18
只针对RtlAnsiStringToUnicodeString or RtlUpcaseUnicodeString.
因为在上面的情况下由系统分配内核堆栈,来存储你的数据,所以因该释放,而用RtlInitUnicodeString(&name,L\"\\\\Device\\\\ParallelPort0\");中的字符串空间是在你函数的堆栈中,函数结束后自动释放,不用系统来管 说白了就是你狗拿耗子了,呵呵 |
|
|
地下室#
发布于:2003-07-17 13:43
RtlInitUnicodeString(&name,L\"\\\\Device\\\\ParallelPort0\");
把UNICODE_STRING的buffer指针指向常量L\"\\\\Device\\\\ParallelPort0\",然后你free他,当然会出错。 |
|
5楼#
发布于:2003-07-17 14:41
不好好看书,张冠李戴。该打
|
|
|