오랜만에 코드 관련 포스팅입니다.
종종
오늘은 특정 메모리 영역의 포인터에 접근하고자 할때 안전하게 사용하는 몇 가지 Win32 API를 소개하려 합니다.
매우 기초지식이지만, 자주 사용하는 놈이 아니다 보니 벌써 잊었네요.
(1) IsBadCodePtr
Determines whether the calling process has read access to the memory at the specified address.
현재의 프로세스가 특정 주소가 가리키는 영역을 읽을 수 있는지 여부를 확인합니다.
(2) IsBadReadPtr
Verifies that the calling process has read access to the specified range of memory.
현재의 프로세스가 특정 주소가 가리키는 영역을 읽을 수 있는지 여부를 확인합니다. (영역 지정 가능)
(3) IsBadStringPtr
Verifies that the calling process has read access to the specified range of memory.
현재의 프로세스가 특정 주소가 가리키는 영역을 문자열로 읽을 수 있는지 여부를 확인하며, 시작 포인터로부터 null을 만날 때까지 유효성을 확인합니다.
(4) IsBadWritePtr
Verifies that the calling process has write access to the specified range of memory.
현재의 프로세스가 특정 주소가 가리키는 영역에 쓸 수 있는지 여부를 확인합니다.
Important This function is obsolete and should not be used. Despite its name, it does not guarantee that the pointer is valid or that the memory pointed to is safe to use. For more information, see Remarks on this page.
물론 빠른 성능을 고려해야 하는 시스템에 도입은 힘들겠지만, 활발한 입/출력의 포인터 제어시에 유용하겠네요.
오늘 기초지식이 없어 고생 좀 했습니다 :D
그리고 추가 팁! 메모리 Leak을 체크하는 방법이 MSDN에 있네요! 다들 아시겠지만요 ㅠ
http://msdn.microsoft.com/en-us/library/x98tx3cf(VS.71).aspx
이올린에 북마크하기
이올린에 추천하기