reactos.git
13 years ago[HAL]: Implement HalTranslateBusAddress using Bus Handler support. The old HAL would...
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

13 years ago[HAL]: Implement ISA BUS address translation.
Sir Richard [Mon, 7 Jun 2010 20:59:46 +0000 (20:59 +0000)]
[HAL]: Implement ISA BUS address translation.

svn path=/trunk/; revision=47678

13 years ago[HAL]: Implement system bus address translation.
Sir Richard [Mon, 7 Jun 2010 20:59:00 +0000 (20:59 +0000)]
[HAL]: Implement system bus address translation.

svn path=/trunk/; revision=47677

13 years ago[HAL]: Implement Bus Handler support for HalGetInterruptVector too. The new functiona...
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

13 years ago[HAL]: Implement PCI Vector/IRQL translation too.
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

13 years ago[HALMP]: MP HAL should have HalpDefaultInterruptAffinity too.
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

13 years ago[HAL]: Forgot file.
Sir Richard [Mon, 7 Jun 2010 20:35:02 +0000 (20:35 +0000)]
[HAL]: Forgot file.

svn path=/trunk/; revision=47673

13 years ago[HAL]: Implement system bus (and ISA) vector/interrupt translation.
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

13 years ago[HAL]: Use Bus Handler support for HalSetBusDataByOffset. Please report any problems.
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

13 years ago[HAL]: First use of bus handler support: HalGetBusDataByOffset now uses bus handlers...
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

13 years ago[HAL]: I don't like to swear, but F*CK this MiniHAL bullsh*t!
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

13 years ago[HAL]: Plug in the data from pcidata.c that was committed months ago to display a...
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

13 years ago[HAL]: Implement HalpGetPciBridgeConfig to detect PCI-to-PCI/CardBus bridges, warn...
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

13 years ago[HAL]: Implement partly HalpFixupPciSupportedRanges to detect PCI Bridges, and PCI...
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

13 years ago[HAL]: Detect, check for, and warn about, chipset hacks that need to be applied for...
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

13 years ago[NTOS]: Check registry for our CardList, check if the PCI hardware matches any entry...
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

13 years ago[HAL]: Detect IDE controllers. Their interrupts should not be masked.
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

13 years ago[win32k]
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

13 years ago[MSAFD]
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

13 years ago[HAL]: Detect, initialize, and create bus handlers for, all PCI buses that are found...
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

