1.NTSTATUS를 String으로 바꾸기

원문 :  http://kkamagui.springnote.com/pages/370106

 

들어가기 전에...


 

SUMMARY

 Most Kernel Mode API functions return NTSTATUS values. To translate these status values to messages by using the FormatMessage API function, you must reference the NtDLL.dll module in the parameter list.

 

MORE INFORMATION

The following code sample demonstrates how to obtain the system message string.


  1. void DisplayError(DWORD NTStatusMessage)
    {
    LPVOID lpMessageBuffer;
    HMODULE Hand = LoadLibrary("NTDLL.DLL");

    FormatMessage(
    FORMAT_MESSAGE_ALLOCATE_BUFFER |
    FORMAT_MESSAGE_FROM_SYSTEM |
    FORMAT_MESSAGE_FROM_HMODULE,
    Hand,
    Err,
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    (LPTSTR) &lpMessageBuffer,
    0,
    NULL );

    // Now display the string.

    // Free the buffer allocated by the system.
    LocalFree( lpMessageBuffer );
    FreeLibrary(Hand);
    }

 

2.DDK에서 문자열 처리 함수 

  • 표준 함수(비권장) 

    • strcpy, wcscpy, strncpy, wcsncpy 
    • strcat, wcscat, strncat, wcsncat
    • sprintf, swprintf, _snprintf, _snwprintf 
    • vsprintf, vswprintf, vsnprintf, _vsnwprintf
    • strlen, wcslen
  • 안전한 유니코드 함수(UNICODE) 

    • RtlStringCbCopyW, RtlStringCchCopyW 
    • RtlStringCbCatW, RtlStringCchCatW 
    • RtlStringCbPrintfW, RtlStringCchPrintfW 
    • RtlStringCbVPrintfW, RtlStringCchVPrintW 
    • RtlStringCbLengthW, RtlStringCchLengthW 
  • 안전한 ANSI 함수 

    • RtlStringCbCopyA, RtlStringCchCopyA 
    • RtlStringCbCatA, RtlStringCchCatA 
    • RtlStringCbPrintfA, RtlStringCchPrintfA 
    • RtlStringCbVPrintfA, RtlStringCchVPrintfA 
    • RtlStringCbLengthA, RtlStringCchLengthA 

 

 

 

이 글은 스프링노트에서 작성되었습니다.

'Windows System Application' 카테고리의 다른 글

01 Virtual Desktop  (8) 2007.11.15
00 KKAMALENDAR(KKAMAGUI Calendar)  (11) 2007.11.15
10 WinDbg 간단 사용법  (0) 2007.11.14
02 Device Driver Code  (0) 2007.11.14
04 PE 파일 분석-Relocation 분석  (4) 2007.11.14

+ Recent posts