diff --git a/TerraFX.Interop.Windows.sln b/TerraFX.Interop.Windows.sln index c4969b85d9..d05637e97f 100644 --- a/TerraFX.Interop.Windows.sln +++ b/TerraFX.Interop.Windows.sln @@ -2770,6 +2770,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lzexpand", "lzexpand", "{CC generation\Windows\um\lzexpand\um-lzexpand.h = generation\Windows\um\lzexpand\um-lzexpand.h EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "objbase", "objbase", "{B31F49C6-C263-4674-86D9-3E890348AF4B}" + ProjectSection(SolutionItems) = preProject + generation\Windows\um\objbase\generate.rsp = generation\Windows\um\objbase\generate.rsp + generation\Windows\um\objbase\header.txt = generation\Windows\um\objbase\header.txt + generation\Windows\um\objbase\um-objbase.h = generation\Windows\um\objbase\um-objbase.h + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -3197,6 +3204,7 @@ Global {CBC62B75-03A4-470D-A52A-D84161773CB7} = {67311E5E-FA9C-43A6-B431-9EF10047A0CE} {5FC51DA5-FF47-4100-BE74-2F3DE11EF163} = {67311E5E-FA9C-43A6-B431-9EF10047A0CE} {CC539B27-F7D6-44F9-9CB4-6CA9486D824D} = {67311E5E-FA9C-43A6-B431-9EF10047A0CE} + {B31F49C6-C263-4674-86D9-3E890348AF4B} = {67311E5E-FA9C-43A6-B431-9EF10047A0CE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2FE36DF8-2D9C-4F20-8787-45DC74B57461} diff --git a/generation/Windows/um/objbase/generate.rsp b/generation/Windows/um/objbase/generate.rsp new file mode 100644 index 0000000000..00507d730c --- /dev/null +++ b/generation/Windows/um/objbase/generate.rsp @@ -0,0 +1,63 @@ +@../../../settings.rsp +@../../../remap.rsp +--exclude +CLSIDFromProgIDEx +CoBuildVersion +CoCreateStandardMalloc +CoFileTimeNow +CreateStdProgressIndicator +DcomChannelSetHResult +StgOpenLayoutDocfile +--file +um-objbase.h +--methodClassName +Windows +--namespace +TerraFX.Interop.Windows +--output +../../../../sources/Interop/Windows/Windows/um/objbase +--test-output +../../../../tests/Interop/Windows/Windows/um/objbase +--traverse +C:/Program Files (x86)/Windows Kits/10/Include/10.0.20348.0/um/objbase.h +--with-librarypath +BindMoniker=ole32 +CoAllowSetForegroundWindow=ole32 +CoDosDateTimeToFileTime=ole32 +CoFileTimeToDosDateTime=ole32 +CoFreeAllLibraries=ole32 +CoFreeLibrary=ole32 +CoGetInstanceFromFile=combase +CoGetInstanceFromIStorage=combase +CoGetObject=ole32 +CoGetSystemSecurityPermissions=combase +CoInitialize=ole32 +CoInstall=ole32 +CoIsOle1Class=ole32 +CoLoadLibrary=ole32 +CoRegisterChannelHook=ole32 +CoRegisterInitializeSpy=combase +CoRegisterMallocSpy=combase +CoRegisterMessageFilter=combase +CoRevokeInitializeSpy=combase +CoRevokeMallocSpy=combase +CoTreatAsClass=ole32 +CreateAntiMoniker=ole32 +CreateBindCtx=ole32 +CreateClassMoniker=ole32 +CreateDataAdviseHolder=ole32 +CreateDataCache=ole32 +CreateFileMoniker=ole32 +CreateGenericComposite=ole32 +CreateItemMoniker=ole32 +CreateObjrefMoniker=ole32 +CreatePointerMoniker=ole32 +GetClassFile=ole32 +GetRunningObjectTable=ole32 +IsEqualGUID=ole32 +MkParseDisplayName=ole32 +MonikerCommonPrefixWith=ole32 +MonikerRelativePathTo=ole32 +StgGetIFillLockBytesOnFile=ole32 +StgGetIFillLockBytesOnILockBytes=ole32 +StgOpenAsyncDocfileOnIFillLockBytes=ole32 diff --git a/generation/Windows/um/objbase/header.txt b/generation/Windows/um/objbase/header.txt new file mode 100644 index 0000000000..3774023b34 --- /dev/null +++ b/generation/Windows/um/objbase/header.txt @@ -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/objbase.h in the Windows SDK for Windows 10.0.20348.0 +// Original source is Copyright © Microsoft. All rights reserved. diff --git a/generation/Windows/um/objbase/um-objbase.h b/generation/Windows/um/objbase/um-objbase.h new file mode 100644 index 0000000000..260ff91049 --- /dev/null +++ b/generation/Windows/um/objbase/um-objbase.h @@ -0,0 +1,2 @@ +#include "..\..\..\TerraFX.h" +#include diff --git a/sources/Interop/Windows/Windows/um/objbase/COINIT.cs b/sources/Interop/Windows/Windows/um/objbase/COINIT.cs new file mode 100644 index 0000000000..55ab8d44cb --- /dev/null +++ b/sources/Interop/Windows/Windows/um/objbase/COINIT.cs @@ -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/objbase.h in the Windows SDK for Windows 10.0.20348.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using static TerraFX.Interop.Windows.COINITBASE; + +namespace TerraFX.Interop.Windows; + +/// +public enum COINIT +{ + /// + COINIT_APARTMENTTHREADED = 0x2, + + /// + COINIT_MULTITHREADED = COINITBASE_MULTITHREADED, + + /// + COINIT_DISABLE_OLE1DDE = 0x4, + + /// + COINIT_SPEED_OVER_MEMORY = 0x8, +} diff --git a/sources/Interop/Windows/Windows/um/objbase/COMSD.cs b/sources/Interop/Windows/Windows/um/objbase/COMSD.cs new file mode 100644 index 0000000000..059dc9fc5e --- /dev/null +++ b/sources/Interop/Windows/Windows/um/objbase/COMSD.cs @@ -0,0 +1,22 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/objbase.h in the Windows SDK for Windows 10.0.20348.0 +// Original source is Copyright © Microsoft. All rights reserved. + +namespace TerraFX.Interop.Windows; + +/// +public enum COMSD +{ + /// + SD_LAUNCHPERMISSIONS = 0, + + /// + SD_ACCESSPERMISSIONS = 1, + + /// + SD_LAUNCHRESTRICTIONS = 2, + + /// + SD_ACCESSRESTRICTIONS = 3, +} diff --git a/sources/Interop/Windows/Windows/um/objbase/STG.cs b/sources/Interop/Windows/Windows/um/objbase/STG.cs new file mode 100644 index 0000000000..b7db9d2ae5 --- /dev/null +++ b/sources/Interop/Windows/Windows/um/objbase/STG.cs @@ -0,0 +1,18 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/objbase.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 STG +{ + [NativeTypeName("#define STG_TOEND 0xFFFFFFFFL")] + public const uint STG_TOEND = 0xFFFFFFFF; + + [NativeTypeName("#define STG_LAYOUT_SEQUENTIAL 0x00000000L")] + public const int STG_LAYOUT_SEQUENTIAL = 0x00000000; + + [NativeTypeName("#define STG_LAYOUT_INTERLEAVED 0x00000001L")] + public const int STG_LAYOUT_INTERLEAVED = 0x00000001; +} diff --git a/sources/Interop/Windows/Windows/um/objbase/Windows.cs b/sources/Interop/Windows/Windows/um/objbase/Windows.cs new file mode 100644 index 0000000000..2a84bdaa37 --- /dev/null +++ b/sources/Interop/Windows/Windows/um/objbase/Windows.cs @@ -0,0 +1,180 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/objbase.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 +{ + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CoInitialize([NativeTypeName("LPVOID")] void* pvReserved); + + /// + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT CoRegisterMallocSpy([NativeTypeName("LPMALLOCSPY")] IMallocSpy* pMallocSpy); + + /// + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT CoRevokeMallocSpy(); + + /// + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT CoRegisterInitializeSpy(IInitializeSpy* pSpy, ULARGE_INTEGER* puliCookie); + + /// + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT CoRevokeInitializeSpy(ULARGE_INTEGER uliCookie); + + /// + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT CoGetSystemSecurityPermissions(COMSD comSDType, [NativeTypeName("PSECURITY_DESCRIPTOR *")] void** ppSD); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HINSTANCE CoLoadLibrary([NativeTypeName("LPOLESTR")] ushort* lpszLibName, BOOL bAutoFree); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern void CoFreeLibrary(HINSTANCE hInst); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern void CoFreeAllLibraries(); + + /// + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT CoGetInstanceFromFile(COSERVERINFO* pServerInfo, [NativeTypeName("CLSID *")] Guid* pClsid, IUnknown* punkOuter, [NativeTypeName("DWORD")] uint dwClsCtx, [NativeTypeName("DWORD")] uint grfMode, [NativeTypeName("OLECHAR *")] ushort* pwszName, [NativeTypeName("DWORD")] uint dwCount, MULTI_QI* pResults); + + /// + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT CoGetInstanceFromIStorage(COSERVERINFO* pServerInfo, [NativeTypeName("CLSID *")] Guid* pClsid, IUnknown* punkOuter, [NativeTypeName("DWORD")] uint dwClsCtx, [NativeTypeName("struct IStorage *")] IStorage* pstg, [NativeTypeName("DWORD")] uint dwCount, MULTI_QI* pResults); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CoAllowSetForegroundWindow(IUnknown* pUnk, [NativeTypeName("LPVOID")] void* lpvReserved); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern BOOL CoIsOle1Class([NativeTypeName("const IID &")] Guid* rclsid); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern BOOL CoFileTimeToDosDateTime(FILETIME* lpFileTime, [NativeTypeName("LPWORD")] ushort* lpDosDate, [NativeTypeName("LPWORD")] ushort* lpDosTime); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern BOOL CoDosDateTimeToFileTime([NativeTypeName("WORD")] ushort nDosDate, [NativeTypeName("WORD")] ushort nDosTime, FILETIME* lpFileTime); + + /// + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT CoRegisterMessageFilter([NativeTypeName("LPMESSAGEFILTER")] IMessageFilter* lpMessageFilter, [NativeTypeName("LPMESSAGEFILTER *")] IMessageFilter** lplpMessageFilter); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CoRegisterChannelHook([NativeTypeName("const GUID &")] Guid* ExtensionUuid, IChannelHook* pChannelHook); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CoTreatAsClass([NativeTypeName("const IID &")] Guid* clsidOld, [NativeTypeName("const IID &")] Guid* clsidNew); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreateDataAdviseHolder([NativeTypeName("LPDATAADVISEHOLDER *")] IDataAdviseHolder** ppDAHolder); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreateDataCache([NativeTypeName("LPUNKNOWN")] IUnknown* pUnkOuter, [NativeTypeName("const IID &")] Guid* rclsid, [NativeTypeName("const IID &")] Guid* iid, [NativeTypeName("LPVOID *")] void** ppv); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT StgOpenAsyncDocfileOnIFillLockBytes(IFillLockBytes* pflb, [NativeTypeName("DWORD")] uint grfMode, [NativeTypeName("DWORD")] uint asyncFlags, IStorage** ppstgOpen); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT StgGetIFillLockBytesOnILockBytes(ILockBytes* pilb, IFillLockBytes** ppflb); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT StgGetIFillLockBytesOnFile([NativeTypeName("const OLECHAR *")] ushort* pwcsName, IFillLockBytes** ppflb); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CoInstall(IBindCtx* pbc, [NativeTypeName("DWORD")] uint dwFlags, uCLSSPEC* pClassSpec, QUERYCONTEXT* pQuery, [NativeTypeName("LPWSTR")] ushort* pszCodeBase); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT BindMoniker([NativeTypeName("LPMONIKER")] IMoniker* pmk, [NativeTypeName("DWORD")] uint grfOpt, [NativeTypeName("const IID &")] Guid* iidResult, [NativeTypeName("LPVOID *")] void** ppvResult); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CoGetObject([NativeTypeName("LPCWSTR")] ushort* pszName, BIND_OPTS* pBindOptions, [NativeTypeName("const IID &")] Guid* riid, void** ppv); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT MkParseDisplayName([NativeTypeName("LPBC")] IBindCtx* pbc, [NativeTypeName("LPCOLESTR")] ushort* szUserName, [NativeTypeName("ULONG *")] uint* pchEaten, [NativeTypeName("LPMONIKER *")] IMoniker** ppmk); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT MonikerRelativePathTo([NativeTypeName("LPMONIKER")] IMoniker* pmkSrc, [NativeTypeName("LPMONIKER")] IMoniker* pmkDest, [NativeTypeName("LPMONIKER *")] IMoniker** ppmkRelPath, BOOL dwReserved); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT MonikerCommonPrefixWith([NativeTypeName("LPMONIKER")] IMoniker* pmkThis, [NativeTypeName("LPMONIKER")] IMoniker* pmkOther, [NativeTypeName("LPMONIKER *")] IMoniker** ppmkCommon); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreateBindCtx([NativeTypeName("DWORD")] uint reserved, [NativeTypeName("LPBC *")] IBindCtx** ppbc); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreateGenericComposite([NativeTypeName("LPMONIKER")] IMoniker* pmkFirst, [NativeTypeName("LPMONIKER")] IMoniker* pmkRest, [NativeTypeName("LPMONIKER *")] IMoniker** ppmkComposite); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT GetClassFile([NativeTypeName("LPCOLESTR")] ushort* szFilename, [NativeTypeName("CLSID *")] Guid* pclsid); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreateClassMoniker([NativeTypeName("const IID &")] Guid* rclsid, [NativeTypeName("LPMONIKER *")] IMoniker** ppmk); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreateFileMoniker([NativeTypeName("LPCOLESTR")] ushort* lpszPathName, [NativeTypeName("LPMONIKER *")] IMoniker** ppmk); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreateItemMoniker([NativeTypeName("LPCOLESTR")] ushort* lpszDelim, [NativeTypeName("LPCOLESTR")] ushort* lpszItem, [NativeTypeName("LPMONIKER *")] IMoniker** ppmk); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreateAntiMoniker([NativeTypeName("LPMONIKER *")] IMoniker** ppmk); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreatePointerMoniker([NativeTypeName("LPUNKNOWN")] IUnknown* punk, [NativeTypeName("LPMONIKER *")] IMoniker** ppmk); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT CreateObjrefMoniker([NativeTypeName("LPUNKNOWN")] IUnknown* punk, [NativeTypeName("LPMONIKER *")] IMoniker** ppmk); + + /// + [DllImport("ole32", ExactSpelling = true)] + public static extern HRESULT GetRunningObjectTable([NativeTypeName("DWORD")] uint reserved, [NativeTypeName("LPRUNNINGOBJECTTABLE *")] IRunningObjectTable** pprot); + + [NativeTypeName("#define MARSHALINTERFACE_MIN 500")] + public const int MARSHALINTERFACE_MIN = 500; + + [NativeTypeName("#define ASYNC_MODE_COMPATIBILITY 0x00000001L")] + public const int ASYNC_MODE_COMPATIBILITY = 0x00000001; + + [NativeTypeName("#define ASYNC_MODE_DEFAULT 0x00000000L")] + public const int ASYNC_MODE_DEFAULT = 0x00000000; + + [NativeTypeName("#define STGTY_REPEAT 0x00000100L")] + public const int STGTY_REPEAT = 0x00000100; +} diff --git a/sources/Interop/Windows/Windows/um/winnt/LARGE_INTEGER.Manual.cs b/sources/Interop/Windows/Windows/um/winnt/LARGE_INTEGER.Manual.cs new file mode 100644 index 0000000000..c24af4e155 --- /dev/null +++ b/sources/Interop/Windows/Windows/um/winnt/LARGE_INTEGER.Manual.cs @@ -0,0 +1,20 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/winnt.h in the Windows SDK for Windows 10.0.20348.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System.Runtime.CompilerServices; + +namespace TerraFX.Interop.Windows; + +public partial struct LARGE_INTEGER +{ + public static implicit operator long(LARGE_INTEGER value) => value.QuadPart; + + public static implicit operator LARGE_INTEGER(long value) + { + Unsafe.SkipInit(out LARGE_INTEGER result); + result.QuadPart = value; + return result; + } +} diff --git a/sources/Interop/Windows/Windows/um/winnt/ULARGE_INTEGER.Manual.cs b/sources/Interop/Windows/Windows/um/winnt/ULARGE_INTEGER.Manual.cs new file mode 100644 index 0000000000..3a8d3dcbc1 --- /dev/null +++ b/sources/Interop/Windows/Windows/um/winnt/ULARGE_INTEGER.Manual.cs @@ -0,0 +1,20 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/winnt.h in the Windows SDK for Windows 10.0.20348.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System.Runtime.CompilerServices; + +namespace TerraFX.Interop.Windows; + +public partial struct ULARGE_INTEGER +{ + public static implicit operator ulong(ULARGE_INTEGER value) => value.QuadPart; + + public static implicit operator ULARGE_INTEGER(ulong value) + { + Unsafe.SkipInit(out ULARGE_INTEGER result); + result.QuadPart = value; + return result; + } +}