signature=d60f979e909db97dbaa034ebe539f2fd,a00146.html

本文详细介绍了Win32k中的fntsweep.c文件,该文件涉及字体管理,包括TrueType和Type1字体的处理。主要函数如bCheckFontEntry()检查字体扩展,vProcessFontEntry()处理字体条目,vMoveFileFromSystemToFontsDir()移动文件到字体目录等。代码还涉及到系统目录和字体目录的初始化,以及字体缓存的清理和更新。
摘要由CSDN通过智能技术生成
Win32k: fntsweep.c 文件参考
Win32k

/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */

var searchBox = new SearchBox("searchBox", "search",false,'搜索');

/* @license-end */

/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */

$(function() {

initMenu('',true,false,'search.php','搜索');

$(document).ready(function() { init_search(); });

});

/* @license-end */

class="ui-resizable-handle">

/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */

$(document).ready(function(){initNavTree('a00146.html',''); initResizable(); });

/* @license-end */

οnmοuseοver="return searchBox.OnSearchSelectShow()"

οnmοuseοut="return searchBox.OnSearchSelectHide()"

οnkeydοwn="return searchBox.OnSearchSelectKey(event)">

name="MSearchResults" id="MSearchResults">

fntsweep.c 文件参考
#include "precomp.h"

#include <setupbat.h>

浏览源代码.

宏定义

#define LAST_SWEEP_TIME   L"LastSweepTime"
 
#define DWORDALIGN(X)   (((X) + 3) & ~3)
 
#define EXT_TRUETYPE   L"(TrueType)"
 
#define EXT_FOT   L".FOT"
 

类型定义

typedef VOID(* PFNENTRY) (HKEY hkey, WCHAR *, WCHAR *)
 

函数

BOOL bCheckIfDualBootingWithWin31 ()
 
BOOL bCheckFontEntry (WCHAR *pwcName, WCHAR *pwcExtension)
 
VOID vProcessFontEntry (HKEY hkey, WCHAR *pwcValueName, WCHAR *pwcFileName)
 
VOID vMoveFileFromSystemToFontsDir (WCHAR *pwcFile)
 
VOID vProcessType1FontEntry (HKEY hkey, WCHAR *pwcValueName, WCHAR *pwcValueData)
 
VOID vAddType1Font (WCHAR *pwcValueData, DWORD dwFlags)
 
VOID vAddRemoteType1Font (HKEY hkey, WCHAR *pwcValueName, WCHAR *pwcValueData)
 
VOID vAddLocalType1Font (HKEY hkey, WCHAR *pwcValueName, WCHAR *pwcValueData)
 
VOID vSweepFonts (WCHAR *pwszFontListKey, WCHAR *pwszFontSweepKey, PFNENTRY pfnProcessFontEntry, BOOL bForceEnum)
 
BOOL bLoadableFontDrivers ()
 
VOID vFontSweep ()
 
VOID vLoadT1Fonts (PFNENTRY pfnProcessFontEntry)
 
VOID vLoadLocalT1Fonts ()
 
VOID vLoadRemoteT1Fonts ()
 

变量

WCHAR pwszType1Key [] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Type 1 Installer\\Type 1 Fonts"
 
WCHAR pwszSweepType1Key [] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Type 1 Installer\\LastType1Sweep"
 
WCHAR pwszFontsKey [] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"
 
WCHAR pwszSweepKey [] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontCache\\LastFontSweep"
 
WCHAR pwszFontDrivers [] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Font Drivers"
 
WCHAR * gpwcSystemDir = NULL
 
WCHAR * gpwcFontsDir = NULL
 
BOOL gbWin31Upgrade = FALSE
 

宏定义说明

◆ DWORDALIGN

#define DWORDALIGN( X)   (((X) + 3) & ~3)

在文件 fntsweep.c34 行定义.

◆ EXT_FOT

#define EXT_FOT   L".FOT"

在文件 fntsweep.c110 行定义.

◆ EXT_TRUETYPE

#define EXT_TRUETYPE   L"(TrueType)"

在文件 fntsweep.c109 行定义.

◆ LAST_SWEEP_TIME

#define LAST_SWEEP_TIME   L"LastSweepTime"

在文件 fntsweep.c32 行定义.

类型定义说明

◆ PFNENTRY

typedef VOID(* PFNENTRY) (HKEY hkey, WCHAR *, WCHAR *)

在文件 fntsweep.c507 行定义.

函数说明

◆ bCheckFontEntry()

BOOL bCheckFontEntry (WCHAR * pwcName,
WCHAR * pwcExtension 
)

在文件 fntsweep.c87 行定义.

88 {
89  BOOL bRet = FALSE;
90  LONG cwc = (LONG)wcslen(pwcName) - (LONG)wcslen(pwcExtension);
91  if (cwc > 0)
92  {
93  bRet = !_wcsicmp(&pwcName[cwc], pwcExtension);
94  }
95  return bRet;
96 
97 }

被这些函数引用 vProcessFontEntry().

◆ bCheckIfDualBootingWithWin31()

BOOL bCheckIfDualBootingWithWin31 ()

在文件 fntsweep.c41 行定义.

42 {
43  WCHAR Buffer[32];
44  WCHAR awcWindowsDir[MAX_PATH];
45  DWORD dwRet;
46  UINT cwchWinPath = GetWindowsDirectoryW(awcWindowsDir, MAX_PATH);
47 
48  // the cwchWinPath value does not include the terminating zero
49 
50  if (awcWindowsDir[cwchWinPath - 1] == L '\\')
51  {
52  cwchWinPath -= 1;
53  }
54  awcWindowsDir[cwchWinPath] = L '\0'; // make sure to zero terminated
55 
56  lstrcatW(awcWindowsDir, L "\\system32\\");
57  lstrcatW(awcWindowsDir, WINNT_GUI_FILE_W);
58 
59  dwRet = GetPrivateProfileStringW(
60  WINNT_DATA_W,
61  WINNT_D_WIN31UPGRADE_W,
62  WINNT_A_NO_W,
63  Buffer,
64  sizeof(Buffer)/ sizeof(WCHAR),
65  awcWindowsDir
66  );
67 
68  #if DBG
69  DbgPrint( "\n dwRet = %ld, win31upgrade = %ws\n\n", dwRet, Buffer);
70  #endif
71 
72  return (BOOL)(dwRet ? (!lstrcmpiW(Buffer,WINNT_A_YES)) : 0);
73 }

引用了 DWORD , 以及 UINT().

被这些函数引用 vFontSweep().

◆ bLoadableFontDrivers()

BOOL bLoadableFontDrivers ()

在文件 fntsweep.c810 行定义.

811 {
812  LONG lRet;
813  WCHAR awcClass[MAX_PATH] = L "";
814  DWORD cwcClassName = MAX_PATH;
815  DWORD cSubKeys;
816  DWORD cjMaxSubKey;
817  DWORD cwcMaxClass;
818  DWORD cValues = 0;
819  DWORD cwcMaxValueName;
820  DWORD cjMaxValueData;
821  DWORD cjSecurityDescriptor;
822 
823  HKEY hkey = NULL;
824  FILETIME ftLastWriteTime;
825 
826  BOOL bRet = FALSE;
827 
828  // open the font drivers key and check if there are any entries, if so
829  // return true. If that is the case we will call AddFontResourceW on
830  // Type 1 fonts at boot time, right after user had logged on
831  // PostScript printer drivers are not initialized at this time yet,
832  // it is safe to do it at this time.
833 
834  lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, // Root key
835  pwszFontDrivers, // Subkey to open
836  0L, // Reserved
837  KEY_READ, // SAM
838  &hkey); // return handle
839 
840  if (lRet == ERROR_SUCCESS)
841  {
842  // get the number of entries in the [Fonts] section
843 
844  lRet = RegQueryInfoKeyW(
845  hkey,
846  awcClass, // "" on return
847  &cwcClassName, // 0 on return
848  NULL,
849  &cSubKeys, // 0 on return
850  &cjMaxSubKey, // 0 on return
851  &cwcMaxClass, // 0 on return
852  &cValues, // == cExternalDrivers
853  &cwcMaxValueName, // longest value name
854  &cjMaxValueData, // longest value data
855  &cjSecurityDescriptor, // security descriptor,
856  &ftLastWriteTime
857  );
858 
859  if ((lRet == ERROR_SUCCESS) && cValues)
860  {
861  UserAssert(!(cwcClassName | cSubKeys | cjMaxSubKey | cwcMaxClass | awcClass[0]));
862 
863  // externally loadable drivers are present, force sweep
864 
865  bRet = TRUE;
866  }
867 
868  RegCloseKey(hkey);
869  }
870  return bRet;
871 }

引用了 DWORD, pwszFontDrivers , 以及 UserAssert.

被这些函数引用 vLoadT1Fonts().

◆ vAddLocalType1Font()

VOID vAddLocalType1Font (HKEY hkey,
WCHAR * pwcValueName,
WCHAR * pwcValueData 
)

在文件 fntsweep.c495 行定义.

500 {
501  hkey;
502  pwcValueName;
503  vAddType1Font(pwcValueData, AFRW_ADD_LOCAL_FONT);
504 }

引用了 vAddType1Font().

被这些函数引用 vLoadLocalT1Fonts().

◆ vAddRemoteType1Font()

VOID vAddRemoteType1Font (HKEY hkey,
WCHAR * pwcValueName,
WCHAR * pwcValueData 
)

在文件 fntsweep.c484 行定义.

489 {
490  hkey;
491  pwcValueName;
492  vAddType1Font(pwcValueData, AFRW_ADD_REMOTE_FONT);
493 }

