ReactOS 0.4.17-dev-1190-g4c812f4
font.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for font.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define MAX_TEXT_BUFFER   0x2710000
 

Functions

HFONT APIENTRY HfontCreate (_In_ const ENUMLOGFONTEXDVW *pelfw, _In_ ULONG cjElfw, _In_ LFTYPE lft, _In_ FLONG fl, _In_opt_ PVOID pvCliData)
 
HFONT FASTCALL GreCreateFontIndirectW (_In_ const LOGFONTW *lplf)
 
DWORD FASTCALL GreGetKerningPairs (_In_ HDC hDC, _In_ ULONG NumPairs, _Out_writes_(NumPairs) LPKERNINGPAIR krnpair)
 
ULONG FASTCALL FontGetObject (_Inout_ PTEXTOBJ plfont, _In_ ULONG cjBuffer, _Out_ PVOID pvBuffer)
 
DWORD FASTCALL IntGetCharDimensions (_In_ HDC hdc, _Out_opt_ PTEXTMETRICW ptm, _Out_opt_ PDWORD height)
 
DWORD FASTCALL IntGetFontLanguageInfo (_In_ PDC Dc)
 
PTEXTOBJ FASTCALL RealizeFontInit (_In_ HFONT hFont)
 
static BOOL IntCheckFontPathNames (_In_reads_(cwc) PCWCH pwcFiles, _In_ ULONG cFiles, _In_ ULONG cwc)
 
INT APIENTRY NtGdiAddFontResourceW (_In_reads_(cwc) PCWCH pwcFiles, _In_ ULONG cwc, _In_ ULONG cFiles, _In_ FLONG fl, _In_ DWORD dwPidTid, _In_opt_ const DESIGNVECTOR *pdv)
 
BOOL APIENTRY NtGdiRemoveFontResourceW (_In_reads_(cwc) PCWCH pwszFiles, _In_ ULONG cwc, _In_ ULONG cFiles, _In_ ULONG fl, _In_ DWORD dwPidTid, _In_opt_ const DESIGNVECTOR *pdv)
 
HANDLE APIENTRY NtGdiAddFontMemResourceEx (_In_reads_bytes_(cjBuffer) const VOID *pvBuffer, _In_ DWORD cjBuffer, _In_reads_bytes_opt_(cjDV) const DESIGNVECTOR *pdv, _In_ ULONG cjDV, _Out_ PDWORD pNumFonts)
 
BOOL APIENTRY NtGdiRemoveFontMemResourceEx (_In_ HANDLE hMMFont)
 
DWORD APIENTRY NtGdiGetCharacterPlacementW (_In_ HDC hdc, _In_reads_(nCount) PCWCH pwsz, _In_ INT nCount, _In_ INT nMaxExtent, _Inout_opt_ LPGCP_RESULTSW pgcpw, _In_ DWORD dwFlags)
 
DWORD APIENTRY NtGdiGetFontData (_In_ HDC hDC, _In_ DWORD Table, _In_ DWORD Offset, _Out_writes_bytes_(Size) PVOID Buffer, _In_ DWORD Size)
 
DWORD APIENTRY NtGdiGetFontUnicodeRanges (_In_ HDC hdc, _Out_opt_ LPGLYPHSET pgs)
 
ULONG APIENTRY NtGdiGetGlyphOutline (_In_ HDC hdc, _In_ WCHAR wch, _In_ UINT iFormat, _Out_ LPGLYPHMETRICS pgm, _In_ ULONG cjBuf, _Out_writes_bytes_opt_(cjBuf) PVOID UnsafeBuf, _In_opt_ const MAT2 *pmat2, _In_ BOOL bIgnoreRotation)
 
DWORD APIENTRY NtGdiGetKerningPairs (_In_ HDC hDC, _In_ ULONG NumPairs, _Out_writes_(NumPairs) LPKERNINGPAIR krnpair)
 
ULONG APIENTRY NtGdiGetOutlineTextMetricsInternalW (_In_ HDC hDC, _In_ ULONG Data, _Out_opt_ POUTLINETEXTMETRICW otm, _In_ PTMDIFF Tmd)
 
W32KAPI BOOL APIENTRY NtGdiGetFontResourceInfoInternalW (_In_reads_(cwc) PCWCH pwszFiles, _In_ ULONG cwc, _In_ ULONG cFiles, _In_ UINT cjIn, _Inout_ PDWORD pdwBytes, _Out_writes_bytes_(*pdwBytes) PVOID pvBuf, _In_ DWORD dwType)
 
BOOL APIENTRY NtGdiGetRealizationInfo (_In_ HDC hdc, _Out_ PREALIZATION_INFO pri, _In_ HFONT hf)
 
DWORD APIENTRY NtGdiGetFontFileData (_In_ UINT uFileCollectionID, _In_ UINT uFileIndex, _In_ PULONGLONG pullFileOffset, _Out_writes_bytes_(cjBuf) PVOID pvBuf, _In_ SIZE_T cjBuf)
 
DWORD APIENTRY NtGdiGetFontFileInfo (_In_ UINT uFileCollectionID, _In_ UINT uFileIndex, _Out_writes_bytes_(cjSize) PFONT_FILE_INFO pffi, _In_ SIZE_T cjSize, _Out_opt_ PSIZE_T pcjActualSize)
 
BOOL APIENTRY NtGdiGetFontRealizationInfo (_In_ HDC hdc, _Out_ FONT_REALIZATION_INFO *info)
 
HFONT APIENTRY HfontCreate (const ENUMLOGFONTEXDVW *pelfw, _In_ ULONG cjElfw, _In_ LFTYPE lft, _In_ FLONG fl, _In_opt_ PVOID pvCliData)
 
HFONT APIENTRY NtGdiHfontCreate (_In_reads_bytes_(cjElfw) const ENUMLOGFONTEXDVW *pelfw, _In_ ULONG cjElfw, _In_ LFTYPE lft, _In_ FLONG fl, _In_opt_ PVOID pvCliData)
 
BOOL NTAPI NtGdiGetCharWidthW (_In_ HDC hDC, _In_ UINT FirstChar, _In_ UINT Count, _In_reads_opt_(Count) PCWCH UnSafepwc, _In_ FLONG fl, _Out_writes_bytes_(Count *sizeof(INT)) PVOID Buffer)
 
BOOL NTAPI NtGdiGetCharABCWidthsW (_In_ HDC hDC, _In_ UINT FirstChar, _In_ UINT Count, _In_reads_opt_(Count) PCWCH UnSafepwch, _In_ FLONG fl, _Out_writes_bytes_(Count *sizeof(ABC)) PVOID Buffer)
 
__kernel_entry W32KAPI DWORD APIENTRY NtGdiGetGlyphIndicesW (_In_ HDC hdc, _In_reads_opt_(cwc) PCWCH pwc, _In_ INT cwc, _Out_writes_opt_(cwc) PWORD pgi, _In_ DWORD iMode)
 
__kernel_entry W32KAPI DWORD APIENTRY NtGdiGetGlyphIndicesWInternal (_In_ HDC hdc, _In_reads_opt_(cwc) PCWCH pwc, _In_ INT cwc, _Out_writes_opt_(cwc) PWORD pgi, _In_ DWORD iMode, _In_ BOOL bSubset)
 

Macro Definition Documentation

◆ MAX_TEXT_BUFFER

#define MAX_TEXT_BUFFER   0x2710000

