From f9c6b4fa3b5f070072f6971281d0f2859f7cbe04 Mon Sep 17 00:00:00 2001 From: Kuba Sunderland-Ober Date: Sat, 9 May 2026 00:30:20 +0200 Subject: [PATCH 1/3] Introduce the (Default) Module (aka _HiddenModule). --- .../Documentation Development.md | 2 +- docs/Reference/Modules/HiddenModule/index.md | 204 ++++++++++++++++++ docs/Reference/Modules/todo.md | 1 - 3 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 docs/Reference/Modules/HiddenModule/index.md diff --git a/docs/Miscellaneous/Documentation Development.md b/docs/Miscellaneous/Documentation Development.md index 0fa9947..58d35de 100644 --- a/docs/Miscellaneous/Documentation Development.md +++ b/docs/Miscellaneous/Documentation Development.md @@ -58,7 +58,7 @@ These are modules within VBA and VBRUN: - [Math](../tB/Modules/Math) - [Strings](../tB/Modules/Strings) - [TextEncodingConstants](../tB/Modules/TextEncodingConstants) - - Internal [_HiddenModule](../tB/Modules/_HiddenModule) + - Internal [_HiddenModule](../tB/Modules/HiddenModule) - VBRUN - [AmbientProperties](../tB/Modules/AmbientProperties) - [AsyncProperty](../tB/Modules/AsyncProperty) diff --git a/docs/Reference/Modules/HiddenModule/index.md b/docs/Reference/Modules/HiddenModule/index.md new file mode 100644 index 0000000..8abede7 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/index.md @@ -0,0 +1,204 @@ +--- +title: (Default) Module +parent: Modules +permalink: /tB/Modules/HiddenModule/ +redirect_from: + - /tB/Modules/_HiddenModule +has_toc: false +--- + +# (Default) module + +The **(Default)** module — known internally as **\_HiddenModule** — gathers together the unqualified intrinsic procedures: pointer- and memory-level helpers, the file-input pseudo-functions, the bridges into the codegen and reflection machinery, and a long tail of runtime utilities that the compiler emits calls into but that are also callable directly. Members of this module are referenced without a qualifier, the same way **MsgBox** and **CStr** are. + +Most of these procedures are deliberately hidden from IntelliSense and exist for advanced or low-level use; reach for them only when the higher-level alternatives in **[Math](../Math/)**, **[Strings](../Strings/)**, **[Information](../Information/)**, or **[Interaction](../Interaction/)** don't cover the case. Several have additional internal-only members that are not listed here at all. + +## Pointers and memory + +Three functions return raw addresses for use with API calls or unsafe interop: [**ObjPtr**](ObjPtr) for an object's COM identity, [**StrPtr**](StrPtr) for the underlying buffer of a **String**, and [**VarPtr**](VarPtr) for any variable. + +Memory at a known address is read and written one machine word at a time with the **GetMem*** / **PutMem*** family — [**GetMem1**](GetMem1), [**GetMem2**](GetMem2), [**GetMem4**](GetMem4), [**GetMem8**](GetMem8), and [**GetMemPtr**](GetMemPtr) for reads, with matching [**PutMem1**](PutMem1), [**PutMem2**](PutMem2), [**PutMem4**](PutMem4), [**PutMem8**](PutMem8), and [**PutMemPtr**](PutMemPtr). [**vbaCopyBytes**](vbaCopyBytes) and [**vbaCopyBytesZero**](vbaCopyBytesZero) move blocks; [**AllocMem**](AllocMem) and [**FreeMem**](FreeMem) manage heap allocations. + +```tb +Dim Buffer As LongPtr = AllocMem(16) +PutMem4 Buffer, &HDEADBEEF +Dim Magic As Long +GetMem4 Buffer, Magic +FreeMem Buffer +``` + +## Reading from open files + +[**Input**](Input) and [**Input$**](Input) read a fixed number of characters from a file opened with **Open**, returning a **Variant** or a **String** respectively. [**InputB**](InputB) and [**InputB$**](InputB) are their byte-oriented counterparts. [**Width**](Width) sets the line width on a sequential output channel. + +## Building variant arrays + +[**Array**](Array) creates a **Variant** array from a comma-separated list of values; the lower bound follows the source file's **Option Base** setting. As a special form, the same name doubles as a destructuring `Property Let` for unpacking an array on the right-hand side into individual variables on the left. + +```tb +Dim a As Variant = Array("one", "two", "three") +Dim x As Variant, y As Variant, z As Variant +Array(x, y, z) = a ' destructuring assignment +``` + +[**vbaRefVarAry**](vbaRefVarAry) and [**vbaAryMove**](vbaAryMove) are lower-level helpers used when interfacing with C-side array layouts. + +## Object references and casting + +[**vbaObjAddref**](vbaObjAddref), [**vbaObjSet**](vbaObjSet), and [**vbaObjSetAddref**](vbaObjSetAddref) manipulate COM reference counts directly. [**vbaCastObj**](vbaCastObj) returns the object reinterpreted as another COM interface, given its IID. [**CreateGUID**](CreateGUID) generates a fresh GUID and returns it as a registry-formatted string. + +## Atomic operations + +The **Interlocked*** family wraps the corresponding Windows kernel atomics — building blocks for lock-free counters and pointer swaps: [**InterlockedExchangePointer**](InterlockedExchangePointer), [**InterlockedCompareExchangePointer**](InterlockedCompareExchangePointer), [**InterlockedCompareExchange32**](InterlockedCompareExchange32), [**InterlockedCompareExchange64**](InterlockedCompareExchange64), [**InterlockedIncrement32**](InterlockedIncrement32), and [**InterlockedDecrement32**](InterlockedDecrement32). + +## Compile-time reflection + +A handful of intrinsics ask questions about the surrounding type without running anything; they are resolved by the compiler and burn in as constants. [**GetDeclaredTypeProgId**](GetDeclaredTypeProgId), [**GetDeclaredTypeClsid**](GetDeclaredTypeClsid), [**GetDeclaredTypeIid**](GetDeclaredTypeIid), and [**GetDeclaredTypeEventIid**](GetDeclaredTypeEventIid) report a type's COM identifiers. [**GetDeclaredMinEnumValue**](GetDeclaredMinEnumValue) and [**GetDeclaredMaxEnumValue**](GetDeclaredMaxEnumValue) return the minimum and maximum value of a declared enumeration. + +## Codegen injection and stack inspection + +[**Emit**](Emit) and [**EmitAny**](EmitAny) splice raw bytes or typed literals into the codegen output of the enclosing procedure — the vehicle for inline assembly. [**StackOffset**](StackOffset) and [**StackArgsSize**](StackArgsSize) report layout information at the current call site; [**UnprotectedAccess**](UnprotectedAccess) returns an object reference that bypasses the usual access checks on private members. + +## Runtime expression evaluation + +[**Eval**](Eval) compiles and evaluates a twinBASIC expression supplied as a string, using a freshly built [**TbExpressionService**](../ExpressionService/) configured with the standard library binder. + +## Pictures, bitmaps, and icons + +[**PictureToByteArray**](PictureToByteArray) serialises an **IPicture** to a byte array; [**CreateStdPictureFromHandle**](CreateStdPictureFromHandle) wraps a GDI handle in an **stdole.StdPicture**; [**ConvertIconToBitmap**](ConvertIconToBitmap) does the obvious. + +## Other helpers + +[**GetInheritedOwner**](GetInheritedOwner) returns the inherited owner object of a control. [**GetShortcutTextByEnum**](GetShortcutTextByEnum) returns the localised display text for a built-in keyboard shortcut. [**SetThreadGlobalErrorTrap**](SetThreadGlobalErrorTrap) registers a callback that fires when an unhandled run-time error escapes the active error handler chain on the calling thread. + +## Members + +- [AllocMem](AllocMem) -- allocates a block of native memory and returns its address +- [Array](Array) -- creates a **Variant** array from a comma-separated list of values, or destructures one when used on the left of an assignment +- [ConvertIconToBitmap](ConvertIconToBitmap) -- converts an icon picture to a bitmap picture +- [CreateGUID](CreateGUID) -- generates a fresh GUID and returns it as a registry-formatted string +- [CreateStdPictureFromHandle](CreateStdPictureFromHandle) -- wraps a GDI bitmap or icon handle in an **stdole.StdPicture** +- [Emit](Emit) -- injects custom **Byte** values into the codegen stream of the enclosing procedure +- [EmitAny](EmitAny) -- injects custom typed values into the codegen stream of the enclosing procedure +- [Eval](Eval) -- compiles and evaluates a twinBASIC expression supplied as a string +- [FreeMem](FreeMem) -- frees memory allocated with [**AllocMem**](AllocMem) +- [GetDeclaredMaxEnumValue](GetDeclaredMaxEnumValue) -- returns the maximum value of a declared enumeration type, resolved at compile time +- [GetDeclaredMinEnumValue](GetDeclaredMinEnumValue) -- returns the minimum value of a declared enumeration type, resolved at compile time +- [GetDeclaredTypeClsid](GetDeclaredTypeClsid) -- returns the COM CLSID associated with the declared type, resolved at compile time +- [GetDeclaredTypeEventIid](GetDeclaredTypeEventIid) -- returns the COM event-interface IID associated with the declared type, resolved at compile time +- [GetDeclaredTypeIid](GetDeclaredTypeIid) -- returns the COM interface IID associated with the declared type, resolved at compile time +- [GetDeclaredTypeProgId](GetDeclaredTypeProgId) -- returns the COM ProgID associated with the declared type, resolved at compile time +- [GetInheritedOwner](GetInheritedOwner) -- returns the inherited owner object of a control +- [GetMem1](GetMem1) -- reads one byte from a memory address into a **Byte** variable +- [GetMem2](GetMem2) -- reads two bytes from a memory address into an **Integer** variable +- [GetMem4](GetMem4) -- reads four bytes from a memory address into a **Long** variable +- [GetMem8](GetMem8) -- reads eight bytes from a memory address into a **Currency** variable +- [GetMemPtr](GetMemPtr) -- reads a pointer-sized value from a memory address into a **LongPtr** variable +- [GetShortcutTextByEnum](GetShortcutTextByEnum) -- returns the localized text for a built-in keyboard shortcut by its enumeration ID +- [Input, Input$](Input) -- reads a fixed number of characters from an open sequential file +- [InputB, InputB$](InputB) -- reads a fixed number of bytes from an open sequential file +- [InterlockedCompareExchange32](InterlockedCompareExchange32) -- atomically compares and exchanges a 32-bit value +- [InterlockedCompareExchange64](InterlockedCompareExchange64) -- atomically compares and exchanges a 64-bit value +- [InterlockedCompareExchangePointer](InterlockedCompareExchangePointer) -- atomically compares and exchanges a pointer-sized value +- [InterlockedDecrement32](InterlockedDecrement32) -- atomically decrements a 32-bit value and returns the new value +- [InterlockedExchangePointer](InterlockedExchangePointer) -- atomically exchanges a pointer-sized value and returns the previous value +- [InterlockedIncrement32](InterlockedIncrement32) -- atomically increments a 32-bit value and returns the new value +- [ObjPtr](ObjPtr) -- returns the COM-identity address of an object +- [PictureToByteArray](PictureToByteArray) -- serialises an **IPicture** into a **Byte** array +- [PutMem1](PutMem1) -- writes one byte to a memory address +- [PutMem2](PutMem2) -- writes two bytes to a memory address +- [PutMem4](PutMem4) -- writes four bytes to a memory address +- [PutMem8](PutMem8) -- writes eight bytes to a memory address +- [PutMemPtr](PutMemPtr) -- writes a pointer-sized value to a memory address +- [RuntimeCreateGetMessageHook](RuntimeCreateGetMessageHook) -- creates an [**IGetMessageHook**](./#igetmessagehook-interface) for filtering window messages +- [SetThreadGlobalErrorTrap](SetThreadGlobalErrorTrap) -- registers a global callback invoked when an unhandled error is raised on the calling thread +- [StackArgsSize](StackArgsSize) -- returns the total size, in bytes, of the arguments on the current procedure's stack frame +- [StackOffset](StackOffset) -- returns the stack-frame offset of a variable +- [StrPtr](StrPtr) -- returns the address of the underlying buffer of a **String** +- [UnprotectedAccess](UnprotectedAccess) -- returns an object reference that bypasses access checks on private members +- [VarPtr](VarPtr) -- returns the address of a variable +- [Width](Width) -- sets the line width for a sequential output file +- [vbaAryMove](vbaAryMove) -- moves the contents of one array variable into another +- [vbaCastObj](vbaCastObj) -- returns an object reinterpreted as another COM interface +- [vbaCopyBytes](vbaCopyBytes) -- copies a block of bytes from one address to another +- [vbaCopyBytesZero](vbaCopyBytesZero) -- copies a block of bytes from one address to another, then zeros the source +- [vbaObjAddref](vbaObjAddref) -- increments the COM reference count of an object at a given address +- [vbaObjSet](vbaObjSet) -- assigns an object pointer to an object variable, releasing any prior reference +- [vbaObjSetAddref](vbaObjSetAddref) -- assigns an object pointer to an object variable, adding a reference and releasing any prior reference +- [vbaRefVarAry](vbaRefVarAry) -- returns a pointer to the **SAFEARRAY** descriptor inside a **Variant** array + +## IGetMessageHook interface + +The **IGetMessageHook** interface taps into the Windows message stream for a chosen window — and optionally its descendants — and forwards messages of a chosen type to a user-supplied callback. Obtain an instance with [**RuntimeCreateGetMessageHook**](RuntimeCreateGetMessageHook); wire up callbacks with [**RegisterMessage**](RegisterMessage); then call [**Start**](Start) to activate every registered subscription, and [**Stop**](Stop) to remove them. + +The interface inherits directly from **stdole.IUnknown** (it is not dispatch-based), and the callbacks supplied to **RegisterMessage** are typed as [**GetMessageHookHelper.GetMessageHandler**](#getmessagehandler). + +```tb +Const WM_LBUTTONDOWN = &H201 + +Sub Demo() + Dim Hook As IGetMessageHook = RuntimeCreateGetMessageHook + Hook.RegisterMessage Me.hWnd, AllDescendants, _ + WM_LBUTTONDOWN, AddressOf OnLButtonDown + Hook.Start +End Sub + +Function OnLButtonDown(ByRef msg As GetMessageHookHelper.HookMSG) As LongPtr + Debug.Print "Click at"; msg.pt.x, msg.pt.y + ' Return zero to let the message continue normal processing. +End Function +``` + +### Members + +- [RegisterMessage](RegisterMessage) -- subscribes a callback to a single message type for a window and a chosen descendant scope +- [Start](Start) -- activates every registered subscription +- [Stop](Stop) -- deactivates every registered subscription + +### EnumDescendantsModeFlags + +Selects the window scope passed to [**RegisterMessage**](RegisterMessage): + +| Constant | Value | Description | +|------------------------------------------|-------|-------------| +| **ExactWindow**{: #ExactWindow } | 1 | Hook only the specified window. | +| **AllDescendants**{: #AllDescendants } | 2 | Hook the specified window and every descendant — children, grandchildren, and so on. | +| **DirectChildren**{: #DirectChildren } | 4 | Hook the specified window and its immediate children only. | + +## GetMessageHookHelper module + +The **GetMessageHookHelper** module is a small companion to [**IGetMessageHook**](#igetmessagehook-interface) that holds the structures and the delegate type used by its callback. There is nothing to construct; the names exist only for use in declarations. + +### HookMSG + +A copy of the Windows `MSG` structure, passed by reference into a [**GetMessageHandler**](#getmessagehandler) callback. + +```tb +Type HookMSG + hwnd As LongPtr ' Window the message is destined for. + message As Long ' The WM_* identifier. + wParam As LongPtr ' Message-specific parameter. + lParam As LongPtr ' Message-specific parameter. + time As Long ' Time the message was posted, in milliseconds since system start. + pt As HookPOINT ' Cursor position when the message was posted. +End Type +``` + +### HookPOINT + +A 2D point with **Long** coordinates, used by [**HookMSG**](#hookmsg) to carry the cursor position. + +```tb +Type HookPOINT + x As Long + y As Long +End Type +``` + +### GetMessageHandler + +The callback signature accepted by [**IGetMessageHook.RegisterMessage**](RegisterMessage). Returning zero generally lets the message continue normal processing. + +```tb +Public Delegate Function GetMessageHandler (ByRef msg As HookMSG) As LongPtr +``` diff --git a/docs/Reference/Modules/todo.md b/docs/Reference/Modules/todo.md index cca7cee..95dfbf3 100644 --- a/docs/Reference/Modules/todo.md +++ b/docs/Reference/Modules/todo.md @@ -3,7 +3,6 @@ title: General TODO List for /tB/Modules/ nav_exclude: true redirect_from: - /tB/Modules/TextEncodingConstants - - /tB/Modules/_HiddenModule - /tB/Modules/AmbientProperties - /tB/Modules/AsyncProperty - /tB/Modules/ContainedControls From 8324aba5d403eea5b8429cb3fb4d65c4ddccacfe Mon Sep 17 00:00:00 2001 From: Kuba Sunderland-Ober Date: Sat, 9 May 2026 01:09:00 +0200 Subject: [PATCH 2/3] Document the (Default) module. --- docs/Reference/Core/todo.md | 1 - .../Modules/HiddenModule/AllocMem.md | 32 +++++++++ docs/Reference/Modules/HiddenModule/Array.md | 65 +++++++++++++++++++ .../HiddenModule/ConvertIconToBitmap.md | 32 +++++++++ .../Modules/HiddenModule/CreateGUID.md | 26 ++++++++ .../CreateStdPictureFromHandle.md | 27 ++++++++ docs/Reference/Modules/HiddenModule/Emit.md | 43 ++++++++++++ .../Reference/Modules/HiddenModule/EmitAny.md | 28 ++++++++ docs/Reference/Modules/HiddenModule/Eval.md | 29 +++++++++ .../Reference/Modules/HiddenModule/FreeMem.md | 20 ++++++ .../HiddenModule/GetDeclaredMaxEnumValue.md | 20 ++++++ .../HiddenModule/GetDeclaredMinEnumValue.md | 35 ++++++++++ .../HiddenModule/GetDeclaredTypeClsid.md | 24 +++++++ .../HiddenModule/GetDeclaredTypeEventIid.md | 24 +++++++ .../HiddenModule/GetDeclaredTypeIid.md | 32 +++++++++ .../HiddenModule/GetDeclaredTypeProgId.md | 31 +++++++++ .../Modules/HiddenModule/GetInheritedOwner.md | 17 +++++ .../Reference/Modules/HiddenModule/GetMem1.md | 33 ++++++++++ .../Reference/Modules/HiddenModule/GetMem2.md | 24 +++++++ .../Reference/Modules/HiddenModule/GetMem4.md | 24 +++++++ .../Reference/Modules/HiddenModule/GetMem8.md | 26 ++++++++ .../Modules/HiddenModule/GetMemPtr.md | 34 ++++++++++ .../HiddenModule/GetShortcutTextByEnum.md | 20 ++++++ docs/Reference/Modules/HiddenModule/Input.md | 50 ++++++++++++++ docs/Reference/Modules/HiddenModule/InputB.md | 40 ++++++++++++ .../InterlockedCompareExchange32.md | 28 ++++++++ .../InterlockedCompareExchange64.md | 27 ++++++++ .../InterlockedCompareExchangePointer.md | 38 +++++++++++ .../HiddenModule/InterlockedDecrement32.md | 21 ++++++ .../InterlockedExchangePointer.md | 24 +++++++ .../HiddenModule/InterlockedIncrement32.md | 21 ++++++ docs/Reference/Modules/HiddenModule/ObjPtr.md | 36 ++++++++++ .../HiddenModule/PictureToByteArray.md | 30 +++++++++ .../Reference/Modules/HiddenModule/PutMem1.md | 24 +++++++ .../Reference/Modules/HiddenModule/PutMem2.md | 24 +++++++ .../Reference/Modules/HiddenModule/PutMem4.md | 24 +++++++ .../Reference/Modules/HiddenModule/PutMem8.md | 26 ++++++++ .../Modules/HiddenModule/PutMemPtr.md | 24 +++++++ .../Modules/HiddenModule/RegisterMessage.md | 48 ++++++++++++++ .../RuntimeCreateGetMessageHook.md | 31 +++++++++ .../HiddenModule/SetThreadGlobalErrorTrap.md | 23 +++++++ .../Modules/HiddenModule/StackArgsSize.md | 19 ++++++ .../Modules/HiddenModule/StackOffset.md | 22 +++++++ docs/Reference/Modules/HiddenModule/Start.md | 22 +++++++ docs/Reference/Modules/HiddenModule/Stop.md | 25 +++++++ docs/Reference/Modules/HiddenModule/StrPtr.md | 38 +++++++++++ .../Modules/HiddenModule/UnprotectedAccess.md | 23 +++++++ docs/Reference/Modules/HiddenModule/VarPtr.md | 34 ++++++++++ docs/Reference/Modules/HiddenModule/Width.md | 40 ++++++++++++ .../Modules/HiddenModule/vbaAryMove.md | 26 ++++++++ .../Modules/HiddenModule/vbaCastObj.md | 36 ++++++++++ .../Modules/HiddenModule/vbaCopyBytes.md | 35 ++++++++++ .../Modules/HiddenModule/vbaCopyBytesZero.md | 26 ++++++++ .../Modules/HiddenModule/vbaObjAddref.md | 24 +++++++ .../Modules/HiddenModule/vbaObjSet.md | 27 ++++++++ .../Modules/HiddenModule/vbaObjSetAddref.md | 27 ++++++++ .../Modules/HiddenModule/vbaRefVarAry.md | 23 +++++++ docs/Reference/Procedures and Functions.md | 33 +++++++++- 58 files changed, 1664 insertions(+), 2 deletions(-) create mode 100644 docs/Reference/Modules/HiddenModule/AllocMem.md create mode 100644 docs/Reference/Modules/HiddenModule/Array.md create mode 100644 docs/Reference/Modules/HiddenModule/ConvertIconToBitmap.md create mode 100644 docs/Reference/Modules/HiddenModule/CreateGUID.md create mode 100644 docs/Reference/Modules/HiddenModule/CreateStdPictureFromHandle.md create mode 100644 docs/Reference/Modules/HiddenModule/Emit.md create mode 100644 docs/Reference/Modules/HiddenModule/EmitAny.md create mode 100644 docs/Reference/Modules/HiddenModule/Eval.md create mode 100644 docs/Reference/Modules/HiddenModule/FreeMem.md create mode 100644 docs/Reference/Modules/HiddenModule/GetDeclaredMaxEnumValue.md create mode 100644 docs/Reference/Modules/HiddenModule/GetDeclaredMinEnumValue.md create mode 100644 docs/Reference/Modules/HiddenModule/GetDeclaredTypeClsid.md create mode 100644 docs/Reference/Modules/HiddenModule/GetDeclaredTypeEventIid.md create mode 100644 docs/Reference/Modules/HiddenModule/GetDeclaredTypeIid.md create mode 100644 docs/Reference/Modules/HiddenModule/GetDeclaredTypeProgId.md create mode 100644 docs/Reference/Modules/HiddenModule/GetInheritedOwner.md create mode 100644 docs/Reference/Modules/HiddenModule/GetMem1.md create mode 100644 docs/Reference/Modules/HiddenModule/GetMem2.md create mode 100644 docs/Reference/Modules/HiddenModule/GetMem4.md create mode 100644 docs/Reference/Modules/HiddenModule/GetMem8.md create mode 100644 docs/Reference/Modules/HiddenModule/GetMemPtr.md create mode 100644 docs/Reference/Modules/HiddenModule/GetShortcutTextByEnum.md create mode 100644 docs/Reference/Modules/HiddenModule/Input.md create mode 100644 docs/Reference/Modules/HiddenModule/InputB.md create mode 100644 docs/Reference/Modules/HiddenModule/InterlockedCompareExchange32.md create mode 100644 docs/Reference/Modules/HiddenModule/InterlockedCompareExchange64.md create mode 100644 docs/Reference/Modules/HiddenModule/InterlockedCompareExchangePointer.md create mode 100644 docs/Reference/Modules/HiddenModule/InterlockedDecrement32.md create mode 100644 docs/Reference/Modules/HiddenModule/InterlockedExchangePointer.md create mode 100644 docs/Reference/Modules/HiddenModule/InterlockedIncrement32.md create mode 100644 docs/Reference/Modules/HiddenModule/ObjPtr.md create mode 100644 docs/Reference/Modules/HiddenModule/PictureToByteArray.md create mode 100644 docs/Reference/Modules/HiddenModule/PutMem1.md create mode 100644 docs/Reference/Modules/HiddenModule/PutMem2.md create mode 100644 docs/Reference/Modules/HiddenModule/PutMem4.md create mode 100644 docs/Reference/Modules/HiddenModule/PutMem8.md create mode 100644 docs/Reference/Modules/HiddenModule/PutMemPtr.md create mode 100644 docs/Reference/Modules/HiddenModule/RegisterMessage.md create mode 100644 docs/Reference/Modules/HiddenModule/RuntimeCreateGetMessageHook.md create mode 100644 docs/Reference/Modules/HiddenModule/SetThreadGlobalErrorTrap.md create mode 100644 docs/Reference/Modules/HiddenModule/StackArgsSize.md create mode 100644 docs/Reference/Modules/HiddenModule/StackOffset.md create mode 100644 docs/Reference/Modules/HiddenModule/Start.md create mode 100644 docs/Reference/Modules/HiddenModule/Stop.md create mode 100644 docs/Reference/Modules/HiddenModule/StrPtr.md create mode 100644 docs/Reference/Modules/HiddenModule/UnprotectedAccess.md create mode 100644 docs/Reference/Modules/HiddenModule/VarPtr.md create mode 100644 docs/Reference/Modules/HiddenModule/Width.md create mode 100644 docs/Reference/Modules/HiddenModule/vbaAryMove.md create mode 100644 docs/Reference/Modules/HiddenModule/vbaCastObj.md create mode 100644 docs/Reference/Modules/HiddenModule/vbaCopyBytes.md create mode 100644 docs/Reference/Modules/HiddenModule/vbaCopyBytesZero.md create mode 100644 docs/Reference/Modules/HiddenModule/vbaObjAddref.md create mode 100644 docs/Reference/Modules/HiddenModule/vbaObjSet.md create mode 100644 docs/Reference/Modules/HiddenModule/vbaObjSetAddref.md create mode 100644 docs/Reference/Modules/HiddenModule/vbaRefVarAry.md diff --git a/docs/Reference/Core/todo.md b/docs/Reference/Core/todo.md index ea9a668..5541b9d 100644 --- a/docs/Reference/Core/todo.md +++ b/docs/Reference/Core/todo.md @@ -50,7 +50,6 @@ redirect_from: - /tB/Core/Unload - /tB/Core/Unlock - /tB/Core/While-Wend - - /tB/Core/Width - /tB/Core/With - /tB/Core/Write --- diff --git a/docs/Reference/Modules/HiddenModule/AllocMem.md b/docs/Reference/Modules/HiddenModule/AllocMem.md new file mode 100644 index 0000000..9419dda --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/AllocMem.md @@ -0,0 +1,32 @@ +--- +title: AllocMem +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/AllocMem +--- +# AllocMem +{: .no_toc } + +Allocates a block of native memory and returns its address. + +Syntax: **AllocMem(** *BytesToAlloc* **)** **As LongPtr** + +*BytesToAlloc* +: *required* **Long**. The size of the block to allocate, in bytes. + +The contents of the new block are unspecified. Release the block with [**FreeMem**](FreeMem) when you are done with it; passing the address to anything else (e.g. a Win32 `HeapFree`) will not work, since the block is owned by the twinBASIC runtime's heap. + +If the allocation fails, **AllocMem** raises a run-time error. + +### Example + +```tb +Dim Buffer As LongPtr = AllocMem(1024) +PutMem4 Buffer, &HDEADBEEF +'... use Buffer ... +FreeMem Buffer +``` + +### See Also + +- [FreeMem](FreeMem) procedure +- [vbaCopyBytes](vbaCopyBytes) function diff --git a/docs/Reference/Modules/HiddenModule/Array.md b/docs/Reference/Modules/HiddenModule/Array.md new file mode 100644 index 0000000..6e5b938 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/Array.md @@ -0,0 +1,65 @@ +--- +title: Array +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/Array +--- +# Array +{: .no_toc } + +Returns a **Variant** containing an array built from a comma-separated list of values, or — when used on the left of an assignment — destructures an array on the right-hand side into the supplied variables. + +Syntax: +- *result* **= Array(** [ *ArgList* ] **)** — array creation. +- **Array(** *Var1*, *Var2*, ... **) =** *RhsArray* — destructuring assignment. + +*ArgList* +: *optional* A comma-delimited list of values that are assigned to the elements of the new array. If no arguments are supplied, an empty array is returned. + +*Var1*, *Var2*, ... +: *required* (destructuring form) The variables to receive successive elements of *RhsArray*. Pass `_` to skip an element. + +*RhsArray* +: *required* (destructuring form) An array; non-array values raise an error. + +The lower bound of an array created with **Array** is determined by the **Option Base** statement at the component scope, defaulting to `0`. + +```tb +Option Base 1 +Dim a As Variant +a = Array(10, 20, 30) +Debug.Print a(1) ' 10 +``` + +The destructuring form unpacks an array into the named variables in order, starting from the array's lower bound. The argument list can mix variables and the `_` placeholder to skip elements: + +```tb +Dim x As Variant, y As Variant, z As Variant +Array(x, y, z) = Array("one", "two", "three") +' x = "one", y = "two", z = "three" + +Dim a As Variant, b As Variant +Array(a, _, b) = Array(1, 2, 3) +' a = 1, b = 3 — the second element is discarded +``` + +> [!NOTE] +> A **Variant** that is not declared as an array can still contain an array, and a **Variant** array can hold values of any type except fixed-length strings and user-defined types. Although a **Variant** containing an array is conceptually different from an array of **Variant** elements, indexing works the same way for both. + +### Example + +This example uses the **Array** function to return a **Variant** containing an array. + +```tb +Dim MyWeek As Variant +Dim MyDay As Variant +MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") +MyDay = MyWeek(2) ' MyDay contains "Wed" with default Option Base 0, + ' or "Tue" under Option Base 1. +``` + +### See Also + +- [Option](../../Core/Option) statement +- [LBound](../Information/LBound), [UBound](../Information/UBound) functions + +{% include VBA-Attribution.md %} diff --git a/docs/Reference/Modules/HiddenModule/ConvertIconToBitmap.md b/docs/Reference/Modules/HiddenModule/ConvertIconToBitmap.md new file mode 100644 index 0000000..ff33aa1 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/ConvertIconToBitmap.md @@ -0,0 +1,32 @@ +--- +title: ConvertIconToBitmap +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/ConvertIconToBitmap +--- +# ConvertIconToBitmap +{: .no_toc } + +Converts an icon picture into a bitmap picture. + +Syntax: **ConvertIconToBitmap(** *IconPicture* [ **,** *BackColor* ] **)** **As Object** + +*IconPicture* +: *required* **Object**. An **stdole.StdPicture** holding an icon (`vbPicTypeIcon`) or cursor (`vbPicTypeIcon`). + +*BackColor* +: *optional* **Variant**. The background colour to flatten transparent pixels onto, given as an OLE colour value. If omitted, the system **Window** colour is used. + +The returned picture is a fresh bitmap-typed **stdole.StdPicture** with the icon rasterised on top of the chosen background. The original icon picture is unchanged. + +### Example + +```tb +Dim Bmp As StdPicture +Set Bmp = ConvertIconToBitmap(MyIconPicture, RGB(255, 255, 255)) +Set Picture1.Picture = Bmp +``` + +### See Also + +- [CreateStdPictureFromHandle](CreateStdPictureFromHandle) function +- [PictureToByteArray](PictureToByteArray) function diff --git a/docs/Reference/Modules/HiddenModule/CreateGUID.md b/docs/Reference/Modules/HiddenModule/CreateGUID.md new file mode 100644 index 0000000..c4a8754 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/CreateGUID.md @@ -0,0 +1,26 @@ +--- +title: CreateGUID +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/CreateGUID +--- +# CreateGUID +{: .no_toc } + +Generates a fresh GUID and returns it as a registry-formatted string. + +Syntax: **CreateGUID()** **As String** + +The result is a fresh, unique GUID in the form `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}` — the same format used by **InterfaceId**, **ClassId**, and the like. Each call returns a different value. + +This is a thin wrapper over the operating system's GUID generator (`CoCreateGuid` on Windows). The resulting GUID is suitable for use as an interface or class identifier; it is not, however, a cryptographically random number — do not use it where unpredictability matters. + +### Example + +```tb +Debug.Print CreateGUID() +' {2A1B6F2C-4D9F-4D5E-9C8A-EE9C8B5F3DCE} +``` + +### See Also + +- [vbaCastObj](vbaCastObj) function diff --git a/docs/Reference/Modules/HiddenModule/CreateStdPictureFromHandle.md b/docs/Reference/Modules/HiddenModule/CreateStdPictureFromHandle.md new file mode 100644 index 0000000..123786f --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/CreateStdPictureFromHandle.md @@ -0,0 +1,27 @@ +--- +title: CreateStdPictureFromHandle +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/CreateStdPictureFromHandle +--- +# CreateStdPictureFromHandle +{: .no_toc } + +Wraps a GDI handle in an **stdole.StdPicture** so it can be assigned to a control's **Picture** property or passed to any other **IPicture** consumer. + +Syntax: **CreateStdPictureFromHandle(** *Handle* **,** *Type* **,** *TakeOwnership* **)** **As Object** + +*Handle* +: *required* **LongPtr**. The GDI handle to wrap — typically an `HBITMAP`, `HICON`, `HCURSOR`, `HENHMETAFILE`, or `HMETAFILE`. + +*Type* +: *required* **Long**. The picture type. Pass one of the **PictureTypeConstants** values (`vbPicTypeBitmap`, `vbPicTypeIcon`, `vbPicTypeMetafile`, `vbPicTypeEnhMetafile`) corresponding to *Handle*'s flavour. + +*TakeOwnership* +: *required* **Boolean**. If **True**, the returned picture takes ownership of *Handle* and frees it when released. If **False**, the caller remains responsible for the handle's lifetime. + +The result is a regular **stdole.StdPicture** equivalent to one returned by **LoadPicture**, suitable for assignment to a **Picture** property. + +### See Also + +- [PictureToByteArray](PictureToByteArray) function +- [ConvertIconToBitmap](ConvertIconToBitmap) function diff --git a/docs/Reference/Modules/HiddenModule/Emit.md b/docs/Reference/Modules/HiddenModule/Emit.md new file mode 100644 index 0000000..72a330a --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/Emit.md @@ -0,0 +1,43 @@ +--- +title: Emit +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/Emit +--- +# Emit +{: .no_toc } + +Splices raw bytes into the codegen output of the enclosing procedure. + +Syntax: **Emit** *Values* ... + +*Values* +: *required* A **ParamArray** of **Byte** values that are emitted, in order, at the location of the call. + +The bytes are written into the procedure's machine code at the spot where **Emit** appears — there is no run-time call. Used together with the **Naked** procedure modifier to write inline assembly. + +### Example + +A naked **InterlockedIncrement** that adds one to *Addend* atomically. + +```tb +Public Function InlineInterlockedIncrement CDecl Naked(Addend As Long) As Long + #If Win64 Then + Emit(&Hb8, &H01, &H00, &H00, &H00) ' mov eax,0x1 + Emit(&Hf0, &H0f, &Hc1, &H41, &H00) ' lock xadd DWORD PTR [rcx+0x4],eax + Emit(&Hff, &Hc0) ' inc eax + Emit(&Hc3) ' ret + #Else + Emit(&H8b, &H4c, &H24, &H04) ' mov ecx, DWORD PTR _Addend$[esp-4] + Emit(&Hb8, &H01, &H00, &H00, &H00) ' mov eax, 1 + Emit(&Hf0, &H0f, &Hc1, &H01) ' lock xadd DWORD PTR [ecx], eax + Emit(&H40) ' inc eax + Emit(&Hc3) ' ret 0 + #End If +End Function +``` + +### See Also + +- [EmitAny](EmitAny) procedure +- [Direct Assembly Insertion](../../../Features/Advanced/Assembly) +- [StackOffset](StackOffset) function diff --git a/docs/Reference/Modules/HiddenModule/EmitAny.md b/docs/Reference/Modules/HiddenModule/EmitAny.md new file mode 100644 index 0000000..526edbe --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/EmitAny.md @@ -0,0 +1,28 @@ +--- +title: EmitAny +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/EmitAny +--- +# EmitAny +{: .no_toc } + +Splices typed literal values into the codegen output of the enclosing procedure. The size of the output is inferred from each value's data type. + +Syntax: **EmitAny** *Values* ... + +*Values* +: *required* A **ParamArray** of typed literals. Each value contributes its in-memory representation — one byte for **Byte**, two for **Integer**, four for **Long** or **Single**, eight for **Currency**, **Double**, or **LongLong**, and pointer-sized for **LongPtr**. + +The values are written into the procedure's machine code at the spot where **EmitAny** appears. Useful when an instruction's operand mixes opcodes and a multi-byte immediate — letting **EmitAny** size the immediate correctly avoids splitting it into a sequence of [**Emit**](Emit) calls. + +### Example + +```tb +' mov eax, 0x12345678 — emit the opcode + a 32-bit immediate. +EmitAny(CByte(&HB8), CLng(&H12345678)) +``` + +### See Also + +- [Emit](Emit) procedure +- [Direct Assembly Insertion](../../../Features/Advanced/Assembly) diff --git a/docs/Reference/Modules/HiddenModule/Eval.md b/docs/Reference/Modules/HiddenModule/Eval.md new file mode 100644 index 0000000..bc4db82 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/Eval.md @@ -0,0 +1,29 @@ +--- +title: Eval +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/Eval +--- +# Eval +{: .no_toc } + +Compiles and evaluates a twinBASIC expression supplied as a string, returning the result as a **Variant**. + +Syntax: **Eval(** *Expression* **)** **As Variant** + +*Expression* +: *required* **String**. A twinBASIC expression that resolves to a value — for example, `"2 + 2"`, `"Sqr(2)"`, or `"UCase(""hello"")"`. + +A fresh [**TbExpressionService**](../ExpressionService/) is built for every call, with the standard library binder registered so the standard runtime functions ([**Sin**](../Math/Sin), [**Sqr**](../Math/Sqr), [**Len**](../Strings/Len), [**CStr**](../Conversion/CStr), and the rest) are visible. The expression is then compiled and evaluated once, and the service is discarded. + +For repeated evaluation of the same source, or for expressions that need to see your own application objects, build the service yourself and reuse a compiled [**ITbExpression**](../ExpressionService/#itbexpression-interface) — see the [ExpressionService module](../ExpressionService/) for details. + +### Example + +```tb +Debug.Print Eval("2 * (Sqr(2) + 1)") ' 4.82842712474619 +Debug.Print Eval("UCase(""hello"")") ' "HELLO" +``` + +### See Also + +- [ExpressionService module](../ExpressionService/) diff --git a/docs/Reference/Modules/HiddenModule/FreeMem.md b/docs/Reference/Modules/HiddenModule/FreeMem.md new file mode 100644 index 0000000..8956223 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/FreeMem.md @@ -0,0 +1,20 @@ +--- +title: FreeMem +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/FreeMem +--- +# FreeMem +{: .no_toc } + +Releases a block of memory previously obtained from [**AllocMem**](AllocMem). + +Syntax: **FreeMem** *MemPointer* + +*MemPointer* +: *required* **LongPtr**. The address returned by a previous call to [**AllocMem**](AllocMem). + +The pointer is invalid after the call returns. Passing a pointer that did not come from **AllocMem** — including zero, or one that has already been freed — has undefined behaviour. + +### See Also + +- [AllocMem](AllocMem) function diff --git a/docs/Reference/Modules/HiddenModule/GetDeclaredMaxEnumValue.md b/docs/Reference/Modules/HiddenModule/GetDeclaredMaxEnumValue.md new file mode 100644 index 0000000..4713cc7 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetDeclaredMaxEnumValue.md @@ -0,0 +1,20 @@ +--- +title: GetDeclaredMaxEnumValue +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetDeclaredMaxEnumValue +--- +# GetDeclaredMaxEnumValue +{: .no_toc } + +Returns the largest member value of a declared enumeration type, resolved at compile time. + +Syntax: **GetDeclaredMaxEnumValue(Of** *T* **)()** **As Long** + +*T* +: *required* The enumeration type to query. + +Walks the members of *T* and returns the highest assigned value. Resolved at compile time and folded into the generated code as a numeric constant — there is no run-time iteration. + +### See Also + +- [GetDeclaredMinEnumValue](GetDeclaredMinEnumValue) function diff --git a/docs/Reference/Modules/HiddenModule/GetDeclaredMinEnumValue.md b/docs/Reference/Modules/HiddenModule/GetDeclaredMinEnumValue.md new file mode 100644 index 0000000..cad1f69 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetDeclaredMinEnumValue.md @@ -0,0 +1,35 @@ +--- +title: GetDeclaredMinEnumValue +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetDeclaredMinEnumValue +--- +# GetDeclaredMinEnumValue +{: .no_toc } + +Returns the smallest member value of a declared enumeration type, resolved at compile time. + +Syntax: **GetDeclaredMinEnumValue(Of** *T* **)()** **As Long** + +*T* +: *required* The enumeration type to query. + +Walks the members of *T* and returns the lowest assigned value. Resolved at compile time and folded into the generated code as a numeric constant — there is no run-time iteration. + +### Example + +```tb +Enum Severity + Trace = 0 + Debug = 1 + Info = 2 + Warning = 3 + Error = 4 +End Enum + +Debug.Print GetDeclaredMinEnumValue(Of Severity)() ' 0 +Debug.Print GetDeclaredMaxEnumValue(Of Severity)() ' 4 +``` + +### See Also + +- [GetDeclaredMaxEnumValue](GetDeclaredMaxEnumValue) function diff --git a/docs/Reference/Modules/HiddenModule/GetDeclaredTypeClsid.md b/docs/Reference/Modules/HiddenModule/GetDeclaredTypeClsid.md new file mode 100644 index 0000000..ac83080 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetDeclaredTypeClsid.md @@ -0,0 +1,24 @@ +--- +title: GetDeclaredTypeClsid +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetDeclaredTypeClsid +--- +# GetDeclaredTypeClsid +{: .no_toc } + +Returns the COM CLSID (class identifier) associated with a declared type, resolved at compile time. + +Syntax: **GetDeclaredTypeClsid(Of** *T* **)()** **As String** + +*T* +: *required* The type to query for. Typically a coclass declared with the **CoClassId** attribute or imported from a type library. + +The CLSID is returned in registry format (`{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`). The lookup happens at compile time and the result is baked into the generated code as a string literal — there is no run-time call. + +Returns an empty string if the type has no associated CLSID. + +### See Also + +- [GetDeclaredTypeProgId](GetDeclaredTypeProgId) function +- [GetDeclaredTypeIid](GetDeclaredTypeIid) function +- [GetDeclaredTypeEventIid](GetDeclaredTypeEventIid) function diff --git a/docs/Reference/Modules/HiddenModule/GetDeclaredTypeEventIid.md b/docs/Reference/Modules/HiddenModule/GetDeclaredTypeEventIid.md new file mode 100644 index 0000000..026ac6d --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetDeclaredTypeEventIid.md @@ -0,0 +1,24 @@ +--- +title: GetDeclaredTypeEventIid +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetDeclaredTypeEventIid +--- +# GetDeclaredTypeEventIid +{: .no_toc } + +Returns the IID of the COM event interface associated with a declared type, resolved at compile time. + +Syntax: **GetDeclaredTypeEventIid(Of** *T* **)()** **As String** + +*T* +: *required* The type to query for. Typically a coclass that exposes events via the **EventInterfaceId** attribute or imported from a type library. + +The IID is returned in registry format (`{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`). The lookup happens at compile time and the result is baked into the generated code as a string literal — there is no run-time call. + +Returns an empty string if the type has no associated event interface. + +### See Also + +- [GetDeclaredTypeIid](GetDeclaredTypeIid) function +- [GetDeclaredTypeProgId](GetDeclaredTypeProgId) function +- [GetDeclaredTypeClsid](GetDeclaredTypeClsid) function diff --git a/docs/Reference/Modules/HiddenModule/GetDeclaredTypeIid.md b/docs/Reference/Modules/HiddenModule/GetDeclaredTypeIid.md new file mode 100644 index 0000000..c80d5fd --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetDeclaredTypeIid.md @@ -0,0 +1,32 @@ +--- +title: GetDeclaredTypeIid +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetDeclaredTypeIid +--- +# GetDeclaredTypeIid +{: .no_toc } + +Returns the COM interface IID associated with a declared type, resolved at compile time. + +Syntax: **GetDeclaredTypeIid(Of** *T* **)()** **As String** + +*T* +: *required* The type to query for. Typically an interface declared with the **InterfaceId** attribute or imported from a type library. + +The IID is returned in registry format (`{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`). The lookup happens at compile time and the result is baked into the generated code as a string literal — there is no run-time call. + +Useful when calling [**vbaCastObj**](vbaCastObj) or any API that takes an interface IID as a string. + +### Example + +```tb +Dim Iid As String = GetDeclaredTypeIid(Of stdole.IPicture)() +Dim AsPic As IUnknown = vbaCastObj(SomeObj, Iid) +``` + +### See Also + +- [GetDeclaredTypeProgId](GetDeclaredTypeProgId) function +- [GetDeclaredTypeClsid](GetDeclaredTypeClsid) function +- [GetDeclaredTypeEventIid](GetDeclaredTypeEventIid) function +- [vbaCastObj](vbaCastObj) function diff --git a/docs/Reference/Modules/HiddenModule/GetDeclaredTypeProgId.md b/docs/Reference/Modules/HiddenModule/GetDeclaredTypeProgId.md new file mode 100644 index 0000000..c04cebb --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetDeclaredTypeProgId.md @@ -0,0 +1,31 @@ +--- +title: GetDeclaredTypeProgId +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetDeclaredTypeProgId +--- +# GetDeclaredTypeProgId +{: .no_toc } + +Returns the COM ProgID associated with a declared type, resolved at compile time. + +Syntax: **GetDeclaredTypeProgId(Of** *T* **)()** **As String** + +*T* +: *required* The type to query for. Typically a coclass declared with the **CoClassId** attribute or imported from a type library. + +The ProgID is the human-readable name (`Application.Object`, `Scripting.Dictionary`, ...) that matches *T*'s CLSID in the registry. The lookup happens at compile time and the result is baked into the generated code as a string literal — there is no run-time call. + +Returns an empty string if the type has no associated ProgID. + +### Example + +```tb +Dim Id As String = GetDeclaredTypeProgId(Of MyApp.Document)() +Debug.Print Id ' "MyApp.Document" +``` + +### See Also + +- [GetDeclaredTypeClsid](GetDeclaredTypeClsid) function +- [GetDeclaredTypeIid](GetDeclaredTypeIid) function +- [GetDeclaredTypeEventIid](GetDeclaredTypeEventIid) function diff --git a/docs/Reference/Modules/HiddenModule/GetInheritedOwner.md b/docs/Reference/Modules/HiddenModule/GetInheritedOwner.md new file mode 100644 index 0000000..99a6953 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetInheritedOwner.md @@ -0,0 +1,17 @@ +--- +title: GetInheritedOwner +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetInheritedOwner +--- +# GetInheritedOwner +{: .no_toc } + +Returns the inherited owner object of a control. + +Syntax: **GetInheritedOwner(** *Value* **)** **As Object** + +*Value* +: *required* **Object**. The control whose inherited owner is wanted. + +For controls that participate in a control-container hierarchy, the inherited owner is the topmost owning object that supplies ambient settings — typically the form. Returns **Nothing** when no inherited owner is set. + diff --git a/docs/Reference/Modules/HiddenModule/GetMem1.md b/docs/Reference/Modules/HiddenModule/GetMem1.md new file mode 100644 index 0000000..661188a --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetMem1.md @@ -0,0 +1,33 @@ +--- +title: GetMem1 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetMem1 +--- +# GetMem1 +{: .no_toc } + +Reads one byte from a memory address into a **Byte** variable. + +Syntax: **GetMem1** *Address* **,** *retVal* + +*Address* +: *required* **LongPtr**. The address to read from. + +*retVal* +: *required* **Byte**. The variable to receive the byte read from *Address*. + +The address is read directly with no bounds or alignment check. Reading from an address that does not belong to the process, or from one that has been freed, will crash the host. + +### Example + +```tb +Dim s As String = "ABC" +Dim b As Byte +GetMem1 StrPtr(s), b +Debug.Print b ' 65 — the low byte of the UTF-16 code unit for "A". +``` + +### See Also + +- [GetMem2](GetMem2), [GetMem4](GetMem4), [GetMem8](GetMem8), [GetMemPtr](GetMemPtr) procedures +- [PutMem1](PutMem1) procedure diff --git a/docs/Reference/Modules/HiddenModule/GetMem2.md b/docs/Reference/Modules/HiddenModule/GetMem2.md new file mode 100644 index 0000000..b6d996e --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetMem2.md @@ -0,0 +1,24 @@ +--- +title: GetMem2 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetMem2 +--- +# GetMem2 +{: .no_toc } + +Reads two bytes from a memory address into an **Integer** variable. + +Syntax: **GetMem2** *Address* **,** *retVal* + +*Address* +: *required* **LongPtr**. The address to read from. + +*retVal* +: *required* **Integer**. The variable to receive the value read from *Address*. + +The bytes are interpreted in the host's native byte order — little-endian on x86 and x64. The address is read directly with no bounds or alignment check. + +### See Also + +- [GetMem1](GetMem1), [GetMem4](GetMem4), [GetMem8](GetMem8), [GetMemPtr](GetMemPtr) procedures +- [PutMem2](PutMem2) procedure diff --git a/docs/Reference/Modules/HiddenModule/GetMem4.md b/docs/Reference/Modules/HiddenModule/GetMem4.md new file mode 100644 index 0000000..51dcc22 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetMem4.md @@ -0,0 +1,24 @@ +--- +title: GetMem4 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetMem4 +--- +# GetMem4 +{: .no_toc } + +Reads four bytes from a memory address into a **Long** variable. + +Syntax: **GetMem4** *Address* **,** *retVal* + +*Address* +: *required* **LongPtr**. The address to read from. + +*retVal* +: *required* **Long**. The variable to receive the value read from *Address*. + +The bytes are interpreted in the host's native byte order — little-endian on x86 and x64. The address is read directly with no bounds or alignment check. + +### See Also + +- [GetMem1](GetMem1), [GetMem2](GetMem2), [GetMem8](GetMem8), [GetMemPtr](GetMemPtr) procedures +- [PutMem4](PutMem4) procedure diff --git a/docs/Reference/Modules/HiddenModule/GetMem8.md b/docs/Reference/Modules/HiddenModule/GetMem8.md new file mode 100644 index 0000000..a0d303b --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetMem8.md @@ -0,0 +1,26 @@ +--- +title: GetMem8 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetMem8 +--- +# GetMem8 +{: .no_toc } + +Reads eight bytes from a memory address into a **Currency** variable. + +Syntax: **GetMem8** *Address* **,** *retVal* + +*Address* +: *required* **LongPtr**. The address to read from. + +*retVal* +: *required* **Currency**. The variable to receive the bytes read from *Address*. + +**Currency** is the convenient eight-byte signed-integer carrier used by these primitives because of its in-memory representation; the resulting bits are the raw 64-bit pattern stored at *Address*, scaled by the **Currency** type's fixed factor of 10000 only at the point of arithmetic. To work with the bits as an unscaled 64-bit integer, [**LSet**](../../Core/LSet) the **Currency** value into a **LongLong** variable. + +The address is read directly with no bounds or alignment check. + +### See Also + +- [GetMem1](GetMem1), [GetMem2](GetMem2), [GetMem4](GetMem4), [GetMemPtr](GetMemPtr) procedures +- [PutMem8](PutMem8) procedure diff --git a/docs/Reference/Modules/HiddenModule/GetMemPtr.md b/docs/Reference/Modules/HiddenModule/GetMemPtr.md new file mode 100644 index 0000000..45dafdb --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetMemPtr.md @@ -0,0 +1,34 @@ +--- +title: GetMemPtr +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetMemPtr +--- +# GetMemPtr +{: .no_toc } + +Reads a pointer-sized value from a memory address into a **LongPtr** variable. + +Syntax: **GetMemPtr** *Address* **,** *retVal* + +*Address* +: *required* **LongPtr**. The address to read from. + +*retVal* +: *required* **LongPtr**. The variable to receive the pointer-sized value read from *Address*. + +The number of bytes read matches the host's pointer width — four bytes in 32-bit builds, eight bytes in 64-bit builds. The bytes are interpreted in the host's native byte order. The address is read directly with no bounds or alignment check. + +### Example + +```tb +' Read the IUnknown vtable pointer of a Collection instance. +Dim c As Collection = New Collection +Dim vtbl As LongPtr +GetMemPtr ObjPtr(c), vtbl +Debug.Print "vtable at "; Hex(vtbl) +``` + +### See Also + +- [GetMem1](GetMem1), [GetMem2](GetMem2), [GetMem4](GetMem4), [GetMem8](GetMem8) procedures +- [PutMemPtr](PutMemPtr) procedure diff --git a/docs/Reference/Modules/HiddenModule/GetShortcutTextByEnum.md b/docs/Reference/Modules/HiddenModule/GetShortcutTextByEnum.md new file mode 100644 index 0000000..ee9682b --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/GetShortcutTextByEnum.md @@ -0,0 +1,20 @@ +--- +title: GetShortcutTextByEnum +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/GetShortcutTextByEnum +--- +# GetShortcutTextByEnum +{: .no_toc } + +Returns the localised display text for a built-in keyboard shortcut, given its enumeration ID. + +Syntax: **GetShortcutTextByEnum(** *ShortcutEnumId* **)** **As String** + +*ShortcutEnumId* +: *required* **Long**. The numeric identifier of the shortcut, as used by the **Shortcut** property of menu and toolbar items. + +The returned string is the user-facing label for the shortcut — e.g. `"Ctrl+S"`, `"Ctrl+Shift+P"`, `"F5"` — formatted in the system UI language. Returns an empty string for an unknown identifier. + +### See Also + +- [RuntimeCreateGetMessageHook](RuntimeCreateGetMessageHook) function diff --git a/docs/Reference/Modules/HiddenModule/Input.md b/docs/Reference/Modules/HiddenModule/Input.md new file mode 100644 index 0000000..5a83919 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/Input.md @@ -0,0 +1,50 @@ +--- +title: Input, Input$ +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/Input +--- +# Input, Input$ +{: .no_toc } + +Returns a fixed number of characters read from a file opened in **Input** or **Binary** mode. + +Syntax: +- **Input(** *Number* **,** [ **#** ] *FileNumber* **)** — returns a **Variant**. +- **Input$(** *Number* **,** [ **#** ] *FileNumber* **)** — returns a **String**. + +*Number* +: *required* The number of characters to return. + +*FileNumber* +: *required* The file number used to open the file with the [**Open**](../../Core/Open) statement. + +Data read with **Input** is usually written to a file with **Print #** or **[Put](../../Core/Put)**. Use this function only with files opened in **Input** or **Binary** mode. + +Unlike the **Input #** statement, the **Input** function returns all the characters it reads, including commas, carriage returns, linefeeds, quotation marks, and leading spaces. + +For files opened for **Binary** access, an attempt to read through the file using **Input** until [**EOF**](../FileSystem/EOF) returns **True** generates an error. Use [**LOF**](../FileSystem/LOF) and [**Loc**](../FileSystem/Loc) instead of **EOF** when reading binary files with **Input**, or use **[Get](../../Core/Get)** when **EOF** is needed. + +> [!NOTE] +> Use [**InputB**](InputB) for byte data contained within text files. With **InputB**, *Number* specifies the number of bytes to return rather than the number of characters. + +### Example + +This example uses the **Input** function to read one character at a time from a file and print it to the immediate window. *TESTFILE* is assumed to be a text file with a few lines of sample data. + +```tb +Dim MyChar As Variant +Open "TESTFILE" For Input As #1 ' Open file. +Do While Not EOF(1) ' Loop until end of file. + MyChar = Input(1, #1) ' Get one character. + Debug.Print MyChar ' Print to the immediate window. +Loop +Close #1 ' Close file. +``` + +### See Also + +- [InputB, InputB$](InputB) functions +- [Open](../../Core/Open) statement +- [EOF](../FileSystem/EOF), [LOF](../FileSystem/LOF), [Loc](../FileSystem/Loc) functions + +{% include VBA-Attribution.md %} diff --git a/docs/Reference/Modules/HiddenModule/InputB.md b/docs/Reference/Modules/HiddenModule/InputB.md new file mode 100644 index 0000000..0548215 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/InputB.md @@ -0,0 +1,40 @@ +--- +title: InputB, InputB$ +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/InputB +--- +# InputB, InputB$ +{: .no_toc } + +Returns a fixed number of bytes read from a file opened in **Input** or **Binary** mode. + +Syntax: +- **InputB(** *Number* **,** [ **#** ] *FileNumber* **)** — returns a **Variant**. +- **InputB$(** *Number* **,** [ **#** ] *FileNumber* **)** — returns a **String** whose underlying bytes are the bytes that were read. + +*Number* +: *required* The number of bytes to return. + +*FileNumber* +: *required* The file number used to open the file with the [**Open**](../../Core/Open) statement. + +**InputB** is the byte-oriented counterpart of [**Input**](Input). Where **Input** counts and returns characters (two bytes per character in twinBASIC's UTF-16 buffer), **InputB** counts and returns raw bytes — useful when reading binary data through a textually-opened channel. + +The bytes are packed into the result without any character-set translation; the **String** form simply reinterprets the byte run as a UTF-16 string for storage. + +### Example + +```tb +Dim Bytes As Variant +Open "data.bin" For Binary Access Read As #1 +Bytes = InputB(LOF(1), 1) ' Read the whole file as bytes. +Close #1 +``` + +### See Also + +- [Input, Input$](Input) functions +- [Open](../../Core/Open) statement +- [LOF](../FileSystem/LOF) function + +{% include VBA-Attribution.md %} diff --git a/docs/Reference/Modules/HiddenModule/InterlockedCompareExchange32.md b/docs/Reference/Modules/HiddenModule/InterlockedCompareExchange32.md new file mode 100644 index 0000000..71a1ff9 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/InterlockedCompareExchange32.md @@ -0,0 +1,28 @@ +--- +title: InterlockedCompareExchange32 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/InterlockedCompareExchange32 +--- +# InterlockedCompareExchange32 +{: .no_toc } + +Atomically compares a 32-bit value at a memory location with a comparand and replaces it with a new value if they match. Returns the original value either way. + +Syntax: **InterlockedCompareExchange32(** *Target* **,** *NewValue* **,** *OldValueCompare* **)** **As Long** + +*Target* +: *required* **Long**. The 32-bit variable to update, passed by reference. + +*NewValue* +: *required* **Long**. The value to write into *Target* if the compare succeeds. + +*OldValueCompare* +: *required* **Long**. The expected current value of *Target*. + +The compare-and-swap happens as one atomic operation. The return value is the value that was in *Target* at the start of the call — equal to *OldValueCompare* on success, anything else on failure (in which case *Target* is left unchanged). Wraps the Win32 `InterlockedCompareExchange` intrinsic. + +### See Also + +- [InterlockedCompareExchange64](InterlockedCompareExchange64) function +- [InterlockedCompareExchangePointer](InterlockedCompareExchangePointer) function +- [InterlockedIncrement32](InterlockedIncrement32), [InterlockedDecrement32](InterlockedDecrement32) functions diff --git a/docs/Reference/Modules/HiddenModule/InterlockedCompareExchange64.md b/docs/Reference/Modules/HiddenModule/InterlockedCompareExchange64.md new file mode 100644 index 0000000..841a5ac --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/InterlockedCompareExchange64.md @@ -0,0 +1,27 @@ +--- +title: InterlockedCompareExchange64 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/InterlockedCompareExchange64 +--- +# InterlockedCompareExchange64 +{: .no_toc } + +Atomically compares a 64-bit value at a memory location with a comparand and replaces it with a new value if they match. Returns the original value either way. + +Syntax: **InterlockedCompareExchange64(** *Target* **,** *NewValue* **,** *OldValueCompare* **)** **As LongLong** + +*Target* +: *required* **LongLong**. The 64-bit variable to update, passed by reference. + +*NewValue* +: *required* **LongLong**. The value to write into *Target* if the compare succeeds. + +*OldValueCompare* +: *required* **LongLong**. The expected current value of *Target*. + +The compare-and-swap happens as one atomic operation. The return value is the value that was in *Target* at the start of the call — equal to *OldValueCompare* on success, anything else on failure (in which case *Target* is left unchanged). Wraps the Win32 `InterlockedCompareExchange64` intrinsic. + +### See Also + +- [InterlockedCompareExchange32](InterlockedCompareExchange32) function +- [InterlockedCompareExchangePointer](InterlockedCompareExchangePointer) function diff --git a/docs/Reference/Modules/HiddenModule/InterlockedCompareExchangePointer.md b/docs/Reference/Modules/HiddenModule/InterlockedCompareExchangePointer.md new file mode 100644 index 0000000..eb3e40e --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/InterlockedCompareExchangePointer.md @@ -0,0 +1,38 @@ +--- +title: InterlockedCompareExchangePointer +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/InterlockedCompareExchangePointer +--- +# InterlockedCompareExchangePointer +{: .no_toc } + +Atomically compares a pointer-sized value at a memory location with a comparand and replaces it with a new value if they match. Returns the original value either way. + +Syntax: **InterlockedCompareExchangePointer(** *Target* **,** *NewValue* **,** *OldValueCompare* **)** **As LongPtr** + +*Target* +: *required* **LongPtr**. The pointer-sized variable to update, passed by reference. + +*NewValue* +: *required* **LongPtr**. The value to write into *Target* if the compare succeeds. + +*OldValueCompare* +: *required* **LongPtr**. The expected current value of *Target*. + +The compare-and-swap happens as one atomic operation. The return value is the value that was in *Target* at the start of the call — equal to *OldValueCompare* on success, anything else on failure (in which case *Target* is left unchanged). Wraps the Win32 `InterlockedCompareExchangePointer` intrinsic. + +### Example + +```tb +' Atomically claim ownership of a slot. +Dim Slot As LongPtr = 0 +Dim NewObj As LongPtr = ObjPtr(New Collection) +If InterlockedCompareExchangePointer(Slot, NewObj, 0) = 0 Then + ' Won the race — Slot now holds NewObj. +End If +``` + +### See Also + +- [InterlockedExchangePointer](InterlockedExchangePointer) function +- [InterlockedCompareExchange32](InterlockedCompareExchange32), [InterlockedCompareExchange64](InterlockedCompareExchange64) functions diff --git a/docs/Reference/Modules/HiddenModule/InterlockedDecrement32.md b/docs/Reference/Modules/HiddenModule/InterlockedDecrement32.md new file mode 100644 index 0000000..4dc1d0d --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/InterlockedDecrement32.md @@ -0,0 +1,21 @@ +--- +title: InterlockedDecrement32 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/InterlockedDecrement32 +--- +# InterlockedDecrement32 +{: .no_toc } + +Atomically decrements a 32-bit value by one and returns the new value. + +Syntax: **InterlockedDecrement32(** *Target* **)** **As Long** + +*Target* +: *required* **Long**. The 32-bit variable to decrement, passed by reference. + +The read, subtract, and write happen as one atomic operation. The return value is the post-decrement value of *Target* — testing against zero is the canonical way to spot the last release of a refcounted resource. Wraps the Win32 `InterlockedDecrement` intrinsic. + +### See Also + +- [InterlockedIncrement32](InterlockedIncrement32) function +- [InterlockedCompareExchange32](InterlockedCompareExchange32) function diff --git a/docs/Reference/Modules/HiddenModule/InterlockedExchangePointer.md b/docs/Reference/Modules/HiddenModule/InterlockedExchangePointer.md new file mode 100644 index 0000000..5cf8903 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/InterlockedExchangePointer.md @@ -0,0 +1,24 @@ +--- +title: InterlockedExchangePointer +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/InterlockedExchangePointer +--- +# InterlockedExchangePointer +{: .no_toc } + +Atomically exchanges a pointer-sized value at a memory location and returns the previous value. + +Syntax: **InterlockedExchangePointer(** *Target* **,** *NewValue* **)** **As LongPtr** + +*Target* +: *required* **LongPtr**. The pointer-sized variable to update, passed by reference. + +*NewValue* +: *required* **LongPtr**. The new value to store at *Target*. + +The store and the read of the prior value happen as a single atomic operation, observable by other threads as either fully-before or fully-after the call. Wraps the Win32 `InterlockedExchangePointer` intrinsic. + +### See Also + +- [InterlockedCompareExchangePointer](InterlockedCompareExchangePointer) function +- [InterlockedCompareExchange32](InterlockedCompareExchange32), [InterlockedCompareExchange64](InterlockedCompareExchange64) functions diff --git a/docs/Reference/Modules/HiddenModule/InterlockedIncrement32.md b/docs/Reference/Modules/HiddenModule/InterlockedIncrement32.md new file mode 100644 index 0000000..dd5ba5e --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/InterlockedIncrement32.md @@ -0,0 +1,21 @@ +--- +title: InterlockedIncrement32 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/InterlockedIncrement32 +--- +# InterlockedIncrement32 +{: .no_toc } + +Atomically increments a 32-bit value by one and returns the new value. + +Syntax: **InterlockedIncrement32(** *Target* **)** **As Long** + +*Target* +: *required* **Long**. The 32-bit variable to increment, passed by reference. + +The read, add, and write happen as one atomic operation. The return value is the post-increment value of *Target*. Wraps the Win32 `InterlockedIncrement` intrinsic. + +### See Also + +- [InterlockedDecrement32](InterlockedDecrement32) function +- [InterlockedCompareExchange32](InterlockedCompareExchange32) function diff --git a/docs/Reference/Modules/HiddenModule/ObjPtr.md b/docs/Reference/Modules/HiddenModule/ObjPtr.md new file mode 100644 index 0000000..b70dcfe --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/ObjPtr.md @@ -0,0 +1,36 @@ +--- +title: ObjPtr +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/ObjPtr +--- +# ObjPtr +{: .no_toc } + +Returns the COM-identity address of an object as a **LongPtr**. + +Syntax: **ObjPtr(** *Object* **)** + +*Object* +: *required* The object reference whose pointer is to be obtained. The argument is taken as **IUnknown**. + +The returned value is the address of the object's **IUnknown** vtable — the same value the COM runtime uses to test object identity. Two **Object** variables refer to the same instance if and only if their **ObjPtr** values are equal. + +The pointer is valid only as long as the underlying object stays alive; nothing about taking **ObjPtr** holds a reference. Pass the result to API functions that need a raw object address, or stash it for an identity check, but do not assume it remains meaningful after the last reference is released. + +### Example + +```tb +Dim a As Collection +Dim b As Collection +Set a = New Collection +Set b = a +Debug.Print ObjPtr(a) = ObjPtr(b) ' True — same instance. + +Set b = New Collection +Debug.Print ObjPtr(a) = ObjPtr(b) ' False — different instances. +``` + +### See Also + +- [StrPtr](StrPtr) function +- [VarPtr](VarPtr) function diff --git a/docs/Reference/Modules/HiddenModule/PictureToByteArray.md b/docs/Reference/Modules/HiddenModule/PictureToByteArray.md new file mode 100644 index 0000000..fe841f9 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/PictureToByteArray.md @@ -0,0 +1,30 @@ +--- +title: PictureToByteArray +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/PictureToByteArray +--- +# PictureToByteArray +{: .no_toc } + +Serialises an **IPicture** into a **Byte** array. + +Syntax: **PictureToByteArray(** *Picture* **)** **As Variant** + +*Picture* +: *required* **IUnknown**. The picture to serialise — an **stdole.StdPicture**, or any object that implements **IPicture** / **IPictureDisp**. + +The result is a **Variant** wrapping a `Byte()` array containing the bytes the picture would write to a stream via **IPersistStream**. The companion deserialiser is the global **LoadPicture**, which accepts a byte array as input and returns a fresh picture. + +Returns an empty array if *Picture* is **Nothing**. + +### Example + +```tb +Dim Bytes As Variant = PictureToByteArray(Picture1.Picture) +Set Picture2.Picture = LoadPicture(Bytes) +``` + +### See Also + +- [CreateStdPictureFromHandle](CreateStdPictureFromHandle) function +- [ConvertIconToBitmap](ConvertIconToBitmap) function diff --git a/docs/Reference/Modules/HiddenModule/PutMem1.md b/docs/Reference/Modules/HiddenModule/PutMem1.md new file mode 100644 index 0000000..5d1089d --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/PutMem1.md @@ -0,0 +1,24 @@ +--- +title: PutMem1 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/PutMem1 +--- +# PutMem1 +{: .no_toc } + +Writes one byte to a memory address. + +Syntax: **PutMem1** *Address* **,** *Value* + +*Address* +: *required* **LongPtr**. The address to write to. + +*Value* +: *required* **Byte**. The byte to store at *Address*. + +The address is written directly with no bounds or alignment check. Writing to an address that does not belong to the process, or one that points into read-only memory, will crash the host. + +### See Also + +- [PutMem2](PutMem2), [PutMem4](PutMem4), [PutMem8](PutMem8), [PutMemPtr](PutMemPtr) procedures +- [GetMem1](GetMem1) procedure diff --git a/docs/Reference/Modules/HiddenModule/PutMem2.md b/docs/Reference/Modules/HiddenModule/PutMem2.md new file mode 100644 index 0000000..68300bf --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/PutMem2.md @@ -0,0 +1,24 @@ +--- +title: PutMem2 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/PutMem2 +--- +# PutMem2 +{: .no_toc } + +Writes two bytes to a memory address. + +Syntax: **PutMem2** *Address* **,** *Value* + +*Address* +: *required* **LongPtr**. The address to write to. + +*Value* +: *required* **Integer**. The 16-bit value to store at *Address*. + +The bytes are written in the host's native byte order — little-endian on x86 and x64. The address is written directly with no bounds or alignment check. + +### See Also + +- [PutMem1](PutMem1), [PutMem4](PutMem4), [PutMem8](PutMem8), [PutMemPtr](PutMemPtr) procedures +- [GetMem2](GetMem2) procedure diff --git a/docs/Reference/Modules/HiddenModule/PutMem4.md b/docs/Reference/Modules/HiddenModule/PutMem4.md new file mode 100644 index 0000000..b489281 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/PutMem4.md @@ -0,0 +1,24 @@ +--- +title: PutMem4 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/PutMem4 +--- +# PutMem4 +{: .no_toc } + +Writes four bytes to a memory address. + +Syntax: **PutMem4** *Address* **,** *Value* + +*Address* +: *required* **LongPtr**. The address to write to. + +*Value* +: *required* **Long**. The 32-bit value to store at *Address*. + +The bytes are written in the host's native byte order — little-endian on x86 and x64. The address is written directly with no bounds or alignment check. + +### See Also + +- [PutMem1](PutMem1), [PutMem2](PutMem2), [PutMem8](PutMem8), [PutMemPtr](PutMemPtr) procedures +- [GetMem4](GetMem4) procedure diff --git a/docs/Reference/Modules/HiddenModule/PutMem8.md b/docs/Reference/Modules/HiddenModule/PutMem8.md new file mode 100644 index 0000000..9b9d9fe --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/PutMem8.md @@ -0,0 +1,26 @@ +--- +title: PutMem8 +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/PutMem8 +--- +# PutMem8 +{: .no_toc } + +Writes eight bytes to a memory address. + +Syntax: **PutMem8** *Address* **,** *Value* + +*Address* +: *required* **LongPtr**. The address to write to. + +*Value* +: *required* **Currency**. A **Currency** carrier whose underlying eight bytes are stored at *Address*. + +**Currency** is used as the eight-byte carrier — its in-memory representation is a raw 64-bit pattern, scaled by the type's fixed factor of 10000 only at the point of arithmetic. To pack an arbitrary 64-bit integer, [**LSet**](../../Core/LSet) it into a **Currency** before calling **PutMem8**. + +The address is written directly with no bounds or alignment check. + +### See Also + +- [PutMem1](PutMem1), [PutMem2](PutMem2), [PutMem4](PutMem4), [PutMemPtr](PutMemPtr) procedures +- [GetMem8](GetMem8) procedure diff --git a/docs/Reference/Modules/HiddenModule/PutMemPtr.md b/docs/Reference/Modules/HiddenModule/PutMemPtr.md new file mode 100644 index 0000000..bb6295f --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/PutMemPtr.md @@ -0,0 +1,24 @@ +--- +title: PutMemPtr +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/PutMemPtr +--- +# PutMemPtr +{: .no_toc } + +Writes a pointer-sized value to a memory address. + +Syntax: **PutMemPtr** *Address* **,** *Value* + +*Address* +: *required* **LongPtr**. The address to write to. + +*Value* +: *required* **LongPtr**. The pointer-sized value to store at *Address*. + +The number of bytes written matches the host's pointer width — four bytes in 32-bit builds, eight bytes in 64-bit builds. The bytes are written in the host's native byte order. The address is written directly with no bounds or alignment check. + +### See Also + +- [PutMem1](PutMem1), [PutMem2](PutMem2), [PutMem4](PutMem4), [PutMem8](PutMem8) procedures +- [GetMemPtr](GetMemPtr) procedure diff --git a/docs/Reference/Modules/HiddenModule/RegisterMessage.md b/docs/Reference/Modules/HiddenModule/RegisterMessage.md new file mode 100644 index 0000000..94800ee --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/RegisterMessage.md @@ -0,0 +1,48 @@ +--- +title: RegisterMessage +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/RegisterMessage +--- +# RegisterMessage +{: .no_toc } + +Subscribes a callback to a single Windows message type for a chosen window and descendant scope. + +Syntax: *hook*.**RegisterMessage** *ParentHWND* **,** *Mode* **,** *MessageType* **,** *Callback* + +*hook* +: *required* An [**IGetMessageHook**](./#igetmessagehook-interface) instance, typically returned by [**RuntimeCreateGetMessageHook**](RuntimeCreateGetMessageHook). + +*ParentHWND* +: *required* **LongPtr**. The window the subscription anchors on. + +*Mode* +: *required* [**EnumDescendantsModeFlags**](./#enumdescendantsmodeflags). The descendant scope: only the exact window, all descendants, or only direct children. + +*MessageType* +: *required* **Integer**. The Windows `WM_*` message identifier to subscribe to. Each call subscribes to one type; call **RegisterMessage** repeatedly to listen for several. + +*Callback* +: *required* [**GetMessageHookHelper.GetMessageHandler**](./#getmessagehandler). The function that receives matching messages. Pass `AddressOf` a function with the matching signature. + +The subscription is recorded but does not start firing until [**Start**](Start) is called on the hook. Existing subscriptions are not disturbed by adding new ones. + +### Example + +```tb +Const WM_KEYDOWN = &H100 +Const WM_CHAR = &H102 + +Sub HookKeyboard(ByVal h As IGetMessageHook) + h.RegisterMessage Me.hWnd, AllDescendants, WM_KEYDOWN, AddressOf OnKeyDown + h.RegisterMessage Me.hWnd, AllDescendants, WM_CHAR, AddressOf OnChar + h.Start +End Sub +``` + +### See Also + +- [Start](Start) method +- [Stop](Stop) method +- [IGetMessageHook interface](./#igetmessagehook-interface) +- [GetMessageHookHelper module](./#getmessagehookhelper-module) diff --git a/docs/Reference/Modules/HiddenModule/RuntimeCreateGetMessageHook.md b/docs/Reference/Modules/HiddenModule/RuntimeCreateGetMessageHook.md new file mode 100644 index 0000000..3f8f832 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/RuntimeCreateGetMessageHook.md @@ -0,0 +1,31 @@ +--- +title: RuntimeCreateGetMessageHook +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/RuntimeCreateGetMessageHook +--- +# RuntimeCreateGetMessageHook +{: .no_toc } + +Creates a fresh [**IGetMessageHook**](./#igetmessagehook-interface) for filtering Windows messages destined for a chosen window and (optionally) its descendants. + +Syntax: **RuntimeCreateGetMessageHook()** **As IGetMessageHook** + +The returned hook starts dormant. Subscribe a callback for one or more message types with [**RegisterMessage**](RegisterMessage), then call [**Start**](Start) to activate the subscriptions and [**Stop**](Stop) to remove them. + +### Example + +```tb +Const WM_LBUTTONDOWN = &H201 + +Sub HookClicks() + Dim Hook As IGetMessageHook = RuntimeCreateGetMessageHook() + Hook.RegisterMessage Me.hWnd, AllDescendants, _ + WM_LBUTTONDOWN, AddressOf OnLButtonDown + Hook.Start +End Sub +``` + +### See Also + +- [IGetMessageHook interface](./#igetmessagehook-interface) +- [GetMessageHookHelper module](./#getmessagehookhelper-module) diff --git a/docs/Reference/Modules/HiddenModule/SetThreadGlobalErrorTrap.md b/docs/Reference/Modules/HiddenModule/SetThreadGlobalErrorTrap.md new file mode 100644 index 0000000..4cf8af3 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/SetThreadGlobalErrorTrap.md @@ -0,0 +1,23 @@ +--- +title: SetThreadGlobalErrorTrap +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/SetThreadGlobalErrorTrap +--- +# SetThreadGlobalErrorTrap +{: .no_toc } + +Registers a global callback that fires when an unhandled run-time error is raised on the calling thread. + +Syntax: **SetThreadGlobalErrorTrap** *CallbackAddress* + +*CallbackAddress* +: *required* **LongPtr**. The address of a callback procedure, typically obtained with **AddressOf**. Pass `0` to clear the trap. + +The trap supplements ordinary `On Error` handling: it sees errors that escape the active error handler chain on the thread that registered it, and is called before the runtime decides what to do next (display the unhandled-error dialog, end the program, etc.). Useful for wiring up application-wide logging or crash reporting. + +Only one trap is active per thread; setting a new one replaces the previous. + +### See Also + +- [On Error](../../Core/On-Error) statement +- [Err object](../ErrObject/) diff --git a/docs/Reference/Modules/HiddenModule/StackArgsSize.md b/docs/Reference/Modules/HiddenModule/StackArgsSize.md new file mode 100644 index 0000000..2a635e4 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/StackArgsSize.md @@ -0,0 +1,19 @@ +--- +title: StackArgsSize +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/StackArgsSize +--- +# StackArgsSize +{: .no_toc } + +Returns the total size, in bytes, of the arguments passed on the stack of the enclosing procedure. + +Syntax: **StackArgsSize()** **As Long** + +The result is resolved at compile time and folded into the generated code as a numeric constant. Used inside a **Naked** procedure when the assembly needs to know how much to clean off the stack on return — for example, to issue the right `ret n` opcode under the `_stdcall` convention. + +### See Also + +- [StackOffset](StackOffset) function +- [Emit](Emit), [EmitAny](EmitAny) procedures +- [Direct Assembly Insertion](../../../Features/Advanced/Assembly) diff --git a/docs/Reference/Modules/HiddenModule/StackOffset.md b/docs/Reference/Modules/HiddenModule/StackOffset.md new file mode 100644 index 0000000..0a5f74d --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/StackOffset.md @@ -0,0 +1,22 @@ +--- +title: StackOffset +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/StackOffset +--- +# StackOffset +{: .no_toc } + +Returns the stack-frame offset of a variable. + +Syntax: **StackOffset(** *Variable* **)** **As Long** + +*Variable* +: *required* A local variable, argument, or other stack-resident reference. The value passed is taken **As Any** so the call works for any type. + +The result is the offset, in bytes, from the procedure's stack frame base to the storage of *Variable*. Typically used inside a **Naked** procedure to compute addresses for inline assembly emitted with [**Emit**](Emit) or [**EmitAny**](EmitAny). The offset is resolved at compile time and folded in as a numeric constant. + +### See Also + +- [StackArgsSize](StackArgsSize) function +- [Emit](Emit), [EmitAny](EmitAny) procedures +- [Direct Assembly Insertion](../../../Features/Advanced/Assembly) diff --git a/docs/Reference/Modules/HiddenModule/Start.md b/docs/Reference/Modules/HiddenModule/Start.md new file mode 100644 index 0000000..18f3e6f --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/Start.md @@ -0,0 +1,22 @@ +--- +title: Start +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/Start +--- +# Start +{: .no_toc } + +Activates every registered subscription on a message hook so that matching messages start being forwarded to their callbacks. + +Syntax: *hook*.**Start** + +*hook* +: *required* An [**IGetMessageHook**](./#igetmessagehook-interface) instance whose subscriptions have been set up with [**RegisterMessage**](RegisterMessage). + +Calling **Start** on a hook that is already started has no effect. Calling it on a hook with no subscriptions is harmless but accomplishes nothing — register first, then start. + +### See Also + +- [RegisterMessage](RegisterMessage) method +- [Stop](Stop) method +- [IGetMessageHook interface](./#igetmessagehook-interface) diff --git a/docs/Reference/Modules/HiddenModule/Stop.md b/docs/Reference/Modules/HiddenModule/Stop.md new file mode 100644 index 0000000..b2c3990 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/Stop.md @@ -0,0 +1,25 @@ +--- +title: Stop (IGetMessageHook) +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/Stop +--- +# Stop +{: .no_toc } + +Deactivates every registered subscription on a message hook so that matching messages are no longer forwarded to their callbacks. + +Syntax: *hook*.**Stop** + +*hook* +: *required* An [**IGetMessageHook**](./#igetmessagehook-interface) instance. + +Subscriptions remain registered after **Stop** — call [**Start**](Start) again to resume delivery without re-registering. Calling **Stop** on a hook that is already stopped has no effect. + +> [!NOTE] +> This is the **Stop** method of the [**IGetMessageHook**](./#igetmessagehook-interface) interface. The unrelated [**Stop**](../../Core/Stop) statement is a language keyword that suspends execution and breaks into the debugger. + +### See Also + +- [Start](Start) method +- [RegisterMessage](RegisterMessage) method +- [Stop](../../Core/Stop) statement (the language keyword) diff --git a/docs/Reference/Modules/HiddenModule/StrPtr.md b/docs/Reference/Modules/HiddenModule/StrPtr.md new file mode 100644 index 0000000..70d4612 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/StrPtr.md @@ -0,0 +1,38 @@ +--- +title: StrPtr +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/StrPtr +--- +# StrPtr +{: .no_toc } + +Returns the address of the underlying buffer of a **String** as a **LongPtr**. + +Syntax: **StrPtr(** *String* **)** + +*String* +: *required* The **String** whose buffer address is wanted. + +twinBASIC stores a **String** as a Unicode (UTF-16) BSTR — a length-prefixed buffer that **StrPtr** returns the start of. The returned value points at the first character, not at the four-byte length prefix that precedes it. + +If *String* is **vbNullString** the result is zero. For an empty string `""`, the result is the address of a valid (but zero-length) buffer; passing it to an API that distinguishes a null pointer from an empty string is the usual reason to prefer **vbNullString** over `""` in declarations. + +The pointer is valid only as long as the **String** variable stays alive and is not reassigned. Treat it as a borrow, not as ownership. + +### Example + +```tb +Dim s As String +s = "Hello" +Debug.Print StrPtr(s) ' e.g. 1234567890 — varies per run + +Dim ch As Integer +GetMem2 StrPtr(s), ch +Debug.Print Chr$(ch) ' "H" +``` + +### See Also + +- [ObjPtr](ObjPtr) function +- [VarPtr](VarPtr) function +- [vbNullString](../Constants/#vbNullString) diff --git a/docs/Reference/Modules/HiddenModule/UnprotectedAccess.md b/docs/Reference/Modules/HiddenModule/UnprotectedAccess.md new file mode 100644 index 0000000..99c83ae --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/UnprotectedAccess.md @@ -0,0 +1,23 @@ +--- +title: UnprotectedAccess +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/UnprotectedAccess +--- +# UnprotectedAccess +{: .no_toc } + +Returns a reference to a value that bypasses the usual access checks on private members. + +Syntax: **UnprotectedAccess(** *Variable* **)** **As Object** + +*Variable* +: *required* The value to wrap. The value passed is taken **As Any** so the call works for any type. + +The returned object exposes *Variable*'s members — including **Private** and **Friend** ones — without triggering the access enforcement that the compiler ordinarily applies. Useful for testing, serialization, and other reflection-style scenarios that legitimately need to reach inside an encapsulation boundary. + +> [!WARNING] +> Use this function sparingly. Bypassing access protection makes the surrounding code coupled to the target type's private layout, which is by definition not a stable API. + +### See Also + +- [GetDeclaredTypeIid](GetDeclaredTypeIid) function diff --git a/docs/Reference/Modules/HiddenModule/VarPtr.md b/docs/Reference/Modules/HiddenModule/VarPtr.md new file mode 100644 index 0000000..a42f6a6 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/VarPtr.md @@ -0,0 +1,34 @@ +--- +title: VarPtr +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/VarPtr +--- +# VarPtr +{: .no_toc } + +Returns the address of a variable as a **LongPtr**. + +Syntax: **VarPtr(** *Var* **)** + +*Var* +: *required* The variable whose pointer is to be obtained. Any type is accepted. + +The returned address is the storage location of *Var* itself — the same place the runtime would write to for an assignment. For a numeric or fixed-length type the value of the variable lives at that address; for a **String** or **Variant** the value at the address is the variable's BSTR pointer or **VARIANT** descriptor. + +Pass the result to an API function that needs a raw address, or hand it to one of the [**GetMem*** / **PutMem***](../HiddenModule/) helpers to read or write the underlying bytes. The pointer is valid only for as long as *Var* is alive in its scope; locals, arguments, and elements of expanded arrays can move when their owning frame or array is reallocated. + +### Example + +```tb +Dim n As Long +n = &H12345678 + +Dim Bytes(0 To 3) As Byte +vbaCopyBytes 4, VarPtr(Bytes(0)), VarPtr(n) +Debug.Print Hex(Bytes(0)) ' "78" — little-endian +``` + +### See Also + +- [ObjPtr](ObjPtr) function +- [StrPtr](StrPtr) function diff --git a/docs/Reference/Modules/HiddenModule/Width.md b/docs/Reference/Modules/HiddenModule/Width.md new file mode 100644 index 0000000..1626fb6 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/Width.md @@ -0,0 +1,40 @@ +--- +title: Width +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/Width +redirect_from: +- /tB/Core/Width +--- +# Width # +{: .no_toc } + +Assigns an output line width to a file opened by the [**Open**](../../Core/Open) statement. + +Syntax: **Width #** *FileNumber* **,** *Width* + +*FileNumber* +: *required* The file number used to open the file. + +*Width* +: *required* A numeric expression in the range 0–255, inclusive, indicating how many characters appear on a line before a new line is started. If *Width* equals `0`, there is no limit to the length of a line. The default is `0`. + +### Example + +This example sets the output line width to 5 — five characters are written per line before the channel wraps. + +```tb +Dim I As Long +Open "TESTFILE" For Output As #1 ' Open file for output. +Width #1, 5 ' Set output line width to 5. +For I = 0 To 9 ' Loop 10 times. + Print #1, Chr(48 + I); ' Prints five characters per line. +Next I +Close #1 ' Close file. +``` + +### See Also + +- [Open](../../Core/Open) statement +- [Print #](../../Core/Print) statement + +{% include VBA-Attribution.md %} diff --git a/docs/Reference/Modules/HiddenModule/vbaAryMove.md b/docs/Reference/Modules/HiddenModule/vbaAryMove.md new file mode 100644 index 0000000..892b2ee --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/vbaAryMove.md @@ -0,0 +1,26 @@ +--- +title: vbaAryMove +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/vbaAryMove +--- +# vbaAryMove +{: .no_toc } + +Moves the contents of one array variable into another in O(1) time, leaving the source empty. + +Syntax: **vbaAryMove** *Dest* **,** *Source* + +*Dest* +: *required* An array variable that receives the contents of *Source*. Any prior contents are released first. + +*Source* +: *required* An array variable whose contents are transferred to *Dest*. After the call, *Source* is in the unallocated state. + +The **SAFEARRAY** descriptor pointer is moved without copying its elements — equivalent to a swap-and-release rather than an element-wise copy. Both arrays must have compatible element types. + +This is the building block for returning a freshly built array from a function without paying for a copy on the way out. + +### See Also + +- [vbaRefVarAry](vbaRefVarAry) function +- [vbaCopyBytes](vbaCopyBytes) function diff --git a/docs/Reference/Modules/HiddenModule/vbaCastObj.md b/docs/Reference/Modules/HiddenModule/vbaCastObj.md new file mode 100644 index 0000000..c0094ea --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/vbaCastObj.md @@ -0,0 +1,36 @@ +--- +title: vbaCastObj +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/vbaCastObj +--- +# vbaCastObj +{: .no_toc } + +Returns an object reinterpreted as another COM interface, given its IID, or **Nothing** if the object does not implement that interface. + +Syntax: **vbaCastObj(** *Obj* **,** *IID* **)** **As IUnknown** + +*Obj* +: *required* **stdole.IUnknown**. The object to cast. + +*IID* +: *required* **Any**. The interface ID to query for — accepted as a 16-byte **GUID** structure or as a **String** in registry format (`{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`). + +A direct wrapper over **IUnknown::QueryInterface**: the object is asked whether it implements the requested interface, and if so a reference to that interface is returned. If not, **Nothing** is returned. + +### Example + +```tb +Const IID_IPicture As String = "{7BF80980-BF32-101A-8BBB-00AA00300CAB}" + +Dim Pic As Object = LoadPicture("logo.bmp") +Dim AsPicture As IUnknown = vbaCastObj(Pic, IID_IPicture) +If Not AsPicture Is Nothing Then + ' Use AsPicture as an IPicture. +End If +``` + +### See Also + +- [ObjPtr](ObjPtr) function +- [CreateGUID](CreateGUID) function diff --git a/docs/Reference/Modules/HiddenModule/vbaCopyBytes.md b/docs/Reference/Modules/HiddenModule/vbaCopyBytes.md new file mode 100644 index 0000000..019e992 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/vbaCopyBytes.md @@ -0,0 +1,35 @@ +--- +title: vbaCopyBytes +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/vbaCopyBytes +--- +# vbaCopyBytes +{: .no_toc } + +Copies a block of bytes from one address to another. + +Syntax: **vbaCopyBytes(** *Length* **,** *Dest* **,** *Src* **)** **As LongPtr** + +*Length* +: *required* **Long**. The number of bytes to copy. + +*Dest* +: *required* **LongPtr**. The destination address. + +*Src* +: *required* **LongPtr**. The source address. + +The behaviour for overlapping ranges is unspecified — use a temporary buffer if the ranges may overlap. The return value is *Dest* (the same address that was passed in), provided as a convenience for chaining. + +### Example + +```tb +Dim src As String = "Hello" +Dim dst(0 To 9) As Byte +vbaCopyBytes 10, VarPtr(dst(0)), StrPtr(src) +``` + +### See Also + +- [vbaCopyBytesZero](vbaCopyBytesZero) function +- [GetMem4](GetMem4), [PutMem4](PutMem4) procedures diff --git a/docs/Reference/Modules/HiddenModule/vbaCopyBytesZero.md b/docs/Reference/Modules/HiddenModule/vbaCopyBytesZero.md new file mode 100644 index 0000000..d81169f --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/vbaCopyBytesZero.md @@ -0,0 +1,26 @@ +--- +title: vbaCopyBytesZero +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/vbaCopyBytesZero +--- +# vbaCopyBytesZero +{: .no_toc } + +Copies a block of bytes from one address to another, then zeroes the source bytes. + +Syntax: **vbaCopyBytesZero(** *Length* **,** *Dest* **,** *Src* **)** **As LongPtr** + +*Length* +: *required* **Long**. The number of bytes to copy. + +*Dest* +: *required* **LongPtr**. The destination address. + +*Src* +: *required* **LongPtr**. The source address. The *Length* bytes starting at *Src* are written with zero after the copy completes. + +Equivalent to a [**vbaCopyBytes**](vbaCopyBytes) followed by a memory clear of the source. Useful when moving an owning resource (a BSTR, an interface pointer) without leaving a duplicate behind. The return value is *Dest*. + +### See Also + +- [vbaCopyBytes](vbaCopyBytes) function diff --git a/docs/Reference/Modules/HiddenModule/vbaObjAddref.md b/docs/Reference/Modules/HiddenModule/vbaObjAddref.md new file mode 100644 index 0000000..a6b5a9b --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/vbaObjAddref.md @@ -0,0 +1,24 @@ +--- +title: vbaObjAddref +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/vbaObjAddref +--- +# vbaObjAddref +{: .no_toc } + +Calls **IUnknown::AddRef** on the COM object at a given address. + +Syntax: **vbaObjAddref** *Address* + +*Address* +: *required* **LongPtr**. The address of an **IUnknown**-derived COM object — typically the value returned by [**ObjPtr**](ObjPtr). + +The reference count of the object is incremented by one. The runtime does not validate that *Address* points at a real COM object; an invalid pointer will crash the host. + +This is a low-level primitive. Ordinary code does not need it — assigning to an **Object** variable already addrefs. + +### See Also + +- [vbaObjSet](vbaObjSet) function +- [vbaObjSetAddref](vbaObjSetAddref) function +- [ObjPtr](ObjPtr) function diff --git a/docs/Reference/Modules/HiddenModule/vbaObjSet.md b/docs/Reference/Modules/HiddenModule/vbaObjSet.md new file mode 100644 index 0000000..560d736 --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/vbaObjSet.md @@ -0,0 +1,27 @@ +--- +title: vbaObjSet +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/vbaObjSet +--- +# vbaObjSet +{: .no_toc } + +Assigns a raw object pointer to an **Object** variable, taking ownership of the existing reference without addrefing. + +Syntax: **vbaObjSet(** *DstObject* **,** *SrcObjPtr* **)** **As LongPtr** + +*DstObject* +: *required* **IUnknown**. The variable to receive the pointer. Any prior reference is released. + +*SrcObjPtr* +: *required* **LongPtr**. The pointer to the COM object that *DstObject* should refer to. The pointer's existing reference count is **not** incremented. + +This is the move-without-addref primitive — used to wrap a freshly-handed-out raw pointer (from a Win32 `IUnknown**` out-parameter, for example) into an **Object** variable without leaking a reference. + +The return value mirrors the assigned pointer. + +### See Also + +- [vbaObjSetAddref](vbaObjSetAddref) function — copy-with-addref counterpart +- [vbaObjAddref](vbaObjAddref) procedure +- [ObjPtr](ObjPtr) function diff --git a/docs/Reference/Modules/HiddenModule/vbaObjSetAddref.md b/docs/Reference/Modules/HiddenModule/vbaObjSetAddref.md new file mode 100644 index 0000000..58ccd0b --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/vbaObjSetAddref.md @@ -0,0 +1,27 @@ +--- +title: vbaObjSetAddref +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/vbaObjSetAddref +--- +# vbaObjSetAddref +{: .no_toc } + +Assigns a raw object pointer to an **Object** variable, addrefing the new pointer and releasing any prior reference. + +Syntax: **vbaObjSetAddref(** *DstObject* **,** *SrcObjPtr* **)** **As LongPtr** + +*DstObject* +: *required* **IUnknown**. The variable to receive the pointer. Any prior reference is released. + +*SrcObjPtr* +: *required* **LongPtr**. The pointer to the COM object that *DstObject* should refer to. **IUnknown::AddRef** is called on the pointer. + +This is the copy-with-addref primitive — equivalent to a regular `Set DstObject = obj` when *obj* is held only as a raw **LongPtr**. + +The return value mirrors the assigned pointer. + +### See Also + +- [vbaObjSet](vbaObjSet) function — move-without-addref counterpart +- [vbaObjAddref](vbaObjAddref) procedure +- [ObjPtr](ObjPtr) function diff --git a/docs/Reference/Modules/HiddenModule/vbaRefVarAry.md b/docs/Reference/Modules/HiddenModule/vbaRefVarAry.md new file mode 100644 index 0000000..446372f --- /dev/null +++ b/docs/Reference/Modules/HiddenModule/vbaRefVarAry.md @@ -0,0 +1,23 @@ +--- +title: vbaRefVarAry +parent: (Default) Module +permalink: /tB/Modules/HiddenModule/vbaRefVarAry +--- +# vbaRefVarAry +{: .no_toc } + +Returns a pointer to the **SAFEARRAY** descriptor stored inside a **Variant** array. + +Syntax: **vbaRefVarAry(** *Variant* **)** **As LongPtr** + +*Variant* +: *required* A **Variant** that contains an array, passed by reference. + +The returned address is the location of the **SAFEARRAY*** field inside the **Variant** — that is, the dereference yields the **SAFEARRAY** pointer that the **Variant** wraps. Useful when calling Win32 APIs that expect to receive or fill a **SAFEARRAY** through a `VARIANT*` argument. + +If *Variant* does not contain an array, the result is undefined. + +### See Also + +- [VarPtr](VarPtr) function +- [vbaAryMove](vbaAryMove) procedure diff --git a/docs/Reference/Procedures and Functions.md b/docs/Reference/Procedures and Functions.md index 7171ca9..e19076c 100644 --- a/docs/Reference/Procedures and Functions.md +++ b/docs/Reference/Procedures and Functions.md @@ -13,7 +13,9 @@ permalink: /Reference/Procedures-and-Functions ## A - [Abs](../tB/Modules/Math/Abs) -- returns the absolute value of a number +- [AllocMem](../tB/Modules/HiddenModule/AllocMem) -- allocates a block of native memory and returns its address - [AppActivate](../tB/Modules/Interaction/AppActivate) -- activates an application window +- [Array](../tB/Modules/HiddenModule/Array) -- creates a **Variant** array from a comma-separated list of values, or destructures one when used on the left of an assignment - [Asc, AscB, AscW](../tB/Modules/Strings/Asc) -- returns the character code of the first letter in a string - [Atn](../tB/Modules/Math/Atn) -- returns the arctangent of a number @@ -43,8 +45,11 @@ permalink: /Reference/Procedures-and-Functions - [CLngPtr](../tB/Modules/Conversion/CLngPtr) -- coerces an expression to a **LongPtr** - [Command$, Command](../tB/Modules/Interaction/Command) -- returns the command-line arguments passed to the program - [CompilerVersion](../tB/Modules/Compilation/CompilerVersion) -- returns the twinBASIC compiler version number +- [ConvertIconToBitmap](../tB/Modules/HiddenModule/ConvertIconToBitmap) -- converts an icon picture to a bitmap picture - [Cos](../tB/Modules/Math/Cos) -- returns the cosine of an angle +- [CreateGUID](../tB/Modules/HiddenModule/CreateGUID) -- generates a fresh GUID and returns it as a registry-formatted string - [CreateObject](../tB/Modules/Interaction/CreateObject) -- creates a new instance of a COM/Automation object +- [CreateStdPictureFromHandle](../tB/Modules/HiddenModule/CreateStdPictureFromHandle) -- wraps a GDI bitmap or icon handle in an **stdole.StdPicture** - [CSng](../tB/Modules/Conversion/CSng) -- coerces an expression to a **Single** - [CStr](../tB/Modules/Conversion/CStr) -- coerces an expression to a **String** - [CType](../tB/Modules/Conversion/CType) -- generic type conversion supporting the **CType(Of *type*)** cast operator @@ -73,11 +78,14 @@ permalink: /Reference/Procedures-and-Functions ## E +- [Emit](../tB/Modules/HiddenModule/Emit) -- injects custom **Byte** values into the codegen stream of the enclosing procedure +- [EmitAny](../tB/Modules/HiddenModule/EmitAny) -- injects custom typed values into the codegen stream of the enclosing procedure - [Environ$, Environ](../tB/Modules/Interaction/Environ) -- returns the value of a process environment variable - [EOF](../tB/Modules/FileSystem/EOF) -- returns whether the end of a file has been reached - [Erl](../tB/Modules/Information/Erl) -- returns the line number where the most recent run-time error occurred - [Err](../tB/Modules/Information/Err) -- returns the **ErrObject** describing the current run-time error state - [Error$, Error](../tB/Modules/Conversion/Error) -- returns the error message that corresponds to a given error number +- [Eval](../tB/Modules/HiddenModule/Eval) -- compiles and evaluates a twinBASIC expression supplied as a string - [Exp](../tB/Modules/Math/Exp) -- returns *e* (the base of natural logarithms) raised to a power ## F @@ -94,12 +102,18 @@ permalink: /Reference/Procedures-and-Functions - [FormatNumber](../tB/Modules/Strings/FormatNumber) -- formats an expression as a number - [FormatPercent](../tB/Modules/Strings/FormatPercent) -- formats an expression as a percentage - [FreeFile](../tB/Modules/FileSystem/FreeFile) -- returns the next file number available for use by the **Open** statement +- [FreeMem](../tB/Modules/HiddenModule/FreeMem) -- frees memory allocated with **AllocMem** - [FV](../tB/Modules/Financial/FV) -- returns the future value of an annuity based on periodic fixed payments and a fixed interest rate ## G - [GetAllSettings](../tB/Modules/Interaction/GetAllSettings) -- returns every key/value pair in a section of an application's registry entry - [GetAttr](../tB/Modules/FileSystem/GetAttr) -- returns the attributes of a file or directory +- [GetMem1](../tB/Modules/HiddenModule/GetMem1) -- reads one byte from a memory address into a **Byte** variable +- [GetMem2](../tB/Modules/HiddenModule/GetMem2) -- reads two bytes from a memory address into an **Integer** variable +- [GetMem4](../tB/Modules/HiddenModule/GetMem4) -- reads four bytes from a memory address into a **Long** variable +- [GetMem8](../tB/Modules/HiddenModule/GetMem8) -- reads eight bytes from a memory address into a **Currency** variable +- [GetMemPtr](../tB/Modules/HiddenModule/GetMemPtr) -- reads a pointer-sized value from a memory address into a **LongPtr** variable - [GetObject](../tB/Modules/Interaction/GetObject) -- returns a reference to an Automation object loaded from a file or already running - [GetSetting](../tB/Modules/Interaction/GetSetting) -- returns a string key setting value from an application’s entry in the Windows registry @@ -113,6 +127,8 @@ permalink: /Reference/Procedures-and-Functions - [If](../tB/Modules/Interaction/If) -- evaluates an expression and returns one of two values, with short-circuit evaluation - [IIf](../tB/Modules/Interaction/IIf) -- evaluates an expression and returns one of two values; both branches are always evaluated - [IMEStatus](../tB/Modules/Information/IMEStatus) -- returns the status of the Input Method Editor +- [Input, Input$](../tB/Modules/HiddenModule/Input) -- reads a fixed number of characters from an open sequential file +- [InputB, InputB$](../tB/Modules/HiddenModule/InputB) -- reads a fixed number of bytes from an open sequential file - [InputBox](../tB/Modules/Interaction/InputBox) -- prompts the user for a line of text and returns what was entered - [InStr$, InStrB, InStr](../tB/Modules/Strings/InStr) -- returns the position of one string within another - [InStrRev](../tB/Modules/Strings/InStrRev) -- returns the position of one string within another, searching from the end @@ -170,14 +186,21 @@ permalink: /Reference/Procedures-and-Functions ## O +- [ObjPtr](../tB/Modules/HiddenModule/ObjPtr) -- returns the COM-identity address of an object - [Oct$, Oct](../tB/Modules/Conversion/Oct) -- returns a string representing the octal value of a number ## P - [Partition](../tB/Modules/Interaction/Partition) -- returns a string identifying the range a number falls into +- [PictureToByteArray](../tB/Modules/HiddenModule/PictureToByteArray) -- serialises an **IPicture** into a **Byte** array - [Pmt](../tB/Modules/Financial/Pmt) -- returns the payment for an annuity based on periodic fixed payments and a fixed interest rate - [PPmt](../tB/Modules/Financial/PPmt) -- returns the principal payment for a given period of an annuity - [ProcessorArchitecture](../tB/Modules/Compilation/ProcessorArchitecture) -- returns the processor architecture of the running application +- [PutMem1](../tB/Modules/HiddenModule/PutMem1) -- writes one byte to a memory address +- [PutMem2](../tB/Modules/HiddenModule/PutMem2) -- writes two bytes to a memory address +- [PutMem4](../tB/Modules/HiddenModule/PutMem4) -- writes four bytes to a memory address +- [PutMem8](../tB/Modules/HiddenModule/PutMem8) -- writes eight bytes to a memory address +- [PutMemPtr](../tB/Modules/HiddenModule/PutMemPtr) -- writes a pointer-sized value to a memory address - [PV](../tB/Modules/Financial/PV) -- returns the present value of an annuity based on periodic fixed payments and a fixed interest rate ## Q @@ -223,6 +246,7 @@ permalink: /Reference/Procedures-and-Functions - [StrComp](../tB/Modules/Strings/StrComp) -- compares two strings - [StrConv](../tB/Modules/Strings/StrConv) -- converts a string to a specified format - [String$, String](../tB/Modules/Strings/String) -- returns a string of repeating characters +- [StrPtr](../tB/Modules/HiddenModule/StrPtr) -- returns the address of the underlying buffer of a **String** - [StrReverse](../tB/Modules/Strings/StrReverse) -- reverses the order of characters in a string - [Switch](../tB/Modules/Interaction/Switch) -- returns the value paired with the first **True** condition in a list of (condition, value) pairs - [SYD](../tB/Modules/Financial/SYD) -- returns the sum-of-years' digits depreciation of an asset for a specified period @@ -248,13 +272,20 @@ permalink: /Reference/Procedures-and-Functions - [Val](../tB/Modules/Conversion/Val) -- parses a string into a **Double** - [ValDec](../tB/Modules/Conversion/ValDec) -- parses a string into a **Decimal** +- [VarPtr](../tB/Modules/HiddenModule/VarPtr) -- returns the address of a variable - [VarType](../tB/Modules/Information/VarType) -- returns the **VbVarType** enumeration value identifying a variable's subtype +- [vbaCastObj](../tB/Modules/HiddenModule/vbaCastObj) -- returns an object reinterpreted as another COM interface +- [vbaCopyBytes](../tB/Modules/HiddenModule/vbaCopyBytes) -- copies a block of bytes from one address to another +- [vbaCopyBytesZero](../tB/Modules/HiddenModule/vbaCopyBytesZero) -- copies a block of bytes from one address to another, then zeros the source +- [vbaObjAddref](../tB/Modules/HiddenModule/vbaObjAddref) -- increments the COM reference count of an object at a given address +- [vbaObjSet](../tB/Modules/HiddenModule/vbaObjSet) -- assigns an object pointer to an object variable, releasing any prior reference +- [vbaObjSetAddref](../tB/Modules/HiddenModule/vbaObjSetAddref) -- assigns an object pointer to an object variable, adding a reference and releasing any prior reference ## W - [Weekday](../tB/Modules/DateTime/Weekday) -- returns the day of the week from a date value - [WeekdayName](../tB/Modules/Strings/WeekdayName) -- returns the name of the specified day of the week -- Width +- [Width](../tB/Modules/HiddenModule/Width) -- sets the line width for a sequential output file ## X From a23cc4c981aa330e44b78a610f09c0767ad76daa Mon Sep 17 00:00:00 2001 From: Kuba Sunderland-Ober Date: Sat, 9 May 2026 01:22:23 +0200 Subject: [PATCH 3/3] Categorize the (Default) API. --- docs/Reference/Categories.md | 74 +++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/docs/Reference/Categories.md b/docs/Reference/Categories.md index 300ad8f..8987984 100644 --- a/docs/Reference/Categories.md +++ b/docs/Reference/Categories.md @@ -71,6 +71,7 @@ Procedures: * [Erl](../tB/Modules/Information/Erl) - returns the line number where the most recent run-time error occurred * [Error$, Error](../tB/Modules/Conversion/Error) function - returns the error message that corresponds to a given error number * [CVErr](../tB/Modules/Conversion/CVErr) - wraps a numeric expression in a **Variant** of subtype **Error** +* [SetThreadGlobalErrorTrap](../tB/Modules/HiddenModule/SetThreadGlobalErrorTrap) - register a callback that fires when an unhandled run-time error escapes the active error handler chain on the calling thread ## Variable Declaration @@ -108,7 +109,8 @@ Procedures: See also: * [Dim](../tB/Core/Dim) - allocate a scalar or array variable -* [Array](../tB/Modules/VBA/Array), [Filter](../tB/Modules/Strings/Filter), [Join](../tB/Modules/Strings/Join), [Split](../tB/Modules/Strings/Split) - array helpers in the **VBA** and **Strings** modules +* [Array](../tB/Modules/HiddenModule/Array), [Filter](../tB/Modules/Strings/Filter), [Join](../tB/Modules/Strings/Join), [Split](../tB/Modules/Strings/Split) - array helpers +* [vbaAryMove](../tB/Modules/HiddenModule/vbaAryMove), [vbaRefVarAry](../tB/Modules/HiddenModule/vbaRefVarAry) - low-level **Variant**-array helpers (see [Memory and Pointers](#memory-and-pointers)) ## File I/O @@ -124,7 +126,9 @@ Statements: Procedures: * [Reset](../tB/Core/Reset) - close all open disk files -* [Width](../tB/Core/Width) - set the limit for line lengths when printing +* [Width](../tB/Modules/HiddenModule/Width) - set the limit for line lengths when printing +* [Input, Input$](../tB/Modules/HiddenModule/Input) - read a fixed number of characters from a sequential file +* [InputB, InputB$](../tB/Modules/HiddenModule/InputB) - read a fixed number of bytes from a sequential file * [ChDir](../tB/Core/ChDir), [ChDrive](../tB/Core/ChDrive) - change the current working directory and disk drive * [MkDir](../tB/Core/MkDir), [RmDir](../tB/Core/RmDir) - create/remove a directory on disk * [Name](../tB/Core/Name) - rename a file or directory on disk @@ -153,10 +157,12 @@ Procedures: * [RaiseEventByName](../tB/Modules/Interaction/RaiseEventByName) - raise an event by name on an object, taking arguments as a **Variant** array * [RaiseEventByName2](../tB/Modules/Interaction/RaiseEventByName2) - raise an event by name on an object, taking a variable-length argument list +* [RuntimeCreateGetMessageHook](../tB/Modules/HiddenModule/RuntimeCreateGetMessageHook) - create an **IGetMessageHook** for filtering Windows messages destined for a window and (optionally) its descendants See also * [Event](../tB/Core/Event) - declare an event +* [IGetMessageHook interface](../tB/Modules/HiddenModule/#igetmessagehook-interface) - subscribe a callback to a Windows message type, then start/stop delivery ## User Dialogs @@ -183,6 +189,14 @@ Procedures: * [GetObject](../tB/Modules/Interaction/GetObject) - obtain a reference to an Automation object loaded from a file or already running * [CallByName](../tB/Modules/Interaction/CallByName) - invoke a method or property on an object dynamically by name * [CallByDispId](../tB/Modules/Interaction/CallByDispId) - invoke a method or property on an object dynamically by IDispatch dispatch ID (twinBASIC addition) +* [CreateGUID](../tB/Modules/HiddenModule/CreateGUID) - generate a fresh GUID and return it as a registry-formatted string +* [vbaCastObj](../tB/Modules/HiddenModule/vbaCastObj) - reinterpret an object as another COM interface (a typed `QueryInterface`) +* [vbaObjSet](../tB/Modules/HiddenModule/vbaObjSet), [vbaObjSetAddref](../tB/Modules/HiddenModule/vbaObjSetAddref) - assign a raw object pointer to an **Object** variable, with or without addref +* [vbaObjAddref](../tB/Modules/HiddenModule/vbaObjAddref) - increment the COM reference count of the object at a given address + +See also: + +* [ObjPtr](../tB/Modules/HiddenModule/ObjPtr) - return the COM-identity address of an object (see [Memory and Pointers](#memory-and-pointers)) ## Command Line and Environment @@ -351,11 +365,67 @@ Procedures: * [CurrentSourceFile](../tB/Modules/Compilation/CurrentSourceFile) - returns the full path of the current source file * [ProcessorArchitecture](../tB/Modules/Compilation/ProcessorArchitecture) - returns the processor architecture of the running application * [CompilerVersion](../tB/Modules/Compilation/CompilerVersion) - returns the twinBASIC compiler version number +* [GetDeclaredTypeProgId](../tB/Modules/HiddenModule/GetDeclaredTypeProgId), [GetDeclaredTypeClsid](../tB/Modules/HiddenModule/GetDeclaredTypeClsid), [GetDeclaredTypeIid](../tB/Modules/HiddenModule/GetDeclaredTypeIid), [GetDeclaredTypeEventIid](../tB/Modules/HiddenModule/GetDeclaredTypeEventIid) - return the COM ProgID/CLSID/IID/event IID of a declared type, resolved at compile time +* [GetDeclaredMinEnumValue](../tB/Modules/HiddenModule/GetDeclaredMinEnumValue), [GetDeclaredMaxEnumValue](../tB/Modules/HiddenModule/GetDeclaredMaxEnumValue) - return the smallest/largest value of a declared enumeration, resolved at compile time See also: * [IMEStatus](../tB/Modules/Information/IMEStatus) - the current Input Method Editor mode (East Asian Windows only) +## Memory and Pointers + +Procedures: + +* [ObjPtr](../tB/Modules/HiddenModule/ObjPtr) - return the COM-identity address of an object +* [StrPtr](../tB/Modules/HiddenModule/StrPtr) - return the address of the underlying buffer of a **String** +* [VarPtr](../tB/Modules/HiddenModule/VarPtr) - return the address of a variable +* [AllocMem](../tB/Modules/HiddenModule/AllocMem), [FreeMem](../tB/Modules/HiddenModule/FreeMem) - allocate/release native memory blocks +* [GetMem1](../tB/Modules/HiddenModule/GetMem1), [GetMem2](../tB/Modules/HiddenModule/GetMem2), [GetMem4](../tB/Modules/HiddenModule/GetMem4), [GetMem8](../tB/Modules/HiddenModule/GetMem8), [GetMemPtr](../tB/Modules/HiddenModule/GetMemPtr) - read N bytes from a memory address into a typed variable +* [PutMem1](../tB/Modules/HiddenModule/PutMem1), [PutMem2](../tB/Modules/HiddenModule/PutMem2), [PutMem4](../tB/Modules/HiddenModule/PutMem4), [PutMem8](../tB/Modules/HiddenModule/PutMem8), [PutMemPtr](../tB/Modules/HiddenModule/PutMemPtr) - write a typed value of N bytes to a memory address +* [vbaCopyBytes](../tB/Modules/HiddenModule/vbaCopyBytes), [vbaCopyBytesZero](../tB/Modules/HiddenModule/vbaCopyBytesZero) - copy a block of bytes; the *Zero* form clears the source after the copy + +See also: + +* [vbaAryMove](../tB/Modules/HiddenModule/vbaAryMove), [vbaRefVarAry](../tB/Modules/HiddenModule/vbaRefVarAry) - low-level **Variant**-array helpers (see [Arrays](#arrays)) +* [vbaObjSet](../tB/Modules/HiddenModule/vbaObjSet), [vbaObjSetAddref](../tB/Modules/HiddenModule/vbaObjSetAddref), [vbaObjAddref](../tB/Modules/HiddenModule/vbaObjAddref) - object-pointer assignment and refcounting (see [COM and Automation](#com-and-automation)) + +## Threading and Atomics + +Procedures: + +* [InterlockedExchangePointer](../tB/Modules/HiddenModule/InterlockedExchangePointer) - atomically exchange a pointer-sized value +* [InterlockedCompareExchangePointer](../tB/Modules/HiddenModule/InterlockedCompareExchangePointer) - atomically compare-and-swap a pointer-sized value +* [InterlockedCompareExchange32](../tB/Modules/HiddenModule/InterlockedCompareExchange32), [InterlockedCompareExchange64](../tB/Modules/HiddenModule/InterlockedCompareExchange64) - atomic 32-bit / 64-bit compare-and-swap +* [InterlockedIncrement32](../tB/Modules/HiddenModule/InterlockedIncrement32), [InterlockedDecrement32](../tB/Modules/HiddenModule/InterlockedDecrement32) - atomic 32-bit increment / decrement + +See also: + +* [SetThreadGlobalErrorTrap](../tB/Modules/HiddenModule/SetThreadGlobalErrorTrap) - per-thread error trap (see [Error Handling](#error-handling)) + +## Inline Assembly and Codegen + +Procedures: + +* [Emit](../tB/Modules/HiddenModule/Emit) - inject custom **Byte** values into the codegen of the enclosing procedure +* [EmitAny](../tB/Modules/HiddenModule/EmitAny) - inject custom typed values into the codegen of the enclosing procedure (size inferred from each value's data type) +* [StackOffset](../tB/Modules/HiddenModule/StackOffset) - return the stack-frame offset of a variable, resolved at compile time +* [StackArgsSize](../tB/Modules/HiddenModule/StackArgsSize) - return the total size of stack-passed arguments to the enclosing procedure +* [UnprotectedAccess](../tB/Modules/HiddenModule/UnprotectedAccess) - return an object reference that bypasses access checks on private members + +See also: + +* [Direct Assembly Insertion](../Features/Advanced/Assembly) - the `Naked` modifier and worked examples + +## Expression Evaluation + +Procedures: + +* [Eval](../tB/Modules/HiddenModule/Eval) - compile and evaluate a twinBASIC expression supplied as a string + +See also: + +* [ExpressionService module](../tB/Modules/ExpressionService/) - the underlying engine, when more control over binders or compiled-expression reuse is needed + ## Financial Procedures: