ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
April 2010
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
22 participants
435 discussions
Start a n
N
ew thread
[sir_richard] 46987: [NTOS]: MiFindExportedRoutineByName should validate the ordinal to make sure it's not higher than the function count. [NTOS]: Use MM_SYSLDR_ defines instead of magic pointer casts. Use appropriate pool tags. [NTOS]: Set the LoadedImport count early-on during image referencing, so that failure will correctly de-reference the imports. By setting it to zero, failures would've leaked driver-dependent DLLs already loaded but now useless. [NTOS]: Do the same checks as Windows to a
by sir_richard@svn.reactos.org
Author: sir_richard Date: Thu Apr 22 05:54:09 2010 New Revision: 46987 URL:
http://svn.reactos.org/svn/reactos?rev=46987&view=rev
Log: [NTOS]: MiFindExportedRoutineByName should validate the ordinal to make sure it's not higher than the function count. [NTOS]: Use MM_SYSLDR_ defines instead of magic pointer casts. Use appropriate pool tags. [NTOS]: Set the LoadedImport count early-on during image referencing, so that failure will correctly de-reference the imports. By setting it to zero, failures would've leaked driver-dependent DLLs already loaded but now useless. [NTOS]: Do the same checks as Windows to avoid drivers linked with user-mode DLLs. [NTOS]: Allow "coverage" and "irt" to be linked with Win32K drivers as well. [NTOS]: When the linker is fixed not to generate corrupt drivers, add the appropriate code to scan IMAGE_DIRECTORY_ENTRY_IAT for updating thunks. A hack exists in ReactOS now to permit loading these hacked drivers, but Windows is not so generous and will crash with a ReactOS driver. Modified: trunk/reactos/ntoskrnl/mm/sysldr.c Modified: trunk/reactos/ntoskrnl/mm/sysldr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/sysldr.c?rev=4…
============================================================================== --- trunk/reactos/ntoskrnl/mm/sysldr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/sysldr.c [iso-8859-1] Thu Apr 22 05:54:09 2010 @@ -509,6 +509,9 @@ /* Otherwise, this is the ordinal */ Ordinal = OrdinalTable[Mid]; + /* Validate the ordinal */ + if (Ordinal >= ExportDirectory->NumberOfFunctions) return NULL; + /* Resolve the address and write it */ ExportTable = (PULONG)((ULONG_PTR)DllBase + ExportDirectory->AddressOfFunctions); @@ -554,9 +557,9 @@ ULONG_PTR OldBaseTop, Delta; PLDR_DATA_TABLE_ENTRY LdrEntry; PLIST_ENTRY NextEntry; - ULONG ImportSize; + ULONG ImportSize, i; + PULONG_PTR ImageThunk; PIMAGE_IMPORT_DESCRIPTOR ImportDescriptor; - PULONG ImageThunk; /* Calculate the top and delta */ OldBaseTop = (ULONG_PTR)OldBase + Size - 1; @@ -571,8 +574,30 @@ LdrEntry = CONTAINING_RECORD(NextEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - +#ifdef _WORKING_LINKER_ + /* Get the IAT */ + ImageThunk = RtlImageDirectoryEntryToData(LdrEntry->DllBase, + TRUE, + IMAGE_DIRECTORY_ENTRY_IAT, + &ImportSize); + if (!ImageThunk) continue; + + /* Make sure we have an IAT */ + DPRINT("[Mm0]: Updating thunks in: %wZ\n", &LdrEntry->BaseDllName); + for (i = 0; i < ImportSize; i++, ImageThunk++) + { + /* Check if it's within this module */ + if ((*ImageThunk >= (ULONG_PTR)OldBase) && (*ImageThunk <= OldBaseTop)) + { + /* Relocate it */ + DPRINT("[Mm0]: Updating IAT at: %p. Old Entry: %p. New Entry: %p.\n", + ImageThunk, *ImageThunk, *ImageThunk + Delta); + *ImageThunk += Delta; + } + } +#else /* Get the import table */ + i = ImportSize; ImportDescriptor = RtlImageDirectoryEntryToData(LdrEntry->DllBase, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, @@ -605,6 +630,7 @@ /* Go to the next import */ ImportDescriptor++; } +#endif } } @@ -672,7 +698,7 @@ /* Get the hint and check if it's valid */ Hint = NameImport->Hint; if ((Hint < ExportDirectory->NumberOfNames) && - !(strcmp((PCHAR) NameImport->Name, (PCHAR)DllBase + NameTable[Hint]))) + !(strcmp((PCHAR)NameImport->Name, (PCHAR)DllBase + NameTable[Hint]))) { /* We have a match, get the ordinal number from here */ Ordinal = OrdinalTable[Hint]; @@ -843,7 +869,7 @@ NULL); /* Check if this driver was loaded at boot and didn't get imports parsed */ - if (LdrEntry->LoadedImports == (PVOID)-1) goto Done; + if (LdrEntry->LoadedImports == MM_SYSLDR_BOOT_LOADED) goto Done; /* We should still be alive */ ASSERT(LdrEntry->LoadCount != 0); @@ -870,6 +896,7 @@ } /* FIXME: Free the driver */ + DPRINT1("Leaking driver: %wZ\n", &LdrEntry->BaseDllName); //MmFreeSection(LdrEntry->DllBase); /* Check if we're linked in */ @@ -940,7 +967,7 @@ __FUNCTION__, ImageBase, ImageFileDirectory); /* Assume no imports */ - *LoadImports = (PVOID)-2; + *LoadImports = MM_SYSLDR_NO_IMPORTS; /* Get the import descriptor */ ImportDescriptor = RtlImageDirectoryEntryToData(ImageBase, @@ -965,11 +992,12 @@ LoadedImportsSize = ImportCount * sizeof(PVOID) + sizeof(SIZE_T); LoadedImports = ExAllocatePoolWithTag(PagedPool, LoadedImportsSize, - TAG_LDR_WSTR); + 'TDmM'); if (LoadedImports) { /* Zero it */ RtlZeroMemory(LoadedImports, LoadedImportsSize); + LoadedImports->Count = ImportCount; } } else @@ -989,15 +1017,31 @@ GdiLink = GdiLink | !(_strnicmp(ImportName, "win32k", sizeof("win32k") - 1)); - /* We can also allow dxapi */ + /* We can also allow dxapi (for Windows compat, allow IRT and coverage )*/ NormalLink = NormalLink | ((_strnicmp(ImportName, "win32k", sizeof("win32k") - 1)) && - (_strnicmp(ImportName, "dxapi", sizeof("dxapi") - 1))); + (_strnicmp(ImportName, "dxapi", sizeof("dxapi") - 1)) && + (_strnicmp(ImportName, "coverage", sizeof("coverage") - 1)) && + (_strnicmp(ImportName, "irt", sizeof("irt") - 1))); /* Check if this is a valid GDI driver */ if ((GdiLink) && (NormalLink)) { /* It's not, it's importing stuff it shouldn't be! */ + MiDereferenceImports(LoadedImports); + if (LoadedImports) ExFreePool(LoadedImports); + return STATUS_PROCEDURE_NOT_FOUND; + } + + /* Check for user-mode printer or video card drivers, which don't belong */ + if (!(_strnicmp(ImportName, "ntdll", sizeof("ntdll") - 1)) || + !(_strnicmp(ImportName, "winsrv", sizeof("winsrv") - 1)) || + !(_strnicmp(ImportName, "advapi32", sizeof("advapi32") - 1)) || + !(_strnicmp(ImportName, "kernel32", sizeof("kernel32") - 1)) || + !(_strnicmp(ImportName, "user32", sizeof("user32") - 1)) || + !(_strnicmp(ImportName, "gdi32", sizeof("gdi32") - 1))) + { + /* This is not kernel code */ MiDereferenceImports(LoadedImports); if (LoadedImports) ExFreePool(LoadedImports); return STATUS_PROCEDURE_NOT_FOUND; @@ -1079,7 +1123,7 @@ sizeof(UNICODE_NULL); DllName.Buffer = ExAllocatePoolWithTag(NonPagedPool, DllName.MaximumLength, - TAG_LDR_WSTR); + 'TDmM'); if (DllName.Buffer) { /* Setup the base length and copy it */ @@ -1091,13 +1135,13 @@ /* Now add the import name and null-terminate it */ RtlAppendStringToString((PSTRING)&DllName, (PSTRING)&NameString); - DllName.Buffer[(DllName.MaximumLength - 1) / sizeof(WCHAR)] = UNICODE_NULL; + DllName.Buffer[(DllName.MaximumLength - 1) / sizeof(WCHAR)] = UNICODE_NULL; /* Load the image */ Status = MmLoadSystemImage(&DllName, NamePrefix, NULL, - 0, + FALSE, (PVOID)&DllEntry, &DllBase); if (NT_SUCCESS(Status)) @@ -1160,8 +1204,8 @@ if (!(LdrEntry->Flags & LDRP_LOAD_IN_PROGRESS)) { /* Add the entry */ - LoadedImports->Entry[LoadedImports->Count] = LdrEntry; - LoadedImports->Count++; + LoadedImports->Entry[ImportCount] = LdrEntry; + ImportCount++; } } @@ -1230,7 +1274,8 @@ if (LoadedImports->Entry[i]) { /* Got an entry, OR it with 1 in case it's the single entry */ - ImportEntry = (PVOID)((ULONG_PTR)LoadedImports->Entry[i] | 1); + ImportEntry = (PVOID)((ULONG_PTR)LoadedImports->Entry[i] | + MM_SYSLDR_SINGLE_ENTRY); ImportCount++; } } @@ -1240,7 +1285,7 @@ { /* Free the list and set it to no imports */ ExFreePoolWithTag(LoadedImports, TAG_LDR_WSTR); - LoadedImports = (PVOID)-2; + LoadedImports = MM_SYSLDR_NO_IMPORTS; } else if (ImportCount == 1) { @@ -1254,7 +1299,7 @@ LoadedImportsSize = ImportCount * sizeof(PVOID) + sizeof(SIZE_T); NewImports = ExAllocatePoolWithTag(PagedPool, LoadedImportsSize, - TAG_LDR_WSTR); + 'TDmM'); if (NewImports) { /* Set count */
14 years, 8 months
1
0
0
0
[tkreuzer] 46986: [WIN32K] - Call DC_vPrepareDCsForBlit in IntRectangle with device coordinates instead of in NtGdiRectangle with logical coordinates. Fixes updating mouse pointer. - Update TODO.txt
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Apr 22 05:53:49 2010 New Revision: 46986 URL:
http://svn.reactos.org/svn/reactos?rev=46986&view=rev
Log: [WIN32K] - Call DC_vPrepareDCsForBlit in IntRectangle with device coordinates instead of in NtGdiRectangle with logical coordinates. Fixes updating mouse pointer. - Update TODO.txt Modified: branches/reactos-yarotows/subsystems/win32/win32k/TODO.txt branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c Modified: branches/reactos-yarotows/subsystems/win32/win32k/TODO.txt URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/TODO.txt [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/TODO.txt [iso-8859-1] Thu Apr 22 05:53:49 2010 @@ -10,7 +10,6 @@ Before the merge: ----------------- -# Fix mouse pointer regression # Resize the desktop window after mode switch # Update mouse area after mode switch # Invalidate the whole Window content after mode switch Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] Thu Apr 22 05:53:49 2010 @@ -539,19 +539,6 @@ pdcattr = dc->pdcattr; - /* Do we rotate or shear? */ - if (!(dc->dclevel.mxWorldToDevice.flAccel & MX_SCALE)) - { - - POINTL DestCoords[4]; - ULONG PolyCounts = 4; - DestCoords[0].x = DestCoords[3].x = LeftRect; - DestCoords[0].y = DestCoords[1].y = TopRect; - DestCoords[1].x = DestCoords[2].x = RightRect; - DestCoords[2].y = DestCoords[3].y = BottomRect; - // Use IntGdiPolyPolygon so to support PATH. - return IntGdiPolyPolygon(dc, DestCoords, &PolyCounts, 1); - } // Rectangle Path only. if ( PATH_IsPathOpen(dc->dclevel) ) { @@ -577,6 +564,8 @@ DestRect.bottom--; } + DC_vPrepareDCsForBlit(dc, DestRect, NULL, DestRect); + if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) DC_vUpdateFillBrush(dc); @@ -590,6 +579,7 @@ ret = FALSE; goto cleanup; } + psurf = dc->dclevel.pSurface; if (!psurf) { @@ -655,6 +645,8 @@ } cleanup: + DC_vFinishBlit(dc, NULL); + /* Move current position in DC? MSDN: The current position is neither used nor updated by Rectangle. */ @@ -671,7 +663,6 @@ { DC *dc; BOOL ret; // default to failure - RECT rect = {LeftRect, TopRect, RightRect, BottomRect} ; dc = DC_LockDc(hDC); if (!dc) @@ -686,16 +677,25 @@ return TRUE; } - DC_vPrepareDCsForBlit(dc, rect, NULL, rect); - if (dc->pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) - DC_vUpdateFillBrush(dc); - - if (dc->pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY)) - DC_vUpdateLineBrush(dc); - - ret = IntRectangle ( dc, LeftRect, TopRect, RightRect, BottomRect ); - DC_vFinishBlit(dc, NULL); - DC_UnlockDc ( dc ); + /* Do we rotate or shear? */ + if (!(dc->dclevel.mxWorldToDevice.flAccel & MX_SCALE)) + { + POINTL DestCoords[4]; + ULONG PolyCounts = 4; + + DestCoords[0].x = DestCoords[3].x = LeftRect; + DestCoords[0].y = DestCoords[1].y = TopRect; + DestCoords[1].x = DestCoords[2].x = RightRect; + DestCoords[2].y = DestCoords[3].y = BottomRect; + // Use IntGdiPolyPolygon so to support PATH. + ret = IntGdiPolyPolygon(dc, DestCoords, &PolyCounts, 1); + } + else + { + ret = IntRectangle(dc, LeftRect, TopRect, RightRect, BottomRect ); + } + + DC_UnlockDc(dc); return ret; }
14 years, 8 months
1
0
0
0
[cgutman] 46985: [PCI] - Don't set DO_BUS_ENUMERATED_DEVICE on child PDOs because the PnP manager does it for us
by cgutman@svn.reactos.org
Author: cgutman Date: Thu Apr 22 01:19:12 2010 New Revision: 46985 URL:
http://svn.reactos.org/svn/reactos?rev=46985&view=rev
Log: [PCI] - Don't set DO_BUS_ENUMERATED_DEVICE on child PDOs because the PnP manager does it for us Modified: trunk/reactos/drivers/bus/pci/fdo.c Modified: trunk/reactos/drivers/bus/pci/fdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pci/fdo.c?rev=…
============================================================================== --- trunk/reactos/drivers/bus/pci/fdo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pci/fdo.c [iso-8859-1] Thu Apr 22 01:19:12 2010 @@ -239,8 +239,6 @@ break; } - Device->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE; - Device->Pdo->Flags &= ~DO_DEVICE_INITIALIZING; //Device->Pdo->Flags |= DO_POWER_PAGABLE;
14 years, 8 months
1
0
0
0
[cgutman] 46984: - Missed this from my last commit
by cgutman@svn.reactos.org
Author: cgutman Date: Thu Apr 22 00:42:21 2010 New Revision: 46984 URL:
http://svn.reactos.org/svn/reactos?rev=46984&view=rev
Log: - Missed this from my last commit Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.…
============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c [iso-8859-1] Thu Apr 22 00:42:21 2010 @@ -822,6 +822,7 @@ if (!DeviceNode->BootResources && !DeviceNode->ResourceRequirements) { DeviceNode->Flags |= DNF_NO_RESOURCE_REQUIRED; + DeviceNode->Flags &= ~DNF_ASSIGNING_RESOURCES; /* No resource needed for this device */ DeviceNode->ResourceList = NULL;
14 years, 8 months
1
0
0
0
[cgutman] 46983: [NTOSKRNL] - Replace the broken CM_RESOURCE_LIST_SIZE with a better function that actually works with resource lists that have device-specific data in them (fixes missing device specific data when resources are retrieved with IoGetDeviceProperty) - Separate the resource code out of pnpmgr.c and into pnpres.c - Simplify resource assigning to simply calling one function, IopAssignDeviceResources, which takes care of the registry configuration, translation, etc. - Set the DNF_NEED_
by cgutman@svn.reactos.org
Author: cgutman Date: Thu Apr 22 00:33:11 2010 New Revision: 46983 URL:
http://svn.reactos.org/svn/reactos?rev=46983&view=rev
Log: [NTOSKRNL] - Replace the broken CM_RESOURCE_LIST_SIZE with a better function that actually works with resource lists that have device-specific data in them (fixes missing device specific data when resources are retrieved with IoGetDeviceProperty) - Separate the resource code out of pnpmgr.c and into pnpres.c - Simplify resource assigning to simply calling one function, IopAssignDeviceResources, which takes care of the registry configuration, translation, etc. - Set the DNF_NEED_ENUMERATION_ONLY flag only AFTER the device is actually started not before - Set DNF_START_FAILED if IRP_MN_START_DEVICE fails - Fix a bug in IoReportDetectedDevice that wrote the AllocConfig value to wrong place Added: trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c (with props) Modified: trunk/reactos/ntoskrnl/include/internal/io.h trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild Modified: trunk/reactos/ntoskrnl/include/internal/io.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] Thu Apr 22 00:33:11 2010 @@ -87,21 +87,6 @@ ObpAllocateObjectCreateInfoBuffer #define IopFreeMdlFromLookaside \ ObpFreeCapturedAttributes - -// -// Returns the size of a CM_RESOURCE_LIST -// -#define CM_RESOURCE_LIST_SIZE(ResList) \ - (ResList->Count == 1) ? \ - FIELD_OFFSET( \ - CM_RESOURCE_LIST, \ - List[0].PartialResourceList. \ - PartialDescriptors[(ResList)-> \ - List[0]. \ - PartialResourceList. \ - Count]) \ - : \ - FIELD_OFFSET(CM_RESOURCE_LIST, List) // // Determines if the IRP is Synchronous @@ -507,6 +492,21 @@ } DEVICETREE_TRAVERSE_CONTEXT, *PDEVICETREE_TRAVERSE_CONTEXT; // +// Resource code +// +ULONG +NTAPI +IopCalculateResourceListSize( + IN PCM_RESOURCE_LIST ResourceList +); + +NTSTATUS +NTAPI +IopAssignDeviceResources( + IN PDEVICE_NODE DeviceNode +); + +// // PNP Routines // NTSTATUS Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.…
============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] Thu Apr 22 00:33:11 2010 @@ -44,21 +44,6 @@ } INVALIDATE_DEVICE_RELATION_DATA, *PINVALIDATE_DEVICE_RELATION_DATA; /* FUNCTIONS *****************************************************************/ - -NTSTATUS -IopAssignDeviceResources( - IN PDEVICE_NODE DeviceNode, - OUT ULONG *pRequiredSize); - -NTSTATUS -IopTranslateDeviceResources( - IN PDEVICE_NODE DeviceNode, - IN ULONG RequiredSize); - -NTSTATUS -IopUpdateResourceMapForPnPDevice( - IN PDEVICE_NODE DeviceNode); - NTSTATUS NTAPI IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath, @@ -133,7 +118,6 @@ ObDereferenceObject(Fdo); IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED); - IopDeviceNodeSetFlag(DeviceNode, DNF_NEED_ENUMERATION_ONLY); return STATUS_SUCCESS; } @@ -156,13 +140,9 @@ Stack.MinorFunction = IRP_MN_START_DEVICE; /* Check if we didn't already report the resources */ - // if (!DeviceNode->Flags & DNF_RESOURCE_REPORTED) + if (!(DeviceNode->Flags & DNF_RESOURCE_REPORTED)) { /* Report them */ - if (DeviceNode->Flags & DNF_RESOURCE_REPORTED) - { - DPRINT1("Warning: Setting resource pointers even though DNF_RESOURCE_REPORTED is set\n"); - } Stack.Parameters.StartDevice.AllocatedResources = DeviceNode->ResourceList; Stack.Parameters.StartDevice.AllocatedResourcesTranslated = @@ -176,15 +156,21 @@ Status = IopSynchronousCall(DeviceObject, &Stack, &Dummy); if (!NT_SUCCESS(Status)) { - /* FIXME: TODO */ - DPRINT1("Warning: PnP Start failed\n"); - //ASSERT(FALSE); + /* We failed start */ + DeviceNode->Flags |= DNF_START_FAILED; + + /* TODO: Undo all the stuff we did up to this point */ + + DPRINT1("Warning: PnP Start failed (%wZ)\n", &DeviceNode->InstancePath); return; } /* Otherwise, mark us as started */ DeviceNode->Flags |= DNF_STARTED; - + + /* We reported the resources */ + DeviceNode->Flags |= DNF_RESOURCE_REPORTED; + /* We now need enumeration */ DeviceNode->Flags |= DNF_NEED_ENUMERATION_ONLY; } @@ -198,11 +184,12 @@ PAGED_CODE(); /* Sanity check */ - // ASSERT((DeviceNode->Flags & DNF_ADDED)); - if (!(DeviceNode->Flags & DNF_ADDED)) DPRINT1("Warning: Starting a device node without DNF_ADDED\n"); + // ASSERT((DeviceNode->Flags & DNF_ADDED) || (DeviceNode->Flags & DNF_ENUMERATED)); + if (!(DeviceNode->Flags & DNF_ADDED) && !(DeviceNode->Flags & DNF_ENUMERATED)) + DPRINT1("Warning: Starting a device node without DNF_ADDED or DNF_ENUMERATED (%wZ)\n", + &DeviceNode->InstancePath); ASSERT((DeviceNode->Flags & (DNF_RESOURCE_ASSIGNED | DNF_RESOURCE_REPORTED | - DNF_NO_RESOURCE_REQUIRED | DNF_NO_RESOURCE_REQUIRED))); ASSERT((!(DeviceNode->Flags & (DNF_HAS_PROBLEM | DNF_STARTED | @@ -212,26 +199,27 @@ DeviceObject = DeviceNode->PhysicalDeviceObject; /* Check if we're not started yet */ - //if (!DeviceNode->Flags & DNF_STARTED) + if (!(DeviceNode->Flags & DNF_STARTED)) { /* Start us */ IopStartDevice2(DeviceObject); } /* Do we need to query IDs? This happens in the case of manual reporting */ - //if (DeviceNode->Flags & DNF_NEED_QUERY_IDS) - //{ - // DPRINT1("Warning: Device node has DNF_NEED_QUERY_IDS\n"); +#if 0 + if (DeviceNode->Flags & DNF_NEED_QUERY_IDS) + { + DPRINT1("Warning: Device node has DNF_NEED_QUERY_IDS\n"); /* And that case shouldn't happen yet */ - // ASSERT(FALSE); - //} + ASSERT(FALSE); + } +#endif /* Make sure we're started, and check if we need enumeration */ if ((DeviceNode->Flags & DNF_STARTED) && (DeviceNode->Flags & DNF_NEED_ENUMERATION_ONLY)) { /* Enumerate us */ - //Status = IopEnumerateDevice(DeviceObject); IoSynchronousInvalidateDeviceRelations(DeviceObject, BusRelations); IopDeviceNodeClearFlag(DeviceNode, DNF_NEED_ENUMERATION_ONLY); Status = STATUS_SUCCESS; @@ -250,56 +238,12 @@ IopStartDevice( PDEVICE_NODE DeviceNode) { - IO_STATUS_BLOCK IoStatusBlock; - IO_STACK_LOCATION Stack; - ULONG RequiredLength; NTSTATUS Status; HANDLE InstanceHandle = INVALID_HANDLE_VALUE, ControlHandle = INVALID_HANDLE_VALUE; UNICODE_STRING KeyName; OBJECT_ATTRIBUTES ObjectAttributes; - IopDeviceNodeSetFlag(DeviceNode, DNF_ASSIGNING_RESOURCES); - DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n"); - Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList = DeviceNode->ResourceRequirements; - Status = IopInitiatePnpIrp( - DeviceNode->PhysicalDeviceObject, - &IoStatusBlock, - IRP_MN_FILTER_RESOURCE_REQUIREMENTS, - &Stack); - if (!NT_SUCCESS(Status) && Status != STATUS_NOT_SUPPORTED) - { - DPRINT("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS) failed\n"); - IopDeviceNodeClearFlag(DeviceNode, DNF_ASSIGNING_RESOURCES); - return Status; - } - else if (NT_SUCCESS(Status)) - { - DeviceNode->ResourceRequirements = (PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information; - } - - Status = IopAssignDeviceResources(DeviceNode, &RequiredLength); - if (NT_SUCCESS(Status)) - { - Status = IopTranslateDeviceResources(DeviceNode, RequiredLength); - if (NT_SUCCESS(Status)) - { - Status = IopUpdateResourceMapForPnPDevice(DeviceNode); - if (!NT_SUCCESS(Status)) - { - DPRINT("IopUpdateResourceMap() failed (Status 0x%08lx)\n", Status); - } - } - else - { - DPRINT("IopTranslateDeviceResources() failed (Status 0x%08lx)\n", Status); - } - } - else - { - DPRINT("IopAssignDeviceResources() failed (Status 0x%08lx)\n", Status); - } - IopDeviceNodeClearFlag(DeviceNode, DNF_ASSIGNING_RESOURCES); - + Status = IopAssignDeviceResources(DeviceNode); if (!NT_SUCCESS(Status)) goto ByeBye; @@ -326,21 +270,8 @@ RtlInitUnicodeString(&KeyName, L"ActiveService"); Status = ZwSetValueKey(ControlHandle, &KeyName, 0, REG_SZ, DeviceNode->ServiceName.Buffer, DeviceNode->ServiceName.Length); // } - - /* FIX: Should be done somewhere in resoure code? */ - if (NT_SUCCESS(Status) && DeviceNode->ResourceList) - { - RtlInitUnicodeString(&KeyName, L"AllocConfig"); - Status = ZwSetValueKey(ControlHandle, &KeyName, 0, REG_RESOURCE_LIST, - DeviceNode->ResourceList, CM_RESOURCE_LIST_SIZE(DeviceNode->ResourceList)); - } ByeBye: - if (NT_SUCCESS(Status)) - IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED); - else - IopDeviceNodeSetFlag(DeviceNode, DNF_START_FAILED); - if (ControlHandle != INVALID_HANDLE_VALUE) ZwClose(ControlHandle); @@ -958,135 +889,6 @@ } NTSTATUS -IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2Key) -{ - NTSTATUS Status; - ULONG Disposition; - HANDLE PnpMgrLevel1, PnpMgrLevel2, ResourceMapKey; - UNICODE_STRING KeyName; - OBJECT_ATTRIBUTES ObjectAttributes; - - RtlInitUnicodeString(&KeyName, - L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP"); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF, - 0, - NULL); - Status = ZwCreateKey(&ResourceMapKey, - KEY_ALL_ACCESS, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_VOLATILE, - &Disposition); - if (!NT_SUCCESS(Status)) - return Status; - - RtlInitUnicodeString(&KeyName, Level1Key); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF, - ResourceMapKey, - NULL); - Status = ZwCreateKey(&PnpMgrLevel1, - KEY_ALL_ACCESS, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_VOLATILE, - &Disposition); - ZwClose(ResourceMapKey); - if (!NT_SUCCESS(Status)) - return Status; - - RtlInitUnicodeString(&KeyName, Level2Key); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF, - PnpMgrLevel1, - NULL); - Status = ZwCreateKey(&PnpMgrLevel2, - KEY_ALL_ACCESS, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_VOLATILE, - &Disposition); - ZwClose(PnpMgrLevel1); - if (!NT_SUCCESS(Status)) - return Status; - - if (DeviceNode->ResourceList) - { - WCHAR NameBuff[256]; - UNICODE_STRING NameU; - UNICODE_STRING Suffix; - ULONG OldLength; - - ASSERT(DeviceNode->ResourceListTranslated); - - NameU.Buffer = NameBuff; - NameU.Length = 0; - NameU.MaximumLength = 256 * sizeof(WCHAR); - - Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject, - DevicePropertyPhysicalDeviceObjectName, - NameU.MaximumLength, - NameU.Buffer, - &OldLength); - ASSERT(Status == STATUS_SUCCESS); - - NameU.Length = (USHORT)OldLength; - - RtlInitUnicodeString(&Suffix, L".Raw"); - RtlAppendUnicodeStringToString(&NameU, &Suffix); - - Status = ZwSetValueKey(PnpMgrLevel2, - &NameU, - 0, - REG_RESOURCE_LIST, - DeviceNode->ResourceList, - CM_RESOURCE_LIST_SIZE(DeviceNode->ResourceList)); - if (!NT_SUCCESS(Status)) - { - ZwClose(PnpMgrLevel2); - return Status; - } - - /* "Remove" the suffix by setting the length back to what it used to be */ - NameU.Length = (USHORT)OldLength; - - RtlInitUnicodeString(&Suffix, L".Translated"); - RtlAppendUnicodeStringToString(&NameU, &Suffix); - - Status = ZwSetValueKey(PnpMgrLevel2, - &NameU, - 0, - REG_RESOURCE_LIST, - DeviceNode->ResourceListTranslated, - CM_RESOURCE_LIST_SIZE(DeviceNode->ResourceListTranslated)); - ZwClose(PnpMgrLevel2); - if (!NT_SUCCESS(Status)) - return Status; - } - else - { - ZwClose(PnpMgrLevel2); - } - - IopDeviceNodeSetFlag(DeviceNode, DNF_RESOURCE_ASSIGNED); - - return STATUS_SUCCESS; -} - -NTSTATUS -IopUpdateResourceMapForPnPDevice(IN PDEVICE_NODE DeviceNode) -{ - return IopUpdateResourceMap(DeviceNode, L"PnP Manager", L"PnpManager"); -} - -NTSTATUS IopSetDeviceInstanceData(HANDLE InstanceKey, PDEVICE_NODE DeviceNode) { @@ -1094,7 +896,7 @@ UNICODE_STRING KeyName; HANDLE LogConfKey; ULONG ResCount; - ULONG ListSize, ResultLength; + ULONG ResultLength; NTSTATUS Status; HANDLE ControlHandle; @@ -1122,15 +924,13 @@ ResCount = DeviceNode->BootResources->Count; if (ResCount != 0) { - ListSize = CM_RESOURCE_LIST_SIZE(DeviceNode->BootResources); - RtlInitUnicodeString(&KeyName, L"BootConfig"); Status = ZwSetValueKey(LogConfKey, &KeyName, 0, REG_RESOURCE_LIST, DeviceNode->BootResources, - ListSize); + IopCalculateResourceListSize(DeviceNode->BootResources)); } } @@ -1187,894 +987,6 @@ return Status; } -BOOLEAN -IopCheckResourceDescriptor( - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc, - IN PCM_RESOURCE_LIST ResourceList, - IN BOOLEAN Silent, - OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) -{ - ULONG i, ii; - BOOLEAN Result = FALSE; - - if (ResDesc->ShareDisposition == CmResourceShareShared) - return FALSE; - - for (i = 0; i < ResourceList->Count; i++) - { - PCM_PARTIAL_RESOURCE_LIST ResList = &ResourceList->List[i].PartialResourceList; - for (ii = 0; ii < ResList->Count; ii++) - { - PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc2 = &ResList->PartialDescriptors[ii]; - - /* We don't care about shared resources */ - if (ResDesc->ShareDisposition == CmResourceShareShared && - ResDesc2->ShareDisposition == CmResourceShareShared) - continue; - - /* Make sure we're comparing the same types */ - if (ResDesc->Type != ResDesc2->Type) - continue; - - switch (ResDesc->Type) - { - case CmResourceTypeMemory: - if ((ResDesc->u.Memory.Start.QuadPart < ResDesc2->u.Memory.Start.QuadPart && - ResDesc->u.Memory.Start.QuadPart + ResDesc->u.Memory.Length > - ResDesc2->u.Memory.Start.QuadPart) || (ResDesc2->u.Memory.Start.QuadPart < - ResDesc->u.Memory.Start.QuadPart && ResDesc2->u.Memory.Start.QuadPart + - ResDesc2->u.Memory.Length > ResDesc->u.Memory.Start.QuadPart)) - { - if (!Silent) - { - DPRINT1("Resource conflict: Memory (0x%x to 0x%x vs. 0x%x to 0x%x)\n", - ResDesc->u.Memory.Start.QuadPart, ResDesc->u.Memory.Start.QuadPart + - ResDesc->u.Memory.Length, ResDesc2->u.Memory.Start.QuadPart, - ResDesc2->u.Memory.Start.QuadPart + ResDesc2->u.Memory.Length); - } - - Result = TRUE; - - goto ByeBye; - } - break; - - case CmResourceTypePort: - if ((ResDesc->u.Port.Start.QuadPart < ResDesc2->u.Port.Start.QuadPart && - ResDesc->u.Port.Start.QuadPart + ResDesc->u.Port.Length > - ResDesc2->u.Port.Start.QuadPart) || (ResDesc2->u.Port.Start.QuadPart < - ResDesc->u.Port.Start.QuadPart && ResDesc2->u.Port.Start.QuadPart + - ResDesc2->u.Port.Length > ResDesc->u.Port.Start.QuadPart)) - { - if (!Silent) - { - DPRINT1("Resource conflict: Port (0x%x to 0x%x vs. 0x%x to 0x%x)\n", - ResDesc->u.Port.Start.QuadPart, ResDesc->u.Port.Start.QuadPart + - ResDesc->u.Port.Length, ResDesc2->u.Port.Start.QuadPart, - ResDesc2->u.Port.Start.QuadPart + ResDesc2->u.Port.Length); - } - - Result = TRUE; - - goto ByeBye; - } - break; - - case CmResourceTypeInterrupt: - if (ResDesc->u.Interrupt.Vector == ResDesc2->u.Interrupt.Vector) - { - if (!Silent) - { - DPRINT1("Resource conflict: IRQ (0x%x 0x%x vs. 0x%x 0x%x)\n", - ResDesc->u.Interrupt.Vector, ResDesc->u.Interrupt.Level, - ResDesc2->u.Interrupt.Vector, ResDesc2->u.Interrupt.Level); - } - - Result = TRUE; - - goto ByeBye; - } - break; - - case CmResourceTypeBusNumber: - if ((ResDesc->u.BusNumber.Start < ResDesc2->u.BusNumber.Start && - ResDesc->u.BusNumber.Start + ResDesc->u.BusNumber.Length > - ResDesc2->u.BusNumber.Start) || (ResDesc2->u.BusNumber.Start < - ResDesc->u.BusNumber.Start && ResDesc2->u.BusNumber.Start + - ResDesc2->u.BusNumber.Length > ResDesc->u.BusNumber.Start)) - { - if (!Silent) - { - DPRINT1("Resource conflict: Bus number (0x%x to 0x%x vs. 0x%x to 0x%x)\n", - ResDesc->u.BusNumber.Start, ResDesc->u.BusNumber.Start + - ResDesc->u.BusNumber.Length, ResDesc2->u.BusNumber.Start, - ResDesc2->u.BusNumber.Start + ResDesc2->u.BusNumber.Length); - } - - Result = TRUE; - - goto ByeBye; - } - break; - - case CmResourceTypeDma: - if (ResDesc->u.Dma.Channel == ResDesc2->u.Dma.Channel) - { - if (!Silent) - { - DPRINT1("Resource conflict: Dma (0x%x 0x%x vs. 0x%x 0x%x)\n", - ResDesc->u.Dma.Channel, ResDesc->u.Dma.Port, - ResDesc2->u.Dma.Channel, ResDesc2->u.Dma.Port); - } - - Result = TRUE; - - goto ByeBye; - } - break; - } - } - } - -ByeBye: - - if (Result && ConflictingDescriptor) - { - RtlCopyMemory(ConflictingDescriptor, - ResDesc, - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); - } - - return Result; -} - - -BOOLEAN -IopCheckForResourceConflict( - IN PCM_RESOURCE_LIST ResourceList1, - IN PCM_RESOURCE_LIST ResourceList2, - IN BOOLEAN Silent, - OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) -{ - ULONG i, ii; - BOOLEAN Result = FALSE; - - for (i = 0; i < ResourceList1->Count; i++) - { - PCM_PARTIAL_RESOURCE_LIST ResList = &ResourceList1->List[i].PartialResourceList; - for (ii = 0; ii < ResList->Count; ii++) - { - PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc = &ResList->PartialDescriptors[ii]; - - Result = IopCheckResourceDescriptor(ResDesc, - ResourceList2, - Silent, - ConflictingDescriptor); - if (Result) goto ByeBye; - } - } - - -ByeBye: - - return Result; -} - -NTSTATUS -IopDetectResourceConflict( - IN PCM_RESOURCE_LIST ResourceList, - IN BOOLEAN Silent, - OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING KeyName; - HANDLE ResourceMapKey = INVALID_HANDLE_VALUE, ChildKey2 = INVALID_HANDLE_VALUE, ChildKey3 = INVALID_HANDLE_VALUE; - ULONG KeyInformationLength, RequiredLength, KeyValueInformationLength, KeyNameInformationLength; - PKEY_BASIC_INFORMATION KeyInformation; - PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation; - PKEY_VALUE_BASIC_INFORMATION KeyNameInformation; - ULONG ChildKeyIndex1 = 0, ChildKeyIndex2 = 0, ChildKeyIndex3 = 0; - NTSTATUS Status; - - RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP"); - InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE, 0, NULL); - Status = ZwOpenKey(&ResourceMapKey, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - /* The key is missing which means we are the first device */ - return STATUS_SUCCESS; - } - - while (TRUE) - { - Status = ZwEnumerateKey(ResourceMapKey, - ChildKeyIndex1, - KeyBasicInformation, - NULL, - 0, - &RequiredLength); - if (Status == STATUS_NO_MORE_ENTRIES) - break; - else if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL) - { - KeyInformationLength = RequiredLength; - KeyInformation = ExAllocatePool(PagedPool, KeyInformationLength); - if (!KeyInformation) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto cleanup; - } - - Status = ZwEnumerateKey(ResourceMapKey, - ChildKeyIndex1, - KeyBasicInformation, - KeyInformation, - KeyInformationLength, - &RequiredLength); - } - else - goto cleanup; - ChildKeyIndex1++; - if (!NT_SUCCESS(Status)) - goto cleanup; - - KeyName.Buffer = KeyInformation->Name; - KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength; - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE, - ResourceMapKey, - NULL); - Status = ZwOpenKey(&ChildKey2, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes); - ExFreePool(KeyInformation); - if (!NT_SUCCESS(Status)) - goto cleanup; - - while (TRUE) - { - Status = ZwEnumerateKey(ChildKey2, - ChildKeyIndex2, - KeyBasicInformation, - NULL, - 0, - &RequiredLength); - if (Status == STATUS_NO_MORE_ENTRIES) - break; - else if (Status == STATUS_BUFFER_TOO_SMALL) - { - KeyInformationLength = RequiredLength; - KeyInformation = ExAllocatePool(PagedPool, KeyInformationLength); - if (!KeyInformation) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto cleanup; - } - - Status = ZwEnumerateKey(ChildKey2, - ChildKeyIndex2, - KeyBasicInformation, - KeyInformation, - KeyInformationLength, - &RequiredLength); - } - else - goto cleanup; - ChildKeyIndex2++; - if (!NT_SUCCESS(Status)) - goto cleanup; - - KeyName.Buffer = KeyInformation->Name; - KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength; - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE, - ChildKey2, - NULL); - Status = ZwOpenKey(&ChildKey3, KEY_QUERY_VALUE, &ObjectAttributes); - ExFreePool(KeyInformation); - if (!NT_SUCCESS(Status)) - goto cleanup; - - while (TRUE) - { - Status = ZwEnumerateValueKey(ChildKey3, - ChildKeyIndex3, - KeyValuePartialInformation, - NULL, - 0, - &RequiredLength); - if (Status == STATUS_NO_MORE_ENTRIES) - break; - else if (Status == STATUS_BUFFER_TOO_SMALL) - { - KeyValueInformationLength = RequiredLength; - KeyValueInformation = ExAllocatePool(PagedPool, KeyValueInformationLength); - if (!KeyValueInformation) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto cleanup; - } - - Status = ZwEnumerateValueKey(ChildKey3, - ChildKeyIndex3, - KeyValuePartialInformation, - KeyValueInformation, - KeyValueInformationLength, - &RequiredLength); - } - else - goto cleanup; - if (!NT_SUCCESS(Status)) - goto cleanup; - - Status = ZwEnumerateValueKey(ChildKey3, - ChildKeyIndex3, - KeyValueBasicInformation, - NULL, - 0, - &RequiredLength); - if (Status == STATUS_BUFFER_TOO_SMALL) - { - KeyNameInformationLength = RequiredLength; - KeyNameInformation = ExAllocatePool(PagedPool, KeyNameInformationLength + sizeof(WCHAR)); - if (!KeyNameInformation) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto cleanup; - } - - Status = ZwEnumerateValueKey(ChildKey3, - ChildKeyIndex3, - KeyValueBasicInformation, - KeyNameInformation, - KeyNameInformationLength, - &RequiredLength); - } - else - goto cleanup; - - ChildKeyIndex3++; - - if (!NT_SUCCESS(Status)) - goto cleanup; - - KeyNameInformation->Name[KeyNameInformation->NameLength / sizeof(WCHAR)] = UNICODE_NULL; - - /* Skip translated entries */ - if (wcsstr(KeyNameInformation->Name, L".Translated")) - { - ExFreePool(KeyNameInformation); - continue; - } - - ExFreePool(KeyNameInformation); - - if (IopCheckForResourceConflict(ResourceList, - (PCM_RESOURCE_LIST)KeyValueInformation->Data, - Silent, - ConflictingDescriptor)) - { - ExFreePool(KeyValueInformation); - Status = STATUS_CONFLICTING_ADDRESSES; - goto cleanup; - } - - ExFreePool(KeyValueInformation); - } - } - } - -cleanup: - if (ResourceMapKey != INVALID_HANDLE_VALUE) - ZwClose(ResourceMapKey); - if (ChildKey2 != INVALID_HANDLE_VALUE) - ZwClose(ChildKey2); - if (ChildKey3 != INVALID_HANDLE_VALUE) - ZwClose(ChildKey3); - - if (Status == STATUS_NO_MORE_ENTRIES) - Status = STATUS_SUCCESS; - - return Status; -} - -BOOLEAN -IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) -{ - CM_RESOURCE_LIST CmList; - NTSTATUS Status; - - CmList.Count = 1; - CmList.List[0].InterfaceType = InterfaceTypeUndefined; - CmList.List[0].BusNumber = 0; - CmList.List[0].PartialResourceList.Version = 1; - CmList.List[0].PartialResourceList.Revision = 1; - CmList.List[0].PartialResourceList.Count = 1; - CmList.List[0].PartialResourceList.PartialDescriptors[0] = *CmDesc; - - Status = IopDetectResourceConflict(&CmList, TRUE, ConflictingDescriptor); - if (Status == STATUS_CONFLICTING_ADDRESSES) - return TRUE; - - return FALSE; -} - -BOOLEAN -IopFindBusNumberResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) -{ - ULONG Start; - CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; - - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypeBusNumber); - - for (Start = IoDesc->u.BusNumber.MinBusNumber; - Start < IoDesc->u.BusNumber.MaxBusNumber; - Start++) - { - CmDesc->u.BusNumber.Length = IoDesc->u.BusNumber.Length; - CmDesc->u.BusNumber.Start = Start; - - if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc)) - { - Start += ConflictingDesc.u.BusNumber.Start + ConflictingDesc.u.BusNumber.Length; - } - else - { - return TRUE; - } - } - - return FALSE; -} - -BOOLEAN -IopFindMemoryResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) -{ - ULONGLONG Start; - CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; - - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypeMemory); - - for (Start = IoDesc->u.Memory.MinimumAddress.QuadPart; - Start < IoDesc->u.Memory.MaximumAddress.QuadPart; - Start++) - { - CmDesc->u.Memory.Length = IoDesc->u.Memory.Length; - CmDesc->u.Memory.Start.QuadPart = Start; - - if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc)) - { - Start += ConflictingDesc.u.Memory.Start.QuadPart + ConflictingDesc.u.Memory.Length; - } - else - { - return TRUE; - } - } - - return FALSE; -} - -BOOLEAN -IopFindPortResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) -{ - ULONGLONG Start; - CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; - - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypePort); - - for (Start = IoDesc->u.Port.MinimumAddress.QuadPart; - Start < IoDesc->u.Port.MaximumAddress.QuadPart; - Start++) - { - CmDesc->u.Port.Length = IoDesc->u.Port.Length; - CmDesc->u.Port.Start.QuadPart = Start; - - if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc)) - { - Start += ConflictingDesc.u.Port.Start.QuadPart + ConflictingDesc.u.Port.Length; - } - else - { - return TRUE; - } - } - - return FALSE; -} - -BOOLEAN -IopFindDmaResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) -{ - ULONG Channel; - - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypeDma); - - for (Channel = IoDesc->u.Dma.MinimumChannel; - Channel < IoDesc->u.Dma.MaximumChannel; - Channel++) - { - CmDesc->u.Dma.Channel = Channel; - CmDesc->u.Dma.Port = 0; - - if (!IopCheckDescriptorForConflict(CmDesc, NULL)) - return TRUE; - } - - return FALSE; -} - -BOOLEAN -IopFindInterruptResource( - IN PIO_RESOURCE_DESCRIPTOR IoDesc, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) -{ - ULONG Vector; - - ASSERT(IoDesc->Type == CmDesc->Type); - ASSERT(IoDesc->Type == CmResourceTypeInterrupt); - - for (Vector = IoDesc->u.Interrupt.MinimumVector; - Vector < IoDesc->u.Interrupt.MaximumVector; - Vector++) - { - CmDesc->u.Interrupt.Vector = Vector; - CmDesc->u.Interrupt.Level = Vector; - CmDesc->u.Interrupt.Affinity = (KAFFINITY)-1; - - if (!IopCheckDescriptorForConflict(CmDesc, NULL)) - return TRUE; - } - - return FALSE; -} - -NTSTATUS -IopCreateResourceListFromRequirements( - IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList, - OUT PCM_RESOURCE_LIST *ResourceList) -{ - ULONG i, ii, Size; - PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc; - - Size = FIELD_OFFSET(CM_RESOURCE_LIST, List); - for (i = 0; i < RequirementsList->AlternativeLists; i++) - { - PIO_RESOURCE_LIST ResList = &RequirementsList->List[i]; - Size += FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors) - + ResList->Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - } - - *ResourceList = ExAllocatePool(PagedPool, Size); - if (!*ResourceList) - return STATUS_INSUFFICIENT_RESOURCES; - - (*ResourceList)->Count = 1; - (*ResourceList)->List[0].BusNumber = RequirementsList->BusNumber; - (*ResourceList)->List[0].InterfaceType = RequirementsList->InterfaceType; - (*ResourceList)->List[0].PartialResourceList.Version = 1; - (*ResourceList)->List[0].PartialResourceList.Revision = 1; - (*ResourceList)->List[0].PartialResourceList.Count = 0; - - ResDesc = &(*ResourceList)->List[0].PartialResourceList.PartialDescriptors[0]; - - for (i = 0; i < RequirementsList->AlternativeLists; i++) - { - PIO_RESOURCE_LIST ResList = &RequirementsList->List[i]; - for (ii = 0; ii < ResList->Count; ii++) - { - PIO_RESOURCE_DESCRIPTOR ReqDesc = &ResList->Descriptors[ii]; - - /* FIXME: Handle alternate ranges */ - if (ReqDesc->Option == IO_RESOURCE_ALTERNATIVE) - continue; - - ResDesc->Type = ReqDesc->Type; - ResDesc->Flags = ReqDesc->Flags; - ResDesc->ShareDisposition = ReqDesc->ShareDisposition; - - switch (ReqDesc->Type) - { - case CmResourceTypeInterrupt: - if (!IopFindInterruptResource(ReqDesc, ResDesc)) - { - DPRINT1("Failed to find an available interrupt resource (0x%x to 0x%x)\n", - ReqDesc->u.Interrupt.MinimumVector, ReqDesc->u.Interrupt.MaximumVector); - - if (ReqDesc->Option == 0) - { - ExFreePool(*ResourceList); - return STATUS_CONFLICTING_ADDRESSES; - } - } - break; - - case CmResourceTypePort: - if (!IopFindPortResource(ReqDesc, ResDesc)) - { - DPRINT1("Failed to find an available port resource (0x%x to 0x%x length: 0x%x)\n", - ReqDesc->u.Port.MinimumAddress.QuadPart, ReqDesc->u.Port.MaximumAddress.QuadPart, - ReqDesc->u.Port.Length); - - if (ReqDesc->Option == 0) - { - ExFreePool(*ResourceList); - return STATUS_CONFLICTING_ADDRESSES; - } - } - break; - - case CmResourceTypeMemory: - if (!IopFindMemoryResource(ReqDesc, ResDesc)) - { - DPRINT1("Failed to find an available memory resource (0x%x to 0x%x length: 0x%x)\n", - ReqDesc->u.Memory.MinimumAddress.QuadPart, ReqDesc->u.Memory.MaximumAddress.QuadPart, - ReqDesc->u.Memory.Length); - - if (ReqDesc->Option == 0) - { - ExFreePool(*ResourceList); - return STATUS_CONFLICTING_ADDRESSES; - } - } - break; - - case CmResourceTypeBusNumber: - if (!IopFindBusNumberResource(ReqDesc, ResDesc)) - { - DPRINT1("Failed to find an available bus number resource (0x%x to 0x%x length: 0x%x)\n", - ReqDesc->u.BusNumber.MinBusNumber, ReqDesc->u.BusNumber.MaxBusNumber, - ReqDesc->u.BusNumber.Length); - - if (ReqDesc->Option == 0) - { - ExFreePool(*ResourceList); - return STATUS_CONFLICTING_ADDRESSES; - } - } - break; - - case CmResourceTypeDma: - if (!IopFindDmaResource(ReqDesc, ResDesc)) - { - DPRINT1("Failed to find an available dma resource (0x%x to 0x%x)\n", - ReqDesc->u.Dma.MinimumChannel, ReqDesc->u.Dma.MaximumChannel); - - if (ReqDesc->Option == 0) - { - ExFreePool(*ResourceList); - return STATUS_CONFLICTING_ADDRESSES; - } - } - break; - - default: - DPRINT1("Unsupported resource type: %x\n", ReqDesc->Type); - break; - } - - (*ResourceList)->List[0].PartialResourceList.Count++; - ResDesc++; - } - } - - return STATUS_SUCCESS; -} - -NTSTATUS -IopAssignDeviceResources( - IN PDEVICE_NODE DeviceNode, - OUT ULONG *pRequiredSize) -{ - PCM_PARTIAL_RESOURCE_LIST pPartialResourceList; - ULONG Size; - ULONG i; - ULONG j; - NTSTATUS Status; - - if (!DeviceNode->BootResources && !DeviceNode->ResourceRequirements) - { - /* No resource needed for this device */ - DeviceNode->ResourceList = NULL; - *pRequiredSize = 0; - return STATUS_SUCCESS; - } - - /* Fill DeviceNode->ResourceList - * FIXME: the PnP arbiter should go there! - * Actually, use the BootResources if provided, else the resource requirements - */ - - if (DeviceNode->BootResources) - { - /* Browse the boot resources to know if we have some custom structures */ - Size = FIELD_OFFSET(CM_RESOURCE_LIST, List); - for (i = 0; i < DeviceNode->BootResources->Count; i++) - { - pPartialResourceList = &DeviceNode->BootResources->List[i].PartialResourceList; - Size += FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors) + - pPartialResourceList->Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - for (j = 0; j < pPartialResourceList->Count; j++) - { - if (pPartialResourceList->PartialDescriptors[j].Type == CmResourceTypeDeviceSpecific) - Size += pPartialResourceList->PartialDescriptors[j].u.DeviceSpecificData.DataSize; - } - } - - DeviceNode->ResourceList = ExAllocatePool(PagedPool, Size); - if (!DeviceNode->ResourceList) - { - Status = STATUS_NO_MEMORY; - goto ByeBye; - } - RtlCopyMemory(DeviceNode->ResourceList, DeviceNode->BootResources, Size); - - Status = IopDetectResourceConflict(DeviceNode->ResourceList, FALSE, NULL); - if (NT_SUCCESS(Status) || !DeviceNode->ResourceRequirements) - { - if (!NT_SUCCESS(Status) && !DeviceNode->ResourceRequirements) - { - DPRINT1("Using conflicting boot resources because no requirements were supplied!\n"); - } - - *pRequiredSize = Size; - return STATUS_SUCCESS; - } - else - { - DPRINT1("Boot resources for %wZ cause a resource conflict!\n", &DeviceNode->InstancePath); - ExFreePool(DeviceNode->ResourceList); - } - } - - Status = IopCreateResourceListFromRequirements(DeviceNode->ResourceRequirements, - &DeviceNode->ResourceList); - if (!NT_SUCCESS(Status)) - goto ByeBye; - - Size = FIELD_OFFSET(CM_RESOURCE_LIST, List); - for (i = 0; i < DeviceNode->ResourceList->Count; i++) - { - pPartialResourceList = &DeviceNode->ResourceList->List[i].PartialResourceList; - Size += FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors) + - pPartialResourceList->Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - } - - Status = IopDetectResourceConflict(DeviceNode->ResourceList, FALSE, NULL); - if (!NT_SUCCESS(Status)) - goto ByeBye; - - *pRequiredSize = Size; - return STATUS_SUCCESS; - -ByeBye: - if (DeviceNode->ResourceList) - { - ExFreePool(DeviceNode->ResourceList); - DeviceNode->ResourceList = NULL; - } - *pRequiredSize = 0; - return Status; -} - - -NTSTATUS -IopTranslateDeviceResources( - IN PDEVICE_NODE DeviceNode, - IN ULONG RequiredSize) -{ - PCM_PARTIAL_RESOURCE_LIST pPartialResourceList; - PCM_PARTIAL_RESOURCE_DESCRIPTOR DescriptorRaw, DescriptorTranslated; - ULONG i, j; - NTSTATUS Status; - - if (!DeviceNode->ResourceList) - { - DeviceNode->ResourceListTranslated = NULL; - return STATUS_SUCCESS; - } - - /* That's easy to translate a resource list. Just copy the - * untranslated one and change few fields in the copy - */ - DeviceNode->ResourceListTranslated = ExAllocatePool(PagedPool, RequiredSize); - if (!DeviceNode->ResourceListTranslated) - { - Status =STATUS_NO_MEMORY; - goto cleanup; - } - RtlCopyMemory(DeviceNode->ResourceListTranslated, DeviceNode->ResourceList, RequiredSize); - - for (i = 0; i < DeviceNode->ResourceList->Count; i++) - { - pPartialResourceList = &DeviceNode->ResourceList->List[i].PartialResourceList; - for (j = 0; j < pPartialResourceList->Count; j++) - { - DescriptorRaw = &pPartialResourceList->PartialDescriptors[j]; - DescriptorTranslated = &DeviceNode->ResourceListTranslated->List[i].PartialResourceList.PartialDescriptors[j]; - switch (DescriptorRaw->Type) - { - case CmResourceTypePort: - { - ULONG AddressSpace = 1; /* IO space */ - if (!HalTranslateBusAddress( - DeviceNode->ResourceList->List[i].InterfaceType, - DeviceNode->ResourceList->List[i].BusNumber, - DescriptorRaw->u.Port.Start, - &AddressSpace, - &DescriptorTranslated->u.Port.Start)) - { - Status = STATUS_UNSUCCESSFUL; - goto cleanup; - } - break; - } - case CmResourceTypeInterrupt: - { - DescriptorTranslated->u.Interrupt.Vector = HalGetInterruptVector( - DeviceNode->ResourceList->List[i].InterfaceType, - DeviceNode->ResourceList->List[i].BusNumber, - DescriptorRaw->u.Interrupt.Level, - DescriptorRaw->u.Interrupt.Vector, - (PKIRQL)&DescriptorTranslated->u.Interrupt.Level, - &DescriptorRaw->u.Interrupt.Affinity); - break; - } - case CmResourceTypeMemory: - { - ULONG AddressSpace = 0; /* Memory space */ - if (!HalTranslateBusAddress( - DeviceNode->ResourceList->List[i].InterfaceType, - DeviceNode->ResourceList->List[i].BusNumber, - DescriptorRaw->u.Memory.Start, - &AddressSpace, - &DescriptorTranslated->u.Memory.Start)) - { - Status = STATUS_UNSUCCESSFUL; - goto cleanup; - } - } - - case CmResourceTypeDma: - case CmResourceTypeBusNumber: - case CmResourceTypeDeviceSpecific: - /* Nothing to do */ - break; - default: - DPRINT1("Unknown resource descriptor type 0x%x\n", DescriptorRaw->Type); - Status = STATUS_NOT_IMPLEMENTED; - goto cleanup; - } - } - } - return STATUS_SUCCESS; - -cleanup: - /* Yes! Also delete ResourceList because ResourceList and - * ResourceListTranslated should be a pair! */ - ExFreePool(DeviceNode->ResourceList); - DeviceNode->ResourceList = NULL; - if (DeviceNode->ResourceListTranslated) - { - ExFreePool(DeviceNode->ResourceListTranslated); - DeviceNode->ResourceList = NULL; - } - return Status; -} - - /* * IopGetParentIdPrefix * @@ -2608,17 +1520,12 @@ { DeviceNode->ResourceRequirements = (PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information; - if (IoStatusBlock.Information) - IopDeviceNodeSetFlag(DeviceNode, DNF_RESOURCE_REPORTED); - else - IopDeviceNodeSetFlag(DeviceNode, DNF_NO_RESOURCE_REQUIRED); } else { DPRINT("IopInitiatePnpIrp() failed (Status %08lx)\n", Status); DeviceNode->ResourceRequirements = NULL; } - if (InstanceKey != NULL) { @@ -4285,7 +3192,7 @@ Length = 0; if (DeviceNode->BootResources->Count != 0) { - Length = CM_RESOURCE_LIST_SIZE(DeviceNode->BootResources); + Length = IopCalculateResourceListSize(DeviceNode->BootResources); } Data = DeviceNode->BootResources; break; @@ -4295,7 +3202,7 @@ Length = 0; if (DeviceNode->BootResources->Count != 0) { - Length = CM_RESOURCE_LIST_SIZE(DeviceNode->BootResources); + Length = IopCalculateResourceListSize(DeviceNode->BootResources); } Data = DeviceNode->BootResources; break; Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnprepo…
============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c [iso-8859-1] Thu Apr 22 00:33:11 2010 @@ -19,26 +19,12 @@ OUT PHANDLE Handle); NTSTATUS -IopAssignDeviceResources( - IN PDEVICE_NODE DeviceNode, - OUT ULONG *pRequiredSize); - -NTSTATUS IopSetDeviceInstanceData(HANDLE InstanceKey, PDEVICE_NODE DeviceNode); NTSTATUS -IopTranslateDeviceResources( - IN PDEVICE_NODE DeviceNode, - IN ULONG RequiredSize); - -NTSTATUS IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode, PVOID Context); - -NTSTATUS -IopUpdateResourceMapForPnPDevice( - IN PDEVICE_NODE DeviceNode); NTSTATUS IopDetectResourceConflict( @@ -189,6 +175,11 @@ /* We don't send IRP_MN_START_DEVICE */ IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED); + /* We need to get device IDs */ +#if 0 + IopDeviceNodeSetFlag(DeviceNode, DNF_NEED_QUERY_IDS); +#endif + /* This is a legacy driver for this device */ IopDeviceNodeSetFlag(DeviceNode, DNF_LEGACY_DRIVER); @@ -258,9 +249,7 @@ if (DeviceNode->BootResources) IopDeviceNodeSetFlag(DeviceNode, DNF_HAS_BOOT_CONFIG); - if (DeviceNode->ResourceRequirements) - IopDeviceNodeSetFlag(DeviceNode, DNF_RESOURCE_REPORTED); - else + if (!DeviceNode->ResourceRequirements && !DeviceNode->BootResources) IopDeviceNodeSetFlag(DeviceNode, DNF_NO_RESOURCE_REQUIRED); /* Write the resource information to the registry */ @@ -269,27 +258,7 @@ /* If the caller didn't get the resources assigned for us, do it now */ if (!ResourceAssigned) { - IopDeviceNodeSetFlag(DeviceNode, DNF_ASSIGNING_RESOURCES); - Status = IopAssignDeviceResources(DeviceNode, &RequiredLength); - if (NT_SUCCESS(Status)) - { - Status = IopTranslateDeviceResources(DeviceNode, RequiredLength); - if (NT_SUCCESS(Status)) - { - Status = IopUpdateResourceMapForPnPDevice(DeviceNode); - if (NT_SUCCESS(Status) && DeviceNode->ResourceList) - { - RtlInitUnicodeString(&ValueName, L"AllocConfig"); - Status = ZwSetValueKey(InstanceKey, - &ValueName, - 0, - REG_RESOURCE_LIST, - DeviceNode->ResourceList, - CM_RESOURCE_LIST_SIZE(DeviceNode->ResourceList)); - } - } - } - IopDeviceNodeClearFlag(DeviceNode, DNF_ASSIGNING_RESOURCES); + Status = IopAssignDeviceResources(DeviceNode); /* See if we failed */ if (!NT_SUCCESS(Status)) Added: trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.…
============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c (added) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c [iso-8859-1] Thu Apr 22 00:33:11 2010 @@ -1,0 +1,1158 @@ +/* + * PROJECT: ReactOS Kernel + * COPYRIGHT: GPL - See COPYING in the top level directory + * FILE: ntoskrnl/io/pnpmgr/pnpres.c + * PURPOSE: Resource handling code + * PROGRAMMERS: Cameron Gutman (cameron.gutman(a)reactos.org) + * ReactOS Portable Systems Group + */ + +#include <ntoskrnl.h> + +#define NDEBUG +#include <debug.h> + +NTSTATUS +IopDetectResourceConflict( + IN PCM_RESOURCE_LIST ResourceList, + IN BOOLEAN Silent, + OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor); + +ULONG +NTAPI +IopCalculateResourceListSize( + IN PCM_RESOURCE_LIST ResourceList) +{ + ULONG Size, i, j; + PCM_PARTIAL_RESOURCE_LIST pPartialResourceList; + + Size = FIELD_OFFSET(CM_RESOURCE_LIST, List); + for (i = 0; i < ResourceList->Count; i++) + { + pPartialResourceList = &ResourceList->List[i].PartialResourceList; + Size += FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors) + + pPartialResourceList->Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); + for (j = 0; j < pPartialResourceList->Count; j++) + { + if (pPartialResourceList->PartialDescriptors[j].Type == CmResourceTypeDeviceSpecific) + Size += pPartialResourceList->PartialDescriptors[j].u.DeviceSpecificData.DataSize; + } + } + + return Size; +} + +static +BOOLEAN +IopCheckDescriptorForConflict(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc, OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) +{ + CM_RESOURCE_LIST CmList; + NTSTATUS Status; + + CmList.Count = 1; + CmList.List[0].InterfaceType = InterfaceTypeUndefined; + CmList.List[0].BusNumber = 0; + CmList.List[0].PartialResourceList.Version = 1; + CmList.List[0].PartialResourceList.Revision = 1; + CmList.List[0].PartialResourceList.Count = 1; + CmList.List[0].PartialResourceList.PartialDescriptors[0] = *CmDesc; + + Status = IopDetectResourceConflict(&CmList, TRUE, ConflictingDescriptor); + if (Status == STATUS_CONFLICTING_ADDRESSES) + return TRUE; + + return FALSE; +} + +static +BOOLEAN +IopFindBusNumberResource( + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) +{ + ULONG Start; + CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; + + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypeBusNumber); + + for (Start = IoDesc->u.BusNumber.MinBusNumber; + Start < IoDesc->u.BusNumber.MaxBusNumber; + Start++) + { + CmDesc->u.BusNumber.Length = IoDesc->u.BusNumber.Length; + CmDesc->u.BusNumber.Start = Start; + + if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc)) + { + Start += ConflictingDesc.u.BusNumber.Start + ConflictingDesc.u.BusNumber.Length; + } + else + { + return TRUE; + } + } + + return FALSE; +} + +static +BOOLEAN +IopFindMemoryResource( + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) +{ + ULONGLONG Start; + CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; + + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypeMemory); + + for (Start = IoDesc->u.Memory.MinimumAddress.QuadPart; + Start < IoDesc->u.Memory.MaximumAddress.QuadPart; + Start++) + { + CmDesc->u.Memory.Length = IoDesc->u.Memory.Length; + CmDesc->u.Memory.Start.QuadPart = Start; + + if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc)) + { + Start += ConflictingDesc.u.Memory.Start.QuadPart + ConflictingDesc.u.Memory.Length; + } + else + { + return TRUE; + } + } + + return FALSE; +} + +static +BOOLEAN +IopFindPortResource( + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) +{ + ULONGLONG Start; + CM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDesc; + + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypePort); + + for (Start = IoDesc->u.Port.MinimumAddress.QuadPart; + Start < IoDesc->u.Port.MaximumAddress.QuadPart; + Start++) + { + CmDesc->u.Port.Length = IoDesc->u.Port.Length; + CmDesc->u.Port.Start.QuadPart = Start; + + if (IopCheckDescriptorForConflict(CmDesc, &ConflictingDesc)) + { + Start += ConflictingDesc.u.Port.Start.QuadPart + ConflictingDesc.u.Port.Length; + } + else + { + return TRUE; + } + } + + return FALSE; +} + +static +BOOLEAN +IopFindDmaResource( + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) +{ + ULONG Channel; + + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypeDma); + + for (Channel = IoDesc->u.Dma.MinimumChannel; + Channel < IoDesc->u.Dma.MaximumChannel; + Channel++) + { + CmDesc->u.Dma.Channel = Channel; + CmDesc->u.Dma.Port = 0; + + if (!IopCheckDescriptorForConflict(CmDesc, NULL)) + return TRUE; + } + + return FALSE; +} + +static +BOOLEAN +IopFindInterruptResource( + IN PIO_RESOURCE_DESCRIPTOR IoDesc, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc) +{ + ULONG Vector; + + ASSERT(IoDesc->Type == CmDesc->Type); + ASSERT(IoDesc->Type == CmResourceTypeInterrupt); + + for (Vector = IoDesc->u.Interrupt.MinimumVector; + Vector < IoDesc->u.Interrupt.MaximumVector; + Vector++) + { + CmDesc->u.Interrupt.Vector = Vector; + CmDesc->u.Interrupt.Level = Vector; + CmDesc->u.Interrupt.Affinity = (KAFFINITY)-1; + + if (!IopCheckDescriptorForConflict(CmDesc, NULL)) + return TRUE; + } + + return FALSE; +} + +static +NTSTATUS +IopCreateResourceListFromRequirements( + IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList, + OUT PCM_RESOURCE_LIST *ResourceList) +{ + ULONG i, ii, Size; + PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc; + + Size = FIELD_OFFSET(CM_RESOURCE_LIST, List); + for (i = 0; i < RequirementsList->AlternativeLists; i++) + { + PIO_RESOURCE_LIST ResList = &RequirementsList->List[i]; + Size += FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors) + + ResList->Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); + } + + *ResourceList = ExAllocatePool(PagedPool, Size); + if (!*ResourceList) + return STATUS_INSUFFICIENT_RESOURCES; + + (*ResourceList)->Count = 1; + (*ResourceList)->List[0].BusNumber = RequirementsList->BusNumber; + (*ResourceList)->List[0].InterfaceType = RequirementsList->InterfaceType; + (*ResourceList)->List[0].PartialResourceList.Version = 1; + (*ResourceList)->List[0].PartialResourceList.Revision = 1; + (*ResourceList)->List[0].PartialResourceList.Count = 0; + + ResDesc = &(*ResourceList)->List[0].PartialResourceList.PartialDescriptors[0]; + + for (i = 0; i < RequirementsList->AlternativeLists; i++) + { + PIO_RESOURCE_LIST ResList = &RequirementsList->List[i]; + for (ii = 0; ii < ResList->Count; ii++) + { + PIO_RESOURCE_DESCRIPTOR ReqDesc = &ResList->Descriptors[ii]; + + /* FIXME: Handle alternate ranges */ + if (ReqDesc->Option == IO_RESOURCE_ALTERNATIVE) + continue; + + ResDesc->Type = ReqDesc->Type; + ResDesc->Flags = ReqDesc->Flags; + ResDesc->ShareDisposition = ReqDesc->ShareDisposition; + + switch (ReqDesc->Type) + { + case CmResourceTypeInterrupt: + if (!IopFindInterruptResource(ReqDesc, ResDesc)) + { + DPRINT1("Failed to find an available interrupt resource (0x%x to 0x%x)\n", + ReqDesc->u.Interrupt.MinimumVector, ReqDesc->u.Interrupt.MaximumVector); + + if (ReqDesc->Option == 0) + { + ExFreePool(*ResourceList); + return STATUS_CONFLICTING_ADDRESSES; + } + } + break; + + case CmResourceTypePort: + if (!IopFindPortResource(ReqDesc, ResDesc)) + { + DPRINT1("Failed to find an available port resource (0x%x to 0x%x length: 0x%x)\n", + ReqDesc->u.Port.MinimumAddress.QuadPart, ReqDesc->u.Port.MaximumAddress.QuadPart, + ReqDesc->u.Port.Length); + + if (ReqDesc->Option == 0) + { + ExFreePool(*ResourceList); + return STATUS_CONFLICTING_ADDRESSES; + } + } + break; + + case CmResourceTypeMemory: + if (!IopFindMemoryResource(ReqDesc, ResDesc)) + { + DPRINT1("Failed to find an available memory resource (0x%x to 0x%x length: 0x%x)\n", + ReqDesc->u.Memory.MinimumAddress.QuadPart, ReqDesc->u.Memory.MaximumAddress.QuadPart, + ReqDesc->u.Memory.Length); + + if (ReqDesc->Option == 0) + { + ExFreePool(*ResourceList); + return STATUS_CONFLICTING_ADDRESSES; + } + } + break; + + case CmResourceTypeBusNumber: + if (!IopFindBusNumberResource(ReqDesc, ResDesc)) + { + DPRINT1("Failed to find an available bus number resource (0x%x to 0x%x length: 0x%x)\n", + ReqDesc->u.BusNumber.MinBusNumber, ReqDesc->u.BusNumber.MaxBusNumber, + ReqDesc->u.BusNumber.Length); + + if (ReqDesc->Option == 0) + { + ExFreePool(*ResourceList); + return STATUS_CONFLICTING_ADDRESSES; + } + } + break; + + case CmResourceTypeDma: + if (!IopFindDmaResource(ReqDesc, ResDesc)) + { + DPRINT1("Failed to find an available dma resource (0x%x to 0x%x)\n", + ReqDesc->u.Dma.MinimumChannel, ReqDesc->u.Dma.MaximumChannel); + + if (ReqDesc->Option == 0) + { + ExFreePool(*ResourceList); + return STATUS_CONFLICTING_ADDRESSES; + } + } + break; + + default: + DPRINT1("Unsupported resource type: %x\n", ReqDesc->Type); + break; + } + + (*ResourceList)->List[0].PartialResourceList.Count++; + ResDesc++; + } + } + + return STATUS_SUCCESS; +} + +static +BOOLEAN +IopCheckResourceDescriptor( + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc, + IN PCM_RESOURCE_LIST ResourceList, + IN BOOLEAN Silent, + OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) +{ + ULONG i, ii; + BOOLEAN Result = FALSE; + + if (ResDesc->ShareDisposition == CmResourceShareShared) + return FALSE; + + for (i = 0; i < ResourceList->Count; i++) + { + PCM_PARTIAL_RESOURCE_LIST ResList = &ResourceList->List[i].PartialResourceList; + for (ii = 0; ii < ResList->Count; ii++) + { + PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc2 = &ResList->PartialDescriptors[ii]; + + /* We don't care about shared resources */ + if (ResDesc->ShareDisposition == CmResourceShareShared && + ResDesc2->ShareDisposition == CmResourceShareShared) + continue; + + /* Make sure we're comparing the same types */ + if (ResDesc->Type != ResDesc2->Type) + continue; + + switch (ResDesc->Type) + { + case CmResourceTypeMemory: + if ((ResDesc->u.Memory.Start.QuadPart < ResDesc2->u.Memory.Start.QuadPart && + ResDesc->u.Memory.Start.QuadPart + ResDesc->u.Memory.Length > + ResDesc2->u.Memory.Start.QuadPart) || (ResDesc2->u.Memory.Start.QuadPart < + ResDesc->u.Memory.Start.QuadPart && ResDesc2->u.Memory.Start.QuadPart + + ResDesc2->u.Memory.Length > ResDesc->u.Memory.Start.QuadPart)) + { + if (!Silent) + { + DPRINT1("Resource conflict: Memory (0x%x to 0x%x vs. 0x%x to 0x%x)\n", + ResDesc->u.Memory.Start.QuadPart, ResDesc->u.Memory.Start.QuadPart + + ResDesc->u.Memory.Length, ResDesc2->u.Memory.Start.QuadPart, + ResDesc2->u.Memory.Start.QuadPart + ResDesc2->u.Memory.Length); + } + + Result = TRUE; + + goto ByeBye; + } + break; + + case CmResourceTypePort: + if ((ResDesc->u.Port.Start.QuadPart < ResDesc2->u.Port.Start.QuadPart && + ResDesc->u.Port.Start.QuadPart + ResDesc->u.Port.Length > + ResDesc2->u.Port.Start.QuadPart) || (ResDesc2->u.Port.Start.QuadPart < + ResDesc->u.Port.Start.QuadPart && ResDesc2->u.Port.Start.QuadPart + + ResDesc2->u.Port.Length > ResDesc->u.Port.Start.QuadPart)) + { + if (!Silent) + { + DPRINT1("Resource conflict: Port (0x%x to 0x%x vs. 0x%x to 0x%x)\n", + ResDesc->u.Port.Start.QuadPart, ResDesc->u.Port.Start.QuadPart + + ResDesc->u.Port.Length, ResDesc2->u.Port.Start.QuadPart, + ResDesc2->u.Port.Start.QuadPart + ResDesc2->u.Port.Length); + } + + Result = TRUE; + + goto ByeBye; + } + break; + + case CmResourceTypeInterrupt: + if (ResDesc->u.Interrupt.Vector == ResDesc2->u.Interrupt.Vector) + { + if (!Silent) + { + DPRINT1("Resource conflict: IRQ (0x%x 0x%x vs. 0x%x 0x%x)\n", + ResDesc->u.Interrupt.Vector, ResDesc->u.Interrupt.Level, + ResDesc2->u.Interrupt.Vector, ResDesc2->u.Interrupt.Level); + } + + Result = TRUE; + + goto ByeBye; + } + break; + + case CmResourceTypeBusNumber: + if ((ResDesc->u.BusNumber.Start < ResDesc2->u.BusNumber.Start && + ResDesc->u.BusNumber.Start + ResDesc->u.BusNumber.Length > + ResDesc2->u.BusNumber.Start) || (ResDesc2->u.BusNumber.Start < + ResDesc->u.BusNumber.Start && ResDesc2->u.BusNumber.Start + + ResDesc2->u.BusNumber.Length > ResDesc->u.BusNumber.Start)) + { + if (!Silent) + { + DPRINT1("Resource conflict: Bus number (0x%x to 0x%x vs. 0x%x to 0x%x)\n", + ResDesc->u.BusNumber.Start, ResDesc->u.BusNumber.Start + + ResDesc->u.BusNumber.Length, ResDesc2->u.BusNumber.Start, + ResDesc2->u.BusNumber.Start + ResDesc2->u.BusNumber.Length); + } + + Result = TRUE; + + goto ByeBye; + } + break; + + case CmResourceTypeDma: + if (ResDesc->u.Dma.Channel == ResDesc2->u.Dma.Channel) + { + if (!Silent) + { + DPRINT1("Resource conflict: Dma (0x%x 0x%x vs. 0x%x 0x%x)\n", + ResDesc->u.Dma.Channel, ResDesc->u.Dma.Port, + ResDesc2->u.Dma.Channel, ResDesc2->u.Dma.Port); + } + + Result = TRUE; + + goto ByeBye; + } + break; + } + } + } + +ByeBye: + + if (Result && ConflictingDescriptor) + { + RtlCopyMemory(ConflictingDescriptor, + ResDesc, + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); + } + + return Result; +} + +static +NTSTATUS +IopUpdateControlKeyWithResources(IN PDEVICE_NODE DeviceNode) +{ + UNICODE_STRING EnumRoot = RTL_CONSTANT_STRING(ENUM_ROOT); + UNICODE_STRING Control = RTL_CONSTANT_STRING(L"Control"); + UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"AllocConfig"); + HANDLE EnumKey, InstanceKey, ControlKey; + NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + + /* Open the Enum key */ + Status = IopOpenRegistryKeyEx(&EnumKey, NULL, &EnumRoot, KEY_ENUMERATE_SUB_KEYS); + if (!NT_SUCCESS(Status)) + return Status; + + /* Open the instance key (eg. Root\PNP0A03) */ + Status = IopOpenRegistryKeyEx(&InstanceKey, EnumKey, &DeviceNode->InstancePath, KEY_ENUMERATE_SUB_KEYS); + ZwClose(EnumKey); + + if (!NT_SUCCESS(Status)) + return Status; + + /* Create/Open the Control key */ + InitializeObjectAttributes(&ObjectAttributes, + &Control, + OBJ_CASE_INSENSITIVE, + InstanceKey, + NULL); + Status = ZwCreateKey(&ControlKey, + KEY_SET_VALUE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + ZwClose(InstanceKey); + + if (!NT_SUCCESS(Status)) + return Status; + + /* Write the resource list */ + Status = ZwSetValueKey(ControlKey, + &ValueName, + 0, + REG_RESOURCE_LIST, + DeviceNode->ResourceList, + IopCalculateResourceListSize(DeviceNode->ResourceList)); + ZwClose(ControlKey); + + if (!NT_SUCCESS(Status)) + return Status; + + return STATUS_SUCCESS; +} + +static +NTSTATUS +IopFilterResourceRequirements(IN PDEVICE_NODE DeviceNode) +{ + IO_STACK_LOCATION Stack; + IO_STATUS_BLOCK IoStatusBlock; + NTSTATUS Status; + + DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n"); + + Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList = DeviceNode->ResourceRequirements; + Status = IopInitiatePnpIrp( + DeviceNode->PhysicalDeviceObject, + &IoStatusBlock, + IRP_MN_FILTER_RESOURCE_REQUIREMENTS, + &Stack); + if (!NT_SUCCESS(Status) && Status != STATUS_NOT_SUPPORTED) + { + DPRINT("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS) failed\n"); + return Status; + } + else if (NT_SUCCESS(Status)) + { + DeviceNode->ResourceRequirements = (PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information; + } + + return STATUS_SUCCESS; +} + + +NTSTATUS +IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2Key) +{ + NTSTATUS Status; + ULONG Disposition; + HANDLE PnpMgrLevel1, PnpMgrLevel2, ResourceMapKey; + UNICODE_STRING KeyName; + OBJECT_ATTRIBUTES ObjectAttributes; + + RtlInitUnicodeString(&KeyName, + L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE | OBJ_OPENIF, + 0, + NULL); + Status = ZwCreateKey(&ResourceMapKey, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + &Disposition); + if (!NT_SUCCESS(Status)) + return Status; + + RtlInitUnicodeString(&KeyName, Level1Key); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE | OBJ_OPENIF, + ResourceMapKey, + NULL); + Status = ZwCreateKey(&PnpMgrLevel1, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + &Disposition); + ZwClose(ResourceMapKey); + if (!NT_SUCCESS(Status)) + return Status; + + RtlInitUnicodeString(&KeyName, Level2Key); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE | OBJ_OPENIF, + PnpMgrLevel1, + NULL); + Status = ZwCreateKey(&PnpMgrLevel2, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + &Disposition); + ZwClose(PnpMgrLevel1); + if (!NT_SUCCESS(Status)) + return Status; + + if (DeviceNode->ResourceList) + { + WCHAR NameBuff[256]; + UNICODE_STRING NameU; + UNICODE_STRING Suffix; + ULONG OldLength; + + ASSERT(DeviceNode->ResourceListTranslated); + + NameU.Buffer = NameBuff; + NameU.Length = 0; + NameU.MaximumLength = 256 * sizeof(WCHAR); + + Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject, + DevicePropertyPhysicalDeviceObjectName, + NameU.MaximumLength, + NameU.Buffer, + &OldLength); + ASSERT(Status == STATUS_SUCCESS); + + NameU.Length = (USHORT)OldLength; + + RtlInitUnicodeString(&Suffix, L".Raw"); + RtlAppendUnicodeStringToString(&NameU, &Suffix); + + Status = ZwSetValueKey(PnpMgrLevel2, + &NameU, + 0, + REG_RESOURCE_LIST, + DeviceNode->ResourceList, + IopCalculateResourceListSize(DeviceNode->ResourceList)); + if (!NT_SUCCESS(Status)) + { + ZwClose(PnpMgrLevel2); + return Status; + } + + /* "Remove" the suffix by setting the length back to what it used to be */ + NameU.Length = (USHORT)OldLength; + + RtlInitUnicodeString(&Suffix, L".Translated"); + RtlAppendUnicodeStringToString(&NameU, &Suffix); + + Status = ZwSetValueKey(PnpMgrLevel2, + &NameU, + 0, + REG_RESOURCE_LIST, + DeviceNode->ResourceListTranslated, + IopCalculateResourceListSize(DeviceNode->ResourceListTranslated)); + ZwClose(PnpMgrLevel2); + if (!NT_SUCCESS(Status)) + return Status; + } + else + { + ZwClose(PnpMgrLevel2); + } + + return STATUS_SUCCESS; +} + +NTSTATUS +IopUpdateResourceMapForPnPDevice(IN PDEVICE_NODE DeviceNode) +{ + return IopUpdateResourceMap(DeviceNode, L"PnP Manager", L"PnpManager"); +} + +static +NTSTATUS +IopTranslateDeviceResources( + IN PDEVICE_NODE DeviceNode) +{ + PCM_PARTIAL_RESOURCE_LIST pPartialResourceList; + PCM_PARTIAL_RESOURCE_DESCRIPTOR DescriptorRaw, DescriptorTranslated; + ULONG i, j, ListSize; + NTSTATUS Status; + + if (!DeviceNode->ResourceList) + { + DeviceNode->ResourceListTranslated = NULL; + return STATUS_SUCCESS; + } + + /* That's easy to translate a resource list. Just copy the + * untranslated one and change few fields in the copy + */ + ListSize = IopCalculateResourceListSize(DeviceNode->ResourceList); + + DeviceNode->ResourceListTranslated = ExAllocatePool(PagedPool, ListSize); + if (!DeviceNode->ResourceListTranslated) + { + Status =STATUS_NO_MEMORY; + goto cleanup; + } + RtlCopyMemory(DeviceNode->ResourceListTranslated, DeviceNode->ResourceList, ListSize); + + for (i = 0; i < DeviceNode->ResourceList->Count; i++) + { + pPartialResourceList = &DeviceNode->ResourceList->List[i].PartialResourceList; + for (j = 0; j < pPartialResourceList->Count; j++) + { + DescriptorRaw = &pPartialResourceList->PartialDescriptors[j]; + DescriptorTranslated = &DeviceNode->ResourceListTranslated->List[i].PartialResourceList.PartialDescriptors[j]; + switch (DescriptorRaw->Type) + { + case CmResourceTypePort: + { + ULONG AddressSpace = 1; /* IO space */ + if (!HalTranslateBusAddress( + DeviceNode->ResourceList->List[i].InterfaceType, + DeviceNode->ResourceList->List[i].BusNumber, + DescriptorRaw->u.Port.Start, + &AddressSpace, + &DescriptorTranslated->u.Port.Start)) + { + Status = STATUS_UNSUCCESSFUL; + goto cleanup; + } + break; + } + case CmResourceTypeInterrupt: + { + DescriptorTranslated->u.Interrupt.Vector = HalGetInterruptVector( + DeviceNode->ResourceList->List[i].InterfaceType, + DeviceNode->ResourceList->List[i].BusNumber, + DescriptorRaw->u.Interrupt.Level, + DescriptorRaw->u.Interrupt.Vector, + (PKIRQL)&DescriptorTranslated->u.Interrupt.Level, + &DescriptorRaw->u.Interrupt.Affinity); + break; + } + case CmResourceTypeMemory: + { + ULONG AddressSpace = 0; /* Memory space */ + if (!HalTranslateBusAddress( + DeviceNode->ResourceList->List[i].InterfaceType, + DeviceNode->ResourceList->List[i].BusNumber, + DescriptorRaw->u.Memory.Start, + &AddressSpace, + &DescriptorTranslated->u.Memory.Start)) + { + Status = STATUS_UNSUCCESSFUL; + goto cleanup; + } + } + + case CmResourceTypeDma: + case CmResourceTypeBusNumber: + case CmResourceTypeDeviceSpecific: + /* Nothing to do */ + break; + default: + DPRINT1("Unknown resource descriptor type 0x%x\n", DescriptorRaw->Type); + Status = STATUS_NOT_IMPLEMENTED; + goto cleanup; + } + } + } + return STATUS_SUCCESS; + +cleanup: + /* Yes! Also delete ResourceList because ResourceList and + * ResourceListTranslated should be a pair! */ + ExFreePool(DeviceNode->ResourceList); + DeviceNode->ResourceList = NULL; + if (DeviceNode->ResourceListTranslated) + { + ExFreePool(DeviceNode->ResourceListTranslated); + DeviceNode->ResourceList = NULL; + } + return Status; +} + +NTSTATUS +NTAPI +IopAssignDeviceResources( + IN PDEVICE_NODE DeviceNode) +{ + NTSTATUS Status; + ULONG ListSize; + + IopDeviceNodeSetFlag(DeviceNode, DNF_ASSIGNING_RESOURCES); + + Status = IopFilterResourceRequirements(DeviceNode); + if (!NT_SUCCESS(Status)) + goto ByeBye; + + if (!DeviceNode->BootResources && !DeviceNode->ResourceRequirements) + { + DeviceNode->Flags |= DNF_NO_RESOURCE_REQUIRED; + + /* No resource needed for this device */ + DeviceNode->ResourceList = NULL; + DeviceNode->ResourceListTranslated = NULL; + + return STATUS_SUCCESS; + } + + /* Fill DeviceNode->ResourceList + * FIXME: the PnP arbiter should go there! + * Actually, use the BootResources if provided, else the resource requirements + */ + + if (DeviceNode->BootResources) + { + ListSize = IopCalculateResourceListSize(DeviceNode->BootResources); + + DeviceNode->ResourceList = ExAllocatePool(PagedPool, ListSize); + if (!DeviceNode->ResourceList) + { + Status = STATUS_NO_MEMORY; + goto ByeBye; + } + RtlCopyMemory(DeviceNode->ResourceList, DeviceNode->BootResources, ListSize); + + Status = IopDetectResourceConflict(DeviceNode->ResourceList, FALSE, NULL); + if (NT_SUCCESS(Status) || !DeviceNode->ResourceRequirements) + { + if (!NT_SUCCESS(Status) && !DeviceNode->ResourceRequirements) + { + DPRINT1("Using conflicting boot resources because no requirements were supplied!\n"); + } + + goto Finish; + } + else + { + DPRINT1("Boot resources for %wZ cause a resource conflict!\n", &DeviceNode->InstancePath); + ExFreePool(DeviceNode->ResourceList); + } + } + + Status = IopCreateResourceListFromRequirements(DeviceNode->ResourceRequirements, + &DeviceNode->ResourceList); + if (!NT_SUCCESS(Status)) + goto ByeBye; + + Status = IopDetectResourceConflict(DeviceNode->ResourceList, FALSE, NULL); + if (!NT_SUCCESS(Status)) + goto ByeBye; + +Finish: + Status = IopTranslateDeviceResources(DeviceNode); + if (!NT_SUCCESS(Status)) + goto ByeBye; + + Status = IopUpdateResourceMapForPnPDevice(DeviceNode); + if (!NT_SUCCESS(Status)) + goto ByeBye; + + Status = IopUpdateControlKeyWithResources(DeviceNode); + if (!NT_SUCCESS(Status)) + goto ByeBye; + + IopDeviceNodeSetFlag(DeviceNode, DNF_RESOURCE_ASSIGNED); + + IopDeviceNodeClearFlag(DeviceNode, DNF_ASSIGNING_RESOURCES); + + return STATUS_SUCCESS; + +ByeBye: + if (DeviceNode->ResourceList) + { + ExFreePool(DeviceNode->ResourceList); + DeviceNode->ResourceList = NULL; + } + + DeviceNode->ResourceListTranslated = NULL; + + IopDeviceNodeClearFlag(DeviceNode, DNF_ASSIGNING_RESOURCES); + + return Status; +} + +static +BOOLEAN +IopCheckForResourceConflict( + IN PCM_RESOURCE_LIST ResourceList1, + IN PCM_RESOURCE_LIST ResourceList2, + IN BOOLEAN Silent, + OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) +{ + ULONG i, ii; + BOOLEAN Result = FALSE; + + for (i = 0; i < ResourceList1->Count; i++) + { + PCM_PARTIAL_RESOURCE_LIST ResList = &ResourceList1->List[i].PartialResourceList; + for (ii = 0; ii < ResList->Count; ii++) + { + PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc = &ResList->PartialDescriptors[ii]; + + Result = IopCheckResourceDescriptor(ResDesc, + ResourceList2, + Silent, + ConflictingDescriptor); + if (Result) goto ByeBye; + } + } + + +ByeBye: + + return Result; +} + +NTSTATUS +IopDetectResourceConflict( + IN PCM_RESOURCE_LIST ResourceList, + IN BOOLEAN Silent, + OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING KeyName; + HANDLE ResourceMapKey = INVALID_HANDLE_VALUE, ChildKey2 = INVALID_HANDLE_VALUE, ChildKey3 = INVALID_HANDLE_VALUE; + ULONG KeyInformationLength, RequiredLength, KeyValueInformationLength, KeyNameInformationLength; + PKEY_BASIC_INFORMATION KeyInformation; + PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation; + PKEY_VALUE_BASIC_INFORMATION KeyNameInformation; + ULONG ChildKeyIndex1 = 0, ChildKeyIndex2 = 0, ChildKeyIndex3 = 0; + NTSTATUS Status; + + RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP"); + InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE, 0, NULL); + Status = ZwOpenKey(&ResourceMapKey, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + /* The key is missing which means we are the first device */ + return STATUS_SUCCESS; + } + + while (TRUE) + { + Status = ZwEnumerateKey(ResourceMapKey, + ChildKeyIndex1, + KeyBasicInformation, + NULL, + 0, + &RequiredLength); + if (Status == STATUS_NO_MORE_ENTRIES) + break; + else if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL) + { + KeyInformationLength = RequiredLength; + KeyInformation = ExAllocatePool(PagedPool, KeyInformationLength); + if (!KeyInformation) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto cleanup; + } + + Status = ZwEnumerateKey(ResourceMapKey, + ChildKeyIndex1, + KeyBasicInformation, + KeyInformation, + KeyInformationLength, + &RequiredLength); + } + else + goto cleanup; + ChildKeyIndex1++; + if (!NT_SUCCESS(Status)) + goto cleanup; + + KeyName.Buffer = KeyInformation->Name; + KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength; + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + ResourceMapKey, + NULL); + Status = ZwOpenKey(&ChildKey2, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes); + ExFreePool(KeyInformation); + if (!NT_SUCCESS(Status)) + goto cleanup; + + while (TRUE) + { + Status = ZwEnumerateKey(ChildKey2, + ChildKeyIndex2, + KeyBasicInformation, + NULL, + 0, + &RequiredLength); + if (Status == STATUS_NO_MORE_ENTRIES) + break; + else if (Status == STATUS_BUFFER_TOO_SMALL) + { + KeyInformationLength = RequiredLength; + KeyInformation = ExAllocatePool(PagedPool, KeyInformationLength); + if (!KeyInformation) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto cleanup; + } + + Status = ZwEnumerateKey(ChildKey2, + ChildKeyIndex2, + KeyBasicInformation, + KeyInformation, + KeyInformationLength, + &RequiredLength); + } + else + goto cleanup; + ChildKeyIndex2++; + if (!NT_SUCCESS(Status)) + goto cleanup; + + KeyName.Buffer = KeyInformation->Name; + KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength; + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + ChildKey2, + NULL); + Status = ZwOpenKey(&ChildKey3, KEY_QUERY_VALUE, &ObjectAttributes); + ExFreePool(KeyInformation); + if (!NT_SUCCESS(Status)) + goto cleanup; + + while (TRUE) + { + Status = ZwEnumerateValueKey(ChildKey3, + ChildKeyIndex3, + KeyValuePartialInformation, + NULL, + 0, + &RequiredLength); + if (Status == STATUS_NO_MORE_ENTRIES) + break; + else if (Status == STATUS_BUFFER_TOO_SMALL) + { + KeyValueInformationLength = RequiredLength; + KeyValueInformation = ExAllocatePool(PagedPool, KeyValueInformationLength); + if (!KeyValueInformation) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto cleanup; + } + + Status = ZwEnumerateValueKey(ChildKey3, + ChildKeyIndex3, + KeyValuePartialInformation, + KeyValueInformation, + KeyValueInformationLength, + &RequiredLength); + } + else + goto cleanup; + if (!NT_SUCCESS(Status)) + goto cleanup; + + Status = ZwEnumerateValueKey(ChildKey3, + ChildKeyIndex3, + KeyValueBasicInformation, + NULL, + 0, + &RequiredLength); + if (Status == STATUS_BUFFER_TOO_SMALL) + { + KeyNameInformationLength = RequiredLength; + KeyNameInformation = ExAllocatePool(PagedPool, KeyNameInformationLength + sizeof(WCHAR)); + if (!KeyNameInformation) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + goto cleanup; + } + + Status = ZwEnumerateValueKey(ChildKey3, + ChildKeyIndex3, + KeyValueBasicInformation, + KeyNameInformation, + KeyNameInformationLength, + &RequiredLength); + } + else + goto cleanup; + + ChildKeyIndex3++; + + if (!NT_SUCCESS(Status)) + goto cleanup; + + KeyNameInformation->Name[KeyNameInformation->NameLength / sizeof(WCHAR)] = UNICODE_NULL; + + /* Skip translated entries */ + if (wcsstr(KeyNameInformation->Name, L".Translated")) + { + ExFreePool(KeyNameInformation); + continue; + } + + ExFreePool(KeyNameInformation); + + if (IopCheckForResourceConflict(ResourceList, + (PCM_RESOURCE_LIST)KeyValueInformation->Data, + Silent, + ConflictingDescriptor)) + { + ExFreePool(KeyValueInformation); + Status = STATUS_CONFLICTING_ADDRESSES; + goto cleanup; + } + + ExFreePool(KeyValueInformation); + } + } + } + +cleanup: + if (ResourceMapKey != INVALID_HANDLE_VALUE) + ZwClose(ResourceMapKey); + if (ChildKey2 != INVALID_HANDLE_VALUE) + ZwClose(ChildKey2); + if (ChildKey3 != INVALID_HANDLE_VALUE) + ZwClose(ChildKey3); + + if (Status == STATUS_NO_MORE_ENTRIES) + Status = STATUS_SUCCESS; + + return Status; +} + Propchange: trunk/reactos/ntoskrnl/io/pnpmgr/pnpres.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl-generic.…
============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] Thu Apr 22 00:33:11 2010 @@ -270,6 +270,7 @@ <file>pnpmgr.c</file> <file>pnpnotify.c</file> <file>pnpreport.c</file> + <file>pnpres.c</file> <file>pnproot.c</file> <file>pnputil.c</file> </directory>
14 years, 8 months
1
0
0
0
[fireball] 46982: [WINESYNC] - Sync comdlg32, crypt32, gdiplus, inetcomm, jscript, msctf, mshtml, msxml3, rsaenh, schannel, shlwapi, urlmon, usp10, wininet winetests.
by fireball@svn.reactos.org
Author: fireball Date: Wed Apr 21 22:35:09 2010 New Revision: 46982 URL:
http://svn.reactos.org/svn/reactos?rev=46982&view=rev
Log: [WINESYNC] - Sync comdlg32, crypt32, gdiplus, inetcomm, jscript, msctf, mshtml, msxml3, rsaenh, schannel, shlwapi, urlmon, usp10, wininet winetests. Added: trunk/rostests/winetests/comdlg32/fontdlg.c (with props) Modified: trunk/rostests/winetests/comdlg32/comdlg32.rbuild trunk/rostests/winetests/comdlg32/filedlg.c trunk/rostests/winetests/comdlg32/printdlg.c trunk/rostests/winetests/comdlg32/rsrc.rc trunk/rostests/winetests/crypt32/chain.c trunk/rostests/winetests/crypt32/main.c trunk/rostests/winetests/crypt32/msg.c trunk/rostests/winetests/gdiplus/brush.c trunk/rostests/winetests/gdiplus/font.c trunk/rostests/winetests/gdiplus/graphics.c trunk/rostests/winetests/gdiplus/image.c trunk/rostests/winetests/inetcomm/mimeintl.c trunk/rostests/winetests/jscript/regexp.js trunk/rostests/winetests/msctf/inputprocessor.c trunk/rostests/winetests/mshtml/dom.c trunk/rostests/winetests/mshtml/events.c trunk/rostests/winetests/mshtml/jstest.html trunk/rostests/winetests/mshtml/script.c trunk/rostests/winetests/msxml3/domdoc.c trunk/rostests/winetests/rsaenh/rsaenh.c trunk/rostests/winetests/schannel/main.c trunk/rostests/winetests/shlwapi/generated.c trunk/rostests/winetests/shlwapi/istream.c trunk/rostests/winetests/shlwapi/ordinal.c trunk/rostests/winetests/shlwapi/path.c trunk/rostests/winetests/shlwapi/shlwapi.rbuild trunk/rostests/winetests/shlwapi/string.c trunk/rostests/winetests/shlwapi/url.c trunk/rostests/winetests/urlmon/generated.c trunk/rostests/winetests/urlmon/misc.c trunk/rostests/winetests/urlmon/sec_mgr.c trunk/rostests/winetests/urlmon/url.c trunk/rostests/winetests/usp10/usp10.c trunk/rostests/winetests/wininet/ftp.c trunk/rostests/winetests/wininet/generated.c trunk/rostests/winetests/wininet/http.c trunk/rostests/winetests/wininet/internet.c trunk/rostests/winetests/wininet/url.c trunk/rostests/winetests/wininet/urlcache.c trunk/rostests/winetests/wininet/wininet.rbuild [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/rostests/winetests/comdlg32/comdlg32.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/comdlg32/comdlg…
Modified: trunk/rostests/winetests/comdlg32/filedlg.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/comdlg32/filedl…
Added: trunk/rostests/winetests/comdlg32/fontdlg.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/comdlg32/fontdl…
Modified: trunk/rostests/winetests/comdlg32/printdlg.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/comdlg32/printd…
Modified: trunk/rostests/winetests/comdlg32/rsrc.rc URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/comdlg32/rsrc.r…
Modified: trunk/rostests/winetests/crypt32/chain.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/crypt32/chain.c…
Modified: trunk/rostests/winetests/crypt32/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/crypt32/main.c?…
Modified: trunk/rostests/winetests/crypt32/msg.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/crypt32/msg.c?r…
Modified: trunk/rostests/winetests/gdiplus/brush.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/brush.c…
Modified: trunk/rostests/winetests/gdiplus/font.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/font.c?…
Modified: trunk/rostests/winetests/gdiplus/graphics.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/graphic…
Modified: trunk/rostests/winetests/gdiplus/image.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/image.c…
Modified: trunk/rostests/winetests/inetcomm/mimeintl.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/inetcomm/mimein…
Modified: trunk/rostests/winetests/jscript/regexp.js URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/jscript/regexp.…
Modified: trunk/rostests/winetests/msctf/inputprocessor.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msctf/inputproc…
Modified: trunk/rostests/winetests/mshtml/dom.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mshtml/dom.c?re…
Modified: trunk/rostests/winetests/mshtml/events.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mshtml/events.c…
Modified: trunk/rostests/winetests/mshtml/jstest.html URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mshtml/jstest.h…
Modified: trunk/rostests/winetests/mshtml/script.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/mshtml/script.c…
Modified: trunk/rostests/winetests/msxml3/domdoc.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msxml3/domdoc.c…
Modified: trunk/rostests/winetests/rsaenh/rsaenh.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/rsaenh/rsaenh.c…
Modified: trunk/rostests/winetests/schannel/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/schannel/main.c…
Modified: trunk/rostests/winetests/shlwapi/generated.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/shlwapi/generat…
Modified: trunk/rostests/winetests/shlwapi/istream.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/shlwapi/istream…
Modified: trunk/rostests/winetests/shlwapi/ordinal.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/shlwapi/ordinal…
Modified: trunk/rostests/winetests/shlwapi/path.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/shlwapi/path.c?…
Modified: trunk/rostests/winetests/shlwapi/shlwapi.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/shlwapi/shlwapi…
Modified: trunk/rostests/winetests/shlwapi/string.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/shlwapi/string.…
Modified: trunk/rostests/winetests/shlwapi/url.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/shlwapi/url.c?r…
Modified: trunk/rostests/winetests/urlmon/generated.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/urlmon/generate…
Modified: trunk/rostests/winetests/urlmon/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/urlmon/misc.c?r…
Modified: trunk/rostests/winetests/urlmon/sec_mgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/urlmon/sec_mgr.…
Modified: trunk/rostests/winetests/urlmon/url.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/urlmon/url.c?re…
Modified: trunk/rostests/winetests/usp10/usp10.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/usp10/usp10.c?r…
Modified: trunk/rostests/winetests/wininet/ftp.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/ftp.c?r…
Modified: trunk/rostests/winetests/wininet/generated.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/generat…
Modified: trunk/rostests/winetests/wininet/http.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/http.c?…
Modified: trunk/rostests/winetests/wininet/internet.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/interne…
Modified: trunk/rostests/winetests/wininet/url.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/url.c?r…
Modified: trunk/rostests/winetests/wininet/urlcache.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/urlcach…
Modified: trunk/rostests/winetests/wininet/wininet.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/wininet…
14 years, 8 months
1
0
0
0
[jgardou] 46981: [WIN32K] - Use the attached surface bits depth when creating a compatible DC [USER32] - use a display DC for loading images
by jgardou@svn.reactos.org
Author: jgardou Date: Wed Apr 21 17:52:52 2010 New Revision: 46981 URL:
http://svn.reactos.org/svn/reactos?rev=46981&view=rev
Log: [WIN32K] - Use the attached surface bits depth when creating a compatible DC [USER32] - use a display DC for loading images Modified: branches/reactos-yarotows/dll/win32/user32/windows/bitmap.c branches/reactos-yarotows/dll/win32/user32/windows/icon.c branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c Modified: branches/reactos-yarotows/dll/win32/user32/windows/bitmap.c URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/dll/win32/user…
============================================================================== --- branches/reactos-yarotows/dll/win32/user32/windows/bitmap.c [iso-8859-1] (original) +++ branches/reactos-yarotows/dll/win32/user32/windows/bitmap.c [iso-8859-1] Wed Apr 21 17:52:52 2010 @@ -491,10 +491,10 @@ UnmapViewOfFile(BitmapInfo); return NULL; } - + /* FIXME: Handle color conversion and transparency. */ - hScreenDc = CreateCompatibleDC(NULL); + hScreenDc = CreateDCW(L"DISPLAY", NULL, NULL, NULL); if (hScreenDc == NULL) { RtlFreeHeap(GetProcessHeap(), 0, PrivateInfo); Modified: branches/reactos-yarotows/dll/win32/user32/windows/icon.c URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/dll/win32/user…
============================================================================== --- branches/reactos-yarotows/dll/win32/user32/windows/icon.c [iso-8859-1] (original) +++ branches/reactos-yarotows/dll/win32/user32/windows/icon.c [iso-8859-1] Wed Apr 21 17:52:52 2010 @@ -140,7 +140,7 @@ ICONINFO IconInfo; IconInfo.fIcon = TRUE; - + if (cBitsPixel == 1) { nHeight <<= 1; @@ -159,7 +159,7 @@ { IconInfo.hbmColor = CreateBitmap(nWidth, nHeight, cPlanes, cBitsPixel, XORbits); if(!IconInfo.hbmColor) - { + { DeleteObject(IconInfo.hbmMask); return (HICON)0; } @@ -260,9 +260,7 @@ Data = (PBYTE)SafeIconImage + HeaderSize; /* get a handle to the screen dc, the icon we create is going to be compatable with this */ - // FIXME!!! This is a victim of the Win32k Initialization BUG!!!!! - //hScreenDc = CreateDCW(NULL, NULL, NULL, NULL); - hScreenDc = CreateCompatibleDC(NULL); + hScreenDc = CreateDCW(L"DISPLAY", NULL, NULL, NULL); if (hScreenDc == NULL) { RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage); Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
============================================================================== --- branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original) +++ branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Wed Apr 21 17:52:52 2010 @@ -176,7 +176,7 @@ Bmp = IntGdiCreateBitmap(abs(Width), abs(Height), dibs.dsBm.bmPlanes, - Dc->ppdev->gdiinfo.cBitsPixel,//<-- HACK! dibs.dsBm.bmBitsPixel, // <-- Correct! + dibs.dsBm.bmBitsPixel, NULL); } else @@ -665,7 +665,7 @@ switch (*Color >> 24) { case 0x10: /* DIBINDEX */ - if (IntGetDIBColorTable(hDC, LOWORD(*Color), 1, &quad) == 1) + if (IntGetDIBColorTable(hDC, LOWORD(*Color), 1, &quad) == 1) { *Color = RGB(quad.rgbRed, quad.rgbGreen, quad.rgbBlue); } @@ -707,7 +707,7 @@ default: DPRINT("Unsupported color type %d passed\n", *Color >> 24); break; - } + } } BOOL APIENTRY
14 years, 8 months
1
0
0
0
[tkreuzer] 46980: [WIN32K] Update text and background brush properly. Fixes wrong colors in radio buttons in Firefox. Fix by Jerome Gardou. See issue #5311 for more details.
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Apr 21 17:15:57 2010 New Revision: 46980 URL:
http://svn.reactos.org/svn/reactos?rev=46980&view=rev
Log: [WIN32K] Update text and background brush properly. Fixes wrong colors in radio buttons in Firefox. Fix by Jerome Gardou. See issue #5311 for more details. Modified: trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c Modified: trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] Wed Apr 21 17:15:57 2010 @@ -110,6 +110,9 @@ { PDC_ATTR pdcattr = pdc->pdcattr; + if(pdcattr->ulDirty_ & DIRTY_TEXT) + EBRUSHOBJ_vUpdate(&pdc->eboText, pdc->eboText.pbrush, pdc); + /* Update the eboText's solid color */ EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboText, pdcattr->crForegroundClr); @@ -122,6 +125,9 @@ DC_vUpdateBackgroundBrush(PDC pdc) { PDC_ATTR pdcattr = pdc->pdcattr; + + if(pdcattr->ulDirty_ & DIRTY_BACKGROUND) + EBRUSHOBJ_vUpdate(&pdc->eboBackground, pdc->eboBackground.pbrush, pdc); /* Update the eboBackground's solid color */ EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboBackground, pdcattr->crBackgroundClr);
14 years, 8 months
1
0
0
0
[tkreuzer] 46979: remove svn:mergeinfo
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Wed Apr 21 17:12:58 2010 New Revision: 46979 URL:
http://svn.reactos.org/svn/reactos?rev=46979&view=rev
Log: remove svn:mergeinfo Modified: trunk/reactos/lib/3rdparty/mingw/getopt.c (props changed) Propchange: trunk/reactos/lib/3rdparty/mingw/getopt.c ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo (removed) @@ -1,3 +1,0 @@ -/branches/header-work/lib/3rdparty/mingw/getopt.c:45691-46463 -/branches/ros-amd64-bringup/lib/3rdparty/mingw/getopt.c:36852 -/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/getopt.c:34711-34712,34741,34743,34780-34782,34803,34812,34839,34842,34864,34870,34874,34877,34908-34909,34917,34965,35323-35324,35347-35348,35361,35436,35509,35515,35588,35655,35683,35739,35746,35762,35771,35777,35781,35789,35805,35823,35827,35902,35904-35906,35942,35947-35949,35952-35953,35966,36011-36013,36172,36360,36380,36388-36389,36397,36445,36502-36503,36505,36570,36614,36898-36899,36930,36936,36949,36951,36958,36961,36964,36969,36972,36992,37323,37434,37472,37475,37536,37820-37821,37868-37869,37873,37990-37991,38013-38014,38092,38100,38148-38151,38264-38265,38268,38355,39151,39333,39335,39345,39639,40122-40123,40125,40128,40155,40247,40324,40753,40927-40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41030,41044-41045,41047-41050,41052,41070,41082-41086,41097-41098,41101,41449,41479,41484-41485,41499-41500,41502,41531,41536,41540,41546-41547,41549,43080,43426,43454,43506,43566,43574,43598,43600-43602,43604-43605,43677,43682,43757,43775,43836,43838-43840,43857-43858,43860,43905-43907,43969,44002,44036-44037,44039-44040,44044-44045,44065,44095,44123,44144,44205,44238,44294,44338-44339,44389,44391,44426,44460,44467-44468,44470-44471,44499,44501,44503-44504,44506,44510-44512,44521,44523-44526,44530,44540,44601,44772,45124,45126-45127,46394,46524,46526,46589
14 years, 8 months
1
0
0
0
[sir_richard] 46978: [NTOS]: Support unload of system modules by parsing the LoadedImports (implement MiDereferenceImports which was just a stub) and calling MiCallDllUnloadAndUnloadDll. [NTOS]: Fix a bug in MiClearImports.
by sir_richard@svn.reactos.org
Author: sir_richard Date: Wed Apr 21 16:14:45 2010 New Revision: 46978 URL:
http://svn.reactos.org/svn/reactos?rev=46978&view=rev
Log: [NTOS]: Support unload of system modules by parsing the LoadedImports (implement MiDereferenceImports which was just a stub) and calling MiCallDllUnloadAndUnloadDll. [NTOS]: Fix a bug in MiClearImports. Modified: trunk/reactos/ntoskrnl/mm/sysldr.c Modified: trunk/reactos/ntoskrnl/mm/sysldr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/sysldr.c?rev=4…
============================================================================== --- trunk/reactos/ntoskrnl/mm/sysldr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/sysldr.c [iso-8859-1] Wed Apr 21 16:14:45 2010 @@ -191,53 +191,10 @@ return Status; } -NTSTATUS -NTAPI -MiDereferenceImports(IN PLOAD_IMPORTS ImportList) -{ - SIZE_T i; - - /* Check if there's no imports or if we're a boot driver */ - if ((ImportList == (PVOID)-1) || - (ImportList == (PVOID)-2) || - (ImportList->Count == 0)) - { - /* Then there's nothing to do */ - return STATUS_SUCCESS; - } - - /* Otherwise, FIXME */ - DPRINT1("%u imports not dereferenced!\n", ImportList->Count); - for (i = 0; i < ImportList->Count; i++) - { - DPRINT1("%wZ <%wZ>\n", &ImportList->Entry[i]->FullDllName, &ImportList->Entry[i]->BaseDllName); - } - return STATUS_UNSUCCESSFUL; -} - -VOID -NTAPI -MiClearImports(IN PLDR_DATA_TABLE_ENTRY LdrEntry) -{ - PAGED_CODE(); - - /* Check if there's no imports or we're a boot driver or only one entry */ - if ((LdrEntry->LoadedImports == (PVOID)-1) || - (LdrEntry->LoadedImports == (PVOID)-2) || - ((ULONG_PTR)LdrEntry->LoadedImports & 1)) - { - /* Nothing to do */ - return; - } - - /* Otherwise, free the import list */ - ExFreePool(LdrEntry->LoadedImports); -} - PVOID NTAPI -MiFindExportedRoutineByName(IN PVOID DllBase, - IN PANSI_STRING ExportName) +MiLocateExportName(IN PVOID DllBase, + IN PCHAR ExportName) { PULONG NameTable; PUSHORT OrdinalTable; @@ -270,7 +227,7 @@ Mid = (Low + High) >> 1; /* Compare name */ - Ret = strcmp(ExportName->Buffer, (PCHAR)DllBase + NameTable[Mid]); + Ret = strcmp(ExportName, (PCHAR)DllBase + NameTable[Mid]); if (Ret < 0) { /* Update high */ @@ -299,16 +256,203 @@ ExportDirectory->AddressOfFunctions); Function = (PVOID)((ULONG_PTR)DllBase + ExportTable[Ordinal]); - /* We found it! */ - ASSERT(!(Function > (PVOID)ExportDirectory) && - (Function < (PVOID)((ULONG_PTR)ExportDirectory + ExportSize))); + /* Check if the function is actually a forwarder */ + if (((ULONG_PTR)Function > (ULONG_PTR)ExportDirectory) && + ((ULONG_PTR)Function < ((ULONG_PTR)ExportDirectory + ExportSize))) + { + /* It is, fail */ + return NULL; + } + + /* We found it */ return Function; +} + +NTSTATUS +NTAPI +MmCallDllInitialize(IN PLDR_DATA_TABLE_ENTRY LdrEntry, + IN PLIST_ENTRY ListHead) +{ + UNICODE_STRING ServicesKeyName = RTL_CONSTANT_STRING( + L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"); + PMM_DLL_INITIALIZE DllInit; + UNICODE_STRING RegPath, ImportName; + NTSTATUS Status; + + /* Try to see if the image exports a DllInitialize routine */ + DllInit = (PMM_DLL_INITIALIZE)MiLocateExportName(LdrEntry->DllBase, + "DllInitialize"); + if (!DllInit) return STATUS_SUCCESS; + + /* Do a temporary copy of BaseDllName called ImportName + * because we'll alter the length of the string + */ + ImportName.Length = LdrEntry->BaseDllName.Length; + ImportName.MaximumLength = LdrEntry->BaseDllName.MaximumLength; + ImportName.Buffer = LdrEntry->BaseDllName.Buffer; + + /* Obtain the path to this dll's service in the registry */ + RegPath.MaximumLength = ServicesKeyName.Length + + ImportName.Length + sizeof(UNICODE_NULL); + RegPath.Buffer = ExAllocatePoolWithTag(NonPagedPool, + RegPath.MaximumLength, + TAG_LDR_WSTR); + + /* Check if this allocation was unsuccessful */ + if (!RegPath.Buffer) return STATUS_INSUFFICIENT_RESOURCES; + + /* Build and append the service name itself */ + RegPath.Length = ServicesKeyName.Length; + RtlCopyMemory(RegPath.Buffer, + ServicesKeyName.Buffer, + ServicesKeyName.Length); + + /* Check if there is a dot in the filename */ + if (wcschr(ImportName.Buffer, L'.')) + { + /* Remove the extension */ + ImportName.Length = (wcschr(ImportName.Buffer, L'.') - + ImportName.Buffer) * sizeof(WCHAR); + } + + /* Append service name (the basename without extension) */ + RtlAppendUnicodeStringToString(&RegPath, &ImportName); + + /* Now call the DllInit func */ + DPRINT("Calling DllInit(%wZ)\n", &RegPath); + Status = DllInit(&RegPath); + + /* Clean up */ + ExFreePool(RegPath.Buffer); + + /* Return status value which DllInitialize returned */ + return Status; +} + +BOOLEAN +NTAPI +MiCallDllUnloadAndUnloadDll(IN PLDR_DATA_TABLE_ENTRY LdrEntry) +{ + NTSTATUS Status; + PMM_DLL_UNLOAD Func; + PAGED_CODE(); + + /* Get the unload routine */ + Func = (PMM_DLL_UNLOAD)MiLocateExportName(LdrEntry->DllBase, "DllUnload"); + if (!Func) return FALSE; + + /* Call it and check for success */ + Status = Func(); + if (!NT_SUCCESS(Status)) return FALSE; + + /* Lie about the load count so we can unload the image */ + ASSERT(LdrEntry->LoadCount == 0); + LdrEntry->LoadCount = 1; + + /* Unload it and return true */ + MmUnloadSystemImage(LdrEntry); + return TRUE; +} + +NTSTATUS +NTAPI +MiDereferenceImports(IN PLOAD_IMPORTS ImportList) +{ + SIZE_T i; + LOAD_IMPORTS SingleEntry; + PLDR_DATA_TABLE_ENTRY LdrEntry; + PVOID CurrentImports; + PAGED_CODE(); + + /* Check if there's no imports or if we're a boot driver */ + if ((ImportList == MM_SYSLDR_NO_IMPORTS) || + (ImportList == MM_SYSLDR_BOOT_LOADED) || + (ImportList->Count == 0)) + { + /* Then there's nothing to do */ + return STATUS_SUCCESS; + } + + /* Check for single-entry */ + if ((ULONG_PTR)ImportList & MM_SYSLDR_SINGLE_ENTRY) + { + /* Set it up */ + SingleEntry.Count = 1; + SingleEntry.Entry[0] = (PVOID)((ULONG_PTR)ImportList &~ MM_SYSLDR_SINGLE_ENTRY); + + /* Use this as the import list */ + ImportList = &SingleEntry; + } + + /* Loop the import list */ + for (i = 0; (i < ImportList->Count) && (ImportList->Entry[i]); i++) + { + /* Get the entry */ + LdrEntry = ImportList->Entry[i]; + DPRINT1("%wZ <%wZ>\n", &LdrEntry->FullDllName, &LdrEntry->BaseDllName); + + /* Skip boot loaded images */ + if (LdrEntry->LoadedImports == MM_SYSLDR_BOOT_LOADED) continue; + + /* Dereference the entry */ + ASSERT(LdrEntry->LoadCount >= 1); + if (!--LdrEntry->LoadCount) + { + /* Save the import data in case unload fails */ + CurrentImports = LdrEntry->LoadedImports; + + /* This is the last entry */ + LdrEntry->LoadedImports = MM_SYSLDR_NO_IMPORTS; + if (MiCallDllUnloadAndUnloadDll(LdrEntry)) + { + /* Unloading worked, parse this DLL's imports too */ + MiDereferenceImports(CurrentImports); + + /* Check if we had valid imports */ + if ((CurrentImports != MM_SYSLDR_BOOT_LOADED) || + (CurrentImports != MM_SYSLDR_NO_IMPORTS) || + !((ULONG_PTR)LdrEntry->LoadedImports & MM_SYSLDR_SINGLE_ENTRY)) + { + /* Free them */ + ExFreePool(CurrentImports); + } + } + else + { + /* Unload failed, restore imports */ + LdrEntry->LoadedImports = CurrentImports; + } + } + } + + /* Done */ + return STATUS_SUCCESS; +} + +VOID +NTAPI +MiClearImports(IN PLDR_DATA_TABLE_ENTRY LdrEntry) +{ + PAGED_CODE(); + + /* Check if there's no imports or we're a boot driver or only one entry */ + if ((LdrEntry->LoadedImports == MM_SYSLDR_BOOT_LOADED) || + (LdrEntry->LoadedImports == MM_SYSLDR_NO_IMPORTS) || + ((ULONG_PTR)LdrEntry->LoadedImports & MM_SYSLDR_SINGLE_ENTRY)) + { + /* Nothing to do */ + return; + } + + /* Otherwise, free the import list */ + ExFreePool(LdrEntry->LoadedImports); + LdrEntry->LoadedImports = MM_SYSLDR_BOOT_LOADED; } PVOID NTAPI -MiLocateExportName(IN PVOID DllBase, - IN PCHAR ExportName) +MiFindExportedRoutineByName(IN PVOID DllBase, + IN PANSI_STRING ExportName) { PULONG NameTable; PUSHORT OrdinalTable; @@ -341,7 +485,7 @@ Mid = (Low + High) >> 1; /* Compare name */ - Ret = strcmp(ExportName, (PCHAR)DllBase + NameTable[Mid]); + Ret = strcmp(ExportName->Buffer, (PCHAR)DllBase + NameTable[Mid]); if (Ret < 0) { /* Update high */ @@ -370,77 +514,10 @@ ExportDirectory->AddressOfFunctions); Function = (PVOID)((ULONG_PTR)DllBase + ExportTable[Ordinal]); - /* Check if the function is actually a forwarder */ - if (((ULONG_PTR)Function > (ULONG_PTR)ExportDirectory) && - ((ULONG_PTR)Function < ((ULONG_PTR)ExportDirectory + ExportSize))) - { - /* It is, fail */ - return NULL; - } - - /* We found it */ + /* We found it! */ + ASSERT(!(Function > (PVOID)ExportDirectory) && + (Function < (PVOID)((ULONG_PTR)ExportDirectory + ExportSize))); return Function; -} - -NTSTATUS -NTAPI -MmCallDllInitialize(IN PLDR_DATA_TABLE_ENTRY LdrEntry, - IN PLIST_ENTRY ListHead) -{ - UNICODE_STRING ServicesKeyName = RTL_CONSTANT_STRING( - L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"); - PMM_DLL_INITIALIZE DllInit; - UNICODE_STRING RegPath, ImportName; - NTSTATUS Status; - - /* Try to see if the image exports a DllInitialize routine */ - DllInit = (PMM_DLL_INITIALIZE)MiLocateExportName(LdrEntry->DllBase, - "DllInitialize"); - if (!DllInit) return STATUS_SUCCESS; - - /* Do a temporary copy of BaseDllName called ImportName - * because we'll alter the length of the string - */ - ImportName.Length = LdrEntry->BaseDllName.Length; - ImportName.MaximumLength = LdrEntry->BaseDllName.MaximumLength; - ImportName.Buffer = LdrEntry->BaseDllName.Buffer; - - /* Obtain the path to this dll's service in the registry */ - RegPath.MaximumLength = ServicesKeyName.Length + - ImportName.Length + sizeof(UNICODE_NULL); - RegPath.Buffer = ExAllocatePoolWithTag(NonPagedPool, - RegPath.MaximumLength, - TAG_LDR_WSTR); - - /* Check if this allocation was unsuccessful */ - if (!RegPath.Buffer) return STATUS_INSUFFICIENT_RESOURCES; - - /* Build and append the service name itself */ - RegPath.Length = ServicesKeyName.Length; - RtlCopyMemory(RegPath.Buffer, - ServicesKeyName.Buffer, - ServicesKeyName.Length); - - /* Check if there is a dot in the filename */ - if (wcschr(ImportName.Buffer, L'.')) - { - /* Remove the extension */ - ImportName.Length = (wcschr(ImportName.Buffer, L'.') - - ImportName.Buffer) * sizeof(WCHAR); - } - - /* Append service name (the basename without extension) */ - RtlAppendUnicodeStringToString(&RegPath, &ImportName); - - /* Now call the DllInit func */ - DPRINT("Calling DllInit(%wZ)\n", &RegPath); - Status = DllInit(&RegPath); - - /* Clean up */ - ExFreePool(RegPath.Buffer); - - /* Return status value which DllInitialize returned */ - return Status; } VOID
14 years, 8 months
1
0
0
0
← Newer
1
...
6
7
8
9
10
11
12
...
44
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Results per page:
10
25
50
100
200