Definition at line 17 of file font.c.

◆ NDEBUG

#define NDEBUG

Includes

Definition at line 14 of file font.c.

Function Documentation

◆ FontGetObject()

ULONG FASTCALL FontGetObject ( _Inout_ PTEXTOBJ  plfont,
_In_ ULONG  cjBuffer,
_Out_ PVOID  pvBuffer 
)

Definition at line 298 of file font.c.

302{
303 ULONG cjMaxSize;
304 ENUMLOGFONTEXDVW *plf;
305
306 ASSERT(plfont);
307 plf = &plfont->logfont;
308
309 if (!(plfont->fl & TEXTOBJECT_INIT))
310 {
312 DPRINT("FontGetObject font not initialized!\n");
313
314 Status = TextIntRealizeFont(plfont->BaseObject.hHmgr, plfont);
315 if (!NT_SUCCESS(Status))
316 {
317 DPRINT1("FontGetObject(TextIntRealizeFont) Status = 0x%lx\n", Status);
318 }
319 }
320
321 /* If buffer is NULL, only the size is requested */
322 if (pvBuffer == NULL) return sizeof(LOGFONTW);
323
324 /* Calculate the maximum size according to number of axes */
325 cjMaxSize = FIELD_OFFSET(ENUMLOGFONTEXDVW,
326 elfDesignVector.dvValues[plf->elfDesignVector.dvNumAxes]);
327
328 if (cjBuffer > cjMaxSize) cjBuffer = cjMaxSize;
329
330 RtlCopyMemory(pvBuffer, plf, cjBuffer);
331
332 return cjBuffer;
333}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
_In_ ULONG cjBuffer
Definition: ntgdi.h:2888
#define DPRINT
Definition: sndvol32.h:73
DWORD dvNumAxes
Definition: wingdi.h:3215
DESIGNVECTOR elfDesignVector
Definition: wingdi.h:3226
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj)
Definition: freetype.c:5990
#define TEXTOBJECT_INIT
Definition: text.h:56

Referenced by GreGetObject().

◆ GreCreateFontIndirectW()

HFONT FASTCALL GreCreateFontIndirectW ( _In_ const LOGFONTW *  lplf)

Internal

Definition at line 30 of file font.c.

31{
32 if (lplf)
33 {
34 ENUMLOGFONTEXDVW Logfont;
35
36 RtlCopyMemory( &Logfont.elfEnumLogfontEx.elfLogFont, lplf, sizeof(LOGFONTW));
38 sizeof(Logfont.elfEnumLogfontEx.elfFullName));
40 sizeof(Logfont.elfEnumLogfontEx.elfStyle));
42 sizeof(Logfont.elfEnumLogfontEx.elfScript));
43
44 Logfont.elfDesignVector.dvNumAxes = 0;
45
46 RtlZeroMemory( &Logfont.elfDesignVector, sizeof(DESIGNVECTOR));
47
48 return HfontCreate(&Logfont, 0, 0, 0, NULL);
49 }
50 else return NULL;
51}
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:3225
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:3150
LOGFONTW elfLogFont
Definition: wingdi.h:3148
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:3149
WCHAR elfScript[LF_FACESIZE]
Definition: wingdi.h:3151
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
HFONT APIENTRY HfontCreate(_In_ const ENUMLOGFONTEXDVW *pelfw, _In_ ULONG cjElfw, _In_ LFTYPE lft, _In_ FLONG fl, _In_opt_ PVOID pvCliData)

Referenced by IntPaintDesktop(), MENU_DrawPopupGlyph(), MenuInit(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), UITOOLS95_DrawFrameMenu(), and UITOOLS95_DrawFrameScroll().

◆ GreGetKerningPairs()

DWORD FASTCALL GreGetKerningPairs ( _In_ HDC  hDC,
_In_ ULONG  NumPairs,
_Out_writes_(NumPairs) LPKERNINGPAIR  krnpair 
)

Definition at line 55 of file font.c.

59{
60 PDC dc;
61 PDC_ATTR pdcattr;
62 PTEXTOBJ TextObj;
63 PFONTGDI FontGDI;
65 KERNINGPAIR *pKP;
66
67 dc = DC_LockDc(hDC);
68 if (!dc)
69 {
71 return 0;
72 }
73
74 pdcattr = dc->pdcattr;
75 TextObj = RealizeFontInit(pdcattr->hlfntNew);
77
78 if (!TextObj)
79 {
81 return 0;
82 }
83
84 FontGDI = ObjToGDI(TextObj->Font, FONT);
85 TEXTOBJ_UnlockText(TextObj);
86
87 Count = ftGdiGetKerningPairs(FontGDI,0,NULL);
88
89 if ( Count && krnpair )
90 {
91 if (Count > NumPairs)
92 {
94 return 0;
95 }
97 if (!pKP)
98 {
100 return 0;
101 }
102 ftGdiGetKerningPairs(FontGDI,Count,pKP);
103
104 RtlCopyMemory(krnpair, pKP, Count * sizeof(KERNINGPAIR));
105
107 }
108 return Count;
109}
static HDC hDC
Definition: 3dtext.c:33
HDC dc
Definition: cylfrac.c:34
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:184
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
int Count
Definition: noreturn.cpp:7
Definition: polytest.cpp:41
HANDLE hlfntNew
Definition: ntgdihdl.h:330
Definition: text.h:60
FONTOBJ * Font
Definition: text.h:66
PTEXTOBJ FASTCALL RealizeFontInit(_In_ HFONT hFont)
Definition: font.c:433
DWORD FASTCALL ftGdiGetKerningPairs(PFONTGDI Font, DWORD cPairs, LPKERNINGPAIR pKerningPair)
Definition: freetype.c:6391
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define GDITAG_TEXT
Definition: tags.h:172
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:21

◆ HfontCreate() [1/2]

HFONT APIENTRY HfontCreate ( _In_ const ENUMLOGFONTEXDVW *  pelfw,
_In_ ULONG  cjElfw,
_In_ LFTYPE  lft,
_In_ FLONG  fl,
_In_opt_ PVOID  pvCliData 
)

◆ HfontCreate() [2/2]

HFONT APIENTRY HfontCreate ( const ENUMLOGFONTEXDVW *  pelfw,
_In_ ULONG  cjElfw,
_In_ LFTYPE  lft,
_In_ FLONG  fl,
_In_opt_ PVOID  pvCliData 
)

Definition at line 1259 of file font.c.

1265{
1266 HFONT hNewFont;
1267 PLFONT plfont;
1268
1269 if (!pelfw)
1270 {
1271 return NULL;
1272 }
1273
1274 plfont = LFONT_AllocFontWithHandle();
1275 if (!plfont)
1276 {
1277 return NULL;
1278 }
1279 hNewFont = plfont->BaseObject.hHmgr;
1280
1281 plfont->lft = lft;
1282 plfont->fl = fl;
1283 RtlCopyMemory (&plfont->logfont, pelfw, sizeof(ENUMLOGFONTEXDVW));
1284 ExInitializePushLock(&plfont->lock);
1285
1288 {
1289 /* This should really depend on whether GM_ADVANCED is set */
1292 }
1293 LFONT_UnlockFont(plfont);
1294
1295 if (pvCliData && hNewFont)
1296 {
1297 // FIXME: Use GDIOBJ_InsertUserData
1299 {
1302 Entry->UserData = pvCliData;
1303 }
1305 }
1306
1307 return hNewFont;
1308}
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
#define ExInitializePushLock
Definition: ex.h:1016
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
Entry
Definition: section.c:5216
Definition: gdi.h:2
LFTYPE lft
Definition: text.h:64
BASEOBJECT BaseObject
Definition: text.h:63
FLONG fl
Definition: text.h:65
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
EX_PUSH_LOCK lock
Definition: text.h:71
LONG lfOrientation
Definition: dwrite.idl:1124
LONG lfEscapement
Definition: dwrite.idl:1123
int32_t INT
Definition: typedefs.h:58
_In_ WDFCOLLECTION _In_ ULONG Index
#define GdiHandleTable
Definition: win32nt.h:37
#define LFONT_UnlockFont(plfnt)
Definition: text.h:79
#define LFONT_AllocFontWithHandle()
Definition: text.h:76
_In_ FLONG fl
Definition: winddi.h:1279

