Johannes Anderwald [Wed, 9 Jun 2010 13:27:19 +0000 (13:27 +0000)]
[PORTCLS]
- Check if resource list has been allocated
svn path=/trunk/; revision=47711
Aleksey Bragin [Wed, 9 Jun 2010 10:34:35 +0000 (10:34 +0000)]
- Add "bootcdregtest" in the list of well-known targets.
svn path=/trunk/; revision=47708
Ged Murphy [Wed, 9 Jun 2010 08:09:35 +0000 (08:09 +0000)]
This bug seems to have gone now. Tried to replicate it the devmgmt treeview.
svn path=/trunk/; revision=47706
Ged Murphy [Wed, 9 Jun 2010 08:04:35 +0000 (08:04 +0000)]
Merge second part of the comctl32 Wine 1.2 sync.
All code currently omits the reactos specific patches. It's been a long time since we synched this lib so it's possible we no longer need them. Time will tell.
svn path=/trunk/; revision=47705
Cameron Gutman [Wed, 9 Jun 2010 04:45:17 +0000 (04:45 +0000)]
[IP]
- Handle socket operations that can be completed immediately before terminating the socket to avoid losing data sitting in the receive buffer
svn path=/trunk/; revision=47704
Sylvain Petreolle [Tue, 8 Jun 2010 20:24:15 +0000 (20:24 +0000)]
Merge RtlIpv4StringToAddressW fix from network branch.
svn path=/trunk/; revision=47699
Timo Kreuzer [Tue, 8 Jun 2010 14:31:31 +0000 (14:31 +0000)]
[PSDK]
Merge 47681 and 47682 from header branch
- Add missing file headers
- Fix defintition of POINTER_64
- by Amine Khaldi
svn path=/trunk/; revision=47697
Ged Murphy [Tue, 8 Jun 2010 11:09:32 +0000 (11:09 +0000)]
Move UTF8 to the bottom of the file. Thanks to Christoph for the tip
svn path=/trunk/; revision=47696
Ged Murphy [Tue, 8 Jun 2010 10:21:26 +0000 (10:21 +0000)]
Part 1 of the comctl32 sync. I'll do it in 2 stages for testing purposes as it's a very large patch.
This part includes alpha support for imagelists and tango icons for the common toolbars
I'll do the second part later today. It has a propsheet bug and I'm a bit busy at the mo.
svn path=/trunk/; revision=47695
Ged Murphy [Tue, 8 Jun 2010 10:16:34 +0000 (10:16 +0000)]
Add missing info needed for the comctl32 sync
svn path=/trunk/; revision=47694
Jeffrey Morlan [Tue, 8 Jun 2010 06:38:14 +0000 (06:38 +0000)]
[KERNEL32], [WIN32CSR]
- Implement ReadConsoleW's CONSOLE_READCONSOLE_CONTROL structure.
- Make pressing Insert during line input work
svn path=/trunk/; revision=47693
Timo Kreuzer [Tue, 8 Jun 2010 01:37:58 +0000 (01:37 +0000)]
revert 47688 and 47689
svn path=/trunk/; revision=47691
Timo Kreuzer [Tue, 8 Jun 2010 00:19:34 +0000 (00:19 +0000)]
[BOOTCD]
Add cabman to bootcd. This is for diagnostic purposes.
svn path=/trunk/; revision=47689
Timo Kreuzer [Mon, 7 Jun 2010 23:39:37 +0000 (23:39 +0000)]
[ZLIB]
Revert r47411. This is a test to see if it fixes the sysreg crash in 1st stage.
svn path=/trunk/; revision=47688
Johannes Anderwald [Mon, 7 Jun 2010 23:00:04 +0000 (23:00 +0000)]
[WDMAUD_KERNEL]
- Extend the mdl hack
svn path=/trunk/; revision=47687
Sylvain Petreolle [Mon, 7 Jun 2010 21:38:49 +0000 (21:38 +0000)]
Revert 47685.
svn path=/trunk/; revision=47686
Sylvain Petreolle [Mon, 7 Jun 2010 21:36:37 +0000 (21:36 +0000)]
Enable debug in usetup. This will be reverted in next commit.
svn path=/trunk/; revision=47685
Sir Richard [Mon, 7 Jun 2010 21:36:31 +0000 (21:36 +0000)]
[HAL]: Use Bus Handler support for HalFindBusAddressTranslation. Implement HalpContextToBusHandler to support this. Seems to work fine with bootvid (only user).
All the HAL's bus functions now use Bus Handlers on Legacy systems. There are still big issues with PCI cards.
eVb: PCI-x should work now.
More PCI-related HAL patches may follow later.
svn path=/trunk/; revision=47684
Sir Richard [Mon, 7 Jun 2010 21:26:09 +0000 (21:26 +0000)]
[HAL]: Use Bus Handlers for HalpAssignSlotResources. Warn that current PCI Slot assignment code is frelled.
[HAL]: Add PAGED_CODE();
[HAL]: Fix HALACPI build break.
svn path=/trunk/; revision=47683
Sir Richard [Mon, 7 Jun 2010 21:06:16 +0000 (21:06 +0000)]
[HAL]: Implement HalAdjustResourceList using Bus Handler support. Previous HAL said this was "deprecated" and faked success. Although correct on ACPI HALs, this is a legacy HALs, so Bus Handlers have a chance to do ajdustment.
svn path=/trunk/; revision=47680
Sir Richard [Mon, 7 Jun 2010 21:01:53 +0000 (21:01 +0000)]
[HAL]: Implement HalTranslateBusAddress using Bus Handler support. The old HAL would just return whatever the caller gave (no translation was done). For example, with the new HAL, this now results in the translation of 0xCF800 in I/O space to fail (not sure which driver requests this), because this is not a valid I/O address on PC/AT systems (highest is 0xFFFF).
This change also allows for the PCI driver to override the translation mechanism (which will piggy-back to the system bus translator) with its own. Please test.
svn path=/trunk/; revision=47679
Sir Richard [Mon, 7 Jun 2010 20:59:46 +0000 (20:59 +0000)]
[HAL]: Implement ISA BUS address translation.
svn path=/trunk/; revision=47678
Sir Richard [Mon, 7 Jun 2010 20:59:00 +0000 (20:59 +0000)]
[HAL]: Implement system bus address translation.
svn path=/trunk/; revision=47677
Sir Richard [Mon, 7 Jun 2010 20:39:11 +0000 (20:39 +0000)]
[HAL]: Implement Bus Handler support for HalGetInterruptVector too. The new functionality now includes support for checking against reserved HAL vectors instead of blindling assining IRQLs/Vectors to callers. A warning is printed on the debug log when the old HAL would've returned different values. Please test. If you have issues, the problem is in the DRIVERS, not this code.
svn path=/trunk/; revision=47676
Sir Richard [Mon, 7 Jun 2010 20:37:45 +0000 (20:37 +0000)]
[HAL]: Implement PCI Vector/IRQL translation too.
svn path=/trunk/; revision=47675
Sir Richard [Mon, 7 Jun 2010 20:37:19 +0000 (20:37 +0000)]
[HALMP]: MP HAL should have HalpDefaultInterruptAffinity too.
svn path=/trunk/; revision=47674
Sir Richard [Mon, 7 Jun 2010 20:35:02 +0000 (20:35 +0000)]
[HAL]: Forgot file.
svn path=/trunk/; revision=47673
Sir Richard [Mon, 7 Jun 2010 20:34:41 +0000 (20:34 +0000)]
[HAL]: Implement system bus (and ISA) vector/interrupt translation.
svn path=/trunk/; revision=47672
Sir Richard [Mon, 7 Jun 2010 20:13:05 +0000 (20:13 +0000)]
[HAL]: Use Bus Handler support for HalSetBusDataByOffset. Please report any problems.
svn path=/trunk/; revision=47671
Sir Richard [Mon, 7 Jun 2010 20:10:53 +0000 (20:10 +0000)]
[HAL]: First use of bus handler support: HalGetBusDataByOffset now uses bus handlers. Please report any problems.
svn path=/trunk/; revision=47670
Sir Richard [Mon, 7 Jun 2010 18:30:20 +0000 (18:30 +0000)]
[HAL]: I don't like to swear, but F*CK this MiniHAL bullsh*t!
svn path=/trunk/; revision=47668
Sir Richard [Mon, 7 Jun 2010 17:01:56 +0000 (17:01 +0000)]
[HAL]: Plug in the data from pcidata.c that was committed months ago to display a beautiful enumeration of all PCI devices on the machine. This will allow debug logs not only to contain nearly full hardware information, but also identify the VM the tester/reporter is using (based on the device's subsystem ID).
[HAL]: Display all the warning DPRINTs in-line with the PCI enumeration code, resulting in a much easier to read and comprehensive review of the machine.
svn path=/trunk/; revision=47666
Sir Richard [Mon, 7 Jun 2010 16:44:12 +0000 (16:44 +0000)]
[HAL]: Implement HalpGetPciBridgeConfig to detect PCI-to-PCI/CardBus bridges, warn if they are found.
[HAL]: Modify the debug messages to be more accurate as to what exactly is unsupported.
svn path=/trunk/; revision=47665
Sir Richard [Mon, 7 Jun 2010 16:15:01 +0000 (16:15 +0000)]
[HAL]: Implement partly HalpFixupPciSupportedRanges to detect PCI Bridges, and PCI-to-PCI Bridges. The point is we want buses to be cramped down to the addresses supported by the parent bus/bridge. This is NOT currently done, so we warn users of these systems.
svn path=/trunk/; revision=47664
Sir Richard [Mon, 7 Jun 2010 15:34:35 +0000 (15:34 +0000)]
[HAL]: Detect, check for, and warn about, chipset hacks that need to be applied for the machine.
svn path=/trunk/; revision=47662
Sir Richard [Mon, 7 Jun 2010 15:09:44 +0000 (15:09 +0000)]
[NTOS]: Check registry for our CardList, check if the PCI hardware matches any entry in there that specifies it has full/extended address decoding, and write the registry flag for it.
svn path=/trunk/; revision=47660
Sir Richard [Mon, 7 Jun 2010 15:02:49 +0000 (15:02 +0000)]
[HAL]: Detect IDE controllers. Their interrupts should not be masked.
svn path=/trunk/; revision=47659
Michael Martin [Mon, 7 Jun 2010 13:37:43 +0000 (13:37 +0000)]
[win32k]
- Change the number of windowless timers from 1024 to 32768.
- When destroying windowless timers, clear the bit number (IDEvent) in the bitmap so the bit number can be reused.
- Only create a windowless timer if there is no windowless timer matching IDEvent.
- Fixes case where applications create too many windowless timers and/or run out of windowless timers.
svn path=/trunk/; revision=47658
Cameron Gutman [Mon, 7 Jun 2010 05:40:08 +0000 (05:40 +0000)]
[MSAFD]
- Fix a bug in GetSocketStructure that resulted in us missing the last entry of the list
- Remove an "optimization" which was supposed to find an unused socket entry (which it almost never did) but now just corrupts the linked list by trashing our NextSocket pointer
svn path=/trunk/; revision=47656
Sir Richard [Mon, 7 Jun 2010 03:23:48 +0000 (03:23 +0000)]
[HAL]: Detect, initialize, and create bus handlers for, all PCI buses that are found on the machine.
[HAL]: Detect PCI-to-PCI Bridges, Extended CardBus Addressing, read Chipset Hacks from Registry, and scan for IRQ lines used by PCI Devices. Scan for PCI-IDE controllers, broken Intel PCI Bridges/Controllers. Scan for OHCI and UHCI USB controllers. Warn the user that if any of these are found, the current HAL does not handle certain types of these devices (these checks are based on the ones the Legacy Windows HAL makes).
svn path=/trunk/; revision=47655
Sir Richard [Mon, 7 Jun 2010 03:19:20 +0000 (03:19 +0000)]
[HAL]: Add missing PCI Bus Handler support functions, used on non-ACPI systems (ISA-PCI support and such).
svn path=/trunk/; revision=47654
Sir Richard [Mon, 7 Jun 2010 03:18:51 +0000 (03:18 +0000)]
[HAL]: Kill debug spew.
svn path=/trunk/; revision=47653
Cameron Gutman [Mon, 7 Jun 2010 01:50:26 +0000 (01:50 +0000)]
[MSAFD]
- Fix 2 more callers who don't pass a valid lpErrno pointer
- Check the return value of WSPSocket
- Return WSAEWOULDBLOCK if there are no connections that can be accepted instead of silently returning 0 which is not INVALID_SOCKET so the caller treats it as a valid socket pointer and passes it to other functions which caused wide-spread mayhem since we never checked whether the socket handle the caller passed was valid until my last commit
svn path=/trunk/; revision=47652
Cameron Gutman [Mon, 7 Jun 2010 01:38:15 +0000 (01:38 +0000)]
[AFD]
- It is legal to send a NULL event object pointer to AFD (this is sent by msafd to cancel an existing event select)
svn path=/trunk/; revision=47651
Cameron Gutman [Mon, 7 Jun 2010 01:24:15 +0000 (01:24 +0000)]
[MSAFD]
- Validate that we found the corresponding socket information in our socket information list
- Fixes a crash in Firefox 2 when it tries to call accept() with a closed socket
svn path=/trunk/; revision=47650
Sir Richard [Mon, 7 Jun 2010 01:09:41 +0000 (01:09 +0000)]
[HAL]: Bus support in the HAL actually creates a further wedge between the different x86 HALs: There are actually two dinstinct implementations. On the ACPI HAL, the system is assumed not to have things like special ISA, MCA, EISA buses, and a PCI driver is used in combination with the ACPI Interface for PCI Bus support. On non-ACPI systems, the legacy "Bus Handler" library is used, and the HAL provides a core set of CMOS, EISA, ISA, MCA and PCI bus handlers, each with their own routines and specific code. Additionally, PCI IRQ Routing and other PCI bus internals are handled directly by the HAL -- on the ACPI HAL, the PCI Bus support is implemented through a "Fake"/static bus handler, just to keep the functions shared. On ReactOS, both the ACPI and non-ACPI HAL were currently using a mix of both HAL bus handling types, mostly implemented the "ACPI way" (with a fake PCI bus handler and such).
As a result, none of the Hal*Bus HALDISPATCH routines were implemented, which bus drivers expect to find when they're not on ACPI systems (ReactOS today). eVb's new PCI driver was crashing, for example.
Furthermore, legacy systems suffer, because the ACPI HAL Bus routines (that we currently have) expect perfect ACPI-style-compliant systems, not the legacy crap from the early 90ies. This works fine in VMs and new hardware, but old hardware is left behind.
This patch basically corrects the first part of the problem, by making the bus handling support separate between ACPI and non-ACPI HALs. For now, the code remains 100% the same in functionality between both.
However, I have started adding the first few elements:
[HAL]: Implement HalRegisterBusHandler HALDISPATCH routine.
[HAL]: On legacy HALs, register the CMOS, ISA, SYSTEM handlers.
[HAL]: Add cmosbus.c. Stub all bus-specific bus handler routines in the xxxbus.c files.
No real functionality change occurs with this patch, yet.
svn path=/trunk/; revision=47649
Sir Richard [Mon, 7 Jun 2010 00:58:55 +0000 (00:58 +0000)]
[DHCP/FTP]: Fix building on OS X hosts.
svn path=/trunk/; revision=47648
Cameron Gutman [Mon, 7 Jun 2010 00:44:00 +0000 (00:44 +0000)]
I hate making the same mistake twice in one day
svn path=/trunk/; revision=47647
Cameron Gutman [Mon, 7 Jun 2010 00:24:27 +0000 (00:24 +0000)]
[MSAFD]
- Use a linked list to store the socket information instead of allocating a massive array (1024 elements!) for each process in DllMain to hold all of the pointers
- Fix a massive memory leak (free the socket information which we leaked for every socket we allocated)
- This improves performance because we don't have to look through an array of stale socket information pointers (which we never actually removed from the socket information array in the old code) and the new code queues the socket information at the head of the list which makes newer sockets faster to access
svn path=/trunk/; revision=47646
Cameron Gutman [Sun, 6 Jun 2010 23:49:27 +0000 (23:49 +0000)]
Remove an unintended change
svn path=/trunk/; revision=47645
Daniel Reimer [Sun, 6 Jun 2010 23:45:20 +0000 (23:45 +0000)]
Add Opera 9 to rapps.
Update OOo to 3.2.1 and the last time... fix the FF2 link.
svn path=/trunk/; revision=47644
Cameron Gutman [Sun, 6 Jun 2010 23:07:26 +0000 (23:07 +0000)]
[MSAFD]
- Fix many times where we wait for an operation but don't update our status and return if it failed
- Fix the overlapped pending case in writing which was completely broken (callers would detect an error but GetLastError would return 0 because we didn't store the error in the lpErrno variable)
- Fix many times where we pass a pointer to an event that we close without waiting
- Fix a bug in WSPEnumNetworkEvents when we would set WSAEINVAL in the lpErrno variable but not return SOCKET_ERROR so the error got ignored
svn path=/trunk/; revision=47643
Cameron Gutman [Sun, 6 Jun 2010 22:08:40 +0000 (22:08 +0000)]
[NDIS]
- Hold the miniport lock when we work with the timer queue
- Use the return value of KeSetTimer(Ex) to determine whether we need to queue the timer in our queue, otherwise we just use the entry that is already there
- Add more assertions
svn path=/trunk/; revision=47642
Cameron Gutman [Sun, 6 Jun 2010 21:31:58 +0000 (21:31 +0000)]
Forgot to remove this ASSERT for r47636
svn path=/trunk/; revision=47639
Gregor Schneider [Sun, 6 Jun 2010 19:29:20 +0000 (19:29 +0000)]
[WIN32K]
- Use TAG_KEYBOARD for keyboard layouts
- Free TAG_ACCEL and TAG_DRIVER allocations with their tags
svn path=/trunk/; revision=47637
Cameron Gutman [Sun, 6 Jun 2010 19:18:19 +0000 (19:18 +0000)]
[NDIS]
- Only dequeue the timer in the DPC if the Period is 0 (which means that it's NOT a periodic timer so we only get called once)
- Attempt to dequeue the timer before inserting it so we don't end up with multiple copies of the same timer on the timer queue if somebody calls NdisMSet(Periodic)Timer twice
svn path=/trunk/; revision=47636
Gregor Schneider [Sun, 6 Jun 2010 19:11:52 +0000 (19:11 +0000)]
[WIN32K]
- Use TAG_PALETTE for palette entries
- Remove mapping codes, the functions from pre r9000 don't even exist anymore
svn path=/trunk/; revision=47635
Gregor Schneider [Sun, 6 Jun 2010 18:51:43 +0000 (18:51 +0000)]
[WIN32K] Use TAG_GDIICM tag for ICM allocations
svn path=/trunk/; revision=47634
Stefan Ginsberg [Sun, 6 Jun 2010 18:45:46 +0000 (18:45 +0000)]
[NTOS] Inline writing to PTEs through MI_WRITE_VALID/INVALID_PTE.
svn path=/trunk/; revision=47633
Gregor Schneider [Sun, 6 Jun 2010 18:34:57 +0000 (18:34 +0000)]
[WIN32K] Free allocations with the tag that was used to allocate them
svn path=/trunk/; revision=47632
Gregor Schneider [Sun, 6 Jun 2010 18:32:57 +0000 (18:32 +0000)]
[WIN32K] assert -> ASSERT
svn path=/trunk/; revision=47631
Cameron Gutman [Sun, 6 Jun 2010 18:09:25 +0000 (18:09 +0000)]
[NDIS]
- Implement miniport timer queuing
- Add some BUGCODE_ID_DRIVER bug check cases for missing interrupt deregistration, missing timer cancellation, and invalid IRQL when calling NdisMAllocateSharedMemory
svn path=/trunk/; revision=47630
Sir Richard [Sun, 6 Jun 2010 15:59:42 +0000 (15:59 +0000)]
[NTOS]: Enable usage of ARM3 paged pool, up until Mm Phase 2.
[NTOS]: Re-arrange some of the init code, now that we have access to ARM3 paged pool early-on. Move more code to ARM3::INIT in its right place.
[NTOS]: Enable using the ARM3 PFN Database, getting rid of the old ReactOS PFN database. Should reduce physical memory usage now that we don't have two copies anymore.
[NTOS]: Fix the ARM3 PFN Datbase initialization code.
[NTOS]: Get rid of MiInitializePageList, use MiGetPfnEntryOffset instead of hard-coded pointer math in freelist.c.
This is the last big low-level Mm/ARM3 patch for a long, long time.
svn path=/trunk/; revision=47627
Sir Richard [Sun, 6 Jun 2010 15:49:54 +0000 (15:49 +0000)]
[COMPBATT]: Remove useless function.
svn path=/trunk/; revision=47626
Stefan Ginsberg [Sun, 6 Jun 2010 14:42:03 +0000 (14:42 +0000)]
- Fix a comment and remove a superfluous extern.
svn path=/trunk/; revision=47625
Sir Richard [Sun, 6 Jun 2010 14:24:18 +0000 (14:24 +0000)]
[NTOS]: Another one bites the dust, another one bites the dust. And another one gone and another one gone. Another one bites the dust, yeah. Out of the doorway the bullets rip, Repeating to the sound of the beat.
svn path=/trunk/; revision=47624
Sir Richard [Sun, 6 Jun 2010 14:15:18 +0000 (14:15 +0000)]
[NTOS]: A PFN entry is not necessarily physical only if it is higher than MmHighestPhysicalPage. It can also be physical if it lies in a memory hole within the min-max physical page range. We can detect this by using our PFN Bitmap. So replace all "Is this an I/O mapping?" checks with a check on whether or not the PFN Database entry is NULL (which will check for us both of these statements). This ought to be a macro...
svn path=/trunk/; revision=47623
Sir Richard [Sun, 6 Jun 2010 14:13:35 +0000 (14:13 +0000)]
[NTOS]: Don't use MmAllocPage for the first paged pool PDE, instead, use MiRemoveZeroPage.
[NTOS]: Use MiInitializePfnForOtherProcess to setup the first paged pool PDE.
svn path=/trunk/; revision=47622
Sir Richard [Sun, 6 Jun 2010 14:12:28 +0000 (14:12 +0000)]
[NTOS]: Implement MiRemoveZeroPage and MiZeroPhysicalPage.
Not yet used.
svn path=/trunk/; revision=47621
Sir Richard [Sun, 6 Jun 2010 13:42:19 +0000 (13:42 +0000)]
[NTOS]: Fix a loop off-by-one when saving the page table index in contigious memory allocation PFNs. Spotted by Stefan100.
svn path=/trunk/; revision=47620
Timo Kreuzer [Sun, 6 Jun 2010 07:52:32 +0000 (07:52 +0000)]
Add /KDSERIAL to the command line, to make sysreg able to bt in first stage.
svn path=/trunk/; revision=47615
Timo Kreuzer [Sun, 6 Jun 2010 07:35:21 +0000 (07:35 +0000)]
[NTOSKNRL]
Add the possibility to break on all first chance exceptions, by passing /FIRSTCHANCE on the command line. Enable it temporary to get some more information from the sysreg crash.
svn path=/trunk/; revision=47614
Michael Martin [Sun, 6 Jun 2010 07:21:53 +0000 (07:21 +0000)]
[rtl]
- Fix a overlooked change needed due to mbstowcs fix. Use the number of WCHARs vice number of bytes to calculate end of xmlbuf.
svn path=/trunk/; revision=47613
Sir Richard [Sun, 6 Jun 2010 04:38:51 +0000 (04:38 +0000)]
[NTOS]: Clean up /mm a bit, move sysldr.c into ARM3.
svn path=/trunk/; revision=47608
Sir Richard [Sun, 6 Jun 2010 04:37:53 +0000 (04:37 +0000)]
[NTOS]: Silence more debug spew.
svn path=/trunk/; revision=47607
Sir Richard [Sun, 6 Jun 2010 01:04:03 +0000 (01:04 +0000)]
[NTOS]: Fix for the the bug that broke ARM3 paged pool (and has been corrupting ReactOS paged pool behind the scenes for years):
When a KCB (key stuff) is allocated, the key name associated with it receives an NCB (name stuff). In case this name is already used, a cache exists, and an existing NCB is grabbed, and its reference count is increased. When the KCB goes away, its NCB loses a reference. When all references are gone, the NCB is destroyed. Simple enough.
It turns out that what was currently happening is that an NCB would get dereferenced to 0, deleted, but still remained attached to a valid KCB (shouldn't happen). When that KCB went away, the NCB's reference count was dropped to... -1, and then -2, -3, -4, etc. Remember this is a FREED NCB. In other words, freed pool, that might now belong to someone else, was getting "-1" operations on it. So any value stored in that freed pool would get decremented by one. In ARM3 paged pool, because the allocator keeps a linked list, what would happen is that the FLINK pointer would be 0xE0F01234 instead of 0xE1A01234. What happened is that "0xE1A0" was treated as the reference count of the freed NCB, and it kept getting dereferenced down to 0xE0F0.
Proving this was easy, by adding an ASSERT(Ncb->RefCount >= 1) to the routine that dereferences NCBs. Obviously, we should not try to dereference an NCB that has a reference count of 0, because that NCB is now gone. Adding this ASSERT immediately caught the error, regardless of which pool implementation was being used, so this was a problem in ReactOS today, right now.
My first thought was that we were taking references to NCBs without incrementing the reference count. The NCB gets referenced in two places: when it gets created, and everytime a cached NCB is re-used for a new KCB (all this in CmpGetNameControlBlock).
After adding some tracing code, I discovered that CmpGetNameControlBlock would sometimes return an NCB that was cached, but without referencing it. I did not understand why, since the code says "if (Found) Ncb->RefCount++".
Further analysis showed that what would happen, on this particular instance, is that NCB "Foo" was being Found, but NCB "Bar" was returned instead. Therefore, causing some serious issues: First, NCB Foo was receiving too many references. Secondly, NCB Bar was not being referenced.
Worse though, it turns out this would happen when "Foo" was the CORRECT NCB, and "Bar" was an INCORRECT NCB. What do we mean by correct and incorrect? Well, because NCBs are hashed, it's possible for two NCB hashes to be VERY SIMILAR, but only ONE OF THOSE NCBs will be the right one -- for example, HKLM\Software\Hello vs HKLM\Software\Hell.
In our case, when a KCB for "Hello" was searching for the "Hello" NCB, the "Hello NCB would get a reference, but the "Hell" NCB would be returned. In other words, whenever a HASH COLLISION happened, the incorrect NCB was returned, probably messing up registry code in the process. Subsequently, when the KCB was dereferneced, it was attached to this incorrect, under-referenced NCB.
Since in ANY hash collision with "Hell", in our example, the "Hell" NCB would come first, subsequent searches for "Hellmaster", "Hellboy", "Hello World" would all still return "Hell". Eventually when all these KCBs would go away, the "Hell" NCB would reach even -18 references.
The simple solution? When the CORRECT NCB is found, STOP SEARCHING! By adding a simple "break" statement. Otherwise, even after the correct NCB is found, further, incorrect, collided NCBs are found, and eventually the last one ("Hell", in our example) got returned, and under-referenced, while "Hellmaster" and "Hellboy" were not returned, but LEAKED REFERENCES.
There you have it folks, MEMORY CORRUPTION (USE-AFTER-FREE), INCORRECT REGISTRY NAME PARSHING, REFERENCE LEAKS and REFERENCE UNDERRUNS, all due to ONE missing "break;".
-r
svn path=/trunk/; revision=47605
Sir Richard [Sun, 6 Jun 2010 00:49:26 +0000 (00:49 +0000)]
[NTOS]: Kill some debug spew.
svn path=/trunk/; revision=47604
Sir Richard [Sat, 5 Jun 2010 19:32:46 +0000 (19:32 +0000)]
[NTOS]: Even after allowing ARM3 paged pool, we should still use the old allocator to free allocations made by the old allocator!
svn path=/trunk/; revision=47601
Sir Richard [Sat, 5 Jun 2010 19:19:28 +0000 (19:19 +0000)]
[NTOS]: Fix up POOL_PREV_BLOCK based on suggestion by hpoussin.
[NTOS]: Fix up NTAPI location in function definition.
[NTOS]: Implement even more stringent header checks: ExpCheckPoolHeader and ExpCheckPoolBlocks. Normally we would only want this on a DBG build, but I am enabling them for now until I can fix paged pool. If your machine crashes, reverting this commit is NOT the solution (boots for me).
[NTOS]: Add a AllowPagedPool BOOLEAN that will allow us to selectively enable when the ARM3 pool can be used, playing around with the situation that causes the corruption, and perhaps making it easier to find/fix.
svn path=/trunk/; revision=47600
Sir Richard [Sat, 5 Jun 2010 19:17:21 +0000 (19:17 +0000)]
[NTOS]: Kill debug spew.
svn path=/trunk/; revision=47599
Sir Richard [Sat, 5 Jun 2010 18:26:15 +0000 (18:26 +0000)]
[NTOS]: Fix Exp*PoolList macros. Also make then non-inlined, so we can see who called them in a stack trace.
[NTOS]: Enable them.
This boots on my system -- if it doesn't boot on yours, someone is corrupting your nonpaged pool. Reverting this patch is NOT the solution to your woes.
svn path=/trunk/; revision=47598
Jeffrey Morlan [Sat, 5 Jun 2010 18:17:42 +0000 (18:17 +0000)]
[WIN32CSR]
- Implement basic support for history in line editing
- Reorganize code to reflect that line input is more coupled to history than it is to character input
svn path=/trunk/; revision=47597
Sir Richard [Sat, 5 Jun 2010 18:02:45 +0000 (18:02 +0000)]
[NTOS]: Add some paranoid-invariant list access checks to the pool code. They serve a dual purpose: catch pool corruption by broken drivers/kernel code, as well as catch malicious modification of the pool links as part of a kernel-mode exploit.
[NTOS]: Not yet used, thanks to Arthur for the idea.
See comment for more information.
svn path=/trunk/; revision=47596
Sir Richard [Sat, 5 Jun 2010 17:54:19 +0000 (17:54 +0000)]
[NTOS]: Defensive programming on the pool macros.
svn path=/trunk/; revision=47595
Sir Richard [Sat, 5 Jun 2010 17:53:17 +0000 (17:53 +0000)]
[NTOS]: Use logical math operations on the various block<->entry<->free_list_head operations in the pool code, instead of works-by-chance-and-assumption pointer math operations. This will now allow pool implementations where the pool header is not the size of a pool block (and the size of a LIST_ENTRY, by definition, although, even that, could change, if we choose to implement a cache-aligned overhead).
svn path=/trunk/; revision=47594
Cameron Gutman [Sat, 5 Jun 2010 17:51:12 +0000 (17:51 +0000)]
[NTOSKRNL]
- Print the base address of the process that we killed to make debugging much easier
svn path=/trunk/; revision=47593
Sir Richard [Sat, 5 Jun 2010 16:53:54 +0000 (16:53 +0000)]
[NTOS]: Define the POOL_HEADER for x64.
[NTOS]: Define POOL_BLOCK_SIZE definition to set the minimum pool block size. In NT, this is equal to a LIST_ENTRY structure, because the Pool Allocator must be able to store a LIST_ENTRY into a freed pool block. This also determines the alignment of pool allocations. So 8 on x86, 16 on x64.
[NTOS]: Don't depend on LIST_ENTRY, but use POOL_BLOCK_SIZE instead (on IA64, if we ever want to support this, the pool block size is different from a LIST_ENTRY/POOL_HEADER).
[NTOS]: The following ASSERTs must hold: the POOL_HEADER must be as big as the the smallest pool block (POOL_BLOCK_SIZE), which must be at least as big as a LIST_ENTRY structure. 8 == 8 == 8 on x86, 16 == 16 == 16 on x64.
svn path=/trunk/; revision=47592
Sir Richard [Sat, 5 Jun 2010 14:59:50 +0000 (14:59 +0000)]
[NTOS]: Don't assume that ANY fault in the system address range, not associated to a memory area, might be ARM3. Instead, since this hack only exists for early boot page pool support, make only treat this as an ARM3 fault when it happens in the paged pool area or higher. Leads to more direct Mm crashes when invalid page access happens, instead of infinite "PAGE FAULT ON PAGE TABLES".
svn path=/trunk/; revision=47589
Sir Richard [Sat, 5 Jun 2010 14:55:17 +0000 (14:55 +0000)]
[NTOS]: In MiInitializePfnForOtherProcess, should increment the sharecount of the page table PFN entry, not the PFN entry of the PTE itself. Spotted by Stefan100.
svn path=/trunk/; revision=47588
Sir Richard [Sat, 5 Jun 2010 14:54:26 +0000 (14:54 +0000)]
[NTOS]: In MiDeleteSystemPageableVm, should also handle the case where the PTE is demand-zero. This can happen if the caller allocated, say, 12KB (3 pages) of paged pool, only touched 4KB (1 page), and then frees the allocation -- the other 2 pages will still be demand-zero at this point.
svn path=/trunk/; revision=47587
Eric Kohl [Sat, 5 Jun 2010 12:20:53 +0000 (12:20 +0000)]
[NTOSKRNL]
NtDuplicateToken: Fail, if a primary token is to be created from an impersonation token and and the impersonation level of the impersonation token is below SecurityImpersonation.
svn path=/trunk/; revision=47586
Jeffrey Morlan [Sat, 5 Jun 2010 06:10:53 +0000 (06:10 +0000)]
[WIN32CSR] Implement some basic line editing capability
svn path=/trunk/; revision=47584
Sir Richard [Sat, 5 Jun 2010 04:16:46 +0000 (04:16 +0000)]
[NTOS]: Implement MiDeleteSystemPageableVm.
[NTOS]: The paged pool free code was behaving incorrectly, assuming that paged pool was "locked down" and never paged out/reused (a valid NT operation mode), while the allocation code was assuming paged pool was a volatile, reusable, pageable resource (normal NT operation mode). The free code now assumes normal operation mode, and actually frees the freed paged pool pages, by using MiDeleteSystemPageableVm.
I have a feeling this will make ARM3 paged pool work.
svn path=/trunk/; revision=47582
Jeffrey Morlan [Sat, 5 Jun 2010 03:12:51 +0000 (03:12 +0000)]
add missing file
svn path=/trunk/; revision=47581
Jeffrey Morlan [Sat, 5 Jun 2010 00:45:08 +0000 (00:45 +0000)]
[KERNEL32], [WIN32CSR]
- Implement console history (note: not too useful yet without any way to recall it)
- Implement APIs GetConsoleCommandHistoryLength, GetConsoleCommandHistory, ExpungeConsoleCommandHistory, SetConsoleNumberOfCommands, GetConsoleHistoryInfo, SetConsoleHistoryInfo.
- Remove stub of obsolete function SetConsoleCommandHistoryMode, which no longer exists in Windows.
svn path=/trunk/; revision=47580
Sir Richard [Fri, 4 Jun 2010 22:08:40 +0000 (22:08 +0000)]
[NTOS]: When expanding paged pool, use MiRemoveAnyPage, not MmAllocPage.
[NTOS]: When expanding paged pool, initialize the PFN entry for the allocated page. Note we might be in arbitrary process space, so the PTE is not necessary valid for the process causing the expansion.
[NTOS]: Implement MiInitializePfnForOtherProcess to handle the case above.
[NTOS]: Change two static ASSERTs into C_ASSERTs. Might break non-x86 builds for a bit (vs breaking them at boot, which is worse).
Paged pool should start working soon.
svn path=/trunk/; revision=47579
Timo Kreuzer [Fri, 4 Jun 2010 21:50:06 +0000 (21:50 +0000)]
[winnt.h]
Fix definition of KNONVOLATILE_CONTEXT_POINTERS for amd64
svn path=/trunk/; revision=47578
Cameron Gutman [Fri, 4 Jun 2010 20:36:48 +0000 (20:36 +0000)]
[FREELOADER]
- Use the old method for identifying the drive type (based on partition number) which actually works for floppies now because I changed the DrivePartition value returned (floppy = 0, cdrom = 0xFF) in a previous commit
- Fixes bug 5233
svn path=/trunk/; revision=47577
Cameron Gutman [Fri, 4 Jun 2010 20:22:29 +0000 (20:22 +0000)]
[FREELOADER]
- Remove duplicated code
- Add back the Mac hack but use 0x8A for the lowest CD-ROM drive number instead of 0x90
svn path=/trunk/; revision=47576
Sir Richard [Fri, 4 Jun 2010 20:18:27 +0000 (20:18 +0000)]
[NTOS]: Build paged pool demand-zero PTE with MI_MAKE_SOFTWARE_PTE macro.
[NTOS]: Handle paged pool demand-zero fault fulfillment with MI_MAKE_HARDWARE_PTE macro.
[NTOS]: Use MiRemoveAnyPage instead of MmAllocPage, in paged pool demand-zero fault fulfillment.
These changes affect code paths that are not currently in-use.
svn path=/trunk/; revision=47575