ReactOS  0.4.13-dev-563-g0561610
blue.h File Reference
#include <wdm.h>
#include <blue/ntddblue.h>
#include <ndk/inbvfuncs.h>
Include dependency graph for blue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagCOORD
 
struct  tagSMALL_RECT
 
struct  tagCONSOLE_SCREEN_BUFFER_INFO
 
struct  tagCONSOLE_CURSOR_INFO
 
struct  _CFHEADER
 
struct  _CFFILE
 

Macros

#define ENABLE_PROCESSED_OUTPUT   0x0001
 
#define ENABLE_WRAP_AT_EOL_OUTPUT   0x0002
 
#define TAG_BLUE   'EULB'
 
#define CAB_SIGNATURE   0x4643534D
 
#define VIDMEM_BASE   0xb8000
 
#define BITPLANE_BASE   0xa0000
 
#define CRTC_COMMAND   ((PUCHAR)0x3d4)
 
#define CRTC_DATA   ((PUCHAR)0x3d5)
 
#define CRTC_COLUMNS   0x01
 
#define CRTC_OVERFLOW   0x07
 
#define CRTC_ROWS   0x12
 
#define CRTC_SCANLINES   0x09
 
#define CRTC_CURSORSTART   0x0a
 
#define CRTC_CURSOREND   0x0b
 
#define CRTC_CURSORPOSHI   0x0e
 
#define CRTC_CURSORPOSLO   0x0f
 
#define SEQ_COMMAND   ((PUCHAR)0x3c4)
 
#define SEQ_DATA   ((PUCHAR)0x3c5)
 
#define GCT_COMMAND   ((PUCHAR)0x3ce)
 
#define GCT_DATA   ((PUCHAR)0x3cf)
 
#define SEQ_RESET   0x00
 
#define SEQ_ENABLE_WRT_PLANE   0x02
 
#define SEQ_MEM_MODE   0x04
 
#define GCT_READ_PLANE   0x04
 
#define GCT_RW_MODES   0x05
 
#define GCT_GRAPH_MODE   0x06
 
#define ATTRC_WRITEREG   ((PUCHAR)0x3c0)
 
#define ATTRC_READREG   ((PUCHAR)0x3c1)
 
#define ATTRC_INPST1   ((PUCHAR)0x3da)
 
#define TAB_WIDTH   8
 
#define MAX_PATH   260
 
#define MISC   (PUCHAR)0x3c2
 
#define SEQ   (PUCHAR)0x3c4
 
#define SEQDATA   (PUCHAR)0x3c5
 
#define CRTC   (PUCHAR)0x3d4
 
#define CRTCDATA   (PUCHAR)0x3d5
 
#define GRAPHICS   (PUCHAR)0x3ce
 
#define GRAPHICSDATA   (PUCHAR)0x3cf
 
#define ATTRIB   (PUCHAR)0x3c0
 
#define STATUS   (PUCHAR)0x3da
 
#define PELMASK   (PUCHAR)0x3c6
 
#define PELINDEX   (PUCHAR)0x3c8
 
#define PELDATA   (PUCHAR)0x3c9
 

Typedefs

typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
 
typedef struct _SECURITY_ATTRIBUTESPSECURITY_ATTRIBUTES
 
typedef struct tagCOORD COORD
 
typedef struct tagCOORDPCOORD
 
typedef struct tagSMALL_RECT SMALL_RECT
 
typedef struct tagCONSOLE_SCREEN_BUFFER_INFO CONSOLE_SCREEN_BUFFER_INFO
 
typedef struct tagCONSOLE_SCREEN_BUFFER_INFOPCONSOLE_SCREEN_BUFFER_INFO
 
typedef struct tagCONSOLE_CURSOR_INFO CONSOLE_CURSOR_INFO
 
typedef struct tagCONSOLE_CURSOR_INFOPCONSOLE_CURSOR_INFO
 
typedef struct _CFHEADER CFHEADER
 
typedef struct _CFHEADERPCFHEADER
 
typedef struct _CFFILE CFFILE
 
typedef struct _CFFILEPCFFILE
 

Functions

void ScrLoadFontTable (UINT32 CodePage)
 
NTSTATUS ExtractFont (UINT32 CodePage, PUCHAR FontBitField)
 

Macro Definition Documentation

◆ ATTRC_INPST1

#define ATTRC_INPST1   ((PUCHAR)0x3da)

Definition at line 114 of file blue.h.

◆ ATTRC_READREG

#define ATTRC_READREG   ((PUCHAR)0x3c1)

Definition at line 113 of file blue.h.

◆ ATTRC_WRITEREG

#define ATTRC_WRITEREG   ((PUCHAR)0x3c0)

Definition at line 112 of file blue.h.

◆ ATTRIB

#define ATTRIB   (PUCHAR)0x3c0

Definition at line 127 of file blue.h.

◆ BITPLANE_BASE

#define BITPLANE_BASE   0xa0000

Definition at line 82 of file blue.h.

◆ CAB_SIGNATURE

#define CAB_SIGNATURE   0x4643534D

Definition at line 79 of file blue.h.

◆ CRTC

#define CRTC   (PUCHAR)0x3d4

Definition at line 123 of file blue.h.

◆ CRTC_COLUMNS

#define CRTC_COLUMNS   0x01

Definition at line 87 of file blue.h.

◆ CRTC_COMMAND

#define CRTC_COMMAND   ((PUCHAR)0x3d4)

Definition at line 84 of file blue.h.

◆ CRTC_CURSOREND

#define CRTC_CURSOREND   0x0b

Definition at line 92 of file blue.h.

◆ CRTC_CURSORPOSHI

#define CRTC_CURSORPOSHI   0x0e

Definition at line 93 of file blue.h.

◆ CRTC_CURSORPOSLO

#define CRTC_CURSORPOSLO   0x0f

Definition at line 94 of file blue.h.

◆ CRTC_CURSORSTART

#define CRTC_CURSORSTART   0x0a

Definition at line 91 of file blue.h.

◆ CRTC_DATA

#define CRTC_DATA   ((PUCHAR)0x3d5)

Definition at line 85 of file blue.h.

◆ CRTC_OVERFLOW

#define CRTC_OVERFLOW   0x07

Definition at line 88 of file blue.h.

◆ CRTC_ROWS

#define CRTC_ROWS   0x12

Definition at line 89 of file blue.h.

◆ CRTC_SCANLINES

#define CRTC_SCANLINES   0x09

Definition at line 90 of file blue.h.

◆ CRTCDATA

#define CRTCDATA   (PUCHAR)0x3d5

Definition at line 124 of file blue.h.

◆ ENABLE_PROCESSED_OUTPUT

#define ENABLE_PROCESSED_OUTPUT   0x0001

Definition at line 44 of file blue.h.

◆ ENABLE_WRAP_AT_EOL_OUTPUT

#define ENABLE_WRAP_AT_EOL_OUTPUT   0x0002

Definition at line 45 of file blue.h.

◆ GCT_COMMAND

#define GCT_COMMAND   ((PUCHAR)0x3ce)

Definition at line 99 of file blue.h.

◆ GCT_DATA

#define GCT_DATA   ((PUCHAR)0x3cf)

Definition at line 100 of file blue.h.

◆ GCT_GRAPH_MODE

#define GCT_GRAPH_MODE   0x06

Definition at line 110 of file blue.h.

◆ GCT_READ_PLANE

#define GCT_READ_PLANE   0x04

Definition at line 108 of file blue.h.

◆ GCT_RW_MODES

#define GCT_RW_MODES   0x05

Definition at line 109 of file blue.h.

◆ GRAPHICS

#define GRAPHICS   (PUCHAR)0x3ce

Definition at line 125 of file blue.h.

◆ GRAPHICSDATA

#define GRAPHICSDATA   (PUCHAR)0x3cf

Definition at line 126 of file blue.h.

◆ MAX_PATH

#define MAX_PATH   260

Definition at line 118 of file blue.h.

◆ MISC

#define MISC   (PUCHAR)0x3c2

Definition at line 120 of file blue.h.

◆ PELDATA

#define PELDATA   (PUCHAR)0x3c9

Definition at line 131 of file blue.h.

◆ PELINDEX

#define PELINDEX   (PUCHAR)0x3c8

Definition at line 130 of file blue.h.

◆ PELMASK

#define PELMASK   (PUCHAR)0x3c6

Definition at line 129 of file blue.h.

◆ SEQ

#define SEQ   (PUCHAR)0x3c4

Definition at line 121 of file blue.h.

◆ SEQ_COMMAND

#define SEQ_COMMAND   ((PUCHAR)0x3c4)

Definition at line 96 of file blue.h.

◆ SEQ_DATA

#define SEQ_DATA   ((PUCHAR)0x3c5)

Definition at line 97 of file blue.h.

◆ SEQ_ENABLE_WRT_PLANE

#define SEQ_ENABLE_WRT_PLANE   0x02

Definition at line 104 of file blue.h.

◆ SEQ_MEM_MODE

#define SEQ_MEM_MODE   0x04

Definition at line 105 of file blue.h.

◆ SEQ_RESET

#define SEQ_RESET   0x00

Definition at line 103 of file blue.h.

◆ SEQDATA

