Chasing Galactic Civilizations Unhandled Exception

Mike Kost mike at
Fri Jun 25 18:59:38 CDT 2004

After sucking it up and realizing I'd have to learn how to navigate winedbg,
 I started playing around with the Galactic Civilizations unhandled exception. 
Some documentation and a few trips through winedbg later, it appears that 
Gal Civ is throwing a divide-by-zero
First chance exception: divide by zero in 32-bit code (0x40f2cda8)

I did a 'bt' next:
=>1 0x40f2cda8 send_mouse_event+0xc8(hwnd=0x10024, flags=0x8001, posX=0x1fb0000, posY=0x1df, data=0x0, time=0xef3d) [mouse.c:135] in x11drv (0x406cfbb0)
  2 0x40f2e010 X11DRV_MotionNotify+0x60(hwnd=0x10024, event=0x406cfc4c) [mouse.c:613] in x11drv (0x406cfbdc)
  3 0x40f24e90 .L79+0xa in x11drv (0x406cfc3c)
  ... stuff ...

and then did an 'info local' and got:
        struct HWND__* hwnd = 0x00010024 (parameter)
        long unsigned int flags = 0x00008001 (parameter)
        long unsigned int posX = 0x01fb0000 (parameter)
        long unsigned int posY = 0x000001df (parameter)
        long unsigned int data = 0x00000000 (parameter)
        long unsigned int time = 0x0000ef3d (parameter)
        unsigned int state = 0x0000004c (local in register ECX)
        unsigned int state = 0x0000004c (local in register ECX)
        struct HWND__* hwnd = 0x01faffff (local in register EAX)
        long unsigned int data = 0x01faffff (local in register EAX)
        long unsigned int time = 0x0000ef3d (local in register EDI)
        struct tagINPUT input = 0x40f61028 (local)
        int width = 0x00000000 (local in register ESI)
        int height = 0x00000000 (local)

After digging around in dlls/x11drv/mouse.c (see the bt output), I found:
        int width  = GetSystemMetrics( SM_CXSCREEN );
        int height = GetSystemMetrics( SM_CYSCREEN );
        /* Relative mouse movements seem not to be scaled as absolute ones */
        posX = (((long)posX << 16) + width-1)  / width;
        posY = (((long)posY << 16) + height-1) / height;

The posX and poxY calculations are the only divides in the send_mouse_event 
function (pointed to by the bt as the stack location when the divide-by-zero 
occurred). The 'info local' confirms that width and height are indeed 0. My 
problem is that I do not think GetSystemMetrics should be returning 0. The
display is quite chorked up by the time the unhandled exception occurs, so
I'm pretty sure something bad has already happened; I just don't know what.

If any x11drv experienced folk can provide pointers or insight, I'd greatly
appreciate it.

Mike Kost
mike -at-

More information about the wine-devel mailing list