Ignore:
Timestamp:
Feb 21, 2001, 8:44:15 AM (25 years ago)
Author:
bird
Message:

Added x86 functions for clearing and restoring the WP flag in CR0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/dev32/devfirst.asm

    r4164 r5220  
    1 ; $Id: devfirst.asm,v 1.6 2000-09-02 21:07:58 bird Exp $
     1; $Id: devfirst.asm,v 1.7 2001-02-21 07:44:15 bird Exp $
    22;
    33; DevFirst - entrypoint and segment definitions
     
    4141    public _SSToDS_16a
    4242    public GetOS2KrnlMTE
     43    public x86DisableWriteProtect
     44    public x86RestoreWriteProtect
    4345
    4446
     
    220222GetOS2KrnlMTE ENDP
    221223
     224
     225;;
     226; Disables the ring-0 write protection.
     227; It's used to help us write to readonly code segments and objects.
     228; @cproto   extern ULONG    _Optlink x86DisableWriteProtect(void);
     229; @return   Previous write protection flag setting.
     230; @uses     eax, edx
     231; @status   completely implemented.
     232; @author   knut st. osmundsen (knut.stange.osmundsen@mynd.no)
     233; @remark   Used by importTabInit.
     234x86DisableWriteProtect proc near
     235    cli
     236    mov     edx, cr0                    ; Get current cr0
     237    test    edx, 000010000h             ; Test for the WriteProtect flag (bit 16)
     238    setnz   al
     239    movzx   eax, al                     ; Old flag setting in eax (return value)
     240    and     edx, 0fffeffffh             ; Clear the 16th (WP) bit.
     241    mov     cr0, edx                    ;
     242    sti
     243    ret                                 ; return eax holds previous WP value.
     244x86DisableWriteProtect endp
     245
     246
     247;;
     248; Restore the WP flag of CR0 to it's previous state.
     249; The call is intent only to be called with the result from x86DisableWriteProtect,
     250; and will hence only enable the WP flag.
     251; @cproto   extern ULONG    _Optlink x86RestoreWriteProtect(ULONG flWP);
     252; @return   Previous write protection flag setting.
     253; @param    eax - flWP  Boolean value. (1 = WP was set, 0 WP was clear)
     254; @uses     eax
     255; @status   completely implemented.
     256; @author   knut st. osmundsen (knut.stange.osmundsen@mynd.no)
     257; @remark   Used by importTabInit.
     258x86RestoreWriteProtect proc near
     259    test    eax, eax                    ; Check if the flag was previously clear
     260    jnz     x86RWP_set                  ; If set Then Set it back.
     261    jmp     x86RWP_end                  ; If clear Then nothing to do.
     262x86RWP_set:
     263    cli
     264    mov     eax, cr0                    ; Get current cr0.
     265    or      eax, 000010000h             ; The the 16-bit (WP) bit.
     266    mov     cr0, eax                    ; Update cr0.
     267    sti
     268
     269x86RWP_end:
     270    ret
     271x86RestoreWriteProtect endp
     272
     273
    222274CODE32 ends
    223275
Note: See TracChangeset for help on using the changeset viewer.