Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target
*.bndb
/toolchain
/research
/research
/.codegraph
85 changes: 84 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,88 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.6.0] - 2026-11-08

A form's record stream had three misreads: a hosted control's record was
property data nobody decoded, the form header's +0x59 and +0x5D were read as
a width and a height they never held, and external table type 6 was read as
a type library reference rather than the global object the runtime binds.

### Added

- **The procedure an event handler slot calls.** `VbObject::handler_method`
resolves a connected sink slot's stub to the method-table index of the
procedure it calls: a P-Code stub (`mov eax, imm32; cmp ax, 0xC033; mov
edx, <ProcDscInfo>; ...`) by the `ProcDscInfo` a method slot points at,
a native one (`sub dword [esp+4], imm32; jmp <procedure>`) by the
procedure a native method slot points at. `EventBinding::method_index`
carries it. A handler's name is the binding Visual Basic makes at compile
time, so the procedure names an event no template does: `events`
`Listener`'s `WithEvents m_Source` handlers resolve to `m_Source_Started`,
`m_Source_Ticked` and `m_Source_Named`, and `activex`'s hosted `Winsock1`
slots resolve although its sink leads with the extender's events. A
natively compiled class has no method table, so its handlers do not
resolve (`events-native`).

- **A hosted control's extender properties.** A hosted control's record (an
ActiveX control, a project's UserControl) has type `0xFF` and states its
extender's properties - its place (`Bounds`, or `Left` and `Top` for one
not drawn at run time), `Index` and `TabIndex` - after its ProgID, around
the object it persisted. `FormControlRecord::properties` now starts
decoding past the ProgID (its `u16` length, bytes and NUL) rather than at
the stream's first byte, against the `Extender` descriptor table (75
entries, MSVBVM60.DLL 6.00.8176 `0x6602DE18`); any other record has no
ProgID and still decodes from the first byte.
`PropertyIter::new_at` decodes from a given offset so the properties'
offsets stay those of the whole stream.

- **The persisted object a hosted control writes** (`ObjectBlob`): a `u32`
tag, a `u32` length and that many bytes (`OleObjectBlob`), carried by the
new `PropertyValue::ObjectBlob` and `PropType::ObjectBlob` (persisted as
`"ObjectBlob"`). `forms` Gauge1 is 72 bytes and `activex` CommonDialog1
76, each record going on after it with the extender's remaining
properties.

- **`ExternalGlobalObject::data_slot_va`**: the `.data` slot the runtime
stores the bound object into.

- **The arithmetic every opcode computes.** `ArithOp` gains `Fix`, `Int`
and `Sgn` for the `FnFix`, `FnInt` and `FnSgn` families, which were
`ArithOp::Other`. Two tests now assert that no `Arithmetic` or `Unary`
opcode in any of the six dispatch tables is left `ArithOp::Other`.

### Changed

- **`EventBinding` gains `method_index`** (breaking for struct literals).

- **External table type 6 is a global object, not a type library**
(breaking). The runtime binds the object of the entry's class into the
entry's data slot when it loads the project, so the entry is
`{lpClsid, lpDataSlot}`: `ExternalKind::TypeLib` is now
`ExternalKind::GlobalObject` (persisted as `"GlobalObject"`),
`ExternalTypelibInfo` is now `ExternalGlobalObject` with `clsid_va`,
`clsid` and the new `data_slot_va`, and
`ExternalTableEntry::as_typelib` is now `as_global_object`.

- **`PropType`, `PropertyValue` and `ArithOp` gain variants** (breaking for
exhaustive matches; none of the three is `non_exhaustive`).

### Fixed

- **The form header's +0x59 and +0x5D are sizes of the stream, not a form's
width and height** (breaking). `FormDataHeader::width` is now
`stream_size`, the byte length of the form's stream from offset 0x5D to
the `0x04` after its last record, and `height` is now `properties_size`,
the byte length of the designer object's own record counted from 0x5D.
`forms` Board states 483 and 87 there, and its size is in its properties
(`ClientSize`, 4680 x 3090 twips); the old names reported 483 x 87 twips
as a form's dimensions.

- **Exponentiation is classified.** `ArithOp::Pow` was never produced: the
build script looked for a `Pow` mnemonic prefix, and the opcodes are the
`Pwr` family (`PwrR8R8`, `PwrR8I2`, `PwrVar`), which classified as
`ArithOp::Other`.