#define SEQDATA   (PUCHAR)0x3c5

Definition at line 122 of file blue.h.

◆ STATUS

#define STATUS   (PUCHAR)0x3da

Definition at line 128 of file blue.h.

◆ TAB_WIDTH

#define TAB_WIDTH   8

Definition at line 116 of file blue.h.

◆ TAG_BLUE

#define TAG_BLUE   'EULB'

Definition at line 50 of file blue.h.

◆ VIDMEM_BASE

#define VIDMEM_BASE   0xb8000

Definition at line 81 of file blue.h.

Typedef Documentation

◆ CFFILE

◆ CFHEADER

◆ CONSOLE_CURSOR_INFO

◆ CONSOLE_SCREEN_BUFFER_INFO

◆ COORD

◆ PCFFILE

typedef struct _CFFILE * PCFFILE

◆ PCFHEADER

◆ PCONSOLE_CURSOR_INFO

◆ PCONSOLE_SCREEN_BUFFER_INFO

◆ PCOORD

typedef struct tagCOORD * PCOORD

◆ PSECURITY_ATTRIBUTES

Definition at line 14 of file blue.h.

◆ SECURITY_ATTRIBUTES

Definition at line 14 of file blue.h.

◆ SMALL_RECT

Function Documentation

◆ ExtractFont()

NTSTATUS ExtractFont ( UINT32  CodePage,
PUCHAR  FontBitField 
)

Definition at line 69 of file font.c.

