mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 14:53:40 +00:00
[WIN32K]
- Remove a wrong ASSERT - Improve EngLoadImageEx to correctly handle the path and optional dll extension. - Get rid of EngLoadDriver svn path=/branches/reactos-yarotows/; revision=49245
This commit is contained in:
parent
b0dd54e446
commit
548559a3d5
5 changed files with 44 additions and 28 deletions
|
@ -122,7 +122,7 @@ EngpRegisterGraphicsDevice(
|
||||||
{
|
{
|
||||||
DPRINT1("trying driver: %ls\n", pwsz);
|
DPRINT1("trying driver: %ls\n", pwsz);
|
||||||
/* Try to load the display driver */
|
/* Try to load the display driver */
|
||||||
pldev = EngLoadDriver(pwsz, LDEV_DEVICE_DISPLAY);
|
pldev = EngLoadImageEx(pwsz, LDEV_DEVICE_DISPLAY);
|
||||||
if (!pldev)
|
if (!pldev)
|
||||||
{
|
{
|
||||||
DPRINT1("Could not load driver: '%ls'\n", pwsz);
|
DPRINT1("Could not load driver: '%ls'\n", pwsz);
|
||||||
|
|
|
@ -185,8 +185,9 @@ LDEVOBJ_bLoadImage(
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Failed to load a GDI driver: '%S'\n", pstrPathName->Buffer);
|
DPRINT1("Failed to load a GDI driver: '%S', Status = 0x%lx\n",
|
||||||
ASSERT(FALSE);
|
pstrPathName->Buffer, Status);
|
||||||
|
|
||||||
/* Free the allocated memory */
|
/* Free the allocated memory */
|
||||||
ExFreePoolWithTag(pDriverInfo, TAG_LDEV);
|
ExFreePoolWithTag(pDriverInfo, TAG_LDEV);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -322,13 +323,47 @@ EngLoadImageEx(
|
||||||
LPWSTR pwszDriverName,
|
LPWSTR pwszDriverName,
|
||||||
ULONG ldevtype)
|
ULONG ldevtype)
|
||||||
{
|
{
|
||||||
|
WCHAR acwBuffer[MAX_PATH];
|
||||||
PLDEVOBJ pldev;
|
PLDEVOBJ pldev;
|
||||||
UNICODE_STRING strDriverName;
|
UNICODE_STRING strDriverName;
|
||||||
|
ULONG cwcLength;
|
||||||
|
LPWSTR pwsz;
|
||||||
|
|
||||||
DPRINT("EngLoadImageEx(%ls, %ld)\n", pwszDriverName, ldevtype);
|
DPRINT("EngLoadImageEx(%ls, %ld)\n", pwszDriverName, ldevtype);
|
||||||
|
ASSERT(pwszDriverName);
|
||||||
|
|
||||||
/* Initialize the driver name */
|
/* Initialize buffer for the the driver name */
|
||||||
RtlInitUnicodeString(&strDriverName, pwszDriverName);
|
RtlInitEmptyUnicodeString(&strDriverName, acwBuffer, sizeof(acwBuffer));
|
||||||
|
|
||||||
|
/* Start path with systemroot */
|
||||||
|
RtlAppendUnicodeToString(&strDriverName, L"\\SystemRoot\\System32\\");
|
||||||
|
|
||||||
|
/* Get Length of given string */
|
||||||
|
cwcLength = wcslen(pwszDriverName);
|
||||||
|
|
||||||
|
/* Check if we have a system32 path given */
|
||||||
|
pwsz = pwszDriverName + cwcLength;
|
||||||
|
while (pwsz > pwszDriverName)
|
||||||
|
{
|
||||||
|
if (_wcsnicmp(pwsz, L"\\system32\\", 10) == 0)
|
||||||
|
{
|
||||||
|
/* Driver name starts after system32 */
|
||||||
|
pwsz += 10;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pwsz--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Append the driver name */
|
||||||
|
RtlAppendUnicodeToString(&strDriverName, pwsz);
|
||||||
|
|
||||||
|
/* MSDN says "The driver must include this suffix in the pwszDriver string."
|
||||||
|
But in fact it's optional. */
|
||||||
|
if (_wcsnicmp(pwszDriverName + cwcLength - 4, L".dll", 4) != 0)
|
||||||
|
{
|
||||||
|
/* Append the .dll suffix */
|
||||||
|
RtlAppendUnicodeToString(&strDriverName, L".dll");
|
||||||
|
}
|
||||||
|
|
||||||
/* Lock loader */
|
/* Lock loader */
|
||||||
EngAcquireSemaphore(ghsemLDEVList);
|
EngAcquireSemaphore(ghsemLDEVList);
|
||||||
|
@ -339,7 +374,7 @@ EngLoadImageEx(
|
||||||
/* Check if the ldev is associated with a file */
|
/* Check if the ldev is associated with a file */
|
||||||
if (pldev->pGdiDriverInfo)
|
if (pldev->pGdiDriverInfo)
|
||||||
{
|
{
|
||||||
/* Check for match */
|
/* Check for match (case insensative) */
|
||||||
if (RtlEqualUnicodeString(&pldev->pGdiDriverInfo->DriverName, &strDriverName, 1))
|
if (RtlEqualUnicodeString(&pldev->pGdiDriverInfo->DriverName, &strDriverName, 1))
|
||||||
{
|
{
|
||||||
/* Image found in LDEV list */
|
/* Image found in LDEV list */
|
||||||
|
@ -399,25 +434,6 @@ leave:
|
||||||
return pldev;
|
return pldev;
|
||||||
}
|
}
|
||||||
|
|
||||||
PLDEVOBJ
|
|
||||||
APIENTRY
|
|
||||||
EngLoadDriver(
|
|
||||||
LPWSTR pwszDriverName,
|
|
||||||
ULONG ldevtype)
|
|
||||||
{
|
|
||||||
WCHAR acwBuffer[MAX_PATH];
|
|
||||||
PLDEVOBJ pldev;
|
|
||||||
|
|
||||||
ASSERT(pwszDriverName);
|
|
||||||
DPRINT("EngLoadDriver(%ls, %ld)\n", pwszDriverName, ldevtype);
|
|
||||||
|
|
||||||
/* Create a full file name */ // FIXME: do better than that
|
|
||||||
swprintf(acwBuffer, L"\\SystemRoot\\System32\\%ls.dll", pwszDriverName);
|
|
||||||
|
|
||||||
pldev = EngLoadImageEx(acwBuffer, ldevtype);
|
|
||||||
|
|
||||||
return pldev;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Exported functions ********************************************************/
|
/** Exported functions ********************************************************/
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,7 @@ EngpCreatePDEV(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to get a diplay driver */
|
/* Try to get a diplay driver */
|
||||||
ppdev->pldev = EngLoadDriver(pdm->dmDeviceName, LDEV_DEVICE_DISPLAY);
|
ppdev->pldev = EngLoadImageEx(pdm->dmDeviceName, LDEV_DEVICE_DISPLAY);
|
||||||
if (!ppdev->pldev)
|
if (!ppdev->pldev)
|
||||||
{
|
{
|
||||||
DPRINT1("Could not load display driver '%ls'\n",
|
DPRINT1("Could not load display driver '%ls'\n",
|
||||||
|
|
|
@ -173,7 +173,7 @@ SURFACE_AllocSurface(
|
||||||
pso->iType = iType;
|
pso->iType = iType;
|
||||||
pso->iUniq = InterlockedIncrement((PLONG)&giUniqueSurface);
|
pso->iUniq = InterlockedIncrement((PLONG)&giUniqueSurface);
|
||||||
|
|
||||||
/* Assign a default palette amd increment its reference count */
|
/* Assign a default palette and increment its reference count */
|
||||||
psurf->ppal = appalSurfaceDefault[iFormat];
|
psurf->ppal = appalSurfaceDefault[iFormat];
|
||||||
GDIOBJ_IncrementShareCount(&psurf->ppal->BaseObject);
|
GDIOBJ_IncrementShareCount(&psurf->ppal->BaseObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ InitLDEVImpl();
|
||||||
|
|
||||||
PLDEVOBJ
|
PLDEVOBJ
|
||||||
APIENTRY
|
APIENTRY
|
||||||
EngLoadDriver(
|
EngLoadImageEx(
|
||||||
LPWSTR pwszDriverName,
|
LPWSTR pwszDriverName,
|
||||||
ULONG ldevtype);
|
ULONG ldevtype);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue