@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.
Files changed (54) hide show
  1. package/README.md +50 -624
  2. package/dist/automation/dispatch.js +10 -3
  3. package/dist/automation/record.js +3 -1
  4. package/dist/automation/variant.d.ts +4 -4
  5. package/dist/automation/variant.js +102 -29
  6. package/dist/client/dynamic.js +7 -8
  7. package/dist/client/events.js +18 -2
  8. package/dist/client/index.js +3 -1
  9. package/dist/commethod.d.ts +1 -1
  10. package/dist/commethod.js +151 -57
  11. package/dist/errorinfo.d.ts +10 -3
  12. package/dist/errorinfo.js +66 -18
  13. package/dist/errors.d.ts +7 -1
  14. package/dist/executor/apartment.d.ts +7 -3
  15. package/dist/executor/apartment.js +65 -29
  16. package/dist/executor/executor.d.ts +2 -0
  17. package/dist/executor/executor.js +65 -14
  18. package/dist/guid.d.ts +1 -1
  19. package/dist/guid.js +15 -10
  20. package/dist/index.d.ts +5 -5
  21. package/dist/index.js +4 -4
  22. package/dist/interfaces/agile.d.ts +52 -0
  23. package/dist/interfaces/agile.js +59 -0
  24. package/dist/interfaces/errorinfo.d.ts +8 -0
  25. package/dist/interfaces/errorinfo.js +10 -0
  26. package/dist/interfaces/index.d.ts +2 -1
  27. package/dist/interfaces/index.js +2 -1
  28. package/dist/interfaces/typeinfo.js +3 -0
  29. package/dist/low-level/iids.d.ts +14 -0
  30. package/dist/low-level/iids.js +14 -0
  31. package/dist/low-level/index.d.ts +2 -2
  32. package/dist/low-level/index.js +1 -1
  33. package/dist/low-level/native.d.ts +23 -0
  34. package/dist/low-level/native.js +53 -0
  35. package/dist/low-level/registry.js +4 -2
  36. package/dist/low-level/vtable.d.ts +10 -0
  37. package/dist/low-level/vtable.js +32 -5
  38. package/dist/pointer.d.ts +2 -0
  39. package/dist/pointer.js +154 -84
  40. package/dist/pump.d.ts +32 -8
  41. package/dist/pump.js +87 -15
  42. package/dist/runtime.d.ts +6 -0
  43. package/dist/runtime.js +15 -1
  44. package/dist/server/automation.js +3 -3
  45. package/dist/server/comobject.d.ts +53 -0
  46. package/dist/server/comobject.js +319 -27
  47. package/dist/server/index.d.ts +1 -1
  48. package/dist/server/index.js +1 -1
  49. package/dist/server/marshal.d.ts +1 -0
  50. package/dist/server/marshal.js +16 -8
  51. package/dist/server/register.js +8 -6
  52. package/dist/tracking.d.ts +2 -0
  53. package/dist/tracking.js +13 -0
  54. package/package.json +6 -2
@@ -2,7 +2,7 @@ import * as ctypes from "node-ctypes";
2
2
  import { COMError, systemMessage } from "../errors.js";
3
3
  import { GUID_NULL } from "../guid.js";
4
4
  import { DISP_E_EXCEPTION, DISP_E_PARAMNOTFOUND, DISP_E_TYPEMISMATCH, DISP_E_UNKNOWNNAME } from "../hresult.js";
5
- import { POINTER_SIZE, takeBSTR } from "../low-level/native.js";
5
+ import { POINTER_SIZE, flushMirror, refreshMirror, takeBSTR } from "../low-level/native.js";
6
6
  import { DISPATCH_PROPERTYPUT, DISPATCH_PROPERTYPUTREF, DISPID_PROPERTYPUT, LOCALE_NEUTRAL } from "./constants.js";
7
7
  import { DISPPARAMS, EXCEPINFO } from "./types.js";
8
8
  import { ByRef, VARIANT, VARIANT_SIZE, byRefArgument, clearVariant, missing, readVariant, writeVariant } from "./variant.js";
@@ -14,7 +14,11 @@ export function setDefaultLCID(lcid) {
14
14
  defaultLCID = lcid >>> 0;
15
15
  }
