代码如下:
#include "stdafx.h"
#include <Windows.h>
#include <tchar.h>typedef struct _UNICODE_STRING 
{
USHORT Length;
USHORT MaximumLength;
PWSTR  Buffer;
} UNICODE_STRING;typedef UNICODE_STRING *PUNICODE_STRING;
typedef const UNICODE_STRING *PCUNICODE_STRING;typedef VOID (NTAPI *FUNC_RtlInitUnicodeString)(IN OUT PUNICODE_STRING  DestinationString,
IN PCWSTR  SourceString);
typedef VOID (NTAPI *FUNC_RtlFreeUnicodeString)(IN PUNICODE_STRING  UnicodeString);FUNC_RtlInitUnicodeString Real_RtlInitUnicodeString = NULL;
FUNC_RtlFreeUnicodeString Real_RtlFreeUnicodeString = NULL;void test()
{
HMODULE hNtDll = ::GetModuleHandle(_T("ntdll.dll"));
Real_RtlInitUnicodeString = (FUNC_RtlInitUnicodeString)::GetProcAddress(hNtDll,"RtlInitUnicodeString");
Real_RtlFreeUnicodeString = (FUNC_RtlFreeUnicodeString)::GetProcAddress(hNtDll,"RtlFreeUnicodeString"); WCHAR wcTemp[MAX_PATH] = L"ddd";
UNICODE_STRING unicodeString ;
Real_RtlInitUnicodeString(&unicodeString,wcTemp);
Real_RtlFreeUnicodeString(&unicodeString);

return;
}int _tmain(int argc, _TCHAR* argv[])
{
test();
return 0;
}错误如下:
HEAP[TestApp.exe]: Invalid Address specified to RtlFreeHeap( 00150000, 0012FC78 )
Windows has triggered a breakpoint in TestApp.exe.This may be due to a corruption of the heap, which indicates a bug in TestApp.exe or any of the DLLs it has loaded.This may also be due to the user pressing F12 while TestApp.exe has focus.