From 465116ce9eb42c2519dc9246cef0bc60976ea9e1 Mon Sep 17 00:00:00 2001 From: Halil Durmus Date: Thu, 25 Apr 2024 13:44:16 +0300 Subject: [PATCH] Fix the Dart representation of the `PROPVARIANT` structure (#845) --- CHANGELOG.md | 10 + analysis_options.yaml | 2 +- example/wasapi.dart | 8 +- lib/src/macros.dart | 11 + lib/src/structs.g.dart | 206 ++++++++++ lib/src/types.dart | 1 + lib/src/variant.dart | 487 +++++++++++++++++++++++- lib/src/win32/ole32.g.dart | 14 + pubspec.yaml | 6 +- test/api_test.dart | 7 + tool/struct_sizes/struct_sizes.cpp | 25 ++ tool/win32gen/analysis_options.yaml | 2 +- tool/win32gen/data/win32_functions.json | 4 + tool/win32gen/data/win32_structs.json | 25 ++ tool/win32gen/pubspec.yaml | 20 +- tool/win32gen/test/helpers.dart | 11 +- 16 files changed, 808 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf9a1d5da..f54d3f9f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 5.5.0-wip + +- Add `BLOB`, `BSTRBLOB`, `CABOOL`, `CABSTR`, `CABSTRBLOB`, `CAC`, `CACLIPDATA`, + `CACLSID`, `CACY`, `CADATE`, `CADBL`, `CAFILETIME`, `CAFLT`, `CAH`, `CAI`, + `CAL`, `CALPSTR`, `CALPWSTR`, `CAPROPVARIANT`, `CASCODE`, `CAUB`, `CAUH`, + `CAUI`, `CAUL`, `CLIPDATA`, and `VERSIONEDSTREAM` structures (#845) +- Add `VARIANT_BOOL` typedef (#845) +- Fix the Dart representation of the `PROPVARIANT` structure (#845) +- Add `PropVariantInit` and `PropVariantClear` APIs (#845) + ## 5.4.0 - Fix constant values `ERROR_SERVICE_NOT_ACTIVE`, `KF_FLAG_ALIAS_ONLY`, diff --git a/analysis_options.yaml b/analysis_options.yaml index 9ca854240..309d2eabb 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:dartwindows_lints/analysis_options.yaml +include: package:lints/recommended.yaml analyzer: exclude: ['example/explorer/**', 'test_fixes/**'] diff --git a/example/wasapi.dart b/example/wasapi.dart index 7c68d3789..9956a647c 100644 --- a/example/wasapi.dart +++ b/example/wasapi.dart @@ -130,12 +130,12 @@ void main() { // Check the retrieved device friendly name. final varName = pVal.ref; if (varName.vt != VARENUM.VT_EMPTY) { - final ptr = Pointer.fromAddress(varName.val1); - final name = ptr.toDartString(); + final bstrVal = varName.bstrVal; + final name = bstrVal.toDartString(); print(" ID: $id Name: $name"); - free(ptr); + SysFreeString(bstrVal); } else { - print(" Unknown device"); + print(' Unknown device'); } free(ppEndpoint); diff --git a/lib/src/macros.dart b/lib/src/macros.dart index 5fb71102d..13def68bb 100644 --- a/lib/src/macros.dart +++ b/lib/src/macros.dart @@ -10,7 +10,10 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; +import 'constants.dart'; import 'enums.g.dart'; +import 'inline.dart'; +import 'variant.dart'; /// Creates a WORD value by concatenating the specified values. // @@ -111,3 +114,11 @@ int CTL_CODE(int DeviceType, int Function, int Method, int Access) => // // #define GET_SC_WPARAM(wParam) ((int)wParam & 0xFFF0) int GET_SC_WPARAM(int wParam) => wParam & 0xFFF0; + +/// The PropVariantInit function initializes a PROPVARIANT structure. +// +// #define PropVariantInit(pvar) memset ( (pvar), 0, sizeof(PROPVARIANT) ) +void PropVariantInit(Pointer pvar) { + ZeroMemory(pvar, sizeOf()); + pvar.ref.vt = VARENUM.VT_EMPTY; +} diff --git a/lib/src/structs.g.dart b/lib/src/structs.g.dart index 3fc990c8e..30380e713 100644 --- a/lib/src/structs.g.dart +++ b/lib/src/structs.g.dart @@ -363,6 +363,17 @@ base class BLENDFUNCTION extends Struct { external int AlphaFormat; } +/// The BLOB structure, derived from Binary Large Object, contains +/// information about a block of data. +/// +/// {@category struct} +base class BLOB extends Struct { + @Uint32() + external int cbSize; + + external Pointer pBlobData; +} + /// The BLUETOOTH_ADDRESS structure provides the address of a Bluetooth /// device. /// @@ -742,6 +753,14 @@ base class BSMINFO extends Struct { external LUID luid; } +/// {@category struct} +base class BSTRBLOB extends Struct { + @Uint32() + external int cbSize; + + external Pointer pData; +} + /// The BTH_DEVICE_INFO structure stores information about a Bluetooth /// device. /// @@ -1180,6 +1199,38 @@ base class BY_HANDLE_FILE_INFORMATION extends Struct { external int nFileIndexLow; } +/// {@category struct} +base class CABOOL extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CABSTR extends Struct { + @Uint32() + external int cElems; + + external Pointer> pElems; +} + +/// {@category struct} +base class CABSTRBLOB extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAC extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + /// Describes the cache attributes. /// /// {@category struct} @@ -1200,6 +1251,150 @@ base class CACHE_DESCRIPTOR extends Struct { external int Type; } +/// {@category struct} +base class CACLIPDATA extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CACLSID extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CACY extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CADATE extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CADBL extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAFILETIME extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAFLT extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAH extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAI extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAL extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CALPSTR extends Struct { + @Uint32() + external int cElems; + + external Pointer> pElems; +} + +/// {@category struct} +base class CALPWSTR extends Struct { + @Uint32() + external int cElems; + + external Pointer> pElems; +} + +/// {@category struct} +base class CAPROPVARIANT extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CASCODE extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAUB extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAUH extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAUI extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + +/// {@category struct} +base class CAUL extends Struct { + @Uint32() + external int cElems; + + external Pointer pElems; +} + /// Contains information passed to a WH_CBT hook procedure, CBTProc, before /// a window is activated. /// @@ -1434,6 +1629,17 @@ base class CLIENT_ID extends Struct { external int UniqueThread; } +/// {@category struct} +base class CLIPDATA extends Struct { + @Uint32() + external int cbSize; + + @Int32() + external int ulClipFmt; + + external Pointer pClipData; +} + /// The COLORADJUSTMENT structure defines the color adjustment values used /// by the StretchBlt and StretchDIBits functions when the stretch mode is /// HALFTONE. You can set the color adjustment values by calling the diff --git a/lib/src/types.dart b/lib/src/types.dart index c0d1971b9..e4ba93529 100644 --- a/lib/src/types.dart +++ b/lib/src/types.dart @@ -87,6 +87,7 @@ typedef ULONG64 = Uint64; typedef ULONGLONG = Uint64; typedef ULONG_PTR = IntPtr; typedef USHORT = Uint16; +typedef VARIANT_BOOL = Int16; typedef WCHAR = Uint16; typedef WORD = Uint16; typedef WPARAM = UINT_PTR; diff --git a/lib/src/variant.dart b/lib/src/variant.dart index e0a40c4ee..6564f79b4 100644 --- a/lib/src/variant.dart +++ b/lib/src/variant.dart @@ -4,7 +4,7 @@ // Dart representations of COM variant structs used in the Win32 API. -// ignore_for_file: camel_case_types +// ignore_for_file: camel_case_extensions, camel_case_types // ignore_for_file: constant_identifier_names, non_constant_identifier_names import 'dart:ffi'; @@ -15,7 +15,9 @@ import 'com/idispatch.dart'; import 'com/iunknown.dart'; import 'combase.dart'; import 'constants.dart'; +import 'guid.dart'; import 'structs.g.dart'; +import 'types.dart'; import 'win32/oleaut32.g.dart'; // struct tagVARIANT @@ -402,22 +404,491 @@ base class VARIANT extends Struct { .__VARIANT_NAME_3.__VARIANT_NAME_4.pRecInfo = value.ref.lpVtbl; } -/// The PROPVARIANT structure is used in the ReadMultiple and WriteMultiple -/// methods of IPropertyStorage to define the type tag and the value of a -/// property in a property set. +/// Used in the ReadMultiple and WriteMultiple methods of IPropertyStorage to +/// define the type tag and the value of a property in a property set. +/// +/// To learn more about this struct, see +/// . /// /// {@category struct} base class PROPVARIANT extends Struct { + external PROPVARIANT_0 Anonymous; +} + +sealed class PROPVARIANT_0 extends Union { + external PROPVARIANT_0_0 Anonymous; + + external DECIMAL decVal; +} + +extension PROPVARIANT_0_Extension on PROPVARIANT { + PROPVARIANT_0_0 get Anonymous => this.Anonymous.Anonymous; + set Anonymous(PROPVARIANT_0_0 value) => this.Anonymous.Anonymous = value; + + DECIMAL get decVal => this.Anonymous.decVal; + set decVal(DECIMAL value) => this.Anonymous.decVal = value; +} + +sealed class PROPVARIANT_0_0 extends Struct { @Uint16() external int vt; + @Uint16() external int wReserved1; + @Uint16() external int wReserved2; + @Uint16() external int wReserved3; - @IntPtr() - external int val1; - @IntPtr() - external int val2; + + external PROPVARIANT_0_0_0 Anonymous; +} + +extension PROPVARIANT_0_0_Extension on PROPVARIANT { + int get vt => this.Anonymous.Anonymous.vt; + set vt(int value) => this.Anonymous.Anonymous.vt = value; + + PROPVARIANT_0_0_0 get Anonymous => this.Anonymous.Anonymous.Anonymous; + set Anonymous(PROPVARIANT_0_0_0 value) => + this.Anonymous.Anonymous.Anonymous = value; +} + +sealed class PROPVARIANT_0_0_0 extends Union { + @Int8() + external int cVal; + + @Uint8() + external int bVal; + + @Int16() + external int iVal; + + @Uint16() + external int uiVal; + + @Int32() + external int lVal; + + @Uint32() + external int ulVal; + + @Int32() + external int intVal; + + @Uint32() + external int uintVal; + + @Int64() + external int hVal; + + @Uint64() + external int uhVal; + + @Float() + external double fltVal; + + @Double() + external double dblVal; + + @Int16() + external int boolVal; + + @Int16() + // ignore: unused_field + external int __OBSOLETE__VARIANT_BOOL; + + @Int32() + external int scode; + + external CY cyVal; + + @Double() + external double date; + + external FILETIME filetime; + + external Pointer puuid; + + external Pointer pclipdata; + + external Pointer bstrVal; + + external BSTRBLOB bstrblobVal; + + external BLOB blob; + + external Pointer pszVal; + + external Pointer pwszVal; + + external VTablePointer punkVal; + + external VTablePointer pdispVal; + + external VTablePointer pStream; + + external VTablePointer pStorage; + + external Pointer pVersionedStream; + + external Pointer parray; + + external CAC cac; + + external CAUB caub; + + external CAI cai; + + external CAUI caui; + + external CAL cal; + + external CAUL caul; + + external CAH cah; + + external CAUH cauh; + + external CAFLT caflt; + + external CADBL cadbl; + + external CABOOL cabool; + + external CASCODE cascode; + + external CACY cacy; + + external CADATE cadate; + + external CAFILETIME cafiletime; + + external CACLSID cauuid; + + external CACLIPDATA caclipdata; + + external CABSTR cabstr; + + external CABSTRBLOB cabstrblob; + + external CALPSTR calpstr; + + external CALPWSTR calpwstr; + + external CAPROPVARIANT capropvar; + + external Pointer pcVal; + + external Pointer pbVal; + + external Pointer piVal; + + external Pointer puiVal; + + external Pointer plVal; + + external Pointer pulVal; + + external Pointer pintVal; + + external Pointer puintVal; + + external Pointer pfltVal; + + external Pointer pdblVal; + + external Pointer pboolVal; + + external Pointer pdecVal; + + external Pointer pscode; + + external Pointer pcyVal; + + external Pointer pdate; + + external Pointer> pbstrVal; + + external Pointer> ppunkVal; + + external Pointer> ppdispVal; + + external Pointer> pparray; + + external Pointer pvarVal; +} + +extension PROPVARIANT_0_0_0_Extension on PROPVARIANT { + int get cVal => this.Anonymous.Anonymous.Anonymous.cVal; + set cVal(int value) => this.Anonymous.Anonymous.Anonymous.cVal = value; + + int get bVal => this.Anonymous.Anonymous.Anonymous.bVal; + set bVal(int value) => this.Anonymous.Anonymous.Anonymous.bVal = value; + + int get iVal => this.Anonymous.Anonymous.Anonymous.iVal; + set iVal(int value) => this.Anonymous.Anonymous.Anonymous.iVal = value; + + int get uiVal => this.Anonymous.Anonymous.Anonymous.uiVal; + set uiVal(int value) => this.Anonymous.Anonymous.Anonymous.uiVal = value; + + int get lVal => this.Anonymous.Anonymous.Anonymous.lVal; + set lVal(int value) => this.Anonymous.Anonymous.Anonymous.lVal = value; + + int get ulVal => this.Anonymous.Anonymous.Anonymous.ulVal; + set ulVal(int value) => this.Anonymous.Anonymous.Anonymous.ulVal = value; + + int get intVal => this.Anonymous.Anonymous.Anonymous.intVal; + set intVal(int value) => this.Anonymous.Anonymous.Anonymous.intVal = value; + + int get uintVal => this.Anonymous.Anonymous.Anonymous.uintVal; + set uintVal(int value) => this.Anonymous.Anonymous.Anonymous.uintVal = value; + + int get hVal => this.Anonymous.Anonymous.Anonymous.hVal; + set hVal(int value) => this.Anonymous.Anonymous.Anonymous.hVal = value; + + int get uhVal => this.Anonymous.Anonymous.Anonymous.uhVal; + set uhVal(int value) => this.Anonymous.Anonymous.Anonymous.uhVal = value; + + double get fltVal => this.Anonymous.Anonymous.Anonymous.fltVal; + set fltVal(double value) => this.Anonymous.Anonymous.Anonymous.fltVal = value; + + double get dblVal => this.Anonymous.Anonymous.Anonymous.dblVal; + set dblVal(double value) => this.Anonymous.Anonymous.Anonymous.dblVal = value; + + int get boolVal => this.Anonymous.Anonymous.Anonymous.boolVal; + set boolVal(int value) => this.Anonymous.Anonymous.Anonymous.boolVal = value; + + int get scode => this.Anonymous.Anonymous.Anonymous.scode; + set scode(int value) => this.Anonymous.Anonymous.Anonymous.scode = value; + + CY get cyVal => this.Anonymous.Anonymous.Anonymous.cyVal; + set cyVal(CY value) => this.Anonymous.Anonymous.Anonymous.cyVal = value; + + double get date => this.Anonymous.Anonymous.Anonymous.date; + set date(double value) => this.Anonymous.Anonymous.Anonymous.date = value; + + FILETIME get filetime => this.Anonymous.Anonymous.Anonymous.filetime; + set filetime(FILETIME value) => + this.Anonymous.Anonymous.Anonymous.filetime = value; + + Pointer get puuid => this.Anonymous.Anonymous.Anonymous.puuid; + set puuid(Pointer value) => + this.Anonymous.Anonymous.Anonymous.puuid = value; + + Pointer get pclipdata => + this.Anonymous.Anonymous.Anonymous.pclipdata; + set pclipdata(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pclipdata = value; + + Pointer get bstrVal => this.Anonymous.Anonymous.Anonymous.bstrVal; + set bstrVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.bstrVal = value; + + BSTRBLOB get bstrblobVal => this.Anonymous.Anonymous.Anonymous.bstrblobVal; + set bstrblobVal(BSTRBLOB value) => + this.Anonymous.Anonymous.Anonymous.bstrblobVal = value; + + BLOB get blob => this.Anonymous.Anonymous.Anonymous.blob; + set blob(BLOB value) => this.Anonymous.Anonymous.Anonymous.blob = value; + + Pointer get pszVal => this.Anonymous.Anonymous.Anonymous.pszVal; + set pszVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pszVal = value; + + Pointer get pwszVal => this.Anonymous.Anonymous.Anonymous.pwszVal; + set pwszVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pwszVal = value; + + VTablePointer get punkVal => this.Anonymous.Anonymous.Anonymous.punkVal; + set punkVal(VTablePointer value) => + this.Anonymous.Anonymous.Anonymous.punkVal = value; + + VTablePointer get pdispVal => this.Anonymous.Anonymous.Anonymous.pdispVal; + set pdispVal(VTablePointer value) => + this.Anonymous.Anonymous.Anonymous.pdispVal = value; + + VTablePointer get pStream => this.Anonymous.Anonymous.Anonymous.pStream; + set pStream(VTablePointer value) => + this.Anonymous.Anonymous.Anonymous.pStream = value; + + VTablePointer get pStorage => this.Anonymous.Anonymous.Anonymous.pStorage; + set pStorage(VTablePointer value) => + this.Anonymous.Anonymous.Anonymous.pStorage = value; + + Pointer get pVersionedStream => + this.Anonymous.Anonymous.Anonymous.pVersionedStream; + set pVersionedStream(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pVersionedStream = value; + + Pointer get parray => this.Anonymous.Anonymous.Anonymous.parray; + set parray(Pointer value) => + this.Anonymous.Anonymous.Anonymous.parray = value; + + CAC get cac => this.Anonymous.Anonymous.Anonymous.cac; + set cac(CAC value) => this.Anonymous.Anonymous.Anonymous.cac = value; + + CAUB get caub => this.Anonymous.Anonymous.Anonymous.caub; + set caub(CAUB value) => this.Anonymous.Anonymous.Anonymous.caub = value; + + CAI get cai => this.Anonymous.Anonymous.Anonymous.cai; + set cai(CAI value) => this.Anonymous.Anonymous.Anonymous.cai = value; + + CAUI get caui => this.Anonymous.Anonymous.Anonymous.caui; + set caui(CAUI value) => this.Anonymous.Anonymous.Anonymous.caui = value; + + CAL get cal => this.Anonymous.Anonymous.Anonymous.cal; + set cal(CAL value) => this.Anonymous.Anonymous.Anonymous.cal = value; + + CAUL get caul => this.Anonymous.Anonymous.Anonymous.caul; + set caul(CAUL value) => this.Anonymous.Anonymous.Anonymous.caul = value; + + CAH get cah => this.Anonymous.Anonymous.Anonymous.cah; + set cah(CAH value) => this.Anonymous.Anonymous.Anonymous.cah = value; + + CAUH get cauh => this.Anonymous.Anonymous.Anonymous.cauh; + set cauh(CAUH value) => this.Anonymous.Anonymous.Anonymous.cauh = value; + + CAFLT get caflt => this.Anonymous.Anonymous.Anonymous.caflt; + set caflt(CAFLT value) => this.Anonymous.Anonymous.Anonymous.caflt = value; + + CADBL get cadbl => this.Anonymous.Anonymous.Anonymous.cadbl; + set cadbl(CADBL value) => this.Anonymous.Anonymous.Anonymous.cadbl = value; + + CABOOL get cabool => this.Anonymous.Anonymous.Anonymous.cabool; + set cabool(CABOOL value) => this.Anonymous.Anonymous.Anonymous.cabool = value; + + CASCODE get cascode => this.Anonymous.Anonymous.Anonymous.cascode; + set cascode(CASCODE value) => + this.Anonymous.Anonymous.Anonymous.cascode = value; + + CACY get cacy => this.Anonymous.Anonymous.Anonymous.cacy; + set cacy(CACY value) => this.Anonymous.Anonymous.Anonymous.cacy = value; + + CADATE get cadate => this.Anonymous.Anonymous.Anonymous.cadate; + set cadate(CADATE value) => this.Anonymous.Anonymous.Anonymous.cadate = value; + + CAFILETIME get cafiletime => this.Anonymous.Anonymous.Anonymous.cafiletime; + set cafiletime(CAFILETIME value) => + this.Anonymous.Anonymous.Anonymous.cafiletime = value; + + CACLSID get cauuid => this.Anonymous.Anonymous.Anonymous.cauuid; + set cauuid(CACLSID value) => + this.Anonymous.Anonymous.Anonymous.cauuid = value; + + CACLIPDATA get caclipdata => this.Anonymous.Anonymous.Anonymous.caclipdata; + set caclipdata(CACLIPDATA value) => + this.Anonymous.Anonymous.Anonymous.caclipdata = value; + + CABSTR get cabstr => this.Anonymous.Anonymous.Anonymous.cabstr; + set cabstr(CABSTR value) => this.Anonymous.Anonymous.Anonymous.cabstr = value; + + CABSTRBLOB get cabstrblob => this.Anonymous.Anonymous.Anonymous.cabstrblob; + set cabstrblob(CABSTRBLOB value) => + this.Anonymous.Anonymous.Anonymous.cabstrblob = value; + + CALPSTR get calpstr => this.Anonymous.Anonymous.Anonymous.calpstr; + set calpstr(CALPSTR value) => + this.Anonymous.Anonymous.Anonymous.calpstr = value; + + CALPWSTR get calpwstr => this.Anonymous.Anonymous.Anonymous.calpwstr; + set calpwstr(CALPWSTR value) => + this.Anonymous.Anonymous.Anonymous.calpwstr = value; + + CAPROPVARIANT get capropvar => this.Anonymous.Anonymous.Anonymous.capropvar; + set capropvar(CAPROPVARIANT value) => + this.Anonymous.Anonymous.Anonymous.capropvar = value; + + Pointer get pcVal => this.Anonymous.Anonymous.Anonymous.pcVal; + set pcVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pcVal = value; + + Pointer get pbVal => this.Anonymous.Anonymous.Anonymous.pbVal; + set pbVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pbVal = value; + + Pointer get piVal => this.Anonymous.Anonymous.Anonymous.piVal; + set piVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.piVal = value; + + Pointer get puiVal => this.Anonymous.Anonymous.Anonymous.puiVal; + set puiVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.puiVal = value; + + Pointer get plVal => this.Anonymous.Anonymous.Anonymous.plVal; + set plVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.plVal = value; + + Pointer get pulVal => this.Anonymous.Anonymous.Anonymous.pulVal; + set pulVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pulVal = value; + + Pointer get pintVal => this.Anonymous.Anonymous.Anonymous.pintVal; + set pintVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pintVal = value; + + Pointer get puintVal => this.Anonymous.Anonymous.Anonymous.puintVal; + set puintVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.puintVal = value; + + Pointer get pfltVal => this.Anonymous.Anonymous.Anonymous.pfltVal; + set pfltVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pfltVal = value; + + Pointer get pdblVal => this.Anonymous.Anonymous.Anonymous.pdblVal; + set pdblVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pdblVal = value; + + Pointer get pboolVal => + this.Anonymous.Anonymous.Anonymous.pboolVal; + set pboolVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pboolVal = value; + + Pointer get pdecVal => this.Anonymous.Anonymous.Anonymous.pdecVal; + set pdecVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pdecVal = value; + + Pointer get pscode => this.Anonymous.Anonymous.Anonymous.pscode; + set pscode(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pscode = value; + + Pointer get pcyVal => this.Anonymous.Anonymous.Anonymous.pcyVal; + set pcyVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pcyVal = value; + + Pointer get pdate => this.Anonymous.Anonymous.Anonymous.pdate; + set pdate(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pdate = value; + + Pointer> get pbstrVal => + this.Anonymous.Anonymous.Anonymous.pbstrVal; + set pbstrVal(Pointer> value) => + this.Anonymous.Anonymous.Anonymous.pbstrVal = value; + + Pointer> get ppunkVal => + this.Anonymous.Anonymous.Anonymous.ppunkVal; + set ppunkVal(Pointer> value) => + this.Anonymous.Anonymous.Anonymous.ppunkVal = value; + + Pointer> get ppdispVal => + this.Anonymous.Anonymous.Anonymous.ppdispVal; + set ppdispVal(Pointer> value) => + this.Anonymous.Anonymous.Anonymous.ppdispVal = value; + + Pointer> get pparray => + this.Anonymous.Anonymous.Anonymous.pparray; + set pparray(Pointer> value) => + this.Anonymous.Anonymous.Anonymous.pparray = value; + + Pointer get pvarVal => + this.Anonymous.Anonymous.Anonymous.pvarVal; + set pvarVal(Pointer value) => + this.Anonymous.Anonymous.Anonymous.pvarVal = value; +} + +/// {@category struct} +base class VERSIONEDSTREAM extends Struct { + external GUID guidVersion; + + external VTablePointer pStream; } diff --git a/lib/src/win32/ole32.g.dart b/lib/src/win32/ole32.g.dart index c039a9503..0e6430f48 100644 --- a/lib/src/win32/ole32.g.dart +++ b/lib/src/win32/ole32.g.dart @@ -563,6 +563,20 @@ final _ProgIDFromCLSID = _ole32.lookupFunction< int Function(Pointer clsid, Pointer> lplpszProgID)>('ProgIDFromCLSID'); +/// Clears a PROPVARIANT structure. +/// +/// ```c +/// HRESULT PropVariantClear( +/// [in, out] PROPVARIANT *pvar +/// ); +/// ``` +/// {@category ole32} +int PropVariantClear(Pointer pvar) => _PropVariantClear(pvar); + +final _PropVariantClear = _ole32.lookupFunction< + Int32 Function(Pointer pvar), + int Function(Pointer pvar)>('PropVariantClear'); + /// Converts a CLSID into a string of printable characters. Different CLSIDs /// always convert to different strings. /// diff --git a/pubspec.yaml b/pubspec.yaml index 4d9930f81..3a5ddd68a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: win32 description: > A Dart library for accessing common Win32 APIs using FFI. No C required! -version: 5.4.0 +version: 5.5.0-wip homepage: https://win32.pub repository: https://github.com/dart-windows/win32 issue_tracker: https://github.com/dart-windows/win32/issues @@ -27,10 +27,10 @@ dev_dependencies: args: ^2.4.2 # Help ensure that the code is well-written. - dartwindows_lints: ^1.1.0 + lints: ^3.0.0 # Used for joining paths, as part of our path_provider integration test. path: ^1.9.0 # Running the test suite. - test: ^1.25.2 + test: ^1.25.4 diff --git a/test/api_test.dart b/test/api_test.dart index 374de1c00..ef79403be 100644 --- a/test/api_test.dart +++ b/test/api_test.dart @@ -11207,6 +11207,13 @@ void main() { Pointer> lplpszProgID)>('ProgIDFromCLSID'); expect(ProgIDFromCLSID, isA()); }); + test('Can instantiate PropVariantClear', () { + final ole32 = DynamicLibrary.open('ole32.dll'); + final PropVariantClear = ole32.lookupFunction< + Int32 Function(Pointer pvar), + int Function(Pointer pvar)>('PropVariantClear'); + expect(PropVariantClear, isA()); + }); test('Can instantiate StringFromCLSID', () { final ole32 = DynamicLibrary.open('ole32.dll'); final StringFromCLSID = ole32.lookupFunction< diff --git a/tool/struct_sizes/struct_sizes.cpp b/tool/struct_sizes/struct_sizes.cpp index 57b0da137..85e319ff4 100644 --- a/tool/struct_sizes/struct_sizes.cpp +++ b/tool/struct_sizes/struct_sizes.cpp @@ -77,6 +77,7 @@ void main() printf(" 'BITMAPINFO': %zu,\n", sizeof(BITMAPINFO)); printf(" 'BITMAPINFOHEADER': %zu,\n", sizeof(BITMAPINFOHEADER)); printf(" 'BLENDFUNCTION': %zu,\n", sizeof(BLENDFUNCTION)); + printf(" 'BLOB': %zu,\n", sizeof(BLOB)); printf(" 'BLUETOOTH_ADDRESS': %zu,\n", sizeof(BLUETOOTH_ADDRESS)); printf(" 'BLUETOOTH_AUTHENTICATE_RESPONSE': %zu,\n", sizeof(BLUETOOTH_AUTHENTICATE_RESPONSE)); printf(" 'BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS': %zu,\n", sizeof(BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS)); @@ -93,6 +94,7 @@ void main() printf(" 'BLUETOOTH_RADIO_INFO': %zu,\n", sizeof(BLUETOOTH_RADIO_INFO)); printf(" 'BLUETOOTH_SELECT_DEVICE_PARAMS': %zu,\n", sizeof(BLUETOOTH_SELECT_DEVICE_PARAMS)); printf(" 'BSMINFO': %zu,\n", sizeof(BSMINFO)); + printf(" 'BSTRBLOB': %zu,\n", sizeof(BSTRBLOB)); printf(" 'BTH_DEVICE_INFO': %zu,\n", sizeof(BTH_DEVICE_INFO)); printf(" 'BTH_HCI_EVENT_INFO': %zu,\n", sizeof(BTH_HCI_EVENT_INFO)); printf(" 'BTH_L2CAP_EVENT_INFO': %zu,\n", sizeof(BTH_L2CAP_EVENT_INFO)); @@ -107,7 +109,29 @@ void main() printf(" 'BTH_RADIO_IN_RANGE': %zu,\n", sizeof(BTH_RADIO_IN_RANGE)); printf(" 'BTH_SET_SERVICE': %zu,\n", sizeof(BTH_SET_SERVICE)); printf(" 'BY_HANDLE_FILE_INFORMATION': %zu,\n", sizeof(BY_HANDLE_FILE_INFORMATION)); + printf(" 'CABOOL': %zu,\n", sizeof(CABOOL)); + printf(" 'CABSTR': %zu,\n", sizeof(CABSTR)); + printf(" 'CABSTRBLOB': %zu,\n", sizeof(CABSTRBLOB)); + printf(" 'CAC': %zu,\n", sizeof(CAC)); printf(" 'CACHE_DESCRIPTOR': %zu,\n", sizeof(CACHE_DESCRIPTOR)); + printf(" 'CACLIPDATA': %zu,\n", sizeof(CACLIPDATA)); + printf(" 'CACLSID': %zu,\n", sizeof(CACLSID)); + printf(" 'CACY': %zu,\n", sizeof(CACY)); + printf(" 'CADATE': %zu,\n", sizeof(CADATE)); + printf(" 'CADBL': %zu,\n", sizeof(CADBL)); + printf(" 'CAFILETIME': %zu,\n", sizeof(CAFILETIME)); + printf(" 'CAFLT': %zu,\n", sizeof(CAFLT)); + printf(" 'CAH': %zu,\n", sizeof(CAH)); + printf(" 'CAI': %zu,\n", sizeof(CAI)); + printf(" 'CAL': %zu,\n", sizeof(CAL)); + printf(" 'CALPSTR': %zu,\n", sizeof(CALPSTR)); + printf(" 'CALPWSTR': %zu,\n", sizeof(CALPWSTR)); + printf(" 'CAPROPVARIANT': %zu,\n", sizeof(CAPROPVARIANT)); + printf(" 'CASCODE': %zu,\n", sizeof(CASCODE)); + printf(" 'CAUB': %zu,\n", sizeof(CAUB)); + printf(" 'CAUH': %zu,\n", sizeof(CAUH)); + printf(" 'CAUI': %zu,\n", sizeof(CAUI)); + printf(" 'CAUL': %zu,\n", sizeof(CAUL)); printf(" 'CBTACTIVATESTRUCT': %zu,\n", sizeof(CBTACTIVATESTRUCT)); printf(" 'CBT_CREATEWND': %zu,\n", sizeof(CBT_CREATEWNDW)); printf(" 'CERT_CONTEXT': %zu,\n", sizeof(CERT_CONTEXT)); @@ -119,6 +143,7 @@ void main() printf(" 'CHOOSECOLOR': %zu,\n", sizeof(CHOOSECOLORW)); printf(" 'CHOOSEFONT': %zu,\n", sizeof(CHOOSEFONTW)); printf(" 'CLIENT_ID': %zu,\n", sizeof(CLIENT_ID)); + printf(" 'CLIPDATA': %zu,\n", sizeof(CLIPDATA)); printf(" 'COLORADJUSTMENT': %zu,\n", sizeof(COLORADJUSTMENT)); printf(" 'COMDLG_FILTERSPEC': %zu,\n", sizeof(COMDLG_FILTERSPEC)); printf(" 'COMMCONFIG': %zu,\n", sizeof(COMMCONFIG)); diff --git a/tool/win32gen/analysis_options.yaml b/tool/win32gen/analysis_options.yaml index 6beee5854..135056261 100644 --- a/tool/win32gen/analysis_options.yaml +++ b/tool/win32gen/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:dartwindows_lints/analysis_options.yaml +include: package:lints/recommended.yaml analyzer: errors: diff --git a/tool/win32gen/data/win32_functions.json b/tool/win32gen/data/win32_functions.json index 14e5bb64c..3859a2a47 100644 --- a/tool/win32gen/data/win32_functions.json +++ b/tool/win32gen/data/win32_functions.json @@ -3984,6 +3984,10 @@ "prototype": "HRESULT ProgIDFromCLSID(\n REFCLSID clsid,\n LPOLESTR *lplpszProgID\n);", "comment": "Retrieves the ProgID for a given CLSID." }, + "PropVariantClear": { + "prototype": "HRESULT PropVariantClear(\n [in, out] PROPVARIANT *pvar\n);", + "comment": "Clears a PROPVARIANT structure." + }, "PtInRect": { "prototype": "BOOL PtInRect(\n const RECT *lprc,\n POINT pt\n);", "comment": "The PtInRect function determines whether the specified point lies within the specified rectangle. A point is within a rectangle if it lies on the left or top side or is within all four sides. A point on the right or bottom side is considered outside the rectangle." diff --git a/tool/win32gen/data/win32_structs.json b/tool/win32gen/data/win32_structs.json index 104d1a00c..e7a5d013c 100644 --- a/tool/win32gen/data/win32_structs.json +++ b/tool/win32gen/data/win32_structs.json @@ -230,6 +230,7 @@ "Windows.Win32.Storage.Packaging.Appx.APPX_PACKAGE_SETTINGS": "Represents package settings used to create a package.", "Windows.Win32.System.ApplicationInstallationAndServicing.ACTCTXW": "The ACTCTX structure is used by the CreateActCtx function to create the activation context.", "Windows.Win32.System.Com.BIND_OPTS": "Contains parameters used during a moniker-binding operation.", + "Windows.Win32.System.Com.BLOB": "The BLOB structure, derived from Binary Large Object, contains information about a block of data.", "Windows.Win32.System.Com.CY": "A currency number stored as an 8-byte, two's complement integer, scaled by 10,000 to give a fixed-point number with 15 digits to the left of the decimal point and 4 digits to the right. This IDispatch::GetTypeInfo representation provides a range of 922337203685477.5807 to -922337203685477.5808.", "Windows.Win32.System.Com.DISPPARAMS": "Contains the arguments passed to a method or property.", "Windows.Win32.System.Com.ELEMDESC": "Contains the type description and process-transfer information for a variable, a function, or a function parameter.", @@ -240,6 +241,30 @@ "Windows.Win32.System.Com.SAFEARRAYBOUND": "Represents the bounds of one dimension of the array.", "Windows.Win32.System.Com.SOLE_AUTHENTICATION_SERVICE": "Identifies an authentication service that a server is willing to use to communicate to a client.", "Windows.Win32.System.Com.STATSTG": "The STATSTG structure contains statistical data about an open storage, stream, or byte-array object. This structure is used in the IEnumSTATSTG, ILockBytes, IStorage, and IStream interfaces.", + "Windows.Win32.System.Com.StructuredStorage.BSTRBLOB": "", + "Windows.Win32.System.Com.StructuredStorage.CABOOL": "", + "Windows.Win32.System.Com.StructuredStorage.CABSTR": "", + "Windows.Win32.System.Com.StructuredStorage.CABSTRBLOB": "", + "Windows.Win32.System.Com.StructuredStorage.CAC": "", + "Windows.Win32.System.Com.StructuredStorage.CACLIPDATA": "", + "Windows.Win32.System.Com.StructuredStorage.CACLSID": "", + "Windows.Win32.System.Com.StructuredStorage.CACY": "", + "Windows.Win32.System.Com.StructuredStorage.CADATE": "", + "Windows.Win32.System.Com.StructuredStorage.CADBL": "", + "Windows.Win32.System.Com.StructuredStorage.CAFILETIME": "", + "Windows.Win32.System.Com.StructuredStorage.CAFLT": "", + "Windows.Win32.System.Com.StructuredStorage.CAH": "", + "Windows.Win32.System.Com.StructuredStorage.CAI": "", + "Windows.Win32.System.Com.StructuredStorage.CAL": "", + "Windows.Win32.System.Com.StructuredStorage.CALPSTR": "", + "Windows.Win32.System.Com.StructuredStorage.CALPWSTR": "", + "Windows.Win32.System.Com.StructuredStorage.CAPROPVARIANT": "", + "Windows.Win32.System.Com.StructuredStorage.CASCODE": "", + "Windows.Win32.System.Com.StructuredStorage.CAUB": "", + "Windows.Win32.System.Com.StructuredStorage.CAUH": "", + "Windows.Win32.System.Com.StructuredStorage.CAUI": "", + "Windows.Win32.System.Com.StructuredStorage.CAUL": "", + "Windows.Win32.System.Com.StructuredStorage.CLIPDATA": "", "Windows.Win32.System.Com.StructuredStorage.PROPSPEC": "The PROPSPEC structure is used by many of the methods of IPropertyStorage to specify a property either by its property identifier (ID) or the associated string name.", "Windows.Win32.System.Com.StructuredStorage.STATPROPSETSTG": "The STATPROPSETSTG structure contains information about a property set.", "Windows.Win32.System.Com.StructuredStorage.STATPROPSTG": "The STATPROPSTG structure contains data about a single property in a property set. This data is the property ID and type tag, and the optional string name that may be associated with the property.", diff --git a/tool/win32gen/pubspec.yaml b/tool/win32gen/pubspec.yaml index 103626ee5..b2745094d 100644 --- a/tool/win32gen/pubspec.yaml +++ b/tool/win32gen/pubspec.yaml @@ -1,5 +1,6 @@ name: win32gen -description: Auto-generate Dart wrapper classes for the Win32 API using Windows metadata +description: > + Auto-generate Dart wrapper classes for the Win32 API using Windows metadata publish_to: none environment: @@ -13,17 +14,18 @@ dependencies: # For formatting Dart code (APIs for performing dart format). dart_style: ^2.3.6 - # Help ensure that the code is well-written. - dartwindows_lints: ^1.1.0 - # Foreign Function Interface extension methods ffi: ^2.1.2 - # Running the test suite. - test: ^1.25.2 - # Windows metadata for automatically generating API signatures. - winmd: ^5.0.0 + winmd: ^5.0.1 # Win32 itself - win32: ^5.3.0 + win32: ^5.4.0 + +dev_dependencies: + # Help ensure that the code is well-written. + lints: ^3.0.0 + + # Running the test suite. + test: ^1.25.3 diff --git a/tool/win32gen/test/helpers.dart b/tool/win32gen/test/helpers.dart index 2f46a0d30..15e8af55f 100644 --- a/tool/win32gen/test/helpers.dart +++ b/tool/win32gen/test/helpers.dart @@ -22,15 +22,16 @@ Object getRegistryValue(int key, String subKey, String valueName) { final dataSize = calloc()..value = 256; try { - var result = RegOpenKeyEx(key, subKeyPtr, 0, KEY_READ, openKeyPtr); - if (result == ERROR_SUCCESS) { + var result = + RegOpenKeyEx(key, subKeyPtr, 0, REG_SAM_FLAGS.KEY_READ, openKeyPtr); + if (result == WIN32_ERROR.ERROR_SUCCESS) { result = RegQueryValueEx( openKeyPtr.value, valueNamePtr, nullptr, dataType, data, dataSize); - if (result == ERROR_SUCCESS) { - if (dataType.value == REG_DWORD) { + if (result == WIN32_ERROR.ERROR_SUCCESS) { + if (dataType.value == REG_VALUE_TYPE.REG_DWORD) { dataValue = data.value; - } else if (dataType.value == REG_SZ) { + } else if (dataType.value == REG_VALUE_TYPE.REG_SZ) { dataValue = data.cast().toDartString(); } else { // other data types are available, but this is a sample