引用了 vAddType1Font().

被这些函数引用 vLoadRemoteT1Fonts().

◆ vAddType1Font()

VOID vAddType1Font (WCHAR * pwcValueData,
DWORD dwFlags 
)

在文件 fntsweep.c442 行定义.

446 {
447  WCHAR *pwcPFM, *pwcPFB, *pwcMMM;
448 
449  #if DBG
450  int iRet;
451  #endif
452 
453  // skip unused boolean value in this multi reg_sz string:
454 
455  if ((pwcValueData[0] != L '\0') && (pwcValueData[1] == L '\0'))
456  {
457  pwcPFM = &pwcValueData[2];
458  pwcPFB = pwcPFM + wcslen(pwcPFM) + 1; // add 1 for zero separator
459  pwcMMM = pwcPFB + wcslen(pwcPFB) + 1; // may of may not be there.
460 
461  // replace space by separator and call addfontresourcew
462 
463  pwcPFB[-1] = PATH_SEPARATOR;
464 
465  // if this is a multiple master font, need one more separator:
466 
467  if (pwcMMM[0] != L '\0')
468  pwcMMM[-1] = PATH_SEPARATOR;
469 
470  #if DBG
471  iRet =
472  #endif
473 
474  GdiAddFontResourceW(pwcPFM, dwFlags);
475 
476  #if DBG
477  DbgPrint( "%ld = GdiAddFontResourceW(%ws, 0x%lx);\n",
478  iRet, pwcPFM, dwFlags);
479  #endif
480  }
481 }

被这些函数引用 vAddLocalType1Font() , 以及 vAddRemoteType1Font().

◆ vFontSweep()

VOID vFontSweep ()

在文件 fntsweep.c885 行定义.

886 {
887  // check if shared windows directory installation:
888 
890 
891  // sweep fonts in the [Fonts] key
892 
894 
895  // now sweep type 1 fonts, if any
896 
898 
899  // one of the two routines above may have initialized %windir%\system
900  // and %windir%\fonts directories. Free the memory associated with this
901 
902  if ( gpwcSystemDir)
903  {
904  LocalFree( gpwcSystemDir);
905  gpwcSystemDir = NULL;
906  }
907 
908 }

引用了 bCheckIfDualBootingWithWin31(), gbWin31Upgrade, gpwcSystemDir, pwszFontsKey, pwszSweepKey, pwszSweepType1Key, pwszType1Key, vProcessFontEntry(), vProcessType1FontEntry() , 以及 vSweepFonts().

◆ vLoadLocalT1Fonts()

VOID vLoadLocalT1Fonts ()

在文件 fntsweep.c943 行定义.

944 {
946 }

引用了 vAddLocalType1Font() , 以及 vLoadT1Fonts().

◆ vLoadRemoteT1Fonts()

VOID vLoadRemoteT1Fonts ()

在文件 fntsweep.c948 行定义.

949 {
951 }

引用了 vAddRemoteType1Font() , 以及 vLoadT1Fonts().

◆ vLoadT1Fonts()

VOID vLoadT1Fonts (PFNENTRY pfnProcessFontEntry)

在文件 fntsweep.c920 行定义.

921 {
922 
923  if ( bLoadableFontDrivers())
924  {
925  #if DBG
926  DbgPrint( "vLoadT1Fonts(0x%lx) was called\n", pfnProcessFontEntry);
927  #endif
928  // now enum and add remote type1 fonts if any
929 
930  vSweepFonts( pwszType1Key, pwszSweepType1Key, pfnProcessFontEntry, TRUE);
931 
932  // if the routines above initialized %windir%\system
933  // and %windir%\fonts directories. Free the memory associated with this
934 
935  if ( gpwcSystemDir)
936  {
937  LocalFree( gpwcSystemDir);
938  gpwcSystemDir = NULL;
939  }
940  }
941 }

引用了 bLoadableFontDrivers(), gpwcSystemDir, pwszSweepType1Key, pwszType1Key , 以及 vSweepFonts().

被这些函数引用 vLoadLocalT1Fonts() , 以及 vLoadRemoteT1Fonts().

◆ vMoveFileFromSystemToFontsDir()

VOID vMoveFileFromSystemToFontsDir (WCHAR * pwcFile)

在文件 fntsweep.c320 行定义.

