forked from terrafx/terrafx.interop.windows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds all of the Structured Stroage (IStorage) related APIs and related defines. Add the remap-classes.rsp to the solution file. fixes terrafx#263 fixes terrafx#227
- Loading branch information
1 parent
ea649a6
commit 3227357
Showing
10 changed files
with
294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@../../../settings.rsp | ||
@../../../remap.rsp | ||
--file | ||
um-coml2api.h | ||
--methodClassName | ||
Windows | ||
--namespace | ||
TerraFX.Interop.Windows | ||
--output | ||
../../../../sources/Interop/Windows/Windows/um/coml2api | ||
--test-output | ||
../../../../tests/Interop/Windows/Windows/um/coml2api | ||
--traverse | ||
C:/Program Files (x86)/Windows Kits/10/Include/10.0.20348.0/um/coml2api.h | ||
--with-librarypath | ||
*=ole32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
// Ported from um/coml2api.h in the Windows SDK for Windows 10.0.20348.0 | ||
// Original source is Copyright © Microsoft. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "..\..\..\TerraFX.h" | ||
#include <coml2api.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
// Ported from um/coml2api.h in the Windows SDK for Windows 10.0.20348.0 | ||
// Original source is Copyright © Microsoft. All rights reserved. | ||
|
||
namespace TerraFX.Interop.Windows; | ||
|
||
public static partial class STGFMT | ||
{ | ||
[NativeTypeName("#define STGFMT_STORAGE 0")] | ||
public const int STGFMT_STORAGE = 0; | ||
|
||
[NativeTypeName("#define STGFMT_NATIVE 1")] | ||
public const int STGFMT_NATIVE = 1; | ||
|
||
[NativeTypeName("#define STGFMT_FILE 3")] | ||
public const int STGFMT_FILE = 3; | ||
|
||
[NativeTypeName("#define STGFMT_ANY 4")] | ||
public const int STGFMT_ANY = 4; | ||
|
||
[NativeTypeName("#define STGFMT_DOCFILE 5")] | ||
public const int STGFMT_DOCFILE = 5; | ||
|
||
[NativeTypeName("#define STGFMT_DOCUMENT 0")] | ||
public const int STGFMT_DOCUMENT = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
// Ported from um/coml2api.h in the Windows SDK for Windows 10.0.20348.0 | ||
// Original source is Copyright © Microsoft. All rights reserved. | ||
|
||
namespace TerraFX.Interop.Windows; | ||
|
||
public static partial class STGM | ||
{ | ||
[NativeTypeName("#define STGM_DIRECT 0x00000000L")] | ||
public const int STGM_DIRECT = 0x00000000; | ||
|
||
[NativeTypeName("#define STGM_TRANSACTED 0x00010000L")] | ||
public const int STGM_TRANSACTED = 0x00010000; | ||
|
||
[NativeTypeName("#define STGM_SIMPLE 0x08000000L")] | ||
public const int STGM_SIMPLE = 0x08000000; | ||
|
||
[NativeTypeName("#define STGM_READ 0x00000000L")] | ||
public const int STGM_READ = 0x00000000; | ||
|
||
[NativeTypeName("#define STGM_WRITE 0x00000001L")] | ||
public const int STGM_WRITE = 0x00000001; | ||
|
||
[NativeTypeName("#define STGM_READWRITE 0x00000002L")] | ||
public const int STGM_READWRITE = 0x00000002; | ||
|
||
[NativeTypeName("#define STGM_SHARE_DENY_NONE 0x00000040L")] | ||
public const int STGM_SHARE_DENY_NONE = 0x00000040; | ||
|
||
[NativeTypeName("#define STGM_SHARE_DENY_READ 0x00000030L")] | ||
public const int STGM_SHARE_DENY_READ = 0x00000030; | ||
|
||
[NativeTypeName("#define STGM_SHARE_DENY_WRITE 0x00000020L")] | ||
public const int STGM_SHARE_DENY_WRITE = 0x00000020; | ||
|
||
[NativeTypeName("#define STGM_SHARE_EXCLUSIVE 0x00000010L")] | ||
public const int STGM_SHARE_EXCLUSIVE = 0x00000010; | ||
|
||
[NativeTypeName("#define STGM_PRIORITY 0x00040000L")] | ||
public const int STGM_PRIORITY = 0x00040000; | ||
|
||
[NativeTypeName("#define STGM_DELETEONRELEASE 0x04000000L")] | ||
public const int STGM_DELETEONRELEASE = 0x04000000; | ||
|
||
[NativeTypeName("#define STGM_NOSCRATCH 0x00100000L")] | ||
public const int STGM_NOSCRATCH = 0x00100000; | ||
|
||
[NativeTypeName("#define STGM_CREATE 0x00001000L")] | ||
public const int STGM_CREATE = 0x00001000; | ||
|
||
[NativeTypeName("#define STGM_CONVERT 0x00020000L")] | ||
public const int STGM_CONVERT = 0x00020000; | ||
|
||
[NativeTypeName("#define STGM_FAILIFTHERE 0x00000000L")] | ||
public const int STGM_FAILIFTHERE = 0x00000000; | ||
|
||
[NativeTypeName("#define STGM_NOSNAPSHOT 0x00200000L")] | ||
public const int STGM_NOSNAPSHOT = 0x00200000; | ||
|
||
[NativeTypeName("#define STGM_DIRECT_SWMR 0x00400000L")] | ||
public const int STGM_DIRECT_SWMR = 0x00400000; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
// Ported from um/coml2api.h in the Windows SDK for Windows 10.0.20348.0 | ||
// Original source is Copyright © Microsoft. All rights reserved. | ||
|
||
namespace TerraFX.Interop.Windows; | ||
|
||
/// <include file='STGOPTIONS.xml' path='doc/member[@name="STGOPTIONS"]/*' /> | ||
public unsafe partial struct STGOPTIONS | ||
{ | ||
/// <include file='STGOPTIONS.xml' path='doc/member[@name="STGOPTIONS.usVersion"]/*' /> | ||
public ushort usVersion; | ||
|
||
/// <include file='STGOPTIONS.xml' path='doc/member[@name="STGOPTIONS.reserved"]/*' /> | ||
public ushort reserved; | ||
|
||
/// <include file='STGOPTIONS.xml' path='doc/member[@name="STGOPTIONS.ulSectorSize"]/*' /> | ||
[NativeTypeName("ULONG")] | ||
public uint ulSectorSize; | ||
|
||
/// <include file='STGOPTIONS.xml' path='doc/member[@name="STGOPTIONS.pwcsTemplateFile"]/*' /> | ||
[NativeTypeName("const WCHAR *")] | ||
public ushort* pwcsTemplateFile; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
// Ported from um/coml2api.h in the Windows SDK for Windows 10.0.20348.0 | ||
// Original source is Copyright © Microsoft. All rights reserved. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace TerraFX.Interop.Windows; | ||
|
||
public static unsafe partial class Windows | ||
{ | ||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgCreateDocfile"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgCreateDocfile([NativeTypeName("const WCHAR *")] ushort* pwcsName, [NativeTypeName("DWORD")] uint grfMode, [NativeTypeName("DWORD")] uint reserved, IStorage** ppstgOpen); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgCreateDocfileOnILockBytes"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgCreateDocfileOnILockBytes(ILockBytes* plkbyt, [NativeTypeName("DWORD")] uint grfMode, [NativeTypeName("DWORD")] uint reserved, IStorage** ppstgOpen); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgOpenStorage"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgOpenStorage([NativeTypeName("const WCHAR *")] ushort* pwcsName, IStorage* pstgPriority, [NativeTypeName("DWORD")] uint grfMode, [NativeTypeName("SNB")] ushort** snbExclude, [NativeTypeName("DWORD")] uint reserved, IStorage** ppstgOpen); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgOpenStorageOnILockBytes"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgOpenStorageOnILockBytes(ILockBytes* plkbyt, IStorage* pstgPriority, [NativeTypeName("DWORD")] uint grfMode, [NativeTypeName("SNB")] ushort** snbExclude, [NativeTypeName("DWORD")] uint reserved, IStorage** ppstgOpen); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgIsStorageFile"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgIsStorageFile([NativeTypeName("const WCHAR *")] ushort* pwcsName); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgIsStorageILockBytes"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgIsStorageILockBytes(ILockBytes* plkbyt); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgSetTimes"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgSetTimes([NativeTypeName("const WCHAR *")] ushort* lpszName, [NativeTypeName("const FILETIME *")] FILETIME* pctime, [NativeTypeName("const FILETIME *")] FILETIME* patime, [NativeTypeName("const FILETIME *")] FILETIME* pmtime); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgCreateStorageEx"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgCreateStorageEx([NativeTypeName("const WCHAR *")] ushort* pwcsName, [NativeTypeName("DWORD")] uint grfMode, [NativeTypeName("DWORD")] uint stgfmt, [NativeTypeName("DWORD")] uint grfAttrs, STGOPTIONS* pStgOptions, [NativeTypeName("PSECURITY_DESCRIPTOR")] void* pSecurityDescriptor, [NativeTypeName("const IID &")] Guid* riid, void** ppObjectOpen); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgOpenStorageEx"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgOpenStorageEx([NativeTypeName("const WCHAR *")] ushort* pwcsName, [NativeTypeName("DWORD")] uint grfMode, [NativeTypeName("DWORD")] uint stgfmt, [NativeTypeName("DWORD")] uint grfAttrs, STGOPTIONS* pStgOptions, [NativeTypeName("PSECURITY_DESCRIPTOR")] void* pSecurityDescriptor, [NativeTypeName("const IID &")] Guid* riid, void** ppObjectOpen); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgCreatePropStg"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgCreatePropStg(IUnknown* pUnk, [NativeTypeName("const IID &")] Guid* fmtid, [NativeTypeName("const CLSID *")] Guid* pclsid, [NativeTypeName("DWORD")] uint grfFlags, [NativeTypeName("DWORD")] uint dwReserved, IPropertyStorage** ppPropStg); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgOpenPropStg"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgOpenPropStg(IUnknown* pUnk, [NativeTypeName("const IID &")] Guid* fmtid, [NativeTypeName("DWORD")] uint grfFlags, [NativeTypeName("DWORD")] uint dwReserved, IPropertyStorage** ppPropStg); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.StgCreatePropSetStg"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT StgCreatePropSetStg(IStorage* pStorage, [NativeTypeName("DWORD")] uint dwReserved, IPropertySetStorage** ppPropSetStg); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.FmtIdToPropStgName"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT FmtIdToPropStgName([NativeTypeName("const FMTID *")] Guid* pfmtid, [NativeTypeName("LPOLESTR")] ushort* oszName); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.PropStgNameToFmtId"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT PropStgNameToFmtId([NativeTypeName("const LPOLESTR")] ushort* oszName, [NativeTypeName("FMTID *")] Guid* pfmtid); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.ReadClassStg"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT ReadClassStg([NativeTypeName("LPSTORAGE")] IStorage* pStg, [NativeTypeName("CLSID *")] Guid* pclsid); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.WriteClassStg"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT WriteClassStg([NativeTypeName("LPSTORAGE")] IStorage* pStg, [NativeTypeName("const IID &")] Guid* rclsid); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.ReadClassStm"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT ReadClassStm([NativeTypeName("LPSTREAM")] IStream* pStm, [NativeTypeName("CLSID *")] Guid* pclsid); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.WriteClassStm"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT WriteClassStm([NativeTypeName("LPSTREAM")] IStream* pStm, [NativeTypeName("const IID &")] Guid* rclsid); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.GetHGlobalFromILockBytes"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT GetHGlobalFromILockBytes([NativeTypeName("LPLOCKBYTES")] ILockBytes* plkbyt, HGLOBAL* phglobal); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.CreateILockBytesOnHGlobal"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT CreateILockBytesOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, [NativeTypeName("LPLOCKBYTES *")] ILockBytes** pplkbyt); | ||
|
||
/// <include file='Windows.xml' path='doc/member[@name="Windows.GetConvertStg"]/*' /> | ||
[DllImport("ole32", ExactSpelling = true)] | ||
public static extern HRESULT GetConvertStg([NativeTypeName("LPSTORAGE")] IStorage* pStg); | ||
|
||
[NativeTypeName("#define CWCSTORAGENAME 32")] | ||
public const int CWCSTORAGENAME = 32; | ||
|
||
[NativeTypeName("#define STGOPTIONS_VERSION 2")] | ||
public const int STGOPTIONS_VERSION = 2; | ||
|
||
[NativeTypeName("#define CCH_MAX_PROPSTG_NAME 31")] | ||
public const int CCH_MAX_PROPSTG_NAME = 31; | ||
} |
42 changes: 42 additions & 0 deletions
42
tests/Interop/Windows/Windows/um/coml2api/STGOPTIONSTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
// Ported from um/coml2api.h in the Windows SDK for Windows 10.0.20348.0 | ||
// Original source is Copyright © Microsoft. All rights reserved. | ||
|
||
using NUnit.Framework; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace TerraFX.Interop.Windows.UnitTests; | ||
|
||
/// <summary>Provides validation of the <see cref="STGOPTIONS" /> struct.</summary> | ||
public static unsafe partial class STGOPTIONSTests | ||
{ | ||
/// <summary>Validates that the <see cref="STGOPTIONS" /> struct is blittable.</summary> | ||
[Test] | ||
public static void IsBlittableTest() | ||
{ | ||
Assert.That(Marshal.SizeOf<STGOPTIONS>(), Is.EqualTo(sizeof(STGOPTIONS))); | ||
} | ||
|
||
/// <summary>Validates that the <see cref="STGOPTIONS" /> struct has the right <see cref="LayoutKind" />.</summary> | ||
[Test] | ||
public static void IsLayoutSequentialTest() | ||
{ | ||
Assert.That(typeof(STGOPTIONS).IsLayoutSequential, Is.True); | ||
} | ||
|
||
/// <summary>Validates that the <see cref="STGOPTIONS" /> struct has the correct size.</summary> | ||
[Test] | ||
public static void SizeOfTest() | ||
{ | ||
if (Environment.Is64BitProcess) | ||
{ | ||
Assert.That(sizeof(STGOPTIONS), Is.EqualTo(16)); | ||
} | ||
else | ||
{ | ||
Assert.That(sizeof(STGOPTIONS), Is.EqualTo(12)); | ||
} | ||
} | ||
} |