Files
Claude 6848cc13c7 Add vbapi.h and the Visual Basic API stubs for custom controls (VBX)
A VBX is a DLL that Visual Basic 1.0, 2.0 and 3.0 load. vbapi.h has the
custom control interface: MODEL, PROPINFO, EVENTINFO, the VBM_
messages and the VB functions.

The VB functions are not exports of a module: Visual Basic puts its
dispatcher at SS:0x20, and each function is a stub that jumps there
with its number in BX. vbapi/vbapi.S has the stubs; build-sysroot.sh
and make-dist.sh put them in lib/win16/vbapi.lib. The numbers come from
the CDK's VBAPI.LIB.

tests/win16/vbxctl.c is a counter control. run-tests.sh checks its
imports and exports, and the test checks the structure sizes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRV6wfb9PKGryxuRrjF
2026-11-26 19:37:09 +00:00

129 lines
4.0 KiB
ArmAsm

/* vbapi.S: the stubs of the Visual Basic API functions (vbapi.h), for
* custom controls (VBX) and DLLs that Visual Basic loads.
* Written for clang-retro; AGPL-3.0-only, see the win16-sdk LICENSE.
*
* The functions are not exports of a module. Visual Basic puts a far
* pointer to its dispatcher at offset 0x20 of its stack segment, and the
* code of a DLL runs on that stack. Each stub puts 4 times the number of
* its function in BX and jumps to the dispatcher, with the arguments of
* the caller still on the stack. The names are in upper case, as FAR
* PASCAL makes them. */
/* VBSTUB name, number: a stub for function number of the dispatcher. */
.macro VBSTUB name, number
.globl \name
\name:
movw $(\number * 4), %bx
ljmpw *%ss:0x20
.endm
.text
VBSTUB VBREGISTERMODEL, 0
VBSTUB VBDEREFCONTROL, 1
VBSTUB VBDEFCONTROLPROC, 2
VBSTUB VBFIREEVENT, 3
VBSTUB VBSETCONTROLPROPERTY, 4
VBSTUB VBGETCONTROLPROPERTY, 5
VBSTUB VBCREATEHSZ, 6
VBSTUB VBDESTROYHSZ, 7
VBSTUB VBDEREFHSZ, 8
VBSTUB VBLOCKHSZ, 9
VBSTUB VBUNLOCKHSZ, 10
VBSTUB VBGETCONTROLHWND, 11
VBSTUB VBRECREATECONTROLHWND, 12
VBSTUB VBGETCONTROLMODEL, 13
VBSTUB VBSENDCONTROLMSG, 14
VBSTUB VBREADFORMFILE, 15
VBSTUB VBWRITEFORMFILE, 16
VBSTUB VBSUPERCONTROLPROC, 17
VBSTUB VBGETMODE, 18
VBSTUB VBGETHINSTANCE, 19
VBSTUB VBCREATEHLSTR, 20
VBSTUB VBSETHLSTR, 21
VBSTUB VBDESTROYHLSTR, 22
VBSTUB VBDEREFHLSTR, 23
VBSTUB VBGETHLSTRLEN, 24
VBSTUB VBGETHWNDCONTROL, 25
VBSTUB VBXPIXELSTOTWIPS, 26
VBSTUB VBYPIXELSTOTWIPS, 27
VBSTUB VBXTWIPSTOPIXELS, 28
VBSTUB VBYTWIPSTOPIXELS, 29
VBSTUB VBREADBASICFILE, 30
VBSTUB VBWRITEBASICFILE, 31
VBSTUB VBALLOCPIC, 32
VBSTUB VBFREEPIC, 33
VBSTUB VBGETPIC, 34
VBSTUB VBREFPIC, 35
VBSTUB VBPICFROMCF, 36
VBSTUB VBSETERRORMESSAGE, 37
VBSTUB VBGETAPPTITLE, 38
VBSTUB VBDIALOGBOXPARAM, 39
VBSTUB VBSEEKFORMFILE, 40
VBSTUB VBRELSEEKFORMFILE, 41
VBSTUB VBGETCONTROLNAME, 42
/* Function 43 is reserved. */
/* Function 44 is reserved. */
/* Function 45 is reserved. */
/* Function 46 is reserved. */
/* Function 47 is VBGetVersion; the stub below calls it. */
VBSTUB __VBGETVERSION_STUB, 47
VBSTUB VBLINKPOSTADVISE, 48
VBSTUB VBPASTELINKOK, 49
VBSTUB VBDIRTYFORM, 50
VBSTUB VBSETCONTROLFLAGS, 51
VBSTUB VBPALETTECHANGED, 52
VBSTUB VBALLOCPICEX, 53
VBSTUB VBGETPICEX, 54
VBSTUB VBTRANSLATECOLOR, 55
VBSTUB VBGETCAPTURE, 56
VBSTUB VBSETCAPTURE, 57
VBSTUB VBRELEASECAPTURE, 58
VBSTUB VBGETCONTROL, 59
VBSTUB VBZORDER, 60
VBSTUB VBMOVECONTROL, 61
VBSTUB VBGETCONTROLRECT, 62
VBSTUB VBGETRECTINCONTAINER, 63
VBSTUB VBGETCLIENTRECT, 64
VBSTUB VBCLIENTTOSCREEN, 65
VBSTUB VBSCREENTOCLIENT, 66
VBSTUB VBISCONTROLVISIBLE, 67
VBSTUB VBISCONTROLENABLED, 68
VBSTUB VBINVALIDATERECT, 69
VBSTUB VBUPDATECONTROL, 70
VBSTUB VBCOERCEVARIANT, 71
VBSTUB VBGETVARIANTTYPE, 72
VBSTUB VBGETVARIANTVALUE, 73
VBSTUB VBSETVARIANTVALUE, 74
VBSTUB VBGETHLSTR, 75
VBSTUB VBRESIZEHLSTR, 76
VBSTUB VBDEREFHLSTRLEN, 77
VBSTUB VBDEREFZEROTERMHLSTR, 78
VBSTUB VBCREATETEMPHLSTR, 79
VBSTUB VBARRAYELEMENT, 80
VBSTUB VBARRAYBOUNDS, 81
VBSTUB VBARRAYELEMSIZE, 82
VBSTUB VBARRAYFIRSTELEM, 83
VBSTUB VBARRAYINDEXCOUNT, 84
VBSTUB VBRUNTIMEERROR, 85
VBSTUB VBFORMAT, 86
VBSTUB VBCBSAVEFPSTATE, 87
VBSTUB VBRESTOREFPSTATE, 88
VBSTUB VBLINKMAKEITEMNAME, 89
VBSTUB VBSEEKBASICFILE, 90
VBSTUB VBRELSEEKBASICFILE, 91
VBSTUB VBGETDATASOURCECONTROL, 92
/* VBGetVersion: the version of Visual Basic (VB300_VERSION and the
* others). When the offset of the dispatcher is 0x00BC, the stub gives
* VB100_VERSION and does not call function 47, as Microsoft's VBAPI.LIB
* does: Visual Basic 1.0 does not have that function. */
.globl VBGETVERSION
VBGETVERSION:
cmpw $0x00bc, %ss:0x20
je 1f
jmp __VBGETVERSION_STUB
1:
movw $0x0100, %ax
lretw