02 Device Driver Code
원문 : http://kkamagui.springnote.com/pages/570024
들어가기 전에...
1.CR0 Write Protect Managment Code
- //
// 콘트롤 레지스터 관련 (IA-32 manual vol3, ch 2.5
// CR0 (Control Register Zero) 레지스터의 WP 비트(16)는 쓰기 속성제어에 사용됨
//
#define CR0_WP_MASK 0x0FFFEFFFF
-
- /**
Write Protect를 제거
*/
VOID ClearWriteProtect(VOID)
{
__asm
{
push eax;
mov eax, cr0;
and eax, CR0_WP_MASK; // WP 클리어
mov cr0, eax;
pop eax;
}
}
- /**
Write Protect를 설정
*/
VOID SetWriteProtect(VOID)
{
__asm
{
push eax;
mov eax, cr0;
or eax, not CR0_WP_MASK; // WP 비트 세팅
mov cr0, eax;
pop eax;
}
}