◆ IntCheckFontPathNames()

static BOOL IntCheckFontPathNames ( _In_reads_(cwc) PCWCH  pwcFiles,
_In_ ULONG  cFiles,
_In_ ULONG  cwc 
)
static

Definition at line 453 of file font.c.

457{
458 ULONG ich, cRealFiles;
459
460 if (pwcFiles[cwc - 1] != UNICODE_NULL)
461 return FALSE;
462
463 for (ich = cRealFiles = 0; ich < cwc; ++ich)
464 {
465 if (!pwcFiles[ich])
466 ++cRealFiles;
467 }
468
469 return cRealFiles >= cFiles;
470}
#define FALSE
Definition: types.h:117
#define UNICODE_NULL

Referenced by NtGdiAddFontResourceW(), and NtGdiRemoveFontResourceW().

◆ IntGetCharDimensions()

DWORD FASTCALL IntGetCharDimensions ( _In_ HDC  hdc,
_Out_opt_ PTEXTMETRICW  ptm,
_Out_opt_ PDWORD  height 
)

Definition at line 337 of file font.c.

341{
342 PDC pdc;
343 PDC_ATTR pdcattr;
344 PTEXTOBJ TextObj;
345 SIZE sz;
346 TMW_INTERNAL tmwi;
347 BOOL Good;
348
349 static const WCHAR alphabet[] = {
350 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
351 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
352 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
353
354 if(!ftGdiGetTextMetricsW(hdc, &tmwi)) return 0;
355
356 pdc = DC_LockDc(hdc);
357
358 if (!pdc) return 0;
359
360 pdcattr = pdc->pdcattr;
361
362 TextObj = RealizeFontInit(pdcattr->hlfntNew);
363 if ( !TextObj )
364 {
365 DC_UnlockDc(pdc);
366 return 0;
367 }
368 Good = TextIntGetTextExtentPoint(pdc, TextObj, alphabet, 52, 0, NULL, NULL, &sz, 0);
369 TEXTOBJ_UnlockText(TextObj);
370 DC_UnlockDc(pdc);
371
372 if (!Good) return 0;
373 if (ptm) *ptm = tmwi.TextMetric;
374 if (height) *height = tmwi.TextMetric.tmHeight;
375
376 return (sz.cx / 26 + 1) / 2;
377}
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
HDC hdc
Definition: main.c:9
short WCHAR
Definition: pedump.c:58
LONG cx
Definition: kdterminal.h:27
TEXTMETRICW TextMetric
Definition: ntgdityp.h:370
LONG tmHeight
Definition: wingdi.h:2829
BOOL FASTCALL TextIntGetTextExtentPoint(_In_ PDC dc, _In_ PTEXTOBJ TextObj, _In_reads_(Count) PCWCH String, _In_ INT Count, _In_ ULONG MaxExtent, _Out_ PINT Fit, _Out_writes_to_opt_(Count, *Fit) PINT Dx, _Out_ PSIZE Size, _In_ FLONG fl)
Definition: freetype.c:4969
BOOL FASTCALL ftGdiGetTextMetricsW(HDC hDC, PTMW_INTERNAL ptmwi)
Definition: freetype.c:5289

Referenced by co_IntInitializeDesktopGraphics(), IntGetDialogBaseUnits(), MENU_CalcItemSize(), and UserChangeDisplaySettings().

◆ IntGetFontLanguageInfo()

DWORD FASTCALL IntGetFontLanguageInfo ( _In_ PDC  Dc)

Definition at line 382 of file font.c.

383{
384 PDC_ATTR pdcattr;
385 FONTSIGNATURE fontsig;
386 static const DWORD GCP_DBCS_MASK=0x003F0000,
387 GCP_DIACRITIC_MASK=0x00000000,
388 FLI_GLYPHS_MASK=0x00000000,
389 GCP_GLYPHSHAPE_MASK=0x00000040,
390 GCP_KASHIDA_MASK=0x00000000,
391 GCP_LIGATE_MASK=0x00000000,
392 GCP_USEKERNING_MASK=0x00000000,
393 GCP_REORDER_MASK=0x00000060;
394
395 DWORD result=0;
396
397 ftGdiGetTextCharsetInfo( Dc, &fontsig, 0 );
398
399 /* We detect each flag we return using a bitmask on the Codepage Bitfields */
400 if( (fontsig.fsCsb[0]&GCP_DBCS_MASK)!=0 )
402
403 if( (fontsig.fsCsb[0]&GCP_DIACRITIC_MASK)!=0 )
405
406 if( (fontsig.fsCsb[0]&FLI_GLYPHS_MASK)!=0 )
408
409 if( (fontsig.fsCsb[0]&GCP_GLYPHSHAPE_MASK)!=0 )
411
412 if( (fontsig.fsCsb[0]&GCP_KASHIDA_MASK)!=0 )
414
415 if( (fontsig.fsCsb[0]&GCP_LIGATE_MASK)!=0 )
417
418 if( (fontsig.fsCsb[0]&GCP_USEKERNING_MASK)!=0 )
420
421 pdcattr = Dc->pdcattr;
422
423 /* This might need a test for a HEBREW- or ARABIC_CHARSET as well */
424 if ( pdcattr->flTextAlign & TA_RTLREADING )
425 if( (fontsig.fsCsb[0]&GCP_REORDER_MASK)!=0 )
427
428 return result;
429}
struct FONTSIGNATURE FONTSIGNATURE
Definition: dwrite_3.idl:31
GLuint64EXT * result
Definition: glext.h:11304
FLONG flTextAlign
Definition: ntgdihdl.h:324
INT FASTCALL ftGdiGetTextCharsetInfo(PDC Dc, LPFONTSIGNATURE lpSig, DWORD dwFlags)
Definition: freetype.c:5093
#define GCP_GLYPHSHAPE
Definition: wingdi.h:833
#define GCP_DIACRITIC
Definition: wingdi.h:831
#define GCP_LIGATE
Definition: wingdi.h:837
#define GCP_USEKERNING
Definition: wingdi.h:845
#define GCP_KASHIDA
Definition: wingdi.h:836
#define FLI_GLYPHS
Definition: wingdi.h:846
#define TA_RTLREADING
Definition: wingdi.h:934
#define GCP_REORDER
Definition: wingdi.h:843
#define GCP_DBCS
Definition: wingdi.h:828

Referenced by NtGdiGetDCDword().

◆ NtGdiAddFontMemResourceEx()

HANDLE APIENTRY NtGdiAddFontMemResourceEx ( _In_reads_bytes_(cjBuffer) const VOID *  pvBuffer,
_In_ DWORD  cjBuffer,
_In_reads_bytes_opt_(cjDV) const DESIGNVECTOR *  pdv,
_In_ ULONG  cjDV,
_Out_ PDWORD  pNumFonts 
)

Definition at line 584 of file font.c.

590{
592 HANDLE Ret;
593 DWORD NumFonts = 0;
594
595 DPRINT("NtGdiAddFontMemResourceEx\n");
598
599 if (!pvBuffer || !cjBuffer)
600 return NULL;
601
603 {
604 ProbeForRead(pvBuffer, cjBuffer, sizeof(BYTE));
606 RtlCopyMemory(Buffer, pvBuffer, cjBuffer);
607 }
609 {
610 if (Buffer != NULL)
611 {
613 }
614 _SEH2_YIELD(return NULL);
615 }
616 _SEH2_END;
617
618 Ret = IntGdiAddFontMemResource(Buffer, cjBuffer, &NumFonts);
620
622 {
623 ProbeForWrite(pNumFonts, sizeof(NumFonts), 1);
624 *pNumFonts = NumFonts;
625 }
627 {
628 /* Leak it? */
629 _SEH2_YIELD(return NULL);
630 }
631 _SEH2_END;
632
633
634 return Ret;
635}
Definition: bufpool.h:45
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define DBG_UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:330
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_VOLATILE
Definition: pseh2_64.h:208
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:207
HANDLE FASTCALL IntGdiAddFontMemResource(PVOID Buffer, DWORD dwSize, PDWORD pNumAdded)
Definition: freetype.c:2529
#define TAG_FONT
Definition: tags.h:12
_In_ ULONG_PTR _In_opt_ DESIGNVECTOR * pdv
Definition: winddi.h:3723
#define ExAllocatePoolWithQuotaTag(a, b, c)
Definition: exfuncs.h:530
unsigned char BYTE
Definition: xxhash.c:193

Referenced by AddFontMemResourceEx().

◆ NtGdiAddFontResourceW()

INT APIENTRY NtGdiAddFontResourceW ( _In_reads_(cwc) PCWCH  pwcFiles,
_In_ ULONG  cwc,
_In_ ULONG  cFiles,
_In_ FLONG  fl,
_In_ DWORD  dwPidTid,
_In_opt_ const DESIGNVECTOR *  pdv 
)

Functions

Definition at line 476 of file font.c.

483{
484 UNICODE_STRING SafeFileName;
485 INT Ret;
486
489
490 DPRINT("NtGdiAddFontResourceW\n");
491
492 /* cwc = Length + trailing zero. */
493 if ((cwc <= 1) || (cwc > UNICODE_STRING_MAX_CHARS))
494 return 0;
495
496 SafeFileName.Length = (USHORT)((cwc - 1) * sizeof(WCHAR));
497 SafeFileName.MaximumLength = SafeFileName.Length + sizeof(UNICODE_NULL);
499 SafeFileName.MaximumLength,
500 TAG_STRING);
501 if (!SafeFileName.Buffer)
502 return 0;
503
505 {
506 ProbeForRead(pwcFiles, cwc * sizeof(WCHAR), sizeof(WCHAR));
507
508 if (!IntCheckFontPathNames(pwcFiles, cFiles, cwc))
509 return 0;
510
511 RtlCopyMemory(SafeFileName.Buffer, pwcFiles, SafeFileName.Length);
512 }
514 {
515 ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
516 _SEH2_YIELD(return 0);
517 }
518 _SEH2_END;
519
520 SafeFileName.Buffer[SafeFileName.Length / sizeof(WCHAR)] = UNICODE_NULL;
521
522 Ret = IntGdiAddFontResourceEx(&SafeFileName, cFiles, fl, 0);
523
524 ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
525 return Ret;
526}
#define UNICODE_STRING_MAX_CHARS
#define TAG_STRING
Definition: oslist.h:22
unsigned short USHORT
Definition: pedump.c:61
USHORT MaximumLength
Definition: env_spec_w32.h:370
static BOOL IntCheckFontPathNames(_In_reads_(cwc) PCWCH pwcFiles, _In_ ULONG cFiles, _In_ ULONG cwc)
Definition: font.c:453
INT FASTCALL IntGdiAddFontResourceEx(_In_ PCUNICODE_STRING FileName, _In_ DWORD cFiles, _In_ DWORD Characteristics, _In_ DWORD dwFlags)
Definition: freetype.c:2198

◆ NtGdiGetCharABCWidthsW()

BOOL NTAPI NtGdiGetCharABCWidthsW ( _In_ HDC  hDC,
_In_ UINT  FirstChar,
_In_ UINT  Count,
_In_reads_opt_(Count) PCWCH  UnSafepwch,
_In_ FLONG  fl,
_Out_writes_bytes_(Count *sizeof(ABC)) PVOID  Buffer 
)

Definition at line 1412 of file font.c.

1419{
1420 BOOL ret = FALSE;
1421 PVOID SafeBuff = NULL;
1422 PWCHAR Safepwch = NULL;
1423 ULONG cbABCs;
1425 WCHAR Stackpwch[28];
1426 ABC StackABCs[28];
1427
1428 if (!Buffer || (UnSafepwch && !Count) || Count > MAX_TEXT_BUFFER / sizeof(ABC))
1429 return FALSE;
1430
1431 if (UnSafepwch)
1432 {
1433 UINT pwchSize = Count * sizeof(WCHAR);
1434 if (Count <= _countof(Stackpwch))
1435 Safepwch = Stackpwch;
1436 else
1437 Safepwch = ExAllocatePoolWithTag(PagedPool, pwchSize, GDITAG_TEXT);
1438
1439 if (!Safepwch)
1440 return FALSE;
1441
1442 Status = MmCopyFromCaller(Safepwch, UnSafepwch, pwchSize);
1443 if (!NT_SUCCESS(Status))
1444 goto Cleanup;
1445 }
1446
1447 cbABCs = Count * sizeof(ABC);
1448 if (Count <= _countof(StackABCs))
1449 SafeBuff = StackABCs;
1450 else
1451 SafeBuff = ExAllocatePoolWithTag(PagedPool, cbABCs, GDITAG_TEXT);
1452
1453 if (!SafeBuff)
1454 goto Cleanup;
1455
1456 ret = GreGetCharABCWidthsW(hDC, FirstChar, Count, Safepwch, fl, SafeBuff);
1457 if (ret)
1458 {
1459 Status = MmCopyToCaller(Buffer, SafeBuff, cbABCs);
1461 }
1462
1463Cleanup:
1464 if (SafeBuff && SafeBuff != StackABCs)
1465 ExFreePoolWithTag(SafeBuff, GDITAG_TEXT);
1466 if (Safepwch && Safepwch != Stackpwch)
1467 ExFreePoolWithTag(Safepwch, GDITAG_TEXT);
1468 return ret;
1469}
static const WCHAR Cleanup[]
Definition: register.c:80
return ret
Definition: mutex.c:147
unsigned int UINT
Definition: sysinfo.c:13
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
#define MmCopyFromCaller
Definition: polytest.cpp:29
#define _countof(array)
Definition: sndvol32.h:70
Definition: wingdi.h:1856
uint16_t * PWCHAR
Definition: typedefs.h:56
#define MAX_TEXT_BUFFER
Definition: font.c:17
BOOL APIENTRY GreGetCharABCWidthsW(_In_ HDC hDC, _In_ UINT FirstChar, _In_ UINT Count, _In_reads_opt_(Count) PCWCH Safepwch, _In_ FLONG fl, _Out_writes_bytes_(Count *sizeof(ABC)) PVOID SafeBuffer)
Definition: freetype.c:7380
struct _ABC ABC

