@node-ctypes/comtypes 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -624
- package/dist/automation/dispatch.js +10 -3
- package/dist/automation/record.js +3 -1
- package/dist/automation/variant.d.ts +4 -4
- package/dist/automation/variant.js +102 -29
- package/dist/client/dynamic.js +7 -8
- package/dist/client/events.js +18 -2
- package/dist/client/index.js +3 -1
- package/dist/commethod.d.ts +1 -1
- package/dist/commethod.js +151 -57
- package/dist/errorinfo.d.ts +10 -3
- package/dist/errorinfo.js +66 -18
- package/dist/errors.d.ts +7 -1
- package/dist/executor/apartment.d.ts +7 -3
- package/dist/executor/apartment.js +65 -29
- package/dist/executor/executor.d.ts +2 -0
- package/dist/executor/executor.js +65 -14
- package/dist/guid.d.ts +1 -1
- package/dist/guid.js +15 -10
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/interfaces/agile.d.ts +52 -0
- package/dist/interfaces/agile.js +59 -0
- package/dist/interfaces/errorinfo.d.ts +8 -0
- package/dist/interfaces/errorinfo.js +10 -0
- package/dist/interfaces/index.d.ts +2 -1
- package/dist/interfaces/index.js +2 -1
- package/dist/interfaces/typeinfo.js +3 -0
- package/dist/low-level/iids.d.ts +14 -0
- package/dist/low-level/iids.js +14 -0
- package/dist/low-level/index.d.ts +2 -2
- package/dist/low-level/index.js +1 -1
- package/dist/low-level/native.d.ts +23 -0
- package/dist/low-level/native.js +53 -0
- package/dist/low-level/registry.js +4 -2
- package/dist/low-level/vtable.d.ts +10 -0
- package/dist/low-level/vtable.js +32 -5
- package/dist/pointer.d.ts +2 -0
- package/dist/pointer.js +154 -84
- package/dist/pump.d.ts +32 -8
- package/dist/pump.js +87 -15
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +15 -1
- package/dist/server/automation.js +3 -3
- package/dist/server/comobject.d.ts +53 -0
- package/dist/server/comobject.js +319 -27
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/marshal.d.ts +1 -0
- package/dist/server/marshal.js +16 -8
- package/dist/server/register.js +8 -6
- package/dist/tracking.d.ts +2 -0
- package/dist/tracking.js +13 -0
- package/package.json +6 -2
|
@@ -6,15 +6,16 @@
|
|
|
6
6
|
import * as ctypes from "node-ctypes";
|
|
7
7
|
import { COINIT_MULTITHREADED } from "../constants.js";
|
|
8
8
|
import { GUID } from "../guid.js";
|
|
9
|
+
import { IID_IRestrictedErrorInfo, IID_ISupportErrorInfo } from "../low-level/iids.js";
|
|
9
10
|
import { ole32, oleaut32, takeBSTR } from "../low-level/native.js";
|
|
10
|
-
import { functionCache, vtableEntry } from "../low-level/vtable.js";
|
|
11
|
+
import { functionCache, PointerArgAt, QueryInterfaceAt, RefCountAt, vtableEntry } from "../low-level/vtable.js";
|
|
11
12
|
const { c_int32, c_uint32, c_void_p } = ctypes;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const RestrictedDetailsAt = functionCache(() => ctypes.WINFUNCTYPE(c_int32, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p));
|
|
14
|
+
const executorStopHooks = new Set();
|
|
15
|
+
/** Register a hook invoked right before an executor runs `CoUninitialize` during `finalize()`. */
|
|
16
|
+
export function onExecutorStopping(hook) {
|
|
17
|
+
executorStopHooks.add(hook);
|
|
18
|
+
}
|
|
18
19
|
let executor = null;
|
|
19
20
|
let closing = null;
|
|
20
21
|
let generation = 0;
|
|
@@ -66,11 +67,20 @@ export function finalize() {
|
|
|
66
67
|
const stopping = executor;
|
|
67
68
|
if (!stopping)
|
|
68
69
|
return Promise.resolve();
|
|
70
|
+
const stoppingGen = generation;
|
|
69
71
|
executor = null;
|
|
70
72
|
if (exitHandler) {
|
|
71
73
|
process.off("beforeExit", exitHandler);
|
|
72
74
|
exitHandler = null;
|
|
73
75
|
}
|
|
76
|
+
for (const hook of executorStopHooks) {
|
|
77
|
+
try {
|
|
78
|
+
hook(stopping, stoppingGen);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Keep shutting down.
|
|
82
|
+
}
|
|
83
|
+
}
|
|
74
84
|
// FIFO: after every accepted call, before the thread stops.
|
|
75
85
|
ole32()
|
|
76
86
|
.CoUninitialize.callOn(stopping)
|
|
@@ -112,7 +122,7 @@ function takeErrorObject(target) {
|
|
|
112
122
|
.then((hr) => (hr === 0 && out.value ? out.value : null));
|
|
113
123
|
}
|
|
114
124
|
function release(target, address) {
|
|
115
|
-
|
|
125
|
+
RefCountAt(vtableEntry(address, 2))
|
|
116
126
|
.callOn(target, address)
|
|
117
127
|
.catch(() => undefined);
|
|
118
128
|
}
|
|
@@ -150,15 +160,56 @@ async function readErrorObject(target, errorObject) {
|
|
|
150
160
|
helpContext: hasContext >= 0 ? context.value : 0,
|
|
151
161
|
};
|
|
152
162
|
}
|
|
153
|
-
|
|
163
|
+
/** Read an `IRestrictedErrorInfo` object on the executor thread when its HRESULT matches `failedHr`. */
|
|
164
|
+
async function readRestrictedErrorObject(target, errorObject, failedHr) {
|
|
165
|
+
const out = new c_void_p();
|
|
166
|
+
const qhr = await QueryInterfaceAt(vtableEntry(errorObject, 0)).callOn(target, errorObject, IID_IRestrictedErrorInfo._buffer, ctypes.byref(out));
|
|
167
|
+
if (qhr < 0 || !out.value)
|
|
168
|
+
return null;
|
|
169
|
+
const restricted = out.value;
|
|
170
|
+
try {
|
|
171
|
+
const desc = new c_void_p();
|
|
172
|
+
const err = new c_int32();
|
|
173
|
+
const restrictedDesc = new c_void_p();
|
|
174
|
+
const capabilitySid = new c_void_p();
|
|
175
|
+
const ref = new c_void_p();
|
|
176
|
+
const [hr, refHr] = await Promise.all([
|
|
177
|
+
RestrictedDetailsAt(vtableEntry(restricted, 3)).callOn(target, restricted, ctypes.byref(desc), ctypes.byref(err), ctypes.byref(restrictedDesc), ctypes.byref(capabilitySid)),
|
|
178
|
+
PointerArgAt(vtableEntry(restricted, 4)).callOn(target, restricted, ctypes.byref(ref)),
|
|
179
|
+
]);
|
|
180
|
+
const descriptionText = hr >= 0 ? takeBSTR(desc.value) : null;
|
|
181
|
+
const restrictedText = hr >= 0 ? takeBSTR(restrictedDesc.value) : null;
|
|
182
|
+
const capabilityText = hr >= 0 ? takeBSTR(capabilitySid.value) : null;
|
|
183
|
+
const referenceText = refHr >= 0 ? takeBSTR(ref.value) : null;
|
|
184
|
+
if (hr < 0 || err.value !== failedHr)
|
|
185
|
+
return null;
|
|
186
|
+
const trimmedRestricted = restrictedText?.trim() || null;
|
|
187
|
+
const trimmedDescription = descriptionText?.trim() || null;
|
|
188
|
+
return {
|
|
189
|
+
guid: null,
|
|
190
|
+
source: null,
|
|
191
|
+
description: trimmedRestricted ?? trimmedDescription,
|
|
192
|
+
helpFile: null,
|
|
193
|
+
helpContext: 0,
|
|
194
|
+
restrictedDescription: trimmedRestricted,
|
|
195
|
+
capabilitySid: capabilityText?.trim() || null,
|
|
196
|
+
reference: referenceText?.trim() || null,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
release(target, restricted);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async function errorDetails(target, errorObject, errorInfo, failedHr) {
|
|
154
204
|
const taken = await errorObject;
|
|
155
205
|
if (!taken)
|
|
156
206
|
return null;
|
|
157
207
|
try {
|
|
158
|
-
//
|
|
159
|
-
if (
|
|
160
|
-
return
|
|
161
|
-
|
|
208
|
+
// Classic COM: check ISupportErrorInfo first, as Python comtypes.
|
|
209
|
+
if (await supportsErrorInfo(target, errorInfo.object, new GUID(errorInfo.iid)))
|
|
210
|
+
return await readErrorObject(target, taken);
|
|
211
|
+
// WinRT / modern COM fallback: IRestrictedErrorInfo (stored in the same thread error slot).
|
|
212
|
+
return await readRestrictedErrorObject(target, taken, failedHr);
|
|
162
213
|
}
|
|
163
214
|
catch {
|
|
164
215
|
return null;
|
|
@@ -203,6 +254,6 @@ export function executorCall(call, options = {}) {
|
|
|
203
254
|
return pending.then((value) => {
|
|
204
255
|
if (!(typeof value === "number" && value < 0) || !errorInfo || lastJob(target) !== job)
|
|
205
256
|
return { value, details: null };
|
|
206
|
-
return errorDetails(target, takeErrorObject(target), errorInfo).then((details) => ({ value, details }));
|
|
257
|
+
return errorDetails(target, takeErrorObject(target), errorInfo, value).then((details) => ({ value, details }));
|
|
207
258
|
});
|
|
208
259
|
}
|
package/dist/guid.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as ctypes from "node-ctypes";
|
|
|
5
5
|
* ```ts
|
|
6
6
|
* new GUID("{00000000-0000-0000-C000-000000000046}");
|
|
7
7
|
* new GUID(); // GUID_NULL
|
|
8
|
-
* new GUID(buffer); //
|
|
8
|
+
* new GUID(buffer); // copy of 16 bytes (GUID.from_buffer(buffer) for a view)
|
|
9
9
|
* ```
|
|
10
10
|
*/
|
|
11
11
|
export declare class GUID extends ctypes.Structure {
|
package/dist/guid.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ctypes from "node-ctypes";
|
|
2
|
-
import { ole32, takeCoTaskMemString } from "./low-level/native.js";
|
|
2
|
+
import { flushMirror, ole32, refreshMirror, takeCoTaskMemString } from "./low-level/native.js";
|
|
3
3
|
import { checkHRESULT } from "./errors.js";
|
|
4
4
|
const GUID_PATTERN = /^\{?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}?$/i;
|
|
5
5
|
/**
|
|
@@ -8,7 +8,7 @@ const GUID_PATTERN = /^\{?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4}
|
|
|
8
8
|
* ```ts
|
|
9
9
|
* new GUID("{00000000-0000-0000-C000-000000000046}");
|
|
10
10
|
* new GUID(); // GUID_NULL
|
|
11
|
-
* new GUID(buffer); //
|
|
11
|
+
* new GUID(buffer); // copy of 16 bytes (GUID.from_buffer(buffer) for a view)
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export class GUID extends ctypes.Structure {
|
|
@@ -19,13 +19,7 @@ export class GUID extends ctypes.Structure {
|
|
|
19
19
|
["Data4", ctypes.array(ctypes.c_uint8, 8)],
|
|
20
20
|
];
|
|
21
21
|
constructor(init) {
|
|
22
|
-
//
|
|
23
|
-
if (Buffer.isBuffer(init)) {
|
|
24
|
-
if (init.length !== 16)
|
|
25
|
-
throw new TypeError("GUID requires a GUID string, another GUID or exactly 16 bytes");
|
|
26
|
-
super(init);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
22
|
+
// Bytes (Buffers included) are copied, as CPython's GUID(bytes) would not wrap them: use GUID.from_buffer for a view.
|
|
29
23
|
super();
|
|
30
24
|
if (init === undefined)
|
|
31
25
|
return;
|
|
@@ -37,23 +31,29 @@ export class GUID extends ctypes.Structure {
|
|
|
37
31
|
this.Data2 = parseInt(match[2], 16);
|
|
38
32
|
this.Data3 = parseInt(match[3], 16);
|
|
39
33
|
Buffer.from(match[4] + match[5], "hex").copy(this._buffer, 8);
|
|
34
|
+
flushMirror(this._buffer);
|
|
40
35
|
return;
|
|
41
36
|
}
|
|
37
|
+
if (init instanceof GUID)
|
|
38
|
+
refreshMirror(init._buffer);
|
|
42
39
|
const bytes = init instanceof GUID ? init._buffer : init;
|
|
43
40
|
if (!(bytes instanceof Uint8Array) || bytes.length !== 16)
|
|
44
41
|
throw new TypeError("GUID requires a GUID string, another GUID or exactly 16 bytes");
|
|
45
42
|
this._buffer.set(bytes);
|
|
43
|
+
flushMirror(this._buffer);
|
|
46
44
|
}
|
|
47
45
|
/** A new random GUID (`CoCreateGuid`). Python: `GUID.create_new()`. */
|
|
48
46
|
static createNew() {
|
|
49
47
|
const guid = new GUID();
|
|
50
48
|
checkHRESULT(ole32().CoCreateGuid(guid._buffer), "CoCreateGuid");
|
|
49
|
+
refreshMirror(guid._buffer);
|
|
51
50
|
return guid;
|
|
52
51
|
}
|
|
53
52
|
/** CLSID registered for a ProgID (`CLSIDFromProgID`). Python: `GUID.from_progid()`. */
|
|
54
53
|
static fromProgID(progid) {
|
|
55
54
|
const guid = new GUID();
|
|
56
55
|
checkHRESULT(ole32().CLSIDFromProgID(progid, guid._buffer), "CLSIDFromProgID");
|
|
56
|
+
refreshMirror(guid._buffer);
|
|
57
57
|
return guid;
|
|
58
58
|
}
|
|
59
59
|
/** ProgID registered for this CLSID (`ProgIDFromCLSID`). Python: `GUID.as_progid()`. */
|
|
@@ -69,13 +69,18 @@ export class GUID extends ctypes.Structure {
|
|
|
69
69
|
equals(other) {
|
|
70
70
|
if (other === null || other === undefined)
|
|
71
71
|
return false;
|
|
72
|
-
|
|
72
|
+
const target = toGUID(other);
|
|
73
|
+
refreshMirror(target._buffer);
|
|
74
|
+
refreshMirror(this._buffer);
|
|
75
|
+
return target._buffer.equals(this._buffer);
|
|
73
76
|
}
|
|
74
77
|
isNull() {
|
|
78
|
+
refreshMirror(this._buffer);
|
|
75
79
|
return this._buffer.every((byte) => byte === 0);
|
|
76
80
|
}
|
|
77
81
|
/** `{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}` (uppercase, as `StringFromGUID2`). */
|
|
78
82
|
toString() {
|
|
83
|
+
refreshMirror(this._buffer);
|
|
79
84
|
const hex = (value, width) => value.toString(16).padStart(width, "0");
|
|
80
85
|
const tail = this._buffer.subarray(8, 16).toString("hex");
|
|
81
86
|
return `{${hex(this.Data1, 8)}-${hex(this.Data2, 4)}-${hex(this.Data3, 4)}-${tail.slice(0, 4)}-${tail.slice(4)}}`.toUpperCase();
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { GUIDLike } from "./guid.ts";
|
|
|
3
3
|
export * from "./hresult.ts";
|
|
4
4
|
export { COMError, checkHRESULT, hresultText, systemMessage } from "./errors.ts";
|
|
5
5
|
export type { COMErrorDetails, COMErrorOptions } from "./errors.ts";
|
|
6
|
-
export { takeErrorInfo } from "./errorinfo.ts";
|
|
6
|
+
export { takeErrorInfo, takeRestrictedErrorInfo } from "./errorinfo.ts";
|
|
7
7
|
export { stats, finalize } from "./executor/executor.ts";
|
|
8
8
|
export { run } from "./executor/operations.ts";
|
|
9
9
|
export type { RunOptions } from "./executor/operations.ts";
|
|
@@ -15,17 +15,17 @@ export type { ComParamType, ParamFlag, ParamSpec, ParamInfo, IdlFlag, DispIdFlag
|
|
|
15
15
|
export { COMPointer } from "./pointer.ts";
|
|
16
16
|
export type { FromAddressOptions } from "./pointer.ts";
|
|
17
17
|
export * from "./constants.ts";
|
|
18
|
-
export { CoInitializeEx, CoInitialize, CoUninitialize, apartment, getApartmentType, getLivePointerCount, CoCreateInstance, CoCreateInstanceEx, CoGetClassObject, CoTaskMemAlloc, CoTaskMemRealloc, CoTaskMemFree } from "./runtime.ts";
|
|
18
|
+
export { CoInitializeEx, CoInitialize, CoUninitialize, apartment, getApartmentType, getLivePointerCount, CoCreateInstance, CoCreateInstanceEx, CoGetClassObject, CoTaskMemAlloc, CoTaskMemRealloc, CoTaskMemFree, CoCreateFreeThreadedMarshaler, } from "./runtime.ts";
|
|
19
19
|
export type { Apartment, ApartmentType, CreateInstanceOptions, CreateInstanceExOptions } from "./runtime.ts";
|
|
20
20
|
export * from "./interfaces/index.ts";
|
|
21
21
|
export * from "./automation/index.ts";
|
|
22
22
|
export * from "./client/index.ts";
|
|
23
23
|
export * from "./server/index.ts";
|
|
24
|
-
export { pumpMessages, PumpEvents, startMessagePump, waitFor } from "./pump.ts";
|
|
24
|
+
export { pumpMessages, waitAndPumpMessages, PumpEvents, startMessagePump, waitFor } from "./pump.ts";
|
|
25
25
|
export { DISPMETHOD, DISPPROPERTY } from "./dispmethod.ts";
|
|
26
26
|
export type { DispSpec } from "./dispmethod.ts";
|
|
27
27
|
export * from "./typelib/index.ts";
|
|
28
28
|
export { marshalInterface, unmarshalInterface, unmarshalDispatch, releaseMarshaled, GlobalInterfaceTable, IGlobalInterfaceTable, CLSID_StdGlobalInterfaceTable } from "./threads.ts";
|
|
29
29
|
export type { MarshaledInterface } from "./threads.ts";
|
|
30
|
-
export type { MessagePump } from "./pump.ts";
|
|
31
|
-
export declare const version = "0.
|
|
30
|
+
export type { MessagePump, StartMessagePumpOptions } from "./pump.ts";
|
|
31
|
+
export declare const version = "0.4.0";
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export { GUID, GUID_NULL, toGUID } from "./guid.js";
|
|
2
2
|
export * from "./hresult.js";
|
|
3
3
|
export { COMError, checkHRESULT, hresultText, systemMessage } from "./errors.js";
|
|
4
|
-
export { takeErrorInfo } from "./errorinfo.js";
|
|
4
|
+
export { takeErrorInfo, takeRestrictedErrorInfo } from "./errorinfo.js";
|
|
5
5
|
export { stats, finalize } from "./executor/executor.js";
|
|
6
6
|
export { run } from "./executor/operations.js";
|
|
7
7
|
export { COMInterface, STDMETHOD, HRESULT, findInterface, derivesFrom } from "./interface.js";
|
|
8
8
|
export { COMMETHOD, BSTR, LPOLESTR, REFGUID, REFIID, REFCLSID, SAFEARRAY, SELF, DATE, CURRENCY, lazy, dispid, helpstring, classifyParamType, resolveParamInterface } from "./commethod.js";
|
|
9
9
|
export { COMPointer } from "./pointer.js";
|
|
10
10
|
export * from "./constants.js";
|
|
11
|
-
export { CoInitializeEx, CoInitialize, CoUninitialize, apartment, getApartmentType, getLivePointerCount, CoCreateInstance, CoCreateInstanceEx, CoGetClassObject, CoTaskMemAlloc, CoTaskMemRealloc, CoTaskMemFree } from "./runtime.js";
|
|
11
|
+
export { CoInitializeEx, CoInitialize, CoUninitialize, apartment, getApartmentType, getLivePointerCount, CoCreateInstance, CoCreateInstanceEx, CoGetClassObject, CoTaskMemAlloc, CoTaskMemRealloc, CoTaskMemFree, CoCreateFreeThreadedMarshaler, } from "./runtime.js";
|
|
12
12
|
export * from "./interfaces/index.js";
|
|
13
13
|
export * from "./automation/index.js";
|
|
14
14
|
export * from "./client/index.js";
|
|
15
15
|
export * from "./server/index.js";
|
|
16
|
-
export { pumpMessages, PumpEvents, startMessagePump, waitFor } from "./pump.js";
|
|
16
|
+
export { pumpMessages, waitAndPumpMessages, PumpEvents, startMessagePump, waitFor } from "./pump.js";
|
|
17
17
|
export { DISPMETHOD, DISPPROPERTY } from "./dispmethod.js";
|
|
18
18
|
export * from "./typelib/index.js";
|
|
19
19
|
export { marshalInterface, unmarshalInterface, unmarshalDispatch, releaseMarshaled, GlobalInterfaceTable, IGlobalInterfaceTable, CLSID_StdGlobalInterfaceTable } from "./threads.js";
|
|
20
|
-
export const version = "0.
|
|
20
|
+
export const version = "0.4.0";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as ctypes from "node-ctypes";
|
|
2
|
+
import { GUID } from "../guid.ts";
|
|
3
|
+
import type { InterfaceDef, InterfacePointer } from "../interface.ts";
|
|
4
|
+
import { COMPointer } from "../pointer.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Marker interface declaring that a COM/WinRT object is agile (callable from
|
|
7
|
+
* any apartment without marshaling).
|
|
8
|
+
*/
|
|
9
|
+
export declare const IAgileObject: import("../interface.ts").ComInterfaceDef<import("../interface.ts").ComInterfaceDef<undefined, readonly [import("../interface.ts").MethodSpec<"QueryInterface", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
10
|
+
_isHResult: true;
|
|
11
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "QueryInterface">, import("../interface.ts").MethodSpec<"AddRef", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "AddRef">, import("../interface.ts").MethodSpec<"Release", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "Release">], readonly []>, readonly [], readonly []>;
|
|
12
|
+
/**
|
|
13
|
+
* Weak reference to a COM/WinRT object (`IWeakReference`). Call
|
|
14
|
+
* {@link resolveWeakReference} (or `Resolve`) to obtain a strong pointer while
|
|
15
|
+
* the target is still alive (`null` once its reference count has reached zero).
|
|
16
|
+
*/
|
|
17
|
+
export declare const IWeakReference: import("../interface.ts").ComInterfaceDef<import("../interface.ts").ComInterfaceDef<undefined, readonly [import("../interface.ts").MethodSpec<"QueryInterface", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
18
|
+
_isHResult: true;
|
|
19
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "QueryInterface">, import("../interface.ts").MethodSpec<"AddRef", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "AddRef">, import("../interface.ts").MethodSpec<"Release", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "Release">], readonly []>, readonly [import("../interface.ts").MethodSpec<"Resolve", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
20
|
+
_isHResult: true;
|
|
21
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "Resolve">], readonly []>;
|
|
22
|
+
/** Exposes a weak reference to a COM/WinRT object (`IWeakReferenceSource`). */
|
|
23
|
+
export declare const IWeakReferenceSource: import("../interface.ts").ComInterfaceDef<import("../interface.ts").ComInterfaceDef<undefined, readonly [import("../interface.ts").MethodSpec<"QueryInterface", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
24
|
+
_isHResult: true;
|
|
25
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "QueryInterface">, import("../interface.ts").MethodSpec<"AddRef", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "AddRef">, import("../interface.ts").MethodSpec<"Release", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "Release">], readonly []>, readonly [import("../commethod.ts").CommethodSpec<readonly [], ctypes.SimpleCDataConstructor<"int32"> & {
|
|
26
|
+
_isHResult: true;
|
|
27
|
+
}, "GetWeakReference", readonly [readonly [readonly ["out", "retval"], import("../interface.ts").ComInterfaceDef<import("../interface.ts").ComInterfaceDef<undefined, readonly [import("../interface.ts").MethodSpec<"QueryInterface", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
28
|
+
_isHResult: true;
|
|
29
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "QueryInterface">, import("../interface.ts").MethodSpec<"AddRef", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "AddRef">, import("../interface.ts").MethodSpec<"Release", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "Release">], readonly []>, readonly [import("../interface.ts").MethodSpec<"Resolve", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
30
|
+
_isHResult: true;
|
|
31
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "Resolve">], readonly []>, "weakReference"]]>], readonly []>;
|
|
32
|
+
/** Custom marshaling interface (`IMarshal`), including the Free-Threaded Marshaler. */
|
|
33
|
+
export declare const IMarshal: import("../interface.ts").ComInterfaceDef<import("../interface.ts").ComInterfaceDef<undefined, readonly [import("../interface.ts").MethodSpec<"QueryInterface", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
34
|
+
_isHResult: true;
|
|
35
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "QueryInterface">, import("../interface.ts").MethodSpec<"AddRef", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "AddRef">, import("../interface.ts").MethodSpec<"Release", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "Release">], readonly []>, readonly [import("../interface.ts").MethodSpec<"GetUnmarshalClass", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
36
|
+
_isHResult: true;
|
|
37
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.PointerTypeDef<typeof GUID>]>, "method", "GetUnmarshalClass">, import("../interface.ts").MethodSpec<"GetMarshalSizeMax", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
38
|
+
_isHResult: true;
|
|
39
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"uint32">>]>, "method", "GetMarshalSizeMax">, import("../interface.ts").MethodSpec<"MarshalInterface", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
40
|
+
_isHResult: true;
|
|
41
|
+
}, readonly [ctypes.SimpleCDataConstructor<"pointer">, ctypes.PointerTypeDef<typeof GUID>, ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"uint32">]>, "method", "MarshalInterface">, import("../interface.ts").MethodSpec<"UnmarshalInterface", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
42
|
+
_isHResult: true;
|
|
43
|
+
}, readonly [ctypes.SimpleCDataConstructor<"pointer">, ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "UnmarshalInterface">, import("../interface.ts").MethodSpec<"ReleaseMarshalData", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
44
|
+
_isHResult: true;
|
|
45
|
+
}, readonly [ctypes.SimpleCDataConstructor<"pointer">]>, "method", "ReleaseMarshalData">, import("../interface.ts").MethodSpec<"DisconnectObject", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
46
|
+
_isHResult: true;
|
|
47
|
+
}, readonly [ctypes.SimpleCDataConstructor<"uint32">]>, "method", "DisconnectObject">], readonly []>;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve an `IWeakReference` to a strong typed pointer for `iface`, or `null`
|
|
50
|
+
* if the target object has already been released.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveWeakReference<T extends InterfaceDef<any>>(weak: COMPointer<typeof IWeakReference>, iface: T): InterfacePointer<T> | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as ctypes from "node-ctypes";
|
|
2
|
+
import { COMMETHOD } from "../commethod.js";
|
|
3
|
+
import { checkHRESULT } from "../errors.js";
|
|
4
|
+
import { GUID } from "../guid.js";
|
|
5
|
+
import { COMInterface, HRESULT, STDMETHOD } from "../interface.js";
|
|
6
|
+
import { COMPointer, sync } from "../pointer.js";
|
|
7
|
+
import { IUnknown } from "./unknown.js";
|
|
8
|
+
const { c_uint32, c_void_p, POINTER } = ctypes;
|
|
9
|
+
/**
|
|
10
|
+
* Marker interface declaring that a COM/WinRT object is agile (callable from
|
|
11
|
+
* any apartment without marshaling).
|
|
12
|
+
*/
|
|
13
|
+
export const IAgileObject = COMInterface({
|
|
14
|
+
name: "IAgileObject",
|
|
15
|
+
iid: "{94EA2B94-E9CC-49E0-C0FF-EE64CA8F5B90}",
|
|
16
|
+
extends: IUnknown,
|
|
17
|
+
methods: [],
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Weak reference to a COM/WinRT object (`IWeakReference`). Call
|
|
21
|
+
* {@link resolveWeakReference} (or `Resolve`) to obtain a strong pointer while
|
|
22
|
+
* the target is still alive (`null` once its reference count has reached zero).
|
|
23
|
+
*/
|
|
24
|
+
export const IWeakReference = COMInterface({
|
|
25
|
+
name: "IWeakReference",
|
|
26
|
+
iid: "{00000037-0000-0000-C000-000000000046}",
|
|
27
|
+
extends: IUnknown,
|
|
28
|
+
methods: [STDMETHOD(HRESULT, "Resolve", [POINTER(GUID), POINTER(c_void_p)])],
|
|
29
|
+
});
|
|
30
|
+
/** Exposes a weak reference to a COM/WinRT object (`IWeakReferenceSource`). */
|
|
31
|
+
export const IWeakReferenceSource = COMInterface({
|
|
32
|
+
name: "IWeakReferenceSource",
|
|
33
|
+
iid: "{00000038-0000-0000-C000-000000000046}",
|
|
34
|
+
extends: IUnknown,
|
|
35
|
+
methods: [COMMETHOD([], HRESULT, "GetWeakReference", [["out", "retval"], IWeakReference, "weakReference"])],
|
|
36
|
+
});
|
|
37
|
+
/** Custom marshaling interface (`IMarshal`), including the Free-Threaded Marshaler. */
|
|
38
|
+
export const IMarshal = COMInterface({
|
|
39
|
+
name: "IMarshal",
|
|
40
|
+
iid: "{00000003-0000-0000-C000-000000000046}",
|
|
41
|
+
extends: IUnknown,
|
|
42
|
+
methods: [
|
|
43
|
+
STDMETHOD(HRESULT, "GetUnmarshalClass", [POINTER(GUID), c_void_p, c_uint32, c_void_p, c_uint32, POINTER(GUID)]),
|
|
44
|
+
STDMETHOD(HRESULT, "GetMarshalSizeMax", [POINTER(GUID), c_void_p, c_uint32, c_void_p, c_uint32, POINTER(c_uint32)]),
|
|
45
|
+
STDMETHOD(HRESULT, "MarshalInterface", [c_void_p, POINTER(GUID), c_void_p, c_uint32, c_void_p, c_uint32]),
|
|
46
|
+
STDMETHOD(HRESULT, "UnmarshalInterface", [c_void_p, POINTER(GUID), POINTER(c_void_p)]),
|
|
47
|
+
STDMETHOD(HRESULT, "ReleaseMarshalData", [c_void_p]),
|
|
48
|
+
STDMETHOD(HRESULT, "DisconnectObject", [c_uint32]),
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Resolve an `IWeakReference` to a strong typed pointer for `iface`, or `null`
|
|
53
|
+
* if the target object has already been released.
|
|
54
|
+
*/
|
|
55
|
+
export function resolveWeakReference(weak, iface) {
|
|
56
|
+
const out = new c_void_p();
|
|
57
|
+
checkHRESULT(sync(weak).Resolve(iface.iid._buffer, ctypes.byref(out)), "IWeakReference::Resolve");
|
|
58
|
+
return out.value ? COMPointer.fromAddress(out.value, iface) : null;
|
|
59
|
+
}
|
|
@@ -32,3 +32,11 @@ export declare const ISupportErrorInfo: import("../interface.ts").ComInterfaceDe
|
|
|
32
32
|
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "QueryInterface">, import("../interface.ts").MethodSpec<"AddRef", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "AddRef">, import("../interface.ts").MethodSpec<"Release", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "Release">], readonly []>, readonly [import("../commethod.ts").CommethodSpec<readonly [], ctypes.SimpleCDataConstructor<"int32"> & {
|
|
33
33
|
_isHResult: true;
|
|
34
34
|
}, "InterfaceSupportsErrorInfo", readonly [readonly [readonly ["in"], import("../commethod.ts").RefGuidType, "riid"]]>], readonly []>;
|
|
35
|
+
/** WinRT / modern COM restricted error object (`GetRestrictedErrorInfo` / `RoOriginateErrorW`). */
|
|
36
|
+
export declare const IRestrictedErrorInfo: import("../interface.ts").ComInterfaceDef<import("../interface.ts").ComInterfaceDef<undefined, readonly [import("../interface.ts").MethodSpec<"QueryInterface", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"int32"> & {
|
|
37
|
+
_isHResult: true;
|
|
38
|
+
}, readonly [ctypes.PointerTypeDef<typeof GUID>, ctypes.PointerTypeDef<ctypes.SimpleCDataConstructor<"pointer">>]>, "method", "QueryInterface">, import("../interface.ts").MethodSpec<"AddRef", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "AddRef">, import("../interface.ts").MethodSpec<"Release", import("../interface.ts").RawFunction<ctypes.SimpleCDataConstructor<"uint32">, readonly []>, "method", "Release">], readonly []>, readonly [import("../commethod.ts").CommethodSpec<readonly [], ctypes.SimpleCDataConstructor<"int32"> & {
|
|
39
|
+
_isHResult: true;
|
|
40
|
+
}, "GetErrorDetails", readonly [readonly [readonly ["out"], import("../commethod.ts").BSTRType, "description"], readonly [readonly ["out"], ctypes.SimpleCDataConstructor<"int32">, "error"], readonly [readonly ["out"], import("../commethod.ts").BSTRType, "restrictedDescription"], readonly [readonly ["out"], import("../commethod.ts").BSTRType, "capabilitySid"]]>, import("../commethod.ts").CommethodSpec<readonly [], ctypes.SimpleCDataConstructor<"int32"> & {
|
|
41
|
+
_isHResult: true;
|
|
42
|
+
}, "GetReference", readonly [readonly [readonly ["out"], import("../commethod.ts").BSTRType, "reference"]]>], readonly []>;
|
|
@@ -35,3 +35,13 @@ export const ISupportErrorInfo = COMInterface({
|
|
|
35
35
|
extends: IUnknown,
|
|
36
36
|
methods: [COMMETHOD([], HRESULT, "InterfaceSupportsErrorInfo", [["in"], REFIID, "riid"])],
|
|
37
37
|
});
|
|
38
|
+
/** WinRT / modern COM restricted error object (`GetRestrictedErrorInfo` / `RoOriginateErrorW`). */
|
|
39
|
+
export const IRestrictedErrorInfo = COMInterface({
|
|
40
|
+
name: "IRestrictedErrorInfo",
|
|
41
|
+
iid: "{82BA7092-4C88-427D-A7BC-16DD93FEB67E}",
|
|
42
|
+
extends: IUnknown,
|
|
43
|
+
methods: [
|
|
44
|
+
COMMETHOD([], HRESULT, "GetErrorDetails", [["out"], BSTR, "description"], [["out"], ctypes.c_int32, "error"], [["out"], BSTR, "restrictedDescription"], [["out"], BSTR, "capabilitySid"]),
|
|
45
|
+
COMMETHOD([], HRESULT, "GetReference", [["out"], BSTR, "reference"]),
|
|
46
|
+
],
|
|
47
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { IUnknown, IID_IUnknown } from "./unknown.ts";
|
|
2
|
-
export {
|
|
2
|
+
export { IAgileObject, IWeakReference, IWeakReferenceSource, IMarshal, resolveWeakReference } from "./agile.ts";
|
|
3
|
+
export { IErrorInfo, ICreateErrorInfo, ISupportErrorInfo, IRestrictedErrorInfo } from "./errorinfo.ts";
|
|
3
4
|
export { IPersist, IPersistFile, STGM_READ, STGM_WRITE, STGM_READWRITE, IErrorLog, IPropertyBag, IPersistPropertyBag, IPropertyBag2, IPersistPropertyBag2, PROPBAG2, PROPBAG2_TYPE_UNDEFINED, PROPBAG2_TYPE_DATA, PROPBAG2_TYPE_URL, PROPBAG2_TYPE_OBJECT, PROPBAG2_TYPE_STREAM, PROPBAG2_TYPE_STORAGE, PROPBAG2_TYPE_MONIKER, } from "./persist.ts";
|
|
4
5
|
export { IServiceProvider, queryService } from "./servprov.ts";
|
|
5
6
|
export { IViewObject, IViewObject2, SIZEL, DVASPECT_CONTENT, DVASPECT_THUMBNAIL, DVASPECT_ICON, DVASPECT_DOCPRINT } from "./viewobject.ts";
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { IUnknown, IID_IUnknown } from "./unknown.js";
|
|
2
|
-
export {
|
|
2
|
+
export { IAgileObject, IWeakReference, IWeakReferenceSource, IMarshal, resolveWeakReference } from "./agile.js";
|
|
3
|
+
export { IErrorInfo, ICreateErrorInfo, ISupportErrorInfo, IRestrictedErrorInfo } from "./errorinfo.js";
|
|
3
4
|
export { IPersist, IPersistFile, STGM_READ, STGM_WRITE, STGM_READWRITE, IErrorLog, IPropertyBag, IPersistPropertyBag, IPropertyBag2, IPersistPropertyBag2, PROPBAG2, PROPBAG2_TYPE_UNDEFINED, PROPBAG2_TYPE_DATA, PROPBAG2_TYPE_URL, PROPBAG2_TYPE_OBJECT, PROPBAG2_TYPE_STREAM, PROPBAG2_TYPE_STORAGE, PROPBAG2_TYPE_MONIKER, } from "./persist.js";
|
|
4
5
|
export { IServiceProvider, queryService } from "./servprov.js";
|
|
5
6
|
export { IViewObject, IViewObject2, SIZEL, DVASPECT_CONTENT, DVASPECT_THUMBNAIL, DVASPECT_ICON, DVASPECT_DOCPRINT } from "./viewobject.js";
|
|
@@ -4,6 +4,7 @@ import { VARIANT } from "../automation/variant.js";
|
|
|
4
4
|
import { GUID } from "../guid.js";
|
|
5
5
|
import { BSTR, COMMETHOD, LPOLESTR, REFGUID } from "../commethod.js";
|
|
6
6
|
import { COMInterface, HRESULT, STDMETHOD } from "../interface.js";
|
|
7
|
+
import { refreshMirror } from "../low-level/native.js";
|
|
7
8
|
import { IUnknown } from "./unknown.js";
|
|
8
9
|
const { POINTER, c_int16, c_int32, c_uint16, c_uint32, c_void_p, c_wchar_p } = ctypes;
|
|
9
10
|
/** Type of a parameter, return value or variable. `lptdesc` overlays `lpadesc` and `hreftype`. */
|
|
@@ -14,6 +15,7 @@ export class TYPEDESC extends ctypes.Structure {
|
|
|
14
15
|
];
|
|
15
16
|
/** `HREFTYPE` for `VT_USERDEFINED`. */
|
|
16
17
|
get hreftype() {
|
|
18
|
+
refreshMirror(this._buffer);
|
|
17
19
|
return this._buffer.readUInt32LE(0);
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -64,6 +66,7 @@ export class VARDESC extends ctypes.Structure {
|
|
|
64
66
|
["varkind", c_int32],
|
|
65
67
|
];
|
|
66
68
|
get oInst() {
|
|
69
|
+
refreshMirror(this._buffer);
|
|
67
70
|
return this._buffer.readUInt32LE(ctypes.sizeof(c_void_p) === 8 ? 16 : 8);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GUID } from "../guid.ts";
|
|
2
|
+
/** Shared well-known COM IIDs / CLSIDs used internally across modules. */
|
|
3
|
+
export declare const IID_IUnknown: GUID;
|
|
4
|
+
export declare const IID_IDispatch: GUID;
|
|
5
|
+
export declare const IID_ISupportErrorInfo: GUID;
|
|
6
|
+
export declare const IID_IRestrictedErrorInfo: GUID;
|
|
7
|
+
export declare const IID_IAgileObject: GUID;
|
|
8
|
+
export declare const IID_IWeakReference: GUID;
|
|
9
|
+
export declare const IID_IWeakReferenceSource: GUID;
|
|
10
|
+
export declare const IID_IMarshal: GUID;
|
|
11
|
+
export declare const IID_IClientSecurity: GUID;
|
|
12
|
+
export declare const IID_IGlobalInterfaceTable: GUID;
|
|
13
|
+
export declare const CLSID_StdGlobalInterfaceTable: GUID;
|
|
14
|
+
export declare const CLSID_InProcFreeMarshaler: GUID;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GUID } from "../guid.js";
|
|
2
|
+
/** Shared well-known COM IIDs / CLSIDs used internally across modules. */
|
|
3
|
+
export const IID_IUnknown = new GUID("{00000000-0000-0000-C000-000000000046}");
|
|
4
|
+
export const IID_IDispatch = new GUID("{00020400-0000-0000-C000-000000000046}");
|
|
5
|
+
export const IID_ISupportErrorInfo = new GUID("{DF0B3D60-548F-101B-8E65-08002B2BD119}");
|
|
6
|
+
export const IID_IRestrictedErrorInfo = new GUID("{82BA7092-4C88-427D-A7BC-16DD93FEB67E}");
|
|
7
|
+
export const IID_IAgileObject = new GUID("{94EA2B94-E9CC-49E0-C0FF-EE64CA8F5B90}");
|
|
8
|
+
export const IID_IWeakReference = new GUID("{00000037-0000-0000-C000-000000000046}");
|
|
9
|
+
export const IID_IWeakReferenceSource = new GUID("{00000038-0000-0000-C000-000000000046}");
|
|
10
|
+
export const IID_IMarshal = new GUID("{00000003-0000-0000-C000-000000000046}");
|
|
11
|
+
export const IID_IClientSecurity = new GUID("{0000013D-0000-0000-C000-000000000046}");
|
|
12
|
+
export const IID_IGlobalInterfaceTable = new GUID("{00000146-0000-0000-C000-000000000046}");
|
|
13
|
+
export const CLSID_StdGlobalInterfaceTable = new GUID("{00000323-0000-0000-C000-000000000046}");
|
|
14
|
+
export const CLSID_InProcFreeMarshaler = new GUID("{0000033A-0000-0000-C000-000000000046}");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ole32, oleaut32, allocBSTR, readBSTR, takeBSTR, takeCoTaskMemString, readMemory, writeMemory, isWindows, POINTER_SIZE } from "./native.ts";
|
|
2
|
-
export type { Ole32, OleAut32 } from "./native.ts";
|
|
1
|
+
export { ole32, oleaut32, combase, allocBSTR, readBSTR, takeBSTR, takeCoTaskMemString, readMemory, writeMemory, isWindows, POINTER_SIZE } from "./native.ts";
|
|
2
|
+
export type { Ole32, OleAut32, Combase } from "./native.ts";
|
|
3
3
|
export { vtableEntry, functionCache, rawQueryInterface, rawAddRef, rawRelease } from "./vtable.ts";
|
|
4
4
|
export { executorCall, executorGeneration } from "../executor/executor.ts";
|
|
5
5
|
export type { CallOptions, NativeCall, NativeResult } from "../executor/executor.ts";
|
package/dist/low-level/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ole32, oleaut32, allocBSTR, readBSTR, takeBSTR, takeCoTaskMemString, readMemory, writeMemory, isWindows, POINTER_SIZE } from "./native.js";
|
|
1
|
+
export { ole32, oleaut32, combase, allocBSTR, readBSTR, takeBSTR, takeCoTaskMemString, readMemory, writeMemory, isWindows, POINTER_SIZE } from "./native.js";
|
|
2
2
|
export { vtableEntry, functionCache, rawQueryInterface, rawAddRef, rawRelease } from "./vtable.js";
|
|
3
3
|
export { executorCall, executorGeneration } from "../executor/executor.js";
|
|
4
4
|
export { COSERVERINFO, MULTI_QI } from "./types.js";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as ctypes from "node-ctypes";
|
|
2
2
|
export declare const POINTER_SIZE: number;
|
|
3
3
|
export declare const isWindows: boolean;
|
|
4
|
+
/** Whether `type` is a `node-ctypes` `Structure` or `Union` class. */
|
|
5
|
+
export declare function isAggregateClass(type: unknown): type is new (...args: any[]) => ctypes.CDataAggregate;
|
|
6
|
+
/** Whether `type` is a `node-ctypes` `POINTER(T)` class/definition. */
|
|
7
|
+
export declare function isPointerType(type: unknown): type is ctypes.PointerTypeDef;
|
|
4
8
|
declare function bindOle32(library: ctypes.WinDLL): {
|
|
5
9
|
CoInitializeEx: ctypes.TypedFFIFunction<readonly [ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"uint32">], ctypes.SimpleCDataConstructor<"int32">>;
|
|
6
10
|
CoUninitialize: ctypes.TypedFFIFunction<readonly [], null>;
|
|
@@ -22,6 +26,12 @@ declare function bindOle32(library: ctypes.WinDLL): {
|
|
|
22
26
|
CoWaitForMultipleHandles: ctypes.TypedFFIFunction<readonly [ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"pointer">], ctypes.SimpleCDataConstructor<"int32">>;
|
|
23
27
|
CoRegisterClassObject: ctypes.TypedFFIFunction<readonly [ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"pointer">], ctypes.SimpleCDataConstructor<"int32">>;
|
|
24
28
|
CoRevokeClassObject: ctypes.TypedFFIFunction<readonly [ctypes.SimpleCDataConstructor<"uint32">], ctypes.SimpleCDataConstructor<"int32">>;
|
|
29
|
+
CoCreateFreeThreadedMarshaler: ctypes.TypedFFIFunction<readonly [ctypes.SimpleCDataConstructor<"pointer">, ctypes.SimpleCDataConstructor<"pointer">], ctypes.SimpleCDataConstructor<"int32">>;
|
|
30
|
+
};
|
|
31
|
+
declare function bindCombase(library: ctypes.WinDLL): {
|
|
32
|
+
GetRestrictedErrorInfo: ctypes.TypedFFIFunction<readonly [ctypes.SimpleCDataConstructor<"pointer">], ctypes.SimpleCDataConstructor<"int32">>;
|
|
33
|
+
SetRestrictedErrorInfo: ctypes.TypedFFIFunction<readonly [ctypes.SimpleCDataConstructor<"pointer">], ctypes.SimpleCDataConstructor<"int32">>;
|
|
34
|
+
RoOriginateErrorW: ctypes.TypedFFIFunction<readonly [ctypes.SimpleCDataConstructor<"int32">, ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"wstring">], ctypes.SimpleCDataConstructor<"int32">>;
|
|
25
35
|
};
|
|
26
36
|
declare function bindOleAut32(library: ctypes.WinDLL): {
|
|
27
37
|
GetErrorInfo: ctypes.TypedFFIFunction<readonly [ctypes.SimpleCDataConstructor<"uint32">, ctypes.SimpleCDataConstructor<"pointer">], ctypes.SimpleCDataConstructor<"int32">>;
|
|
@@ -60,10 +70,13 @@ declare function bindOleAut32(library: ctypes.WinDLL): {
|
|
|
60
70
|
};
|
|
61
71
|
export type Ole32 = ReturnType<typeof bindOle32>;
|
|
62
72
|
export type OleAut32 = ReturnType<typeof bindOleAut32>;
|
|
73
|
+
export type Combase = ReturnType<typeof bindCombase>;
|
|
63
74
|
/** ole32.dll functions, loaded on first use. */
|
|
64
75
|
export declare function ole32(): Ole32;
|
|
65
76
|
/** oleaut32.dll functions, loaded on first use. */
|
|
66
77
|
export declare function oleaut32(): OleAut32;
|
|
78
|
+
/** combase.dll functions (WinRT / restricted error info), loaded on first use; `null` if unavailable. */
|
|
79
|
+
export declare function combase(): Combase | null;
|
|
67
80
|
/** Allocate a BSTR (embedded NULs preserved). Free it with `SysFreeString`. */
|
|
68
81
|
export declare function allocBSTR(text: string): bigint;
|
|
69
82
|
/** Read a BSTR without freeing it (`null` for a NULL BSTR, which COM treats as ""). */
|
|
@@ -80,6 +93,16 @@ export declare function copyStruct<T>(type: new (...args: any[]) => T, address:
|
|
|
80
93
|
export declare function readMemory(address: bigint, size: number): Buffer;
|
|
81
94
|
/** Copy `data` to native memory at `address`. */
|
|
82
95
|
export declare function writeMemory(address: bigint, data: Uint8Array): void;
|
|
96
|
+
/**
|
|
97
|
+
* Copy current native bytes into `buffer` when external buffers are disabled
|
|
98
|
+
* (`NODE_CTYPES_NO_EXTERNAL_BUFFERS=1` / Electron). No-op when `EXTERNAL_BUFFERS` is true.
|
|
99
|
+
*/
|
|
100
|
+
export declare function refreshMirror(buffer: Buffer): void;
|
|
101
|
+
/**
|
|
102
|
+
* Copy bytes from `buffer` back to native memory when external buffers are disabled
|
|
103
|
+
* (`NODE_CTYPES_NO_EXTERNAL_BUFFERS=1` / Electron). No-op when `EXTERNAL_BUFFERS` is true.
|
|
104
|
+
*/
|
|
105
|
+
export declare function flushMirror(buffer: Buffer): void;
|
|
83
106
|
/** Read a CoTaskMem-allocated wide string and free it. */
|
|
84
107
|
export declare function takeCoTaskMemString(pointer: bigint | null): string | null;
|
|
85
108
|
export {};
|