321 {
322  WCHAR awcTmpBuf[MAX_PATH];
323  WCHAR awcTmp[MAX_PATH];
324  FLONG fl;
325  WCHAR *pwcTmp;
326 
327  #if DBG
328  BOOL bOk;
329  #endif
330 
331  if (bMakePathNameW(awcTmp, pwcFile,NULL, &fl))
332  {
333  // If the font is in the system subdirectory we will just move it
334  // to the fonts subdirectory. The path in the registry is relative
335  // and we will leave it alone.
336 
337  if
338  (
339  (fl & (FONT_IN_SYSTEM_DIR | FONT_RELATIVE_PATH)) ==
340  (FONT_IN_SYSTEM_DIR | FONT_RELATIVE_PATH)
341  )
342  {
343  // find the bare file part, this is what will be written
344  // in the registry
345 
346  pwcTmp = &awcTmp[wcslen(awcTmp) - 1];
347  while ((pwcTmp >= awcTmp) && (*pwcTmp != L '\\') && (*pwcTmp != L ':'))
348  pwcTmp--;
349 
350  if (pwcTmp > awcTmp)
351  pwcTmp++;
352 
353  // need to move the font to fonts dir, can reuse the
354  // buffer on the stack to build the full destination path
355 
356  wcscpy(awcTmpBuf, gpwcFontsDir);
357  lstrcatW(awcTmpBuf, L "\\");
358  lstrcatW(awcTmpBuf, pwcTmp);
359 
360  // note that MoveFile should succeed, for if there was
361  // a font file of the same file name in %windir%\fonts dir
362  // we would not have been in this code path.
363 
364  #if DBG
365  bOk =
366  #endif
367  MoveFileW(awcTmp, awcTmpBuf);
368 
370  "move %ws to %ws %s",
371  awcTmp,
372  awcTmpBuf,
373  (bOk) ? "succeeded" : "failed");
374  }
375  #if DBG
376  else
377  {
379  "File %ws not in system directory, fl = 0x%lx\n",
380  awcTmp, fl);
381  }
382  #endif
383 
384  }
385  #if DBG
386  else
387  {
388  RIPMSG1( RIP_WARNING, "Could not locate %ws", pwcFile);
389  }
390  #endif
391 }

引用了 gpwcFontsDir, RIP_VERBOSE, RIP_WARNING, RIPMSG1, RIPMSG2 , 以及 RIPMSG3.

被这些函数引用 vProcessType1FontEntry().

◆ vProcessFontEntry()

VOID vProcessFontEntry (HKEY hkey,
WCHAR * pwcValueName,
WCHAR * pwcFileName 
)

在文件 fntsweep.c113 行定义.