◆ NtGdiGetCharacterPlacementW()

DWORD APIENTRY NtGdiGetCharacterPlacementW ( _In_ HDC  hdc,
_In_reads_(nCount) PCWCH  pwsz,
_In_ INT  nCount,
_In_ INT  nMaxExtent,
_Inout_opt_ LPGCP_RESULTSW  pgcpw,
_In_ DWORD  dwFlags 
)

Definition at line 652 of file font.c.

659{
661 return 0;
662#if 0
663 return GreGetCharacterPlacementW( hdc,
664 pwsz,
665 nCount,
666 nMaxExtent,
667 pgcpw,
668 dwFlags);
669#endif
670}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141

Referenced by NewGetCharacterPlacementW().

◆ NtGdiGetCharWidthW()

BOOL NTAPI NtGdiGetCharWidthW ( _In_ HDC  hDC,
_In_ UINT  FirstChar,
_In_ UINT  Count,
_In_reads_opt_(Count) PCWCH  UnSafepwc,
_In_ FLONG  fl,
_Out_writes_bytes_(Count *sizeof(INT)) PVOID  Buffer 
)

Definition at line 1354 of file font.c.

1361{
1362 BOOL ret = FALSE;
1363 PVOID pTmpBuffer = NULL;
1364 PWCHAR pSafePwc = NULL;
1366 WCHAR StackPwc[40];
1367 INT StackBuffer[40];
1368
1369 if (!Count || Count > MAX_TEXT_BUFFER / sizeof(INT))
1370 return FALSE;
1371
1372 if (UnSafepwc)
1373 {
1374 if (Count <= _countof(StackPwc))
1375 pSafePwc = StackPwc;
1376 else
1377 pSafePwc = ExAllocatePoolWithTag(PagedPool, Count * sizeof(WCHAR), GDITAG_TEXT);
1378
1379 if (!pSafePwc)
1380 return FALSE;
1381
1382 Status = MmCopyFromCaller(pSafePwc, UnSafepwc, Count * sizeof(WCHAR));
1383 if (!NT_SUCCESS(Status))
1384 goto Cleanup;
1385 }
1386
1387 if (Count <= _countof(StackBuffer))
1388 pTmpBuffer = StackBuffer;
1389 else
1390 pTmpBuffer = ExAllocatePoolWithTag(PagedPool, Count * sizeof(INT), GDITAG_TEXT);
1391
1392 if (!pTmpBuffer)
1393 goto Cleanup;
1394
1395 ret = GreGetCharWidthW(hDC, FirstChar, Count, pSafePwc, fl, pTmpBuffer);
1396 if (ret)
1397 {
1398 Status = MmCopyToCaller(Buffer, pTmpBuffer, Count * sizeof(INT));
1400 }
1401
1402Cleanup:
1403 if (pTmpBuffer && pTmpBuffer != StackBuffer)
1404 ExFreePoolWithTag(pTmpBuffer, GDITAG_TEXT);
1405 if (pSafePwc && pSafePwc != StackPwc)
1406 ExFreePoolWithTag(pSafePwc, GDITAG_TEXT);
1407 return ret;
1408}
BOOL APIENTRY GreGetCharWidthW(_In_ HDC hDC, _In_ UINT FirstChar, _In_ UINT Count, _In_reads_opt_(Count) PCWCH Safepwc, _In_ FLONG fl, _Out_writes_bytes_(Count *sizeof(INT)) PVOID Buffer)
Definition: freetype.c:7484

◆ NtGdiGetFontData()

DWORD APIENTRY NtGdiGetFontData ( _In_ HDC  hDC,
_In_ DWORD  Table,
_In_ DWORD  Offset,
_Out_writes_bytes_(Size) PVOID  Buffer,
_In_ DWORD  Size 
)

Definition at line 674 of file font.c.

680{
681 PDC Dc;
682 PDC_ATTR pdcattr;
683 HFONT hFont;
684 PTEXTOBJ TextObj;
685 PFONTGDI FontGdi;
688
689 if (Buffer && Size)
690 {
692 {
694 }
696 {
698 }
700 }
701
702 if (!NT_SUCCESS(Status)) return Result;
703
704 Dc = DC_LockDc(hDC);
705 if (Dc == NULL)
706 {
708 return GDI_ERROR;
709 }
710 pdcattr = Dc->pdcattr;
711
712 hFont = pdcattr->hlfntNew;
713 TextObj = RealizeFontInit(hFont);
714 DC_UnlockDc(Dc);
715
716 if (TextObj == NULL)
717 {
719 return GDI_ERROR;
720 }
721
722 FontGdi = ObjToGDI(TextObj->Font, FONT);
723
725
726 TEXTOBJ_UnlockText(TextObj);
727
728 return Result;
729}
HFONT hFont
Definition: main.c:53
ASMGENDATA Table[]
Definition: genincdata.c:61
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
DWORD FASTCALL ftGdiGetFontData(PFONTGDI FontGdi, DWORD Table, DWORD Offset, PVOID Buffer, DWORD Size)
Definition: freetype.c:5373
#define GDI_ERROR
Definition: wingdi.h:1309
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

◆ NtGdiGetFontFileData()

DWORD APIENTRY NtGdiGetFontFileData ( _In_ UINT  uFileCollectionID,
_In_ UINT  uFileIndex,
_In_ PULONGLONG  pullFileOffset,
_Out_writes_bytes_(cjBuf) PVOID  pvBuf,
_In_ SIZE_T  cjBuf 
)

Definition at line 1223 of file font.c.

1229{
1231 return 0;
1232}

Referenced by GetFontFileData().

◆ NtGdiGetFontFileInfo()

DWORD APIENTRY NtGdiGetFontFileInfo ( _In_ UINT  uFileCollectionID,
_In_ UINT  uFileIndex,
_Out_writes_bytes_(cjSize) PFONT_FILE_INFO  pffi,
_In_ SIZE_T  cjSize,
_Out_opt_ PSIZE_T  pcjActualSize 
)

Definition at line 1236 of file font.c.

1242{
1244 return 0;
1245}

Referenced by GetFontFileInfo().

◆ NtGdiGetFontRealizationInfo()

BOOL APIENTRY NtGdiGetFontRealizationInfo ( _In_ HDC  hdc,
_Out_ FONT_REALIZATION_INFO *  info 
)

Definition at line 1249 of file font.c.

1252{
1254 return FALSE;
1255}

◆ NtGdiGetFontResourceInfoInternalW()

W32KAPI BOOL APIENTRY NtGdiGetFontResourceInfoInternalW ( _In_reads_(cwc) PCWCH  pwszFiles,
_In_ ULONG  cwc,
_In_ ULONG  cFiles,
_In_ UINT  cjIn,
_Inout_ PDWORD  pdwBytes,
_Out_writes_bytes_ *pdwBytes PVOID  pvBuf,
_In_ DWORD  dwType 
)

Definition at line 1043 of file font.c.