13 years ago[HAL]: Add missing PCI Bus Handler support functions, used on non-ACPI systems (ISA...
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

13 years ago[HAL]: Kill debug spew.
Sir Richard [Mon, 7 Jun 2010 03:18:51 +0000 (03:18 +0000)]
[HAL]: Kill debug spew.

svn path=/trunk/; revision=47653

13 years ago[MSAFD]
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

13 years ago[AFD]
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

13 years ago[MSAFD]
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

13 years ago[HAL]: Bus support in the HAL actually creates a further wedge between the different...
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

13 years ago[DHCP/FTP]: Fix building on OS X hosts.
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

13 years agoI hate making the same mistake twice in one day
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

13 years ago[MSAFD]
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

13 years agoRemove an unintended change
Cameron Gutman [Sun, 6 Jun 2010 23:49:27 +0000 (23:49 +0000)]
Remove an unintended change

svn path=/trunk/; revision=47645

13 years agoAdd Opera 9 to rapps.
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

13 years ago[MSAFD]
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

13 years ago[NDIS]
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

13 years agoForgot to remove this ASSERT for r47636
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

13 years ago[WIN32K]
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

13 years ago[NDIS]
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

13 years ago[WIN32K]
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

13 years ago[WIN32K] Use TAG_GDIICM tag for ICM allocations
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

13 years ago[NTOS] Inline writing to PTEs through MI_WRITE_VALID/INVALID_PTE.
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

13 years ago[WIN32K] Free allocations with the tag that was used to allocate them
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

13 years ago[WIN32K] assert -> ASSERT
Gregor Schneider [Sun, 6 Jun 2010 18:32:57 +0000 (18:32 +0000)]
[WIN32K] assert -> ASSERT

svn path=/trunk/; revision=47631

13 years ago[NDIS]
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

13 years ago[NTOS]: Enable usage of ARM3 paged pool, up until Mm Phase 2.
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

13 years ago[COMPBATT]: Remove useless function.
Sir Richard [Sun, 6 Jun 2010 15:49:54 +0000 (15:49 +0000)]
[COMPBATT]: Remove useless function.

svn path=/trunk/; revision=47626

13 years ago- Fix a comment and remove a superfluous extern.
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

13 years ago[NTOS]: Another one bites the dust, another one bites the dust. And another one gone...
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

13 years ago[NTOS]: A PFN entry is not necessarily physical only if it is higher than MmHighestPh...
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

13 years ago[NTOS]: Don't use MmAllocPage for the first paged pool PDE, instead, use MiRemoveZero...
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

13 years ago[NTOS]: Implement MiRemoveZeroPage and MiZeroPhysicalPage.
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

13 years ago[NTOS]: Fix a loop off-by-one when saving the page table index in contigious memory...
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

13 years agoAdd /KDSERIAL to the command line, to make sysreg able to bt in first stage.
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

13 years ago[NTOSKNRL]
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

13 years ago[rtl]
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

13 years ago[NTOS]: Clean up /mm a bit, move sysldr.c into ARM3.
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

13 years ago[NTOS]: Silence more debug spew.
Sir Richard [Sun, 6 Jun 2010 04:37:53 +0000 (04:37 +0000)]
[NTOS]: Silence more debug spew.

svn path=/trunk/; revision=47607

13 years ago[NTOS]: Fix for the the bug that broke ARM3 paged pool (and has been corrupting React...
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

13 years ago[NTOS]: Kill some debug spew.
Sir Richard [Sun, 6 Jun 2010 00:49:26 +0000 (00:49 +0000)]
[NTOS]: Kill some debug spew.

svn path=/trunk/; revision=47604

13 years ago[NTOS]: Even after allowing ARM3 paged pool, we should still use the old allocator...
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

13 years ago[NTOS]: Fix up POOL_PREV_BLOCK based on suggestion by hpoussin.
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

13 years ago[NTOS]: Kill debug spew.
Sir Richard [Sat, 5 Jun 2010 19:17:21 +0000 (19:17 +0000)]
[NTOS]: Kill debug spew.

svn path=/trunk/; revision=47599

13 years ago[NTOS]: Fix Exp*PoolList macros. Also make then non-inlined, so we can see who called...
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

13 years ago[WIN32CSR]
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

13 years ago[NTOS]: Add some paranoid-invariant list access checks to the pool code. They serve...
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

13 years ago[NTOS]: Defensive programming on the pool macros.
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

13 years ago[NTOS]: Use logical math operations on the various block<->entry<->free_list_head...
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

13 years ago[NTOSKRNL]
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

13 years ago[NTOS]: Define the POOL_HEADER for x64.
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

13 years ago[NTOS]: Don't assume that ANY fault in the system address range, not associated to...
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

13 years ago[NTOS]: In MiInitializePfnForOtherProcess, should increment the sharecount of the...
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

13 years ago[NTOS]: In MiDeleteSystemPageableVm, should also handle the case where the PTE is...
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

13 years ago[NTOSKRNL]
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

13 years ago[WIN32CSR] Implement some basic line editing capability
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

13 years ago[NTOS]: Implement MiDeleteSystemPageableVm.
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

13 years agoadd missing file
Jeffrey Morlan [Sat, 5 Jun 2010 03:12:51 +0000 (03:12 +0000)]
add missing file

svn path=/trunk/; revision=47581

13 years ago[KERNEL32], [WIN32CSR]
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

13 years ago[NTOS]: When expanding paged pool, use MiRemoveAnyPage, not MmAllocPage.
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

13 years ago[winnt.h]
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

13 years ago[FREELOADER]
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

13 years ago[FREELOADER]
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

13 years ago[NTOS]: Build paged pool demand-zero PTE with MI_MAKE_SOFTWARE_PTE macro.
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

13 years ago[DDK]
Timo Kreuzer [Fri, 4 Jun 2010 20:16:26 +0000 (20:16 +0000)]
[DDK]
Fix definition of USE_DMA_MACROS

svn path=/trunk/; revision=47574

13 years ago[MMEBUDDY]
Timo Kreuzer [Fri, 4 Jun 2010 18:37:14 +0000 (18:37 +0000)]
[MMEBUDDY]
Make mmebuddy more 64bit compliant. Based on r40127 by Samuel Serapion with some modifications by me.

svn path=/trunk/; revision=47573

13 years ago[WIN32CSR] Console input simplification:
Jeffrey Morlan [Fri, 4 Jun 2010 18:26:22 +0000 (18:26 +0000)]
[WIN32CSR] Console input simplification:
- Put code for processing events for line input in one place, instead of duplicating it everywhere
- Remove "Fake" and "NotChar" fields from ConsoleInput struct. ConioProcessKey didn't actually add Fake events; they were used for the \n when converting \r to \r\n, but this is better done by the line input code.
- Build an input line completely on the server side; this will make it practical to add history and more sophisticated editing later

svn path=/trunk/; revision=47572

13 years agoTesters: Please test this build.
Sir Richard [Fri, 4 Jun 2010 17:49:36 +0000 (17:49 +0000)]
Testers: Please test this build.
[NTOS]: Implement a MI_MAKE_HARDWARE_PTE macro for the generation of valid kernel PTEs instead of always taking the ValidKernelPte and changing its flags. This macro will take into account the protection mask (up until now ignored) and use the array previously implemented to determine the correct hardware PTE settings. Assertions are also added to validate correct usage of the macro, and later revisions will fill out NT-specific fields to help deal with transition PTEs, page faults, etc.
[NTOS]: Make the stack code the first user of this macro, for the stack PTEs. Good testing base as we create kernel stacks very often.
[NTOS]: The NT MM ABI specifies that in between the allocation of a new PTE and its initialization as a valid PFN, the PTE entry should be an invalid PTE, and should only be marked valid after the PFN has been initialized. For stack PTEs, do this -- first allocating the page, making it invalid, then initializing the PFN, and then writing the valid page.

svn path=/trunk/; revision=47571

13 years ago[NTOS]: Allocate non-paged pool pages with MiRemoveAnyPage instead of MmAllocPage.
Sir Richard [Fri, 4 Jun 2010 17:40:11 +0000 (17:40 +0000)]
[NTOS]: Allocate non-paged pool pages with MiRemoveAnyPage instead of MmAllocPage.

svn path=/trunk/; revision=47570

13 years ago[HAL]
Timo Kreuzer [Fri, 4 Jun 2010 16:56:14 +0000 (16:56 +0000)]
[HAL]
Delete empty folder

svn path=/trunk/; revision=47569

13 years ago[WIN32CSR] Consistently store console input events internally as unicode.
Jeffrey Morlan [Fri, 4 Jun 2010 16:31:56 +0000 (16:31 +0000)]
[WIN32CSR] Consistently store console input events internally as unicode.

svn path=/trunk/; revision=47568

13 years ago[KS]
Timo Kreuzer [Fri, 4 Jun 2010 15:58:43 +0000 (15:58 +0000)]
[KS]
- KSSTREAM_POINTER_OFFSET doesn't have an Alignment member on 64 bit systems. Comment the use out in these cases. It should probably be removed completely, as it's only an alignment / dummy value, but I leave this to the expert in this field.
- ULONG -> ULONG_PTR for pointer casts

svn path=/trunk/; revision=47567

13 years ago[win32k]
Giannis Adamopoulos [Fri, 4 Jun 2010 11:30:14 +0000 (11:30 +0000)]
[win32k]
- CreateWindow: initialize window position after sending WM_GETMINMAXINFO message

svn path=/trunk/; revision=47566

13 years ago[HAL]
Timo Kreuzer [Fri, 4 Jun 2010 10:59:19 +0000 (10:59 +0000)]
[HAL]
- Move all amd64 specific files to one amd64 folder
- Compile x86 specific timer code only on x86
- Use KeRegisterInterruptHandler instead of manual idt manipulation
- add missing stubs for amd64

svn path=/trunk/; revision=47565

13 years ago[NTOSKRNL]
Timo Kreuzer [Fri, 4 Jun 2010 10:51:44 +0000 (10:51 +0000)]
[NTOSKRNL]
Implement KeRegisterInterruptHandler and KeQueryInterruptHandler for amd64

svn path=/trunk/; revision=47564

13 years ago[HAL]
Timo Kreuzer [Fri, 4 Jun 2010 10:17:55 +0000 (10:17 +0000)]
[HAL]
- Move memory functions from halinit.c to new memory.c
- HalpAllocPhysicalMemory: MemoryFirmwareTemporary -> LoaderFirmwareTemporary (same value, different enum)

svn path=/trunk/; revision=47563

13 years ago[KERNEL32], [WIN32CSR]
Jeffrey Morlan [Fri, 4 Jun 2010 06:36:12 +0000 (06:36 +0000)]
[KERNEL32], [WIN32CSR]
- Make Get/SetConsoleTitle more compatible with windows; in particular, transfer title via capture buffer to allow for longer titles.
- Tighten up capture buffer validation in win32csr.

svn path=/trunk/; revision=47562

13 years agorevert 47559 and 47560 (once again... sigh)
Timo Kreuzer [Fri, 4 Jun 2010 00:49:33 +0000 (00:49 +0000)]
revert 47559 and 47560 (once again... sigh)

svn path=/trunk/; revision=47561

13 years agotry to fix build
Timo Kreuzer [Fri, 4 Jun 2010 00:26:49 +0000 (00:26 +0000)]
try to fix build

svn path=/trunk/; revision=47560

13 years ago[DDK]
Timo Kreuzer [Fri, 4 Jun 2010 00:19:39 +0000 (00:19 +0000)]
[DDK]
Merge the rest of the old header-branch version of ntddk.h, but with a large number of additional types #if 0'ed out

svn path=/trunk/; revision=47559

13 years ago[DDK]
Timo Kreuzer [Thu, 3 Jun 2010 23:40:33 +0000 (23:40 +0000)]
[DDK]
try to work around the testbot brokenness with an #if 0"

svn path=/trunk/; revision=47558

13 years ago[HAL]
Timo Kreuzer [Thu, 3 Jun 2010 23:18:20 +0000 (23:18 +0000)]
[HAL]
Include the correct headers for amd64 vs i386

svn path=/trunk/; revision=47557

13 years ago[DDK]
Timo Kreuzer [Thu, 3 Jun 2010 23:08:40 +0000 (23:08 +0000)]
[DDK]
In an incredibly daring move, add even more types to ntddk.h

svn path=/trunk/; revision=47556

13 years ago[DDK]
Timo Kreuzer [Thu, 3 Jun 2010 22:25:25 +0000 (22:25 +0000)]
[DDK]
2nd try, this time adding half of the structures.

svn path=/trunk/; revision=47555