Driver Online에 견우님의 글을 가지고 왔습니다.
출처 : http://www.driveronline.org/bbs/view.asp?tb=cjhnim&no=80
WDK에서 유니코드 관련 함수중에
있을만할 것 같은데도 없는 함수들이 몇가지가 있습니다.
바로 유니코드 할당/해제 함수이죠…그래서 아래와 같이
MyAllocateUnicodeString, MyFreeUnicodeString 등을 만들어 쓰면
편리합니다.uniString.MaximumLength = (USHORT) MAX_PATH ;
status = MyAllocateUnicodeString( &uniString );
… 중간 생략 …
MyFreeUnicodeString(&uniSTring) ;
NTSTATUS
MyAllocateUnicodeString (
__inout PUNICODE_STRING String
)
{
PAGED_CODE();
String->Buffer = ExAllocatePoolWithTag( PagedPool,
String->MaximumLength,
NULL );
if (String->Buffer == NULL) {
return STATUS_INSUFFICIENT_RESOURCES;
}
String->Length = 0;
return STATUS_SUCCESS;
}
VOID
MyFreeUnicodeString (
__inout PUNICODE_STRING String
)
{
PAGED_CODE();
ExFreePoolWithTag( String->Buffer,
NULL );
String->Length = String->MaximumLength = 0;
String->Buffer = NULL;
}p.s.ExAllocatePoolWithTag( PagedPool,
String->MaximumLength,
‘10YM’ );
ExFreePoolWithTag( String->Buffer,
‘10YM’ );
위처럼 태깅을 하셔서 쓰시면
메모리 풀 관련 문제가 생겼을때 디버깅하기 유용하실꺼에요~
태그는..원하시는 이름으로 바꿔서 쓰세요
최근 답글