1051{
1053 DWORD dwBytes, dwBytesRequested;
1054 UNICODE_STRING SafeFileNames;
1055 BOOL bRet = FALSE;
1056 ULONG cbStringSize;
1057 LPVOID Buffer;
1058
1059 /* FIXME: Handle cFiles > 0 */
1060
1061 /* Check for valid dwType values */
1062 if (dwType > 5)
1063 {
1065 return FALSE;
1066 }
1067
1068 /* Allocate a safe unicode string buffer */
1069 cbStringSize = cwc * sizeof(WCHAR);
1070 SafeFileNames.MaximumLength = SafeFileNames.Length = (USHORT)cbStringSize - sizeof(WCHAR);
1071 SafeFileNames.Buffer = ExAllocatePoolWithTag(PagedPool,
1072 cbStringSize,
1073 TAG_USTR);
1074 if (!SafeFileNames.Buffer)
1075 {
1077 return FALSE;
1078 }
1079 RtlZeroMemory(SafeFileNames.Buffer, SafeFileNames.MaximumLength);
1080
1081 /* Check buffers and copy pwszFiles to safe unicode string */
1082 _SEH2_TRY
1083 {
1084 ProbeForRead(pwszFiles, cbStringSize, 1);
1085 ProbeForWrite(pdwBytes, sizeof(DWORD), 1);
1086 if (pvBuf)
1087 ProbeForWrite(pvBuf, cjIn, 1);
1088
1089 dwBytes = *pdwBytes;
1090 dwBytesRequested = dwBytes;
1091
1092 RtlCopyMemory(SafeFileNames.Buffer, pwszFiles, cbStringSize);
1093 if (dwBytes > 0)
1094 {
1096 }
1097 else
1098 {
1100 }
1101 }
1103 {
1105 }
1106 _SEH2_END
1107
1108 if(!NT_SUCCESS(Status))
1109 {
1111 /* Free the string buffer for the safe filename */
1112 ExFreePoolWithTag(SafeFileNames.Buffer, TAG_USTR);
1113 return FALSE;
1114 }
1115
1116 /* Do the actual call */
1117 bRet = IntGdiGetFontResourceInfo(&SafeFileNames,
1118 (pvBuf ? Buffer : NULL),
1119 &dwBytes, dwType);
1120
1121 /* Check if succeeded */
1122 if (bRet)
1123 {
1124 /* Copy the data back to caller */
1125 _SEH2_TRY
1126 {
1127 /* Buffers are already probed */
1128 if (pvBuf && dwBytesRequested > 0)
1129 RtlCopyMemory(pvBuf, Buffer, min(dwBytesRequested, dwBytes));
1130 *pdwBytes = dwBytes;
1131 }
1133 {
1135 }
1136 _SEH2_END
1137
1138 if(!NT_SUCCESS(Status))
1139 {
1141 bRet = FALSE;
1142 }
1143 }
1144
1146 /* Free the string for the safe filenames */
1147 ExFreePoolWithTag(SafeFileNames.Buffer, TAG_USTR);
1148
1149 return bRet;
1150}
#define TAG_USTR
Definition: libsupp.c:1008
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:35
#define min(a, b)
Definition: monoChain.cc:55
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:30
BOOL FASTCALL IntGdiGetFontResourceInfo(PUNICODE_STRING FileName, PVOID pBuffer, DWORD *pdwBytes, DWORD dwType)
Definition: freetype.c:6104
#define TAG_FINF
Definition: text.h:3
_In_ ULONG _In_ CLIPOBJ _In_ RECTL _In_ ULONG cjIn
Definition: winddi.h:3532

◆ NtGdiGetFontUnicodeRanges()

DWORD APIENTRY NtGdiGetFontUnicodeRanges ( _In_ HDC  hdc,
_Out_opt_ LPGLYPHSET  pgs 
)

Definition at line 734 of file font.c.

737{
738 PDC pDc;
739 PDC_ATTR pdcattr;
740 HFONT hFont;
741 PTEXTOBJ TextObj;
742 PFONTGDI FontGdi;
743 DWORD Size = 0;
744 PGLYPHSET pgsSafe;
746
747 pDc = DC_LockDc(hdc);
748 if (!pDc)
749 {
751 return 0;
752 }
753
754 pdcattr = pDc->pdcattr;
755
756 hFont = pdcattr->hlfntNew;
757 TextObj = RealizeFontInit(hFont);
758
759 if ( TextObj == NULL)
760 {
762 goto Exit;
763 }
764 FontGdi = ObjToGDI(TextObj->Font, FONT);
765
766 Size = ftGetFontUnicodeRanges( FontGdi, NULL);
767
768 if (Size && pgs)
769 {
771 if (!pgsSafe)
772 {
774 Size = 0;
775 goto Exit;
776 }
777
778 Size = ftGetFontUnicodeRanges( FontGdi, pgsSafe);
779
780 if (Size)
781 {
783 {
784 ProbeForWrite(pgs, Size, 1);
785 RtlCopyMemory(pgs, pgsSafe, Size);
786 }
788 {
790 }
792
793 if (!NT_SUCCESS(Status)) Size = 0;
794 }
796 }
797Exit:
798 TEXTOBJ_UnlockText(TextObj);
799 DC_UnlockDc(pDc);
800 return Size;
801}
static void Exit(void)
Definition: sock.c:1330
DWORD FASTCALL ftGetFontUnicodeRanges(PFONTGDI Font, PGLYPHSET glyphset)
Definition: freetype.c:5206

◆ NtGdiGetGlyphIndicesW()

__kernel_entry W32KAPI DWORD APIENTRY NtGdiGetGlyphIndicesW ( _In_ HDC  hdc,
_In_reads_opt_(cwc) PCWCH  pwc,
_In_ INT  cwc,
_Out_writes_opt_(cwc) PWORD  pgi,
_In_ DWORD  iMode 
)

Definition at line 1476 of file font.c.

1482{
1483 return NtGdiGetGlyphIndicesWInternal(hdc, pwc, cwc, pgi, iMode, FALSE);
1484}
__kernel_entry W32KAPI DWORD APIENTRY NtGdiGetGlyphIndicesWInternal(_In_ HDC hdc, _In_reads_opt_(cwc) PCWCH pwc, _In_ INT cwc, _Out_writes_opt_(cwc) PWORD pgi, _In_ DWORD iMode, _In_ BOOL bSubset)
Definition: font.c:1490
_In_ ULONG iMode
Definition: winddi.h:3520

◆ NtGdiGetGlyphIndicesWInternal()

__kernel_entry W32KAPI DWORD APIENTRY NtGdiGetGlyphIndicesWInternal ( _In_ HDC  hdc,
_In_reads_opt_(cwc) PCWCH  pwc,
_In_ INT  cwc,
_Out_writes_opt_(cwc) PWORD  pgi,
_In_ DWORD  iMode,
_In_ BOOL  bSubset 
)

Definition at line 1490 of file font.c.