72 {
73  BOOLEAN bFoundFile = FALSE;
74  HANDLE Handle;
76  CHAR FileName[20];
79  UNICODE_STRING LinkName;
81  CFHEADER CabFileHeader;
82  CFFILE CabFile;
83  ULONG CabFileOffset = 0;
85  WCHAR SourceBuffer[MAX_PATH] = { L'\0' };
86  ULONG ReadCP;
87 
90 
91  RtlInitUnicodeString(&LinkName,
92  L"\\SystemRoot");
93 
95  &LinkName,
97  NULL,
98  NULL);
99 
103 
104  if (!NT_SUCCESS(Status))
105  {
106  DPRINT1("ZwOpenSymbolicLinkObject failed with Status 0x%lx\n", Status);
107  return Status;
108  }
109 
110  SourceName.Length = 0;
111  SourceName.MaximumLength = MAX_PATH * sizeof(WCHAR);
112  SourceName.Buffer = SourceBuffer;
113 
114  Status = ZwQuerySymbolicLinkObject(Handle,
115  &SourceName,
116  NULL);
117  ZwClose(Handle);
118 
119  if (!NT_SUCCESS(Status))
120  {
121  DPRINT1("ZwQuerySymbolicLinkObject failed with Status 0x%lx\n", Status);
122  return Status;
123  }
124 
125  Status = RtlAppendUnicodeToString(&SourceName, L"\\vgafonts.cab");
126  if (!NT_SUCCESS(Status))
127  {
128  DPRINT1("RtlAppendUnicodeToString failed with Status 0x%lx\n", Status);
129  return Status;
130  }
131 
133  &SourceName,
135  NULL,
136  NULL);
137 
138  Status = ZwCreateFile(&Handle,
139  GENERIC_READ,
141  &IoStatusBlock,
142  NULL,
144  0,
145  FILE_OPEN,
147  NULL,
148  0);
149  if (!NT_SUCCESS(Status))
150  {
151  DPRINT1("Error: Cannot open vgafonts.cab (0x%lx)\n", Status);
152  return Status;
153  }
154 
155  ByteOffset.QuadPart = 0;
156  Status = ZwReadFile(Handle,
157  NULL,
158  NULL,
159  NULL,
160  &IoStatusBlock,
161  &CabFileHeader,
162  sizeof(CabFileHeader),
163  &ByteOffset,
164  NULL);
165 
166  if (!NT_SUCCESS(Status))
167  {
168  DPRINT1("Error: Cannot read from file (0x%lx)\n", Status);
169  goto Exit;
170  }
171 
172  if (CabFileHeader.Signature != CAB_SIGNATURE)
173  {
174  DPRINT1("Invalid CAB signature: 0x%lx!\n", CabFileHeader.Signature);
176  goto Exit;
177  }
178 
179  // We have a valid CAB file!
180  // Read the file table now and decrement the file count on every file. When it's zero, we read the complete table.
181  ByteOffset.QuadPart = CabFileHeader.FileTableOffset;
182 
183  while (CabFileHeader.FileCount)
184  {
185  Status = ZwReadFile(Handle,
186  NULL,
187  NULL,
188  NULL,
189  &IoStatusBlock,
190  &CabFile,
191  sizeof(CabFile),
192  &ByteOffset,
193  NULL);
194 
195  if (NT_SUCCESS(Status))
196  {
197  ByteOffset.QuadPart += sizeof(CabFile);
198 
199  // We assume here that the file name is max. 19 characters (+ 1 NULL character) long.
200  // This should be enough for our purpose.
201  Status = ZwReadFile(Handle,
202  NULL,
203  NULL,
204  NULL,
205  &IoStatusBlock,
206  FileName,
207  sizeof(FileName),
208  &ByteOffset,
209  NULL);
210 
211  if (NT_SUCCESS(Status))
212  {
213  if (!bFoundFile)
214  {
215  Status = RtlCharToInteger(FileName, 0, &ReadCP);
216  if (NT_SUCCESS(Status) && ReadCP == CodePage)
217  {
218  // We got the correct file.
219  // Save the offset and loop through the rest of the file table to find the position, where the actual data starts.
220  CabFileOffset = CabFile.FileOffset;
221  bFoundFile = TRUE;
222  }
223  }
224 
225  ByteOffset.QuadPart += strlen(FileName) + 1;
226  }
227  }
228 
229  CabFileHeader.FileCount--;
230  }
231 
232  // 8 = Size of a CFFOLDER structure (see cabman). As we don't need the values of that structure, just increase the offset here.
233  ByteOffset.QuadPart += 8;
234  ByteOffset.QuadPart += CabFileOffset;
235 
236  // ByteOffset now contains the offset of the actual data, so we can read the RAW font
237  Status = ZwReadFile(Handle,
238  NULL,
239  NULL,
240  NULL,
241  &IoStatusBlock,
242  FontBitField,
243  2048,
244  &ByteOffset,
245  NULL);
246  if (!NT_SUCCESS(Status))
247  {
248  DPRINT1("ZwReadFile failed with Status 0x%lx\n", Status);
249  }
250 
251 Exit:
252 
253  ZwClose(Handle);
254  return Status;
255 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSYSAPI NTSTATUS NTAPI RtlCharToInteger(PCSZ String, ULONG Base, PULONG Value)
Definition: unicode.c:261
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define SYMBOLIC_LINK_ALL_ACCESS
Definition: nt_native.h:1267
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
_In_ HANDLE Handle
Definition: extypes.h:390
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static void Exit(void)
Definition: sock.c:1331
#define MAX_PATH
Definition: compat.h:26
Definition: fci.c:89
#define CAB_SIGNATURE
Definition: cabinet.c:47
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:124
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
WCHAR SourceName[256]
Definition: arping.c:28
Definition: fci.c:65
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
NTSYSAPI NTSTATUS NTAPI ZwOpenSymbolicLinkObject(_Out_ PHANDLE SymbolicLinkHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:716

Referenced by ScrLoadFontTable().

◆ ScrLoadFontTable()

void ScrLoadFontTable ( UINT32  CodePage)

Definition at line 27 of file font.c.

29 {
31  PUCHAR Bitplane;
32  PUCHAR FontBitfield = NULL;
34 
35  FontBitfield = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, 2048, TAG_BLUE);
36  if (FontBitfield == NULL)
37  {
38  DPRINT1("ExAllocatePoolWithTag failed\n");
39  return;
40  }
41 
42  /* open bit plane for font table access */
43  OpenBitPlane();
44 
45  /* get pointer to video memory */
46  BaseAddress.QuadPart = BITPLANE_BASE;
47  Bitplane = (PUCHAR)MmMapIoSpace(BaseAddress, 0xFFFF, MmNonCached);
48 
49  Status = ExtractFont(CodePage, FontBitfield);
50  if (NT_SUCCESS(Status))
51  {
52  LoadFont(Bitplane, FontBitfield);
53  }
54  else
55  {
56  DPRINT1("ExtractFont failed with Status 0x%lx\n", Status);
57  }
58 
59  MmUnmapIoSpace(Bitplane, 0xFFFF);
60  ExFreePool(FontBitfield);
61 
62  /* close bit plane */
63  CloseBitPlane();
64 }
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS ExtractFont(UINT32 CodePage, PUCHAR FontBitField)
Definition: font.c:69
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
VOID LoadFont(PUCHAR Bitplane, PUCHAR FontBitfield)
Definition: font.c:301
smooth NULL
Definition: ftsmooth.c:416
#define TAG_BLUE
Definition: blue.h:50
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define BITPLANE_BASE
Definition: blue.h:82
Status
Definition: gdiplustypes.h:24
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
VOID OpenBitPlane()
#define DPRINT1
Definition: precomp.h:8
VOID CloseBitPlane()
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by ScrAcquireOwnership(), and ScrIoControl().