DevHelp PhysToGDTSel: Difference between revisions
Appearance
Created page with "This service maps a given GDT selector to a specified physical address, setting the access byte of the descriptor to the desired privilege value. The specified segment size mu..." |
m →C |
||
Line 50: | Line 50: | ||
==Parameters== | ==Parameters== | ||
===C=== | ===C=== | ||
; PhysAddr (ULONG) | ;PhysAddr (ULONG): 32-bit physical address that the GDT selector is to be mapped to. | ||
;Count (ULONG): Count of bytes to be mapped, must be less than or equal to 64KB. | |||
; Count (ULONG) : Count of bytes to be mapped, must be less than or equal to 64KB. | ;Selector (SEL): GDT selector (allocated using AllocateGDTSelector) | ||
;Access (UCHAR): Descriptor's type and privilege level: | |||
; Selector (SEL) | ::GDTSEL_R3CODE - The selector is mapped as ring 3, readable code with 16-bit addressing/operand size (286 format). | ||
::GDTSEL_R3DATA - (binary 0001) The selector is mapped as ring 3 writable data. | |||
; Access (UCHAR) | ::GDTSEL_R2CODE - (binary 0011) The selector is mapped as ring 2, IOPL, readable code with 16-bit addressing/operand size. | ||
::GDTSEL_R2DATA - (binary 0100) The selector is mapped as ring 2, IOPL, writable data. | |||
::GDTSEL_R0CODE - (binary 0101) The selector is mapped as ring 0, readable code with 16-bit addressing/operand size. | |||
::GDTSEL_R0DATA - (binary 0110) The selector is mapped as ring 0, writable data. | |||
::GDTSEL_ADDR32 - (binary 10000000) The selector will be mapped as ring 3 readable code with 32-bit addressing/operand size. | |||
::GDTSEL_R2CODE/GDTSEL_ADDR32 - (binary 10000011) The selector will be mapped as ring 2, IOPL, readable code with 32-bit addressing/operand size. | |||
::GDTSEL_R0CODE/GDTSEL_ADDR32 - (binary 10000101) The selector will be mapped as ring 0 readable code with 32-bit addressing/operand size. | |||
:All other values are invalid. | |||
===Assembler=== | ===Assembler=== |
Revision as of 22:35, 3 November 2018
This service maps a given GDT selector to a specified physical address, setting the access byte of the descriptor to the desired privilege value. The specified segment size must be less than or equal to 64KB.
Syntax
C
USHORT APIENTRY DevHelp_PhysToGDTSel( ULONG PhysAddr, ULONG Count, SEL Selector, UCHAR Access)
Assembler
MOV EAX,PhysAddress ; 32-bit physical address that the ; GDT selector is to be mapped to MOV ECX,Size ; Size of segment mapped; ; must be less than or equal to 64KB ; (a 0 value will map a 64KB segment) MOV SI,Selector ; GDT selector (allocated using AllocateGDTSelector) MOV DH,Access ; Descriptor's type and privilege level ; = 0 The selector is mapped as Ring 3, readable code ; with 16-bit addressing/operand ; size (286 format). ; = 1 (binary 0001) The selector is mapped as Ring 3, ; writable data. ; = 3 (binary 0011) The selector is mapped as Ring 2, ; IOPL, readable code with 16-bit ; addressing/operand size. ; = 4 (binary 0100) The selector is mapped as Ring 2, ; IOPL, writable data. ; = 5 (binary 0101) The selector is mapped as Ring 0, ; readable code with 16-bit addressing/operand size. ; = 6 (binary 0110) The selector is mapped as Ring 0, ; writable data. ; = 128 (binary 10000000) The selector will be mapped ; as Ring 3, readable code with 32-bit ; addressing/operand size. ; = 131 (binary 10000011) The selector will be mapped ; as Ring 2, IOPL, readable code with 32-bit ; addressing/operand size. ; = 133 (binary 10000101) The selector will be mapped ; as Ring 0, readable code with 32-bit ; addressing/operand size. ; All other values are invalid. MOV DL,DevHlp_PhysToGDTSel CALL [Device_Help]
Parameters
C
- PhysAddr (ULONG)
- 32-bit physical address that the GDT selector is to be mapped to.
- Count (ULONG)
- Count of bytes to be mapped, must be less than or equal to 64KB.
- Selector (SEL)
- GDT selector (allocated using AllocateGDTSelector)
- Access (UCHAR)
- Descriptor's type and privilege level:
- GDTSEL_R3CODE - The selector is mapped as ring 3, readable code with 16-bit addressing/operand size (286 format).
- GDTSEL_R3DATA - (binary 0001) The selector is mapped as ring 3 writable data.
- GDTSEL_R2CODE - (binary 0011) The selector is mapped as ring 2, IOPL, readable code with 16-bit addressing/operand size.
- GDTSEL_R2DATA - (binary 0100) The selector is mapped as ring 2, IOPL, writable data.
- GDTSEL_R0CODE - (binary 0101) The selector is mapped as ring 0, readable code with 16-bit addressing/operand size.
- GDTSEL_R0DATA - (binary 0110) The selector is mapped as ring 0, writable data.
- GDTSEL_ADDR32 - (binary 10000000) The selector will be mapped as ring 3 readable code with 32-bit addressing/operand size.
- GDTSEL_R2CODE/GDTSEL_ADDR32 - (binary 10000011) The selector will be mapped as ring 2, IOPL, readable code with 32-bit addressing/operand size.
- GDTSEL_R0CODE/GDTSEL_ADDR32 - (binary 10000101) The selector will be mapped as ring 0 readable code with 32-bit addressing/operand size.
- All other values are invalid.
Assembler
MOV EAX,PhysAddress ; 32-bit physical address that the ; GDT selector is to be mapped to MOV ECX,Size ; Size of segment mapped; ; must be less than or equal to 64KB ; (a 0 value will map a 64KB segment) MOV SI,Selector ; GDT selector (allocated using AllocateGDTSelector) MOV DH,Access ; Descriptor's type and privilege level ; = 0 The selector is mapped as Ring 3, readable code ; with 16-bit addressing/operand ; size (286 format). ; = 1 (binary 0001) The selector is mapped as Ring 3, ; writable data. ; = 3 (binary 0011) The selector is mapped as Ring 2, ; IOPL, readable code with 16-bit ; addressing/operand size. ; = 4 (binary 0100) The selector is mapped as Ring 2, ; IOPL, writable data. ; = 5 (binary 0101) The selector is mapped as Ring 0, ; readable code with 16-bit addressing/operand size. ; = 6 (binary 0110) The selector is mapped as Ring 0, ; writable data. ; = 128 (binary 10000000) The selector will be mapped ; as Ring 3, readable code with 32-bit ; addressing/operand size. ; = 131 (binary 10000011) The selector will be mapped ; as Ring 2, IOPL, readable code with 32-bit ; addressing/operand size. ; = 133 (binary 10000101) The selector will be mapped ; as Ring 0, readable code with 32-bit ; addressing/operand size. ; All other values are invalid.
Return Code
C
Success Indicator: 0 if pages locked, returns selector with modified
Request Privilege Level (RPL) bits.
Possible errors:
ERROR_INVALID_ADDRESS (487) ERROR_INVALID_SELECTOR (490) ERROR_INVALID_PARAMETER (87)
Assembler
'C' Clear if pages locked. SI = Selector with the modified RPL (Requested Privilege Level) bits. 'C' Set if segment unavailable. EAX = Error code. Possible errors: ERROR_INVALID_ADDRESS (487) ERROR_INVALID_SELECTOR (490) ERROR_INVALID_PARAMETER (87)
Remarks
The physical memory that is being mapped must be fixed or locked prior to the call to this service. After the call has been issued for a particular selector, the addressability remains valid until the physical device driver changes its content with a subsequent call to the DevHlp services PhysToGDTSel, PhysToGDTSelector, PageListToGDTSelector, or LinToGDTSelector.
Example Code
C
#include "dhcalls.h" USHORT APIENTRY DevHelp_PhysToGDTSel( ULONG PhysAddr, ULONG Count, SEL Selector, UCHAR Access)