## [0.5.0] - 2026-10-09

Every name of the ProjectInfo2 name area now has an owner: the private
Expand Down Expand Up @@ -687,7 +769,8 @@ Affects `vbobject.rs`, `pcodemethod.rs`, `methodlink.rs`,

Initial public release.

[Unreleased]: https://github.com/ATRAPSLLC/visualbasic-rs/compare/v0.5.0...HEAD
[Unreleased]: https://github.com/ATRAPSLLC/visualbasic-rs/compare/v0.6.0...HEAD
[0.6.0]: https://github.com/ATRAPSLLC/visualbasic-rs/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/ATRAPSLLC/visualbasic-rs/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/ATRAPSLLC/visualbasic-rs/compare/v0.3.2...v0.4.0
[0.3.2]: https://github.com/ATRAPSLLC/visualbasic-rs/compare/v0.3.1...v0.3.2
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "visualbasic"
version = "0.5.0"
version = "0.6.0"
edition = "2024"
rust-version = "1.88"
description = "Parse and inspect Visual Basic 6 compiled binaries"
Expand Down
33 changes: 23 additions & 10 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
//! - `opcode_generated.rs` - 6 static `[OpcodeInfo; 256]` opcode arrays
//! - `vb6_data_generated.rs` - control GUIDs, event templates, VB6 constants

use std::collections::HashMap;
use std::env;
use std::fs;
use std::io::Write;
use std::path::Path;
use std::{collections::HashMap, env, fs, io::Write, mem, path::Path};