118 {
119  BOOL bFot = FALSE;
120  WCHAR awcTTF[MAX_PATH];
121  WCHAR awcTmpBuf[MAX_PATH];
122  WCHAR *pwcTTF;
123  FLONG fl, fl2;
124  FLONG flEmbed;
125  DWORD dwPidTid;
126 
127  if ( bCheckFontEntry(pwcValueName, EXT_TRUETYPE))
128  {
129  // This is a tt entry, either .fot or .ttf
130 
131  if (bFot = bCheckFontEntry(pwcFileName, EXT_FOT))
132  {
133  // this is an .fot entry, must find ttf pointed to by .fot,
134  // but first must get the full path to the .fot file
135  // for cGetTTFFromFOT routine expects it. We will also need
136  // the full path to the .fot file so that we can delete it
137  // eventually.
138 
139  if (bMakePathNameW(awcTmpBuf, pwcFileName,NULL, &fl2))
140  {
141  if (cGetTTFFromFOT(awcTmpBuf, MAX_PATH, awcTTF, &fl, &flEmbed, &dwPidTid) &&
142  !(fl & FONT_ISNOT_FOT))
143  {
144  // fix the entry to point to .ttf file. At this point
145  // awcTTF points to the FULL path to the .ttf file.
146  // However, we will only need a relative path to the
147  // .ttf file, when the .ttf file is in the %windir%\system
148  // or %windir%\fonts directories. In case the file is in the
149  // %windir%\system directory we shall copy it to %windir%\fonts
150  // directory and write the relative path to the registry.
151  // In case it is in the %windir%\fonts directory we do not
152  // touch the file and also just write the relative path to the
153  // registry. In any other case we just write the full .ttf
154  // path to the registry.
155 
156  // first delete the .fot file, it is no longer needed
157 
158  if (bFot && ! gbWin31Upgrade)
159  {
160  UserVerify(DeleteFileW(awcTmpBuf));
161  }
162 
163  if ((fl & (FONT_IN_FONTS_DIR | FONT_IN_SYSTEM_DIR)) == 0)
164  {
165  // if ttf file is not in either the system or the fonts
166  // directories, just write the full path to the registry
167 
168  pwcTTF = awcTTF;
169  }
170  else
171  {
172  // find the bare file part, this is what will be written
173  // in the registry
174 
175  pwcTTF = &awcTTF[wcslen(awcTTF) - 1];
176  while ((pwcTTF >= awcTTF) && (*pwcTTF != L '\\') && (*pwcTTF != L ':'))
177  pwcTTF--;
178  pwcTTF++;
179 
180  if (fl & FONT_IN_SYSTEM_DIR)
181  {
182  // need to move the ttf to fonts dir, can reuse the
183  // buffer on the stack:
184 
185  wcscpy(awcTmpBuf, gpwcFontsDir);
186  lstrcatW(awcTmpBuf, L "\\");
187  lstrcatW(awcTmpBuf, pwcTTF);
188 
189  // note that MoveFile should succeed, for if there was
190  // a ttf file of the same file name in %windir%\fonts dir
191  // we would not have been in this code path.
192 
193  RIPMSG2( RIP_VERBOSE, "Moving %ws to %ws", awcTTF, awcTmpBuf);
194  if (! gbWin31Upgrade)
195  {
196  UserVerify(MoveFileW(awcTTF, awcTmpBuf));
197  }
198  else
199  {
200  // Boolean value TRUE means "do not copy if target exists"
201 
202  UserVerify(CopyFileW(awcTTF, awcTmpBuf, TRUE));
203  }
204  }
205  }
206 
207  RIPMSG2( RIP_VERBOSE, "writing to the registry:\n %ws=%ws", pwcValueName, pwcTTF);
208  UserVerify(ERROR_SUCCESS ==
209  RegSetValueExW(
210  hkey, // here is the key
211  pwcValueName,
212  0,
213  REG_SZ,
214  (CONST BYTE*) pwcTTF,
215  ( DWORD)((wcslen(pwcTTF)+1) * sizeof(WCHAR))));
216  }
217  #ifdef DEBUG
218  else
219  {
220  RIPMSG1( RIP_WARNING, "Could not locate ttf pointed to by %ws", awcTmpBuf);
221  }
222  #endif
223  }
224  #ifdef DEBUG
225  else
226  {
227  RIPMSG1( RIP_WARNING, "Could not locate .fot: %ws", pwcFileName);
228  }
229  #endif
230  }
231  }
232  else
233  {
234  // not a true type case. little bit simpler,
235  // we will use awcTTF buffer for the full path name, and pwcTTF
236  // as local variable even though these TTF names are misnomer
237  // for these are not tt fonts
238 
239  if (bMakePathNameW(awcTTF, pwcFileName,NULL, &fl))
240  {
241  // At this point
242  // awcTTF points to the FULL path to the font file.
243 
244  // If the font is in the system subdirectory we will just move it
245  // to the fonts subdirectory. If the path in the registry is relative
246  // we will leave it alone. If it is an absolute path, we shall
247  // fix the registry entry to only contain relative path, the
248  // absolute path is redundant.
249 
250  if (fl & (FONT_IN_SYSTEM_DIR | FONT_IN_FONTS_DIR))
251  {
252  // find the bare file part, this is what will be written
253  // in the registry
254 
255  pwcTTF = &awcTTF[wcslen(awcTTF) - 1];
256  while ((pwcTTF >= awcTTF) && (*pwcTTF != L '\\') && (*pwcTTF != L ':'))
257  pwcTTF--;
258  pwcTTF++;
259 
260  if (fl & FONT_IN_SYSTEM_DIR)
261  {
262  // need to move the font to fonts dir, can reuse the
263  // buffer on the stack to build the full destination path
264 
265  wcscpy(awcTmpBuf, gpwcFontsDir);
266  lstrcatW(awcTmpBuf, L "\\");
267  lstrcatW(awcTmpBuf, pwcTTF);
268 
269  // note that MoveFile should succeed, for if there was
270  // a font file of the same file name in %windir%\fonts dir
271  // we would not have been in this code path. The only time
272  // it could fail if the path in the registry is absolute.
273 
274  RIPMSG2( RIP_VERBOSE, "Moving %ws to %ws", awcTTF, awcTmpBuf);
275  if (! gbWin31Upgrade)
276  {
277  UserVerify(MoveFileW(awcTTF, awcTmpBuf));
278  }
279  else
280  {
281  // Boolean value TRUE means "do not copy if target exists"
282 
283  UserVerify(CopyFileW(awcTTF, awcTmpBuf, TRUE));
284  }
285  }
286 
287  // check if the file path in the registry is absolute,
288  // if so make it relative:
289 
290  if (!(fl & FONT_RELATIVE_PATH))
291  {
292  RIPMSG2( RIP_VERBOSE, "writing to the registry:\n %ws=%ws", pwcValueName, pwcTTF);
293  UserVerify(ERROR_SUCCESS ==
294  RegSetValueExW(
295  hkey, // here is the key
296  pwcValueName,
297  0,
298  REG_SZ,
299  (CONST BYTE*) pwcTTF,
300  ( DWORD)((wcslen(pwcTTF)+1) * sizeof(WCHAR))));
301  }
302  }
303  }
304  }
305 }

引用了 bCheckFontEntry(), DWORD, EXT_FOT, EXT_TRUETYPE, gbWin31Upgrade, gpwcFontsDir, RIP_VERBOSE, RIP_WARNING, RIPMSG1, RIPMSG2 , 以及 UserVerify.

被这些函数引用 vFontSweep().

◆ vProcessType1FontEntry()

