aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2026-11-30 12:53:58 +0100
committerJavier <dev.git@javispedro.com>2026-11-30 12:53:58 +0100
commit9f46f39f48d3acf4806473b331b654111a6e2084 (patch)
tree047142a32fda5820ff3f00851903afe33ec3359c
parent2938a67c400930d2d5e6f23bb8e13b1ec3b99000 (diff)
downloadvbados-9f46f39f48d3acf4806473b331b654111a6e2084.tar.gz
vbados-9f46f39f48d3acf4806473b331b654111a6e2084.zip
mousew16: found a way to use the same binary in both 2.x and >3.x
What was missing is to use mark.exe (same as the MEMORY option in wlink) to mark the 2.0 executable as being "protected mode compatible". Thanks to Pietrek's Windows Internals book and their description of what LoadModule is doing.
-rw-r--r--makefile8
-rw-r--r--mousew16.c2
-rw-r--r--mousew16.lnk14
-rw-r--r--mousew2.lnk19
4 files changed, 15 insertions, 28 deletions
diff --git a/makefile b/makefile
index 99c3a44..a3f17e7 100644
--- a/makefile
+++ b/makefile
@@ -64,17 +64,13 @@ mousmain.obj: mousmain.c .AUTODEPEND
$(compile_dos)
# Windows 3.x mouse driver
-vbmouse.drv: mousew16.lnk $(mousew16_objs)
+vbmouse.drv: mousew16.lnk dosstub.exe $(mousew16_objs)
*wlink @$[@ name $@ file { $(mousew16_objs) }
mousew16.obj: mousew16.c .AUTODEPEND
$(compile_w16dll)
-# Windows 2.x version
-# TODO 2.x setup.exe expects an exactly 400byte long stub (option stub=...)
-vbmouse2.drv: mousew16.lnk mousew2.lnk dosstub.exe $(mousew16_objs)
- *wlink @mousew16.lnk @mousew2.lnk name $@ file { $(mousew16_objs) }
-
+# stub/fake DOS exec header used in vbmouse.drv, see mousew16.lnk
dosstub.exe: dosstub.asm .AUTODEPEND
*wcl -fo=$^@ $[@ -\"option fullheader\"
diff --git a/mousew16.c b/mousew16.c
index d617663..5a1770e 100644
--- a/mousew16.c
+++ b/mousew16.c
@@ -370,7 +370,7 @@ static BOOL send_native_wheel_msgs(HWND hWnd, DWORD time, POINT cursor, int z, B
}
/** GetMsgProc hook, called for every message before being returned by GetMessage. */
-LRESULT CALLBACK WheelHookProc(int code, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK __loadds WheelHookProc(int code, WPARAM wParam, LPARAM lParam)
{
if (code >= 0) {
// TODO Unclear if on win9x PeekMessage will also call this hook
diff --git a/mousew16.lnk b/mousew16.lnk
index 4e379ef..14ca952 100644
--- a/mousew16.lnk
+++ b/mousew16.lnk
@@ -1,16 +1,26 @@
-system windows_dll
+system windows_dll memory font
+# "memory" flag above says we are protected mode compatible
+# even if our target windows is < 3.0. this is equivalent to what mark.exe does.
option map=mousew16.map
option modname=MOUSE # This is necessary; USER.EXE imports mouse functions using this module name
option description 'VBMouse int33 absolute mouse driver'
option heapsize=128 # We don't need localheap but windows_dll sets 1K by default
+option version=1.0 # minimal Windows version required
+
+# The 2.x drv loader in SETUP.EXE is way more picky than the regular one
+# Fortunately, we have the source for 2.x SETUP.EXE, so we know what it needs:
+# Paragraph alignment, and for the NE header to start at exactly 0x400,
+# which means we need a custom stub exe that is exactly 1K long.
+option alignment=16
+option stub=dosstub.exe
segment CALLBACKS fixed shared # We need a non-moveable segment to store our callback routines
segment CLASS DATA fixed shared # Likewise fix the data segment, too cumbersome if not
+# We don't do the normal DLL prolog in the interrupt handlers, for example
export Inquire.1
export Enable.2
export Disable.3
export MouseGetIntVect.4
-export WheelHookProc
diff --git a/mousew2.lnk b/mousew2.lnk
deleted file mode 100644
index c0bc8b6..0000000
--- a/mousew2.lnk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Additional link options for vbmouse2.drv, the version for Windows 2.x
-
-option map=mousew2.map
-option description 'VBMouse int33 absolute mouse driver for 2.x'
-
-# Sadly the 3.x/95 NE loader requires an min Windows version >=3.0,
-# while the 1.x/2.x loader requires a min Windows version <=2.0
-# so even though the code is the same, no idea how to provide
-# a single exec that satisfies both OSes.
-
-# Set min windows version required to 1.0
-option version=1.0
-
-# The 1.x/2.x loader in SETUP.EXE is also way more picky than the regular one
-# Fortunately, we have the source for SETUP.EXE, so we know what it needs:
-# Paragraph alignment, and for the NE header to start at exactly 0x400,
-# which means we need a custom stub exe that is exactly 1K long.
-option alignment=16
-option stub=dosstub.exe