/// Splits one CSV line into its fields, honouring double-quoted fields (a
/// quoted field may hold commas; `""` inside one is a quote).
Expand All @@ -31,7 +27,7 @@ fn split_csv_line(line: &str) -> Vec<String> {
chars.next();
}
'"' => quoted = !quoted,
',' if !quoted => fields.push(std::mem::take(&mut field)),
',' if !quoted => fields.push(mem::take(&mut field)),
_ => field.push(c),
}
}
Expand Down Expand Up @@ -672,14 +668,16 @@ fn generate_control_properties(out_dir: &str) {

// Only generate entries for active and flag properties
// (flag = bits 16+17 clear in descriptor flags, opcode emitted with no value)
if status != "active" && status != "flag" {
if status != "active" && status != "flag" && status != "blob" {
continue;
}

// Map (status, ser_type, callback_bytes) to PropType variant name.
// Flag entries have no value data regardless of ser_type.
let prop_type = if status == "flag" {
"Flag"
} else if status == "blob" {
"ObjectBlob"
} else {
match (ser_type, callback_bytes) {
(0, _) => "Flag",
Expand Down Expand Up @@ -720,6 +718,9 @@ fn generate_control_properties(out_dir: &str) {
props.sort_by_key(|e| e.index);
}

writeln!(out, "use super::PropType;").unwrap();
writeln!(out).unwrap();

// Write the PropertyDesc struct
writeln!(
out,
Expand All @@ -732,7 +733,7 @@ fn generate_control_properties(out_dir: &str) {
writeln!(out, " /// Property name.").unwrap();
writeln!(out, " pub name: &'static str,").unwrap();
writeln!(out, " /// Serialized value type.").unwrap();
writeln!(out, " pub prop_type: super::PropType,").unwrap();
writeln!(out, " pub prop_type: PropType,").unwrap();
writeln!(
out,
" /// Serialization type from descriptor flags & 0x3F."
Expand Down Expand Up @@ -767,7 +768,7 @@ fn generate_control_properties(out_dir: &str) {
{
writeln!(
out,
" ({idx}, PropertyDesc {{ name: {name:?}, prop_type: super::PropType::{prop_type}, ser_type: {ser_type}, callback_bytes: {callback_bytes} }}),"
" ({idx}, PropertyDesc {{ name: {name:?}, prop_type: PropType::{prop_type}, ser_type: {ser_type}, callback_bytes: {callback_bytes} }}),"
)
.unwrap();
}
Expand Down Expand Up @@ -832,6 +833,9 @@ fn generate_control_properties(out_dir: &str) {
("UserControl", 40),
("PropertyPage", 41),
("UserDocument", 42),
// A hosted control's record (an ActiveX control, a project's
// UserControl) has type 0xFF and states its extender's properties.
("Extender", 255),
];

for (ctrl_name, ctype_id) in &ctype_map {
Expand Down Expand Up @@ -1105,7 +1109,7 @@ fn classify_arith_op(mnemonic: &str) -> &'static str {
if mnemonic.starts_with("Mod") {
return "Mod";
}
if mnemonic.starts_with("Pow") {
if mnemonic.starts_with("Pwr") {
return "Pow";
}
if mnemonic.starts_with("Concat") {
Expand Down Expand Up @@ -1139,6 +1143,15 @@ fn classify_unary_op(mnemonic: &str) -> &'static str {
if mnemonic.starts_with("FnAbs") {
return "Abs";
}
if mnemonic.starts_with("FnFix") {
return "Fix";
}
if mnemonic.starts_with("FnInt") {
return "Int";
}
if mnemonic.starts_with("FnSgn") {
return "Sgn";
}
"Other"
}

Expand Down
85 changes: 84 additions & 1 deletion data/vb6_control_properties.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
# the composite labels Bounds (Left, Top, Width, Height), ClientSize (ClientLeft to
# ClientHeight) and DataSource(obj). A property stream names a property by
# its index in the table.
# Status: active=serializable, fontsub=flag-only, skip=runtime-only, sep=separator, obj=COM object ref
# Status: active=serializable, fontsub=flag-only, skip=runtime-only, sep=separator, obj=COM object ref,
# blob=a persisted object: a u32 tag, a u32 length and that many bytes. A hosted
# control's OleObjectBlob is one (`tests/fixtures/forms` Gauge1, `activex`
# CommonDialog1, whose record goes on after it); the OLE container's writes only
# its opcode (`props` POLE decodes to its terminator with it as a flag)
#
# Descriptor Table VAs:
# Timer: 0x66028A50 (9 entries)
Expand Down Expand Up @@ -34,6 +38,10 @@
# PropertyPage: 0x6602A3F0 (78 entries)
# UserControl: 0x66029530 (94 entries)
# UserDocument: 0x66029D10 (88 entries)
# Extender: 0x6602DE18 (75 entries) in MSVBVM60.DLL 6.00.8176
# (`toolchain/vb6`), the properties a hosted control's record
# (type 0xFF: an ActiveX control, a project's UserControl) states
# after its ProgID; rows reuse the rows of the same descriptors
#
control_type,index,name,ser_type,callback_bytes,status,flags,descriptor_va
CheckBox,0,Name,18,0,skip,0x8400D412,0x66001E50
Expand Down Expand Up @@ -1248,3 +1256,78 @@ VScrollBar,23,WhatsThisHelpID,3,0,active,0x80C12203,0x66001EF0
VScrollBar,24,Container,32,0,skip,0x80004C20,0x66001FB0
VScrollBar,25,RightToLeft,4,0,active,0x80C14404,0x66114000
VScrollBar,26,CausesValidation,4,0,active,0x80C12204,0x66002010
Extender,0,Name,18,0,skip,0x8400D412,0x6602DE18
Extender,1,Index,17,0,active,0x84C1D411,0x6602DE18
Extender,2,_,4,0,sep,0xE0000804,0x6602DE18
Extender,3,Bounds,8,4,active,0x90222408,0x6602DE18
Extender,4,Top,10,0,flag,0x9020240A,0x6602DE18
Extender,5,Width,9,0,flag,0x90202409,0x6602DE18
Extender,6,Height,11,0,flag,0x9020240B,0x6602DE18
Extender,7,Visible,4,0,active,0x80E14404,0x6602DE18
Extender,8,Parent,32,0,skip,0x80005820,0x6602DE18
Extender,9,DragMode,6,0,active,0x80C12606,0x6602DE18
Extender,10,DragIcon,21,0,active,0x84C1A215,0x6602DE18
Extender,11,Tag,13,0,active,0x80C1220D,0x6602DE18
Extender,12,_,4,0,sep,0xE0000804,0x6602DE18
Extender,13,Enabled,4,0,flag,0x00C04404,0x6602DE18
Extender,14,TabStop,4,0,active,0x80C14404,0x6602DE18
Extender,15,TabIndex,2,0,active,0x84012402,0x6602DE18
Extender,16,_,4,0,sep,0xE0000804,0x6602DE18
Extender,17,_,4,0,sep,0xE0000804,0x6602DE18
Extender,18,_,4,0,sep,0xE0000804,0x6602DE18
Extender,19,_,4,0,sep,0xE0000804,0x6602DE18
Extender,20,_,4,0,sep,0xE0000804,0x6602DE18
Extender,21,_,4,0,sep,0xE0000804,0x6602DE18
Extender,22,_,4,0,sep,0xE0000804,0x6602DE18
Extender,23,_,4,0,sep,0xE0000804,0x6602DE18
Extender,24,_,4,0,sep,0xE0000804,0x6602DE18
Extender,25,_,4,0,sep,0xE0000804,0x6602DE18
Extender,26,_,4,0,sep,0xE0000804,0x6602DE18
Extender,27,_,4,0,sep,0xE0000804,0x6602DE18
Extender,28,Object,32,0,skip,0x00005820,0x6602DE18
Extender,29,_,4,0,sep,0xE0000804,0x6602DE18
Extender,30,_,4,0,sep,0xE0000804,0x6602DE18
Extender,31,_,4,0,sep,0xE0000804,0x6602DE18
Extender,32,_,4,0,sep,0xE0000804,0x6602DE18
Extender,33,_,4,0,sep,0xE0000804,0x6602DE18
Extender,34,_,4,0,sep,0xE0000804,0x6602DE18
Extender,35,_,4,0,sep,0xE0000804,0x6602DE18
Extender,36,_,4,0,sep,0xE0000804,0x6602DE18
Extender,37,_,4,0,sep,0xE0000804,0x6602DE18
Extender,38,_,4,0,sep,0xE0000804,0x6602DE18
Extender,39,_,4,0,sep,0xE0000804,0x6602DE18
Extender,40,_,4,0,sep,0xE0000804,0x6602DE18
Extender,41,DataFormat,22,0,active,0x84654416,0x6602DE18
Extender,42,DataMember,33,0,active,0x80F12621,0x6602DE18
Extender,43,_,4,0,sep,0xE0000804,0x6602DE18
Extender,44,_,4,0,sep,0xE0000804,0x6602DE18
Extender,45,OleObjectBlob,3,0,blob,0x02021803,0x6602DE18
Extender,46,DataSource(obj),22,0,flag,0x84244C16,0x6602DE18
Extender,47,_,4,0,sep,0xE0000804,0x6602DE18
Extender,48,_,4,0,sep,0xE0000804,0x6602DE18
Extender,49,_,4,0,sep,0xE0000804,0x6602DE18
Extender,50,HelpContextID,3,0,active,0x80C12203,0x6602DE18
Extender,51,_,4,0,sep,0xE0000804,0x6602DE18
Extender,52,_,4,0,sep,0xE0000804,0x6602DE18
Extender,53,_,4,0,sep,0xE0000804,0x6602DE18
Extender,54,_,4,0,sep,0xE0000804,0x6602DE18
Extender,55,Default,4,0,active,0x84C14404,0x6602DE18
Extender,56,Cancel,4,0,active,0x84C14404,0x6602DE18
Extender,57,Left,8,0,active,0x82013408,0x6602DE18
Extender,58,Top,10,0,active,0x8201340A,0x6602DE18
Extender,59,Align,6,0,active,0x80C12406,0x6602DE18
Extender,60,Negotiate,4,0,active,0x82C13404,0x6602DE18
Extender,61,LinkTimeout,2,0,active,0x80C14402,0x6602DE18
Extender,62,LinkTopic,1,0,active,0x80E1C401,0x6602DE18
Extender,63,LinkItem,1,0,active,0x80E1C401,0x6602DE18
Extender,64,LinkMode,6,0,active,0x80C1C406,0x6602DE18
Extender,65,DataChanged,4,0,flag,0x80106E04,0x6602DE18
Extender,66,DataField,1,0,active,0x80F12601,0x6602DE18
Extender,67,DataSource,1,0,active,0x82F13201,0x6602DE18
Extender,68,Bindings,1,0,active,0x02021801,0x6602DE18
Extender,69,_,4,0,sep,0xE0000804,0x6602DE18
Extender,70,WhatsThisHelpID,3,0,active,0x80C12203,0x6602DE18
Extender,71,Container,32,0,skip,0x80004C20,0x6602DE18
Extender,72,CausesValidation,4,0,active,0x80C12204,0x6602DE18
Extender,73,DataBindings,22,0,flag,0x04005016,0x6602DE18
Extender,74,ToolTipText,1,0,active,0x80D12401,0x6602DE18
Loading
Loading