1497{
1498 if (cwc < 0)
1499 return GDI_ERROR;
1500
1501 if (!cwc && !pwc && !pgi && !iMode)
1502 return GreGetGlyphIndicesW(hdc, NULL, 0, NULL, 0, bSubset);
1503
1504 if (cwc == 0)
1505 return GDI_ERROR;
1506
1507 const SIZE_T elemSize = sizeof(WORD) + sizeof(WCHAR);
1508 if ((SIZE_T)cwc > (MAX_TEXT_BUFFER / elemSize))
1509 return GDI_ERROR;
1510
1511 // Allocate a working buffer (for pgi and pwc)
1512 WORD stackBuf[80];
1513 PWORD workBuf = NULL;
1514 if ((SIZE_T)cwc <= (sizeof(stackBuf) / elemSize))
1515 {
1516 workBuf = stackBuf;
1517 }
1518 else
1519 {
1520 SIZE_T workBufSize = cwc * elemSize;
1521 workBuf = ExAllocatePoolWithTag(PagedPool, workBufSize, GDITAG_TEXT);
1522 if (!workBuf)
1523 return GDI_ERROR;
1524 }
1525
1527 PWCHAR safePwc = (PWCHAR)&workBuf[cwc];
1528 NTSTATUS Status = MmCopyFromCaller(safePwc, pwc, cwc * sizeof(WCHAR));
1529 if (!NT_SUCCESS(Status))
1530 goto Cleanup;
1531
1532 ret = GreGetGlyphIndicesW(hdc, safePwc, cwc, workBuf, iMode, bSubset);
1533 if (ret == GDI_ERROR)
1534 goto Cleanup;
1535
1536 Status = MmCopyToCaller(pgi, workBuf, cwc * sizeof(WORD));
1537 if (!NT_SUCCESS(Status))
1538 ret = GDI_ERROR;
1539
1540Cleanup:
1541 if (workBuf != stackBuf)
1543
1544 return ret;
1545}
unsigned short WORD
Definition: ntddk_ex.h:93
WORD * PWORD
Definition: pedump.c:67
ULONG_PTR SIZE_T
Definition: typedefs.h:80
DWORD APIENTRY GreGetGlyphIndicesW(_In_ HDC hdc, _In_reads_opt_(cwc) PCWCH pwc, _In_ INT cwc, _Out_writes_opt_(cwc) PWORD pgi, _In_ DWORD iMode, _In_ BOOL bSubset)
Definition: freetype.c:7594

Referenced by NtGdiGetGlyphIndicesW().

◆ NtGdiGetGlyphOutline()

ULONG APIENTRY NtGdiGetGlyphOutline ( _In_ HDC  hdc,
_In_ WCHAR  wch,
_In_ UINT  iFormat,
_Out_ LPGLYPHMETRICS  pgm,
_In_ ULONG  cjBuf,
_Out_writes_bytes_opt_(cjBuf) PVOID  UnsafeBuf,
_In_opt_ const MAT2 *  pmat2,
_In_ BOOL  bIgnoreRotation 
)

Definition at line 805 of file font.c.

814{
815 ULONG Ret = GDI_ERROR;
816 PDC dc;
817 PVOID pvBuf = NULL;
818 GLYPHMETRICS gm;
820
821 dc = DC_LockDc(hdc);
822 if (!dc)
823 {
825 return GDI_ERROR;
826 }
827
828 if (UnsafeBuf && cjBuf)
829 {
831 if (!pvBuf)
832 {
834 goto Exit;
835 }
836 }
837
839 wch,
840 iFormat,
841 pgm ? &gm : NULL,
842 cjBuf,
843 pvBuf,
844 pmat2,
845 bIgnoreRotation);
846
847 if (pvBuf)
848 {
850 {
851 ProbeForWrite(UnsafeBuf, cjBuf, 1);
852 RtlCopyMemory(UnsafeBuf, pvBuf, cjBuf);
853 }
855 {
857 }
859
861 }
862
863 if (pgm)
864 {
866 {
867 ProbeForWrite(pgm, sizeof(GLYPHMETRICS), 1);
868 RtlCopyMemory(pgm, &gm, sizeof(GLYPHMETRICS));
869 }
871 {
873 }
875 }
876
877 if (! NT_SUCCESS(Status))
878 {
880 Ret = GDI_ERROR;
881 }
882
883Exit:
885 return Ret;
886}
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
ULONG FASTCALL ftGdiGetGlyphOutline(PDC dc, WCHAR wch, UINT iFormat, LPGLYPHMETRICS pgm, ULONG cjBuf, PVOID pvBuf, const MAT2 *pmat2, BOOL bIgnoreRotation)
Definition: freetype.c:4434
_In_ DWORD cjBuf
Definition: winddi.h:3827
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3468

◆ NtGdiGetKerningPairs()

DWORD APIENTRY NtGdiGetKerningPairs ( _In_ HDC  hDC,
_In_ ULONG  NumPairs,
_Out_writes_(NumPairs) LPKERNINGPAIR  krnpair 
)

Definition at line 890 of file font.c.

894{
895 PDC dc;
896 PDC_ATTR pdcattr;
897 PTEXTOBJ TextObj;
898 PFONTGDI FontGDI;
899 DWORD Count;
900 KERNINGPAIR *pKP;
902
903 dc = DC_LockDc(hDC);
904 if (!dc)
905 {
907 return 0;
908 }
909
910 pdcattr = dc->pdcattr;
911 TextObj = RealizeFontInit(pdcattr->hlfntNew);
913
914 if (!TextObj)
915 {
917 return 0;
918 }
919
920 FontGDI = ObjToGDI(TextObj->Font, FONT);
921 TEXTOBJ_UnlockText(TextObj);
922
923 Count = ftGdiGetKerningPairs(FontGDI,0,NULL);
924
925 if ( Count && krnpair )
926 {
927 if (Count > NumPairs)
928 {
930 return 0;
931 }
933 if (!pKP)
934 {
936 return 0;
937 }
938 ftGdiGetKerningPairs(FontGDI,Count,pKP);
940 {
941 ProbeForWrite(krnpair, Count * sizeof(KERNINGPAIR), 1);
942 RtlCopyMemory(krnpair, pKP, Count * sizeof(KERNINGPAIR));
943 }
945 {
947 }
949 if (!NT_SUCCESS(Status))
950 {
952 Count = 0;
953 }
955 }
956 return Count;
957}

◆ NtGdiGetOutlineTextMetricsInternalW()

ULONG APIENTRY NtGdiGetOutlineTextMetricsInternalW ( _In_ HDC  hDC,
_In_ ULONG  Data,
_Out_opt_ POUTLINETEXTMETRICW  otm,
_In_ PTMDIFF  Tmd 
)

Definition at line 965 of file font.c.

970{
971 PDC dc;
972 PDC_ATTR pdcattr;
973 PTEXTOBJ TextObj;
974 PFONTGDI FontGDI;
975 HFONT hFont = 0;
976 ULONG Size;
977 OUTLINETEXTMETRICW *potm;
979
980 dc = DC_LockDc(hDC);
981 if (!dc)
982 {
984 return 0;
985 }
986 pdcattr = dc->pdcattr;
987 hFont = pdcattr->hlfntNew;
988 TextObj = RealizeFontInit(hFont);
990 if (!TextObj)
991 {
993 return 0;
994 }
995 FontGDI = ObjToGDI(TextObj->Font, FONT);
996 if (!(FontGDI->flType & FO_TYPE_TRUETYPE))
997 {
998 TEXTOBJ_UnlockText(TextObj);
999 return 0;
1000 }
1001 TextIntUpdateSize(TextObj, FontGDI, TRUE);
1002 TEXTOBJ_UnlockText(TextObj);
1003 Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL, FALSE);
1004 if (!otm) return Size;
1005 if (Size > Data)
1006 {
1008 return 0;
1009 }
1011 if (!potm)
1012 {
1014 return 0;
1015 }
1016 RtlZeroMemory(potm, Size);
1017 IntGetOutlineTextMetrics(FontGDI, Size, potm, FALSE);
1018
1019 _SEH2_TRY
1020 {
1021 ProbeForWrite(otm, Size, 1);
1022 RtlCopyMemory(otm, potm, Size);
1023 }
1025 {
1027 }
1028 _SEH2_END
1029
1030 if (!NT_SUCCESS(Status))
1031 {
1033 Size = 0;
1034 }
1035
1037 return Size;
1038}
#define TRUE
Definition: types.h:120
FLONG flType
Definition: engobjects.h:142
BOOL FASTCALL TextIntUpdateSize(_In_ PTEXTOBJ TextObj, _In_ PFONTGDI FontGDI, _In_ BOOL bDoLock)
Definition: freetype.c:4261
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm, BOOL bLocked)
Definition: freetype.c:3140
#define FO_TYPE_TRUETYPE
Definition: winddi.h:737

