Windows lockups and the still movable cursor

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
drunkenfox
Member
Member
Posts: 46
Joined: Tue Mar 13, 2012 10:46 pm

Windows lockups and the still movable cursor

Post by drunkenfox »

After installing and playing with the windows 9x/ME/3.x series on both physical computers and virtual machines, I've noticed that during complete system lockups, i.e. ctrl alt del does nothing, windows won't click, nothing happens. Except for the cursor. Even when the system is "frozen", the cursor still moves. How is this so? For example, windows 98 did not seem to like my imagine 128 vga card and would either be stuck in an infinite BSOD for some 0D exception. Sometimes it would manage to reach the state where the teal background and hourglass is displayed. The login screen never appeared, and not even ctrl alt del would do anything. The mouse could move, but sometimes it would do some weird clicking and rattling sound from the internal speaker. On one very rare occasion that never happened again, some dialog that looked like it was based off the 3.x kernel popped up complaining about some error, but trying to click OK or move the mouse made the PC speaker go insane. Does the mouse interrupt somehow overcome the lockup? Or does something else allow the cursor to move?
;goodbye OS, hello BIOS
mov eax, FFFFFFF0h
jmp eax
embryo

Re: Windows lockups and the still movable cursor

Post by embryo »

Knightshade wrote:Does the mouse interrupt somehow overcome the lockup?
The lockup is just one of OS modes, when key press actions are disabled. But disabling some interrupt handlers doesn't mean disabling all such handlers. So, those handlers that are not disabled still can do something useful.

In particular case of the cursor it is probably the handler, that not depends on some system data in case it was corrupted before BSOD. And also it is probable that code segment is prohibited from writing (can not be corrupted), so if a handler has working code and requires no (possibly corrupted) data, then such handler can work without problems.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Windows lockups and the still movable cursor

Post by Combuster »

The lockup is just one of OS modes
Citation needed? I doubt microsoft explicitly implemented a mode in such a fashion - they have no need for that.

The thing is that many video cards have a dedicated cursor overlay, which means that in most cases you can get away from a mouse interrupt with two writes to some video registers. You probably want to do this straight from the interrupt as it has the least latency (set X and Y in the video driver), and you don't cause overhead by scheduling move-pointer events outside of interrupt context. If you compare that to a keyboard, it has little reason to do things directly from the keyboard handler, as the only thing it really needs to do is post the event, as the place that handles it typically is deep down in userspace.

So the only thing that happens during a "crash" is that there's no process responding to either keyboard or mouse events, and only the interrupt subsystem and it's shortcircuited logic work, giving you only the visual appearance of a moving cursor while in reality actual mouse events are just as dead as any other.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Windows lockups and the still movable cursor

Post by Brendan »

Hi,
Knightshade wrote:Does the mouse interrupt somehow overcome the lockup? Or does something else allow the cursor to move?
I'd assume that normally (e.g. when the mouse hasn't been "grabbed"), the mouse driver tells the video driver about mouse pointer position changes (to reduce latency, etc). Key-presses would take the full path (from keyboard driver to GUI to application and back up). This would imply that if the GUI or application locks up, mouse pointer still works but keyboard doesn't.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
drunkenfox
Member
Member
Posts: 46
Joined: Tue Mar 13, 2012 10:46 pm

Re: Windows lockups and the still movable cursor

Post by drunkenfox »

Combuster wrote: The thing is that many video cards have a dedicated cursor overlay, which means that in most cases you can get away from a mouse interrupt with two writes to some video registers.
Is there any documentation for the vga cursor registes? I tried looking them up but I couldn't find anything.
;goodbye OS, hello BIOS
mov eax, FFFFFFF0h
jmp eax
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Windows lockups and the still movable cursor

Post by Gigasoft »

This is not a VGA register. Each manufacturer handles it differently.
User avatar
drunkenfox
Member
Member
Posts: 46
Joined: Tue Mar 13, 2012 10:46 pm

Re: Windows lockups and the still movable cursor

Post by drunkenfox »

I decided to run the vga.drv from windows for workgroups 3.11 through IDA and interestingly enough it has a MOVECURSOR export. I took a peek in the function and in the initial parts it has a bounds checking (0 <= x < 640), (1(weird coordinant?) <= y < 480) for the new cursor position, and it also checks if the new cursor coordinates against the current ones to make sure it hasn't updated so it doesn't waste time updating it. If it passes, it runs through a couple of subroutines to update it on the VGA hardware which I haven't explored yet, although I see references to the video plane masking controls from the IDA auto comments.
;goodbye OS, hello BIOS
mov eax, FFFFFFF0h
jmp eax
embryo

Re: Windows lockups and the still movable cursor

Post by embryo »

Combuster wrote:
The lockup is just one of OS modes
Citation needed? I doubt microsoft explicitly implemented a mode in such a fashion - they have no need for that.
Blue screen of dead appears when a problem is not contained within an application. Such situation is detectable, at least the BSOD tells us that the Windows crashed and it is the result of a detection and some management efforts. When the situation is detected there is a need to save (or at least to show) some available information. When information is shown it is required to prevent any application and kernel activity from overwriting the information on the screen. What can be the name for such OS behavior? My bet it is "mode".
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Windows lockups and the still movable cursor

Post by Gigasoft »

vga.drv implements the cursor in software. Other drivers will implement it in hardware, if the card supports it.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Windows lockups and the still movable cursor

Post by onlyonemac »

My Windows 3.1 system sometimes looks up as the desktop appears and on that screen even the cursor doesn't move. Although I seem to think that that is a hardware issue anyway (as in the actual CPU has stopped) because it's intermittent and the same thing happened when I tried booting my operating system on it and a similar thing with OS/2 as well. It seems like that CPU only allows protected mode to function corectly after it's warmed up for about 10 minutes.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Octocontrabass
Member
Member
Posts: 5572
Joined: Mon Mar 25, 2013 7:01 pm

Re: Windows lockups and the still movable cursor

Post by Octocontrabass »

onlyonemac wrote:My Windows 3.1 system
If this computer of yours is an early 386, I might want to test some code on it.
mallard
Member
Member
Posts: 280
Joined: Tue May 13, 2014 3:02 am
Location: Private, UK

Re: Windows lockups and the still movable cursor

Post by mallard »

Since the full source code for the Windows 3.1 mouse driver and a collection of display drivers is provided in the DDK, I had a quick look at how it works. (Why use IDA when the source is easy to find?)

The mouse driver uses the standard DOS int 21h API to register an interrupt handler (the exact interrupt handler is chosen based on exactly which kind of mouse is in use; the driver supports PS/2 and serial devices directly and can use DOS int 33h drivers).

The interrupt handler calls the "event_proc" provided by Windows with AX, BX and CX set to the status and position of the mouse cursor. I don't know exactly what this procedure contains, but is likely a thin wrapper over the "SetCursor" procedure in the display driver, which updates the position and draws the cursor (the included display drivers support both software and hardware cursors).

It's likely that the entire process, from mouse interrupt to updating the display happens in response to an interrupt and doesn't rely heavily on Windows' event handling code (which makes sense, since Windows wants smooth mouse movement, but only supports co-operative multitasking; just updating the cursor position when an application yields/polls for events would result in very jerky motion).

When Windows 3.x "hangs", it's usually because an application is stuck in an endless loop and isn't yielding/polling for events (these are the same thing in the Windows 3.x API). Windows itself is usually still "working", but because the application is frozen, no new events can be processed (so no keyboard input, no response to clicks, etc.). Since the mouse cursor doesn't rely on event processing, it still works.
Image
Post Reply