mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 20:55:16 +00:00
[GDI32][WIN32K:NTGDI]
- Correctly handle relative paths passed to AddFontResource*. - Fix the user->kernel interface between GdiAddFontResourceW and NtGdiAddFontResourceW Patch by Víctor Martínez Calvo. CORE-9079 svn path=/trunk/; revision=67353
This commit is contained in:
parent
0d91854d88
commit
a6840dcddd
|
@ -10,6 +10,7 @@
|
||||||
#include <precomp.h>
|
#include <precomp.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
@ -2181,7 +2182,7 @@ NewEnumFontFamiliesExW(
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
WINAPI
|
WINAPI
|
||||||
|
@ -2190,7 +2191,45 @@ GdiAddFontResourceW(
|
||||||
FLONG fl,
|
FLONG fl,
|
||||||
DESIGNVECTOR *pdv)
|
DESIGNVECTOR *pdv)
|
||||||
{
|
{
|
||||||
return NtGdiAddFontResourceW((PWSTR)lpszFilename, 0, 0, fl, 0, pdv);
|
INT Ret;
|
||||||
|
WCHAR lpszBuffer[MAX_PATH];
|
||||||
|
WCHAR lpszAbsPath[MAX_PATH];
|
||||||
|
UNICODE_STRING NtAbsPath;
|
||||||
|
|
||||||
|
/* FIXME: We don't support multiple files passed in lpszFilename
|
||||||
|
* as L"abcxxxxx.pfm|abcxxxxx.pfb"
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Does the file exist in CurrentDirectory or in the Absolute Path passed? */
|
||||||
|
GetCurrentDirectoryW(MAX_PATH, lpszBuffer);
|
||||||
|
|
||||||
|
if (!SearchPathW(lpszBuffer, lpszFilename, NULL, MAX_PATH, lpszAbsPath, NULL))
|
||||||
|
{
|
||||||
|
/* Nope. Then let's check Fonts folder */
|
||||||
|
GetWindowsDirectoryW(lpszBuffer, MAX_PATH);
|
||||||
|
StringCbCatW(lpszBuffer, sizeof(lpszBuffer), L"\\Fonts");
|
||||||
|
|
||||||
|
if (!SearchPathW(lpszBuffer, lpszFilename, NULL, MAX_PATH, lpszAbsPath, NULL))
|
||||||
|
{
|
||||||
|
DPRINT1("Font not found. The Buffer is: %ls, the FileName is: %S", lpszBuffer, lpszFilename);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We found the font file so: */
|
||||||
|
if (!RtlDosPathNameToNtPathName_U(lpszAbsPath, &NtAbsPath, NULL, NULL))
|
||||||
|
{
|
||||||
|
DPRINT1("Can't convert Path! Path: %ls\n", lpszAbsPath);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The Nt call expects a null-terminator included in cwc param. */
|
||||||
|
ASSERT(NtAbsPath.Buffer[NtAbsPath.Length / sizeof(WCHAR)] == UNICODE_NULL);
|
||||||
|
Ret = NtGdiAddFontResourceW(NtAbsPath.Buffer, NtAbsPath.Length / sizeof(WCHAR) + 1, 1, fl, 0, pdv);
|
||||||
|
|
||||||
|
RtlFreeUnicodeString(&NtAbsPath);
|
||||||
|
|
||||||
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -427,7 +427,7 @@ RealizeFontInit(HFONT hFont)
|
||||||
INT
|
INT
|
||||||
APIENTRY
|
APIENTRY
|
||||||
NtGdiAddFontResourceW(
|
NtGdiAddFontResourceW(
|
||||||
IN WCHAR *pwszFiles,
|
IN WCHAR *pwcFiles,
|
||||||
IN ULONG cwc,
|
IN ULONG cwc,
|
||||||
IN ULONG cFiles,
|
IN ULONG cFiles,
|
||||||
IN FLONG fl,
|
IN FLONG fl,
|
||||||
|
@ -435,37 +435,40 @@ NtGdiAddFontResourceW(
|
||||||
IN OPTIONAL DESIGNVECTOR *pdv)
|
IN OPTIONAL DESIGNVECTOR *pdv)
|
||||||
{
|
{
|
||||||
UNICODE_STRING SafeFileName;
|
UNICODE_STRING SafeFileName;
|
||||||
PWSTR src;
|
INT Ret;
|
||||||
NTSTATUS Status;
|
|
||||||
int Ret;
|
|
||||||
|
|
||||||
/* FIXME: Protect with SEH? */
|
DBG_UNREFERENCED_PARAMETER(cFiles);
|
||||||
RtlInitUnicodeString(&SafeFileName, pwszFiles);
|
DBG_UNREFERENCED_PARAMETER(dwPidTid);
|
||||||
|
DBG_UNREFERENCED_PARAMETER(pdv);
|
||||||
|
|
||||||
/* Reserve for prepending '\??\' */
|
/* cwc = Length + trailing zero. */
|
||||||
SafeFileName.Length += 4 * sizeof(WCHAR);
|
if (cwc <= 1 || cwc > UNICODE_STRING_MAX_CHARS)
|
||||||
SafeFileName.MaximumLength += 4 * sizeof(WCHAR);
|
return 0;
|
||||||
|
|
||||||
src = SafeFileName.Buffer;
|
SafeFileName.MaximumLength = cwc * sizeof(WCHAR);
|
||||||
SafeFileName.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, SafeFileName.MaximumLength, TAG_STRING);
|
SafeFileName.Length = SafeFileName.MaximumLength - sizeof(UNICODE_NULL);
|
||||||
if(!SafeFileName.Buffer)
|
SafeFileName.Buffer = ExAllocatePoolWithTag(PagedPool,
|
||||||
|
SafeFileName.MaximumLength,
|
||||||
|
TAG_STRING);
|
||||||
|
if (!SafeFileName.Buffer)
|
||||||
{
|
{
|
||||||
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepend '\??\' */
|
_SEH2_TRY
|
||||||
RtlCopyMemory(SafeFileName.Buffer, L"\\??\\", 4 * sizeof(WCHAR));
|
{
|
||||||
|
ProbeForRead(pwcFiles, cwc * sizeof(WCHAR), sizeof(WCHAR));
|
||||||
Status = MmCopyFromCaller(SafeFileName.Buffer + 4, src, SafeFileName.MaximumLength - (4 * sizeof(WCHAR)));
|
RtlCopyMemory(SafeFileName.Buffer, pwcFiles, SafeFileName.Length);
|
||||||
if(!NT_SUCCESS(Status))
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
|
ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
|
||||||
SetLastNtError(Status);
|
_SEH2_YIELD(return 0);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
|
||||||
Ret = IntGdiAddFontResource(&SafeFileName, (DWORD)fl);
|
SafeFileName.Buffer[SafeFileName.Length / sizeof(WCHAR)] = UNICODE_NULL;
|
||||||
|
Ret = IntGdiAddFontResource(&SafeFileName, fl);
|
||||||
|
|
||||||
ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
|
ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
|
||||||
return Ret;
|
return Ret;
|
||||||
|
|
Loading…
Reference in a new issue