◆ NtGdiGetRealizationInfo()

BOOL APIENTRY NtGdiGetRealizationInfo ( _In_ HDC  hdc,
_Out_ PREALIZATION_INFO  pri,
_In_ HFONT  hf 
)

Definition at line 1155 of file font.c.

1159{
1160 PDC pDc;
1161 PTEXTOBJ pTextObj;
1162 PFONTGDI pFontGdi;
1163 PDC_ATTR pdcattr;
1164 BOOL Ret = FALSE;
1165 INT i = 0;
1167
1168 pDc = DC_LockDc(hdc);
1169 if (!pDc)
1170 {
1172 return 0;
1173 }
1174 pdcattr = pDc->pdcattr;
1175 pTextObj = RealizeFontInit(pdcattr->hlfntNew);
1176 ASSERT(pTextObj != NULL);
1177 pFontGdi = ObjToGDI(pTextObj->Font, FONT);
1178 TEXTOBJ_UnlockText(pTextObj);
1179 DC_UnlockDc(pDc);
1180
1181 Ret = ftGdiRealizationInfo(pFontGdi, &ri);
1182 if (Ret)
1183 {
1184 if (pri)
1185 {
1187 _SEH2_TRY
1188 {
1189 ProbeForWrite(pri, sizeof(REALIZATION_INFO), 1);
1190 RtlCopyMemory(pri, &ri, sizeof(REALIZATION_INFO));
1191 }
1193 {
1195 }
1196 _SEH2_END
1197
1198 if(!NT_SUCCESS(Status))
1199 {
1201 return FALSE;
1202 }
1203 }
1204 do
1205 {
1206 if (GdiHandleTable->cfPublic[i].hf == hf)
1207 {
1208 GdiHandleTable->cfPublic[i].iTechnology = ri.iTechnology;
1209 GdiHandleTable->cfPublic[i].iUniq = ri.iUniq;
1210 GdiHandleTable->cfPublic[i].dwUnknown = ri.dwUnknown;
1211 GdiHandleTable->cfPublic[i].dwCFCount = GdiHandleTable->dwCFCount;
1212 GdiHandleTable->cfPublic[i].fl |= CFONT_REALIZATION;
1213 }
1214 i++;
1215 }
1216 while ( i < GDI_CFONT_MAX );
1217 }
1218 return Ret;
1219}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GDI_CFONT_MAX
Definition: ntgdihdl.h:20
#define CFONT_REALIZATION
Definition: ntgdityp.h:430
BOOL FASTCALL ftGdiRealizationInfo(PFONTGDI Font, PREALIZATION_INFO Info)
Definition: freetype.c:6372

◆ NtGdiHfontCreate()

HFONT APIENTRY NtGdiHfontCreate ( _In_reads_bytes_(cjElfw) const ENUMLOGFONTEXDVW *  pelfw,
_In_ ULONG  cjElfw,
_In_ LFTYPE  lft,
_In_ FLONG  fl,
_In_opt_ PVOID  pvCliData 
)

Definition at line 1313 of file font.c.

1319{
1320 ENUMLOGFONTEXDVW SafeLogfont;
1322
1323 /* Silence GCC warnings */
1326
1327 if (!pelfw)
1328 {
1329 return NULL;
1330 }
1331
1332 _SEH2_TRY
1333 {
1334 ProbeForRead(pelfw, sizeof(ENUMLOGFONTEXDVW), 1);
1335 RtlCopyMemory(&SafeLogfont, pelfw, sizeof(ENUMLOGFONTEXDVW));
1336 }
1338 {
1340 }
1341 _SEH2_END
1342
1343 if (!NT_SUCCESS(Status))
1344 {
1345 return NULL;
1346 }
1347
1348 return HfontCreate(&SafeLogfont, cjElfw, lft, fl, pvCliData);
1349}

Referenced by CreateFontIndirectExA(), and CreateFontIndirectExW().

◆ NtGdiRemoveFontMemResourceEx()

BOOL APIENTRY NtGdiRemoveFontMemResourceEx ( _In_ HANDLE  hMMFont)

Definition at line 640 of file font.c.

642{
643 return IntGdiRemoveFontMemResource(hMMFont);
644}
BOOL FASTCALL IntGdiRemoveFontMemResource(HANDLE hMMFont)
Definition: freetype.c:2615

Referenced by RemoveFontMemResourceEx().

◆ NtGdiRemoveFontResourceW()

BOOL APIENTRY NtGdiRemoveFontResourceW ( _In_reads_(cwc) PCWCH  pwszFiles,
_In_ ULONG  cwc,
_In_ ULONG  cFiles,
_In_ ULONG  fl,
_In_ DWORD  dwPidTid,
_In_opt_ const DESIGNVECTOR *  pdv 
)

Definition at line 530 of file font.c.

537{
538 UNICODE_STRING SafeFileName;
539 BOOL Ret;
540
543
544 DPRINT("NtGdiRemoveFontResourceW\n");
545
546 /* cwc = Length + trailing zero. */
547 if ((cwc <= 1) || (cwc > UNICODE_STRING_MAX_CHARS))
548 return FALSE;
549
550 SafeFileName.Length = (USHORT)((cwc - 1) * sizeof(WCHAR));
551 SafeFileName.MaximumLength = SafeFileName.Length + sizeof(UNICODE_NULL);
553 SafeFileName.MaximumLength,
554 TAG_STRING);
555 if (!SafeFileName.Buffer)
556 return FALSE;
557
559 {
560 ProbeForRead(pwszFiles, cwc * sizeof(WCHAR), sizeof(WCHAR));
561
562 if (!IntCheckFontPathNames(pwszFiles, cFiles, cwc))
563 return FALSE;
564
565 RtlCopyMemory(SafeFileName.Buffer, pwszFiles, SafeFileName.Length);
566 }
568 {
569 ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
570 _SEH2_YIELD(return FALSE);
571 }
572 _SEH2_END;
573
574 SafeFileName.Buffer[SafeFileName.Length / sizeof(WCHAR)] = UNICODE_NULL;
575
576 Ret = IntGdiRemoveFontResource(&SafeFileName, cFiles, fl);
577
578 ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
579 return Ret;
580}
BOOL FASTCALL IntGdiRemoveFontResource(_In_ PCUNICODE_STRING FileName, _In_ DWORD cFiles, _In_ DWORD dwFlags)
Definition: freetype.c:2341

Referenced by RemoveFontResourceExW().

◆ RealizeFontInit()