VOID vProcessType1FontEntry (HKEY hkey,
WCHAR * pwcValueName,
WCHAR * pwcValueData 
)

在文件 fntsweep.c410 行定义.

415 {
416  WCHAR *pwcPFM, *pwcPFB;
417 
418  // skip unused boolean value in this multi reg_sz string:
419 
420  if ((pwcValueData[0] != L '\0') && (pwcValueData[1] == L '\0'))
421  {
422  pwcPFM = &pwcValueData[2];
423  pwcPFB = pwcPFM + wcslen(pwcPFM) + 1; // add 1 for zero separator
424 
427  }
428 }

引用了 vMoveFileFromSystemToFontsDir().

被这些函数引用 vFontSweep().

◆ vSweepFonts()

VOID vSweepFonts (WCHAR * pwszFontListKey,
WCHAR * pwszFontSweepKey,
PFNENTRY pfnProcessFontEntry,
BOOL bForceEnum 
)

在文件 fntsweep.c522 行定义.

528 {
529  LONG lRet;
530  WCHAR awcClass[MAX_PATH] = L "";
531  DWORD cwcClassName = MAX_PATH;
532  DWORD cSubKeys;
533  DWORD cjMaxSubKey;
534  DWORD cwcMaxClass;
535  DWORD cValues = 0;
536  DWORD cwcMaxValueName, cjMaxValueName;
537  DWORD cjMaxValueData;
538  DWORD cjSecurityDescriptor;
539  DWORD iFont;
540 
541  WCHAR *pwcValueName;
542  BYTE *pjValueData;
543  DWORD cwcValueName, cjValueData;
544 
545  HKEY hkey = NULL;
546  FILETIME ftLastWriteTime;
547  FILETIME ftLastSweepTime;
548  BOOL bSweep = FALSE;
549 
550  HKEY hkeyLastSweep;
551  DWORD dwType;
552  DWORD cjData;
553 
554  if (!bForceEnum)
555  {
556  // first check if anything needs to be done, that is, if anybody
557  // touched the [Fonts] section of the registry since the last time we sweeped it.
558  // get the time of the last sweep of the fonts section of the registry:
559 
560  lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, // Root key
561  pwszFontSweepKey, // Subkey to open
562  0L, // Reserved
563  KEY_READ|KEY_WRITE, // SAM
564  &hkeyLastSweep); // return handle
565 
566  if (lRet != ERROR_SUCCESS)
567  {
568  DWORD dwDisposition;
569 
570  // We are running for the first time, we need to create the key
571  // for it does not exist as yet at this time
572 
573  bSweep = TRUE;
574 
575  // Create the key, open it for writing, since we will have to
576  // store the time when the [Fonts] section of the registry was last swept
577 
578  lRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE,
579  pwszFontSweepKey,
580  0,
581  REG_OPTION_NON_VOLATILE,
582  0,
583  KEY_WRITE,
584  NULL,
585  &hkeyLastSweep,
586  &dwDisposition
587  );
588 
589  if (lRet != ERROR_SUCCESS)
590  return;
591  }
592  else
593  {
594  lRet = RegQueryValueExW(hkeyLastSweep,
596  NULL,
597  &dwType,
598  (LPBYTE)&ftLastSweepTime,
599  &cjData
600  );
601  if (lRet != ERROR_SUCCESS)
602  {
603  bSweep = TRUE; // force sweep, something is suspicious
604  }
605  #if DBG
606  else
607  {
608  UserAssert(dwType == REG_BINARY);
609  UserAssert(cjData == sizeof(ftLastSweepTime));
610  }
611  #endif // DBG
612  }
613  }
614  else
615  {
616  bSweep = TRUE;
617  }
618 
619  // now open the Fonts key and get the time the key last changed:
620  // now get the time of the time of the last change is bigger than
621  // the time of last sweep, must sweep again:
622 
623  lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, // Root key
624  pwszFontListKey, // Subkey to open
625  0L, // Reserved
626  KEY_READ|KEY_WRITE, // SAM
627  &hkey); // return handle
628 
629  if (lRet == ERROR_SUCCESS)
630  {
631  // get the number of entries in the [Fonts] section
632 
633  lRet = RegQueryInfoKeyW(
634  hkey,
635  awcClass, // "" on return
636  &cwcClassName, // 0 on return
637  NULL,
638  &cSubKeys, // 0 on return
639  &cjMaxSubKey, // 0 on return
640  &cwcMaxClass, // 0 on return
641  &cValues, // == cFonts, if all of them are present
642  &cwcMaxValueName, // longest value name
643  &cjMaxValueData, // longest value data
644  &cjSecurityDescriptor, // security descriptor,
645  &ftLastWriteTime
646  );
647 
648  if ((lRet == ERROR_SUCCESS) && cValues)
649  {
650  UserAssert(!(cwcClassName | cSubKeys | cjMaxSubKey | cwcMaxClass | awcClass[0]));
651 
652  // now let us check if the fonts need to be sweeped. This is the case
653  // when the registry last write time is bigger than the last sweep time
654 
655  if (!bSweep)
656  {
657  switch(CompareFileTime(&ftLastWriteTime, &ftLastSweepTime))
658  {
659  case 1:
660  bSweep = TRUE;
661  break;
662  case 0:
663  bSweep = FALSE;
664  break;
665  case -1:
666 
667  // Error condition, this should not have happened,
668  // we will sweep just to be safe.
669 
670  bSweep = TRUE;
671  break;
672  }
673  }
674 
675  // init system dir, we will need it:
676 
677  if (bSweep &&
678  bInitSystemAndFontsDirectoriesW(& gpwcSystemDir, & gpwcFontsDir))
679  {
680  // alloc buffer big enough to hold the biggest ValueName and ValueData
681 
682  cjMaxValueName = DWORDALIGN((cwcMaxValueName+1) * sizeof(WCHAR));
683 
684  // allocate temporary buffer into which we are going to suck the contents
685  // of the registry
686 
687  cjMaxValueData = DWORDALIGN(cjMaxValueData);
688  cjData = cjMaxValueName + // space for the value name
689  cjMaxValueData ; // space for the value data
690 
691  #if DBG
692  {
693  dwType = sizeof(WCHAR) * MAX_PATH;
694  UserAssert((dwType & 3) == 0);
695  }
696  #endif
697 
698  if (pwcValueName = LocalAlloc(LMEM_FIXED,cjData))
699  {
700  // data goes into the second half of the buffer
701 
702  pjValueData = (BYTE *)pwcValueName + cjMaxValueName;
703 
704  for (iFont = 0; iFont < cValues; iFont++)
705  {
706  // make sure to let RegEnumValueW the size of buffers
707 
708  // Note that this is bizzare, on input RegEnumValueW expects
709  // the size in BYTE's of the ValueName buffer
710  // (including the terminating zero),
711  // on return RegEnumValueW returns the number of WCHAR's
712  // NOT including the terminating zero.
713 
714  cwcValueName = cjMaxValueName; // bizzare
715  cjValueData = cjMaxValueData;
716 
717  lRet = RegEnumValueW(
718  hkey,
719  iFont,
720  pwcValueName,
721  &cwcValueName,
722  NULL, // reserved
723  &dwType,
724  pjValueData,
725  &cjValueData
726  );
727 
728  if (lRet == ERROR_SUCCESS)
729  {
730  UserAssert(cwcValueName <= cwcMaxValueName);
731  UserAssert(cjValueData <= cjMaxValueData);
732  UserAssert((dwType == REG_SZ) || (dwType == REG_MULTI_SZ));
733 
734  // see if the font files are where the registry claims they are.
735  // It is unfortunate we have to do this because SearchPathW
736  // is slow because it touches the disk.
737 
738  (*pfnProcessFontEntry)(hkey, pwcValueName, (WCHAR *)pjValueData);
739  }
740  }
741 
742  if (!bForceEnum)
743  {
744  // now that the sweep is completed, get the last write time
745  // and store it as the LastSweepTime at the appropriate location
746 
747  lRet = RegQueryInfoKeyW(
748  hkey,
749  awcClass, // "" on return
750  &cwcClassName, // 0 on return
751  NULL,
752  &cSubKeys, // 0 on return
753  &cjMaxSubKey, // 0 on return
754  &cwcMaxClass, // 0 on return
755  &cValues, // == cFonts, if all of them are present
756  &cwcMaxValueName, // longest value name
757  &cjMaxValueData, // longest value data
758  &cjSecurityDescriptor, // security descriptor,
759  &ftLastWriteTime
760  );
761  UserAssert(lRet == ERROR_SUCCESS);
762 
763  // now remember the result
764 
765  lRet = RegSetValueExW(
766  hkeyLastSweep, // here is the key
768  0,
769  REG_BINARY,
770  (CONST BYTE*)&ftLastWriteTime,
771  sizeof(ftLastWriteTime));
772  UserAssert(lRet == ERROR_SUCCESS);
773  }
774 
775  // free the memory that will be no longer needed
776 
777  LocalFree(pwcValueName);
778  }
779  }
780  }
781  RegCloseKey(hkey);
782  }
783 
784  if (!bForceEnum)
785  {
786  RegCloseKey(hkeyLastSweep);
787  }
788 }

引用了 DWORD, DWORDALIGN, gpwcFontsDir, gpwcSystemDir, LAST_SWEEP_TIME , 以及 UserAssert.

被这些函数引用 vFontSweep() , 以及 vLoadT1Fonts().

变量说明

◆ gbWin31Upgrade

BOOL gbWin31Upgrade = FALSE

在文件 fntsweep.c38 行定义.

被这些函数引用 vFontSweep() , 以及 vProcessFontEntry().

◆ gpwcFontsDir

WCHAR* gpwcFontsDir = NULL

在文件 fntsweep.c37 行定义.

被这些函数引用 vMoveFileFromSystemToFontsDir(), vProcessFontEntry() , 以及 vSweepFonts().

◆ gpwcSystemDir

WCHAR* gpwcSystemDir = NULL

在文件 fntsweep.c36 行定义.

被这些函数引用 vFontSweep(), vLoadT1Fonts() , 以及 vSweepFonts().

◆ pwszFontDrivers

WCHAR pwszFontDrivers[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Font Drivers"

在文件 fntsweep.c30 行定义.

被这些函数引用 bLoadableFontDrivers().

◆ pwszFontsKey

WCHAR pwszFontsKey[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"

在文件 fntsweep.c28 行定义.

被这些函数引用 vFontSweep().

◆ pwszSweepKey

WCHAR pwszSweepKey[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontCache\\LastFontSweep"

在文件 fntsweep.c29 行定义.

被这些函数引用 vFontSweep().

◆ pwszSweepType1Key

WCHAR pwszSweepType1Key[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Type 1 Installer\\LastType1Sweep"

在文件 fntsweep.c26 行定义.

被这些函数引用 vFontSweep() , 以及 vLoadT1Fonts().

◆ pwszType1Key

WCHAR pwszType1Key[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Type 1 Installer\\Type 1 Fonts"

在文件 fntsweep.c25 行定义.

被这些函数引用 vFontSweep() , 以及 vLoadT1Fonts().

#define EXT_FOT
Definition: fntsweep.c:110
WCHAR pwszSweepType1Key[]
Definition: fntsweep.c:26
#define DWORDALIGN(X)
Definition: fntsweep.c:34
WCHAR pwszSweepKey[]
Definition: fntsweep.c:29
#define RIP_VERBOSE
Definition: winerrp.h:30
WCHAR pwszFontDrivers[]
Definition: fntsweep.c:30
#define LAST_SWEEP_TIME
Definition: fntsweep.c:32
WCHAR pwszFontsKey[]
Definition: fntsweep.c:28
BOOL gbWin31Upgrade
Definition: fntsweep.c:38
VOID vProcessFontEntry(HKEY hkey, WCHAR *pwcValueName, WCHAR *pwcFileName)
Definition: fntsweep.c:113
#define RIPMSG3(flags, szFmt, p1, p2, p3)
Definition: winerrp.h:134
#define UserAssert(exp)
Definition: usersrv.h:117
#define RIPMSG1(flags, szFmt, p1)
Definition: winerrp.h:132
#define UserVerify(exp)
Definition: winerrp.h:138
WCHAR * gpwcSystemDir
Definition: fntsweep.c:36
BOOL bCheckIfDualBootingWithWin31()
Definition: fntsweep.c:41
ddeml v[i< inst >][t< type >][hObj|pObj] Dump DDEML state information ddeml lists all ddeml instances for this process n ddeml t< type > lists all ddeml objects of the given type n n assumes link is first DWORD
Definition: exts.h:175
WCHAR pwszType1Key[]
Definition: fntsweep.c:25
VOID vAddType1Font(WCHAR *pwcValueData, DWORD dwFlags)
Definition: fntsweep.c:442
VOID vMoveFileFromSystemToFontsDir(WCHAR *pwcFile)
Definition: fntsweep.c:320
VOID vAddRemoteType1Font(HKEY hkey, WCHAR *pwcValueName, WCHAR *pwcValueData)
Definition: fntsweep.c:484
VOID vLoadT1Fonts(PFNENTRY pfnProcessFontEntry)
Definition: fntsweep.c:920
#define RIP_WARNING
Definition: winerrp.h:29
WCHAR * gpwcFontsDir
Definition: fntsweep.c:37
VOID vSweepFonts(WCHAR *pwszFontListKey, WCHAR *pwszFontSweepKey, PFNENTRY pfnProcessFontEntry, BOOL bForceEnum)
Definition: fntsweep.c:522
VOID vAddLocalType1Font(HKEY hkey, WCHAR *pwcValueName, WCHAR *pwcValueData)
Definition: fntsweep.c:495
typedef UINT(FAR WINAPI *MSGSOUNDPROC)()
#define RIPMSG2(flags, szFmt, p1, p2)
Definition: winerrp.h:133
BOOL bLoadableFontDrivers()
Definition: fntsweep.c:810
BOOL bCheckFontEntry(WCHAR *pwcName, WCHAR *pwcExtension)
Definition: fntsweep.c:87
VOID vProcessType1FontEntry(HKEY hkey, WCHAR *pwcValueName, WCHAR *pwcValueData)
Definition: fntsweep.c:410
#define EXT_TRUETYPE
Definition: fntsweep.c:109

一键复制

编辑

Web IDE

原始数据

按行查看

历史

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值