16
16
  function wideStrings(values) {
17
- const keep = values.map((value) => Buffer.from(`${value}\0`, "utf16le"));
17
+ const keep = values.map((value) => {
18
+ const buffer = Buffer.from(`${value}\0`, "utf16le");
19
+ flushMirror(buffer);
20
+ return buffer;
21
+ });
18
22
  const pointers = Buffer.alloc(POINTER_SIZE * values.length);
19
23
  keep.forEach((buffer, index) => {
20
24
  const address = ctypes.addressof(buffer);
@@ -47,8 +51,10 @@ export function getIDsOfNames(dispatch, names, lcid = defaultLCID) {
47
51
  }
48
52
  const DeferredFillIn = ctypes.WINFUNCTYPE(ctypes.c_int32, ctypes.c_void_p);
49
53
  function exceptionError(info, method, cause) {
50
- if (info.pfnDeferredFillIn)
54
+ if (info.pfnDeferredFillIn) {
51
55
  DeferredFillIn(info.pfnDeferredFillIn)(info._buffer);
56
+ refreshMirror(info._buffer);
57
+ }
52
58
  const source = takeBSTR(info.bstrSource);
53
59
  // Some servers (e.g. the Scripting runtime) set only the scode.
54
60
  const description = takeBSTR(info.bstrDescription) || (info.scode ? systemMessage(info.scode) : null);
@@ -77,6 +83,7 @@ function prepareInvoke(dispid, flags, args, options) {
77
83
  const variants = Buffer.alloc(VARIANT_SIZE * count);
78
84
  const dispids = Buffer.alloc(4 * namedDispids.length);
79
85
  namedDispids.forEach((id, index) => dispids.writeInt32LE(id, index * 4));
86
+ flushMirror(dispids);
80
87
  const method = `IDispatch::Invoke(${options.name ?? `DISPID ${dispid}`})`;
81
88
  const result = new VARIANT();
82
89
  const info = new EXCEPINFO();
@@ -6,6 +6,7 @@ import { IUnknown } from "../interfaces/unknown.js";
6
6
  import { oleaut32, POINTER_SIZE, takeBSTR } from "../low-level/native.js";
7
7
  import { functionCache, vtableEntry } from "../low-level/vtable.js";
8
8
  import { COMPointer } from "../pointer.js";
9
+ import { onApartmentTeardown } from "../tracking.js";
9
10
  import { recordTypeInfoOf } from "../typelib/coclass.js";
10
11
  import { VARIANT_SIZE, clearVariant, readVariant, writeVariant } from "./variant.js";
11
12
  // User-defined types (VT_RECORD) through IRecordInfo, called by vtable slot
@@ -21,8 +22,9 @@ const CreateAt = functionCache(() => ctypes.WINFUNCTYPE(c_void_p, c_void_p));
21
22
  /** The `IRecordInfo` of a value read from a `VT_RECORD`, kept for writing it back. */
22
23
  export const recordInfo = Symbol.for("node-comtypes.recordInfo");
23
24
  // IRecordInfo address -> wrapper. Record infos are per type (oleaut32 caches
24
- // them), so this stays small; the pointers are released with the apartment.
25
+ // them), so this stays small; cleared on apartment teardown before CoUninitialize.
25
26
  const shared = new Map();
27
+ onApartmentTeardown(() => shared.clear());
26
28
  /** A user-defined type described by `IRecordInfo`. */
27
29
  export class RecordInfo {
28
30
  /** Owned `IRecordInfo` reference. */
@@ -118,10 +118,10 @@ export declare class VARIANT extends ctypes.Structure {
118
118
  wReserved2: number;
119
119
  wReserved3: number;
120
120
  /**
121
- * `new VARIANT(value)` converts `value`. As for any node-ctypes structure, a
122
- * `Buffer` (or a plain object of fields) is wrapped instead: node-ctypes
123
- * builds views (`from_address`, callback arguments) this way. Use
124
- * {@link VARIANT.from} to convert a `Buffer` into a `VT_ARRAY | VT_UI1`.
121
+ * `new VARIANT(value)` converts `value`. A `Buffer` is wrapped instead (a
122
+ * view of its bytes, as `VARIANT.from_buffer`), and a plain object of fields
123
+ * initializes the structure. Use {@link VARIANT.from} to convert a `Buffer`
124
+ * into a `VT_ARRAY | VT_UI1`.
125
125
  */
126
126
  constructor(value?: unknown);
127
127
  /** A new VARIANT holding `value`, whatever its type (`Buffer` included). */
@@ -3,7 +3,8 @@ import { checkHRESULT } from "../errors.js";
3
3
  import { GUID } from "../guid.js";
4
4
  import { DISP_E_PARAMNOTFOUND } from "../hresult.js";
5
5
  import { derivesFrom, findInterface } from "../interface.js";
6
- import { allocBSTR, oleaut32, POINTER_SIZE, readBSTR, readMemory, writeMemory } from "../low-level/native.js";
6
+ import { IID_IDispatch, IID_IUnknown } from "../low-level/iids.js";
7
+ import { allocBSTR, flushMirror, oleaut32, POINTER_SIZE, readBSTR, readMemory, refreshMirror, writeMemory } from "../low-level/native.js";
7
8
  import { rawAddRef, rawQueryInterface, rawRelease } from "../low-level/vtable.js";
8
9
  import { RecordInfo, recordParts } from "./record.js";
9
10
  import { COMPointer, setArgumentInspector, sharedWithExecutor } from "../pointer.js";
@@ -14,8 +15,6 @@ import { currencyToString, readDecimal, writeDecimal } from "./decimal.js";
14
15
  /** Size of a VARIANT: 16 bytes on 32-bit Windows, 24 on 64-bit. */
15
16
  export const VARIANT_SIZE = 8 + 2 * POINTER_SIZE;
16
17
  const DATA = 8;
17
- const IID_IUnknown = new GUID("{00000000-0000-0000-C000-000000000046}");
18
- const IID_IDispatch = new GUID("{00020400-0000-0000-C000-000000000046}");
19
18
  /**
20
19
  * Objects exposing a COM pointer under this symbol (e.g. dynamic dispatch
21
20
  * proxies) are converted like that pointer.
@@ -95,6 +94,7 @@ export function writeReference(address, vt, value) {
95
94
  else {
96
95
  writeDecimal(view._buffer, 0, value);
97
96
  view._buffer.writeUInt16LE(0, 0);
97
+ flushMirror(view._buffer);
98
98
  }
99
99
  return;
100
100
  }
@@ -244,6 +244,7 @@ function readScalar(vt, buffer, offset) {
244
244
  }
245
245
  /** Convert the VARIANT in `buffer` to a JavaScript value. COM objects are returned as new owned pointers. */
246
246
  export function readVariant(buffer) {
247
+ refreshMirror(buffer);
247
248
  const vt = buffer.readUInt16LE(0);
248
249
  // VT_RECORD (also by reference): pvRecord and pRecInfo.
249
250
  if ((vt & ~VT_BYREF) === VT_RECORD) {
@@ -270,6 +271,7 @@ export function readVariant(buffer) {
270
271
  }
271
272
  /** Exact text of a `VT_DECIMAL` or `VT_CY` VARIANT (the `value` getter returns a number). */
272
273
  export function readVariantExact(buffer) {
274
+ refreshMirror(buffer);
273
275
  const vt = buffer.readUInt16LE(0);
274
276
  if (vt === VT_DECIMAL)
275
277
  return readDecimal(buffer, 0);
@@ -313,9 +315,65 @@ export function readSafeArray(psa, vtHint = VT_VARIANT) {
313
315
  finally {
314
316
  api.SafeArrayUnaccessData(psa);
315
317
  }
318
+ if (dimensions <= 1) {
319
+ const length = lengths[0] ?? 0;
320
+ if (records)
321
+ return records;
322
+ const out = new Array(length);
323
+ switch (vt) {
324
+ case VT_UI1:
325
+ for (let i = 0; i < length; i++)
326
+ out[i] = bytes[i];
327
+ return out;
328
+ case VT_I1:
329
+ for (let i = 0; i < length; i++)
330
+ out[i] = bytes.readInt8(i);
331
+ return out;
332
+ case VT_I2:
333
+ for (let i = 0; i < length; i++)
334
+ out[i] = bytes.readInt16LE(i * 2);
335
+ return out;
336
+ case VT_UI2:
337
+ for (let i = 0; i < length; i++)
338
+ out[i] = bytes.readUInt16LE(i * 2);
339
+ return out;
340
+ case VT_I4:
341
+ case VT_INT:
342
+ for (let i = 0; i < length; i++)
343
+ out[i] = bytes.readInt32LE(i * 4);
344
+ return out;
345
+ case VT_UI4:
346
+ case VT_UINT:
347
+ for (let i = 0; i < length; i++)
348
+ out[i] = bytes.readUInt32LE(i * 4);
349
+ return out;
350
+ case VT_R4:
351
+ for (let i = 0; i < length; i++)
352
+ out[i] = bytes.readFloatLE(i * 4);
353
+ return out;
354
+ case VT_R8:
355
+ for (let i = 0; i < length; i++)
356
+ out[i] = bytes.readDoubleLE(i * 8);
357
+ return out;
358
+ case VT_I8:
359
+ for (let i = 0; i < length; i++)
360
+ out[i] = bytes.readBigInt64LE(i * 8);
361
+ return out;
362
+ case VT_UI8:
363
+ for (let i = 0; i < length; i++)
364
+ out[i] = bytes.readBigUInt64LE(i * 8);
365
+ return out;
366
+ case VT_BOOL:
367
+ for (let i = 0; i < length; i++)
368
+ out[i] = bytes.readInt16LE(i * 2) !== 0;
369
+ return out;
370
+ default:
371
+ for (let i = 0; i < length; i++)
372
+ out[i] = readScalar(vt, bytes, i * size);
373
+ return out;
374
+ }
375
+ }
316
376
  const element = (index) => (records ? records[index] : readScalar(vt, bytes, index * size));
317
- if (dimensions <= 1)
318
- return Array.from({ length: lengths[0] ?? 0 }, (_, index) => element(index));
319
377
  // Column-major storage: the first index varies fastest.
320
378
  const build = (dimension, base, stride) => {
321
379
  const length = lengths[dimension];
@@ -534,6 +592,7 @@ export function writeVariant(buffer, value) {
534
592
  throw new TypeError("byRef() values are IDispatch arguments, not VARIANT values");
535
593
  if (value instanceof VARIANT) {
536
594
  checkHRESULT(oleaut32().VariantCopy(buffer, value._buffer), "VariantCopy");
595
+ refreshMirror(buffer);
537
596
  return;
538
597
  }
539
598
  const vt = inferVartype(value);
@@ -565,6 +624,7 @@ export function writeVariant(buffer, value) {
565
624
  writeScalar(vt, buffer, DATA, payload);
566
625
  }
567
626
  buffer.writeUInt16LE(vt, 0);
627
+ flushMirror(buffer);
568
628
  }
569
629
  function shapeOf(values, dimensions) {
570
630
  const shape = [];
@@ -593,29 +653,34 @@ export function createSafeArray(vt, values, dimensions = 1) {
593
653
  throw new TypeError(`SafeArrayCreate failed for ${vartypeName(VT_ARRAY | vt)}`);
594
654
  const size = elementSize(vt);
595
655
  const count = shape.reduce((total, length) => total * length, 1);
596
- const data = Buffer.alloc(count * size);
597
656
  const target = new ctypes.c_void_p();
598
657
  checkHRESULT(api.SafeArrayAccessData(psa, ctypes.byref(target)), "SafeArrayAccessData");
599
- let filled = false;
600
- try {
601
- if (dimensions === 1 && ArrayBuffer.isView(values) && typedArrayVartype(values) === vt) {
602
- data.set(new Uint8Array(values.buffer, values.byteOffset, values.byteLength));
658
+ // Fast path: 1-D TypedArray with matching VARTYPE copies directly into SAFEARRAY memory (zero intermediate Buffer).
659
+ if (dimensions === 1 && ArrayBuffer.isView(values) && typedArrayVartype(values) === vt) {
660
+ try {
661
+ writeMemory(target.value ?? 0n, new Uint8Array(values.buffer, values.byteOffset, values.byteLength));
603
662
  }
604
- else {
605
- // Column-major storage: the first index varies fastest.
606
- const fill = (level, dimension, base, stride) => {
607
- if (!isList(level) || level.length !== shape[dimension])
608
- throw new TypeError("SAFEARRAY values must be rectangular");
609
- for (let index = 0; index < level.length; index++) {
610
- const flat = base + index * stride;
611
- if (dimension === dimensions - 1)
612
- writeScalar(vt, data, flat * size, level[index]);
613
- else
614
- fill(level[index], dimension + 1, flat, stride * shape[dimension]);
615
- }
616
- };
617
- fill(values, 0, 0, 1);
663
+ finally {
664
+ api.SafeArrayUnaccessData(psa);
618
665
  }
666
+ return psa;
667
+ }
668
+ const data = Buffer.alloc(count * size);
669
+ let filled = false;
670
+ try {
671
+ // Column-major storage: the first index varies fastest.
672
+ const fill = (level, dimension, base, stride) => {
673
+ if (!isList(level) || level.length !== shape[dimension])
674
+ throw new TypeError("SAFEARRAY values must be rectangular");
675
+ for (let index = 0; index < level.length; index++) {
676
+ const flat = base + index * stride;
677
+ if (dimension === dimensions - 1)
678
+ writeScalar(vt, data, flat * size, level[index]);
679
+ else
680
+ fill(level[index], dimension + 1, flat, stride * shape[dimension]);
681
+ }
682
+ };
683
+ fill(values, 0, 0, 1);
619
684
  filled = true;
620
685
  }
621
686
  finally {
@@ -675,9 +740,11 @@ export function destroySafeArray(psa) {
675
740
  }
676
741
  /** Release the resources of the VARIANT in `buffer` (`VariantClear`) and reset it to `VT_EMPTY`. */
677
742
  export function clearVariant(buffer) {
743
+ refreshMirror(buffer);
678
744
  if (needsClear(buffer.readUInt16LE(0)))
679
745
  checkHRESULT(oleaut32().VariantClear(buffer), "VariantClear");
680
746
  buffer.fill(0, 0, VARIANT_SIZE);
747
+ flushMirror(buffer);
681
748
  }
682
749
  // ── VARIANT ───────────────────────────────────────────────────────────
683
750
  /**
@@ -710,13 +777,17 @@ export class VARIANT extends ctypes.Structure {
710
777
  ["data", ctypes.array(ctypes.c_uint64, POINTER_SIZE === 8 ? 2 : 1)],
711
778
  ];
712
779
  /**
713
- * `new VARIANT(value)` converts `value`. As for any node-ctypes structure, a
714
- * `Buffer` (or a plain object of fields) is wrapped instead: node-ctypes
715
- * builds views (`from_address`, callback arguments) this way. Use
716
- * {@link VARIANT.from} to convert a `Buffer` into a `VT_ARRAY | VT_UI1`.
780
+ * `new VARIANT(value)` converts `value`. A `Buffer` is wrapped instead (a
781
+ * view of its bytes, as `VARIANT.from_buffer`), and a plain object of fields
782
+ * initializes the structure. Use {@link VARIANT.from} to convert a `Buffer`
783
+ * into a `VT_ARRAY | VT_UI1`.
717
784
  */
718
785
  constructor(value) {
719
- if (Buffer.isBuffer(value) || (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype && !recordParts(value))) {
786
+ if (Buffer.isBuffer(value)) {
787
+ // node-ctypes (as CPython) reads a positional Buffer as a field value: build the view explicitly.
788
+ return VARIANT.from_buffer(value);
789
+ }
790
+ if (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype && !recordParts(value)) {
720
791
  super(value);
721
792
  return;
722
793
  }
@@ -757,12 +828,14 @@ export class VARIANT extends ctypes.Structure {
757
828
  checkHRESULT(api.VariantChangeType(this._buffer, this._buffer, flags, vt), "VariantChangeType");
758
829
  else
759
830
  checkHRESULT(api.VariantChangeTypeEx(this._buffer, this._buffer, lcid, flags, vt), "VariantChangeTypeEx");
831
+ refreshMirror(this._buffer);
760
832
  return this;
761
833
  }
762
834
  /** Deep copy (`VariantCopy`). */
763
835
  copy() {
764
836
  const copy = new VARIANT();
765
837
  checkHRESULT(oleaut32().VariantCopy(copy._buffer, this._buffer), "VariantCopy");
838
+ refreshMirror(copy._buffer);
766
839
  return copy;
767
840
  }
768
841
  [Symbol.dispose]() {
@@ -174,25 +174,24 @@ function isObject(value) {
174
174
  function getMember(current, name, synchronous) {
175
175
  const dispid = dispidOf(current, name);
176
176
  const member = memberOf(current, dispid);
177
- const syncCaller = (...args) => call(current, name, dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET, args);
178
- // Methods run on the COM executor (synchronously on a sync() view).
179
- const caller = synchronous ? syncCaller : (...args) => callAsync(current, name, dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET, args);
180
177
  if (member) {
181
178
  if (member.get && member.getArguments === 0)
182
179
  return call(current, name, dispid, DISPATCH_PROPERTYGET, []);
183
- if (member.method)
184
- return caller;
180
+ if (member.method) {
181
+ return synchronous ? (...args) => call(current, name, dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET, args) : (...args) => callAsync(current, name, dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET, args);
182
+ }
185
183
  // A parameterized property: read synchronously.
186
184
  if (member.get)
187
- return syncCaller;
185
+ return (...args) => call(current, name, dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET, args);
188
186
  return undefined;
189
187
  }
190
188
  try {
191
189
  return call(current, name, dispid, DISPATCH_PROPERTYGET, []);
192
190
  }
193
191
  catch (error) {
194
- if (error instanceof COMError && BAD_CONTEXT.has(error.hresult))
195
- return caller;
192
+ if (error instanceof COMError && BAD_CONTEXT.has(error.hresult)) {
193
+ return synchronous ? (...args) => call(current, name, dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET, args) : (...args) => callAsync(current, name, dispid, DISPATCH_METHOD | DISPATCH_PROPERTYGET, args);
194
+ }
196
195
  throw error;
197
196
  }
198
197
  }
@@ -64,6 +64,7 @@ import { IDispatch } from "../interfaces/dispatch.js";
64
64
  import { IProvideClassInfo, ITypeInfo, ITypeLib } from "../interfaces/typeinfo.js";
65
65
  import { IUnknown } from "../interfaces/unknown.js";
66
66
  import { COMPointer, sync } from "../pointer.js";
67
+ import { onApartmentTeardown } from "../tracking.js";
67
68
  import { COMObject } from "../server/comobject.js";
68
69
  function sourcePointer(source) {
69
70
  const borrowed = borrowReference(source);
@@ -268,6 +269,17 @@ function sinkClassFor(definition) {
268
269
  sinkClasses.set(definition, type);
269
270
  return type;
270
271
  }
272
+ const activeConnections = new Set();
273
+ onApartmentTeardown(() => {
274
+ for (const disconnect of [...activeConnections]) {
275
+ try {
276
+ disconnect();
277
+ }
278
+ catch {
279
+ // Keep tearing down remaining connections.
280
+ }
281
+ }
282
+ });
271
283
  /**
272
284
  * Connect `handler` to the events of `source`. Python equivalent:
273
285
  * `comtypes.client.GetEvents`.
@@ -302,13 +314,17 @@ export function GetEvents(source, handler, options = {}) {
302
314
  if (!connected)
303
315
  return;
304
316
  connected = false;
317
+ activeConnections.delete(disconnect);
305
318
  try {
306
- sync(point).Unadvise(cookie);
319
+ if (!point.released)
320
+ sync(point).Unadvise(cookie);
307
321
  }
308
322
  finally {
309
- point.Release();
323
+ if (!point.released)
324
+ point.Release();
310
325
  }
311
326
  };
327
+ activeConnections.add(disconnect);
312
328
  return {
313
329
  cookie,
314
330
  interface: definition,
@@ -61,7 +61,7 @@ import { GUID } from "../guid.js";
61
61
  import { E_POINTER } from "../hresult.js";
62
62
  import { IDispatch } from "../interfaces/dispatch.js";
63
63
  import { IUnknown } from "../interfaces/unknown.js";
64
- import { ole32, oleaut32 } from "../low-level/native.js";
64
+ import { flushMirror, ole32, oleaut32 } from "../low-level/native.js";
65
65
  import { COSERVERINFO, MULTI_QI } from "../low-level/types.js";
66
66
  import { COMPointer, sync as syncPointer } from "../pointer.js";
67
67
  import { CoCreateInstance, CoCreateInstanceEx } from "../runtime.js";
@@ -168,8 +168,10 @@ function obtainHome(method, call) {
168
168
  /** `CoCreateInstanceEx` for `IUnknown` on the executor (remote machines). */
169
169
  function createInstanceEx(target, clsid, clsctx, machine, out) {
170
170
  const name = ctypes.create_unicode_buffer(machine);
171
+ flushMirror(name);
171
172
  const server = new COSERVERINFO();
172
173
  server.pwszName = ctypes.addressof(name);
174
+ flushMirror(IUnknown.iid._buffer);
173
175
  const result = new MULTI_QI();
174
176
  result.pIID = ctypes.addressof(IUnknown.iid);
175
177
  return ole32()
@@ -167,7 +167,7 @@ export type ParamKind = {
167
167
  readonly kind: "variant";
168
168
  } | {
169
169
  readonly kind: "struct";
170
- readonly type: new (...args: any[]) => ctypes.Structure;
170
+ readonly type: new (...args: any[]) => ctypes.CDataAggregate;
171
171
  } | {
172
172
  readonly kind: "simple";
173
173
  readonly type: ctypes.SimpleCDataConstructor;