diff --git a/Core/Extensions/ReflectionExtensions.cs b/Core/Extensions/ReflectionExtensions.cs index 9954dfb0..878c6ea9 100644 --- a/Core/Extensions/ReflectionExtensions.cs +++ b/Core/Extensions/ReflectionExtensions.cs @@ -193,26 +193,36 @@ namespace Vanara.Extensions /// The reference, or null if type or assembly not found. public static Type LoadType(string typeName, string asmRef = null) { - Type ret = null; Assembly asm = null; try { asm = Assembly.LoadFrom(asmRef); } catch { } - if (!TryGetType(asm, typeName, ref ret)) + if (!TryGetType(asm, typeName, out var ret)) { foreach (var asm2 in AppDomain.CurrentDomain.GetAssemblies()) - if (TryGetType(asm2, typeName, ref ret)) break; + if (TryGetType(asm2, typeName, out ret)) break; } return ret; } + /// Sets a named property on an object. + /// The type of the property to be set. + /// The object on which to set the property. + /// Name of the property. + /// The property value to set on the object. + public static void SetPropertyValue(this object obj, string propName, T value) + { + try { obj?.GetType().InvokeMember(propName, BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, obj, new object[] { value }, null); } + catch { } + } + /// Tries the retrieve a reference from an assembly. /// Name of the type. /// The assembly from which to load the type. /// The reference, if found. /// true if the type was found in the assembly; otherwise, false. - private static bool TryGetType(Assembly asm, string typeName, ref Type type) + private static bool TryGetType(Assembly asm, string typeName, out Type type) { - if (asm == null) return false; - return (type = asm.GetType(typeName, false, false)) != null; + type = asm?.GetType(typeName, false, false); + return !(type is null); } } } \ No newline at end of file diff --git a/Core/Vanara.Core.csproj b/Core/Vanara.Core.csproj index 620fca21..1935c2da 100644 --- a/Core/Vanara.Core.csproj +++ b/Core/Vanara.Core.csproj @@ -9,7 +9,7 @@ * Memory stream based on marshaled memory Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard20 Vanara.Core $(AssemblyName) @@ -40,6 +40,8 @@ CorrepsondingAction, StringListPackMethod latest + true + ..\Vanara.snk true diff --git a/HelpBuilder/HelpBuilder.shfbproj b/HelpBuilder/HelpBuilder.shfbproj index 87214ead..6bc8b9f8 100644 --- a/HelpBuilder/HelpBuilder.shfbproj +++ b/HelpBuilder/HelpBuilder.shfbproj @@ -29,7 +29,7 @@ False False True - 2.0.0 + 2.0.1 2 True C#, Visual Basic diff --git a/PInvoke/AclUI/CorrelationReport.md b/PInvoke/AclUI/CorrelationReport.md index 3dc6a734..20e41414 100644 --- a/PInvoke/AclUI/CorrelationReport.md +++ b/PInvoke/AclUI/CorrelationReport.md @@ -12,6 +12,7 @@ Native Structure | Header | Managed Structure [SECURITY_OBJECT](http://msdn2.microsoft.com/en-us/library/hh448532) | aclui.h | Vanara.PInvoke.AclUI+SECURITY_OBJECT [SI_ACCESS](http://msdn2.microsoft.com/en-us/library/aa379603) | aclui.h | Vanara.PInvoke.AclUI+SI_ACCESS [SI_INHERIT_TYPE](http://msdn2.microsoft.com/en-us/library/aa379604) | aclui.h | Vanara.PInvoke.AclUI+SI_INHERIT_TYPE +[SI_OBJECT_INFO](http://msdn2.microsoft.com/en-us/library/aa379605) | aclui.h | Vanara.PInvoke.AclUI+SI_OBJECT_INFO [SID_INFO](http://msdn2.microsoft.com/en-us/library/aa379599) | aclui.h | Vanara.PInvoke.AclUI+SID_INFO ### Interfaces Native Interface | Native DLL | Header | Managed Interface diff --git a/PInvoke/AclUI/Vanara.PInvoke.AclUI.csproj b/PInvoke/AclUI/Vanara.PInvoke.AclUI.csproj index ea233285..40326b43 100644 --- a/PInvoke/AclUI/Vanara.PInvoke.AclUI.csproj +++ b/PInvoke/AclUI/Vanara.PInvoke.AclUI.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from AclUI.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.PInvoke.AclUI $(AssemblyName) @@ -28,13 +28,15 @@ Functions CreateSecurityPage, EditSecurity, EditSecurityAdvanced Structures -EFFPERM_RESULT_LIST, SECURITY_OBJECT, SI_ACCESS, SI_INHERIT_TYPE, SID_INFO +EFFPERM_RESULT_LIST, SECURITY_OBJECT, SI_ACCESS, SI_INHERIT_TYPE, SI_OBJECT_INFO, SID_INFO Interfaces IEffectivePermission, IEffectivePermission2, ISecurityInformation, ISecurityInformation2, ISecurityInformation3, ISecurityInformation4, ISecurityObjectTypeInfo latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/BITS/Vanara.PInvoke.BITS.csproj b/PInvoke/BITS/Vanara.PInvoke.BITS.csproj index 649f1413..6ca5ab1a 100644 --- a/PInvoke/BITS/Vanara.PInvoke.BITS.csproj +++ b/PInvoke/BITS/Vanara.PInvoke.BITS.csproj @@ -4,7 +4,7 @@ Interfaces, structures and constants imported for BITS (Background Intelligent Transfer Service). Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.BITS $(AssemblyName) @@ -32,6 +32,8 @@ IBackgroundCopyCallback, IBackgroundCopyCallback2, IBackgroundCopyCallback3, IBa latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/ComCtl32/CorrelationReport.md b/PInvoke/ComCtl32/CorrelationReport.md index dfd1ea93..a052b08d 100644 --- a/PInvoke/ComCtl32/CorrelationReport.md +++ b/PInvoke/ComCtl32/CorrelationReport.md @@ -76,17 +76,24 @@ Native Method | Native DLL | Header | Managed Method ### Structures Native Structure | Header | Managed Structure --- | --- | --- +[BUTTON_IMAGELIST](http://msdn2.microsoft.com/en-us/library/bb775953) | Commctrl.h | Vanara.PInvoke.ComCtl32+BUTTON_IMAGELIST +[BUTTON_SPLITINFO](http://msdn2.microsoft.com/en-us/library/bb775955) | Commctrl.h | Vanara.PInvoke.ComCtl32+BUTTON_SPLITINFO [COLORMAP](http://msdn2.microsoft.com/en-us/library/bb760448) | Commctrl.h | Vanara.PInvoke.ComCtl32+COLORMAP [COLORSCHEME](https://www.google.com/search?num=5&q=COLORSCHEME+site%3Amicrosoft.com) | | Vanara.PInvoke.ComCtl32+COLORSCHEME [COMBOBOXEXITEM](http://msdn2.microsoft.com/en-us/library/bb775746) | Commctrl.h | Vanara.PInvoke.ComCtl32+COMBOBOXEXITEM +[COMBOBOXINFO](http://msdn2.microsoft.com/en-us/library/bb775798) | Winuser.h | Vanara.PInvoke.ComCtl32+COMBOBOXINFO [DPASTREAMINFO](http://msdn2.microsoft.com/en-us/library/bb775504) | Dpa_dsa.h | Vanara.PInvoke.ComCtl32+DPASTREAMINFO [EDITBALLOONTIP](http://msdn2.microsoft.com/en-us/library/bb775466) | Commctrl.h | Vanara.PInvoke.ComCtl32+EDITBALLOONTIP [HDHITTESTINFO](http://msdn2.microsoft.com/en-us/library/bb775245) | Commctrl.h | Vanara.PInvoke.ComCtl32+HDHITTESTINFO +[HDITEM](http://msdn2.microsoft.com/en-us/library/bb775247) | Commctrl.h | Vanara.PInvoke.ComCtl32+HDITEM [HDLAYOUT](http://msdn2.microsoft.com/en-us/library/bb775249) | Commctrl.h | Vanara.PInvoke.ComCtl32+HDLAYOUT [HDTEXTFILTER](http://msdn2.microsoft.com/en-us/library/bb775251) | Commctrl.h | Vanara.PInvoke.ComCtl32+HDTEXTFILTER [HTREEITEM](https://www.google.com/search?num=5&q=HTREEITEM+site%3Amicrosoft.com) | | Vanara.PInvoke.ComCtl32+HTREEITEM +[IMAGEINFO](http://msdn2.microsoft.com/en-us/library/bb761393) | Commctrl.h | Vanara.PInvoke.ComCtl32+IMAGEINFO +[IMAGELISTDRAWPARAMS](http://msdn2.microsoft.com/en-us/library/bb761395) | Commctrl.h | Vanara.PInvoke.ComCtl32+IMAGELISTDRAWPARAMS [IMAGELISTSTATS](http://msdn2.microsoft.com/en-us/library/bb761397) | Commoncontrols.h | Vanara.PInvoke.ComCtl32+IMAGELISTSTATS [INITCOMMONCONTROLSEX](http://msdn2.microsoft.com/en-us/library/bb775507) | Commctrl.h | Vanara.PInvoke.ComCtl32+INITCOMMONCONTROLSEX +[LVBKIMAGE](http://msdn2.microsoft.com/en-us/library/bb774742) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVBKIMAGE [LVCOLUMN](http://msdn2.microsoft.com/en-us/library/bb774743) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVCOLUMN [LVFINDINFO](http://msdn2.microsoft.com/en-us/library/bb774745) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVFINDINFO [LVGROUP](http://msdn2.microsoft.com/en-us/library/bb774769) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVGROUP @@ -97,19 +104,64 @@ Native Structure | Header | Managed Structure [LVITEMCOLUMNINFO](http://msdn2.microsoft.com/en-us/library/bb774760) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVITEMCOLUMNINFO [LVITEMINDEX](http://msdn2.microsoft.com/en-us/library/bb761385) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVITEMINDEX [LVTILEVIEWINFO](http://msdn2.microsoft.com/en-us/library/bb774768) | Commctrl.h | Vanara.PInvoke.ComCtl32+LVTILEVIEWINFO +[NMBCDROPDOWN](http://msdn2.microsoft.com/en-us/library/bb775957) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMBCDROPDOWN +[NMBCHOTITEM](http://msdn2.microsoft.com/en-us/library/bb775959) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMBCHOTITEM +[NMCBEDRAGBEGIN](http://msdn2.microsoft.com/en-us/library/bb775748) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCBEDRAGBEGIN +[NMCBEENDEDIT](http://msdn2.microsoft.com/en-us/library/bb775750) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCBEENDEDIT +[NMCHAR](http://msdn2.microsoft.com/en-us/library/bb775508) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCHAR +[NMCOMBOBOXEX](http://msdn2.microsoft.com/en-us/library/bb775752) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCOMBOBOXEX +[NMCUSTOMDRAW](http://msdn2.microsoft.com/en-us/library/bb775483) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCUSTOMDRAW +[NMCUSTOMSPLITRECTINFO](http://msdn2.microsoft.com/en-us/library/bb775510) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCUSTOMSPLITRECTINFO +[NMCUSTOMTEXT](http://msdn2.microsoft.com/en-us/library/bb775512) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMCUSTOMTEXT +[NMHDDISPINFO](http://msdn2.microsoft.com/en-us/library/bb775253) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMHDDISPINFO +[NMHDFILTERBTNCLICK](http://msdn2.microsoft.com/en-us/library/bb775255) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMHDFILTERBTNCLICK +[NMHEADER](http://msdn2.microsoft.com/en-us/library/bb775257) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMHEADER +[NMIPADDRESS](http://msdn2.microsoft.com/en-us/library/bb761375) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMIPADDRESS +[NMKEY](http://msdn2.microsoft.com/en-us/library/bb775516) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMKEY +[NMLISTVIEW](http://msdn2.microsoft.com/en-us/library/bb774773) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMLISTVIEW +[NMMOUSE](http://msdn2.microsoft.com/en-us/library/bb775518) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMMOUSE +[NMOBJECTNOTIFY](http://msdn2.microsoft.com/en-us/library/bb775520) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMOBJECTNOTIFY +[NMTBDISPINFO](http://msdn2.microsoft.com/en-us/library/bb760452) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBDISPINFO +[NMTBGETINFOTIP](http://msdn2.microsoft.com/en-us/library/bb760454) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBGETINFOTIP +[NMTBHOTITEM](http://msdn2.microsoft.com/en-us/library/bb760456) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBHOTITEM +[NMTBRESTORE](http://msdn2.microsoft.com/en-us/library/bb760458) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBRESTORE +[NMTBSAVE](http://msdn2.microsoft.com/en-us/library/bb760471) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTBSAVE +[NMTOOLBAR](http://msdn2.microsoft.com/en-us/library/bb760473) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTOOLBAR +[NMTOOLTIPSCREATED](http://msdn2.microsoft.com/en-us/library/bb775522) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTOOLTIPSCREATED +[NMTRBTHUMBPOSCHANGING](http://msdn2.microsoft.com/en-us/library/bb760153) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTRBTHUMBPOSCHANGING +[NMTREEVIEW](http://msdn2.microsoft.com/en-us/library/bb773411) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTREEVIEW +[NMTTDISPINFO](http://msdn2.microsoft.com/en-us/library/bb760258) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTTDISPINFO +[NMTVASYNCDRAW](http://msdn2.microsoft.com/en-us/library/bb773413) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVASYNCDRAW +[NMTVCUSTOMDRAW](http://msdn2.microsoft.com/en-us/library/bb773415) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVCUSTOMDRAW +[NMTVDISPINFO](http://msdn2.microsoft.com/en-us/library/bb773418) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVDISPINFO +[NMTVDISPINFOEX](http://msdn2.microsoft.com/en-us/library/bb760143) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVDISPINFOEX +[NMTVGETINFOTIP](http://msdn2.microsoft.com/en-us/library/bb773421) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVGETINFOTIP +[NMTVITEMCHANGE](http://msdn2.microsoft.com/en-us/library/bb773425) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVITEMCHANGE +[NMTVKEYDOWN](http://msdn2.microsoft.com/en-us/library/bb773433) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMTVKEYDOWN +[NMUPDOWN](http://msdn2.microsoft.com/en-us/library/bb759893) | Commctrl.h | Vanara.PInvoke.ComCtl32+NMUPDOWN [PBRANGE](http://msdn2.microsoft.com/en-us/library/bb760822) | Commctrl.h | Vanara.PInvoke.ComCtl32+PBRANGE +[PROPSHEETHEADER](http://msdn2.microsoft.com/en-us/library/bb774546) | Commctrl.h | Vanara.PInvoke.ComCtl32+PROPSHEETHEADER +[PROPSHEETPAGE](http://msdn2.microsoft.com/en-us/library/bb774548) | Commctrl.h | Vanara.PInvoke.ComCtl32+PROPSHEETPAGE [TASKDIALOG_BUTTON](http://msdn2.microsoft.com/en-us/library/bb787475) | Commctrl.h | Vanara.PInvoke.ComCtl32+TASKDIALOG_BUTTON +[TASKDIALOGCONFIG](http://msdn2.microsoft.com/en-us/library/bb787473) | commctrl.h | Vanara.PInvoke.ComCtl32+TASKDIALOGCONFIG +[TBADDBITMAP](http://msdn2.microsoft.com/en-us/library/bb760475) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBADDBITMAP [TBBUTTON](http://msdn2.microsoft.com/en-us/library/bb760476) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBBUTTON [TBBUTTONINFO](http://msdn2.microsoft.com/en-us/library/bb760478) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBBUTTONINFO [TBINSERTMARK](http://msdn2.microsoft.com/en-us/library/bb760480) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBINSERTMARK [TBMETRICS](http://msdn2.microsoft.com/en-us/library/bb760482) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBMETRICS +[TBREPLACEBITMAP](http://msdn2.microsoft.com/en-us/library/bb760484) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBREPLACEBITMAP +[TBSAVEPARAMS](http://msdn2.microsoft.com/en-us/library/bb760486) | Commctrl.h | Vanara.PInvoke.ComCtl32+TBSAVEPARAMS [TCHITTESTINFO](http://msdn2.microsoft.com/en-us/library/bb760553) | Commctrl.h | Vanara.PInvoke.ComCtl32+TCHITTESTINFO [TCITEM](http://msdn2.microsoft.com/en-us/library/bb760554) | Commctrl.h | Vanara.PInvoke.ComCtl32+TCITEM [TCITEMHEADER](http://msdn2.microsoft.com/en-us/library/bb760813) | Commctrl.h | Vanara.PInvoke.ComCtl32+TCITEMHEADER +[TOOLINFO](http://msdn2.microsoft.com/en-us/library/bb760256) | Commctrl.h | Vanara.PInvoke.ComCtl32+TOOLINFO [TTGETTITLE](http://msdn2.microsoft.com/en-us/library/bb760260) | Commctrl.h | Vanara.PInvoke.ComCtl32+TTGETTITLE +[TTHITTESTINFO](http://msdn2.microsoft.com/en-us/library/bb760262) | Commctrl.h | Vanara.PInvoke.ComCtl32+TTHITTESTINFO [TVGETITEMPARTRECTINFO](http://msdn2.microsoft.com/en-us/library/bb773442) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVGETITEMPARTRECTINFO [TVHITTESTINFO](http://msdn2.microsoft.com/en-us/library/bb773448) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVHITTESTINFO +[TVINSERTSTRUCT](http://msdn2.microsoft.com/en-us/library/bb773452) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVINSERTSTRUCT [TVITEM](http://msdn2.microsoft.com/en-us/library/bb773456) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVITEM +[TVITEMEX](http://msdn2.microsoft.com/en-us/library/bb773459) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVITEMEX [TVSORTCB](http://msdn2.microsoft.com/en-us/library/bb773462) | Commctrl.h | Vanara.PInvoke.ComCtl32+TVSORTCB [UDACCEL](http://msdn2.microsoft.com/en-us/library/bb759897) | Commctrl.h | Vanara.PInvoke.ComCtl32+UDACCEL ### Interfaces diff --git a/PInvoke/ComCtl32/Vanara.PInvoke.ComCtl32.csproj b/PInvoke/ComCtl32/Vanara.PInvoke.ComCtl32.csproj index 6d24bbff..b1ac2674 100644 --- a/PInvoke/ComCtl32/Vanara.PInvoke.ComCtl32.csproj +++ b/PInvoke/ComCtl32/Vanara.PInvoke.ComCtl32.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from ComCtl32.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.PInvoke.ComCtl32 $(AssemblyName) @@ -28,7 +28,7 @@ Functions _TrackMouseEvent, CreateMappedBitmap, CreatePropertySheetPageA, CreatePropertySheetPageW, CreateUpDownControl, DefSubclassProc, DestroyPropertySheetPage, DPA_Clone, DPA_Create, DPA_CreateEx, DPA_DeleteAllPtrs, DPA_DeletePtr, DPA_Destroy, DPA_DestroyCallback, DPA_EnumCallback, DPA_GetPtr, DPA_GetPtrIndex, DPA_GetSize, DPA_Grow, DPA_InsertPtr, DPA_LoadStream, DPA_Merge, DPA_SaveStream, DPA_Search, DPA_SetPtr, DPA_Sort, DrawInsert, DrawShadowText, DrawStatusTextA, DrawStatusTextW, DSA_Clone, DSA_Create, DSA_DeleteAllItems, DSA_DeleteItem, DSA_Destroy, DSA_DestroyCallback, DSA_EnumCallback, DSA_GetItem, DSA_GetItemPtr, DSA_GetSize, DSA_InsertItem, DSA_SetItem, DSA_Sort, GetEffectiveClientRect, GetMUILanguage, GetWindowSubclass, HIMAGELIST_QueryInterface, ImageList_CoCreateInstance, ImageList_Create, ImageList_Destroy, ImageList_Duplicate, ImageList_GetIcon, ImageList_LoadImageA, ImageList_LoadImageW, ImageList_Read, ImageList_ReadEx, ImageList_Write, ImageList_WriteEx, InitCommonControlsEx, InitMUILanguage, LBItemFromPt, LoadIconMetric, LoadIconWithScaleDown, MakeDragList, MenuHelp, PropertySheetA, PropertySheetW, RemoveWindowSubclass, SendMessageA, SendMessageW, SetWindowSubclass, ShowHideMenuCtl, Str_SetPtrW, TaskDialog, TaskDialogIndirect Structures -COMBOBOXEXITEM, COLORSCHEME, INITCOMMONCONTROLSEX, EDITBALLOONTIP, HDTEXTFILTER, HDHITTESTINFO, HDLAYOUT, IMAGELISTSTATS, LVFINDINFO, LVGROUPMETRICS, LVHITTESTINFO, LVINSERTMARK, LVITEMCOLUMNINFO, LVITEMINDEX, LVTILEVIEWINFO, LVCOLUMN, LVGROUP, LVITEM, PBRANGE, TCHITTESTINFO, TCITEM, TCITEMHEADER, TASKDIALOG_BUTTON, COLORMAP, TBBUTTON, TBBUTTONINFO, TBINSERTMARK, TBMETRICS, TTGETTITLE, HTREEITEM, TVHITTESTINFO, TVITEM, TVSORTCB, TVGETITEMPARTRECTINFO, UDACCEL, DPASTREAMINFO +BUTTON_IMAGELIST, BUTTON_SPLITINFO, NMBCDROPDOWN, NMBCHOTITEM, COMBOBOXINFO, NMCBEDRAGBEGIN, NMCBEENDEDIT, NMCOMBOBOXEX, COMBOBOXEXITEM, COLORSCHEME, INITCOMMONCONTROLSEX, NMCHAR, NMCUSTOMDRAW, NMCUSTOMSPLITRECTINFO, NMCUSTOMTEXT, NMKEY, NMMOUSE, NMOBJECTNOTIFY, NMTOOLTIPSCREATED, EDITBALLOONTIP, HDTEXTFILTER, HDHITTESTINFO, HDITEM, HDLAYOUT, NMHDDISPINFO, NMHDFILTERBTNCLICK, NMHEADER, IMAGEINFO, IMAGELISTSTATS, IMAGELISTDRAWPARAMS, NMIPADDRESS, LVFINDINFO, LVGROUPMETRICS, LVHITTESTINFO, LVINSERTMARK, LVITEMCOLUMNINFO, LVITEMINDEX, LVTILEVIEWINFO, NMLISTVIEW, LVBKIMAGE, LVCOLUMN, LVGROUP, LVITEM, PBRANGE, PROPSHEETHEADER, PROPSHEETPAGE, TCHITTESTINFO, TCITEM, TCITEMHEADER, TASKDIALOG_BUTTON, TASKDIALOGCONFIG, COLORMAP, NMTBDISPINFO, NMTBGETINFOTIP, NMTBHOTITEM, NMTBRESTORE, NMTBSAVE, NMTOOLBAR, TBADDBITMAP, TBBUTTON, TBBUTTONINFO, TBINSERTMARK, TBMETRICS, TBREPLACEBITMAP, TBSAVEPARAMS, NMTTDISPINFO, TOOLINFO, TTGETTITLE, TTHITTESTINFO, NMTRBTHUMBPOSCHANGING, HTREEITEM, NMTREEVIEW, NMTVASYNCDRAW, NMTVCUSTOMDRAW, NMTVDISPINFO, NMTVDISPINFOEX, NMTVGETINFOTIP, NMTVITEMCHANGE, NMTVKEYDOWN, TVHITTESTINFO, TVINSERTSTRUCT, TVITEM, TVITEMEX, TVSORTCB, TVGETITEMPARTRECTINFO, NMUPDOWN, UDACCEL, DPASTREAMINFO Interfaces IImageList, IImageList2 @@ -36,6 +36,8 @@ IImageList, IImageList2 latest Library.manifest + true + ..\..\Vanara.snk true diff --git a/PInvoke/CredUI/CorrelationReport.md b/PInvoke/CredUI/CorrelationReport.md index e9da704e..a8485bbf 100644 --- a/PInvoke/CredUI/CorrelationReport.md +++ b/PInvoke/CredUI/CorrelationReport.md @@ -19,5 +19,6 @@ Native Method | Native DLL | Header | Managed Method ### Structures Native Structure | Header | Managed Structure --- | --- | --- +[CREDUI_INFO](http://msdn2.microsoft.com/en-us/library/aa375183) | wincred.h | Vanara.PInvoke.CredUI+CREDUI_INFO [PSEC_WINNT_CREDUI_CONTEXT](https://www.google.com/search?num=5&q=PSEC_WINNT_CREDUI_CONTEXT+site%3Amicrosoft.com) | | Vanara.PInvoke.CredUI+PSEC_WINNT_CREDUI_CONTEXT [PSEC_WINNT_CREDUI_CONTEXT_VECTOR](https://www.google.com/search?num=5&q=PSEC_WINNT_CREDUI_CONTEXT_VECTOR+site%3Amicrosoft.com) | | Vanara.PInvoke.CredUI+PSEC_WINNT_CREDUI_CONTEXT_VECTOR diff --git a/PInvoke/CredUI/Vanara.PInvoke.CredUI.csproj b/PInvoke/CredUI/Vanara.PInvoke.CredUI.csproj index 63012e1b..db4664bc 100644 --- a/PInvoke/CredUI/Vanara.PInvoke.CredUI.csproj +++ b/PInvoke/CredUI/Vanara.PInvoke.CredUI.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from CredUI.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.PInvoke.CredUI $(AssemblyName) @@ -28,10 +28,12 @@ Functions CredPackAuthenticationBufferA, CredPackAuthenticationBufferW, CredUICmdLinePromptForCredentialsA, CredUICmdLinePromptForCredentialsW, CredUIConfirmCredentialsA, CredUIConfirmCredentialsW, CredUIParseUserNameA, CredUIParseUserNameW, CredUIPromptForCredentialsA, CredUIPromptForCredentialsW, CredUIPromptForWindowsCredentialsA, CredUIPromptForWindowsCredentialsW, CredUIReadSSOCredA, CredUIReadSSOCredW, CredUIStoreSSOCredA, CredUIStoreSSOCredW, CredUnPackAuthenticationBufferA, CredUnPackAuthenticationBufferW, SspiGetCredUIContext, SspiIsPromptingNeeded, SspiPromptForCredentialsA, SspiPromptForCredentialsW, SspiUnmarshalCredUIContext, SspiUpdateCredentials Structures -PSEC_WINNT_CREDUI_CONTEXT, PSEC_WINNT_CREDUI_CONTEXT_VECTOR +PSEC_WINNT_CREDUI_CONTEXT, PSEC_WINNT_CREDUI_CONTEXT_VECTOR, CREDUI_INFO latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/Crypt32/Vanara.PInvoke.Crypt32.csproj b/PInvoke/Crypt32/Vanara.PInvoke.Crypt32.csproj deleted file mode 100644 index fb8fda40..00000000 --- a/PInvoke/Crypt32/Vanara.PInvoke.Crypt32.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - - Methods, structures and constants imported from Crypt32.dll. - Copyright © 2017-2018 - $(AssemblyName) - 2.0.0 - net20;net35;net40;net45;netstandard2.0 - Vanara.PInvoke.Crypt32 - $(AssemblyName) - Vanara.PInvoke - David Hall - https://github.com/dahall/vanara - https://github.com/dahall/vanara/blob/master/LICENSE - https://raw.githubusercontent.com/dahall/Vanara/master/docs/icons/Vanara48x48.png - https://github.com/dahall/vanara - Git - pinvoke vanara net-extensions interop - en-US - true - true - GitHub Community - Vanara - True - Currently implements: - -Structures -CERT_CONTEXT, CERT_EXTENSION, CERT_INFO, CERT_PUBLIC_KEY_INFO, CRYPT_ALGORITHM_IDENTIFIER, CRYPTOAPI_BLOB - - - latest - - - true - bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PInvoke/Cryptography/BCrypt/BCrypt.cs b/PInvoke/Cryptography/BCrypt/BCrypt.cs new file mode 100644 index 00000000..cea71ca7 --- /dev/null +++ b/PInvoke/Cryptography/BCrypt/BCrypt.cs @@ -0,0 +1,9935 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using Vanara.Extensions; +using Vanara.InteropServices; +using static Vanara.PInvoke.NCrypt; + +namespace Vanara.PInvoke +{ + /// Methods and data types found in BCrypt.dll. + public static partial class BCrypt + { + /// A value that specifies the algorithm operation types to include in the enumeration. + [PInvokeData("bcrypt.h", MSDNShortId = "7fa227c0-2b80-49ab-8a19-72f8444d5507")] + [Flags] + public enum AlgOperations + { + /// Include the cipher algorithms in the enumeration. + BCRYPT_CIPHER_OPERATION = 0x00000001, + + /// Include the hash algorithms in the enumeration. + BCRYPT_HASH_OPERATION = 0x00000002, + + /// Include the asymmetric encryption algorithms in the enumeration. + BCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION = 0x00000004, + + /// Include the secret agreement algorithms in the enumeration. + BCRYPT_SECRET_AGREEMENT_OPERATION = 0x00000008, + + /// Include the signature algorithms in the enumeration. + BCRYPT_SIGNATURE_OPERATION = 0x00000010, + + /// Include the random number generator (RNG) algorithms in the enumeration. + BCRYPT_RNG_OPERATION = 0x00000020, + + /// Undocumented. + BCRYPT_KEY_DERIVATION_OPERATION = 0x00000040, + } + + /// Primitive algorithm provider functions. + [PInvokeData("bcrypt.h", MSDNShortId = "aceba9c0-19e6-4f3c-972a-752feed4a9f8")] + [Flags] + public enum AlgProviderFlags + { + /// + /// Loads the provider into the nonpaged memory pool. If this flag is not present, the provider is loaded into the paged memory + /// pool. When this flag is specified, the handle returned must not be closed before all dependent objects have been freed. This flag is only supported in kernel mode and allows subsequent operations on the provider to be processed at + /// the Dispatch level. If the provider does not support being called at dispatch level, then it will return an error when opened + /// using this flag. + /// + /// Windows Server 2008 and Windows Vista: This flag is only supported by the Microsoft algorithm providers and only for hashing + /// algorithms and symmetric key cryptographic algorithms. + /// + /// + BCRYPT_PROV_DISPATCH = 0x00000001, + + /// + /// The provider will perform the Hash-Based Message Authentication Code (HMAC) algorithm with the specified hash algorithm. This + /// flag is only used by hash algorithm providers. + /// + BCRYPT_ALG_HANDLE_HMAC_FLAG = 0x00000008, + + /// + /// Creates a reusable hashing object. The object can be used for a new hashing operation immediately after calling + /// BCryptFinishHash. For more information, see Creating a Hash with CNG. + /// Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista: This flag is not supported. + /// + BCRYPT_HASH_REUSABLE_FLAG = 0x00000020, + + /// + /// Specifies that the target algorithm is AES and that the key therefore must be double expanded. This flag is only valid with + /// the CAPI_KDF algorithm. + /// + BCRYPT_CAPI_AES_FLAG = 0x00000010, + + /// Undocumented + BCRYPT_MULTI_FLAG = 0x00000040, + } + + /// The BCRYPT_HASH_OPERATION_TYPE enumeration specifies the hash operation type. + [PInvokeData("bcrypt.h")] + public enum BCRYPT_HASH_OPERATION_TYPE + { + /// + /// The operation performed is equivalent to calling the BCryptHashData function on the hash object array element with + /// pbBuffer/cbBuffer pointing to the buffer to be hashed. + /// + BCRYPT_HASH_OPERATION_HASH_DATA = 1, + + /// + /// The operation performed is equivalent to calling the BCryptFinishHash function on the hash object array element with + /// pbBuffer/cbBuffer pointing to the output buffer that receives the result. + /// + BCRYPT_HASH_OPERATION_FINISH_HASH = 2, + } + + /// + /// The BCRYPT_MULTI_OPERATION_TYPE enumeration specifies type of multi-operation that is passed to the BCryptProcessMultiOperations function. + /// + [PInvokeData("bcrypt.h", MSDNShortId = "5FD28AC3-46D2-4F06-BF06-F5FEF8E531F5")] + public enum BCRYPT_MULTI_OPERATION_TYPE + { + /// + /// A hash operation. This value identifies the hObject parameter as a multi-hash object and the pOperations pointer as pointing + /// to an array of BCRYPT_MULTI_HASH_OPERATION elements. + /// + BCRYPT_OPERATION_TYPE_HASH = 1, + } + + /// Magic numbers for the various blobs. + public enum BlobMagicNumber + { + BCRYPT_DH_PARAMETERS_MAGIC = 0x4d504844, + BCRYPT_DH_PRIVATE_MAGIC = 0x56504844, + BCRYPT_DH_PUBLIC_MAGIC = 0x42504844, + BCRYPT_DSA_PARAMETERS_MAGIC_V2 = 0x324d5044, + BCRYPT_DSA_PRIVATE_MAGIC = 0x56505344, + BCRYPT_DSA_PRIVATE_MAGIC_V2 = 0x32565044, + BCRYPT_DSA_PUBLIC_MAGIC = 0x42505344, + BCRYPT_DSA_PUBLIC_MAGIC_V2 = 0x32425044, + BCRYPT_ECC_PARAMETERS_MAGIC = 0x50434345, + BCRYPT_ECDH_PRIVATE_GENERIC_MAGIC = 0x564B4345, + BCRYPT_ECDH_PRIVATE_P256_MAGIC = 0x324B4345, + BCRYPT_ECDH_PRIVATE_P384_MAGIC = 0x344B4345, + BCRYPT_ECDH_PRIVATE_P521_MAGIC = 0x364B4345, + BCRYPT_ECDH_PUBLIC_GENERIC_MAGIC = 0x504B4345, + BCRYPT_ECDH_PUBLIC_P256_MAGIC = 0x314B4345, + BCRYPT_ECDH_PUBLIC_P384_MAGIC = 0x334B4345, + BCRYPT_ECDH_PUBLIC_P521_MAGIC = 0x354B4345, + BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC = 0x56444345, + BCRYPT_ECDSA_PRIVATE_P256_MAGIC = 0x32534345, + BCRYPT_ECDSA_PRIVATE_P384_MAGIC = 0x34534345, + BCRYPT_ECDSA_PRIVATE_P521_MAGIC = 0x36534345, + BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC = 0x50444345, + BCRYPT_ECDSA_PUBLIC_P256_MAGIC = 0x31534345, + BCRYPT_ECDSA_PUBLIC_P384_MAGIC = 0x33534345, + BCRYPT_ECDSA_PUBLIC_P521_MAGIC = 0x35534345, + BCRYPT_KEY_DATA_BLOB_MAGIC = 0x4d42444b, + BCRYPT_RSAFULLPRIVATE_MAGIC = 0x33415352, + BCRYPT_RSAPRIVATE_MAGIC = 0x32415352, + BCRYPT_RSAPUBLIC_MAGIC = 0x31415352, + } + + /// A set of flags that determine the options for the configuration context. + [PInvokeData("bcrypt.h", MSDNShortId = "3e07b7ae-84ef-4b77-bd49-d96906eaa4f8")] + [Flags] + public enum ContextConfigFlags + { + /// + /// + /// Restricts the set of cryptographic functions in an interface to those that the current CNG context is specifically registered + /// to support. If this flag is set, then any attempts to resolve a given function will succeed only if one of the following is true: + /// + /// + /// The function exists within the current CNG context. + /// + /// The function exists in some interface in the default context, and an instance of that same interface also exists within the + /// current CNG context. + /// + /// + /// + CRYPT_EXCLUSIVE = 0x00000001, + + /// + /// Indicates that this entry in the enterprise-wide configuration table should take precedence over any and all corresponding + /// entries in the local-machine configuration table for this context. This flag only applies to entries in the enterprise-wide + /// configuration table. Without this flag, local machine configuration entries take precedence. + /// + CRYPT_OVERRIDE = 0x00010000, + } + + /// Configuration tables + [PInvokeData("bcrypt.h", MSDNShortId = "4f5b6db0-775d-42de-b9d9-a99fb11c89f2")] + public enum ContextConfigTable + { + /// The context exists in the local-machine configuration table. + CRYPT_LOCAL = 0x00000001, + + /// This value is not available for use. + CRYPT_DOMAIN = 0x00000002, + } + + /// + /// Specifies the position in the list at which to insert this function. The function is inserted at this position ahead of any + /// existing functions. + /// + [PInvokeData("bcrypt.h", MSDNShortId = "4f5b6db0-775d-42de-b9d9-a99fb11c89f2")] + public enum CryptPriority : uint + { + /// The crypt priority top + CRYPT_PRIORITY_TOP = 0x00000000, + + /// The crypt priority bottom + CRYPT_PRIORITY_BOTTOM = 0xFFFFFFFF + } + + /// + /// Flags used by . + /// + [PInvokeData("bcrypt.h", MSDNShortId = "33c3cbf7-6c08-42ed-ac3f-feb71f3a9cbf")] + [Flags] + public enum DeriveKeyFlags + { + /// + /// The secret agreement value will also serve as the HMAC key. If this flag is specified, the KDF_HMAC_KEY parameter should not + /// be included in the set of parameters in the pParameterList parameter. This flag is only used by the BCRYPT_KDF_HMAC key + /// derivation function. + /// + KDF_USE_SECRET_AS_HMAC_KEY_FLAG = 1 + } + + /// Flags used by BCryptEncrypt. + [PInvokeData("bcrypt.h", MSDNShortId = "69fe4530-4b7c-40db-a85c-f9dc458735e7")] + public enum EncryptFlags + { + /// + /// Allows the encryption algorithm to pad the data to the next block size. If this flag is not specified, the size of the + /// plaintext specified in the cbInput parameter must be a multiple of the algorithm's block size. The block size can be obtained + /// by calling the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH property for the key. This will provide the size of + /// a block for the algorithm. This flag must not be used with the authenticated encryption modes (AES-CCM and AES-GCM). + /// + BCRYPT_BLOCK_PADDING = 0x00000001, + + /// + /// Do not use any padding. The pPaddingInfo parameter is not used. The size of the plaintext specified in the cbInput parameter + /// must be a multiple of the algorithm's block size. + /// + BCRYPT_PAD_NONE = 0x00000001, + + /// + /// The data will be padded with a random number to round out the block size. The pPaddingInfo parameter is not used. + /// + BCRYPT_PAD_PKCS1 = 0x00000002, + + /// + /// Use the Optimal Asymmetric Encryption Padding (OAEP) scheme. The pPaddingInfo parameter is a pointer to a + /// BCRYPT_OAEP_PADDING_INFO structure. + /// + BCRYPT_PAD_OAEP = 0x00000004, + + /// Undocumented + BCRYPT_PAD_PSS = 0x00000008, + + /// Undocumented + BCRYPT_PAD_PKCS1_OPTIONAL_HASH_OID = 0x00000010, + } + + /// Flags used by BCryptGenRandom. + [PInvokeData("bcrypt.h", MSDNShortId = "7c6cee3a-f2c5-46f3-8cfe-984316f323d9")] + [Flags] + public enum GenRandomFlags + { + /// + /// This function will use the number in the pbBuffer buffer as additional entropy for the random number. If this flag is not + /// specified, this function will use a random number for the entropy. + /// Windows 8 and later: This flag is ignored in Windows 8 and later. + /// + BCRYPT_RNG_USE_ENTROPY_IN_BUFFER = 0x00000001, + + /// + /// Use the system-preferred random number generator algorithm. The hAlgorithm parameter must be NULL. + /// BCRYPT_USE_SYSTEM_PREFERRED_RNG is only supported at PASSIVE_LEVEL IRQL. For more information, see Remarks. + /// Windows Vista: This flag is not supported. + /// + BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002, + } + + /// A set of flags that modify the behavior of this function + [PInvokeData("bcrypt.h", MSDNShortId = "271fc084-6121-4666-b521-b849c7d7966c")] + [Flags] + public enum ImportFlags + { + /// Do not validate the public portion of the key pair. + BCRYPT_NO_KEY_VALIDATION = 0x00000008, + } + + /// Identifies the cryptographic interface to add the function to. + [PInvokeData("bcrypt.h", MSDNShortId = "4f5b6db0-775d-42de-b9d9-a99fb11c89f2")] + public enum InterfaceId + { + /// Add the function to the list of cipher functions. + BCRYPT_CIPHER_INTERFACE = 0x00000001, + + /// Add the function to the list of hash functions. + BCRYPT_HASH_INTERFACE = 0x00000002, + + /// Add the function to the list of asymmetric encryption functions. + BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE = 0x00000003, + + /// Add the function to the list of secret agreement functions. + BCRYPT_SECRET_AGREEMENT_INTERFACE = 0x00000004, + + /// Add the function to the list of signature functions. + BCRYPT_SIGNATURE_INTERFACE = 0x00000005, + + /// Add the function to the list of random number generator functions. + BCRYPT_RNG_INTERFACE = 0x00000006, + + /// Undocumented + BCRYPT_KEY_DERIVATION_INTERFACE = 0x00000007, + + /// Add the function to the list of key storage functions. + NCRYPT_KEY_STORAGE_INTERFACE = 0x00010001, + + /// Add the function to the list of Schannel functions. + NCRYPT_SCHANNEL_INTERFACE = 0x00010002, + + /// + /// Add the function to the list of signature suites that Schannel will accept for TLS 1.2. + /// Windows Vista and Windows Server 2008: This value is not supported. + /// + NCRYPT_SCHANNEL_SIGNATURE_INTERFACE = 0x00010003, + + /// Undocumented + NCRYPT_KEY_PROTECTION_INTERFACE = 0x00010004, + } + + /// Flags used with BCryptKeyDerivation. + [PInvokeData("bcrypt.h", MSDNShortId = "D0B91FFE-2E72-4AE3-A84F-DC598C02CF53")] + [Flags] + public enum KeyDerivationFlags + { + /// + /// Specifies that the target algorithm is AES and that the key therefore must be double expanded. This flag is only valid with + /// the CAPI_KDF algorithm. + /// + BCRYPT_CAPI_AES_FLAG = 0, + } + + [Flags] + public enum PaddingScheme : uint + { + /// The provider supports padding added by the router. + BCRYPT_SUPPORTED_PAD_ROUTER = 0x00000001, + + /// The provider supports the PKCS1 encryption padding scheme. + BCRYPT_SUPPORTED_PAD_PKCS1_ENC = 0x00000002, + + /// The provider supports the PKCS1 signature padding scheme. + BCRYPT_SUPPORTED_PAD_PKCS1_SIG = 0x00000004, + + /// The provider supports the OAEP padding scheme. + BCRYPT_SUPPORTED_PAD_OAEP = 0x00000008, + + /// The provider supports the PSS padding scheme. + BCRYPT_SUPPORTED_PAD_PSS = 0x00000010, + } + + /// Specifies the type of information to retrieve. + public enum ProviderInfoType + { + /// Retrieve the user mode information for the provider. + CRYPT_UM = 0x00000001, + + /// Retrieve the kernel mode information for the provider. + CRYPT_KM = 0x00000002, + + /// Retrieve both the user mode and kernel mode information for the provider. + CRYPT_MM = 0x00000003, + + /// Retrieve any information for the provider. + CRYPT_ANY = 0x00000004, + } + + /// A set of flags that modify the behavior of BCryptResolveProviders. + [PInvokeData("bcrypt.h", MSDNShortId = "cf30f635-4918-4911-9db0-df90d26a2f1a")] + [Flags] + public enum ResolveProviderFlags + { + /// + /// This function will retrieve all of the functions supported by each provider that meets the specified criteria. If this flag + /// is not specified, this function will only retrieve the first function of the provider or providers that meet the specified criteria. + /// + CRYPT_ALL_FUNCTIONS = 1, + + /// + /// This function will retrieve all of the providers that meet the specified criteria. If this flag is not specified, this + /// function will only retrieve the first provider that is found that meets the specified criteria. + /// + CRYPT_ALL_PROVIDERS = 2, + } + + /// + /// + /// [ BCryptAddContextFunction is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// + /// The BCryptAddContextFunction function adds a cryptographic function to the list of functions that are supported by an + /// existing CNG context. + /// + /// + /// + /// Identifies the configuration table that the context exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// The context exists in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to add the function to. + /// + /// + /// Identifies the cryptographic interface to add the function to. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// Add the function to the list of asymmetric encryption functions. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// Add the function to the list of cipher functions. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// Add the function to the list of hash functions. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// Add the function to the list of random number generator functions. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// Add the function to the list of secret agreement functions. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// Add the function to the list of signature functions. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// Add the function to the list of key storage functions. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// Add the function to the list of Schannel functions. + /// + /// + /// NCRYPT_SCHANNEL_SIGNATURE_INTERFACE + /// + /// Add the function to the list of signature suites that Schannel will accept for TLS 1.2. Windows Vista and Windows Server 2008: + /// This value is not supported. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the cryptographic function to add. + /// + /// + /// + /// Specifies the position in the list at which to insert this function. The function is inserted at this position ahead of any + /// existing functions. The CRYPT_PRIORITY_TOP value is used to insert the function at the top of the list. The + /// CRYPT_PRIORITY_BOTTOM value is used to insert the function at the end of the list. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_NOT_FOUND + /// The context could not be found. + /// + /// + /// + /// + /// If the function added is already in the list, it will be removed and inserted at the new position. + /// BCryptAddContextFunction can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptaddcontextfunction NTSTATUS BCryptAddContextFunction( + // ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, ULONG dwPosition ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "4f5b6db0-775d-42de-b9d9-a99fb11c89f2")] + public static extern NTStatus BCryptAddContextFunction(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction, CryptPriority dwPosition); + + /// + /// The BCryptCloseAlgorithmProvider function closes an algorithm provider. + /// + /// + /// + /// A handle that represents the algorithm provider to close. This handle is obtained by calling the BCryptOpenAlgorithmProvider function. + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are defined for this function. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// + /// + /// + /// BCryptCloseAlgorithmProvider can be called either from user mode or kernel mode. Kernel mode callers must be executing at + /// PASSIVE_LEVEL IRQL. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptclosealgorithmprovider NTSTATUS + // BCryptCloseAlgorithmProvider( BCRYPT_ALG_HANDLE hAlgorithm, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "def90d52-87e0-40e6-9c50-fd77177991d0")] + public static extern NTStatus BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE hAlgorithm, uint dwFlags = 0); + + /// + /// + /// [ BCryptConfigureContext is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// The BCryptConfigureContext function sets the configuration information for an existing CNG context. + /// + /// + /// Identifies the configuration table that the context exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// The context exists in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to set the configuration information for. + /// + /// + /// + /// The address of a CRYPT_CONTEXT_CONFIG structure that contains the new context configuration information. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// BCryptConfigureContext can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptconfigurecontext NTSTATUS BCryptConfigureContext( + // ULONG dwTable, LPCWSTR pszContext, PCRYPT_CONTEXT_CONFIG pConfig ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "7989fefc-64fe-4ab3-9a48-7992edac171f")] + public static extern NTStatus BCryptConfigureContext(ContextConfigTable dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, in CRYPT_CONTEXT_CONFIG pConfig); + + /// + /// + /// [ BCryptConfigureContextFunction is available for use in the operating systems specified in the Requirements section. It + /// may be altered or unavailable in subsequent versions.] + /// + /// + /// The BCryptConfigureContextFunction function sets the configuration information for the cryptographic function of an + /// existing CNG context. + /// + /// + /// + /// Identifies the configuration table that the context exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// The context exists in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to set the cryptographic function + /// configuration information for. + /// + /// + /// + /// + /// Identifies the cryptographic interface to set the function configuration information for. This can be one of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// Set the function configuration information in the list of asymmetric encryption functions. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// Set the function configuration information in the list of cipher functions. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// Set the function configuration information in the list of hash functions. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// Set the function configuration information in the list of random number generator functions. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// Set the function configuration information in the list of secret agreement functions. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// Set the function configuration information in the list of signature functions. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// Set the function configuration information in the list of key storage functions. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// Set the function configuration information in the list of Schannel functions. + /// + /// + /// NCRYPT_SCHANNEL_SIGNATURE_INTERFACE + /// + /// Set the function configuration information in the list of signature suites that Schannel accepts for TLS 1.2. Windows Vista and + /// Windows Server 2008: This value is not supported. + /// + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the cryptographic function to set the configuration + /// information for. + /// + /// + /// + /// The address of a CRYPT_CONTEXT_FUNCTION_CONFIG structure that contains the new function configuration information. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// BCryptConfigureContextFunction can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptconfigurecontextfunction NTSTATUS + // BCryptConfigureContextFunction( ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, + // PCRYPT_CONTEXT_FUNCTION_CONFIG pConfig ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "e93c5e3e-3c63-49a3-8c8c-6510e10611ea")] + public static extern NTStatus BCryptConfigureContextFunction(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction, in CRYPT_CONTEXT_FUNCTION_CONFIG pConfig); + + /// + /// + /// [ BCryptCreateContext is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// The BCryptCreateContext function creates a new CNG configuration context. + /// + /// + /// Identifies the configuration table to create the context in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// Create the context in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to create. + /// + /// + /// + /// A pointer to a CRYPT_CONTEXT_CONFIG structure that contains additional configuration data for the new context. This parameter can + /// be NULL if it is not needed. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// BCryptCreateContext can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptcreatecontext NTSTATUS BCryptCreateContext( ULONG + // dwTable, LPCWSTR pszContext, PCRYPT_CONTEXT_CONFIG pConfig ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "68f71010-0089-4433-bc89-f61f190e0bff")] + public static extern NTStatus BCryptCreateContext(ContextConfigTable dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, in CRYPT_CONTEXT_CONFIG pConfig); + + /// + /// + /// [ BCryptCreateContext is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// The BCryptCreateContext function creates a new CNG configuration context. + /// + /// + /// Identifies the configuration table to create the context in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// Create the context in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to create. + /// + /// + /// + /// A pointer to a CRYPT_CONTEXT_CONFIG structure that contains additional configuration data for the new context. This parameter can + /// be NULL if it is not needed. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// BCryptCreateContext can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptcreatecontext NTSTATUS BCryptCreateContext( ULONG + // dwTable, LPCWSTR pszContext, PCRYPT_CONTEXT_CONFIG pConfig ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "68f71010-0089-4433-bc89-f61f190e0bff")] + public static extern NTStatus BCryptCreateContext(ContextConfigTable dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, IntPtr pConfig = default); + + /// + /// The BCryptCreateHash function is called to create a hash or Message Authentication Code (MAC) object. + /// + /// + /// + /// The handle of an algorithm provider created by using the BCryptOpenAlgorithmProvider function. The algorithm that was specified + /// when the provider was created must support the hash interface. + /// + /// + /// + /// + /// A pointer to a BCRYPT_HASH_HANDLE value that receives a handle that represents the hash or MAC object. This handle is used + /// in subsequent hashing or MAC functions, such as the BCryptHashData function. When you have finished using this handle, release it + /// by passing it to the BCryptDestroyHash function. + /// + /// + /// + /// + /// A pointer to a buffer that receives the hash or MAC object. The cbHashObject parameter contains the size of this buffer. The + /// required size of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH + /// property. This will provide the size of the hash or MAC object for the specified algorithm. + /// + /// This memory can only be freed after the handle pointed to by the phHash parameter is destroyed. + /// + /// If the value of this parameter is NULL and the value of the cbHashObject parameter is zero, the memory for the hash object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// + /// + /// The size, in bytes, of the pbHashObject buffer. + /// + /// If the value of this parameter is zero and the value of the pbHashObject parameter is NULL, the memory for the key object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// c + /// + /// + /// + /// A pointer to a buffer that contains the key to use for the hash or MAC. The cbSecret parameter contains the size of this buffer. + /// This key only applies to hash algorithms opened by the BCryptOpenAlgorithmProvider function by using the + /// BCRYPT_ALG_HANDLE_HMAC flag. Otherwise, set this parameter to NULL. + /// + /// + /// + /// The size, in bytes, of the pbSecret buffer. If no key is used, set this parameter to zero. + /// + /// + /// Flags that modify the behavior of the function. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_HASH_REUSABLE_FLAG + /// + /// Creates a reusable hashing object. The object can be used for a new hashing operation immediately after calling BCryptFinishHash. + /// For more information, see Creating a Hash with CNG. Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista: + /// This flag is not supported. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the hash object specified by the cbHashObject parameter is not large enough to hold the hash object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm provider specified by the hAlgorithm parameter does not support the hash interface. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptCreateHash can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptCreateHash function must refer to nonpaged (or + /// locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptcreatehash NTSTATUS BCryptCreateHash( + // BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_HASH_HANDLE *phHash, PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, ULONG + // cbSecret, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "deb02f67-f3d3-4542-8245-fd4982c3190b")] + public static extern NTStatus BCryptCreateHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, SafeAllocatedMemoryHandle pbHashObject, uint cbHashObject, SafeAllocatedMemoryHandle pbSecret, uint cbSecret, AlgProviderFlags dwFlags = 0); + + /// + /// The BCryptCreateHash function is called to create a hash or Message Authentication Code (MAC) object. + /// + /// + /// + /// The handle of an algorithm provider created by using the BCryptOpenAlgorithmProvider function. The algorithm that was specified + /// when the provider was created must support the hash interface. + /// + /// + /// + /// + /// A pointer to a BCRYPT_HASH_HANDLE value that receives a handle that represents the hash or MAC object. This handle is used + /// in subsequent hashing or MAC functions, such as the BCryptHashData function. When you have finished using this handle, release it + /// by passing it to the BCryptDestroyHash function. + /// + /// + /// + /// + /// A pointer to a buffer that receives the hash or MAC object. The cbHashObject parameter contains the size of this buffer. The + /// required size of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH + /// property. This will provide the size of the hash or MAC object for the specified algorithm. + /// + /// This memory can only be freed after the handle pointed to by the phHash parameter is destroyed. + /// + /// If the value of this parameter is NULL and the value of the cbHashObject parameter is zero, the memory for the hash object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// + /// + /// The size, in bytes, of the pbHashObject buffer. + /// + /// If the value of this parameter is zero and the value of the pbHashObject parameter is NULL, the memory for the key object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// c + /// + /// + /// + /// A pointer to a buffer that contains the key to use for the hash or MAC. The cbSecret parameter contains the size of this buffer. + /// This key only applies to hash algorithms opened by the BCryptOpenAlgorithmProvider function by using the + /// BCRYPT_ALG_HANDLE_HMAC flag. Otherwise, set this parameter to NULL. + /// + /// + /// + /// The size, in bytes, of the pbSecret buffer. If no key is used, set this parameter to zero. + /// + /// + /// Flags that modify the behavior of the function. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_HASH_REUSABLE_FLAG + /// + /// Creates a reusable hashing object. The object can be used for a new hashing operation immediately after calling BCryptFinishHash. + /// For more information, see Creating a Hash with CNG. Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista: + /// This flag is not supported. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the hash object specified by the cbHashObject parameter is not large enough to hold the hash object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm provider specified by the hAlgorithm parameter does not support the hash interface. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptCreateHash can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptCreateHash function must refer to nonpaged (or + /// locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptcreatehash NTSTATUS BCryptCreateHash( + // BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_HASH_HANDLE *phHash, PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, ULONG + // cbSecret, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "deb02f67-f3d3-4542-8245-fd4982c3190b")] + public static extern NTStatus BCryptCreateHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, SafeAllocatedMemoryHandle pbHashObject, uint cbHashObject, [Optional] IntPtr pbSecret, [Optional] uint cbSecret, AlgProviderFlags dwFlags = 0); + + /// + /// The BCryptCreateHash function is called to create a hash or Message Authentication Code (MAC) object. + /// + /// + /// + /// The handle of an algorithm provider created by using the BCryptOpenAlgorithmProvider function. The algorithm that was specified + /// when the provider was created must support the hash interface. + /// + /// + /// + /// + /// A pointer to a BCRYPT_HASH_HANDLE value that receives a handle that represents the hash or MAC object. This handle is used + /// in subsequent hashing or MAC functions, such as the BCryptHashData function. When you have finished using this handle, release it + /// by passing it to the BCryptDestroyHash function. + /// + /// + /// + /// + /// A pointer to a buffer that receives the hash or MAC object. The cbHashObject parameter contains the size of this buffer. The + /// required size of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH + /// property. This will provide the size of the hash or MAC object for the specified algorithm. + /// + /// This memory can only be freed after the handle pointed to by the phHash parameter is destroyed. + /// + /// If the value of this parameter is NULL and the value of the cbHashObject parameter is zero, the memory for the hash object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// + /// + /// The size, in bytes, of the pbHashObject buffer. + /// + /// If the value of this parameter is zero and the value of the pbHashObject parameter is NULL, the memory for the key object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// c + /// + /// + /// + /// A pointer to a buffer that contains the key to use for the hash or MAC. The cbSecret parameter contains the size of this buffer. + /// This key only applies to hash algorithms opened by the BCryptOpenAlgorithmProvider function by using the + /// BCRYPT_ALG_HANDLE_HMAC flag. Otherwise, set this parameter to NULL. + /// + /// + /// + /// The size, in bytes, of the pbSecret buffer. If no key is used, set this parameter to zero. + /// + /// + /// Flags that modify the behavior of the function. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_HASH_REUSABLE_FLAG + /// + /// Creates a reusable hashing object. The object can be used for a new hashing operation immediately after calling BCryptFinishHash. + /// For more information, see Creating a Hash with CNG. Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista: + /// This flag is not supported. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the hash object specified by the cbHashObject parameter is not large enough to hold the hash object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm provider specified by the hAlgorithm parameter does not support the hash interface. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptCreateHash can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptCreateHash function must refer to nonpaged (or + /// locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptcreatehash NTSTATUS BCryptCreateHash( + // BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_HASH_HANDLE *phHash, PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, ULONG + // cbSecret, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "deb02f67-f3d3-4542-8245-fd4982c3190b", MinClient = PInvokeClient.Windows7)] + public static extern NTStatus BCryptCreateHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, [Optional] IntPtr pbHashObject, [Optional] uint cbHashObject, [Optional] IntPtr pbSecret, [Optional] uint cbSecret, AlgProviderFlags dwFlags = 0); + + /// + /// + /// The BCryptCreateMultiHash function creates a multi-hash state that allows for the parallel computation of multiple hash + /// operations. This multi-hash state is used by the BCryptProcessMultiOperations function. The multi-hash state can be thought of as + /// an array of hash objects, each of which is equivalent to one created by BCryptCreateHash. + /// + /// Parallel computations can greatly increase overall throughput, at the expense of increased latency for individual computations. + /// + /// Parallel hash computations are currently only implemented for SHA-256, SHA-384, and SHA-512. Other hash algorithms can be used + /// with the parallel computation API but they run at the throughput of the sequential hash operations. The set of hash algorithms + /// that can benefit from parallel computations might change in future updates. + /// + /// + /// + /// + /// The algorithm handle used for all of the hash states in the multi-hash array. The algorithm handle must have been opened with the + /// BCYRPT_MULTI_FLAG passed to the BCryptOpenAlgorithmProvider function. Alternatively, the caller can use the pseudo-handles. + /// + /// + /// + /// + /// A pointer to a BCRYPT_HASH_HANDLE value that receives a handle that represents the multi-hash state. This handle is used + /// in subsequent operations such as BCryptProcessMultiOperations. When you have finished using this handle, release it by passing it + /// to the BCryptDestroyHash function. + /// + /// + /// + /// + /// The number of elements in the array. The multi-hash state that this function creates is able to perform parallel computations on + /// nHashes different hash states. + /// + /// + /// + /// A pointer to a buffer that receives the multi-hash state. + /// + /// The size can be calculated from the cbPerObject and cbPerElement members of the BCRYPT_MULTI_OBJECT_LENGTH_STRUCT + /// structure. The value is the following: . + /// + /// If pbHashObject is NULL and cbHashObject has a value of zero (0), the object buffer is automatically allocated. + /// + /// + /// The size of the pbHashObject buffer, or zero if pbHashObject is NULL. + /// + /// + /// + /// A pointer to a buffer that contains the key to use for the hash or MAC. The cbSecret parameter contains the size of this buffer. + /// This key only applies to hash algorithms opened by the BCryptOpenAlgorithmProvider function by using the + /// BCRYPT_ALG_HANDLE_HMAC flag. Otherwise, set this parameter to NULL. + /// + /// The same key is used for all elements of the array. + /// + /// + /// The size, in bytes, of the pbSecret buffer. If no key is used, set this parameter to zero. + /// + /// + /// + /// Flags that modify the behavior of the function. This can be zero or the values below. Multi-hash objects are always reusable and + /// always behave as if the BCRYPT_HASH_REUSABLE_FLAG was passed. This flag is supported here for consistency. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_HASH_REUSABLE_FLAG + /// + /// Creates a reusable hashing object. The object can be used for a new hashing operation immediately after calling BCryptFinishHash. + /// For more information, see Creating a Hash with CNG. + /// + /// + /// + /// + /// + /// None + /// + /// + /// + /// Internally, parallel hash computations are done using single-instruction multiple-data (SIMD) instructions with up to 8 parallel + /// computations at a time, depending on the hash algorithm and the CPU features available. To maximize performance, we recommend + /// that the caller provide at least eight computations that can be processed in parallel. + /// + /// + /// For computations of unequal length, providing more computations in parallel allows the implementation to schedule the + /// computations better across the CPU registers. This can provide a throughput benefit. For optimal throughput, we recommend that + /// the caller provide between eight and 100 computations. Select a lower value in that range only if all the hash computations are + /// the same length. + /// + /// Multi-hashing is not supported for HMAC-MD2, HMAC-MD4, and GMAC. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptcreatemultihash NTSTATUS BCryptCreateMultiHash( + // BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_HASH_HANDLE *phHash, ULONG nHashes, PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, + // ULONG cbSecret, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "AAF91460-AEFB-4E16-91EA-4A60272B3839")] + public static extern NTStatus BCryptCreateMultiHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, uint nHashes, SafeAllocatedMemoryHandle pbHashObject, uint cbHashObject, SafeAllocatedMemoryHandle pbSecret, uint cbSecret, AlgProviderFlags dwFlags); + + /// + /// + /// The BCryptCreateMultiHash function creates a multi-hash state that allows for the parallel computation of multiple hash + /// operations. This multi-hash state is used by the BCryptProcessMultiOperations function. The multi-hash state can be thought of as + /// an array of hash objects, each of which is equivalent to one created by BCryptCreateHash. + /// + /// Parallel computations can greatly increase overall throughput, at the expense of increased latency for individual computations. + /// + /// Parallel hash computations are currently only implemented for SHA-256, SHA-384, and SHA-512. Other hash algorithms can be used + /// with the parallel computation API but they run at the throughput of the sequential hash operations. The set of hash algorithms + /// that can benefit from parallel computations might change in future updates. + /// + /// + /// + /// + /// The algorithm handle used for all of the hash states in the multi-hash array. The algorithm handle must have been opened with the + /// BCYRPT_MULTI_FLAG passed to the BCryptOpenAlgorithmProvider function. Alternatively, the caller can use the pseudo-handles. + /// + /// + /// + /// + /// A pointer to a BCRYPT_HASH_HANDLE value that receives a handle that represents the multi-hash state. This handle is used + /// in subsequent operations such as BCryptProcessMultiOperations. When you have finished using this handle, release it by passing it + /// to the BCryptDestroyHash function. + /// + /// + /// + /// + /// The number of elements in the array. The multi-hash state that this function creates is able to perform parallel computations on + /// nHashes different hash states. + /// + /// + /// + /// A pointer to a buffer that receives the multi-hash state. + /// + /// The size can be calculated from the cbPerObject and cbPerElement members of the BCRYPT_MULTI_OBJECT_LENGTH_STRUCT + /// structure. The value is the following: . + /// + /// If pbHashObject is NULL and cbHashObject has a value of zero (0), the object buffer is automatically allocated. + /// + /// + /// The size of the pbHashObject buffer, or zero if pbHashObject is NULL. + /// + /// + /// + /// A pointer to a buffer that contains the key to use for the hash or MAC. The cbSecret parameter contains the size of this buffer. + /// This key only applies to hash algorithms opened by the BCryptOpenAlgorithmProvider function by using the + /// BCRYPT_ALG_HANDLE_HMAC flag. Otherwise, set this parameter to NULL. + /// + /// The same key is used for all elements of the array. + /// + /// + /// The size, in bytes, of the pbSecret buffer. If no key is used, set this parameter to zero. + /// + /// + /// + /// Flags that modify the behavior of the function. This can be zero or the values below. Multi-hash objects are always reusable and + /// always behave as if the BCRYPT_HASH_REUSABLE_FLAG was passed. This flag is supported here for consistency. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_HASH_REUSABLE_FLAG + /// + /// Creates a reusable hashing object. The object can be used for a new hashing operation immediately after calling BCryptFinishHash. + /// For more information, see Creating a Hash with CNG. + /// + /// + /// + /// + /// + /// None + /// + /// + /// + /// Internally, parallel hash computations are done using single-instruction multiple-data (SIMD) instructions with up to 8 parallel + /// computations at a time, depending on the hash algorithm and the CPU features available. To maximize performance, we recommend + /// that the caller provide at least eight computations that can be processed in parallel. + /// + /// + /// For computations of unequal length, providing more computations in parallel allows the implementation to schedule the + /// computations better across the CPU registers. This can provide a throughput benefit. For optimal throughput, we recommend that + /// the caller provide between eight and 100 computations. Select a lower value in that range only if all the hash computations are + /// the same length. + /// + /// Multi-hashing is not supported for HMAC-MD2, HMAC-MD4, and GMAC. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptcreatemultihash NTSTATUS BCryptCreateMultiHash( + // BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_HASH_HANDLE *phHash, ULONG nHashes, PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, + // ULONG cbSecret, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "AAF91460-AEFB-4E16-91EA-4A60272B3839", MinClient = PInvokeClient.Windows7)] + public static extern NTStatus BCryptCreateMultiHash(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_HASH_HANDLE phHash, uint nHashes, [Optional] IntPtr pbHashObject, [Optional] uint cbHashObject, SafeAllocatedMemoryHandle pbSecret, uint cbSecret, AlgProviderFlags dwFlags); + + /// + /// The BCryptDecrypt function decrypts a block of data. + /// + /// + /// + /// The handle of the key to use to decrypt the data. This handle is obtained from one of the key creation functions, such as + /// BCryptGenerateSymmetricKey, BCryptGenerateKeyPair, or BCryptImportKey. + /// + /// + /// + /// + /// The address of a buffer that contains the ciphertext to be decrypted. The cbInput parameter contains the size of the ciphertext + /// to decrypt. For more information, see Remarks. + /// + /// + /// + /// The number of bytes in the pbInput buffer to decrypt. + /// + /// + /// + /// A pointer to a structure that contains padding information. This parameter is only used with asymmetric keys and authenticated + /// encryption modes. If an authenticated encryption mode is used, this parameter must point to a + /// BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO structure. If asymmetric keys are used, the type of structure this parameter points to is + /// determined by the value of the dwFlags parameter. Otherwise, the parameter must be set to NULL. + /// + /// + /// + /// + /// The address of a buffer that contains the initialization vector (IV) to use during decryption. The cbIV parameter contains the + /// size of this buffer. This function will modify the contents of this buffer. If you need to reuse the IV later, make sure you make + /// a copy of this buffer before calling this function. + /// + /// This parameter is optional and can be NULL if no IV is used. + /// + /// The required size of the IV can be obtained by calling the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH + /// property. This will provide the size of a block for the algorithm, which is also the size of the IV. + /// + /// + /// + /// The size, in bytes, of the pbIV buffer. + /// + /// + /// + /// The address of a buffer to receive the plaintext produced by this function. The cbOutput parameter contains the size of this + /// buffer. For more information, see Remarks. + /// + /// + /// If this parameter is NULL, the BCryptDecrypt function calculates the size required for the plaintext of the + /// encrypted data passed in the pbInput parameter. In this case, the location pointed to by the pcbResult parameter contains this + /// size, and the function returns STATUS_SUCCESS. + /// + /// + /// If the values of both the pbOutput and pbInput parameters are NULL, an error is returned unless an authenticated + /// encryption algorithm is in use. In the latter case, the call is treated as an authenticated encryption call with zero length + /// data, and the authentication tag, passed in the pPaddingInfo parameter, is verified. + /// + /// + /// + /// The size, in bytes, of the pbOutput buffer. This parameter is ignored if the pbOutput parameter is NULL. + /// + /// + /// + /// A pointer to a ULONG variable to receive the number of bytes copied to the pbOutput buffer. If pbOutput is NULL, + /// this receives the size, in bytes, required for the plaintext. + /// + /// + /// + /// + /// A set of flags that modify the behavior of this function. The allowed set of flags depends on the type of key specified by the + /// hKey parameter. + /// + /// If the key is a symmetric key, this can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_BLOCK_PADDING + /// + /// The data was padded to the next block size when it was encrypted. If this flag was used with the BCryptEncrypt function, it must + /// also be specified in this function. This flag must not be used with the authenticated encryption modes (AES-CCM and AES-GCM). + /// + /// + /// + /// If the key is an asymmetric key, this can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_PAD_NONE + /// + /// Do not use any padding. The pPaddingInfo parameter is not used. The cbInput parameter must be a multiple of the algorithm's block + /// size. The block size can be obtained by calling the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH property for the + /// key. This will provide the size of a block for the algorithm. + /// + /// + /// + /// BCRYPT_PAD_OAEP + /// + /// The Optimal Asymmetric Encryption Padding (OAEP) scheme was used when the data was encrypted. The pPaddingInfo parameter is a + /// pointer to a BCRYPT_OAEP_PADDING_INFO structure. + /// + /// + /// + /// BCRYPT_PAD_PKCS1 + /// The data was padded with a random number when the data was encrypted. The pPaddingInfo parameter is not used. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_AUTH_TAG_MISMATCH + /// The computed authentication tag did not match the value supplied in the pPaddingInfo parameter. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the cbOutput parameter is not large enough to hold the ciphertext. + /// + /// + /// STATUS_INVALID_BUFFER_SIZE + /// + /// The cbInput parameter is not a multiple of the algorithm's block size, and the BCRYPT_BLOCK_PADDING flag was not specified in the + /// dwFlags parameter. + /// + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hKey parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm does not support decryption. + /// + /// + /// + /// + /// + /// The pbInput and pbOutput parameters can point to the same buffer. In this case, this function will perform the decryption in place. + /// + /// + /// Depending on what processor modes a provider supports, BCryptDecrypt can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a provider + /// that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptDecrypt function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptdecrypt NTSTATUS BCryptDecrypt( BCRYPT_KEY_HANDLE + // hKey, PUCHAR pbInput, ULONG cbInput, VOID *pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, ULONG cbOutput, ULONG + // *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "62286f6b-0d57-4691-83fc-2b9a9740af71")] + public static extern NTStatus BCryptDecrypt(BCRYPT_KEY_HANDLE hKey, SafeAllocatedMemoryHandle pbInput, uint cbInput, IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbIV, uint cbIV, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, EncryptFlags dwFlags); + + /// + /// The BCryptDecrypt function decrypts a block of data. + /// + /// + /// + /// The handle of the key to use to decrypt the data. This handle is obtained from one of the key creation functions, such as + /// BCryptGenerateSymmetricKey, BCryptGenerateKeyPair, or BCryptImportKey. + /// + /// + /// + /// + /// The address of a buffer that contains the ciphertext to be decrypted. The cbInput parameter contains the size of the ciphertext + /// to decrypt. For more information, see Remarks. + /// + /// + /// + /// The number of bytes in the pbInput buffer to decrypt. + /// + /// + /// + /// A pointer to a structure that contains padding information. This parameter is only used with asymmetric keys and authenticated + /// encryption modes. If an authenticated encryption mode is used, this parameter must point to a + /// BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO structure. If asymmetric keys are used, the type of structure this parameter points to is + /// determined by the value of the dwFlags parameter. Otherwise, the parameter must be set to NULL. + /// + /// + /// + /// + /// The address of a buffer that contains the initialization vector (IV) to use during decryption. The cbIV parameter contains the + /// size of this buffer. This function will modify the contents of this buffer. If you need to reuse the IV later, make sure you make + /// a copy of this buffer before calling this function. + /// + /// This parameter is optional and can be NULL if no IV is used. + /// + /// The required size of the IV can be obtained by calling the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH + /// property. This will provide the size of a block for the algorithm, which is also the size of the IV. + /// + /// + /// + /// The size, in bytes, of the pbIV buffer. + /// + /// + /// + /// The address of a buffer to receive the plaintext produced by this function. The cbOutput parameter contains the size of this + /// buffer. For more information, see Remarks. + /// + /// + /// If this parameter is NULL, the BCryptDecrypt function calculates the size required for the plaintext of the + /// encrypted data passed in the pbInput parameter. In this case, the location pointed to by the pcbResult parameter contains this + /// size, and the function returns STATUS_SUCCESS. + /// + /// + /// If the values of both the pbOutput and pbInput parameters are NULL, an error is returned unless an authenticated + /// encryption algorithm is in use. In the latter case, the call is treated as an authenticated encryption call with zero length + /// data, and the authentication tag, passed in the pPaddingInfo parameter, is verified. + /// + /// + /// + /// The size, in bytes, of the pbOutput buffer. This parameter is ignored if the pbOutput parameter is NULL. + /// + /// + /// + /// A pointer to a ULONG variable to receive the number of bytes copied to the pbOutput buffer. If pbOutput is NULL, + /// this receives the size, in bytes, required for the plaintext. + /// + /// + /// + /// + /// A set of flags that modify the behavior of this function. The allowed set of flags depends on the type of key specified by the + /// hKey parameter. + /// + /// If the key is a symmetric key, this can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_BLOCK_PADDING + /// + /// The data was padded to the next block size when it was encrypted. If this flag was used with the BCryptEncrypt function, it must + /// also be specified in this function. This flag must not be used with the authenticated encryption modes (AES-CCM and AES-GCM). + /// + /// + /// + /// If the key is an asymmetric key, this can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_PAD_NONE + /// + /// Do not use any padding. The pPaddingInfo parameter is not used. The cbInput parameter must be a multiple of the algorithm's block + /// size. The block size can be obtained by calling the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH property for the + /// key. This will provide the size of a block for the algorithm. + /// + /// + /// + /// BCRYPT_PAD_OAEP + /// + /// The Optimal Asymmetric Encryption Padding (OAEP) scheme was used when the data was encrypted. The pPaddingInfo parameter is a + /// pointer to a BCRYPT_OAEP_PADDING_INFO structure. + /// + /// + /// + /// BCRYPT_PAD_PKCS1 + /// The data was padded with a random number when the data was encrypted. The pPaddingInfo parameter is not used. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_AUTH_TAG_MISMATCH + /// The computed authentication tag did not match the value supplied in the pPaddingInfo parameter. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the cbOutput parameter is not large enough to hold the ciphertext. + /// + /// + /// STATUS_INVALID_BUFFER_SIZE + /// + /// The cbInput parameter is not a multiple of the algorithm's block size, and the BCRYPT_BLOCK_PADDING flag was not specified in the + /// dwFlags parameter. + /// + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hKey parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm does not support decryption. + /// + /// + /// + /// + /// + /// The pbInput and pbOutput parameters can point to the same buffer. In this case, this function will perform the decryption in place. + /// + /// + /// Depending on what processor modes a provider supports, BCryptDecrypt can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a provider + /// that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptDecrypt function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptdecrypt NTSTATUS BCryptDecrypt( BCRYPT_KEY_HANDLE + // hKey, PUCHAR pbInput, ULONG cbInput, VOID *pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, ULONG cbOutput, ULONG + // *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "62286f6b-0d57-4691-83fc-2b9a9740af71")] + public static extern NTStatus BCryptDecrypt(BCRYPT_KEY_HANDLE hKey, SafeAllocatedMemoryHandle pbInput, uint cbInput, IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbIV, uint cbIV, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags); + + /// + /// + /// [ BCryptDeleteContext is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// The BCryptDeleteContext function deletes an existing CNG configuration context. + /// + /// + /// Identifies the configuration table to delete the context from. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// Delete the context from the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to delete. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// BCryptDeleteContext can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptdeletecontext NTSTATUS BCryptDeleteContext( ULONG + // dwTable, LPCWSTR pszContext ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "6a250bed-0ea4-4cae-86e6-f0cea95dc56e")] + public static extern NTStatus BCryptDeleteContext(ContextConfigTable dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext); + + /// The BCryptDeriveKey function derives a key from a secret agreement value. + /// + /// The secret agreement handle to create the key from. This handle is obtained from the BCryptSecretAgreement function. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that identifies the key derivation function (KDF) to use to derive the key. This + /// can be one of the following strings. + /// + /// BCRYPT_KDF_HASH (L"HASH") + /// Use the hash key derivation function. + /// + /// If the cbDerivedKey parameter is less than the size of the derived key, this function will only copy the specified number of + /// bytes to the pbDerivedKey buffer. If the cbDerivedKey parameter is greater than the size of the derived key, this function will + /// copy the key to the pbDerivedKey buffer and set the variable pointed to by the pcbResult to the actual number of bytes copied. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// A null-terminated Unicode string that identifies the hash algorithm to use. This can be one of the standard hash algorithm + /// identifiers from CNG Algorithm Identifiers or the identifier for another registered hash algorithm. If this parameter is not + /// specified, the SHA1 hash algorithm is used. + /// + /// Optional + /// + /// + /// KDF_SECRET_PREPEND + /// A value to add to the beginning of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// KDF_SECRET_APPEND + /// A value to add to the end of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// KDF-Prepend = KDF_SECRET_PREPEND[0] + + /// KDF_SECRET_PREPEND[1] + + /// ... + + /// KDF_SECRET_PREPEND[n] + /// + /// KDF-Append = KDF_SECRET_APPEND[0] + + /// KDF_SECRET_APPEND[1] + + /// ... + + /// KDF_SECRET_APPEND[n] + /// + /// KDF-Output = Hash( + /// KDF-Prepend + + /// + /// hSharedSecret + + /// + /// KDF-Append) + /// + /// BCRYPT_KDF_HMAC (L"HMAC") + /// Use the Hash-Based Message Authentication Code (HMAC) key derivation function. + /// + /// If the cbDerivedKey parameter is less than the size of the derived key, this function will only copy the specified number of + /// bytes to the pbDerivedKey buffer. If the cbDerivedKey parameter is greater than the size of the derived key, this function will + /// copy the key to the pbDerivedKey buffer and set the variable pointed to by the pcbResult to the actual number of bytes copied. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// A null-terminated Unicode string that identifies the hash algorithm to use. This can be one of the standard hash algorithm + /// identifiers from CNG Algorithm Identifiers or the identifier for another registered hash algorithm. If this parameter is not + /// specified, the SHA1 hash algorithm is used. + /// + /// Optional + /// + /// + /// KDF_HMAC_KEY + /// The key to use for the pseudo-random function (PRF). + /// Optional + /// + /// + /// KDF_SECRET_PREPEND + /// A value to add to the beginning of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// KDF_SECRET_APPEND + /// A value to add to the end of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// KDF-Prepend = KDF_SECRET_PREPEND[0] + + /// KDF_SECRET_PREPEND[1] + + /// ... + + /// KDF_SECRET_PREPEND[n] + /// + /// KDF-Append = KDF_SECRET_APPEND[0] + + /// KDF_SECRET_APPEND[1] + + /// ... + + /// KDF_SECRET_APPEND[n] + /// + /// KDF-Output = HMAC-Hash( + /// KDF_HMAC_KEY, + /// KDF-Prepend + + /// hSharedSecret + + /// KDF-Append) + /// + /// BCRYPT_KDF_TLS_PRF (L"TLS_PRF") + /// + /// Use the transport layer security (TLS) pseudo-random function (PRF) key derivation function. The size of the derived key is + /// always 48 bytes, so the cbDerivedKey parameter must be 48. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_TLS_PRF_LABEL + /// An ANSI string that contains the PRF label. + /// Required + /// + /// + /// KDF_TLS_PRF_SEED + /// The PRF seed. The seed must be 64 bytes long. + /// Required + /// + /// + /// KDF_TLS_PRF_PROTOCOL + /// + /// A DWORD value that specifies the TLS protocol version whose PRF algorithm is to be used. Valid values are: SSL2_PROTOCOL_VERSION + /// (0x0002) SSL3_PROTOCOL_VERSION (0x0300) TLS1_PROTOCOL_VERSION (0x0301) TLS1_0_PROTOCOL_VERSION (0x0301) TLS1_1_PROTOCOL_VERSION + /// (0x0302) TLS1_2_PROTOCOL_VERSION (0x0303) DTLS1_0_PROTOCOL_VERSION (0xfeff) Windows Server 2008 and Windows Vista: + /// TLS1_1_PROTOCOL_VERSION, TLS1_2_PROTOCOL_VERSION and DTLS1_0_PROTOCOL_VERSION are not supported. Windows Server 2008 R2, Windows + /// 7, Windows Server 2008 and Windows Vista: DTLS1_0_PROTOCOL_VERSION is not supported. + /// + /// Optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// The CNG algorithm ID of the hash to be used with the HMAC in the PRF, for the TLS 1.2 protocol version. Valid choices are SHA-256 + /// and SHA-384. If not specified, SHA-256 is used. + /// + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// KDF-Output = PRF( + /// hSharedSecret, + /// KDF_TLS_PRF_LABEL, + /// KDF_TLS_PRF_SEED) + /// + /// BCRYPT_KDF_SP80056A_CONCAT (L"SP800_56A_CONCAT") + /// Use the SP800-56A key derivation function. + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. All parameter values are treated as opaque byte arrays. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_ALGORITHMID + /// + /// Specifies the AlgorithmID subfield of the OtherInfo field in the SP800-56A key derivation function. Indicates the intended + /// purpose of the derived key. + /// + /// Required + /// + /// + /// KDF_PARTYUINFO + /// + /// Specifies the PartyUInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information contributed by the initiator. + /// + /// Required + /// + /// + /// KDF_PARTYVINFO + /// + /// Specifies the PartyVInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information contributed by the responder. + /// + /// Required + /// + /// + /// KDF_SUPPPUBINFO + /// + /// Specifies the SuppPubInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information known to both initiator and responder. + /// + /// Optional + /// + /// + /// KDF_SUPPPRIVINFO + /// + /// Specifies the SuppPrivInfo subfield of the OtherInfo field in the SP800-56A key derivation function. It contains private + /// information known to both initiator and responder, such as a shared secret. + /// + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// KDF-Output = SP_800-56A_KDF( + /// hSharedSecret, + /// KDF_ALGORITHMID, + /// KDF_PARTYUINFO, + /// KDF_PARTYVINFO, + /// KDF_SUPPPUBINFO, + /// KDF_SUPPPRIVINFO) + /// + /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported. + /// + /// + /// The address of a BCryptBufferDesc structure that contains the KDF parameters. This parameter is optional and can be NULL + /// if it is not needed. + /// + /// + /// The address of a buffer that receives the key. The cbDerivedKey parameter contains the size of this buffer. If this parameter is + /// NULL, this function will place the required size, in bytes, in the ULONG pointed to by the pcbResult parameter. + /// + /// The size, in bytes, of the pbDerivedKey buffer. + /// + /// A pointer to a ULONG that receives the number of bytes that were copied to the pbDerivedKey buffer. If the pbDerivedKey + /// parameter is NULL, this function will place the required size, in bytes, in the ULONG pointed to by this parameter. + /// + /// + /// A set of flags that modify the behavior of this function. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// KDF_USE_SECRET_AS_HMAC_KEY_FLAG + /// + /// The secret agreement value will also serve as the HMAC key. If this flag is specified, the KDF_HMAC_KEY parameter should not be + /// included in the set of parameters in the pParameterList parameter. This flag is only used by the BCRYPT_KDF_HMAC key derivation function. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INTERNAL_ERROR + /// An internal error occurred. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hSharedSecret parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// The BCryptBufferDesc structure in the pParameterList parameter can contain more than one of the KDF_SECRET_PREPEND and + /// KDF_SECRET_APPEND parameters. If more than one of these parameters is specified, the parameter values are concatenated in + /// the order in which they are contained in the array before the KDF is called. For example, assume the following parameter values + /// are specified. + /// + /// If the above parameter values are specified, the concatenated values to the actual KDF are as follows. + /// + /// Depending on what processor modes a provider supports, BCryptDeriveKey can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hSharedSecret parameter must be located in nonpaged (or locked) memory and must + /// be derived from an algorithm handle returned by a provider that was opened by using the BCRYPT_PROV_DISPATCH flag. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptderivekey NTSTATUS BCryptDeriveKey( + // BCRYPT_SECRET_HANDLE hSharedSecret, LPCWSTR pwszKDF, BCryptBufferDesc *pParameterList, PUCHAR pbDerivedKey, ULONG cbDerivedKey, + // ULONG *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "33c3cbf7-6c08-42ed-ac3f-feb71f3a9cbf")] + public static extern NTStatus BCryptDeriveKey(BCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc pParameterList, SafeAllocatedMemoryHandle pbDerivedKey, + uint cbDerivedKey, out uint pcbResult, DeriveKeyFlags dwFlags); + + /// The BCryptDeriveKey function derives a key from a secret agreement value. + /// + /// The secret agreement handle to create the key from. This handle is obtained from the BCryptSecretAgreement function. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that identifies the key derivation function (KDF) to use to derive the key. This + /// can be one of the following strings. + /// + /// BCRYPT_KDF_HASH (L"HASH") + /// Use the hash key derivation function. + /// + /// If the cbDerivedKey parameter is less than the size of the derived key, this function will only copy the specified number of + /// bytes to the pbDerivedKey buffer. If the cbDerivedKey parameter is greater than the size of the derived key, this function will + /// copy the key to the pbDerivedKey buffer and set the variable pointed to by the pcbResult to the actual number of bytes copied. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// A null-terminated Unicode string that identifies the hash algorithm to use. This can be one of the standard hash algorithm + /// identifiers from CNG Algorithm Identifiers or the identifier for another registered hash algorithm. If this parameter is not + /// specified, the SHA1 hash algorithm is used. + /// + /// Optional + /// + /// + /// KDF_SECRET_PREPEND + /// A value to add to the beginning of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// KDF_SECRET_APPEND + /// A value to add to the end of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// KDF-Prepend = KDF_SECRET_PREPEND[0] + + /// KDF_SECRET_PREPEND[1] + + /// ... + + /// KDF_SECRET_PREPEND[n] + /// + /// KDF-Append = KDF_SECRET_APPEND[0] + + /// KDF_SECRET_APPEND[1] + + /// ... + + /// KDF_SECRET_APPEND[n] + /// + /// KDF-Output = Hash( + /// KDF-Prepend + + /// + /// hSharedSecret + + /// + /// KDF-Append) + /// + /// BCRYPT_KDF_HMAC (L"HMAC") + /// Use the Hash-Based Message Authentication Code (HMAC) key derivation function. + /// + /// If the cbDerivedKey parameter is less than the size of the derived key, this function will only copy the specified number of + /// bytes to the pbDerivedKey buffer. If the cbDerivedKey parameter is greater than the size of the derived key, this function will + /// copy the key to the pbDerivedKey buffer and set the variable pointed to by the pcbResult to the actual number of bytes copied. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// A null-terminated Unicode string that identifies the hash algorithm to use. This can be one of the standard hash algorithm + /// identifiers from CNG Algorithm Identifiers or the identifier for another registered hash algorithm. If this parameter is not + /// specified, the SHA1 hash algorithm is used. + /// + /// Optional + /// + /// + /// KDF_HMAC_KEY + /// The key to use for the pseudo-random function (PRF). + /// Optional + /// + /// + /// KDF_SECRET_PREPEND + /// A value to add to the beginning of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// KDF_SECRET_APPEND + /// A value to add to the end of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// KDF-Prepend = KDF_SECRET_PREPEND[0] + + /// KDF_SECRET_PREPEND[1] + + /// ... + + /// KDF_SECRET_PREPEND[n] + /// + /// KDF-Append = KDF_SECRET_APPEND[0] + + /// KDF_SECRET_APPEND[1] + + /// ... + + /// KDF_SECRET_APPEND[n] + /// + /// KDF-Output = HMAC-Hash( + /// KDF_HMAC_KEY, + /// KDF-Prepend + + /// hSharedSecret + + /// KDF-Append) + /// + /// BCRYPT_KDF_TLS_PRF (L"TLS_PRF") + /// + /// Use the transport layer security (TLS) pseudo-random function (PRF) key derivation function. The size of the derived key is + /// always 48 bytes, so the cbDerivedKey parameter must be 48. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_TLS_PRF_LABEL + /// An ANSI string that contains the PRF label. + /// Required + /// + /// + /// KDF_TLS_PRF_SEED + /// The PRF seed. The seed must be 64 bytes long. + /// Required + /// + /// + /// KDF_TLS_PRF_PROTOCOL + /// + /// A DWORD value that specifies the TLS protocol version whose PRF algorithm is to be used. Valid values are: SSL2_PROTOCOL_VERSION + /// (0x0002) SSL3_PROTOCOL_VERSION (0x0300) TLS1_PROTOCOL_VERSION (0x0301) TLS1_0_PROTOCOL_VERSION (0x0301) TLS1_1_PROTOCOL_VERSION + /// (0x0302) TLS1_2_PROTOCOL_VERSION (0x0303) DTLS1_0_PROTOCOL_VERSION (0xfeff) Windows Server 2008 and Windows Vista: + /// TLS1_1_PROTOCOL_VERSION, TLS1_2_PROTOCOL_VERSION and DTLS1_0_PROTOCOL_VERSION are not supported. Windows Server 2008 R2, Windows + /// 7, Windows Server 2008 and Windows Vista: DTLS1_0_PROTOCOL_VERSION is not supported. + /// + /// Optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// The CNG algorithm ID of the hash to be used with the HMAC in the PRF, for the TLS 1.2 protocol version. Valid choices are SHA-256 + /// and SHA-384. If not specified, SHA-256 is used. + /// + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// KDF-Output = PRF( + /// hSharedSecret, + /// KDF_TLS_PRF_LABEL, + /// KDF_TLS_PRF_SEED) + /// + /// BCRYPT_KDF_SP80056A_CONCAT (L"SP800_56A_CONCAT") + /// Use the SP800-56A key derivation function. + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. All parameter values are treated as opaque byte arrays. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_ALGORITHMID + /// + /// Specifies the AlgorithmID subfield of the OtherInfo field in the SP800-56A key derivation function. Indicates the intended + /// purpose of the derived key. + /// + /// Required + /// + /// + /// KDF_PARTYUINFO + /// + /// Specifies the PartyUInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information contributed by the initiator. + /// + /// Required + /// + /// + /// KDF_PARTYVINFO + /// + /// Specifies the PartyVInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information contributed by the responder. + /// + /// Required + /// + /// + /// KDF_SUPPPUBINFO + /// + /// Specifies the SuppPubInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information known to both initiator and responder. + /// + /// Optional + /// + /// + /// KDF_SUPPPRIVINFO + /// + /// Specifies the SuppPrivInfo subfield of the OtherInfo field in the SP800-56A key derivation function. It contains private + /// information known to both initiator and responder, such as a shared secret. + /// + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// KDF-Output = SP_800-56A_KDF( + /// hSharedSecret, + /// KDF_ALGORITHMID, + /// KDF_PARTYUINFO, + /// KDF_PARTYVINFO, + /// KDF_SUPPPUBINFO, + /// KDF_SUPPPRIVINFO) + /// + /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported. + /// + /// + /// The address of a BCryptBufferDesc structure that contains the KDF parameters. This parameter is optional and can be NULL + /// if it is not needed. + /// + /// + /// The address of a buffer that receives the key. The cbDerivedKey parameter contains the size of this buffer. If this parameter is + /// NULL, this function will place the required size, in bytes, in the ULONG pointed to by the pcbResult parameter. + /// + /// The size, in bytes, of the pbDerivedKey buffer. + /// + /// A pointer to a ULONG that receives the number of bytes that were copied to the pbDerivedKey buffer. If the pbDerivedKey + /// parameter is NULL, this function will place the required size, in bytes, in the ULONG pointed to by this parameter. + /// + /// + /// A set of flags that modify the behavior of this function. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// KDF_USE_SECRET_AS_HMAC_KEY_FLAG + /// + /// The secret agreement value will also serve as the HMAC key. If this flag is specified, the KDF_HMAC_KEY parameter should not be + /// included in the set of parameters in the pParameterList parameter. This flag is only used by the BCRYPT_KDF_HMAC key derivation function. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INTERNAL_ERROR + /// An internal error occurred. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hSharedSecret parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// The BCryptBufferDesc structure in the pParameterList parameter can contain more than one of the KDF_SECRET_PREPEND and + /// KDF_SECRET_APPEND parameters. If more than one of these parameters is specified, the parameter values are concatenated in + /// the order in which they are contained in the array before the KDF is called. For example, assume the following parameter values + /// are specified. + /// + /// If the above parameter values are specified, the concatenated values to the actual KDF are as follows. + /// + /// Depending on what processor modes a provider supports, BCryptDeriveKey can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hSharedSecret parameter must be located in nonpaged (or locked) memory and must + /// be derived from an algorithm handle returned by a provider that was opened by using the BCRYPT_PROV_DISPATCH flag. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptderivekey NTSTATUS BCryptDeriveKey( + // BCRYPT_SECRET_HANDLE hSharedSecret, LPCWSTR pwszKDF, BCryptBufferDesc *pParameterList, PUCHAR pbDerivedKey, ULONG cbDerivedKey, + // ULONG *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "33c3cbf7-6c08-42ed-ac3f-feb71f3a9cbf")] + public static extern NTStatus BCryptDeriveKey(BCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc pParameterList, [Optional] IntPtr pbDerivedKey, + [Optional] uint cbDerivedKey, out uint pcbResult, DeriveKeyFlags dwFlags); + + /// + /// The BCryptDeriveKeyCapi function derives a key from a hash value. + /// + /// This function is provided as a helper function to assist in migrating legacy Cryptography API (CAPI)–based applications to use + /// Cryptography API: Next Generation (CNG). The BCryptDeriveKeyCapi function performs the key derivation in a manner that is + /// compatible with the CAPI CryptDeriveKey function. + /// + /// + /// + /// The handle of the hash object. The handle is obtained by calling the BCryptCreateHash function. When you have finished using the + /// handle, you must free it by calling the BCryptDestroyHash function. + /// + /// + /// The handle of the algorithm object. This can be an ALG_ID value that is compatible with the CryptDeriveKey function. + /// + /// Note Limitations in CAPI and key expansion prevent the use of any hash algorithm that generates an output that is larger + /// than 512 bits. + /// + /// + /// A pointer to the buffer that receives the derived key. + /// The size, in characters, of the derived key pointed to by the pbDerivedKey parameter. + /// This parameter is reserved and must be set to zero. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hHash or hTargetAlg parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// The value in the cbDerivedKey parameter is larger than twice the output size of the hash function. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// This function does not support the PK salt functionality of the CAPI CryptDeriveKey function. + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptderivekeycapi NTSTATUS BCryptDeriveKeyCapi( + // BCRYPT_HASH_HANDLE hHash, BCRYPT_ALG_HANDLE hTargetAlg, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "bebb0767-8c54-48b7-864c-f53caea7120d")] + public static extern NTStatus BCryptDeriveKeyCapi(BCRYPT_HASH_HANDLE hHash, BCRYPT_ALG_HANDLE hTargetAlg, SafeAllocatedMemoryHandle pbDerivedKey, uint cbDerivedKey, uint dwFlags = 0); + + /// + /// The BCryptDeriveKeyCapi function derives a key from a hash value. + /// + /// This function is provided as a helper function to assist in migrating legacy Cryptography API (CAPI)–based applications to use + /// Cryptography API: Next Generation (CNG). The BCryptDeriveKeyCapi function performs the key derivation in a manner that is + /// compatible with the CAPI CryptDeriveKey function. + /// + /// + /// + /// The handle of the hash object. The handle is obtained by calling the BCryptCreateHash function. When you have finished using the + /// handle, you must free it by calling the BCryptDestroyHash function. + /// + /// + /// The handle of the algorithm object. This can be an ALG_ID value that is compatible with the CryptDeriveKey function. + /// + /// Note Limitations in CAPI and key expansion prevent the use of any hash algorithm that generates an output that is larger + /// than 512 bits. + /// + /// + /// A pointer to the buffer that receives the derived key. + /// The size, in characters, of the derived key pointed to by the pbDerivedKey parameter. + /// This parameter is reserved and must be set to zero. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hHash or hTargetAlg parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// The value in the cbDerivedKey parameter is larger than twice the output size of the hash function. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// This function does not support the PK salt functionality of the CAPI CryptDeriveKey function. + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptderivekeycapi NTSTATUS BCryptDeriveKeyCapi( + // BCRYPT_HASH_HANDLE hHash, BCRYPT_ALG_HANDLE hTargetAlg, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "bebb0767-8c54-48b7-864c-f53caea7120d")] + public static extern NTStatus BCryptDeriveKeyCapi(BCRYPT_HASH_HANDLE hHash, BCRYPT_ALG_HANDLE hTargetAlg, [Optional] IntPtr pbDerivedKey, uint cbDerivedKey, uint dwFlags = 0); + + /// + /// The BCryptDeriveKeyPBKDF2 function derives a key from a hash value by using the PBKDF2 key derivation algorithm as defined + /// by RFC 2898. + /// + /// + /// + /// The handle of an algorithm provider that provides the pseudo-random function. This should be an algorithm provider that performs + /// a Message Authentication Code computation. When you use the default Microsoft algorithm provider, any hashing algorithm opened by + /// using the BCRYPT_ALG_HANDLE_HMAC_FLAG flag can be used. + /// + /// Note Only algorithms that implement the BCRYPT_IS_KEYED_HASH property can be used to populate this parameter. + /// + /// A pointer to a buffer that contains the password parameter for the PBKDF2 key derivation algorithm. + /// The length, in bytes, of the data in the buffer pointed to by the pbPassword parameter. + /// + /// A pointer to a buffer that contains the salt argument for the PBKDF2 key derivation algorithm. + /// Note Any information that is not secret and that is used in the key derivation should be passed in this buffer. + /// + /// The length, in bytes, of the salt argument pointed to by the pbSalt parameter. + /// The iteration count for the PBKDF2 key derivation algorithm. + /// A pointer to a buffer that receives the derived key. + /// The length, in bytes, of the derived key returned in the buffer pointed to by the pbDerivedKey parameter. + /// This parameter is reserved and must be set to zero. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hPrf parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptderivekeypbkdf2 NTSTATUS BCryptDeriveKeyPBKDF2( + // BCRYPT_ALG_HANDLE hPrf, PUCHAR pbPassword, ULONG cbPassword, PUCHAR pbSalt, ULONG cbSalt, ULONGLONG cIterations, PUCHAR + // pbDerivedKey, ULONG cbDerivedKey, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "afdddfec-a3a5-410c-998b-9a5af8e051b6")] + public static extern NTStatus BCryptDeriveKeyPBKDF2(BCRYPT_ALG_HANDLE hPrf, SafeAllocatedMemoryHandle pbPassword, uint cbPassword, SafeAllocatedMemoryHandle pbSalt, uint cbSalt, ulong cIterations, SafeAllocatedMemoryHandle pbDerivedKey, uint cbDerivedKey, uint dwFlags = 0); + + /// + /// The BCryptDeriveKeyPBKDF2 function derives a key from a hash value by using the PBKDF2 key derivation algorithm as defined + /// by RFC 2898. + /// + /// + /// + /// The handle of an algorithm provider that provides the pseudo-random function. This should be an algorithm provider that performs + /// a Message Authentication Code computation. When you use the default Microsoft algorithm provider, any hashing algorithm opened by + /// using the BCRYPT_ALG_HANDLE_HMAC_FLAG flag can be used. + /// + /// Note Only algorithms that implement the BCRYPT_IS_KEYED_HASH property can be used to populate this parameter. + /// + /// A pointer to a buffer that contains the password parameter for the PBKDF2 key derivation algorithm. + /// The length, in bytes, of the data in the buffer pointed to by the pbPassword parameter. + /// + /// A pointer to a buffer that contains the salt argument for the PBKDF2 key derivation algorithm. + /// Note Any information that is not secret and that is used in the key derivation should be passed in this buffer. + /// + /// The length, in bytes, of the salt argument pointed to by the pbSalt parameter. + /// The iteration count for the PBKDF2 key derivation algorithm. + /// A pointer to a buffer that receives the derived key. + /// The length, in bytes, of the derived key returned in the buffer pointed to by the pbDerivedKey parameter. + /// This parameter is reserved and must be set to zero. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hPrf parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptderivekeypbkdf2 NTSTATUS BCryptDeriveKeyPBKDF2( + // BCRYPT_ALG_HANDLE hPrf, PUCHAR pbPassword, ULONG cbPassword, PUCHAR pbSalt, ULONG cbSalt, ULONGLONG cIterations, PUCHAR + // pbDerivedKey, ULONG cbDerivedKey, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "afdddfec-a3a5-410c-998b-9a5af8e051b6")] + public static extern NTStatus BCryptDeriveKeyPBKDF2(BCRYPT_ALG_HANDLE hPrf, IntPtr pbPassword, uint cbPassword, IntPtr pbSalt, uint cbSalt, ulong cIterations, IntPtr pbDerivedKey, uint cbDerivedKey, uint dwFlags = 0); + + /// + /// The BCryptDestroyHash function destroys a hash or Message Authentication Code (MAC) object. + /// + /// + /// The handle of the hash or MAC object to destroy. This handle is obtained by using the BCryptCreateHash function. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hHash parameter is not valid. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptDestroyHash can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hHash parameter must be derived from an algorithm handle returned by a + /// provider that was opened by using the BCRYPT_PROV_DISPATCH flag. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptdestroyhash NTSTATUS BCryptDestroyHash( + // BCRYPT_HASH_HANDLE hHash ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "067dac61-98b9-478c-ac4d-e141961865e9")] + public static extern NTStatus BCryptDestroyHash(BCRYPT_HASH_HANDLE hHash); + + /// The BCryptDestroyKey function destroys a key. + /// The handle of the key to destroy. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hKey parameter is not valid. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptDestroyKey can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a + /// provider that was opened with the BCRYPT_PROV_DISPATCH flag. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptdestroykey NTSTATUS BCryptDestroyKey( + // BCRYPT_KEY_HANDLE hKey ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "98c02e55-6489-4901-8a7a-021baac41965")] + public static extern NTStatus BCryptDestroyKey(BCRYPT_KEY_HANDLE hKey); + + /// + /// + /// The BCryptDestroySecret function destroys a secret agreement handle that was created by using the BCryptSecretAgreement function. + /// + /// + /// + /// The BCRYPT_SECRET_HANDLE to be destroyed. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hSecret parameter is not valid. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptDestroySecret can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hSecret parameter must be derived from an algorithm handle returned by + /// a provider that was opened by using the BCRYPT_PROV_DISPATCH flag. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptdestroysecret NTSTATUS BCryptDestroySecret( + // BCRYPT_SECRET_HANDLE hSecret ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "237743ff-ecb1-4c01-b4f9-192f27716f2c")] + public static extern NTStatus BCryptDestroySecret(BCRYPT_SECRET_HANDLE hSecret); + + /// + /// + /// The BCryptDuplicateHash function duplicates an existing hash or Message Authentication Code (MAC) object. The duplicate + /// object contains all state and data contained in the original object at the point of duplication. + /// + /// + /// + /// The handle of the hash or MAC object to duplicate. + /// + /// + /// A pointer to a BCRYPT_HASH_HANDLE value that receives the handle that represents the duplicate hash or MAC object. + /// + /// + /// + /// A pointer to a buffer that receives the duplicate hash or MAC object. The cbHashObject parameter contains the size of this + /// buffer. The required size of this buffer can be obtained by calling the BCryptGetProperty function to get the + /// BCRYPT_OBJECT_LENGTH property. This will provide the size of the hash object for the specified algorithm. + /// + /// When the duplicate hash handle is released, free this memory. + /// + /// + /// The size, in bytes, of the pbHashObject buffer. + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the hash object specified by the cbHashObject parameter is not large enough to hold the hash object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The hash handle in the hHash parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// This function is useful when computing a hash or MAC over a block of common data. After the common data has been processed, the + /// hash or MAC object can be duplicated, and then the unique data can be added to the individual objects. + /// + /// + /// Depending on what processor modes a provider supports, BCryptDuplicateHash can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hHash parameter must be derived from an algorithm handle returned by a + /// provider that was opened by using the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptDestroyKey function + /// must refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptduplicatehash NTSTATUS BCryptDuplicateHash( + // BCRYPT_HASH_HANDLE hHash, BCRYPT_HASH_HANDLE *phNewHash, PUCHAR pbHashObject, ULONG cbHashObject, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "451ff5dc-b66a-4e8e-a327-28b4ee618b74")] + public static extern NTStatus BCryptDuplicateHash(BCRYPT_HASH_HANDLE hHash, out SafeBCRYPT_HASH_HANDLE phNewHash, IntPtr pbHashObject, uint cbHashObject, uint dwFlags = 0); + + /// + /// + /// The BCryptDuplicateHash function duplicates an existing hash or Message Authentication Code (MAC) object. The duplicate + /// object contains all state and data contained in the original object at the point of duplication. + /// + /// + /// + /// The handle of the hash or MAC object to duplicate. + /// + /// + /// A pointer to a BCRYPT_HASH_HANDLE value that receives the handle that represents the duplicate hash or MAC object. + /// + /// + /// + /// A pointer to a buffer that receives the duplicate hash or MAC object. The cbHashObject parameter contains the size of this + /// buffer. The required size of this buffer can be obtained by calling the BCryptGetProperty function to get the + /// BCRYPT_OBJECT_LENGTH property. This will provide the size of the hash object for the specified algorithm. + /// + /// When the duplicate hash handle is released, free this memory. + /// + /// + /// The size, in bytes, of the pbHashObject buffer. + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the hash object specified by the cbHashObject parameter is not large enough to hold the hash object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The hash handle in the hHash parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// This function is useful when computing a hash or MAC over a block of common data. After the common data has been processed, the + /// hash or MAC object can be duplicated, and then the unique data can be added to the individual objects. + /// + /// + /// Depending on what processor modes a provider supports, BCryptDuplicateHash can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hHash parameter must be derived from an algorithm handle returned by a + /// provider that was opened by using the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptDestroyKey function + /// must refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptduplicatehash NTSTATUS BCryptDuplicateHash( + // BCRYPT_HASH_HANDLE hHash, BCRYPT_HASH_HANDLE *phNewHash, PUCHAR pbHashObject, ULONG cbHashObject, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "451ff5dc-b66a-4e8e-a327-28b4ee618b74")] + public static extern NTStatus BCryptDuplicateHash(BCRYPT_HASH_HANDLE hHash, out SafeBCRYPT_HASH_HANDLE phNewHash, SafeAllocatedMemoryHandle pbHashObject, uint cbHashObject, uint dwFlags = 0); + + /// + /// The BCryptDuplicateKey function creates a duplicate of a symmetric key. + /// + /// + /// The handle of the key to duplicate. This must be a handle to a symmetric key. + /// + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE variable that receives the handle of the duplicate key. This handle is used in subsequent + /// functions that require a key, such as BCryptEncrypt. This handle must be released when it is no longer needed by passing it to + /// the BCryptDestroyKey function. + /// + /// + /// + /// + /// A pointer to a buffer that receives the duplicate key object. The cbKeyObject parameter contains the size of this buffer. The + /// required size of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH + /// property. This will provide the size of the key object for the specified algorithm. + /// + /// This memory can only be freed after the phNewKey key handle is destroyed. + /// + /// + /// The size, in bytes, of the pbKeyObject buffer. + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the key object specified by the cbKeyObject parameter is not large enough to hold the key object. + /// + /// + /// STATUS_INVALID_HANDLE + /// + /// The key handle in the hKey parameter is not valid. This value is also returned if the key to duplicate is not a symmetric key. + /// + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptDuplicateKey can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a + /// provider that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptDuplicateKey + /// function must refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptduplicatekey NTSTATUS BCryptDuplicateKey( + // BCRYPT_KEY_HANDLE hKey, BCRYPT_KEY_HANDLE *phNewKey, PUCHAR pbKeyObject, ULONG cbKeyObject, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "13a0b904-353f-498a-bdc2-2fd4e51144ff")] + public static extern NTStatus BCryptDuplicateKey(BCRYPT_KEY_HANDLE hKey, out SafeBCRYPT_KEY_HANDLE phNewKey, IntPtr pbKeyObject, uint cbKeyObject, uint dwFlags = 0); + + /// + /// The BCryptDuplicateKey function creates a duplicate of a symmetric key. + /// + /// + /// The handle of the key to duplicate. This must be a handle to a symmetric key. + /// + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE variable that receives the handle of the duplicate key. This handle is used in subsequent + /// functions that require a key, such as BCryptEncrypt. This handle must be released when it is no longer needed by passing it to + /// the BCryptDestroyKey function. + /// + /// + /// + /// + /// A pointer to a buffer that receives the duplicate key object. The cbKeyObject parameter contains the size of this buffer. The + /// required size of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH + /// property. This will provide the size of the key object for the specified algorithm. + /// + /// This memory can only be freed after the phNewKey key handle is destroyed. + /// + /// + /// The size, in bytes, of the pbKeyObject buffer. + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the key object specified by the cbKeyObject parameter is not large enough to hold the key object. + /// + /// + /// STATUS_INVALID_HANDLE + /// + /// The key handle in the hKey parameter is not valid. This value is also returned if the key to duplicate is not a symmetric key. + /// + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptDuplicateKey can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a + /// provider that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptDuplicateKey + /// function must refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptduplicatekey NTSTATUS BCryptDuplicateKey( + // BCRYPT_KEY_HANDLE hKey, BCRYPT_KEY_HANDLE *phNewKey, PUCHAR pbKeyObject, ULONG cbKeyObject, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "13a0b904-353f-498a-bdc2-2fd4e51144ff")] + public static extern NTStatus BCryptDuplicateKey(BCRYPT_KEY_HANDLE hKey, out SafeBCRYPT_KEY_HANDLE phNewKey, SafeAllocatedMemoryHandle pbKeyObject, uint cbKeyObject, uint dwFlags = 0); + + /// The BCryptEncrypt function encrypts a block of data. + /// + /// The handle of the key to use to encrypt the data. This handle is obtained from one of the key creation functions, such as + /// BCryptGenerateSymmetricKey, BCryptGenerateKeyPair, or BCryptImportKey. + /// + /// + /// The address of a buffer that contains the plaintext to be encrypted. The cbInput parameter contains the size of the plaintext to + /// encrypt. For more information, see Remarks. + /// + /// The number of bytes in the pbInput buffer to encrypt. + /// + /// A pointer to a structure that contains padding information. This parameter is only used with asymmetric keys and authenticated + /// encryption modes. If an authenticated encryption mode is used, this parameter must point to a + /// BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO structure. If asymmetric keys are used, the type of structure this parameter points to is + /// determined by the value of the dwFlags parameter. Otherwise, the parameter must be set to NULL. + /// + /// + /// + /// The address of a buffer that contains the initialization vector (IV) to use during encryption. The cbIV parameter contains the + /// size of this buffer. This function will modify the contents of this buffer. If you need to reuse the IV later, make sure you make + /// a copy of this buffer before calling this function. + /// + /// This parameter is optional and can be NULL if no IV is used. + /// + /// The required size of the IV can be obtained by calling the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH + /// property. This will provide the size of a block for the algorithm, which is also the size of the IV. + /// + /// + /// The size, in bytes, of the pbIV buffer. + /// + /// + /// The address of the buffer that receives the ciphertext produced by this function. The cbOutput parameter contains the size of + /// this buffer. For more information, see Remarks. + /// + /// + /// If this parameter is NULL, the BCryptEncrypt function calculates the size needed for the ciphertext of the data + /// passed in the pbInput parameter. In this case, the location pointed to by the pcbResult parameter contains this size, and the + /// function returns STATUS_SUCCESS. The pPaddingInfo parameter is not modified. + /// + /// + /// If the values of both the pbOutput and pbInput parameters are NULL, an error is returned unless an authenticated + /// encryption algorithm is in use. In the latter case, the call is treated as an authenticated encryption call with zero length + /// data, and the authentication tag is returned in the pPaddingInfo parameter. + /// + /// + /// The size, in bytes, of the pbOutput buffer. This parameter is ignored if the pbOutput parameter is NULL. + /// + /// A pointer to a ULONG variable that receives the number of bytes copied to the pbOutput buffer. If pbOutput is NULL, + /// this receives the size, in bytes, required for the ciphertext. + /// + /// + /// + /// A set of flags that modify the behavior of this function. The allowed set of flags depends on the type of key specified by the + /// hKey parameter. + /// + /// If the key is a symmetric key, this can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_BLOCK_PADDING + /// + /// Allows the encryption algorithm to pad the data to the next block size. If this flag is not specified, the size of the plaintext + /// specified in the cbInput parameter must be a multiple of the algorithm's block size. The block size can be obtained by calling + /// the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH property for the key. This will provide the size of a block for the + /// algorithm. This flag must not be used with the authenticated encryption modes (AES-CCM and AES-GCM). + /// + /// + /// + /// If the key is an asymmetric key, this can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_PAD_NONE + /// + /// Do not use any padding. The pPaddingInfo parameter is not used. The size of the plaintext specified in the cbInput parameter must + /// be a multiple of the algorithm's block size. + /// + /// + /// + /// BCRYPT_PAD_OAEP + /// + /// Use the Optimal Asymmetric Encryption Padding (OAEP) scheme. The pPaddingInfo parameter is a pointer to a + /// BCRYPT_OAEP_PADDING_INFO structure. + /// + /// + /// + /// BCRYPT_PAD_PKCS1 + /// The data will be padded with a random number to round out the block size. The pPaddingInfo parameter is not used. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the cbOutput parameter is not large enough to hold the ciphertext. + /// + /// + /// STATUS_INVALID_BUFFER_SIZE + /// + /// The cbInput parameter is not a multiple of the algorithm's block size and the BCRYPT_BLOCK_PADDING or the BCRYPT_PAD_NONE flag + /// was not specified in the dwFlags parameter. + /// + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hKey parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm does not support encryption. + /// + /// + /// + /// + /// + /// The pbInput and pbOutput parameters can point to the same buffer. In this case, this function will perform the encryption in + /// place. It is possible that the encrypted data size will be larger than the unencrypted data size, so the buffer must be large + /// enough to hold the encrypted data. + /// + /// + /// Depending on what processor modes a provider supports, BCryptEncrypt can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a provider + /// that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptEncrypt function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptencrypt NTSTATUS BCryptEncrypt( BCRYPT_KEY_HANDLE + // hKey, PUCHAR pbInput, ULONG cbInput, VOID *pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, ULONG cbOutput, ULONG + // *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "69fe4530-4b7c-40db-a85c-f9dc458735e7")] + public static extern NTStatus BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, byte[] pbInput, uint cbInput, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbIV, uint cbIV, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags); + + /// The BCryptEncrypt function encrypts a block of data. + /// + /// The handle of the key to use to encrypt the data. This handle is obtained from one of the key creation functions, such as + /// BCryptGenerateSymmetricKey, BCryptGenerateKeyPair, or BCryptImportKey. + /// + /// + /// The address of a buffer that contains the plaintext to be encrypted. The cbInput parameter contains the size of the plaintext to + /// encrypt. For more information, see Remarks. + /// + /// The number of bytes in the pbInput buffer to encrypt. + /// + /// A pointer to a structure that contains padding information. This parameter is only used with asymmetric keys and authenticated + /// encryption modes. If an authenticated encryption mode is used, this parameter must point to a + /// BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO structure. If asymmetric keys are used, the type of structure this parameter points to is + /// determined by the value of the dwFlags parameter. Otherwise, the parameter must be set to NULL. + /// + /// + /// + /// The address of a buffer that contains the initialization vector (IV) to use during encryption. The cbIV parameter contains the + /// size of this buffer. This function will modify the contents of this buffer. If you need to reuse the IV later, make sure you make + /// a copy of this buffer before calling this function. + /// + /// This parameter is optional and can be NULL if no IV is used. + /// + /// The required size of the IV can be obtained by calling the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH + /// property. This will provide the size of a block for the algorithm, which is also the size of the IV. + /// + /// + /// The size, in bytes, of the pbIV buffer. + /// + /// + /// The address of the buffer that receives the ciphertext produced by this function. The cbOutput parameter contains the size of + /// this buffer. For more information, see Remarks. + /// + /// + /// If this parameter is NULL, the BCryptEncrypt function calculates the size needed for the ciphertext of the data + /// passed in the pbInput parameter. In this case, the location pointed to by the pcbResult parameter contains this size, and the + /// function returns STATUS_SUCCESS. The pPaddingInfo parameter is not modified. + /// + /// + /// If the values of both the pbOutput and pbInput parameters are NULL, an error is returned unless an authenticated + /// encryption algorithm is in use. In the latter case, the call is treated as an authenticated encryption call with zero length + /// data, and the authentication tag is returned in the pPaddingInfo parameter. + /// + /// + /// The size, in bytes, of the pbOutput buffer. This parameter is ignored if the pbOutput parameter is NULL. + /// + /// A pointer to a ULONG variable that receives the number of bytes copied to the pbOutput buffer. If pbOutput is NULL, + /// this receives the size, in bytes, required for the ciphertext. + /// + /// + /// + /// A set of flags that modify the behavior of this function. The allowed set of flags depends on the type of key specified by the + /// hKey parameter. + /// + /// If the key is a symmetric key, this can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_BLOCK_PADDING + /// + /// Allows the encryption algorithm to pad the data to the next block size. If this flag is not specified, the size of the plaintext + /// specified in the cbInput parameter must be a multiple of the algorithm's block size. The block size can be obtained by calling + /// the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH property for the key. This will provide the size of a block for the + /// algorithm. This flag must not be used with the authenticated encryption modes (AES-CCM and AES-GCM). + /// + /// + /// + /// If the key is an asymmetric key, this can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_PAD_NONE + /// + /// Do not use any padding. The pPaddingInfo parameter is not used. The size of the plaintext specified in the cbInput parameter must + /// be a multiple of the algorithm's block size. + /// + /// + /// + /// BCRYPT_PAD_OAEP + /// + /// Use the Optimal Asymmetric Encryption Padding (OAEP) scheme. The pPaddingInfo parameter is a pointer to a + /// BCRYPT_OAEP_PADDING_INFO structure. + /// + /// + /// + /// BCRYPT_PAD_PKCS1 + /// The data will be padded with a random number to round out the block size. The pPaddingInfo parameter is not used. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the cbOutput parameter is not large enough to hold the ciphertext. + /// + /// + /// STATUS_INVALID_BUFFER_SIZE + /// + /// The cbInput parameter is not a multiple of the algorithm's block size and the BCRYPT_BLOCK_PADDING or the BCRYPT_PAD_NONE flag + /// was not specified in the dwFlags parameter. + /// + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hKey parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm does not support encryption. + /// + /// + /// + /// + /// + /// The pbInput and pbOutput parameters can point to the same buffer. In this case, this function will perform the encryption in + /// place. It is possible that the encrypted data size will be larger than the unencrypted data size, so the buffer must be large + /// enough to hold the encrypted data. + /// + /// + /// Depending on what processor modes a provider supports, BCryptEncrypt can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a provider + /// that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptEncrypt function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptencrypt NTSTATUS BCryptEncrypt( BCRYPT_KEY_HANDLE + // hKey, PUCHAR pbInput, ULONG cbInput, VOID *pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, ULONG cbOutput, ULONG + // *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "69fe4530-4b7c-40db-a85c-f9dc458735e7")] + public static extern NTStatus BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, byte[] pbInput, uint cbInput, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbIV, uint cbIV, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, EncryptFlags dwFlags); + + /// The BCryptEncrypt function encrypts a block of data. + /// + /// The handle of the key to use to encrypt the data. This handle is obtained from one of the key creation functions, such as + /// BCryptGenerateSymmetricKey, BCryptGenerateKeyPair, or BCryptImportKey. + /// + /// + /// The address of a buffer that contains the plaintext to be encrypted. The cbInput parameter contains the size of the plaintext to + /// encrypt. For more information, see Remarks. + /// + /// The number of bytes in the pbInput buffer to encrypt. + /// + /// A pointer to a structure that contains padding information. This parameter is only used with asymmetric keys and authenticated + /// encryption modes. If an authenticated encryption mode is used, this parameter must point to a + /// BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO structure. If asymmetric keys are used, the type of structure this parameter points to is + /// determined by the value of the dwFlags parameter. Otherwise, the parameter must be set to NULL. + /// + /// + /// + /// The address of a buffer that contains the initialization vector (IV) to use during encryption. The cbIV parameter contains the + /// size of this buffer. This function will modify the contents of this buffer. If you need to reuse the IV later, make sure you make + /// a copy of this buffer before calling this function. + /// + /// This parameter is optional and can be NULL if no IV is used. + /// + /// The required size of the IV can be obtained by calling the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH + /// property. This will provide the size of a block for the algorithm, which is also the size of the IV. + /// + /// + /// The size, in bytes, of the pbIV buffer. + /// + /// + /// The address of the buffer that receives the ciphertext produced by this function. The cbOutput parameter contains the size of + /// this buffer. For more information, see Remarks. + /// + /// + /// If this parameter is NULL, the BCryptEncrypt function calculates the size needed for the ciphertext of the data + /// passed in the pbInput parameter. In this case, the location pointed to by the pcbResult parameter contains this size, and the + /// function returns STATUS_SUCCESS. The pPaddingInfo parameter is not modified. + /// + /// + /// If the values of both the pbOutput and pbInput parameters are NULL, an error is returned unless an authenticated + /// encryption algorithm is in use. In the latter case, the call is treated as an authenticated encryption call with zero length + /// data, and the authentication tag is returned in the pPaddingInfo parameter. + /// + /// + /// The size, in bytes, of the pbOutput buffer. This parameter is ignored if the pbOutput parameter is NULL. + /// + /// A pointer to a ULONG variable that receives the number of bytes copied to the pbOutput buffer. If pbOutput is NULL, + /// this receives the size, in bytes, required for the ciphertext. + /// + /// + /// + /// A set of flags that modify the behavior of this function. The allowed set of flags depends on the type of key specified by the + /// hKey parameter. + /// + /// If the key is a symmetric key, this can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_BLOCK_PADDING + /// + /// Allows the encryption algorithm to pad the data to the next block size. If this flag is not specified, the size of the plaintext + /// specified in the cbInput parameter must be a multiple of the algorithm's block size. The block size can be obtained by calling + /// the BCryptGetProperty function to get the BCRYPT_BLOCK_LENGTH property for the key. This will provide the size of a block for the + /// algorithm. This flag must not be used with the authenticated encryption modes (AES-CCM and AES-GCM). + /// + /// + /// + /// If the key is an asymmetric key, this can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_PAD_NONE + /// + /// Do not use any padding. The pPaddingInfo parameter is not used. The size of the plaintext specified in the cbInput parameter must + /// be a multiple of the algorithm's block size. + /// + /// + /// + /// BCRYPT_PAD_OAEP + /// + /// Use the Optimal Asymmetric Encryption Padding (OAEP) scheme. The pPaddingInfo parameter is a pointer to a + /// BCRYPT_OAEP_PADDING_INFO structure. + /// + /// + /// + /// BCRYPT_PAD_PKCS1 + /// The data will be padded with a random number to round out the block size. The pPaddingInfo parameter is not used. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the cbOutput parameter is not large enough to hold the ciphertext. + /// + /// + /// STATUS_INVALID_BUFFER_SIZE + /// + /// The cbInput parameter is not a multiple of the algorithm's block size and the BCRYPT_BLOCK_PADDING or the BCRYPT_PAD_NONE flag + /// was not specified in the dwFlags parameter. + /// + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hKey parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm does not support encryption. + /// + /// + /// + /// + /// + /// The pbInput and pbOutput parameters can point to the same buffer. In this case, this function will perform the encryption in + /// place. It is possible that the encrypted data size will be larger than the unencrypted data size, so the buffer must be large + /// enough to hold the encrypted data. + /// + /// + /// Depending on what processor modes a provider supports, BCryptEncrypt can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a provider + /// that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptEncrypt function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptencrypt NTSTATUS BCryptEncrypt( BCRYPT_KEY_HANDLE + // hKey, PUCHAR pbInput, ULONG cbInput, VOID *pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, ULONG cbOutput, ULONG + // *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "69fe4530-4b7c-40db-a85c-f9dc458735e7")] + public static extern NTStatus BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, byte[] pbInput, uint cbInput, [Optional] IntPtr pPaddingInfo, [Optional] IntPtr pbIV, [Optional] uint cbIV, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, EncryptFlags dwFlags); + + /// The BCryptEnumAlgorithms function gets a list of the registered algorithm identifiers. + /// + /// + /// A value that specifies the algorithm operation types to include in the enumeration. This can be a combination of one or more of + /// the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_CIPHER_OPERATION 0x00000001 + /// Include the cipher algorithms in the enumeration. + /// + /// + /// BCRYPT_HASH_OPERATION 0x00000002 + /// Include the hash algorithms in the enumeration. + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION 0x00000004 + /// Include the asymmetric encryption algorithms in the enumeration. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_OPERATION 0x00000008 + /// Include the secret agreement algorithms in the enumeration. + /// + /// + /// BCRYPT_SIGNATURE_OPERATION 0x00000010 + /// Include the signature algorithms in the enumeration. + /// + /// + /// BCRYPT_RNG_OPERATION 0x00000020 + /// Include the random number generator (RNG) algorithms in the enumeration. + /// + /// + /// + /// A pointer to a ULONG variable to receive the number of elements in the ppAlgList array. + /// + /// The address of a BCRYPT_ALGORITHM_IDENTIFIER structure pointer to receive the array of registered algorithm identifiers. This + /// pointer must be passed to the BCryptFreeBuffer function when it is no longer needed. + /// + /// A set of flags that modify the behavior of this function. No flags are defined for this function. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// BCryptEnumAlgorithms can be called either from user mode or kernel mode. Kernel mode callers must be executing at + /// PASSIVE_LEVEL IRQL. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptenumalgorithms NTSTATUS BCryptEnumAlgorithms( ULONG + // dwAlgOperations, ULONG *pAlgCount, BCRYPT_ALGORITHM_IDENTIFIER **ppAlgList, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "7fa227c0-2b80-49ab-8a19-72f8444d5507")] + public static extern NTStatus BCryptEnumAlgorithms(AlgOperations dwAlgOperations, out uint pAlgCount, out SafeBCryptBuffer ppAlgList, uint dwFlags = 0); + + /// The BCryptEnumAlgorithms function gets a list of the registered algorithm identifiers. + /// + /// + /// A value that specifies the algorithm operation types to include in the enumeration. This can be a combination of one or more of + /// the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_CIPHER_OPERATION 0x00000001 + /// Include the cipher algorithms in the enumeration. + /// + /// + /// BCRYPT_HASH_OPERATION 0x00000002 + /// Include the hash algorithms in the enumeration. + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION 0x00000004 + /// Include the asymmetric encryption algorithms in the enumeration. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_OPERATION 0x00000008 + /// Include the secret agreement algorithms in the enumeration. + /// + /// + /// BCRYPT_SIGNATURE_OPERATION 0x00000010 + /// Include the signature algorithms in the enumeration. + /// + /// + /// BCRYPT_RNG_OPERATION 0x00000020 + /// Include the random number generator (RNG) algorithms in the enumeration. + /// + /// + /// + /// An array of BCRYPT_ALGORITHM_IDENTIFIER structures that contains the registered algorithm identifiers. + [PInvokeData("bcrypt.h", MSDNShortId = "7fa227c0-2b80-49ab-8a19-72f8444d5507")] + public static BCRYPT_ALGORITHM_IDENTIFIER[] BCryptEnumAlgorithms(AlgOperations dwAlgOperations) + { + BCryptEnumAlgorithms(dwAlgOperations, out var sz, out var mem).ThrowIfFailed(); + return mem.DangerousGetHandle().ToArray((int)sz); + } + + /// + /// The BCryptEnumContextFunctionProviders function obtains the providers for the cryptographic functions for a context in the + /// specified configuration table. + /// + /// + /// + /// Identifies the configuration table from which to retrieve the context function providers. This can be one of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// Retrieve the context functions from the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to enumerate the function providers for. + /// + /// + /// Identifies the cryptographic interface to retrieve the function providers for. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// Retrieve the asymmetric encryption function providers. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// Retrieve the cipher function providers. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// Retrieve the hash function providers. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// Retrieve the random number generator function providers. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// Retrieve the secret agreement function providers. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// Retrieve the signature function providers. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// Retrieve the key storage function providers. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// Retrieve the Schannel function providers. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the function to enumerate the providers for. + /// + /// + /// + /// The address of a ULONG variable that, on entry, contains the size, in bytes, of the buffer pointed to by ppBuffer. If this + /// size is not large enough to hold the set of context identifiers, this function will fail with STATUS_BUFFER_TOO_SMALL. + /// + /// After this function returns, this value contains the number of bytes that were copied to the ppBuffer buffer. + /// + /// + /// + /// The address of a pointer to a CRYPT_CONTEXT_FUNCTION_PROVIDERS structure that receives the set of context function providers + /// retrieved by this function. The value pointed to by the pcbBuffer parameter contains the size of this buffer. + /// + /// + /// If the value pointed to by this parameter is NULL, this function will allocate the required memory. This memory must be + /// freed when it is no longer needed by passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// If this parameter is NULL, this function will place the required size, in bytes, in the variable pointed to by the + /// pcbBuffer parameter and return STATUS_BUFFER_TOO_SMALL. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// + /// The ppBuffer parameter is not NULL, and the value pointed to by the pcbBuffer parameter is not large enough to hold the set of contexts. + /// + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_NOT_FOUND + /// No context function providers that match the specified criteria were found. + /// + /// + /// + /// + /// BCryptEnumContextFunctionProviders can be called only in user mode. + /// Examples + /// + /// The following example shows how to use the BCryptEnumContextFunctionProviders function to enumerate the providers for all + /// key storage functions for all contexts in the local-machine configuration table. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptenumcontextfunctionproviders NTSTATUS + // BCryptEnumContextFunctionProviders( ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, ULONG *pcbBuffer, + // PCRYPT_CONTEXT_FUNCTION_PROVIDERS *ppBuffer ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "82776e61-03bb-463b-8767-fa4f70fe1341")] + public static extern NTStatus BCryptEnumContextFunctionProviders(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction, out uint pcbBuffer, out SafeBCryptBuffer ppBuffer); + + /// + /// The BCryptEnumContextFunctionProviders function obtains the providers for the cryptographic functions for a context in the + /// specified configuration table. + /// + /// + /// + /// Identifies the configuration table from which to retrieve the context function providers. This can be one of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// Retrieve the context functions from the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to enumerate the function providers for. + /// + /// + /// Identifies the cryptographic interface to retrieve the function providers for. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// Retrieve the asymmetric encryption function providers. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// Retrieve the cipher function providers. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// Retrieve the hash function providers. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// Retrieve the random number generator function providers. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// Retrieve the secret agreement function providers. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// Retrieve the signature function providers. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// Retrieve the key storage function providers. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// Retrieve the Schannel function providers. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the function to enumerate the providers for. + /// + /// An array of strings that contains the identifiers of the function providers contained in this set. + [PInvokeData("bcrypt.h", MSDNShortId = "82776e61-03bb-463b-8767-fa4f70fe1341")] + public static string[] BCryptEnumContextFunctionProviders(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction) + { + BCryptEnumContextFunctionProviders(dwTable, pszContext, dwInterface, pszFunction, out var _, out var mem).ThrowIfFailed(); + return mem.ToStructure()._rgpszProviders.ToArray(); + } + + /// + /// The BCryptEnumContextFunctions function obtains the cryptographic functions for a context in the specified configuration table. + /// + /// + /// Identifies the configuration table from which to retrieve the context functions. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// Retrieve the context functions from the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to enumerate the functions for. + /// + /// + /// Identifies the cryptographic interface to retrieve the functions for. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// Retrieve the asymmetric encryption functions. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// Retrieve the cipher functions. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// Retrieve the hash functions. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// Retrieve the random number generator functions. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// Retrieve the secret agreement functions. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// Retrieve the signature functions. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// Retrieve the key storage functions. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// Retrieve the Schannel functions. + /// + /// + /// + /// + /// + /// The address of a ULONG variable that, on entry, contains the size, in bytes, of the buffer pointed to by ppBuffer. If this + /// size is not large enough to hold the set of context identifiers, this function will fail with STATUS_BUFFER_TOO_SMALL. + /// + /// After this function returns, this value contains the number of bytes that were copied to the ppBuffer buffer. + /// + /// + /// + /// The address of a pointer to a CRYPT_CONTEXT_FUNCTIONS structure that receives the set of context functions retrieved by this + /// function. The value pointed to by the pcbBuffer parameter contains the size of this buffer. + /// + /// + /// If the value pointed to by this parameter is NULL, this function will allocate the required memory. This memory must be + /// freed when it is no longer needed by passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// If this parameter is NULL, this function will place the required size, in bytes, in the variable pointed to by the + /// pcbBuffer parameter and return STATUS_BUFFER_TOO_SMALL. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// + /// The ppBuffer parameter is not NULL, and the value pointed to by the pcbBuffer parameter is not large enough to hold the set of contexts. + /// + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_NOT_FOUND + /// No context functions that match the specified criteria were found. + /// + /// + /// + /// + /// BCryptEnumContextFunctions can be called only in user mode. + /// Examples + /// + /// The following example shows how to use the BCryptEnumContextFunctions function to enumerate the key storage functions for + /// all contexts in the local-machine configuration table. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptenumcontextfunctions NTSTATUS + // BCryptEnumContextFunctions( ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, ULONG *pcbBuffer, PCRYPT_CONTEXT_FUNCTIONS + // *ppBuffer ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "81bdfd47-7001-4e63-a8b3-33dae99f2c66")] + public static extern NTStatus BCryptEnumContextFunctions(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, out uint pcbBuffer, out SafeBCryptBuffer ppBuffer); + + /// + /// The BCryptEnumContextFunctions function obtains the cryptographic functions for a context in the specified configuration table. + /// + /// + /// Identifies the configuration table from which to retrieve the context functions. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// Retrieve the context functions from the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to enumerate the functions for. + /// + /// + /// Identifies the cryptographic interface to retrieve the functions for. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// Retrieve the asymmetric encryption functions. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// Retrieve the cipher functions. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// Retrieve the hash functions. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// Retrieve the random number generator functions. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// Retrieve the secret agreement functions. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// Retrieve the signature functions. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// Retrieve the key storage functions. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// Retrieve the Schannel functions. + /// + /// + /// + /// An array of strings that contains the names of the identifiers of the cryptographic functions. + [PInvokeData("bcrypt.h", MSDNShortId = "81bdfd47-7001-4e63-a8b3-33dae99f2c66")] + public static string[] BCryptEnumContextFunctions(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface) + { + BCryptEnumContextFunctions(dwTable, pszContext, dwInterface, out var sz, out var buf).ThrowIfFailed(); + return buf.ToStructure()._rgpszFunctions.ToArray(); + } + + /// + /// + /// [ BCryptEnumContexts is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// The BCryptEnumContexts function obtains the identifiers of the contexts in the specified configuration table. + /// + /// + /// Identifies the configuration table from which to retrieve the contexts. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// Retrieve the contexts from the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// + /// The address of a ULONG variable that, on entry, contains the size, in bytes, of the buffer pointed to by ppBuffer. If this + /// size is not large enough to hold the set of context identifiers, this function will fail with STATUS_BUFFER_TOO_SMALL. + /// + /// After this function returns, this value contains the number of bytes that were copied to the ppBuffer buffer. + /// + /// + /// + /// The address of a pointer to a CRYPT_CONTEXTS structure that receives the set of contexts retrieved by this function. The value + /// pointed to by the pcbBuffer parameter contains the size of this buffer. + /// + /// + /// If the value pointed to by this parameter is NULL, this function will allocate the required memory. This memory must be + /// freed when it is no longer needed by passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// If this parameter is NULL, this function will place the required size, in bytes, in the variable pointed to by the + /// pcbBuffer parameter and return STATUS_BUFFER_TOO_SMALL. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// + /// The ppBuffer parameter is not NULL, and the value pointed to by the pcbBuffer parameter is not large enough to hold the set of contexts. + /// + /// + /// + /// + /// + /// BCryptEnumContexts can be called only in user mode. + /// Examples + /// + /// The following example shows how to use the BCryptEnumContexts function to allocate the memory for the ppBuffer buffer. + /// + /// + /// The following example shows how to use the BCryptEnumContexts function to allocate your own memory for the ppBuffer buffer. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptenumcontexts NTSTATUS BCryptEnumContexts( ULONG + // dwTable, ULONG *pcbBuffer, PCRYPT_CONTEXTS *ppBuffer ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "02646a80-6e93-4169-83da-0488ff3da56f")] + public static extern NTStatus BCryptEnumContexts(ContextConfigTable dwTable, out uint pcbBuffer, out SafeBCryptBuffer ppBuffer); + + /// + /// + /// [ BCryptEnumContexts is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// The BCryptEnumContexts function obtains the identifiers of the contexts in the specified configuration table. + /// + /// + /// Identifies the configuration table from which to retrieve the contexts. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// Retrieve the contexts from the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// An array of strings that contains the names of the identifiers of the contexts. + [PInvokeData("bcrypt.h", MSDNShortId = "02646a80-6e93-4169-83da-0488ff3da56f")] + public static string[] BCryptEnumContexts(ContextConfigTable dwTable) + { + BCryptEnumContexts(dwTable, out var sz, out var buf).ThrowIfFailed(); + return buf.ToStructure()._rgpszContexts.ToArray(); + } + + /// The BCryptEnumProviders function obtains all of the CNG providers that support a specified algorithm. + /// + /// A pointer to a null-terminated Unicode string that identifies the algorithm to obtain the providers for. This can be one of the + /// predefined CNG Algorithm Identifiers or another algorithm identifier. + /// + /// A pointer to a ULONG variable to receive the number of elements in the ppImplList array. + /// + /// The address of an array of BCRYPT_PROVIDER_NAME structures to receive the collection of providers that support the specified + /// algorithm. The pImplCount parameter receives the number of elements in this array. This memory must be freed when it is no longer + /// needed by passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// A set of flags that modifies the behavior of this function. There are currently no flags defined, so this parameter must be zero. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// BCryptEnumProviders can be called either from user mode or kernel mode. Kernel mode callers must be executing at + /// PASSIVE_LEVEL IRQL. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptenumproviders NTSTATUS BCryptEnumProviders( LPCWSTR + // pszAlgId, ULONG *pImplCount, BCRYPT_PROVIDER_NAME **ppImplList, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "0496f241-9530-47fb-89e2-15d7ab6da87a")] + public static extern NTStatus BCryptEnumProviders([MarshalAs(UnmanagedType.LPWStr)] string pszAlgId, out uint pImplCount, out SafeBCryptBuffer ppImplList, uint dwFlags = 0); + + /// The BCryptEnumProviders function obtains all of the CNG providers that support a specified algorithm. + /// + /// A pointer to a null-terminated Unicode string that identifies the algorithm to obtain the providers for. This can be one of the + /// predefined CNG Algorithm Identifiers or another algorithm identifier. + /// + /// An array of strings that contains the names of the providers. + [PInvokeData("bcrypt.h", MSDNShortId = "0496f241-9530-47fb-89e2-15d7ab6da87a")] + public static string[] BCryptEnumProviders(string pszAlgId) + { + BCryptEnumProviders(pszAlgId, out var sz, out var buf).ThrowIfFailed(); + return buf.DangerousGetHandle().ToArray((int)sz).Select(s => s.pszProviderName).ToArray(); + } + + /// The BCryptEnumRegisteredProviders function retrieves information about the registered providers. + /// + /// + /// A pointer to a ULONG value that, on entry, contains the size, in bytes, of the buffer pointed to by the ppBuffer + /// parameter. On exit, this value receives either the number of bytes copied to the buffer or the required size, in bytes, of the buffer. + /// + /// + /// Note This is the total size, in bytes, of the entire buffer, not just the size of the CRYPT_PROVIDERS structure. The + /// buffer must be able to hold other data for the providers in addition to the CRYPT_PROVIDERS structure. + /// + /// + /// + /// + /// A pointer to a buffer pointer that receives a CRYPT_PROVIDERS structure and other data that describes the collection of + /// registered providers. + /// + /// + /// If this parameter is NULL, this function will return STATUS_BUFFER_TOO_SMALL and place in the value pointed to by + /// the pcbBuffer parameter, the required size, in bytes, of all the data. + /// + /// + /// If this parameter is the address of a NULL pointer, this function will allocate the required memory, fill the memory with + /// the information about the providers, and place the pointer to this memory in this parameter. When you have finished using this + /// memory, free it by passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// If this parameter is the address of a non- NULL pointer, this function will copy the provider information into this + /// buffer. The pcbBuffer parameter must contain the size, in bytes, of the entire buffer. If the buffer is not large enough to hold + /// all of the provider information, this function will return STATUS_BUFFER_TOO_SMALL. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the pcbBuffer parameter is not large enough to hold all of the data. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// The BCryptEnumRegisteredProviders function can be called in one of two ways: + /// + /// + /// + /// The first is to have the BCryptEnumRegisteredProviders function allocate the memory. This is accomplished by passing the + /// address of a NULL pointer for the ppBuffer parameter. This code will allocate the memory required for the CRYPT_PROVIDERS + /// structure and the associated strings. When the BCryptEnumRegisteredProviders function is used in this manner, you must + /// free the memory when it is no longer needed by passing ppBuffer to the BCryptFreeBuffer function. + /// + /// + /// + /// + /// The second method is to allocate the required memory yourself. This is accomplished by calling the + /// BCryptEnumRegisteredProviders function with NULL for the ppBuffer parameter. The + /// BCryptEnumRegisteredProviders function will place in the value pointed to by the pcbBuffer parameter, the required size, + /// in bytes, of the CRYPT_PROVIDERS structure and all strings. You then allocate the required memory and pass the address of this + /// buffer pointer for the ppBuffer parameter in a second call to the BCryptEnumRegisteredProviders function. + /// + /// + /// + /// BCryptEnumRegisteredProviders can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptenumregisteredproviders NTSTATUS + // BCryptEnumRegisteredProviders( ULONG *pcbBuffer, PCRYPT_PROVIDERS *ppBuffer ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "a01adfec-dbe0-4817-af97-63163760fafc")] + public static extern NTStatus BCryptEnumRegisteredProviders(out uint pcbBuffer, out SafeBCryptBuffer ppBuffer); + + /// The BCryptEnumRegisteredProviders function retrieves information about the registered providers. + /// An array of strings that contains the names of the registered providers. + [PInvokeData("bcrypt.h", MSDNShortId = "a01adfec-dbe0-4817-af97-63163760fafc")] + public static string[] BCryptEnumRegisteredProviders() + { + BCryptEnumRegisteredProviders(out var sz, out var buf).ThrowIfFailed(); + return buf.ToStructure()._rgpszProviders.ToArray(); + } + + /// The BCryptExportKey function exports a key to a memory BLOB that can be persisted for later use. + /// The handle of the key to export. + /// + /// + /// The handle of the key with which to wrap the exported key. Use this parameter when exporting BLOBs of type + /// BCRYPT_AES_WRAP_KEY_BLOB; otherwise, set it to NULL. + /// + /// Windows Server 2008 and Windows Vista: This parameter is not used and should be set to NULL. + /// + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the type of BLOB to export. This can be one of the + /// following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_AES_WRAP_KEY_BLOB + /// + /// Export an AES key wrapped key. The hExportKey parameter must reference a valid BCRYPT_KEY_HANDLE pointer to the key encryption + /// key, and the key represented by the hKey parameter must be a multiple of 8 bytes long. Windows Server 2008 and Windows Vista: + /// This BLOB type is not supported. + /// + /// + /// + /// BCRYPT_DH_PRIVATE_BLOB + /// + /// Export a Diffie-Hellman public/private key pair. The pbOutput buffer receives a BCRYPT_DH_KEY_BLOB structure immediately followed + /// by the key data. + /// + /// + /// + /// BCRYPT_DH_PUBLIC_BLOB + /// + /// Export a Diffie-Hellman public key. The pbOutput buffer receives a BCRYPT_DH_KEY_BLOB structure immediately followed by the key data. + /// + /// + /// + /// BCRYPT_DSA_PRIVATE_BLOB + /// + /// Export a DSA public/private key pair. The pbOutput buffer receives a BCRYPT_DSA_KEY_BLOB or BCRYPT_DSA_KEY_BLOB_V2 structure + /// immediately followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 to 1024 bits. BCRYPT_DSA_KEY_BLOB_V2 + /// is used for key lengths that exceed 1024 bits but are less than or equal to 3072 bits. Windows 8: Support for + /// BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + /// + /// + /// BCRYPT_DSA_PUBLIC_BLOB + /// + /// Export a DSA public key. The pbOutput buffer receives a BCRYPT_DSA_KEY_BLOB or BCRYPT_DSA_KEY_BLOB_V2 structure immediately + /// followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 to 1024 bits. BCRYPT_DSA_KEY_BLOB_V2 is used for + /// key lengths that exceed 1024 bits but are less than or equal to 3072 bits. Windows 8: Support for BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + /// + /// + /// BCRYPT_ECCPRIVATE_BLOB + /// + /// Export an elliptic curve cryptography (ECC) private key. The pbOutput buffer receives a BCRYPT_ECCKEY_BLOB structure immediately + /// followed by the key data. + /// + /// + /// + /// BCRYPT_ECCPUBLIC_BLOB + /// + /// Export an ECC public key. The pbOutput buffer receives a BCRYPT_ECCKEY_BLOB structure immediately followed by the key data. + /// + /// + /// + /// BCRYPT_KEY_DATA_BLOB + /// + /// Export a symmetric key to a data BLOB. The pbOutput buffer receives a BCRYPT_KEY_DATA_BLOB_HEADER structure immediately followed + /// by the key BLOB. + /// + /// + /// + /// BCRYPT_OPAQUE_KEY_BLOB + /// + /// Export a symmetric key in a format that is specific to a single cryptographic service provider (CSP). Opaque BLOBs are not + /// transferable and must be imported by using the same CSP that generated the BLOB. Opaque BLOBs are only intended to be used for + /// interprocess transfer of keys and are not suitable to be persisted and read across versions of a provider. + /// + /// + /// + /// BCRYPT_PUBLIC_KEY_BLOB + /// + /// Export a generic public key of any type. The type of key in this BLOB is determined by the Magic member of the BCRYPT_KEY_BLOB structure. + /// + /// + /// + /// BCRYPT_PRIVATE_KEY_BLOB + /// + /// Export a generic private key of any type. The private key does not necessarily contain the public key. The type of key in this + /// BLOB is determined by the Magic member of the BCRYPT_KEY_BLOB structure. + /// + /// + /// + /// BCRYPT_RSAFULLPRIVATE_BLOB + /// + /// Export a full RSA public/private key pair. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by + /// the key data. This BLOB will include additional key material compared to the BCRYPT_RSAPRIVATE_BLOB type. + /// + /// + /// + /// BCRYPT_RSAPRIVATE_BLOB + /// + /// Export an RSA public/private key pair. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by the + /// key data. + /// + /// + /// + /// BCRYPT_RSAPUBLIC_BLOB + /// + /// Export an RSA public key. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by the key data. + /// + /// + /// + /// LEGACY_DH_PRIVATE_BLOB + /// + /// Export a legacy Diffie-Hellman Version 3 Private Key BLOB that contains a Diffie-Hellman public/private key pair that can be + /// imported by using CryptoAPI. + /// + /// + /// + /// LEGACY_DH_PUBLIC_BLOB + /// + /// Export a legacy Diffie-Hellman Version 3 Public Key BLOB that contains a Diffie-Hellman public key that can be imported by using CryptoAPI. + /// + /// + /// + /// LEGACY_DSA_PRIVATE_BLOB + /// Export a DSA public/private key pair in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_DSA_PUBLIC_BLOB + /// Export a DSA public key in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_DSA_V2_PRIVATE_BLOB + /// Export a DSA version 2 private key in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_RSAPRIVATE_BLOB + /// Export an RSA public/private key pair in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_RSAPUBLIC_BLOB + /// Export an RSA public key in a form that can be imported by using CryptoAPI. + /// + /// + /// + /// + /// The address of a buffer that receives the key BLOB. The cbOutput parameter contains the size of this buffer. If this parameter is + /// NULL, this function will place the required size, in bytes, in the ULONG pointed to by the pcbResult parameter. + /// + /// Contains the size, in bytes, of the pbOutput buffer. + /// + /// A pointer to a ULONG that receives the number of bytes that were copied to the pbOutput buffer. If the pbOutput parameter + /// is NULL, this function will place the required size, in bytes, in the ULONG pointed to by this parameter. + /// + /// A set of flags that modify the behavior of this function. No flags are defined for this function. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the cbOutput parameter is not large enough to hold the ciphertext. + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hKey parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The specified BLOB type is not supported by the provider. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptExportKey can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a provider + /// that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptExportKey function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptexportkey NTSTATUS BCryptExportKey( BCRYPT_KEY_HANDLE + // hKey, BCRYPT_KEY_HANDLE hExportKey, LPCWSTR pszBlobType, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "a5d73143-c1d6-43b3-a724-7e27c68a5ade")] + public static extern NTStatus BCryptExportKey(BCRYPT_KEY_HANDLE hKey, BCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, uint dwFlags = 0); + + /// The BCryptExportKey function exports a key to a memory BLOB that can be persisted for later use. + /// The handle of the key to export. + /// + /// + /// The handle of the key with which to wrap the exported key. Use this parameter when exporting BLOBs of type + /// BCRYPT_AES_WRAP_KEY_BLOB; otherwise, set it to NULL. + /// + /// Windows Server 2008 and Windows Vista: This parameter is not used and should be set to NULL. + /// + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the type of BLOB to export. This can be one of the + /// following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_AES_WRAP_KEY_BLOB + /// + /// Export an AES key wrapped key. The hExportKey parameter must reference a valid BCRYPT_KEY_HANDLE pointer to the key encryption + /// key, and the key represented by the hKey parameter must be a multiple of 8 bytes long. Windows Server 2008 and Windows Vista: + /// This BLOB type is not supported. + /// + /// + /// + /// BCRYPT_DH_PRIVATE_BLOB + /// + /// Export a Diffie-Hellman public/private key pair. The pbOutput buffer receives a BCRYPT_DH_KEY_BLOB structure immediately followed + /// by the key data. + /// + /// + /// + /// BCRYPT_DH_PUBLIC_BLOB + /// + /// Export a Diffie-Hellman public key. The pbOutput buffer receives a BCRYPT_DH_KEY_BLOB structure immediately followed by the key data. + /// + /// + /// + /// BCRYPT_DSA_PRIVATE_BLOB + /// + /// Export a DSA public/private key pair. The pbOutput buffer receives a BCRYPT_DSA_KEY_BLOB or BCRYPT_DSA_KEY_BLOB_V2 structure + /// immediately followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 to 1024 bits. BCRYPT_DSA_KEY_BLOB_V2 + /// is used for key lengths that exceed 1024 bits but are less than or equal to 3072 bits. Windows 8: Support for + /// BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + /// + /// + /// BCRYPT_DSA_PUBLIC_BLOB + /// + /// Export a DSA public key. The pbOutput buffer receives a BCRYPT_DSA_KEY_BLOB or BCRYPT_DSA_KEY_BLOB_V2 structure immediately + /// followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 to 1024 bits. BCRYPT_DSA_KEY_BLOB_V2 is used for + /// key lengths that exceed 1024 bits but are less than or equal to 3072 bits. Windows 8: Support for BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + /// + /// + /// BCRYPT_ECCPRIVATE_BLOB + /// + /// Export an elliptic curve cryptography (ECC) private key. The pbOutput buffer receives a BCRYPT_ECCKEY_BLOB structure immediately + /// followed by the key data. + /// + /// + /// + /// BCRYPT_ECCPUBLIC_BLOB + /// + /// Export an ECC public key. The pbOutput buffer receives a BCRYPT_ECCKEY_BLOB structure immediately followed by the key data. + /// + /// + /// + /// BCRYPT_KEY_DATA_BLOB + /// + /// Export a symmetric key to a data BLOB. The pbOutput buffer receives a BCRYPT_KEY_DATA_BLOB_HEADER structure immediately followed + /// by the key BLOB. + /// + /// + /// + /// BCRYPT_OPAQUE_KEY_BLOB + /// + /// Export a symmetric key in a format that is specific to a single cryptographic service provider (CSP). Opaque BLOBs are not + /// transferable and must be imported by using the same CSP that generated the BLOB. Opaque BLOBs are only intended to be used for + /// interprocess transfer of keys and are not suitable to be persisted and read across versions of a provider. + /// + /// + /// + /// BCRYPT_PUBLIC_KEY_BLOB + /// + /// Export a generic public key of any type. The type of key in this BLOB is determined by the Magic member of the BCRYPT_KEY_BLOB structure. + /// + /// + /// + /// BCRYPT_PRIVATE_KEY_BLOB + /// + /// Export a generic private key of any type. The private key does not necessarily contain the public key. The type of key in this + /// BLOB is determined by the Magic member of the BCRYPT_KEY_BLOB structure. + /// + /// + /// + /// BCRYPT_RSAFULLPRIVATE_BLOB + /// + /// Export a full RSA public/private key pair. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by + /// the key data. This BLOB will include additional key material compared to the BCRYPT_RSAPRIVATE_BLOB type. + /// + /// + /// + /// BCRYPT_RSAPRIVATE_BLOB + /// + /// Export an RSA public/private key pair. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by the + /// key data. + /// + /// + /// + /// BCRYPT_RSAPUBLIC_BLOB + /// + /// Export an RSA public key. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by the key data. + /// + /// + /// + /// LEGACY_DH_PRIVATE_BLOB + /// + /// Export a legacy Diffie-Hellman Version 3 Private Key BLOB that contains a Diffie-Hellman public/private key pair that can be + /// imported by using CryptoAPI. + /// + /// + /// + /// LEGACY_DH_PUBLIC_BLOB + /// + /// Export a legacy Diffie-Hellman Version 3 Public Key BLOB that contains a Diffie-Hellman public key that can be imported by using CryptoAPI. + /// + /// + /// + /// LEGACY_DSA_PRIVATE_BLOB + /// Export a DSA public/private key pair in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_DSA_PUBLIC_BLOB + /// Export a DSA public key in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_DSA_V2_PRIVATE_BLOB + /// Export a DSA version 2 private key in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_RSAPRIVATE_BLOB + /// Export an RSA public/private key pair in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_RSAPUBLIC_BLOB + /// Export an RSA public key in a form that can be imported by using CryptoAPI. + /// + /// + /// + /// + /// The address of a buffer that receives the key BLOB. The cbOutput parameter contains the size of this buffer. If this parameter is + /// NULL, this function will place the required size, in bytes, in the ULONG pointed to by the pcbResult parameter. + /// + /// Contains the size, in bytes, of the pbOutput buffer. + /// + /// A pointer to a ULONG that receives the number of bytes that were copied to the pbOutput buffer. If the pbOutput parameter + /// is NULL, this function will place the required size, in bytes, in the ULONG pointed to by this parameter. + /// + /// A set of flags that modify the behavior of this function. No flags are defined for this function. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the cbOutput parameter is not large enough to hold the ciphertext. + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hKey parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The specified BLOB type is not supported by the provider. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptExportKey can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a provider + /// that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptExportKey function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptexportkey NTSTATUS BCryptExportKey( BCRYPT_KEY_HANDLE + // hKey, BCRYPT_KEY_HANDLE hExportKey, LPCWSTR pszBlobType, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "a5d73143-c1d6-43b3-a724-7e27c68a5ade")] + public static extern NTStatus BCryptExportKey(BCRYPT_KEY_HANDLE hKey, BCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, uint dwFlags = 0); + + /// + /// The BCryptFinalizeKeyPair function completes a public/private key pair. The key cannot be used until this function has + /// been called. After this function has been called, the BCryptSetProperty function can no longer be used for this key. + /// + /// The handle of the key to complete. This handle is obtained by calling the BCryptGenerateKeyPair function. + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hKey parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The specified provider does not support asymmetric key encryption. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptFinalizeKeyPair can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a + /// provider that was opened with the BCRYPT_PROV_DISPATCH flag. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptfinalizekeypair NTSTATUS BCryptFinalizeKeyPair( + // BCRYPT_KEY_HANDLE hKey, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "bf0b90f1-6da8-464e-9271-ad60ea762653")] + public static extern NTStatus BCryptFinalizeKeyPair(BCRYPT_KEY_HANDLE hKey, uint dwFlags = 0); + + /// + /// + /// The BCryptFinishHash function retrieves the hash or Message Authentication Code (MAC) value for the data accumulated from + /// prior calls to BCryptHashData. + /// + /// + /// + /// + /// The handle of the hash or MAC object to use to compute the hash or MAC. This handle is obtained by calling the BCryptCreateHash + /// function. After this function has been called, the hash handle passed to this function cannot be used again except in a call to BCryptDestroyHash. + /// + /// + /// + /// A pointer to a buffer that receives the hash or MAC value. The cbOutput parameter contains the size of this buffer. + /// + /// + /// The size, in bytes, of the pbOutput buffer. This size must exactly match the size of the hash or MAC value. + /// + /// The size can be obtained by calling the BCryptGetProperty function to get the BCRYPT_HASH_LENGTH property. This will + /// provide the size of the hash or MAC value for the specified algorithm. + /// + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// + /// The hash handle in the hHash parameter is not valid. After the BCryptFinishHash function has been called for a hash handle, that + /// handle cannot be reused. + /// + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. This includes the case where cbOutput is not the same size as the hash. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptFinishHash can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hHash parameter must be derived from an algorithm handle returned by a + /// provider that was opened by using the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptFinishHash + /// function must refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptfinishhash NTSTATUS BCryptFinishHash( + // BCRYPT_HASH_HANDLE hHash, PUCHAR pbOutput, ULONG cbOutput, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "82a7c3d9-c01b-46d0-8b54-694dc0d8ffdd")] + public static extern NTStatus BCryptFinishHash(BCRYPT_HASH_HANDLE hHash, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, uint dwFlags = 0); + + /// + /// The BCryptFreeBuffer function is used to free memory that was allocated by one of the CNG functions. + /// + /// + /// A pointer to the memory buffer to be freed. + /// + /// + /// This function does not return a value. + /// + /// + /// + /// BCryptFreeBuffer must be called in the same processor mode as the BCrypt API function that allocated the buffer. In + /// addition, if the buffer was allocated at PASSIVE_LEVEL IRQL, it must be freed at that IRQL. If the buffer was allocated at + /// DISPATCH_LEVEL IRQL, it can be freed at either DISPATCH_LEVEL IRQL or PASSIVE_LEVEL IRQL. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptfreebuffer void BCryptFreeBuffer( PVOID pvBuffer ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "0ee83ca1-2fe6-4ff2-823e-888b3e66f310")] + public static extern void BCryptFreeBuffer(IntPtr pvBuffer); + + /// + /// The BCryptGenerateKeyPair function creates an empty public/private key pair. After you create a key by using this + /// function, you can use the BCryptSetProperty function to set its properties; however, the key cannot be used until the + /// BCryptFinalizeKeyPair function is called. + /// + /// + /// Handle of an algorithm provider that supports signing, asymmetric encryption, or key agreement. This handle must have been + /// created by using the BCryptOpenAlgorithmProvider function. + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE that receives the handle of the key. This handle is used in subsequent functions that + /// require a key, such as BCryptEncrypt. This handle must be released when it is no longer needed by passing it to the + /// BCryptDestroyKey function. + /// + /// + /// + /// The length, in bits, of the key. Algorithm providers have different key size restrictions for each standard asymmetric algorithm. + /// + /// + /// + /// Algorithm identifier + /// Meaning + /// + /// + /// BCRYPT_DH_ALGORITHM + /// The key size must be greater than or equal to 512 bits, less than or equal to 4096 bits, and must be a multiple of 64. + /// + /// + /// BCRYPT_DSA_ALGORITHM + /// + /// Prior to Windows 8, the key size must be greater than or equal to 512 bits, less than or equal to 1024 bits, and must be a + /// multiple of 64. Beginning with Windows 8, the key size must be greater than or equal to 512 bits, less than or equal to 3072 + /// bits, and must be a multiple of 64. Processing for key sizes less than or equal to 1024 bits adheres to FIPS-186-2. Processing + /// for key sizes greater than 1024 and less than or equal to 3072 adheres to FIPS 186-3. + /// + /// + /// + /// BCRYPT_ECDH_P256_ALGORITHM + /// The key size must be 256 bits. + /// + /// + /// BCRYPT_ECDH_P384_ALGORITHM + /// The key size must be 384 bits. + /// + /// + /// BCRYPT_ECDH_P521_ALGORITHM + /// The key size must be 521 bits. + /// + /// + /// BCRYPT_ECDSA_P256_ALGORITHM + /// The key size must be 256 bits. + /// + /// + /// BCRYPT_ECDSA_P384_ALGORITHM + /// The key size must be 384 bits. + /// + /// + /// BCRYPT_ECDSA_P521_ALGORITHM + /// The key size must be 521 bits. + /// + /// + /// BCRYPT_RSA_ALGORITHM + /// The key size must be greater than or equal to 512 bits, less than or equal to 16384 bits, and must be a multiple of 64. + /// + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The specified provider does not support asymmetric key encryption. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptGenerateKeyPair can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptGenerateKeyPair function must refer to nonpaged (or + /// locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptgeneratekeypair NTSTATUS BCryptGenerateKeyPair( + // BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE *phKey, ULONG dwLength, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "cdf0de2e-2445-45e3-91ba-89791a0c0642")] + public static extern NTStatus BCryptGenerateKeyPair(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey, uint dwLength, uint dwFlags = 0); + + /// + /// The BCryptGenerateSymmetricKey function creates a key object for use with a symmetrical key encryption algorithm from a + /// supplied key. + /// + /// + /// The handle of an algorithm provider created with the BCryptOpenAlgorithmProvider function. The algorithm specified when the + /// provider was created must support symmetric key encryption. + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE that receives the handle of the key. This handle is used in subsequent functions that + /// require a key, such as BCryptEncrypt. This handle must be released when it is no longer needed by passing it to the + /// BCryptDestroyKey function. + /// + /// + /// + /// A pointer to a buffer that receives the key object. The cbKeyObject parameter contains the size of this buffer. The required size + /// of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH property. This + /// will provide the size of the key object for the specified algorithm. + /// + /// This memory can only be freed after the phKey key handle is destroyed. + /// + /// If the value of this parameter is NULL and the value of the cbKeyObject parameter is zero, the memory for the key object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// + /// + /// The size, in bytes, of the pbKeyObject buffer. + /// + /// If the value of this parameter is zero and the value of the pbKeyObject parameter is NULL, the memory for the key object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// + /// + /// + /// Pointer to a buffer that contains the key from which to create the key object. The cbSecret parameter contains the size of this + /// buffer. This is normally a hash of a password or some other reproducible data. If the data passed in exceeds the target key size, + /// the data will be truncated and the excess will be ignored. + /// + /// Note We strongly recommended that applications pass in the exact number of bytes required by the target key. + /// + /// The size, in bytes, of the pbSecret buffer. + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the key object specified by the cbKeyObject parameter is not large enough to hold the key object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptGenerateSymmetricKey can be called either from user mode or + /// kernel mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current + /// IRQL level is DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptGenerateSymmetricKey function must refer to + /// nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptgeneratesymmetrickey NTSTATUS + // BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbKeyObject, ULONG cbKeyObject, PUCHAR + // pbSecret, ULONG cbSecret, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "c55d714f-f47e-4ddf-97b9-985c0441bb2d")] + public static extern NTStatus BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] SafeAllocatedMemoryHandle pbKeyObject, [Optional] uint cbKeyObject, byte[] pbSecret, uint cbSecret, uint dwFlags = 0); + + /// + /// The BCryptGenerateSymmetricKey function creates a key object for use with a symmetrical key encryption algorithm from a + /// supplied key. + /// + /// + /// The handle of an algorithm provider created with the BCryptOpenAlgorithmProvider function. The algorithm specified when the + /// provider was created must support symmetric key encryption. + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE that receives the handle of the key. This handle is used in subsequent functions that + /// require a key, such as BCryptEncrypt. This handle must be released when it is no longer needed by passing it to the + /// BCryptDestroyKey function. + /// + /// + /// + /// A pointer to a buffer that receives the key object. The cbKeyObject parameter contains the size of this buffer. The required size + /// of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH property. This + /// will provide the size of the key object for the specified algorithm. + /// + /// This memory can only be freed after the phKey key handle is destroyed. + /// + /// If the value of this parameter is NULL and the value of the cbKeyObject parameter is zero, the memory for the key object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// + /// + /// The size, in bytes, of the pbKeyObject buffer. + /// + /// If the value of this parameter is zero and the value of the pbKeyObject parameter is NULL, the memory for the key object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// + /// + /// + /// Pointer to a buffer that contains the key from which to create the key object. The cbSecret parameter contains the size of this + /// buffer. This is normally a hash of a password or some other reproducible data. If the data passed in exceeds the target key size, + /// the data will be truncated and the excess will be ignored. + /// + /// Note We strongly recommended that applications pass in the exact number of bytes required by the target key. + /// + /// The size, in bytes, of the pbSecret buffer. + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the key object specified by the cbKeyObject parameter is not large enough to hold the key object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptGenerateSymmetricKey can be called either from user mode or + /// kernel mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current + /// IRQL level is DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptGenerateSymmetricKey function must refer to + /// nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptgeneratesymmetrickey NTSTATUS + // BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbKeyObject, ULONG cbKeyObject, PUCHAR + // pbSecret, ULONG cbSecret, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "c55d714f-f47e-4ddf-97b9-985c0441bb2d")] + public static extern NTStatus BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbKeyObject, [Optional] uint cbKeyObject, byte[] pbSecret, uint cbSecret, uint dwFlags = 0); + + /// + /// The BCryptGenerateSymmetricKey function creates a key object for use with a symmetrical key encryption algorithm from a + /// supplied key. + /// + /// + /// The handle of an algorithm provider created with the BCryptOpenAlgorithmProvider function. The algorithm specified when the + /// provider was created must support symmetric key encryption. + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE that receives the handle of the key. This handle is used in subsequent functions that + /// require a key, such as BCryptEncrypt. This handle must be released when it is no longer needed by passing it to the + /// BCryptDestroyKey function. + /// + /// + /// + /// A pointer to a buffer that receives the key object. The cbKeyObject parameter contains the size of this buffer. The required size + /// of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH property. This + /// will provide the size of the key object for the specified algorithm. + /// + /// This memory can only be freed after the phKey key handle is destroyed. + /// + /// If the value of this parameter is NULL and the value of the cbKeyObject parameter is zero, the memory for the key object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// + /// + /// The size, in bytes, of the pbKeyObject buffer. + /// + /// If the value of this parameter is zero and the value of the pbKeyObject parameter is NULL, the memory for the key object + /// is allocated and freed by this function. Windows 7: This memory management functionality is available beginning with + /// Windows 7. + /// + /// + /// + /// + /// Pointer to a buffer that contains the key from which to create the key object. The cbSecret parameter contains the size of this + /// buffer. This is normally a hash of a password or some other reproducible data. If the data passed in exceeds the target key size, + /// the data will be truncated and the excess will be ignored. + /// + /// Note We strongly recommended that applications pass in the exact number of bytes required by the target key. + /// + /// The size, in bytes, of the pbSecret buffer. + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the key object specified by the cbKeyObject parameter is not large enough to hold the key object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptGenerateSymmetricKey can be called either from user mode or + /// kernel mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current + /// IRQL level is DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptGenerateSymmetricKey function must refer to + /// nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptgeneratesymmetrickey NTSTATUS + // BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbKeyObject, ULONG cbKeyObject, PUCHAR + // pbSecret, ULONG cbSecret, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "c55d714f-f47e-4ddf-97b9-985c0441bb2d")] + public static extern NTStatus BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbKeyObject, [Optional] uint cbKeyObject, IntPtr pbSecret, uint cbSecret, uint dwFlags = 0); + + /// The BCryptGenRandom function generates a random number. + /// + /// The handle of an algorithm provider created by using the BCryptOpenAlgorithmProvider function. The algorithm that was specified + /// when the provider was created must support the random number generator interface. + /// + /// + /// The address of a buffer that receives the random number. The size of this buffer is specified by the cbBuffer parameter. + /// + /// The size, in bytes, of the pbBuffer buffer. + /// + /// A set of flags that modify the behavior of this function. This parameter can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_RNG_USE_ENTROPY_IN_BUFFER 0x00000001 + /// + /// This function will use the number in the pbBuffer buffer as additional entropy for the random number. If this flag is not + /// specified, this function will use a random number for the entropy. Windows 8 and later: This flag is ignored in Windows 8 and later. + /// + /// + /// + /// BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002 + /// + /// Use the system-preferred random number generator algorithm. The hAlgorithm parameter must be NULL. + /// BCRYPT_USE_SYSTEM_PREFERRED_RNG is only supported at PASSIVE_LEVEL IRQL. For more information, see Remarks. Windows Vista: This + /// flag is not supported. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// The default random number provider implements an algorithm for generating random numbers that complies with the NIST SP800-90 + /// standard, specifically the CTR_DRBG portion of that standard. + /// + /// + /// Windows Vista: Prior to Windows Vista with Service Pack 1 (SP1) the default random number provider implements an algorithm + /// for generating random numbers that complies with the FIPS 186-2 standard. + /// + /// + /// Depending on what processor modes a provider supports, BCryptGenRandom can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptGenRandom function must refer to nonpaged (or + /// locked) memory. Windows Vista: The Microsoft provider does not support calling at DISPATCH_LEVEL. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptgenrandom NTSTATUS BCryptGenRandom( BCRYPT_ALG_HANDLE + // hAlgorithm, PUCHAR pbBuffer, ULONG cbBuffer, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "7c6cee3a-f2c5-46f3-8cfe-984316f323d9")] + public static extern NTStatus BCryptGenRandom(BCRYPT_ALG_HANDLE hAlgorithm, IntPtr pbBuffer, uint cbBuffer, GenRandomFlags dwFlags); + + /// The BCryptGenRandom function generates a random number. + /// + /// The handle of an algorithm provider created by using the BCryptOpenAlgorithmProvider function. The algorithm that was specified + /// when the provider was created must support the random number generator interface. + /// + /// + /// The address of a buffer that receives the random number. The size of this buffer is specified by the cbBuffer parameter. + /// + /// The size, in bytes, of the pbBuffer buffer. + /// + /// A set of flags that modify the behavior of this function. This parameter can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_RNG_USE_ENTROPY_IN_BUFFER 0x00000001 + /// + /// This function will use the number in the pbBuffer buffer as additional entropy for the random number. If this flag is not + /// specified, this function will use a random number for the entropy. Windows 8 and later: This flag is ignored in Windows 8 and later. + /// + /// + /// + /// BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002 + /// + /// Use the system-preferred random number generator algorithm. The hAlgorithm parameter must be NULL. + /// BCRYPT_USE_SYSTEM_PREFERRED_RNG is only supported at PASSIVE_LEVEL IRQL. For more information, see Remarks. Windows Vista: This + /// flag is not supported. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// The default random number provider implements an algorithm for generating random numbers that complies with the NIST SP800-90 + /// standard, specifically the CTR_DRBG portion of that standard. + /// + /// + /// Windows Vista: Prior to Windows Vista with Service Pack 1 (SP1) the default random number provider implements an algorithm + /// for generating random numbers that complies with the FIPS 186-2 standard. + /// + /// + /// Depending on what processor modes a provider supports, BCryptGenRandom can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptGenRandom function must refer to nonpaged (or + /// locked) memory. Windows Vista: The Microsoft provider does not support calling at DISPATCH_LEVEL. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptgenrandom NTSTATUS BCryptGenRandom( BCRYPT_ALG_HANDLE + // hAlgorithm, PUCHAR pbBuffer, ULONG cbBuffer, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "7c6cee3a-f2c5-46f3-8cfe-984316f323d9")] + public static extern NTStatus BCryptGenRandom(BCRYPT_ALG_HANDLE hAlgorithm, SafeAllocatedMemoryHandle pbBuffer, uint cbBuffer, GenRandomFlags dwFlags); + + /// + /// + /// The BCryptGetFipsAlgorithmMode function determines whether Federal Information Processing Standard (FIPS) compliance is enabled. + /// + /// + /// + /// + /// The address of a BOOLEAN variable that receives zero if FIPS compliance is not enabled, or a nonzero value if FIPS + /// compliance is enabled. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// The pfEnabled parameter is not valid. + /// + /// + /// + /// + /// + /// BCryptGetFipsAlgorithmMode can be called either from user mode or kernel mode. Kernel mode callers must be executing at + /// PASSIVE_LEVEL IRQL. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptgetfipsalgorithmmode NTSTATUS + // BCryptGetFipsAlgorithmMode( BOOLEAN *pfEnabled ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "eb7b758d-3466-49fe-8729-a8a059fadcde")] + public static extern NTStatus BCryptGetFipsAlgorithmMode([MarshalAs(UnmanagedType.U1)] out bool pfEnabled); + + /// The BCryptGetProperty function retrieves the value of a named property for a CNG object. + /// A handle that represents the CNG object to obtain the property value for. + /// + /// A pointer to a null-terminated Unicode string that contains the name of the property to retrieve. This can be one of the + /// predefined Cryptography Primitive Property Identifiers or a custom property identifier. + /// + /// + /// The address of a buffer that receives the property value. The cbOutput parameter contains the size of this buffer. + /// + /// The size, in bytes, of the pbOutput buffer. + /// + /// A pointer to a ULONG variable that receives the number of bytes that were copied to the pbOutput buffer. If the pbOutput + /// parameter is NULL, this function will place the required size, in bytes, in the location pointed to by this parameter. + /// + /// A set of flags that modify the behavior of this function. No flags are defined for this function. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The buffer size specified by the cbOutput parameter is not large enough to hold the property value. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hObject parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The named property specified by the pszProperty parameter is not supported. + /// + /// + /// + /// + /// + /// To obtain the required size for a property, pass NULL for the pbOutput parameter. This function will place the required + /// size, in bytes, in the value pointed to by the pcbResult parameter. + /// + /// + /// Depending on what processor modes a provider supports, BCryptGetProperty can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, any pointers passed to the BCryptGetProperty function must refer to nonpaged (or locked) + /// memory. If the object specified in the hObject parameter is a handle, it must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptgetproperty NTSTATUS BCryptGetProperty( BCRYPT_HANDLE + // hObject, LPCWSTR pszProperty, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "5c62ca3a-843e-41a7-9340-41785fbb15f4")] + public static extern NTStatus BCryptGetProperty(BCRYPT_HANDLE hObject, [MarshalAs(UnmanagedType.LPWStr)] string pszProperty, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, uint dwFlags = 0); + + /// The BCryptGetProperty function retrieves the value of a named property for a CNG object. + /// The type of the expected return value. + /// A handle that represents the CNG object to obtain the property value for. + /// + /// A pointer to a null-terminated Unicode string that contains the name of the property to retrieve. This can be one of the + /// predefined Cryptography Primitive Property Identifiers or a custom property identifier. + /// + /// The value of the requested property from cast to type . + /// Requested type and system defined sizes do not match. + [PInvokeData("bcrypt.h", MSDNShortId = "5c62ca3a-843e-41a7-9340-41785fbb15f4")] + public static T BCryptGetProperty(BCRYPT_HANDLE hObject, string pszProperty) + { + using (var mem = SafeCoTaskMemHandle.CreateFromStructure()) + { + BCryptGetProperty(hObject, pszProperty, mem, (uint)mem.Size, out var sz).ThrowIfFailed(); + if (mem.Size != sz) throw new InvalidCastException("Requested type and system defined sizes do not match."); + return mem.ToStructure(); + } + } + + /// + /// + /// Performs a single hash computation. This is a convenience function that wraps calls to BCryptCreateHash, BCryptHashData, + /// BCryptFinishHash, and BCryptDestroyHash. + /// + /// + /// + /// + /// The handle of an algorithm provider created by using the BCryptOpenAlgorithmProvider function. The algorithm that was specified + /// when the provider was created must support the hash interface. + /// + /// + /// + /// + /// A pointer to a buffer that contains the key to use for the hash or MAC. The cbSecret parameter contains the size of this buffer. + /// This key only applies to hash algorithms opened by the BCryptOpenAlgorithmProvider function by using the + /// BCRYPT_ALG_HANDLE_HMAC flag. Otherwise, set this parameter to NULL + /// + /// + /// + /// The size, in bytes, of the pbSecret buffer. If no key is used, set this parameter to zero. + /// + /// + /// + /// A pointer to a buffer that contains the data to process. The cbInput parameter contains the number of bytes in this buffer. This + /// function does not modify the contents of this buffer. + /// + /// + /// + /// The number of bytes in the pbInput buffer. + /// + /// + /// A pointer to a buffer that receives the hash or MAC value. The cbOutput parameter contains the size of this buffer. + /// + /// + /// The size, in bytes, of the pbOutput buffer. This size must exactly match the size of the hash or MAC value. + /// + /// The size can be obtained by calling the BCryptGetProperty function to get the BCRYPT_HASH_LENGTH property. This will + /// provide the size of the hash or MAC value for the specified algorithm. + /// + /// + /// + /// A status code indicating success or failure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcrypthash NTSTATUS BCryptHash( BCRYPT_ALG_HANDLE + // hAlgorithm, PUCHAR pbSecret, ULONG cbSecret, PUCHAR pbInput, ULONG cbInput, PUCHAR pbOutput, ULONG cbOutput ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "F0FF9B6D-1345-480A-BE13-BE90547407BF")] + public static extern NTStatus BCryptHash(BCRYPT_ALG_HANDLE hAlgorithm, [Optional] IntPtr pbSecret, uint cbSecret, IntPtr pbInput, uint cbInput, IntPtr pbOutput, uint cbOutput); + + /// + /// + /// Performs a single hash computation. This is a convenience function that wraps calls to BCryptCreateHash, BCryptHashData, + /// BCryptFinishHash, and BCryptDestroyHash. + /// + /// + /// + /// + /// The handle of an algorithm provider created by using the BCryptOpenAlgorithmProvider function. The algorithm that was specified + /// when the provider was created must support the hash interface. + /// + /// + /// + /// + /// A pointer to a buffer that contains the key to use for the hash or MAC. The cbSecret parameter contains the size of this buffer. + /// This key only applies to hash algorithms opened by the BCryptOpenAlgorithmProvider function by using the + /// BCRYPT_ALG_HANDLE_HMAC flag. Otherwise, set this parameter to NULL + /// + /// + /// + /// The size, in bytes, of the pbSecret buffer. If no key is used, set this parameter to zero. + /// + /// + /// + /// A pointer to a buffer that contains the data to process. The cbInput parameter contains the number of bytes in this buffer. This + /// function does not modify the contents of this buffer. + /// + /// + /// + /// The number of bytes in the pbInput buffer. + /// + /// + /// A pointer to a buffer that receives the hash or MAC value. The cbOutput parameter contains the size of this buffer. + /// + /// + /// The size, in bytes, of the pbOutput buffer. This size must exactly match the size of the hash or MAC value. + /// + /// The size can be obtained by calling the BCryptGetProperty function to get the BCRYPT_HASH_LENGTH property. This will + /// provide the size of the hash or MAC value for the specified algorithm. + /// + /// + /// + /// A status code indicating success or failure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcrypthash NTSTATUS BCryptHash( BCRYPT_ALG_HANDLE + // hAlgorithm, PUCHAR pbSecret, ULONG cbSecret, PUCHAR pbInput, ULONG cbInput, PUCHAR pbOutput, ULONG cbOutput ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "F0FF9B6D-1345-480A-BE13-BE90547407BF")] + public static extern NTStatus BCryptHash(BCRYPT_ALG_HANDLE hAlgorithm, SafeAllocatedMemoryHandle pbSecret, uint cbSecret, SafeAllocatedMemoryHandle pbInput, uint cbInput, SafeAllocatedMemoryHandle pbOutput, uint cbOutput); + + /// + /// The BCryptHashData function performs a one way hash or Message Authentication Code (MAC) on a data buffer. + /// + /// + /// + /// The handle of the hash or MAC object to use to perform the operation. This handle is obtained by calling the BCryptCreateHash function. + /// + /// + /// + /// + /// A pointer to a buffer that contains the data to process. The cbInput parameter contains the number of bytes in this buffer. This + /// function does not modify the contents of this buffer. + /// + /// + /// + /// The number of bytes in the pbInput buffer. + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_INVALID_HANDLE + /// + /// The hash handle in the hHash parameter is not valid. After the BCryptFinishHash function has been called for a hash handle, that + /// handle cannot be reused. + /// + /// + /// + /// + /// + /// + /// To combine more than one buffer into the hash or MAC, you can call this function multiple times, passing a different buffer each + /// time. To obtain the hash or MAC value, call the BCryptFinishHash function. After the BCryptFinishHash function has been + /// called for a specified handle, that handle cannot be reused. + /// + /// + /// Depending on what processor modes a provider supports, BCryptHashData can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hHash parameter must be derived from an algorithm handle returned by a provider + /// that was opened by using the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptHashData function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcrypthashdata NTSTATUS BCryptHashData( BCRYPT_HASH_HANDLE + // hHash, PUCHAR pbInput, ULONG cbInput, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "dab89dff-dc84-4f69-8b6b-de65704b0265")] + public static extern NTStatus BCryptHashData(BCRYPT_HASH_HANDLE hHash, byte[] pbInput, uint cbInput, uint dwFlags = 0); + + /// + /// The BCryptHashData function performs a one way hash or Message Authentication Code (MAC) on a data buffer. + /// + /// + /// + /// The handle of the hash or MAC object to use to perform the operation. This handle is obtained by calling the BCryptCreateHash function. + /// + /// + /// + /// + /// A pointer to a buffer that contains the data to process. The cbInput parameter contains the number of bytes in this buffer. This + /// function does not modify the contents of this buffer. + /// + /// + /// + /// The number of bytes in the pbInput buffer. + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_INVALID_HANDLE + /// + /// The hash handle in the hHash parameter is not valid. After the BCryptFinishHash function has been called for a hash handle, that + /// handle cannot be reused. + /// + /// + /// + /// + /// + /// + /// To combine more than one buffer into the hash or MAC, you can call this function multiple times, passing a different buffer each + /// time. To obtain the hash or MAC value, call the BCryptFinishHash function. After the BCryptFinishHash function has been + /// called for a specified handle, that handle cannot be reused. + /// + /// + /// Depending on what processor modes a provider supports, BCryptHashData can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hHash parameter must be derived from an algorithm handle returned by a provider + /// that was opened by using the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptHashData function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcrypthashdata NTSTATUS BCryptHashData( BCRYPT_HASH_HANDLE + // hHash, PUCHAR pbInput, ULONG cbInput, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "dab89dff-dc84-4f69-8b6b-de65704b0265")] + public static extern NTStatus BCryptHashData(BCRYPT_HASH_HANDLE hHash, IntPtr pbInput, uint cbInput, uint dwFlags = 0); + + /// + /// The BCryptImportKey function imports a symmetric key from a key BLOB. The BCryptImportKeyPair function is used to import a + /// public/private key pair. + /// + /// + /// The handle of the algorithm provider to import the key. This handle is obtained by calling the BCryptOpenAlgorithmProvider function. + /// + /// + /// The handle of the key encryption key needed to unwrap the key BLOB in the pbInput parameter. + /// Windows Server 2008 and Windows Vista: This parameter is not used and should be set to NULL. + /// + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the type of BLOB that is contained in the pbInput + /// buffer. This can be one of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_AES_WRAP_KEY_BLOB + /// + /// Import a symmetric key from an AES key–wrapped key BLOB. The hImportKey parameter must reference a valid BCRYPT_KEY_HANDLE + /// pointer to the key encryption key. Windows Server 2008 and Windows Vista: This BLOB type is not supported. + /// + /// + /// + /// BCRYPT_KEY_DATA_BLOB + /// + /// Import a symmetric key from a data BLOB. The pbInput parameter is a pointer to a BCRYPT_KEY_DATA_BLOB_HEADER structure + /// immediately followed by the key BLOB. + /// + /// + /// + /// BCRYPT_OPAQUE_KEY_BLOB + /// + /// Import a symmetric key BLOB in a format that is specific to a single CSP. Opaque BLOBs are not transferable and must be imported + /// by using the same CSP that generated the BLOB. Opaque BLOBs are only intended to be used for interprocess transfer of keys and + /// are not suitable to be persisted and read in across versions of a provider. + /// + /// + /// + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE that receives the handle of the imported key. This handle is used in subsequent functions + /// that require a key, such as BCryptEncrypt. This handle must be released when it is no longer needed by passing it to the + /// BCryptDestroyKey function. + /// + /// + /// + /// A pointer to a buffer that receives the imported key object. The cbKeyObject parameter contains the size of this buffer. The + /// required size of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH + /// property. This will provide the size of the key object for the specified algorithm. + /// + /// This memory can only be freed after the phKey key handle is destroyed. + /// + /// The size, in bytes, of the pbKeyObject buffer. + /// + /// The address of a buffer that contains the key BLOB to import. The cbInput parameter contains the size of this buffer. The + /// pszBlobType parameter specifies the type of key BLOB this buffer contains. + /// + /// The size, in bytes, of the pbInput buffer. + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the key object specified by the cbKeyObject parameter is not large enough to hold the key object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// + /// The algorithm provider specified by the hAlgorithm parameter does not support the BLOB type specified by the pszBlobType parameter. + /// + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptImportKey can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptImportKey function must refer to nonpaged (or + /// locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptimportkey NTSTATUS BCryptImportKey( BCRYPT_ALG_HANDLE + // hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, LPCWSTR pszBlobType, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbKeyObject, ULONG cbKeyObject, + // PUCHAR pbInput, ULONG cbInput, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "6b9683f4-10f2-40e4-9757-a1f01991bef7")] + public static extern NTStatus BCryptImportKey(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, out SafeBCRYPT_KEY_HANDLE phKey, SafeAllocatedMemoryHandle pbKeyObject, uint cbKeyObject, SafeAllocatedMemoryHandle pbInput, uint cbInput, uint dwFlags = 0); + + /// + /// The BCryptImportKey function imports a symmetric key from a key BLOB. The BCryptImportKeyPair function is used to import a + /// public/private key pair. + /// + /// + /// The handle of the algorithm provider to import the key. This handle is obtained by calling the BCryptOpenAlgorithmProvider function. + /// + /// + /// The handle of the key encryption key needed to unwrap the key BLOB in the pbInput parameter. + /// Windows Server 2008 and Windows Vista: This parameter is not used and should be set to NULL. + /// + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the type of BLOB that is contained in the pbInput + /// buffer. This can be one of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_AES_WRAP_KEY_BLOB + /// + /// Import a symmetric key from an AES key–wrapped key BLOB. The hImportKey parameter must reference a valid BCRYPT_KEY_HANDLE + /// pointer to the key encryption key. Windows Server 2008 and Windows Vista: This BLOB type is not supported. + /// + /// + /// + /// BCRYPT_KEY_DATA_BLOB + /// + /// Import a symmetric key from a data BLOB. The pbInput parameter is a pointer to a BCRYPT_KEY_DATA_BLOB_HEADER structure + /// immediately followed by the key BLOB. + /// + /// + /// + /// BCRYPT_OPAQUE_KEY_BLOB + /// + /// Import a symmetric key BLOB in a format that is specific to a single CSP. Opaque BLOBs are not transferable and must be imported + /// by using the same CSP that generated the BLOB. Opaque BLOBs are only intended to be used for interprocess transfer of keys and + /// are not suitable to be persisted and read in across versions of a provider. + /// + /// + /// + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE that receives the handle of the imported key. This handle is used in subsequent functions + /// that require a key, such as BCryptEncrypt. This handle must be released when it is no longer needed by passing it to the + /// BCryptDestroyKey function. + /// + /// + /// + /// A pointer to a buffer that receives the imported key object. The cbKeyObject parameter contains the size of this buffer. The + /// required size of this buffer can be obtained by calling the BCryptGetProperty function to get the BCRYPT_OBJECT_LENGTH + /// property. This will provide the size of the key object for the specified algorithm. + /// + /// This memory can only be freed after the phKey key handle is destroyed. + /// + /// The size, in bytes, of the pbKeyObject buffer. + /// + /// The address of a buffer that contains the key BLOB to import. The cbInput parameter contains the size of this buffer. The + /// pszBlobType parameter specifies the type of key BLOB this buffer contains. + /// + /// The size, in bytes, of the pbInput buffer. + /// + /// A set of flags that modify the behavior of this function. No flags are currently defined, so this parameter should be zero. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size of the key object specified by the cbKeyObject parameter is not large enough to hold the key object. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// + /// The algorithm provider specified by the hAlgorithm parameter does not support the BLOB type specified by the pszBlobType parameter. + /// + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptImportKey can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptImportKey function must refer to nonpaged (or + /// locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptimportkey NTSTATUS BCryptImportKey( BCRYPT_ALG_HANDLE + // hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, LPCWSTR pszBlobType, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbKeyObject, ULONG cbKeyObject, + // PUCHAR pbInput, ULONG cbInput, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "6b9683f4-10f2-40e4-9757-a1f01991bef7")] + public static extern NTStatus BCryptImportKey(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbKeyObject, [Optional] uint cbKeyObject, IntPtr pbInput, uint cbInput, uint dwFlags = 0); + + /// + /// The BCryptImportKeyPair function imports a public/private key pair from a key BLOB. The BCryptImportKey function is used + /// to import a symmetric key pair. + /// + /// + /// The handle of the algorithm provider to import the key. This handle is obtained by calling the BCryptOpenAlgorithmProvider function. + /// + /// This parameter is not currently used and should be NULL. + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the type of BLOB that is contained in the pbInput + /// buffer. This can be one of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_DH_PRIVATE_BLOB + /// + /// The BLOB is a Diffie-Hellman public/private key pair BLOB. The pbInput buffer must contain a BCRYPT_DH_KEY_BLOB structure + /// immediately followed by the key data. + /// + /// + /// + /// BCRYPT_DH_PUBLIC_BLOB + /// + /// The BLOB is a Diffie-Hellman public key BLOB. The pbInput buffer must contain a BCRYPT_DH_KEY_BLOB structure immediately followed + /// by the key data. + /// + /// + /// + /// BCRYPT_DSA_PRIVATE_BLOB + /// + /// The BLOB is a DSA public/private key pair BLOB. The pbInput buffer must contain a BCRYPT_DSA_KEY_BLOB or BCRYPT_DSA_KEY_BLOB_V2 + /// structure immediately followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 to 1024 bits. + /// BCRYPT_DSA_KEY_BLOB_V2 is used for key lengths that exceed 1024 bits but are less than or equal to 3072 bits. Windows 8: Support + /// for BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + /// + /// + /// BCRYPT_DSA_PUBLIC_BLOB + /// + /// The BLOB is a DSA public key BLOB. The pbInput buffer must contain a BCRYPT_DSA_KEY_BLOB or BCRYPT_DSA_KEY_BLOB_V2 structure + /// immediately followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 to 1024 bits. BCRYPT_DSA_KEY_BLOB_V2 + /// is used for key lengths that exceed 1024 bits but are less than or equal to 3072 bits. Windows 8: Support for + /// BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + /// + /// + /// BCRYPT_ECCPRIVATE_BLOB + /// + /// The BLOB is an elliptic curve cryptography (ECC) private key. The pbInput buffer must contain a BCRYPT_ECCKEY_BLOB structure + /// immediately followed by the key data. + /// + /// + /// + /// BCRYPT_ECCPUBLIC_BLOB + /// + /// The BLOB is an ECC public key. The pbInput buffer must contain a BCRYPT_ECCKEY_BLOB structure immediately followed by the key data. + /// + /// + /// + /// BCRYPT_PUBLIC_KEY_BLOB + /// + /// The BLOB is a generic public key of any type. The type of key in this BLOB is determined by the Magic member of the + /// BCRYPT_KEY_BLOB structure. + /// + /// + /// + /// BCRYPT_PRIVATE_KEY_BLOB + /// + /// The BLOB is a generic private key of any type. The private key does not necessarily contain the public key. The type of key in + /// this BLOB is determined by the Magic member of the BCRYPT_KEY_BLOB structure. + /// + /// + /// + /// BCRYPT_RSAPRIVATE_BLOB + /// + /// The BLOB is an RSA public/private key pair BLOB. The pbInput buffer must contain a BCRYPT_RSAKEY_BLOB structure immediately + /// followed by the key data. + /// + /// + /// + /// BCRYPT_RSAPUBLIC_BLOB + /// + /// The BLOB is an RSA public key BLOB. The pbInput buffer must contain a BCRYPT_RSAKEY_BLOB structure immediately followed by the + /// key data. + /// + /// + /// + /// LEGACY_DH_PUBLIC_BLOB + /// + /// The BLOB is a Diffie-Hellman public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not + /// support importing this BLOB type. + /// + /// + /// + /// LEGACY_DH_PRIVATE_BLOB + /// + /// The BLOB is a legacy Diffie-Hellman Version 3 Private Key BLOB that contains a Diffie-Hellman public/private key pair that was + /// exported by using CryptoAPI. + /// + /// + /// + /// LEGACY_DSA_PRIVATE_BLOB + /// The BLOB is a DSA public/private key pair BLOB that was exported by using CryptoAPI. + /// + /// + /// LEGACY_DSA_PUBLIC_BLOB + /// + /// The BLOB is a DSA public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not support + /// importing this BLOB type. + /// + /// + /// + /// LEGACY_DSA_V2_PRIVATE_BLOB + /// The BLOB is a DSA version 2 private key in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_RSAPRIVATE_BLOB + /// The BLOB is an RSA public/private key pair BLOB that was exported by using CryptoAPI. + /// + /// + /// LEGACY_RSAPUBLIC_BLOB + /// + /// The BLOB is an RSA public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not support + /// importing this BLOB type. + /// + /// + /// + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE that receives the handle of the imported key. This handle is used in subsequent functions + /// that require a key, such as BCryptSignHash. This handle must be released when it is no longer needed by passing it to the + /// BCryptDestroyKey function. + /// + /// + /// The address of a buffer that contains the key BLOB to import. The cbInput parameter contains the size of this buffer. The + /// pszBlobType parameter specifies the type of key BLOB this buffer contains. + /// + /// The size, in bytes, of the pbInput buffer. + /// + /// A set of flags that modify the behavior of this function. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_NO_KEY_VALIDATION + /// Do not validate the public portion of the key pair. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// + /// The algorithm provider specified by the hAlgorithm parameter does not support the BLOB type specified by the pszBlobType parameter. + /// + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptImportKeyPair can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptImportKeyPair function must refer to nonpaged (or + /// locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptimportkeypair NTSTATUS BCryptImportKeyPair( + // BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, LPCWSTR pszBlobType, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbInput, ULONG + // cbInput, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "271fc084-6121-4666-b521-b849c7d7966c")] + public static extern NTStatus BCryptImportKeyPair(BCRYPT_ALG_HANDLE hAlgorithm, [Optional] BCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, out SafeBCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbInput, [Optional] uint cbInput, ImportFlags dwFlags = 0); + + /// + /// The BCryptImportKeyPair function imports a public/private key pair from a key BLOB. The BCryptImportKey function is used + /// to import a symmetric key pair. + /// + /// + /// The handle of the algorithm provider to import the key. This handle is obtained by calling the BCryptOpenAlgorithmProvider function. + /// + /// This parameter is not currently used and should be NULL. + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the type of BLOB that is contained in the pbInput + /// buffer. This can be one of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_DH_PRIVATE_BLOB + /// + /// The BLOB is a Diffie-Hellman public/private key pair BLOB. The pbInput buffer must contain a BCRYPT_DH_KEY_BLOB structure + /// immediately followed by the key data. + /// + /// + /// + /// BCRYPT_DH_PUBLIC_BLOB + /// + /// The BLOB is a Diffie-Hellman public key BLOB. The pbInput buffer must contain a BCRYPT_DH_KEY_BLOB structure immediately followed + /// by the key data. + /// + /// + /// + /// BCRYPT_DSA_PRIVATE_BLOB + /// + /// The BLOB is a DSA public/private key pair BLOB. The pbInput buffer must contain a BCRYPT_DSA_KEY_BLOB or BCRYPT_DSA_KEY_BLOB_V2 + /// structure immediately followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 to 1024 bits. + /// BCRYPT_DSA_KEY_BLOB_V2 is used for key lengths that exceed 1024 bits but are less than or equal to 3072 bits. Windows 8: Support + /// for BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + /// + /// + /// BCRYPT_DSA_PUBLIC_BLOB + /// + /// The BLOB is a DSA public key BLOB. The pbInput buffer must contain a BCRYPT_DSA_KEY_BLOB or BCRYPT_DSA_KEY_BLOB_V2 structure + /// immediately followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 to 1024 bits. BCRYPT_DSA_KEY_BLOB_V2 + /// is used for key lengths that exceed 1024 bits but are less than or equal to 3072 bits. Windows 8: Support for + /// BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + /// + /// + /// BCRYPT_ECCPRIVATE_BLOB + /// + /// The BLOB is an elliptic curve cryptography (ECC) private key. The pbInput buffer must contain a BCRYPT_ECCKEY_BLOB structure + /// immediately followed by the key data. + /// + /// + /// + /// BCRYPT_ECCPUBLIC_BLOB + /// + /// The BLOB is an ECC public key. The pbInput buffer must contain a BCRYPT_ECCKEY_BLOB structure immediately followed by the key data. + /// + /// + /// + /// BCRYPT_PUBLIC_KEY_BLOB + /// + /// The BLOB is a generic public key of any type. The type of key in this BLOB is determined by the Magic member of the + /// BCRYPT_KEY_BLOB structure. + /// + /// + /// + /// BCRYPT_PRIVATE_KEY_BLOB + /// + /// The BLOB is a generic private key of any type. The private key does not necessarily contain the public key. The type of key in + /// this BLOB is determined by the Magic member of the BCRYPT_KEY_BLOB structure. + /// + /// + /// + /// BCRYPT_RSAPRIVATE_BLOB + /// + /// The BLOB is an RSA public/private key pair BLOB. The pbInput buffer must contain a BCRYPT_RSAKEY_BLOB structure immediately + /// followed by the key data. + /// + /// + /// + /// BCRYPT_RSAPUBLIC_BLOB + /// + /// The BLOB is an RSA public key BLOB. The pbInput buffer must contain a BCRYPT_RSAKEY_BLOB structure immediately followed by the + /// key data. + /// + /// + /// + /// LEGACY_DH_PUBLIC_BLOB + /// + /// The BLOB is a Diffie-Hellman public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not + /// support importing this BLOB type. + /// + /// + /// + /// LEGACY_DH_PRIVATE_BLOB + /// + /// The BLOB is a legacy Diffie-Hellman Version 3 Private Key BLOB that contains a Diffie-Hellman public/private key pair that was + /// exported by using CryptoAPI. + /// + /// + /// + /// LEGACY_DSA_PRIVATE_BLOB + /// The BLOB is a DSA public/private key pair BLOB that was exported by using CryptoAPI. + /// + /// + /// LEGACY_DSA_PUBLIC_BLOB + /// + /// The BLOB is a DSA public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not support + /// importing this BLOB type. + /// + /// + /// + /// LEGACY_DSA_V2_PRIVATE_BLOB + /// The BLOB is a DSA version 2 private key in a form that can be imported by using CryptoAPI. + /// + /// + /// LEGACY_RSAPRIVATE_BLOB + /// The BLOB is an RSA public/private key pair BLOB that was exported by using CryptoAPI. + /// + /// + /// LEGACY_RSAPUBLIC_BLOB + /// + /// The BLOB is an RSA public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not support + /// importing this BLOB type. + /// + /// + /// + /// + /// + /// A pointer to a BCRYPT_KEY_HANDLE that receives the handle of the imported key. This handle is used in subsequent functions + /// that require a key, such as BCryptSignHash. This handle must be released when it is no longer needed by passing it to the + /// BCryptDestroyKey function. + /// + /// + /// The address of a buffer that contains the key BLOB to import. The cbInput parameter contains the size of this buffer. The + /// pszBlobType parameter specifies the type of key BLOB this buffer contains. + /// + /// The size, in bytes, of the pbInput buffer. + /// + /// A set of flags that modify the behavior of this function. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_NO_KEY_VALIDATION + /// Do not validate the public portion of the key pair. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The algorithm handle in the hAlgorithm parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// + /// The algorithm provider specified by the hAlgorithm parameter does not support the BLOB type specified by the pszBlobType parameter. + /// + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptImportKeyPair can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hAlgorithm parameter must have been opened by using the + /// BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptImportKeyPair function must refer to nonpaged (or + /// locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptimportkeypair NTSTATUS BCryptImportKeyPair( + // BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, LPCWSTR pszBlobType, BCRYPT_KEY_HANDLE *phKey, PUCHAR pbInput, ULONG + // cbInput, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "271fc084-6121-4666-b521-b849c7d7966c")] + public static extern NTStatus BCryptImportKeyPair(BCRYPT_ALG_HANDLE hAlgorithm, [Optional] BCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, out SafeBCRYPT_KEY_HANDLE phKey, SafeAllocatedMemoryHandle pbInput, uint cbInput, ImportFlags dwFlags = 0); + + /// + /// + /// The BCryptKeyDerivation function derives a key without requiring a secret agreement. It is similar in functionality to + /// BCryptDeriveKey but does not require a BCRYPT_SECRET_HANDLE value as input. + /// + /// + /// + /// Handle of the input key. + /// + /// + /// + /// Pointer to a BCryptBufferDesc structure that contains the KDF parameters. This parameter is optional and can be + /// NULL if it is not needed. The parameters can be specific to a key derivation function (KDF) or generic. The following + /// table shows the required and optional parameters for specific KDFs implemented by the Microsoft Primitive provider. + /// + /// + /// + /// KDF + /// Parameter + /// Required + /// + /// + /// SP800-108 HMAC in counter mode + /// KDF_LABEL + /// yes + /// + /// + /// + /// KDF_CONTEXT + /// yes + /// + /// + /// + /// KDF_HASH_ALGORITHM + /// yes + /// + /// + /// SP800-56A + /// KDF_ALGORITHMID + /// yes + /// + /// + /// + /// KDF_PARTYUINFO + /// yes + /// + /// + /// + /// KDF_PARTYVINFO + /// yes + /// + /// + /// + /// KDF_HASH_ALGORITHM + /// yes + /// + /// + /// + /// KDF_SUPPPUBINFO + /// no + /// + /// + /// + /// KDF_SUPPPRIVINFO + /// no + /// + /// + /// PBKDF2 + /// KDF_HASH_ALGORITHM + /// yes + /// + /// + /// + /// KDF_SALT + /// yes + /// + /// + /// + /// KDF_ITERATION_COUNT + /// no + /// + /// + /// CAPI_KDF + /// KDF_HASH_ALGORITHM + /// yes + /// + /// + /// The following generic parameter can be used: + /// + /// + /// KDF_GENERIC_PARAMETER + /// + /// + /// Generic parameters map to KDF specific parameters in the following manner: + /// SP800-108 HMAC in counter mode: + /// + /// + /// KDF_GENERIC_PARAMETER = KDF_LABEL||0x00||KDF_CONTEXT + /// + /// + /// SP800-56A + /// + /// + /// + /// KDF_GENERIC_PARAMETER = KDF_ALGORITHMID || KDF_PARTYUINFO || KDF_PARTYVINFO {|| KDF_SUPPPUBINFO } {|| KDF_SUPPPRIVINFO } + /// + /// + /// + /// PBKDF2 + /// + /// + /// KDF_GENERIC_PARAMETER = KDF_SALT + /// + /// + /// KDF_ITERATION_COUNT – defaults to 10000 + /// + /// + /// CAPI_KDF + /// + /// + /// KDF_GENERIC_PARAMETER = Not Used + /// + /// + /// + /// + /// Address of a buffer that receives the key. The cbDerivedKey parameter contains the size of this buffer. + /// + /// + /// Size, in bytes, of the buffer pointed to by the pbDerivedKey parameter. + /// + /// + /// + /// Pointer to a variable that receives the number of bytes that were copied to the buffer pointed to by the pbDerivedKey parameter. + /// + /// + /// + /// Flags that modify the behavior of this function. The following value can be used with the Microsoft Primitive provider. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_CAPI_AES_FLAG + /// + /// Specifies that the target algorithm is AES and that the key therefore must be double expanded. This flag is only valid with the + /// CAPI_KDF algorithm. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// You can use the following algorithm identifiers in the BCryptOpenAlgorithmProvider function before calling BCryptKeyDerivation: + /// + /// + /// BCRYPT_CAPI_KDF_ALGORITHM + /// + /// + /// BCRYPT_SP800108_CTR_HMAC_ALGORITHM + /// + /// + /// BCRYPT_SP80056A_CONCAT_ALGORITHM + /// + /// + /// BCRYPT_PBKDF2_ALGORITHM + /// + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptkeyderivation NTSTATUS BCryptKeyDerivation( + // BCRYPT_KEY_HANDLE hKey, BCryptBufferDesc *pParameterList, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "D0B91FFE-2E72-4AE3-A84F-DC598C02CF53")] + public static extern NTStatus BCryptKeyDerivation(BCRYPT_KEY_HANDLE hKey, [Optional] NCryptBufferDesc pParameterList, IntPtr pbDerivedKey, uint cbDerivedKey, out uint pcbResult, KeyDerivationFlags dwFlags); + + /// + /// + /// The BCryptKeyDerivation function derives a key without requiring a secret agreement. It is similar in functionality to + /// BCryptDeriveKey but does not require a BCRYPT_SECRET_HANDLE value as input. + /// + /// + /// + /// Handle of the input key. + /// + /// + /// + /// Pointer to a BCryptBufferDesc structure that contains the KDF parameters. This parameter is optional and can be + /// NULL if it is not needed. The parameters can be specific to a key derivation function (KDF) or generic. The following + /// table shows the required and optional parameters for specific KDFs implemented by the Microsoft Primitive provider. + /// + /// + /// + /// KDF + /// Parameter + /// Required + /// + /// + /// SP800-108 HMAC in counter mode + /// KDF_LABEL + /// yes + /// + /// + /// + /// KDF_CONTEXT + /// yes + /// + /// + /// + /// KDF_HASH_ALGORITHM + /// yes + /// + /// + /// SP800-56A + /// KDF_ALGORITHMID + /// yes + /// + /// + /// + /// KDF_PARTYUINFO + /// yes + /// + /// + /// + /// KDF_PARTYVINFO + /// yes + /// + /// + /// + /// KDF_HASH_ALGORITHM + /// yes + /// + /// + /// + /// KDF_SUPPPUBINFO + /// no + /// + /// + /// + /// KDF_SUPPPRIVINFO + /// no + /// + /// + /// PBKDF2 + /// KDF_HASH_ALGORITHM + /// yes + /// + /// + /// + /// KDF_SALT + /// yes + /// + /// + /// + /// KDF_ITERATION_COUNT + /// no + /// + /// + /// CAPI_KDF + /// KDF_HASH_ALGORITHM + /// yes + /// + /// + /// The following generic parameter can be used: + /// + /// + /// KDF_GENERIC_PARAMETER + /// + /// + /// Generic parameters map to KDF specific parameters in the following manner: + /// SP800-108 HMAC in counter mode: + /// + /// + /// KDF_GENERIC_PARAMETER = KDF_LABEL||0x00||KDF_CONTEXT + /// + /// + /// SP800-56A + /// + /// + /// + /// KDF_GENERIC_PARAMETER = KDF_ALGORITHMID || KDF_PARTYUINFO || KDF_PARTYVINFO {|| KDF_SUPPPUBINFO } {|| KDF_SUPPPRIVINFO } + /// + /// + /// + /// PBKDF2 + /// + /// + /// KDF_GENERIC_PARAMETER = KDF_SALT + /// + /// + /// KDF_ITERATION_COUNT – defaults to 10000 + /// + /// + /// CAPI_KDF + /// + /// + /// KDF_GENERIC_PARAMETER = Not Used + /// + /// + /// + /// + /// Address of a buffer that receives the key. The cbDerivedKey parameter contains the size of this buffer. + /// + /// + /// Size, in bytes, of the buffer pointed to by the pbDerivedKey parameter. + /// + /// + /// + /// Pointer to a variable that receives the number of bytes that were copied to the buffer pointed to by the pbDerivedKey parameter. + /// + /// + /// + /// Flags that modify the behavior of this function. The following value can be used with the Microsoft Primitive provider. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_CAPI_AES_FLAG + /// + /// Specifies that the target algorithm is AES and that the key therefore must be double expanded. This flag is only valid with the + /// CAPI_KDF algorithm. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// You can use the following algorithm identifiers in the BCryptOpenAlgorithmProvider function before calling BCryptKeyDerivation: + /// + /// + /// BCRYPT_CAPI_KDF_ALGORITHM + /// + /// + /// BCRYPT_SP800108_CTR_HMAC_ALGORITHM + /// + /// + /// BCRYPT_SP80056A_CONCAT_ALGORITHM + /// + /// + /// BCRYPT_PBKDF2_ALGORITHM + /// + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptkeyderivation NTSTATUS BCryptKeyDerivation( + // BCRYPT_KEY_HANDLE hKey, BCryptBufferDesc *pParameterList, PUCHAR pbDerivedKey, ULONG cbDerivedKey, ULONG *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "D0B91FFE-2E72-4AE3-A84F-DC598C02CF53")] + public static extern NTStatus BCryptKeyDerivation(BCRYPT_KEY_HANDLE hKey, [Optional] NCryptBufferDesc pParameterList, SafeAllocatedMemoryHandle pbDerivedKey, uint cbDerivedKey, out uint pcbResult, KeyDerivationFlags dwFlags); + + /// + /// The BCryptOpenAlgorithmProvider function loads and initializes a CNG provider. + /// + /// + /// + /// A pointer to a BCRYPT_ALG_HANDLE variable that receives the CNG provider handle. When you have finished using this handle, + /// release it by passing it to the BCryptCloseAlgorithmProvider function. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that identifies the requested cryptographic algorithm. This can be one of the + /// standard CNG Algorithm Identifiers or the identifier for another registered algorithm. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that identifies the specific provider to load. This is the registered alias of the + /// cryptographic primitive provider. This parameter is optional and can be NULL if it is not needed. If this parameter is + /// NULL, the default provider for the specified algorithm will be loaded. + /// + /// + /// Note If the pszImplementation parameter value is NULL, CNG attempts to open each registered provider, in order of + /// priority, for the algorithm specified by the pszAlgId parameter and returns the handle of the first provider that is successfully + /// opened. For the lifetime of the handle, any BCrypt*** cryptographic APIs will use the provider that was successfully opened. + /// + /// Windows Server 2008 and Windows Vista: + /// CNG attempts to fall back to the Microsoft CNG provider. + /// The following are the predefined provider names. + /// + /// + /// Value + /// Meaning + /// + /// + /// MS_PRIMITIVE_PROVIDER "Microsoft Primitive Provider" + /// Identifies the basic Microsoft CNG provider. + /// + /// + /// + /// + /// Flags that modify the behavior of the function. This can be zero or a combination of one or more of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ALG_HANDLE_HMAC_FLAG + /// + /// The provider will perform the Hash-Based Message Authentication Code (HMAC) algorithm with the specified hash algorithm. This + /// flag is only used by hash algorithm providers. + /// + /// + /// + /// BCRYPT_PROV_DISPATCH + /// + /// Loads the provider into the nonpaged memory pool. If this flag is not present, the provider is loaded into the paged memory pool. + /// When this flag is specified, the handle returned must not be closed before all dependent objects have been freed. Windows Server + /// 2008 and Windows Vista: This flag is only supported by the Microsoft algorithm providers and only for hashing algorithms and + /// symmetric key cryptographic algorithms. + /// + /// + /// + /// BCRYPT_HASH_REUSABLE_FLAG + /// + /// Creates a reusable hashing object. The object can be used for a new hashing operation immediately after calling BCryptFinishHash. + /// For more information, see Creating a Hash with CNG. Windows Server 2008 R2, Windows 7, Windows Server 2008 and Windows Vista: + /// This flag is not supported. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_NOT_FOUND + /// No provider was found for the specified algorithm ID. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// + /// Because of the number and type of operations that are required to find, load, and initialize an algorithm provider, the + /// BCryptOpenAlgorithmProvider function is a relatively time intensive function. Because of this, we recommend that you cache + /// any algorithm provider handles that you will use more than once, rather than opening and closing the algorithm providers over and over. + /// + /// + /// BCryptOpenAlgorithmProvider can be called either from user mode or kernel mode. Kernel mode callers must be executing at + /// PASSIVE_LEVEL IRQL. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + /// Starting in Windows 10, CNG no longer follows every update to the cryptography configuration. Certain changes, like adding a new + /// default provider or changing the preference order of algorithm providers, may require a reboot. Because of this, you should + /// reboot before calling BCryptOpenAlgorithmProvider with any newly configured provider. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptopenalgorithmprovider NTSTATUS + // BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *phAlgorithm, LPCWSTR pszAlgId, LPCWSTR pszImplementation, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "aceba9c0-19e6-4f3c-972a-752feed4a9f8")] + public static extern NTStatus BCryptOpenAlgorithmProvider(out SafeBCRYPT_ALG_HANDLE phAlgorithm, string pszAlgId, [Optional] string pszImplementation, AlgProviderFlags dwFlags = 0); + + /// + /// The BCryptProcessMultiOperations function processes a sequence of operations on a multi-object state. + /// + /// + /// A handle to a multi-object state, such as one created by the BCryptCreateMultiHash function. + /// + /// + /// + /// A BCRYPT_OPERATION_TYPE_* value. Currently the only defined value is BCRYPT_OPERATION_TYPE_HASH. This value + /// identifies the hObject parameter as a multi-hash object and the pOperations pointer as pointing to an array of + /// BCRYPT_MULTI_HASH_OPERATION elements. + /// + /// + /// + /// + /// A pointer to an array of operation command structures. For hashing, it is a pointer to an array of BCRYPT_MULTI_HASH_OPERATION structures. + /// + /// + /// + /// The size, in bytes, of the pOperations array. + /// + /// + /// Specify a value of zero (0). + /// + /// + /// None + /// + /// + /// + /// Each element of the pOperations array contains instructions for a particular computation to be performed on a single element of + /// the multi-object state. The functional behavior of BCryptProcessMultiOperations is equivalent to performing, for each + /// element in the multi-object state, the computations specified in the operations array for that element, one at a time, in order. + /// + /// + /// The relative order of two operations that operate on different elements of the array is not guaranteed. If an output buffer + /// overlaps an input or output buffer the result is not deterministic. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptprocessmultioperations NTSTATUS + // BCryptProcessMultiOperations( BCRYPT_HANDLE hObject, BCRYPT_MULTI_OPERATION_TYPE operationType, PVOID pOperations, ULONG + // cbOperations, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "5FD28AC3-46D2-4F06-BF06-F5FEF8E531F5")] + public static extern NTStatus BCryptProcessMultiOperations(BCRYPT_HANDLE hObject, BCRYPT_MULTI_OPERATION_TYPE operationType, IntPtr pOperations, uint cbOperations, uint dwFlags = 0); + + /// + /// The BCryptProcessMultiOperations function processes a sequence of operations on a multi-object state. + /// + /// + /// A handle to a multi-object state, such as one created by the BCryptCreateMultiHash function. + /// + /// + /// + /// A BCRYPT_OPERATION_TYPE_* value. Currently the only defined value is BCRYPT_OPERATION_TYPE_HASH. This value + /// identifies the hObject parameter as a multi-hash object and the pOperations pointer as pointing to an array of + /// BCRYPT_MULTI_HASH_OPERATION elements. + /// + /// + /// + /// + /// A pointer to an array of operation command structures. For hashing, it is a pointer to an array of BCRYPT_MULTI_HASH_OPERATION structures. + /// + /// + /// + /// The size, in bytes, of the pOperations array. + /// + /// + /// Specify a value of zero (0). + /// + /// + /// None + /// + /// + /// + /// Each element of the pOperations array contains instructions for a particular computation to be performed on a single element of + /// the multi-object state. The functional behavior of BCryptProcessMultiOperations is equivalent to performing, for each + /// element in the multi-object state, the computations specified in the operations array for that element, one at a time, in order. + /// + /// + /// The relative order of two operations that operate on different elements of the array is not guaranteed. If an output buffer + /// overlaps an input or output buffer the result is not deterministic. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptprocessmultioperations NTSTATUS + // BCryptProcessMultiOperations( BCRYPT_HANDLE hObject, BCRYPT_MULTI_OPERATION_TYPE operationType, PVOID pOperations, ULONG + // cbOperations, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "5FD28AC3-46D2-4F06-BF06-F5FEF8E531F5")] + public static extern NTStatus BCryptProcessMultiOperations(BCRYPT_HANDLE hObject, BCRYPT_MULTI_OPERATION_TYPE operationType, [In] BCRYPT_MULTI_HASH_OPERATION[] pOperations, uint cbOperations, uint dwFlags = 0); + + /// + /// + /// [ BCryptQueryContextConfiguration is available for use in the operating systems specified in the Requirements section. It + /// may be altered or unavailable in subsequent versions.] + /// + /// The BCryptQueryContextConfiguration function retrieves the current configuration for the specified CNG context. + /// + /// + /// Identifies the configuration table that the context exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// The context exists in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to obtain the configuration information for. + /// + /// + /// + /// + /// The address of a ULONG variable that, on entry, contains the size, in bytes, of the buffer pointed to by ppBuffer. If this + /// size is not large enough to hold the context information, this function will fail with STATUS_BUFFER_TOO_SMALL. + /// + /// After this function returns, this variable contains the number of bytes that were copied to the ppBuffer buffer. + /// + /// + /// + /// The address of a pointer to a CRYPT_CONTEXT_CONFIG structure that receives the context configuration information retrieved by + /// this function. The value pointed to by the pcbBuffer parameter contains the size of this buffer. + /// + /// + /// If the value pointed to by this parameter is NULL, this function will allocate the required memory. This memory must be + /// freed when it is no longer needed by passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// If this parameter is NULL, this function will place the required size, in bytes, in the variable pointed to by the + /// pcbBuffer parameter and return STATUS_BUFFER_TOO_SMALL. + /// + /// For more information on the usage of this parameter, see Remarks. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// + /// The ppBuffer parameter is not NULL, and the value pointed to by the pcbBuffer parameter is not large enough to hold the set of contexts. + /// + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_NOT_FOUND + /// The specified context could not be found. + /// + /// + /// + /// + /// + /// Each context has only one set of configuration information, so although the ppBuffer parameter appears to be a used as an array, + /// this function treats this as an array with only one element. The following example helps clarify how this parameter is used. + /// + /// BCryptQueryContextConfiguration can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptquerycontextconfiguration NTSTATUS + // BCryptQueryContextConfiguration( ULONG dwTable, LPCWSTR pszContext, ULONG *pcbBuffer, PCRYPT_CONTEXT_CONFIG *ppBuffer ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "3e2ae471-cad6-4bfe-9e30-7b2a7014bc08")] + public static extern NTStatus BCryptQueryContextConfiguration(ContextConfigTable dwTable, [MarshalAs(UnmanagedType.LPWStr)] string pszContext, out uint pcbBuffer, out SafeBCryptBuffer ppBuffer); + + /// + /// + /// [ BCryptQueryContextFunctionConfiguration is available for use in the operating systems specified in the Requirements + /// section. It may be altered or unavailable in subsequent versions.] + /// + /// + /// The BCryptQueryContextFunctionConfiguration function obtains the cryptographic function configuration information for an + /// existing CNG context. + /// + /// + /// + /// Identifies the configuration table that the context exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// The context exists in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to obtain the function configuration + /// information for. + /// + /// + /// + /// + /// Identifies the cryptographic interface to obtain the function configuration information for. This can be one of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// Obtain the function configuration information from the list of asymmetric encryption functions. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// Obtain the function configuration information from the list of cipher functions. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// Obtain the function configuration information from the list of hash functions. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// Obtain the function configuration information from the list of random number generator functions. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// Obtain the function configuration information from the list of secret agreement functions. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// Obtain the function configuration information from the list of signature functions. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// Obtain the function configuration information from the list of key storage functions. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// Obtain the function configuration information from the list of Schannel functions. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the cryptographic function to obtain the + /// configuration information for. + /// + /// + /// + /// + /// The address of a ULONG variable that, on entry, contains the size, in bytes, of the buffer pointed to by ppBuffer. If this + /// size is not large enough to hold the context information, this function will fail with STATUS_BUFFER_TOO_SMALL. + /// + /// After this function returns, this variable contains the number of bytes that were copied to the ppBuffer buffer. + /// + /// + /// + /// The address of a pointer to a CRYPT_CONTEXT_FUNCTION_CONFIG structure that receives the function configuration information + /// retrieved by this function. The value pointed to by the pcbBuffer parameter contains the size of this buffer. + /// + /// + /// If the value pointed to by this parameter is NULL, this function will allocate the required memory. This memory must be + /// freed when it is no longer needed by passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// If this parameter is NULL, this function will place the required size, in bytes, in the variable pointed to by the + /// pcbBuffer parameter and return STATUS_BUFFER_TOO_SMALL. + /// + /// For more information about the usage of this parameter, see Remarks. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// + /// The ppBuffer parameter is not NULL, and the value pointed to by the pcbBuffer parameter is not large enough to hold the set of contexts. + /// + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_NOT_FOUND + /// The specified context or function could not be found. + /// + /// + /// + /// + /// + /// Each cryptographic function has only one set of configuration information, so although the ppBuffer parameter appears to be a + /// used as an array, this function treats this as an array with only one element. The following example helps clarify how this + /// parameter is used. + /// + /// BCryptQueryContextFunctionConfiguration can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptquerycontextfunctionconfiguration NTSTATUS + // BCryptQueryContextFunctionConfiguration( ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, ULONG + // *pcbBuffer, PCRYPT_CONTEXT_FUNCTION_CONFIG *ppBuffer ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "4eea9efe-bf45-4926-86fc-9b12b6d292cd")] + public static extern NTStatus BCryptQueryContextFunctionConfiguration(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction, out uint pcbBuffer, out SafeBCryptBuffer ppBuffer); + + /// + /// + /// The BCryptQueryContextFunctionProperty function obtains the value of a named property for a cryptographic function in an + /// existing CNG context. + /// + /// + /// + /// Identifies the configuration table that the context exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// The context exists in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to obtain the function property from. + /// + /// + /// + /// Identifies the cryptographic interface that the function exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// The function exists in the list of asymmetric encryption functions. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// The function exists in the list of cipher functions. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// The function exists in the list of hash functions. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// The function exists in the list of random number generator functions. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// The function exists in the list of secret agreement functions. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// The function exists in the list of signature functions. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// The function exists in the list of key storage functions. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// The function exists in the list of Schannel functions. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the cryptographic function to obtain the property for. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the property to obtain. + /// + /// + /// + /// The address of a ULONG variable that, on entry, contains the size, in bytes, of the buffer pointed to by ppbValue. If this + /// size is not large enough to hold the property value, this function will fail with STATUS_BUFFER_TOO_SMALL. + /// + /// After this function returns, this variable contains the number of bytes that were copied to the ppbValue buffer. + /// + /// + /// + /// The address of a pointer to a buffer that receives the property data. The size and format of this buffer depends on the format of + /// the property being retrieved. The value pointed to by the pcbValue parameter contains the size of this buffer. + /// + /// + /// If the value pointed to by this parameter is NULL, this function will allocate the required memory. This memory must be + /// freed when it is no longer needed by passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// If this parameter is NULL, this function will place the required size, in bytes, in the variable pointed to by the + /// pcbValue parameter and return STATUS_BUFFER_TOO_SMALL. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// + /// The ppbValue parameter is not NULL, and the value pointed to by the pcbValue parameter is not large enough to hold the set of contexts. + /// + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_NOT_FOUND + /// The specified context, function, or property could not be found. + /// + /// + /// + /// + /// BCryptQueryContextFunctionProperty can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptquerycontextfunctionproperty NTSTATUS + // BCryptQueryContextFunctionProperty( ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, LPCWSTR + // pszProperty, ULONG *pcbValue, PUCHAR *ppbValue ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "c8814a13-ac28-4583-927f-c787e0a25faf")] + public static extern NTStatus BCryptQueryContextFunctionProperty(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction, string pszProperty, out uint pcbValue, out SafeBCryptBuffer ppbValue); + + /// The BCryptQueryProviderRegistration function retrieves information about a CNG provider. + /// + /// A pointer to a null-terminated Unicode string that contains the name of the provider to obtain information about. + /// + /// + /// Specifies the type of information to retrieve. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_ANY + /// Retrieve any information for the provider. + /// + /// + /// CRYPT_UM + /// Retrieve the user mode information for the provider. + /// + /// + /// CRYPT_KM + /// Retrieve the kernel mode information for the provider. + /// + /// + /// CRYPT_MM + /// Retrieve both the user mode and kernel mode information for the provider. + /// + /// + /// + /// + /// Specifies the interface to retrieve information for. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// Retrieve the asymmetric encryption interface. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// Retrieve the cipher interface. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// Retrieve the hash interface. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// Retrieve the key storage interface. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// Retrieve the random number generator interface. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// Retrieve the Schannel interface. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// Retrieve the secret agreement interface. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// Retrieve the signature interface. + /// + /// + /// + /// + /// + /// A pointer to a ULONG value that, on entry, contains the size, in bytes, of the buffer pointed to by the ppBuffer + /// parameter. On exit, this value receives either the number of bytes copied to the buffer or the required size, in bytes, of the buffer. + /// + /// + /// Note This is the total size, in bytes, of the entire buffer, not just the size of the CRYPT_PROVIDER_REG structure. The + /// buffer must be able to hold other data for the providers in addition to the CRYPT_PROVIDER_REG structure. + /// + /// + /// + /// A pointer to a buffer pointer that receives a CRYPT_PROVIDER_REG structure and other data that describes the provider. + /// + /// If this parameter is NULL, this function will return STATUS_BUFFER_TOO_SMALL and place in the value pointed to by + /// the pcbBuffer parameter, the required size, in bytes, of all data. + /// + /// + /// If this parameter is the address of a NULL pointer, this function will allocate the required memory, fill it in with the + /// provider information, and place a pointer to this memory in this parameter. When you have finished using this memory, free it by + /// passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// If this parameter is the address of a non- NULL pointer, this function will copy the provider information into this + /// buffer. The pcbBuffer parameter must contain the size, in bytes, of the entire buffer. If the buffer is not large enough to hold + /// all of the provider information, this function will return STATUS_BUFFER_TOO_SMALL. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the pcbBuffer parameter is not large enough to hold all of the data. + /// + /// + /// STATUS_NOT_FOUND + /// No provider could be found that matches the specified criteria. + /// + /// + /// + /// BCryptQueryProviderRegistration can be called only in user mode. + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptqueryproviderregistration NTSTATUS + // BCryptQueryProviderRegistration( LPCWSTR pszProvider, ULONG dwMode, ULONG dwInterface, ULONG *pcbBuffer, PCRYPT_PROVIDER_REG + // *ppBuffer ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "28b8bca9-442f-4d58-86aa-8aa274777ede")] + public static extern NTStatus BCryptQueryProviderRegistration([MarshalAs(UnmanagedType.LPWStr)] string pszProvider, ProviderInfoType dwMode, InterfaceId dwInterface, out uint pcbBuffer, out SafeBCryptBuffer ppBuffer); + + /// + /// [ BCryptRegisterConfigChangeNotify is deprecated beginning with Windows 10.] + /// The BCryptRegisterConfigChangeNotify(PRKEVENT) function creates a kernel mode CNG configuration change event handler. + /// + /// + /// + /// The address of a PRKEVENT variable that receives the pointer to the event dispatcher object. You use the kernel wait + /// functions, such as KeWaitForSingleObject, to determine when the event has been signaled. The event is signaled when the CNG + /// configuration has changed. + /// + /// This handle must be passed to the BCryptUnregisterConfigChangeNotify(PRKEVENT) function to remove the event notification. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// The phEvent parameter is not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + // NTSTATUS WINAPI BCryptRegisterConfigChangeNotify( _In_ PRKEVENT phEvent); https://msdn.microsoft.com/en-us/library/windows/desktop/bb394681(v=vs.85).aspx + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("Bcrypt.h", MSDNShortId = "bb394681")] + public static extern NTStatus BCryptRegisterConfigChangeNotify(IntPtr phEvent); + + /// + /// + /// [ BCryptRemoveContextFunction is available for use in the operating systems specified in the Requirements section. It may + /// be altered or unavailable in subsequent versions.] + /// + /// + /// The BCryptRemoveContextFunction function removes a cryptographic function from the list of functions that are supported by + /// an existing CNG context. + /// + /// + /// + /// Identifies the configuration table that the context exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// The context exists in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to remove the function from. + /// + /// + /// Identifies the cryptographic interface to remove the function from. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// Remove the function from the list of asymmetric encryption functions. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// Remove the function from the list of cipher functions. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// Remove the function from the list of hash functions. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// Remove the function from the list of random number generator functions. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// Remove the function from the list of secret agreement functions. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// Remove the function from the list of signature functions. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// Remove the function from the list of key storage functions. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// Remove the function from the list of Schannel functions. + /// + /// + /// NCRYPT_SCHANNEL_SIGNATURE_INTERFACE + /// + /// Remove the function from the list of signature suites that Schannel accepts for TLS 1.2. Windows Vista and Windows Server 2008: + /// This value is not supported. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the cryptographic function to remove. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_FOUND + /// The specified context or function could not be found. + /// + /// + /// + /// + /// BCryptRemoveContextFunction can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptremovecontextfunction NTSTATUS + // BCryptRemoveContextFunction( ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "b8b1df66-f66f-4efc-9c8e-fca32e0278c5")] + public static extern NTStatus BCryptRemoveContextFunction(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction); + + /// + /// The BCryptResolveProviders function obtains a collection of all of the providers that meet the specified criteria. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context for which to obtain the providers. If + /// this is set to NULL or to an empty string, the default context is assumed. + /// + /// + /// + /// + /// The identifier of an interface that the provider must support. This must be one of the CNG Interface Identifiers. If the + /// pszFunction parameter is not NULL or an empty string, you can set dwInterface to zero to force the function to infer the interface. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the algorithm or function identifier that the provider must support. + /// This can be one of the standard CNG Algorithm Identifiers or the identifier for another registered algorithm. If dwInterface is + /// set to a nonzero value, then pszFunction can be NULL to include all algorithms and functions. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the name of the provider to retrieve. If this parameter is + /// NULL, then all providers will be included. + /// + /// + /// This parameter allows you to specify a specific provider to retrieve in the event that more than one provider meets the other criteria. + /// + /// + /// + /// Specifies the type of provider to retrieve. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_UM + /// Retrieve user mode providers. + /// + /// + /// CRYPT_KM + /// Retrieve kernel mode providers. + /// + /// + /// CRYPT_MM + /// Retrieve both user mode and kernel mode providers. + /// + /// + /// + /// + /// A set of flags that modify the behavior of this function. + /// This can be a zero or a combination of one or more of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_ALL_FUNCTIONS 1 + /// + /// This function will retrieve all of the functions supported by each provider that meets the specified criteria. If this flag is + /// not specified, this function will only retrieve the first function of the provider or providers that meet the specified criteria. + /// + /// + /// + /// CRYPT_ALL_PROVIDERS 2 + /// + /// This function will retrieve all of the providers that meet the specified criteria. If this flag is not specified, this function + /// will only retrieve the first provider that is found that meets the specified criteria. + /// + /// + /// + /// + /// + /// + /// A pointer to a DWORD value that, on entry, contains the size, in bytes, of the buffer pointed to by the ppBuffer + /// parameter. On exit, this value receives either the number of bytes copied to the buffer or the required size, in bytes, of the buffer. + /// + /// + /// + /// The address of a CRYPT_PROVIDER_REFS pointer that receives the collection of providers that meet the specified criteria. + /// + /// If this parameter is NULL, this function will return STATUS_SUCCESS and place in the value pointed to by the + /// pcbBuffer parameter, the required size, in bytes, of all the data. + /// + /// + /// If this parameter is the address of a NULL pointer, this function will allocate the required memory, fill the memory with + /// the information about the providers, and place the pointer to this memory in this parameter. When you have finished using this + /// memory, free it by passing this pointer to the BCryptFreeBuffer function. + /// + /// + /// If this parameter is the address of a non- NULL pointer, this function will copy the provider information into this + /// buffer. The pcbBuffer parameter must contain the size, in bytes, of the entire buffer. If the buffer is not large enough to hold + /// all of the provider information, this function will return STATUS_BUFFER_TOO_SMALL. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The size specified by the pcbBuffer parameter is not large enough to hold all of the data. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_FOUND + /// No provider could be found that meets all of the specified criteria. + /// + /// + /// + /// + /// + /// BCryptResolveProviders can be called either from user mode or kernel mode. Kernel mode callers must be executing at + /// PASSIVE_LEVEL IRQL. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptresolveproviders NTSTATUS BCryptResolveProviders( + // LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, LPCWSTR pszProvider, ULONG dwMode, ULONG dwFlags, ULONG *pcbBuffer, + // PCRYPT_PROVIDER_REFS *ppBuffer ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "cf30f635-4918-4911-9db0-df90d26a2f1a")] + public static extern NTStatus BCryptResolveProviders([Optional] string pszContext, InterfaceId dwInterface, [Optional] string pszFunction, [Optional] string pszProvider, ProviderInfoType dwMode, + ResolveProviderFlags dwFlags, out uint pcbBuffer, out SafeBCryptBuffer ppBuffer); + + /// + /// The BCryptSecretAgreement function creates a secret agreement value from a private and a public key. + /// + /// + /// + /// The handle of the private key to use to create the secret agreement value. This key and the hPubKey key must come from the same + /// CNG cryptographic algorithm provider. + /// + /// + /// + /// + /// The handle of the public key to use to create the secret agreement value. This key and the hPrivKey key must come from the same + /// CNG cryptographic algorithm provider. + /// + /// + /// + /// + /// A pointer to a BCRYPT_SECRET_HANDLE that receives a handle that represents the secret agreement value. This handle must be + /// released by passing it to the BCryptDestroySecret function when it is no longer needed. + /// + /// + /// + /// A set of flags that modify the behavior of this function. No flags are defined for this function. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle in the hPrivKey or hPubKey parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The key handle in the hPrivKey parameter is not a Diffie-Hellman key. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptSecretAgreement can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handles provided in the hPrivKey and hPubKey parameters must be derived from an algorithm + /// handle returned by a provider that was opened by using the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the + /// BCryptSecretAgreement function must refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptsecretagreement NTSTATUS BCryptSecretAgreement( + // BCRYPT_KEY_HANDLE hPrivKey, BCRYPT_KEY_HANDLE hPubKey, BCRYPT_SECRET_HANDLE *phAgreedSecret, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "96863d81-3643-4962-8abf-db1cc2acde07")] + public static extern NTStatus BCryptSecretAgreement(BCRYPT_KEY_HANDLE hPrivKey, BCRYPT_KEY_HANDLE hPubKey, out SafeBCRYPT_SECRET_HANDLE phAgreedSecret, uint dwFlags = 0); + + /// + /// + /// The BCryptSetContextFunctionProperty function sets the value of a named property for a cryptographic function in an + /// existing CNG context. + /// + /// + /// + /// Identifies the configuration table that the context exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// The context exists in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to set the function property in. + /// + /// + /// + /// Identifies the cryptographic interface that the function exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// The function exists in the list of asymmetric encryption functions. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// The function exists in the list of cipher functions. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// The function exists in the list of hash functions. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// The function exists in the list of random number generator functions. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// The function exists in the list of secret agreement functions. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// The function exists in the list of signature functions. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// The function exists in the list of key storage functions. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// The function exists in the list of Schannel functions. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the cryptographic function to set the property for. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the property to set. + /// + /// + /// + /// Contains the size, in bytes, of the pbValue buffer. This is the exact number of bytes that will be stored. If the property value + /// is a string, you should add the size of one character to also store the terminating null character, if needed. + /// + /// + /// + /// The address of a buffer that contains the new property value. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_ACCESS_DENIED + /// The caller does not have write access to the properties for the function. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_NOT_FOUND + /// The specified context or function could not be found. + /// + /// + /// + /// + /// BCryptSetContextFunctionProperty can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptsetcontextfunctionproperty NTSTATUS + // BCryptSetContextFunctionProperty( ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, LPCWSTR pszProperty, + // ULONG cbValue, PUCHAR pbValue ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "1e02720b-5210-4127-ab9e-24532a764795")] + public static extern NTStatus BCryptSetContextFunctionProperty(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction, string pszProperty, uint cbValue, SafeAllocatedMemoryHandle pbValue); + + /// + /// + /// The BCryptSetContextFunctionProperty function sets the value of a named property for a cryptographic function in an + /// existing CNG context. + /// + /// + /// + /// Identifies the configuration table that the context exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_LOCAL + /// The context exists in the local-machine configuration table. + /// + /// + /// CRYPT_DOMAIN + /// This value is not available for use. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the context to set the function property in. + /// + /// + /// + /// Identifies the cryptographic interface that the function exists in. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE + /// The function exists in the list of asymmetric encryption functions. + /// + /// + /// BCRYPT_CIPHER_INTERFACE + /// The function exists in the list of cipher functions. + /// + /// + /// BCRYPT_HASH_INTERFACE + /// The function exists in the list of hash functions. + /// + /// + /// BCRYPT_RNG_INTERFACE + /// The function exists in the list of random number generator functions. + /// + /// + /// BCRYPT_SECRET_AGREEMENT_INTERFACE + /// The function exists in the list of secret agreement functions. + /// + /// + /// BCRYPT_SIGNATURE_INTERFACE + /// The function exists in the list of signature functions. + /// + /// + /// NCRYPT_KEY_STORAGE_INTERFACE + /// The function exists in the list of key storage functions. + /// + /// + /// NCRYPT_SCHANNEL_INTERFACE + /// The function exists in the list of Schannel functions. + /// + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the cryptographic function to set the property for. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the property to set. + /// + /// + /// + /// Contains the size, in bytes, of the pbValue buffer. This is the exact number of bytes that will be stored. If the property value + /// is a string, you should add the size of one character to also store the terminating null character, if needed. + /// + /// + /// + /// The address of a buffer that contains the new property value. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_ACCESS_DENIED + /// The caller does not have write access to the properties for the function. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_NOT_FOUND + /// The specified context or function could not be found. + /// + /// + /// + /// + /// BCryptSetContextFunctionProperty can be called only in user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptsetcontextfunctionproperty NTSTATUS + // BCryptSetContextFunctionProperty( ULONG dwTable, LPCWSTR pszContext, ULONG dwInterface, LPCWSTR pszFunction, LPCWSTR pszProperty, + // ULONG cbValue, PUCHAR pbValue ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("bcrypt.h", MSDNShortId = "1e02720b-5210-4127-ab9e-24532a764795")] + public static extern NTStatus BCryptSetContextFunctionProperty(ContextConfigTable dwTable, string pszContext, InterfaceId dwInterface, string pszFunction, string pszProperty, uint cbValue, byte[] pbValue); + + /// The BCryptSetProperty function sets the value of a named property for a CNG object. + /// A handle that represents the CNG object to set the property value for. + /// + /// A pointer to a null-terminated Unicode string that contains the name of the property to set. This can be one of the predefined + /// Cryptography Primitive Property Identifiers or a custom property identifier. + /// + /// + /// The address of a buffer that contains the new property value. The cbInput parameter contains the size of this buffer. + /// + /// The size, in bytes, of the pbInput buffer. + /// A set of flags that modify the behavior of this function. No flags are defined for this function. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hObject parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The named property specified by the pszProperty parameter is not supported or is read-only. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptSetProperty can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, any pointers passed to BCryptSetProperty must refer to nonpaged (or locked) memory. If the + /// object specified in the hObject parameter is a handle, it must have been opened by using the BCRYPT_PROV_DISPATCH flag. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptsetproperty NTSTATUS BCryptSetProperty( BCRYPT_HANDLE + // hObject, LPCWSTR pszProperty, PUCHAR pbInput, ULONG cbInput, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "687f3410-d28b-4ce2-a2a1-c564f757c668")] + public static extern NTStatus BCryptSetProperty(BCRYPT_HANDLE hObject, [MarshalAs(UnmanagedType.LPWStr)] string pszProperty, byte[] pbInput, uint cbInput, uint dwFlags = 0); + + /// The BCryptSetProperty function sets the value of a named property for a CNG object. + /// A handle that represents the CNG object to set the property value for. + /// + /// A pointer to a null-terminated Unicode string that contains the name of the property to set. This can be one of the predefined + /// Cryptography Primitive Property Identifiers or a custom property identifier. + /// + /// + /// The address of a buffer that contains the new property value. The cbInput parameter contains the size of this buffer. + /// + /// The size, in bytes, of the pbInput buffer. + /// A set of flags that modify the behavior of this function. No flags are defined for this function. + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The handle in the hObject parameter is not valid. + /// + /// + /// STATUS_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The named property specified by the pszProperty parameter is not supported or is read-only. + /// + /// + /// + /// + /// + /// Depending on what processor modes a provider supports, BCryptSetProperty can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, any pointers passed to BCryptSetProperty must refer to nonpaged (or locked) memory. If the + /// object specified in the hObject parameter is a handle, it must have been opened by using the BCRYPT_PROV_DISPATCH flag. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptsetproperty NTSTATUS BCryptSetProperty( BCRYPT_HANDLE + // hObject, LPCWSTR pszProperty, PUCHAR pbInput, ULONG cbInput, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "687f3410-d28b-4ce2-a2a1-c564f757c668")] + public static extern NTStatus BCryptSetProperty(BCRYPT_HANDLE hObject, [MarshalAs(UnmanagedType.LPWStr)] string pszProperty, IntPtr pbInput, uint cbInput, uint dwFlags = 0); + + /// + /// The BCryptSignHash function creates a signature of a hash value. + /// + /// + /// The handle of the key to use to sign the hash. + /// + /// + /// + /// A pointer to a structure that contains padding information. The actual type of structure this parameter points to depends on the + /// value of the dwFlags parameter. This parameter is only used with asymmetric keys and must be NULL otherwise. + /// + /// + /// + /// A pointer to a buffer that contains the hash value to sign. The cbInput parameter contains the size of this buffer. + /// + /// + /// The number of bytes in the pbInput buffer to sign. + /// + /// + /// + /// The address of a buffer to receive the signature produced by this function. The cbOutput parameter contains the size of this buffer. + /// + /// + /// If this parameter is NULL, this function will calculate the size required for the signature and return the size in the + /// location pointed to by the pcbResult parameter. + /// + /// + /// + /// The size, in bytes, of the pbOutput buffer. This parameter is ignored if the pbOutput parameter is NULL. + /// + /// + /// A pointer to a ULONG variable that receives the number of bytes copied to the pbOutput buffer. + /// If pbOutput is NULL, this receives the size, in bytes, required for the signature. + /// + /// + /// + /// A set of flags that modify the behavior of this function. The allowed set of flags depends on the type of key specified by the + /// hKey parameter. + /// + /// This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_PAD_PKCS1 + /// Use the PKCS1 padding scheme. The pPaddingInfo parameter is a pointer to a BCRYPT_PKCS1_PADDING_INFO structure. + /// + /// + /// BCRYPT_PAD_PSS + /// + /// Use the Probabilistic Signature Scheme (PSS) padding scheme. The pPaddingInfo parameter is a pointer to a BCRYPT_PSS_PADDING_INFO structure. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle specified by the hKey parameter is not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm provider used to create the key handle specified by the hKey parameter is not a signing algorithm. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The memory size specified by the cbOutput parameter is not large enough to hold the signature. + /// + /// + /// + /// + /// This function will encrypt the hash value with the specified key to create the signature. + /// + /// To later verify that the signature is valid, call the BCryptVerifySignature function with an identical key and an identical hash + /// of the original data. + /// + /// + /// Depending on what processor modes a provider supports, BCryptSignHash can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a provider + /// that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptSignHash function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptsignhash NTSTATUS BCryptSignHash( BCRYPT_KEY_HANDLE + // hKey, VOID *pPaddingInfo, PUCHAR pbInput, ULONG cbInput, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "f402ea9e-89ae-4ccc-9591-aa2328287c0e")] + public static extern NTStatus BCryptSignHash(BCRYPT_KEY_HANDLE hKey, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbInput, uint cbInput, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags); + + /// + /// The BCryptSignHash function creates a signature of a hash value. + /// + /// + /// The handle of the key to use to sign the hash. + /// + /// + /// + /// A pointer to a structure that contains padding information. The actual type of structure this parameter points to depends on the + /// value of the dwFlags parameter. This parameter is only used with asymmetric keys and must be NULL otherwise. + /// + /// + /// + /// A pointer to a buffer that contains the hash value to sign. The cbInput parameter contains the size of this buffer. + /// + /// + /// The number of bytes in the pbInput buffer to sign. + /// + /// + /// + /// The address of a buffer to receive the signature produced by this function. The cbOutput parameter contains the size of this buffer. + /// + /// + /// If this parameter is NULL, this function will calculate the size required for the signature and return the size in the + /// location pointed to by the pcbResult parameter. + /// + /// + /// + /// The size, in bytes, of the pbOutput buffer. This parameter is ignored if the pbOutput parameter is NULL. + /// + /// + /// A pointer to a ULONG variable that receives the number of bytes copied to the pbOutput buffer. + /// If pbOutput is NULL, this receives the size, in bytes, required for the signature. + /// + /// + /// + /// A set of flags that modify the behavior of this function. The allowed set of flags depends on the type of key specified by the + /// hKey parameter. + /// + /// This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_PAD_PKCS1 + /// Use the PKCS1 padding scheme. The pPaddingInfo parameter is a pointer to a BCRYPT_PKCS1_PADDING_INFO structure. + /// + /// + /// BCRYPT_PAD_PSS + /// + /// Use the Probabilistic Signature Scheme (PSS) padding scheme. The pPaddingInfo parameter is a pointer to a BCRYPT_PSS_PADDING_INFO structure. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle specified by the hKey parameter is not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm provider used to create the key handle specified by the hKey parameter is not a signing algorithm. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_BUFFER_TOO_SMALL + /// The memory size specified by the cbOutput parameter is not large enough to hold the signature. + /// + /// + /// + /// + /// This function will encrypt the hash value with the specified key to create the signature. + /// + /// To later verify that the signature is valid, call the BCryptVerifySignature function with an identical key and an identical hash + /// of the original data. + /// + /// + /// Depending on what processor modes a provider supports, BCryptSignHash can be called either from user mode or kernel mode. + /// Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL level is + /// DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a provider + /// that was opened with the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the BCryptSignHash function must + /// refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptsignhash NTSTATUS BCryptSignHash( BCRYPT_KEY_HANDLE + // hKey, VOID *pPaddingInfo, PUCHAR pbInput, ULONG cbInput, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "f402ea9e-89ae-4ccc-9591-aa2328287c0e")] + public static extern NTStatus BCryptSignHash(BCRYPT_KEY_HANDLE hKey, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbInput, uint cbInput, [Optional] IntPtr pbOutput, uint cbOutput, out uint pcbResult, EncryptFlags dwFlags); + + /// + /// The BCryptUnregisterConfigChangeNotify(PRKEVENT) function removes a kernel mode CNG configuration change event handler + /// that was created by using the BCryptRegisterConfigChangeNotify(PRKEVENT) function. + /// + /// + /// The pointer to the event dispatcher object to remove. This is the pointer that was obtained by using the + /// BCryptRegisterConfigChangeNotify(PRKEVENT) function. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_PARAMETER + /// The hEvent parameter is not valid. + /// + /// + /// STATUS_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + // NTSTATUS WINAPI BCryptUnregisterConfigChangeNotify( _In_ PRKEVENT hEvent); https://msdn.microsoft.com/en-us/library/windows/desktop/bb394683(v=vs.85).aspx + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("Bcrypt.h", MSDNShortId = "bb394683")] + public static extern NTStatus BCryptUnregisterConfigChangeNotify(IntPtr hEvent); + + /// + /// The BCryptVerifySignature function verifies that the specified signature matches the specified hash. + /// + /// + /// + /// The handle of the key to use to decrypt the signature. This must be an identical key or the public key portion of the key pair + /// used to sign the data with the BCryptSignHash function. + /// + /// + /// + /// + /// A pointer to a structure that contains padding information. The actual type of structure this parameter points to depends on the + /// value of the dwFlags parameter. This parameter is only used with asymmetric keys and must be NULL otherwise. + /// + /// + /// + /// The address of a buffer that contains the hash of the data. The cbHash parameter contains the size of this buffer. + /// + /// + /// The size, in bytes, of the pbHash buffer. + /// + /// + /// + /// The address of a buffer that contains the signed hash of the data. The BCryptSignHash function is used to create the signature. + /// The cbSignature parameter contains the size of this buffer. + /// + /// + /// + /// The size, in bytes, of the pbSignature buffer. The BCryptSignHash function is used to create the signature. + /// + /// + /// + /// A set of flags that modify the behavior of this function. The allowed set of flags depends on the type of key specified by the + /// hKey parameter. + /// + /// If the key is a symmetric key, this parameter is not used and should be zero. + /// If the key is an asymmetric key, this can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPT_PAD_PKCS1 + /// + /// The PKCS1 padding scheme was used when the signature was created. The pPaddingInfo parameter is a pointer to a + /// BCRYPT_PKCS1_PADDING_INFO structure. + /// + /// + /// + /// BCRYPT_PAD_PSS + /// + /// The Probabilistic Signature Scheme (PSS) padding scheme was used when the signature was created. The pPaddingInfo parameter is a + /// pointer to a BCRYPT_PSS_PADDING_INFO structure. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// STATUS_SUCCESS + /// The function was successful. + /// + /// + /// STATUS_INVALID_SIGNATURE + /// The signature was not verified. + /// + /// + /// NTE_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// STATUS_INVALID_HANDLE + /// The key handle specified by the hKey parameter is not valid. + /// + /// + /// STATUS_NOT_SUPPORTED + /// The algorithm provider used to create the key handle specified by the hKey parameter is not a signing algorithm. + /// + /// + /// + /// + /// + /// This function decrypts the signature with the provided key and then compares the decrypted value to the specified hash value. + /// + /// + /// To use this function, you must hash the data by using the same hashing algorithm that was used to create the hash value that was + /// signed. If applicable, you must also specify the same padding scheme that was specified when the signature was created. + /// + /// + /// Depending on what processor modes a provider supports, BCryptVerifySignature can be called either from user mode or kernel + /// mode. Kernel mode callers can execute either at PASSIVE_LEVEL IRQL or DISPATCH_LEVEL IRQL. If the current IRQL + /// level is DISPATCH_LEVEL, the handle provided in the hKey parameter must be derived from an algorithm handle returned by a + /// provider that was opened by using the BCRYPT_PROV_DISPATCH flag, and any pointers passed to the + /// BCryptVerifySignature function must refer to nonpaged (or locked) memory. + /// + /// + /// To call this function in kernel mode, use Cng.lib, which is part of the Driver Development Kit (DDK). For more information, see + /// WDK and Developer Tools. Windows Server 2008 and Windows Vista: To call this function in kernel mode, use Ksecdd.lib. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/nf-bcrypt-bcryptverifysignature NTSTATUS BCryptVerifySignature( + // BCRYPT_KEY_HANDLE hKey, VOID *pPaddingInfo, PUCHAR pbHash, ULONG cbHash, PUCHAR pbSignature, ULONG cbSignature, ULONG dwFlags ); + [DllImport(Lib.Bcrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("bcrypt.h", MSDNShortId = "95c32056-e444-441c-bbc1-c5ae82aba964")] + public static extern NTStatus BCryptVerifySignature(BCRYPT_KEY_HANDLE hKey, [Optional] IntPtr pPaddingInfo, SafeAllocatedMemoryHandle pbHash, uint cbHash, SafeAllocatedMemoryHandle pbSignature, uint cbSignature, EncryptFlags dwFlags); + + /// Provides a handle to an algorithm provider. + [StructLayout(LayoutKind.Sequential)] + public struct BCRYPT_ALG_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public BCRYPT_ALG_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static BCRYPT_ALG_HANDLE NULL => new BCRYPT_ALG_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(BCRYPT_ALG_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator BCRYPT_ALG_HANDLE(IntPtr h) => new BCRYPT_ALG_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(BCRYPT_ALG_HANDLE h1, BCRYPT_ALG_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(BCRYPT_ALG_HANDLE h1, BCRYPT_ALG_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is BCRYPT_ALG_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// + /// + /// The BCRYPT_ALGORITHM_IDENTIFIER structure is used with the BCryptEnumAlgorithms function to contain a cryptographic + /// algorithm identifier. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_algorithm_identifier typedef struct + // _BCRYPT_ALGORITHM_IDENTIFIER { LPWSTR pszName; ULONG dwClass; ULONG dwFlags; } BCRYPT_ALGORITHM_IDENTIFIER; + [PInvokeData("bcrypt.h", MSDNShortId = "a49a21c9-5668-4709-b52a-f6cacd944845")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct BCRYPT_ALGORITHM_IDENTIFIER + { + /// + /// + /// A pointer to a null-terminated Unicode string that contains the string identifier of the algorithm. The CNG Algorithm + /// Identifiers topic contains the predefined algorithm identifiers. + /// + /// + public string pszName; + + /// + /// Specifies the class of the algorithm. This can be one of the CNG Interface Identifiers. + /// + public InterfaceId dwClass; + + /// + /// A set of flags that specify other information about the algorithm. There are currently no flags defined for this member. + /// + public uint dwFlags; + } + + /// Provides a handle to a CNG object. + [StructLayout(LayoutKind.Sequential)] + public struct BCRYPT_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public BCRYPT_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static BCRYPT_HANDLE NULL => new BCRYPT_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(BCRYPT_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator BCRYPT_HANDLE(IntPtr h) => new BCRYPT_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(BCRYPT_HANDLE h1, BCRYPT_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(BCRYPT_HANDLE h1, BCRYPT_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is BCRYPT_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// Provides a handle to a multi-hash state. + [StructLayout(LayoutKind.Sequential)] + public struct BCRYPT_HASH_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public BCRYPT_HASH_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static BCRYPT_HASH_HANDLE NULL => new BCRYPT_HASH_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(BCRYPT_HASH_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator BCRYPT_HASH_HANDLE(IntPtr h) => new BCRYPT_HASH_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(BCRYPT_HASH_HANDLE h1, BCRYPT_HASH_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(BCRYPT_HASH_HANDLE h1, BCRYPT_HASH_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is BCRYPT_HASH_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// Provides a handle to a key pair. + [StructLayout(LayoutKind.Sequential)] + public struct BCRYPT_KEY_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public BCRYPT_KEY_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static BCRYPT_KEY_HANDLE NULL => new BCRYPT_KEY_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(BCRYPT_KEY_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator BCRYPT_KEY_HANDLE(IntPtr h) => new BCRYPT_KEY_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(BCRYPT_KEY_HANDLE h1, BCRYPT_KEY_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(BCRYPT_KEY_HANDLE h1, BCRYPT_KEY_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is BCRYPT_KEY_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// A BCRYPT_MULTI_HASH_OPERATION structure defines a single operation in a multi-hash operation. + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_multi_hash_operation typedef struct + // _BCRYPT_MULTI_HASH_OPERATION { ULONG iHash; BCRYPT_HASH_OPERATION_TYPE hashOperation; PUCHAR pbBuffer; ULONG cbBuffer; } BCRYPT_MULTI_HASH_OPERATION; + [PInvokeData("bcrypt.h", MSDNShortId = "B0418A07-D2EE-4346-9971-676C8FB08FAA")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct BCRYPT_MULTI_HASH_OPERATION + { + /// + /// An index into the multi-object state array of the hash state on which this computation operates. The first element of the + /// array corresponds to an iHash value of zero (0). Valid values are less than the value of the nHashes parameter of the + /// BCryptCreateMultiHash function. + /// + public uint iHash; + + /// + /// A hash operation type, either BCRYPT_HASH_OPERATION_HASH_DATA or BCRYPT_HASH_OPERATION_FINISH_HASH. + /// + /// If the value is BCRYPT_HASH_OPERATION_HASH_DATA, the operation performed is equivalent to calling the BCryptHashData + /// function on the hash object array element with pbBuffer/cbBuffer pointing to the buffer to be hashed. + /// + /// + /// If the value is BCRYPT_HASH_OPERATION_FINISH_HASH, the operation performed is equivalent to calling the + /// BCryptFinishHash function on the hash object array element with pbBuffer/cbBuffer pointing to the output buffer that receives + /// the result. + /// + /// + public BCRYPT_HASH_OPERATION_TYPE hashOperation; + + /// The buffer on which the operation works. + public IntPtr pbBuffer; + + /// The buffer on which the operation works. + public uint cbBuffer; + } + + /// + /// The BCRYPT_OAEP_PADDING_INFO structure is used to provide options for the Optimal Asymmetric Encryption Padding (OAEP) scheme. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_oaep_padding_info typedef struct + // _BCRYPT_OAEP_PADDING_INFO { LPCWSTR pszAlgId; PUCHAR pbLabel; ULONG cbLabel; } BCRYPT_OAEP_PADDING_INFO; + [PInvokeData("bcrypt.h", MSDNShortId = "19f48f2d-e952-4a01-8112-f298c79919b2")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct BCRYPT_OAEP_PADDING_INFO + { + /// + /// A pointer to a null-terminated Unicode string that identifies the cryptographic algorithm to use to create the padding. This + /// algorithm must be a hashing algorithm. + /// + public string pszAlgId; + + /// + /// The address of a buffer that contains the data to use to create the padding. The cbLabel member contains the size of + /// this buffer. + /// + public IntPtr pbLabel; + + /// Contains the number of bytes in the pbLabel buffer to use to create the padding. + public uint cbLabel; + } + + /// The BCRYPT_PKCS1_PADDING_INFO structure is used to provide options for the PKCS #1 padding scheme. + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_pkcs1_padding_info typedef struct + // _BCRYPT_PKCS1_PADDING_INFO { LPCWSTR pszAlgId; } BCRYPT_PKCS1_PADDING_INFO; + [PInvokeData("bcrypt.h", MSDNShortId = "920fa461-5b7e-4429-972d-e7c83fb62c64")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct BCRYPT_PKCS1_PADDING_INFO + { + /// + /// A pointer to a null-terminated Unicode string that identifies the cryptographic algorithm to use to create the padding. This + /// algorithm must be a hashing algorithm. When creating a signature, the object identifier (OID) that corresponds to this + /// algorithm is added to the DigestInfo element in the signature, and if this member is NULL, then the OID is not + /// added. When verifying a signature, the verification fails if the OID that corresponds to this member is not the same as the + /// OID in the signature. If there is no OID in the signature, then verification fails unless this member is NULL. + /// + public string pszAlgId; + } + + /// The BCRYPT_PROVIDER_NAME structure contains the name of a CNG provider. + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_provider_name typedef struct _BCRYPT_PROVIDER_NAME { + // LPWSTR pszProviderName; } BCRYPT_PROVIDER_NAME; + [PInvokeData("bcrypt.h", MSDNShortId = "0c57aa3f-1d9a-4bb2-b142-bce9c054e658")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct BCRYPT_PROVIDER_NAME + { + /// A pointer to a null-terminated Unicode string that contains the name of the provider. + public string pszProviderName; + } + + /// + /// The BCRYPT_PSS_PADDING_INFO structure is used to provide options for the Probabilistic Signature Scheme (PSS) padding scheme. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_pss_padding_info typedef struct + // _BCRYPT_PSS_PADDING_INFO { LPCWSTR pszAlgId; ULONG cbSalt; } BCRYPT_PSS_PADDING_INFO; + [PInvokeData("bcrypt.h", MSDNShortId = "28605b34-b1e1-4460-a8f0-b0fe9f9b94d4")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct BCRYPT_PSS_PADDING_INFO + { + /// + /// A pointer to a null-terminated Unicode string that identifies the cryptographic algorithm to use to create the padding. This + /// algorithm must be a hashing algorithm. + /// + public string pszAlgId; + + /// The size, in bytes, of the random salt to use for the padding. + public uint cbSalt; + } + + /// Provides a handle to a secret agreement. + [StructLayout(LayoutKind.Sequential)] + public struct BCRYPT_SECRET_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public BCRYPT_SECRET_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static BCRYPT_SECRET_HANDLE NULL => new BCRYPT_SECRET_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(BCRYPT_SECRET_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator BCRYPT_SECRET_HANDLE(IntPtr h) => new BCRYPT_SECRET_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(BCRYPT_SECRET_HANDLE h1, BCRYPT_SECRET_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(BCRYPT_SECRET_HANDLE h1, BCRYPT_SECRET_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is BCRYPT_SECRET_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// + /// The CRYPT_CONTEXT_CONFIG structure contains configuration information for a CNG context. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_crypt_context_config typedef struct _CRYPT_CONTEXT_CONFIG { + // ULONG dwFlags; ULONG dwReserved; } CRYPT_CONTEXT_CONFIG, *PCRYPT_CONTEXT_CONFIG; + [PInvokeData("bcrypt.h", MSDNShortId = "3e07b7ae-84ef-4b77-bd49-d96906eaa4f8")] + [StructLayout(LayoutKind.Sequential)] + public struct CRYPT_CONTEXT_CONFIG + { + /// + /// + /// A set of flags that determine the options for the configuration context. This can be zero or a combination of one or more of + /// the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_EXCLUSIVE + /// + /// Restricts the set of cryptographic functions in an interface to those that the current CNG context is specifically registered + /// to support. If this flag is set, then any attempts to resolve a given function will succeed only if one of the following is true: + /// + /// + /// + /// CRYPT_OVERRIDE + /// + /// Indicates that this entry in the enterprise-wide configuration table should take precedence over any and all corresponding + /// entries in the local-machine configuration table for this context. This flag only applies to entries in the enterprise-wide + /// configuration table. Without this flag, local machine configuration entries take precedence. + /// + /// + /// + /// + public ContextConfigFlags dwFlags; + + /// + public uint dwReserved; + } + + /// + /// + /// The CRYPT_CONTEXT_FUNCTION_CONFIG structure contains configuration information for a cryptographic function of a CNG context. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_crypt_context_function_config typedef struct + // _CRYPT_CONTEXT_FUNCTION_CONFIG { ULONG dwFlags; ULONG dwReserved; } CRYPT_CONTEXT_FUNCTION_CONFIG, *PCRYPT_CONTEXT_FUNCTION_CONFIG; + [PInvokeData("bcrypt.h", MSDNShortId = "53026095-c871-4027-ac7d-428f1cb4aafe")] + [StructLayout(LayoutKind.Sequential)] + public struct CRYPT_CONTEXT_FUNCTION_CONFIG + { + /// + /// + /// A set of flags that determine the options for the context function configuration. This can be zero or the following value. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// CRYPT_EXCLUSIVE + /// + /// Restricts the set of usable providers for this function to only those that this function is specifically registered to support. + /// + /// + /// + /// + public ContextConfigFlags dwFlags; + + /// + public uint dwReserved; + } + + /// + /// The CRYPT_CONTEXT_FUNCTION_PROVIDERS structure contains a set of cryptographic function providers for a CNG configuration context. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_crypt_context_function_providers typedef struct + // _CRYPT_CONTEXT_FUNCTION_PROVIDERS { ULONG cProviders; PWSTR *rgpszProviders; } CRYPT_CONTEXT_FUNCTION_PROVIDERS, *PCRYPT_CONTEXT_FUNCTION_PROVIDERS; + [PInvokeData("bcrypt.h", MSDNShortId = "5e175ac2-38eb-44c4-a01a-fb436e833546")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct CRYPT_CONTEXT_FUNCTION_PROVIDERS + { + /// The number of elements in the rgpszProviders array. + public uint cProviders; + + /// + /// An array of pointers to null-terminated Unicode strings that contain the identifiers of the function providers contained in + /// this set. The cProviders member contains the number of elements in this array. + /// + public IntPtr rgpszProviders; + + internal IEnumerable _rgpszProviders => rgpszProviders.ToStringEnum((int)cProviders, CharSet.Unicode); + } + + /// + /// The CRYPT_CONTEXT_FUNCTIONS structure contains a set of cryptographic functions for a CNG configuration context. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_crypt_context_functions typedef struct + // _CRYPT_CONTEXT_FUNCTIONS { ULONG cFunctions; PWSTR *rgpszFunctions; } CRYPT_CONTEXT_FUNCTIONS, *PCRYPT_CONTEXT_FUNCTIONS; + [PInvokeData("bcrypt.h", MSDNShortId = "c576f39c-a03a-47aa-90b7-500736070c6f")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct CRYPT_CONTEXT_FUNCTIONS + { + /// + /// The number of elements in the rgpszFunctions array. + /// + public uint cFunctions; + + /// + /// + /// An array of pointers to null-terminated Unicode strings that contain the identifiers of the cryptographic functions contained + /// in this set. The cFunctions member contains the number of elements in this array. + /// + /// + public IntPtr rgpszFunctions; + + internal IEnumerable _rgpszFunctions => rgpszFunctions.ToStringEnum((int)cFunctions, CharSet.Unicode); + } + + /// + /// The CRYPT_CONTEXTS structure contains a set of CNG configuration context identifiers. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_crypt_contexts typedef struct _CRYPT_CONTEXTS { ULONG + // cContexts; PWSTR *rgpszContexts; } CRYPT_CONTEXTS, *PCRYPT_CONTEXTS; + [PInvokeData("bcrypt.h", MSDNShortId = "a1b60660-a4c5-4880-8cd4-48d8717c77c3")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct CRYPT_CONTEXTS + { + /// + /// Contains the number of elements in the rgpszContexts array. + /// + public uint cContexts; + + /// + /// + /// An array of pointers to null-terminated Unicode strings that contain the identifiers of the contexts contained in this set. + /// The cContext member contains the number of elements in this array. + /// + /// + public IntPtr rgpszContexts; + + internal IEnumerable _rgpszContexts => rgpszContexts.ToStringEnum((int)cContexts, CharSet.Unicode); + } + + /// + /// The CRYPT_PROVIDERS structure contains information about the registered CNG providers. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_crypt_providers typedef struct _CRYPT_PROVIDERS { ULONG + // cProviders; PWSTR *rgpszProviders; } CRYPT_PROVIDERS, *PCRYPT_PROVIDERS; + [PInvokeData("bcrypt.h", MSDNShortId = "aef0e173-d3df-466e-ac2a-c686cae5edc9")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct CRYPT_PROVIDERS + { + /// + /// Contains the number of elements in the rgpszProviders array. + /// + public uint cProviders; + + /// + /// An array of null-terminated Unicode strings that contains the names of the registered providers. + /// + public IntPtr rgpszProviders; + + internal IEnumerable _rgpszProviders => rgpszProviders.ToStringEnum((int)cProviders, CharSet.Unicode); + } + + public static class BlobType + { + public const string BCRYPT_AES_WRAP_KEY_BLOB = "Rfc3565KeyWrapBlob"; + + /// + /// The BLOB is a Diffie-Hellman public/private key pair BLOB. The pbInput buffer must contain a BCRYPT_DH_KEY_BLOB structure + /// immediately followed by the key data. + /// + public const string BCRYPT_DH_PRIVATE_BLOB = "DHPRIVATEBLOB"; + + /// + /// The BLOB is a Diffie-Hellman public key BLOB. The pbInput buffer must contain a BCRYPT_DH_KEY_BLOB structure immediately + /// followed by the key data. + /// + public const string BCRYPT_DH_PUBLIC_BLOB = "DHPUBLICBLOB"; + + /// + /// The BLOB is a DSA public/private key pair BLOB. The pbInput buffer must contain a BCRYPT_DSA_KEY_BLOB or + /// BCRYPT_DSA_KEY_BLOB_V2 structure immediately followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 + /// to 1024 bits. BCRYPT_DSA_KEY_BLOB_V2 is used for key lengths that exceed 1024 bits but are less than or equal to 3072 bits. + /// Windows 8: Support for BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + public const string BCRYPT_DSA_PRIVATE_BLOB = "DSAPRIVATEBLOB"; + + /// + /// The BLOB is a DSA public key BLOB. The pbInput buffer must contain a BCRYPT_DSA_KEY_BLOB or BCRYPT_DSA_KEY_BLOB_V2 structure + /// immediately followed by the key data. BCRYPT_DSA_KEY_BLOB is used for key lengths from 512 to 1024 bits. + /// BCRYPT_DSA_KEY_BLOB_V2 is used for key lengths that exceed 1024 bits but are less than or equal to 3072 bits. + /// Windows 8: Support for BCRYPT_DSA_KEY_BLOB_V2 begins. + /// + public const string BCRYPT_DSA_PUBLIC_BLOB = "DSAPUBLICBLOB"; + + public const string BCRYPT_ECCFULLPRIVATE_BLOB = "ECCFULLPRIVATEBLOB"; + + public const string BCRYPT_ECCFULLPUBLIC_BLOB = "ECCFULLPUBLICBLOB"; + + /// + /// The BLOB is an elliptic curve cryptography (ECC) private key. The pbInput buffer must contain a BCRYPT_ECCKEY_BLOB structure + /// immediately followed by the key data. + /// + public const string BCRYPT_ECCPRIVATE_BLOB = "ECCPRIVATEBLOB"; + + /// + /// The BLOB is an ECC public key. The pbInput buffer must contain a BCRYPT_ECCKEY_BLOB structure immediately followed by the key data. + /// + public const string BCRYPT_ECCPUBLIC_BLOB = "ECCPUBLICBLOB"; + + public const string BCRYPT_KEY_DATA_BLOB = "KeyDataBlob"; + + public const string BCRYPT_OPAQUE_KEY_BLOB = "OpaqueKeyBlob"; + + /// + /// The BLOB is a generic private key of any type. The private key does not necessarily contain the public key. The type of key + /// in this BLOB is determined by the Magic member of the BCRYPT_KEY_BLOB structure. + /// + public const string BCRYPT_PRIVATE_KEY_BLOB = "PRIVATEBLOB"; + + /// + /// The BLOB is a generic public key of any type. The type of key in this BLOB is determined by the Magic member of the + /// BCRYPT_KEY_BLOB structure. + /// + public const string BCRYPT_PUBLIC_KEY_BLOB = "PUBLICBLOB"; + + public const string BCRYPT_RSAFULLPRIVATE_BLOB = "RSAFULLPRIVATEBLOB"; + + /// + /// The BLOB is an RSA public/private key pair BLOB. The pbInput buffer must contain a BCRYPT_RSAKEY_BLOB structure immediately + /// followed by the key data. + /// + public const string BCRYPT_RSAPRIVATE_BLOB = "RSAPRIVATEBLOB"; + + /// + /// The BLOB is an RSA public key BLOB. The pbInput buffer must contain a BCRYPT_RSAKEY_BLOB structure immediately followed by + /// the key data. + /// + public const string BCRYPT_RSAPUBLIC_BLOB = "RSAPUBLICBLOB"; + + /// + /// The BLOB is a legacy Diffie-Hellman Version 3 Private Key BLOB that contains a Diffie-Hellman public/private key pair that + /// was exported by using CryptoAPI. + /// + public const string LEGACY_DH_PRIVATE_BLOB = "CAPIDHPRIVATEBLOB"; + + /// + /// The BLOB is a Diffie-Hellman public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not + /// support importing this BLOB type. + /// + public const string LEGACY_DH_PUBLIC_BLOB = "CAPIDHPUBLICBLOB"; + + /// The BLOB is a DSA public/private key pair BLOB that was exported by using CryptoAPI. + public const string LEGACY_DSA_PRIVATE_BLOB = "CAPIDSAPRIVATEBLOB"; + + /// + /// The BLOB is a DSA public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not support + /// importing this BLOB type. + /// + public const string LEGACY_DSA_PUBLIC_BLOB = "CAPIDSAPUBLICBLOB"; + + /// The BLOB is a DSA version 2 private key in a form that can be imported by using CryptoAPI. + public const string LEGACY_DSA_V2_PRIVATE_BLOB = "V2CAPIDSAPRIVATEBLOB"; + + /// The BLOB is a DSA version 2 public key in a form that can be imported by using CryptoAPI. + public const string LEGACY_DSA_V2_PUBLIC_BLOB = "V2CAPIDSAPUBLICBLOB"; + + /// The BLOB is an RSA public/private key pair BLOB that was exported by using CryptoAPI. + public const string LEGACY_RSAPRIVATE_BLOB = "CAPIPRIVATEBLOB"; + + /// + /// The BLOB is an RSA public key BLOB that was exported by using CryptoAPI. The Microsoft primitive provider does not support + /// importing this BLOB type. + /// + public const string LEGACY_RSAPUBLIC_BLOB = "CAPIPUBLICBLOB"; + + public const string SSL_ECCPUBLIC_BLOB = "SSLECCPUBLICBLOB"; + } + + public static class ChainingMode + { + /// Undocumented + public const string BCRYPT_CHAIN_MODE_CBC = "ChainingModeCBC"; + + /// Undocumented + public const string BCRYPT_CHAIN_MODE_CCM = "ChainingModeCCM"; + + /// Undocumented + public const string BCRYPT_CHAIN_MODE_CFB = "ChainingModeCFB"; + + /// Undocumented + public const string BCRYPT_CHAIN_MODE_ECB = "ChainingModeECB"; + + /// Undocumented + public const string BCRYPT_CHAIN_MODE_GCM = "ChainingModeGCM"; + + /// Undocumented + public const string BCRYPT_CHAIN_MODE_NA = "ChainingModeN/A"; + } + + /// Known key derivation function identifiers. + [PInvokeData("bcrypt.h", MSDNShortId = "33c3cbf7-6c08-42ed-ac3f-feb71f3a9cbf")] + public static class KDF + { + /// The hash key derivation function. + public const string BCRYPT_KDF_HASH = "HASH"; + + /// Undocumented. + public const string BCRYPT_KDF_HKDF = "HKDF"; + + /// The Hash-Based Message Authentication Code (HMAC) key derivation function. + public const string BCRYPT_KDF_HMAC = "HMAC"; + + /// Undocumented. + public const string BCRYPT_KDF_RAW_SECRET = "TRUNCATE"; + + /// The SP800-56A key derivation function. + public const string BCRYPT_KDF_SP80056A_CONCAT = "SP800_56A_CONCAT"; + + /// + /// The transport layer security (TLS) pseudo-random function (PRF) key derivation function. The size of the derived key is + /// always 48 bytes. + /// + public const string BCRYPT_KDF_TLS_PRF = "TLS_PRF"; + } + + /// Well-known CNG providers. + public static class KnownProvider + { + /// + /// Generates and stores keys in Trusted Platform Modules. Supports Key Attestation to allow CA to ensure key is created in + /// TPM/Virtual smart card + /// + public const string MS_PLATFORM_CRYPTO_PROVIDER = "Microsoft Platform Crypto Provider"; + + /// Identifies the basic Microsoft CNG provider. + public const string MS_PRIMITIVE_PROVIDER = "Microsoft Primitive Provider"; + } + + /// The following values are used with the BCryptGetProperty and BCryptSetProperty functions to identify a property. + public static class PropertyName + { + /// A null-terminated Unicode string that contains the name of the algorithm. + [CorrespondingType(typeof(string))] + public const string BCRYPT_ALGORITHM_NAME = "AlgorithmName"; + + /// + /// The authentication tag lengths that are supported by the algorithm. This property is a BCRYPT_AUTH_TAG_LENGTHS_STRUCT + /// structure. This property only applies to algorithms. + /// + [CorrespondingType(typeof(uint))] + public const string BCRYPT_AUTH_TAG_LENGTH = "AuthTagLength"; + + /// + /// The size, in bytes, of a cipher block for the algorithm. This property only applies to block cipher algorithms. This data + /// type is a DWORD. + /// + [CorrespondingType(typeof(uint))] + public const string BCRYPT_BLOCK_LENGTH = "BlockLength"; + + /// + /// A list of the block lengths supported by an encryption algorithm. This data type is an array of DWORDs. The number of + /// elements in the array can be determined by dividing the number of bytes retrieved by the size of a single DWORD. + /// + [CorrespondingType(typeof(uint))] + public const string BCRYPT_BLOCK_SIZE_LIST = "BlockSizeList"; + + /// + /// A pointer to a null-terminated Unicode string that represents the chaining mode of the encryption algorithm. This property + /// can be set on an algorithm handle or a key handle to one of the following values. + /// + [CorrespondingType(typeof(string))] + public const string BCRYPT_CHAINING_MODE = "ChainingMode"; + + /// + /// Specifies parameters to use with a Diffie-Hellman key.This data type is a pointer to a BCRYPT_DH_PARAMETER_HEADER structure. + /// This property can only be set and must be set for the key before the key is completed. + /// + [CorrespondingType(typeof(IntPtr))] + public const string BCRYPT_DH_PARAMETERS = "DHParameters"; + + /// + /// Specifies parameters to use with a DSA key. This property is a BCRYPT_DSA_PARAMETER_HEADER or a + /// BCRYPT_DSA_PARAMETER_HEADER_V2 structure. This property can only be set and must be set for the key before the key is completed. + /// + /// Windows 8: Beginning with Windows 8, this property can be a BCRYPT_DSA_PARAMETER_HEADER_V2 structure.Use this structure if + /// the key size exceeds 1024 bits and is less than or equal to 3072 bits.If the key size is greater than or equal to 512 but + /// less than or equal to 1024 bits, use the BCRYPT_DSA_PARAMETER_HEADER structure. + /// + /// + [CorrespondingType(typeof(IntPtr))] + public const string BCRYPT_DSA_PARAMETERS = "DSAParameters"; + + /// Undocumented + public const string BCRYPT_ECC_CURVE_NAME = "ECCCurveName"; + + /// Undocumented + public const string BCRYPT_ECC_CURVE_NAME_LIST = "ECCCurveNameList"; + + /// Undocumented + public const string BCRYPT_ECC_PARAMETERS = "ECCParameters"; + + /// The size, in bits, of the effective length of an RC2 key. This data type is a DWORD. + [CorrespondingType(typeof(uint))] + public const string BCRYPT_EFFECTIVE_KEY_LENGTH = "EffectiveKeyLength"; + + /// Undocumented + public const string BCRYPT_GLOBAL_PARAMETERS = "SecretAgreementParam"; + + /// + /// The size, in bytes, of the block for a hash. This property only applies to hash algorithms. This data type is a DWORD. + /// + [CorrespondingType(typeof(uint))] + public const string BCRYPT_HASH_BLOCK_LENGTH = "HashBlockLength"; + + /// The size, in bytes, of the hash value of a hash provider. This data type is a DWORD. + [CorrespondingType(typeof(uint))] + public const string BCRYPT_HASH_LENGTH = "HashDigestLength"; + + /// + /// The list of DER-encoded hashing object identifiers (OIDs). This property is a BCRYPT_OID_LIST structure. This property can + /// only be read. + /// + // TODO [CorrespondingType(typeof(BCRYPT_OID_LIST))] + public const string BCRYPT_HASH_OID_LIST = "HashOIDList"; + + /// Contains the initialization vector (IV) for a key. This property only applies to keys. + public const string BCRYPT_INITIALIZATION_VECTOR = "IV"; + + /// Undocumented + public const string BCRYPT_IS_IFX_TPM_WEAK_KEY = "IsIfxTpmWeakKey"; + + /// Undocumented. + public const string BCRYPT_IS_KEYED_HASH = "IsKeyedHash"; + + /// Undocumented. + public const string BCRYPT_IS_REUSABLE_HASH = "IsReusableHash"; + + /// The size, in bits, of the key value of a symmetric key provider. This data type is a DWORD. + [CorrespondingType(typeof(uint))] + public const string BCRYPT_KEY_LENGTH = "KeyLength"; + + /// + /// The key lengths that are supported by the algorithm. This property is a BCRYPT_KEY_LENGTHS_STRUCT structure. This property + /// only applies to algorithms. + /// + // TODO [CorrespondingType(typeof(BCRYPT_KEY_LENGTHS_STRUCT))] + public const string BCRYPT_KEY_LENGTHS = "KeyLengths"; + + /// This property is not used. The BCRYPT_OBJECT_LENGTH property is used to obtain this information. + [CorrespondingType(typeof(uint))] + public const string BCRYPT_KEY_OBJECT_LENGTH = "KeyObjectLength"; + + /// The number of bits in the key. This data type is a DWORD. This property only applies to keys. + [CorrespondingType(typeof(uint))] + public const string BCRYPT_KEY_STRENGTH = "KeyStrength"; + + /// + /// This can be set on any key handle that has the CFB chaining mode set. By default, this property is set to 1 for 8-bit CFB. + /// Setting it to the block size in bytes causes full-block CFB to be used. + /// + [CorrespondingType(typeof(uint))] + public const string BCRYPT_MESSAGE_BLOCK_LENGTH = "MessageBlockLength"; + + /// + /// This property returns a BCRYPT_MULTI_OBJECT_LENGTH_STRUCT, which contains information necessary to calculate the size of an + /// object buffer.This property is only supported on operating system versions that support the BCryptCreateMultiHash function. + /// + // TODO [CorrespondingType(typeof(BCRYPT_MULTI_OBJECT_LENGTH_STRUCT))] + public const string BCRYPT_MULTI_OBJECT_LENGTH = "MultiObjectLength"; + + /// + /// The size, in bytes, of the subobject of a provider. This data type is a DWORD. Currently, the hash and symmetric cipher + /// algorithm providers use caller-allocated buffers to store their subobjects. For example, the hash provider requires you to + /// allocate memory for the hash object obtained with the BCryptCreateHash function. This property provides the buffer size for a + /// provider's object so you can allocate memory for the object created by the provider. + /// + [CorrespondingType(typeof(uint))] + public const string BCRYPT_OBJECT_LENGTH = "ObjectLength"; + + /// Represents the padding scheme of the RSA algorithm provider. This data type is a DWORD. + [CorrespondingType(typeof(PaddingScheme))] + public const string BCRYPT_PADDING_SCHEMES = "PaddingSchemes"; + + /// Undocumented + public const string BCRYPT_PCP_PLATFORM_TYPE_PROPERTY = "PCP_PLATFORM_TYPE"; + + /// Undocumented + public const string BCRYPT_PCP_PROVIDER_VERSION_PROPERTY = "PCP_PROVIDER_VERSION"; + + /// Undocumented. + public const string BCRYPT_PRIMITIVE_TYPE = "PrimitiveType"; + + /// Undocumented + public const string BCRYPT_PRIVATE_KEY = "PrivKeyVal"; + + /// + /// The handle of the CNG provider that created the object passed in the hObject parameter. This data type is a + /// BCRYPT_ALG_HANDLE. This property can only be retrieved; it cannot be set. + /// + [CorrespondingType(typeof(BCRYPT_ALG_HANDLE))] + public const string BCRYPT_PROVIDER_HANDLE = "ProviderHandle"; + + /// Undocumented. + public const string BCRYPT_PUBLIC_KEY_LENGTH = "PublicKeyLength"; + + /// + /// The size, in bytes, of the length of a signature for a key. This data type is a DWORD. This property only applies to keys. + /// This property can only be retrieved; it cannot be set. + /// + [CorrespondingType(typeof(uint))] + public const string BCRYPT_SIGNATURE_LENGTH = "SignatureLength"; + } + + /// + /// The following identifiers are used to identify standard encryption algorithms in various CNG functions and structures, such as + /// the CRYPT_INTERFACE_REG structure. Third party providers may have additional algorithms that they support. + /// + public static class StandardAlgorithmId + { + /// The 112-bit triple data encryption standard symmetric encryption algorithm. Standard: SP800-67, SP800-38A + public const string BCRYPT_3DES_112_ALGORITHM = "3DES_112"; + + /// The triple data encryption standard symmetric encryption algorithm. Standard: SP800-67, SP800-38A + public const string BCRYPT_3DES_ALGORITHM = "3DES"; + + /// The advanced encryption standard symmetric encryption algorithm. Standard: FIPS 197 + public const string BCRYPT_AES_ALGORITHM = "AES"; + + /// + /// The advanced encryption standard (AES) cipher based message authentication code (CMAC) symmetric encryption algorithm. + /// Standard: SP 800-38B + /// Windows 8: Support for this algorithm begins. + /// + public const string BCRYPT_AES_CMAC_ALGORITHM = "AES-CMAC"; + + /// + /// The advanced encryption standard (AES) Galois message authentication code (GMAC) symmetric encryption algorithm. Standard: SP800-38D + /// Windows Vista: This algorithm is supported beginning with Windows Vista with SP1. + /// + public const string BCRYPT_AES_GMAC_ALGORITHM = "AES-GMAC"; + + /// + /// Crypto API (CAPI) key derivation function algorithm. Used by the BCryptKeyDerivation and NCryptKeyDerivation functions. + /// + public const string BCRYPT_CAPI_KDF_ALGORITHM = "CAPI_KDF"; + + /// The data encryption standard symmetric encryption algorithm. Standard: FIPS 46-3, FIPS 81 + public const string BCRYPT_DES_ALGORITHM = "DES"; + + /// The extended data encryption standard symmetric encryption algorithm. Standard: None + public const string BCRYPT_DESX_ALGORITHM = "DESX"; + + /// The Diffie-Hellman key exchange algorithm. Standard: PKCS #3 + public const string BCRYPT_DH_ALGORITHM = "DH"; + + /// + /// The digital signature algorithm. Standard: FIPS 186-2 + /// + /// Windows 8: Beginning with Windows 8, this algorithm supports FIPS 186-3. Keys less than or equal to 1024 bits adhere to FIPS + /// 186-2 and keys greater than 1024 to FIPS 186-3. + /// + /// + public const string BCRYPT_DSA_ALGORITHM = "DSA"; + + /// + /// Generic prime elliptic curve Diffie-Hellman key exchange algorithm (see Remarks for more information). Standard: SP800-56A. + /// + public const string BCRYPT_ECDH_ALGORITHM = "ECDH"; + + /// The 256-bit prime elliptic curve Diffie-Hellman key exchange algorithm. Standard: SP800-56A + public const string BCRYPT_ECDH_P256_ALGORITHM = "ECDH_P256"; + + /// The 384-bit prime elliptic curve Diffie-Hellman key exchange algorithm. Standard: SP800-56A + public const string BCRYPT_ECDH_P384_ALGORITHM = "ECDH_P384"; + + /// The 521-bit prime elliptic curve Diffie-Hellman key exchange algorithm. Standard: SP800-56A + public const string BCRYPT_ECDH_P521_ALGORITHM = "ECDH_P521"; + + /// + /// Generic prime elliptic curve digital signature algorithm (see Remarks for more information). Standard: ANSI X9.62. + /// + public const string BCRYPT_ECDSA_ALGORITHM = "ECDSA"; + + /// The 256-bit prime elliptic curve digital signature algorithm (FIPS 186-2). Standard: FIPS 186-2, X9.62 + public const string BCRYPT_ECDSA_P256_ALGORITHM = "ECDSA_P256"; + + /// The 384-bit prime elliptic curve digital signature algorithm (FIPS 186-2). Standard: FIPS 186-2, X9.62 + public const string BCRYPT_ECDSA_P384_ALGORITHM = "ECDSA_P384"; + + /// The 521-bit prime elliptic curve digital signature algorithm (FIPS 186-2). Standard: FIPS 186-2, X9.62 + public const string BCRYPT_ECDSA_P521_ALGORITHM = "ECDSA_P521"; + + /// The bcrypt HKDF algorithm + public const string BCRYPT_HKDF_ALGORITHM = "HKDF"; + + /// The MD2 hash algorithm. Standard: RFC 1319 + public const string BCRYPT_MD2_ALGORITHM = "MD2"; + + /// The MD4 hash algorithm. Standard: RFC 1320 + public const string BCRYPT_MD4_ALGORITHM = "MD4"; + + /// The MD5 hash algorithm. Standard: RFC 1321 + public const string BCRYPT_MD5_ALGORITHM = "MD5"; + + /// + /// Password-based key derivation function 2 (PBKDF2) algorithm. Used by the BCryptKeyDerivation and NCryptKeyDerivation functions. + /// + public const string BCRYPT_PBKDF2_ALGORITHM = "PBKDF2"; + + /// The RC2 block symmetric encryption algorithm. Standard: RFC 2268 + public const string BCRYPT_RC2_ALGORITHM = "RC2"; + + /// The RC4 symmetric encryption algorithm. Standard: Various + public const string BCRYPT_RC4_ALGORITHM = "RC4"; + + /// + /// The random-number generator algorithm. Standard: FIPS 186-2, FIPS 140-2, NIST SP 800-90 Beginning with + /// Windows Vista with SP1 and Windows Server 2008, the random number generator is based on the AES counter mode specified in the + /// NIST SP 800-90 standard. + /// + /// Windows Vista: The random number generator is based on the hash-based random number generator specified in the FIPS 186-2 standard. + /// + /// + /// Windows 8: Beginning with Windows 8, the RNG algorithm supports FIPS 186-3. Keys less than or equal to 1024 bits adhere to + /// FIPS 186-2 and keys greater than 1024 to FIPS 186-3. + /// + /// + /// + public const string BCRYPT_RNG_ALGORITHM = "RNG"; + + /// + /// The dual elliptic curve random-number generator algorithm. Standard: SP800-90. + /// + /// Windows 8: Beginning with Windows 8, the EC RNG algorithm supports FIPS 186-3. Keys less than or equal to 1024 bits adhere to + /// FIPS 186-2 and keys greater than 1024 to FIPS 186-3. + /// + /// + /// Windows 10: Beginning with Windows 10, the dual elliptic curve random number generator algorithm has been removed.Existing + /// uses of this algorithm will continue to work; however, the random number generator is based on the AES counter mode specified + /// in the NIST SP 800-90 standard.New code should use BCRYPT_RNG_ALGORITHM, and it is recommended that existing code be changed + /// to use BCRYPT_RNG_ALGORITHM. + /// + /// + public const string BCRYPT_RNG_DUAL_EC_ALGORITHM = "DUALECRNG"; + + /// + /// The random-number generator algorithm suitable for DSA (Digital Signature Algorithm). Standard: FIPS 186-2. + /// Windows 8: Support for FIPS 186-3 begins. + /// + public const string BCRYPT_RNG_FIPS186_DSA_ALGORITHM = "FIPS186DSARNG"; + + /// The RSA public key algorithm. Standard: PKCS #1 v1.5 and v2.0. + public const string BCRYPT_RSA_ALGORITHM = "RSA"; + + /// + /// The RSA signature algorithm. This algorithm is not currently supported. You can use the BCRYPT_RSA_ALGORITHM algorithm to + /// perform RSA signing operations. Standard: PKCS #1 v1.5 and v2.0. + /// + public const string BCRYPT_RSA_SIGN_ALGORITHM = "RSA_SIGN"; + + /// The 160-bit secure hash algorithm. Standard: FIPS 180-2, FIPS 198. + public const string BCRYPT_SHA1_ALGORITHM = "SHA1"; + + /// The 256-bit secure hash algorithm. Standard: FIPS 180-2, FIPS 198. + public const string BCRYPT_SHA256_ALGORITHM = "SHA256"; + + /// The 384-bit secure hash algorithm. Standard: FIPS 180-2, FIPS 198. + public const string BCRYPT_SHA384_ALGORITHM = "SHA384"; + + /// The 512-bit secure hash algorithm. Standard: FIPS 180-2, FIPS 198. + public const string BCRYPT_SHA512_ALGORITHM = "SHA512"; + + /// + /// Counter mode, hash-based message authentication code (HMAC) key derivation function algorithm. Used by the + /// BCryptKeyDerivation and NCryptKeyDerivation functions. + /// + public const string BCRYPT_SP800108_CTR_HMAC_ALGORITHM = "SP800_108_CTR_HMAC"; + + /// SP800-56A key derivation function algorithm. Used by the BCryptKeyDerivation and NCryptKeyDerivation functions. + public const string BCRYPT_SP80056A_CONCAT_ALGORITHM = "SP800_56A_CONCAT"; + + /// The bcrypt tl s1 1 KDF algorithm + public const string BCRYPT_TLS1_1_KDF_ALGORITHM = "TLS1_1_KDF"; + + /// The bcrypt tl s1 2 KDF algorithm + public const string BCRYPT_TLS1_2_KDF_ALGORITHM = "TLS1_2_KDF"; + + /// + /// The advanced encryption standard symmetric encryption algorithm in XTS mode. Standard: SP-800-38E, IEEE Std 1619-2007. + /// Windows 10: Support for this algorithm begins. + /// + public const string BCRYPT_XTS_AES_ALGORITHM = "XTS-AES"; + } + + /// Provides a for that is disposed using . + public class SafeBCRYPT_ALG_HANDLE : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeBCRYPT_ALG_HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeBCRYPT_ALG_HANDLE() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator BCRYPT_ALG_HANDLE(SafeBCRYPT_ALG_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator BCRYPT_HANDLE(SafeBCRYPT_ALG_HANDLE h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => BCryptCloseAlgorithmProvider(this).Succeeded; + } + + /// Provides a for that is disposed using . + public class SafeBCRYPT_HASH_HANDLE : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeBCRYPT_HASH_HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeBCRYPT_HASH_HANDLE() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator BCRYPT_HASH_HANDLE(SafeBCRYPT_HASH_HANDLE h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => BCryptDestroyHash(this).Succeeded; + } + + /// Provides a for that is disposed using . + public class SafeBCRYPT_KEY_HANDLE : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeBCRYPT_KEY_HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeBCRYPT_KEY_HANDLE() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator BCRYPT_KEY_HANDLE(SafeBCRYPT_KEY_HANDLE h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => BCryptDestroyKey(this).Succeeded; + } + + /// Provides a for that is disposed using . + public class SafeBCRYPT_SECRET_HANDLE : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeBCRYPT_SECRET_HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeBCRYPT_SECRET_HANDLE() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator BCRYPT_SECRET_HANDLE(SafeBCRYPT_SECRET_HANDLE h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => BCryptDestroySecret(this).Succeeded; + } + + /// Provides a for that is disposed using . + public class SafeBCryptBuffer : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeBCryptBuffer(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeBCryptBuffer() : base() { } + + /// Marshals data to a newly allocated managed object of the type specified by a generic type parameter. + /// The type of the object to which the data is to be copied. This must be a structure. + /// A managed object that this buffer points to. + public T ToStructure() => IsInvalid || IsClosed ? default : handle.ToStructure(); + + /// + protected override bool InternalReleaseHandle() { BCryptFreeBuffer(handle); return true; } + } + } +} \ No newline at end of file diff --git a/PInvoke/Crypt32/CorrelationReport.md b/PInvoke/Cryptography/CorrelationReport.md similarity index 53% rename from PInvoke/Crypt32/CorrelationReport.md rename to PInvoke/Cryptography/CorrelationReport.md index cca06549..41b88dc0 100644 --- a/PInvoke/Crypt32/CorrelationReport.md +++ b/PInvoke/Cryptography/CorrelationReport.md @@ -1,7 +1,60 @@ -## Correlation report for crypt32.dll -### Methods (0% complete) +## Correlation report for crypt32.dll, bcrypt.dll, ncrypt.dll, tokenbinding.dll +### Methods (23% complete) Native Method | Native DLL | Header | Managed Method --- | --- | --- | --- +[BCryptAddContextFunction](http://msdn2.microsoft.com/en-us/library/4f5b6db0-775d-42de-b9d9-a99fb11c89f2) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptAddContextFunction +[BCryptCloseAlgorithmProvider](http://msdn2.microsoft.com/en-us/library/def90d52-87e0-40e6-9c50-fd77177991d0) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptCloseAlgorithmProvider +[BCryptConfigureContext](http://msdn2.microsoft.com/en-us/library/7989fefc-64fe-4ab3-9a48-7992edac171f) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptConfigureContext +[BCryptConfigureContextFunction](http://msdn2.microsoft.com/en-us/library/e93c5e3e-3c63-49a3-8c8c-6510e10611ea) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptConfigureContextFunction +[BCryptCreateContext](http://msdn2.microsoft.com/en-us/library/68f71010-0089-4433-bc89-f61f190e0bff) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptCreateContext +[BCryptCreateHash](http://msdn2.microsoft.com/en-us/library/deb02f67-f3d3-4542-8245-fd4982c3190b) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptCreateHash +[BCryptCreateMultiHash](http://msdn2.microsoft.com/en-us/library/AAF91460-AEFB-4E16-91EA-4A60272B3839) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptCreateMultiHash +[BCryptDecrypt](http://msdn2.microsoft.com/en-us/library/62286f6b-0d57-4691-83fc-2b9a9740af71) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDecrypt +[BCryptDeleteContext](http://msdn2.microsoft.com/en-us/library/6a250bed-0ea4-4cae-86e6-f0cea95dc56e) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDeleteContext +[BCryptDeriveKey](http://msdn2.microsoft.com/en-us/library/33c3cbf7-6c08-42ed-ac3f-feb71f3a9cbf) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDeriveKey +[BCryptDeriveKeyCapi](http://msdn2.microsoft.com/en-us/library/bebb0767-8c54-48b7-864c-f53caea7120d) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDeriveKeyCapi +[BCryptDeriveKeyPBKDF2](http://msdn2.microsoft.com/en-us/library/afdddfec-a3a5-410c-998b-9a5af8e051b6) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDeriveKeyPBKDF2 +[BCryptDestroyHash](http://msdn2.microsoft.com/en-us/library/067dac61-98b9-478c-ac4d-e141961865e9) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDestroyHash +[BCryptDestroyKey](http://msdn2.microsoft.com/en-us/library/98c02e55-6489-4901-8a7a-021baac41965) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDestroyKey +[BCryptDestroySecret](http://msdn2.microsoft.com/en-us/library/237743ff-ecb1-4c01-b4f9-192f27716f2c) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDestroySecret +[BCryptDuplicateHash](http://msdn2.microsoft.com/en-us/library/451ff5dc-b66a-4e8e-a327-28b4ee618b74) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDuplicateHash +[BCryptDuplicateKey](http://msdn2.microsoft.com/en-us/library/13a0b904-353f-498a-bdc2-2fd4e51144ff) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptDuplicateKey +[BCryptEncrypt](http://msdn2.microsoft.com/en-us/library/69fe4530-4b7c-40db-a85c-f9dc458735e7) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptEncrypt +[BCryptEnumAlgorithms](http://msdn2.microsoft.com/en-us/library/7fa227c0-2b80-49ab-8a19-72f8444d5507) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptEnumAlgorithms +[BCryptEnumContextFunctionProviders](http://msdn2.microsoft.com/en-us/library/82776e61-03bb-463b-8767-fa4f70fe1341) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptEnumContextFunctionProviders +[BCryptEnumContextFunctions](http://msdn2.microsoft.com/en-us/library/81bdfd47-7001-4e63-a8b3-33dae99f2c66) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptEnumContextFunctions +[BCryptEnumContexts](http://msdn2.microsoft.com/en-us/library/02646a80-6e93-4169-83da-0488ff3da56f) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptEnumContexts +[BCryptEnumProviders](http://msdn2.microsoft.com/en-us/library/0496f241-9530-47fb-89e2-15d7ab6da87a) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptEnumProviders +[BCryptEnumRegisteredProviders](http://msdn2.microsoft.com/en-us/library/a01adfec-dbe0-4817-af97-63163760fafc) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptEnumRegisteredProviders +[BCryptExportKey](http://msdn2.microsoft.com/en-us/library/a5d73143-c1d6-43b3-a724-7e27c68a5ade) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptExportKey +[BCryptFinalizeKeyPair](http://msdn2.microsoft.com/en-us/library/bf0b90f1-6da8-464e-9271-ad60ea762653) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptFinalizeKeyPair +[BCryptFinishHash](http://msdn2.microsoft.com/en-us/library/82a7c3d9-c01b-46d0-8b54-694dc0d8ffdd) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptFinishHash +[BCryptFreeBuffer](http://msdn2.microsoft.com/en-us/library/0ee83ca1-2fe6-4ff2-823e-888b3e66f310) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptFreeBuffer +[BCryptGenerateKeyPair](http://msdn2.microsoft.com/en-us/library/cdf0de2e-2445-45e3-91ba-89791a0c0642) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptGenerateKeyPair +[BCryptGenerateSymmetricKey](http://msdn2.microsoft.com/en-us/library/c55d714f-f47e-4ddf-97b9-985c0441bb2d) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptGenerateSymmetricKey +[BCryptGenRandom](http://msdn2.microsoft.com/en-us/library/7c6cee3a-f2c5-46f3-8cfe-984316f323d9) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptGenRandom +[BCryptGetFipsAlgorithmMode](http://msdn2.microsoft.com/en-us/library/eb7b758d-3466-49fe-8729-a8a059fadcde) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptGetFipsAlgorithmMode +[BCryptGetProperty](http://msdn2.microsoft.com/en-us/library/5c62ca3a-843e-41a7-9340-41785fbb15f4) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptGetProperty +[BCryptHash](http://msdn2.microsoft.com/en-us/library/F0FF9B6D-1345-480A-BE13-BE90547407BF) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptHash +[BCryptHashData](http://msdn2.microsoft.com/en-us/library/dab89dff-dc84-4f69-8b6b-de65704b0265) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptHashData +[BCryptImportKey](http://msdn2.microsoft.com/en-us/library/6b9683f4-10f2-40e4-9757-a1f01991bef7) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptImportKey +[BCryptImportKeyPair](http://msdn2.microsoft.com/en-us/library/271fc084-6121-4666-b521-b849c7d7966c) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptImportKeyPair +[BCryptKeyDerivation](http://msdn2.microsoft.com/en-us/library/D0B91FFE-2E72-4AE3-A84F-DC598C02CF53) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptKeyDerivation +[BCryptOpenAlgorithmProvider](http://msdn2.microsoft.com/en-us/library/aceba9c0-19e6-4f3c-972a-752feed4a9f8) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptOpenAlgorithmProvider +[BCryptProcessMultiOperations](http://msdn2.microsoft.com/en-us/library/5FD28AC3-46D2-4F06-BF06-F5FEF8E531F5) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptProcessMultiOperations +[BCryptQueryContextConfiguration](http://msdn2.microsoft.com/en-us/library/3e2ae471-cad6-4bfe-9e30-7b2a7014bc08) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptQueryContextConfiguration +[BCryptQueryContextFunctionConfiguration](http://msdn2.microsoft.com/en-us/library/4eea9efe-bf45-4926-86fc-9b12b6d292cd) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptQueryContextFunctionConfiguration +[BCryptQueryContextFunctionProperty](http://msdn2.microsoft.com/en-us/library/c8814a13-ac28-4583-927f-c787e0a25faf) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptQueryContextFunctionProperty +[BCryptQueryProviderRegistration](http://msdn2.microsoft.com/en-us/library/28b8bca9-442f-4d58-86aa-8aa274777ede) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptQueryProviderRegistration +[BCryptRegisterConfigChangeNotify](http://msdn2.microsoft.com/en-us/library/bb394681) | bcrypt.dll | Bcrypt.h | Vanara.PInvoke.BCrypt.BCryptRegisterConfigChangeNotify +[BCryptRemoveContextFunction](http://msdn2.microsoft.com/en-us/library/b8b1df66-f66f-4efc-9c8e-fca32e0278c5) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptRemoveContextFunction +[BCryptResolveProviders](http://msdn2.microsoft.com/en-us/library/cf30f635-4918-4911-9db0-df90d26a2f1a) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptResolveProviders +[BCryptSecretAgreement](http://msdn2.microsoft.com/en-us/library/96863d81-3643-4962-8abf-db1cc2acde07) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptSecretAgreement +[BCryptSetContextFunctionProperty](http://msdn2.microsoft.com/en-us/library/1e02720b-5210-4127-ab9e-24532a764795) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptSetContextFunctionProperty +[BCryptSetProperty](http://msdn2.microsoft.com/en-us/library/687f3410-d28b-4ce2-a2a1-c564f757c668) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptSetProperty +[BCryptSignHash](http://msdn2.microsoft.com/en-us/library/f402ea9e-89ae-4ccc-9591-aa2328287c0e) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptSignHash +[BCryptUnregisterConfigChangeNotify](http://msdn2.microsoft.com/en-us/library/bb394683) | bcrypt.dll | Bcrypt.h | Vanara.PInvoke.BCrypt.BCryptUnregisterConfigChangeNotify +[BCryptVerifySignature](http://msdn2.microsoft.com/en-us/library/95c32056-e444-441c-bbc1-c5ae82aba964) | bcrypt.dll | bcrypt.h | Vanara.PInvoke.BCrypt.BCryptVerifySignature [CertAddCertificateContextToStore](https://www.google.com/search?num=5&q=CertAddCertificateContextToStore+site%3Amicrosoft.com) | crypt32.dll | | [CertAddCertificateLinkToStore](https://www.google.com/search?num=5&q=CertAddCertificateLinkToStore+site%3Amicrosoft.com) | crypt32.dll | | [CertAddCRLContextToStore](https://www.google.com/search?num=5&q=CertAddCRLContextToStore+site%3Amicrosoft.com) | crypt32.dll | | @@ -84,7 +137,6 @@ Native Method | Native DLL | Header | Managed Method [CertIsRDNAttrsInCertificateName](https://www.google.com/search?num=5&q=CertIsRDNAttrsInCertificateName+site%3Amicrosoft.com) | crypt32.dll | | [CertIsStrongHashToSign](https://www.google.com/search?num=5&q=CertIsStrongHashToSign+site%3Amicrosoft.com) | crypt32.dll | | [CertIsValidCRLForCertificate](https://www.google.com/search?num=5&q=CertIsValidCRLForCertificate+site%3Amicrosoft.com) | crypt32.dll | | -[CertIsWeakHash](https://www.google.com/search?num=5&q=CertIsWeakHash+site%3Amicrosoft.com) | crypt32.dll | | [CertNameToStr](https://www.google.com/search?num=5&q=CertNameToStrA+site%3Amicrosoft.com) | crypt32.dll | | [CertOIDToAlgId](https://www.google.com/search?num=5&q=CertOIDToAlgId+site%3Amicrosoft.com) | crypt32.dll | | [CertOpenServerOcspResponse](https://www.google.com/search?num=5&q=CertOpenServerOcspResponse+site%3Amicrosoft.com) | crypt32.dll | | @@ -121,8 +173,6 @@ Native Method | Native DLL | Header | Managed Method [CertVerifyValidityNesting](https://www.google.com/search?num=5&q=CertVerifyValidityNesting+site%3Amicrosoft.com) | crypt32.dll | | [CryptAcquireCertificatePrivateKey](https://www.google.com/search?num=5&q=CryptAcquireCertificatePrivateKey+site%3Amicrosoft.com) | crypt32.dll | | [CryptBinaryToString](https://www.google.com/search?num=5&q=CryptBinaryToStringA+site%3Amicrosoft.com) | crypt32.dll | | -[CryptCloseAsyncHandle](https://www.google.com/search?num=5&q=CryptCloseAsyncHandle+site%3Amicrosoft.com) | crypt32.dll | | -[CryptCreateAsyncHandle](https://www.google.com/search?num=5&q=CryptCreateAsyncHandle+site%3Amicrosoft.com) | crypt32.dll | | [CryptCreateKeyIdentifierFromCSP](https://www.google.com/search?num=5&q=CryptCreateKeyIdentifierFromCSP+site%3Amicrosoft.com) | crypt32.dll | | [CryptDecodeMessage](https://www.google.com/search?num=5&q=CryptDecodeMessage+site%3Amicrosoft.com) | crypt32.dll | | [CryptDecodeObject](https://www.google.com/search?num=5&q=CryptDecodeObject+site%3Amicrosoft.com) | crypt32.dll | | @@ -135,7 +185,6 @@ Native Method | Native DLL | Header | Managed Method [CryptEnumKeyIdentifierProperties](https://www.google.com/search?num=5&q=CryptEnumKeyIdentifierProperties+site%3Amicrosoft.com) | crypt32.dll | | [CryptEnumOIDFunction](https://www.google.com/search?num=5&q=CryptEnumOIDFunction+site%3Amicrosoft.com) | crypt32.dll | | [CryptEnumOIDInfo](https://www.google.com/search?num=5&q=CryptEnumOIDInfo+site%3Amicrosoft.com) | crypt32.dll | | -[CryptExportPKCS8](https://www.google.com/search?num=5&q=CryptExportPKCS8+site%3Amicrosoft.com) | crypt32.dll | | [CryptExportPublicKeyInfo](https://www.google.com/search?num=5&q=CryptExportPublicKeyInfo+site%3Amicrosoft.com) | crypt32.dll | | [CryptExportPublicKeyInfoEx](https://www.google.com/search?num=5&q=CryptExportPublicKeyInfoEx+site%3Amicrosoft.com) | crypt32.dll | | [CryptExportPublicKeyInfoFromBCryptKeyHandle](https://www.google.com/search?num=5&q=CryptExportPublicKeyInfoFromBCryptKeyHandle+site%3Amicrosoft.com) | crypt32.dll | | @@ -144,7 +193,6 @@ Native Method | Native DLL | Header | Managed Method [CryptFindOIDInfo](https://www.google.com/search?num=5&q=CryptFindOIDInfo+site%3Amicrosoft.com) | crypt32.dll | | [CryptFormatObject](https://www.google.com/search?num=5&q=CryptFormatObject+site%3Amicrosoft.com) | crypt32.dll | | [CryptFreeOIDFunctionAddress](https://www.google.com/search?num=5&q=CryptFreeOIDFunctionAddress+site%3Amicrosoft.com) | crypt32.dll | | -[CryptGetAsyncParam](https://www.google.com/search?num=5&q=CryptGetAsyncParam+site%3Amicrosoft.com) | crypt32.dll | | [CryptGetDefaultOIDDllList](https://www.google.com/search?num=5&q=CryptGetDefaultOIDDllList+site%3Amicrosoft.com) | crypt32.dll | | [CryptGetDefaultOIDFunctionAddress](https://www.google.com/search?num=5&q=CryptGetDefaultOIDFunctionAddress+site%3Amicrosoft.com) | crypt32.dll | | [CryptGetKeyIdentifierProperty](https://www.google.com/search?num=5&q=CryptGetKeyIdentifierProperty+site%3Amicrosoft.com) | crypt32.dll | | @@ -157,14 +205,12 @@ Native Method | Native DLL | Header | Managed Method [CryptHashMessage](https://www.google.com/search?num=5&q=CryptHashMessage+site%3Amicrosoft.com) | crypt32.dll | | [CryptHashPublicKeyInfo](https://www.google.com/search?num=5&q=CryptHashPublicKeyInfo+site%3Amicrosoft.com) | crypt32.dll | | [CryptHashToBeSigned](https://www.google.com/search?num=5&q=CryptHashToBeSigned+site%3Amicrosoft.com) | crypt32.dll | | -[CryptImportPKCS8](https://www.google.com/search?num=5&q=CryptImportPKCS8+site%3Amicrosoft.com) | crypt32.dll | | [CryptImportPublicKeyInfo](https://www.google.com/search?num=5&q=CryptImportPublicKeyInfo+site%3Amicrosoft.com) | crypt32.dll | | [CryptImportPublicKeyInfoEx](https://www.google.com/search?num=5&q=CryptImportPublicKeyInfoEx+site%3Amicrosoft.com) | crypt32.dll | | [CryptImportPublicKeyInfoEx2](https://www.google.com/search?num=5&q=CryptImportPublicKeyInfoEx2+site%3Amicrosoft.com) | crypt32.dll | | [CryptInitOIDFunctionSet](https://www.google.com/search?num=5&q=CryptInitOIDFunctionSet+site%3Amicrosoft.com) | crypt32.dll | | [CryptInstallDefaultContext](https://www.google.com/search?num=5&q=CryptInstallDefaultContext+site%3Amicrosoft.com) | crypt32.dll | | [CryptInstallOIDFunctionAddress](https://www.google.com/search?num=5&q=CryptInstallOIDFunctionAddress+site%3Amicrosoft.com) | crypt32.dll | | -[CryptLoadSip](https://www.google.com/search?num=5&q=CryptLoadSip+site%3Amicrosoft.com) | crypt32.dll | | [CryptMemAlloc](https://www.google.com/search?num=5&q=CryptMemAlloc+site%3Amicrosoft.com) | crypt32.dll | | [CryptMemFree](https://www.google.com/search?num=5&q=CryptMemFree+site%3Amicrosoft.com) | crypt32.dll | | [CryptMemRealloc](https://www.google.com/search?num=5&q=CryptMemRealloc+site%3Amicrosoft.com) | crypt32.dll | | @@ -183,13 +229,6 @@ Native Method | Native DLL | Header | Managed Method [CryptMsgUpdate](https://www.google.com/search?num=5&q=CryptMsgUpdate+site%3Amicrosoft.com) | crypt32.dll | | [CryptMsgVerifyCountersignatureEncoded](https://www.google.com/search?num=5&q=CryptMsgVerifyCountersignatureEncoded+site%3Amicrosoft.com) | crypt32.dll | | [CryptMsgVerifyCountersignatureEncodedEx](https://www.google.com/search?num=5&q=CryptMsgVerifyCountersignatureEncodedEx+site%3Amicrosoft.com) | crypt32.dll | | -[CryptObjectLocatorFree](https://www.google.com/search?num=5&q=CryptObjectLocatorFree+site%3Amicrosoft.com) | crypt32.dll | | -[CryptObjectLocatorGet](https://www.google.com/search?num=5&q=CryptObjectLocatorGet+site%3Amicrosoft.com) | crypt32.dll | | -[CryptObjectLocatorGetContent](https://www.google.com/search?num=5&q=CryptObjectLocatorGetContent+site%3Amicrosoft.com) | crypt32.dll | | -[CryptObjectLocatorGetUpdated](https://www.google.com/search?num=5&q=CryptObjectLocatorGetUpdated+site%3Amicrosoft.com) | crypt32.dll | | -[CryptObjectLocatorInitialize](https://www.google.com/search?num=5&q=CryptObjectLocatorInitialize+site%3Amicrosoft.com) | crypt32.dll | | -[CryptObjectLocatorIsChanged](https://www.google.com/search?num=5&q=CryptObjectLocatorIsChanged+site%3Amicrosoft.com) | crypt32.dll | | -[CryptObjectLocatorRelease](https://www.google.com/search?num=5&q=CryptObjectLocatorRelease+site%3Amicrosoft.com) | crypt32.dll | | [CryptProtectData](https://www.google.com/search?num=5&q=CryptProtectData+site%3Amicrosoft.com) | crypt32.dll | | [CryptProtectMemory](https://www.google.com/search?num=5&q=CryptProtectMemory+site%3Amicrosoft.com) | crypt32.dll | | [CryptQueryObject](https://www.google.com/search?num=5&q=CryptQueryObject+site%3Amicrosoft.com) | crypt32.dll | | @@ -197,7 +236,6 @@ Native Method | Native DLL | Header | Managed Method [CryptRegisterOIDFunction](https://www.google.com/search?num=5&q=CryptRegisterOIDFunction+site%3Amicrosoft.com) | crypt32.dll | | [CryptRegisterOIDInfo](https://www.google.com/search?num=5&q=CryptRegisterOIDInfo+site%3Amicrosoft.com) | crypt32.dll | | [CryptRetrieveTimeStamp](https://www.google.com/search?num=5&q=CryptRetrieveTimeStamp+site%3Amicrosoft.com) | crypt32.dll | | -[CryptSetAsyncParam](https://www.google.com/search?num=5&q=CryptSetAsyncParam+site%3Amicrosoft.com) | crypt32.dll | | [CryptSetKeyIdentifierProperty](https://www.google.com/search?num=5&q=CryptSetKeyIdentifierProperty+site%3Amicrosoft.com) | crypt32.dll | | [CryptSetOIDFunctionValue](https://www.google.com/search?num=5&q=CryptSetOIDFunctionValue+site%3Amicrosoft.com) | crypt32.dll | | [CryptSignAndEncodeCertificate](https://www.google.com/search?num=5&q=CryptSignAndEncodeCertificate+site%3Amicrosoft.com) | crypt32.dll | | @@ -208,7 +246,6 @@ Native Method | Native DLL | Header | Managed Method [CryptSIPAddProvider](https://www.google.com/search?num=5&q=CryptSIPAddProvider+site%3Amicrosoft.com) | crypt32.dll | | [CryptSIPCreateIndirectData](https://www.google.com/search?num=5&q=CryptSIPCreateIndirectData+site%3Amicrosoft.com) | crypt32.dll | | [CryptSIPGetCaps](https://www.google.com/search?num=5&q=CryptSIPGetCaps+site%3Amicrosoft.com) | crypt32.dll | | -[CryptSIPGetSealedDigest](https://www.google.com/search?num=5&q=CryptSIPGetSealedDigest+site%3Amicrosoft.com) | crypt32.dll | | [CryptSIPGetSignedDataMsg](https://www.google.com/search?num=5&q=CryptSIPGetSignedDataMsg+site%3Amicrosoft.com) | crypt32.dll | | [CryptSIPLoad](https://www.google.com/search?num=5&q=CryptSIPLoad+site%3Amicrosoft.com) | crypt32.dll | | [CryptSIPPutSignedDataMsg](https://www.google.com/search?num=5&q=CryptSIPPutSignedDataMsg+site%3Amicrosoft.com) | crypt32.dll | | @@ -233,21 +270,127 @@ Native Method | Native DLL | Header | Managed Method [CryptVerifyMessageSignature](https://www.google.com/search?num=5&q=CryptVerifyMessageSignature+site%3Amicrosoft.com) | crypt32.dll | | [CryptVerifyMessageSignatureWithKey](https://www.google.com/search?num=5&q=CryptVerifyMessageSignatureWithKey+site%3Amicrosoft.com) | crypt32.dll | | [CryptVerifyTimeStampSignature](https://www.google.com/search?num=5&q=CryptVerifyTimeStampSignature+site%3Amicrosoft.com) | crypt32.dll | | -[I_CertWnfEnableFlushCache](https://www.google.com/search?num=5&q=I_CertWnfEnableFlushCache+site%3Amicrosoft.com) | crypt32.dll | | -[I_PFXDecrypt](https://www.google.com/search?num=5&q=I_PFXDecrypt+site%3Amicrosoft.com) | crypt32.dll | | -[I_PFXHMAC](https://www.google.com/search?num=5&q=I_PFXHMAC+site%3Amicrosoft.com) | crypt32.dll | | +[NCryptCloseProtectionDescriptor](http://msdn2.microsoft.com/en-us/library/523FD83E-85A3-4A0E-BA8D-2F27F82C1072) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptCloseProtectionDescriptor +[NCryptCreateClaim](https://www.google.com/search?num=5&q=NCryptCreateClaim+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptCreatePersistedKey](http://msdn2.microsoft.com/en-us/library/eeb1842f-fd9e-4edf-9db8-7b4e91760e9b) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptCreatePersistedKey +[NCryptCreateProtectionDescriptor](http://msdn2.microsoft.com/en-us/library/BA6B15AC-2CD8-4D9A-817F-65CF9C09D22C) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptCreateProtectionDescriptor +[NCryptDecrypt](https://www.google.com/search?num=5&q=NCryptDecrypt+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptDeleteKey](http://msdn2.microsoft.com/en-us/library/2e1958a7-51e0-4731-b4cf-a90d6c1f9ae0) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptDeleteKey +[NCryptDeriveKey](http://msdn2.microsoft.com/en-us/library/0ff08c6a-5f30-43ca-9db8-cda3e0704b0a) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptDeriveKey +[NCryptEncrypt](https://www.google.com/search?num=5&q=NCryptEncrypt+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptEnumAlgorithms](https://www.google.com/search?num=5&q=NCryptEnumAlgorithms+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptEnumKeys](https://www.google.com/search?num=5&q=NCryptEnumKeys+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptEnumStorageProviders](https://www.google.com/search?num=5&q=NCryptEnumStorageProviders+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptExportKey](http://msdn2.microsoft.com/en-us/library/1588eb29-4026-4d1c-8bee-a035df38444a) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptExportKey +[NCryptFinalizeKey](http://msdn2.microsoft.com/en-us/library/4386030d-4ce6-4b2e-adc5-a15ddc869349) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptFinalizeKey +[NCryptFreeBuffer](https://www.google.com/search?num=5&q=NCryptFreeBuffer+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptFreeObject](http://msdn2.microsoft.com/en-us/library/a5535cf9-ba8c-4212-badd-f1dc88903624) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptFreeObject +[NCryptGetProperty](https://www.google.com/search?num=5&q=NCryptGetProperty+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptGetProtectionDescriptorInfo](http://msdn2.microsoft.com/en-us/library/EF4777D5-E218-4868-8D25-58E0EF8C9D30) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptGetProtectionDescriptorInfo +[NCryptImportKey](http://msdn2.microsoft.com/en-us/library/ede0e7e0-cb2c-44c0-b724-58db3480b781) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptImportKey +[NCryptIsAlgSupported](https://www.google.com/search?num=5&q=NCryptIsAlgSupported+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptIsKeyHandle](https://www.google.com/search?num=5&q=NCryptIsKeyHandle+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptKeyDerivation](https://www.google.com/search?num=5&q=NCryptKeyDerivation+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptNotifyChangeKey](https://www.google.com/search?num=5&q=NCryptNotifyChangeKey+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptOpenKey](http://msdn2.microsoft.com/en-us/library/581c5d89-730d-4d8c-b3bb-a28edec25910) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptOpenKey +[NCryptOpenStorageProvider](http://msdn2.microsoft.com/en-us/library/febcf440-78b3-420b-b13d-030e8071cd50) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptOpenStorageProvider +[NCryptProtectSecret](http://msdn2.microsoft.com/en-us/library/8726F92B-34D5-4696-8803-3D7F50F1006D) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptProtectSecret +[NCryptQueryProtectionDescriptorName](http://msdn2.microsoft.com/en-us/library/32953AEC-01EE-4ED1-80F3-29963F43004F) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptQueryProtectionDescriptorName +[NCryptRegisterProtectionDescriptorName](http://msdn2.microsoft.com/en-us/library/DAB03CB2-630F-4BB3-93BD-06BE9126B1C4) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptRegisterProtectionDescriptorName +[NCryptSecretAgreement](http://msdn2.microsoft.com/en-us/library/b5bf3eac-1fae-43e2-84b6-e8e5e255d7c5) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptSecretAgreement +[NCryptSetProperty](http://msdn2.microsoft.com/en-us/library/ad1148aa-5f64-4867-9e17-6b41cc0c20b7) | ncrypt.dll | ncrypt.h | Vanara.PInvoke.NCrypt.NCryptSetProperty +[NCryptSignHash](https://www.google.com/search?num=5&q=NCryptSignHash+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptStreamClose](http://msdn2.microsoft.com/en-us/library/770640F2-04C7-4512-8004-41F4ECDC110E) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptStreamClose +[NCryptStreamOpenToProtect](http://msdn2.microsoft.com/en-us/library/7DE74BB1-1B84-4721-BE4A-4D2661E93E00) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptStreamOpenToProtect +[NCryptStreamOpenToUnprotect](http://msdn2.microsoft.com/en-us/library/9848082E-EDDA-4DA1-9896-42EAF2ADFAB4) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptStreamOpenToUnprotect +[NCryptStreamOpenToUnprotectEx](http://msdn2.microsoft.com/en-us/library/8E607F4F-4A0F-4796-8F40-D232687815AF) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptStreamOpenToUnprotectEx +[NCryptStreamUpdate](http://msdn2.microsoft.com/en-us/library/417F9267-6055-489C-AF26-BEF5E17CB8B4) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptStreamUpdate +[NCryptTranslateHandle](https://www.google.com/search?num=5&q=NCryptTranslateHandle+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptUnprotectSecret](http://msdn2.microsoft.com/en-us/library/F532F0ED-36F4-47E3-B478-089CC083E5D1) | ncrypt.dll | ncryptprotect.h | Vanara.PInvoke.NCrypt.NCryptUnprotectSecret +[NCryptVerifyClaim](https://www.google.com/search?num=5&q=NCryptVerifyClaim+site%3Amicrosoft.com) | ncrypt.dll | | +[NCryptVerifySignature](https://www.google.com/search?num=5&q=NCryptVerifySignature+site%3Amicrosoft.com) | ncrypt.dll | | [PFXExportCertStore](https://www.google.com/search?num=5&q=PFXExportCertStore+site%3Amicrosoft.com) | crypt32.dll | | -[PFXExportCertStore2](https://www.google.com/search?num=5&q=PFXExportCertStore2+site%3Amicrosoft.com) | crypt32.dll | | [PFXExportCertStoreEx](https://www.google.com/search?num=5&q=PFXExportCertStoreEx+site%3Amicrosoft.com) | crypt32.dll | | [PFXImportCertStore](https://www.google.com/search?num=5&q=PFXImportCertStore+site%3Amicrosoft.com) | crypt32.dll | | [PFXIsPFXBlob](https://www.google.com/search?num=5&q=PFXIsPFXBlob+site%3Amicrosoft.com) | crypt32.dll | | [PFXVerifyPassword](https://www.google.com/search?num=5&q=PFXVerifyPassword+site%3Amicrosoft.com) | crypt32.dll | | +[SslChangeNotify](https://www.google.com/search?num=5&q=SslChangeNotify+site%3Amicrosoft.com) | ncrypt.dll | | +[SslComputeClientAuthHash](https://www.google.com/search?num=5&q=SslComputeClientAuthHash+site%3Amicrosoft.com) | ncrypt.dll | | +[SslComputeEapKeyBlock](https://www.google.com/search?num=5&q=SslComputeEapKeyBlock+site%3Amicrosoft.com) | ncrypt.dll | | +[SslComputeFinishedHash](https://www.google.com/search?num=5&q=SslComputeFinishedHash+site%3Amicrosoft.com) | ncrypt.dll | | +[SslCreateClientAuthHash](https://www.google.com/search?num=5&q=SslCreateClientAuthHash+site%3Amicrosoft.com) | ncrypt.dll | | +[SslCreateEphemeralKey](https://www.google.com/search?num=5&q=SslCreateEphemeralKey+site%3Amicrosoft.com) | ncrypt.dll | | +[SslCreateHandshakeHash](https://www.google.com/search?num=5&q=SslCreateHandshakeHash+site%3Amicrosoft.com) | ncrypt.dll | | +[SslDecrementProviderReferenceCount](https://www.google.com/search?num=5&q=SslDecrementProviderReferenceCount+site%3Amicrosoft.com) | ncrypt.dll | | +[SslDecryptPacket](https://www.google.com/search?num=5&q=SslDecryptPacket+site%3Amicrosoft.com) | ncrypt.dll | | +[SslEncryptPacket](https://www.google.com/search?num=5&q=SslEncryptPacket+site%3Amicrosoft.com) | ncrypt.dll | | +[SslEnumCipherSuites](https://www.google.com/search?num=5&q=SslEnumCipherSuites+site%3Amicrosoft.com) | ncrypt.dll | | +[SslEnumProtocolProviders](https://www.google.com/search?num=5&q=SslEnumProtocolProviders+site%3Amicrosoft.com) | ncrypt.dll | | +[SslExportKey](https://www.google.com/search?num=5&q=SslExportKey+site%3Amicrosoft.com) | ncrypt.dll | | +[SslExportKeyingMaterial](https://www.google.com/search?num=5&q=SslExportKeyingMaterial+site%3Amicrosoft.com) | ncrypt.dll | | +[SslFreeBuffer](https://www.google.com/search?num=5&q=SslFreeBuffer+site%3Amicrosoft.com) | ncrypt.dll | | +[SslFreeObject](https://www.google.com/search?num=5&q=SslFreeObject+site%3Amicrosoft.com) | ncrypt.dll | | +[SslGenerateMasterKey](https://www.google.com/search?num=5&q=SslGenerateMasterKey+site%3Amicrosoft.com) | ncrypt.dll | | +[SslGenerateSessionKeys](https://www.google.com/search?num=5&q=SslGenerateSessionKeys+site%3Amicrosoft.com) | ncrypt.dll | | +[SslGetCipherSuitePRFHashAlgorithm](https://www.google.com/search?num=5&q=SslGetCipherSuitePRFHashAlgorithm+site%3Amicrosoft.com) | ncrypt.dll | | +[SslGetKeyProperty](https://www.google.com/search?num=5&q=SslGetKeyProperty+site%3Amicrosoft.com) | ncrypt.dll | | +[SslGetProviderProperty](https://www.google.com/search?num=5&q=SslGetProviderProperty+site%3Amicrosoft.com) | ncrypt.dll | | +[SslHashHandshake](https://www.google.com/search?num=5&q=SslHashHandshake+site%3Amicrosoft.com) | ncrypt.dll | | +[SslImportKey](https://www.google.com/search?num=5&q=SslImportKey+site%3Amicrosoft.com) | ncrypt.dll | | +[SslImportMasterKey](https://www.google.com/search?num=5&q=SslImportMasterKey+site%3Amicrosoft.com) | ncrypt.dll | | +[SslIncrementProviderReferenceCount](https://www.google.com/search?num=5&q=SslIncrementProviderReferenceCount+site%3Amicrosoft.com) | ncrypt.dll | | +[SslLookupCipherLengths](https://www.google.com/search?num=5&q=SslLookupCipherLengths+site%3Amicrosoft.com) | ncrypt.dll | | +[SslLookupCipherSuiteInfo](https://www.google.com/search?num=5&q=SslLookupCipherSuiteInfo+site%3Amicrosoft.com) | ncrypt.dll | | +[SslOpenPrivateKey](https://www.google.com/search?num=5&q=SslOpenPrivateKey+site%3Amicrosoft.com) | ncrypt.dll | | +[SslOpenProvider](https://www.google.com/search?num=5&q=SslOpenProvider+site%3Amicrosoft.com) | ncrypt.dll | | +[SslSignHash](https://www.google.com/search?num=5&q=SslSignHash+site%3Amicrosoft.com) | ncrypt.dll | | +[SslVerifySignature](https://www.google.com/search?num=5&q=SslVerifySignature+site%3Amicrosoft.com) | ncrypt.dll | | +[TokenBindingDeleteAllBindings](http://msdn2.microsoft.com/en-us/library/0446F62F-96B4-4F4B-9789-0CD12173E601) | tokenbinding.dll | tokenbinding.h | Vanara.PInvoke.TokenBinding.TokenBindingDeleteAllBindings +[TokenBindingDeleteBinding](http://msdn2.microsoft.com/en-us/library/4258CC92-580E-403C-9AE4-4BB726255464) | tokenbinding.dll | tokenbinding.h | Vanara.PInvoke.TokenBinding.TokenBindingDeleteBinding +[TokenBindingGenerateBinding](http://msdn2.microsoft.com/en-us/library/4289E3F0-17AC-485B-A326-2C8BECD5CABB) | tokenbinding.dll | tokenbinding.h | Vanara.PInvoke.TokenBinding.TokenBindingGenerateBinding +[TokenBindingGenerateID](http://msdn2.microsoft.com/en-us/library/F3E30DF8-2A1D-445E-914B-62999428BB6F) | tokenbinding.dll | tokenbinding.h | Vanara.PInvoke.TokenBinding.TokenBindingGenerateID +[TokenBindingGenerateMessage](http://msdn2.microsoft.com/en-us/library/7A268C6D-952B-482A-835D-89D6452D986D) | tokenbinding.dll | tokenbinding.h | Vanara.PInvoke.TokenBinding.TokenBindingGenerateMessage +[TokenBindingGetKeyTypesClient](http://msdn2.microsoft.com/en-us/library/583687B6-5A87-4616-A5EE-4FECFF06749E) | tokenbinding.dll | tokenbinding.h | Vanara.PInvoke.TokenBinding.TokenBindingGetKeyTypesClient +[TokenBindingGetKeyTypesServer](http://msdn2.microsoft.com/en-us/library/8ABAC0AF-AF68-4742-9C36-3FB17D303409) | tokenbinding.dll | tokenbinding.h | Vanara.PInvoke.TokenBinding.TokenBindingGetKeyTypesServer +[TokenBindingVerifyMessage](http://msdn2.microsoft.com/en-us/library/D6827DA3-75DC-4F31-B57A-4ED5B5F03112) | tokenbinding.dll | tokenbinding.h | Vanara.PInvoke.TokenBinding.TokenBindingVerifyMessage ### Structures Native Structure | Header | Managed Structure --- | --- | --- -[CERT_CONTEXT](https://www.google.com/search?num=5&q=CERT_CONTEXT+site%3Amicrosoft.com) | | Vanara.PInvoke.Crypt32+CERT_CONTEXT -[CERT_EXTENSION](https://www.google.com/search?num=5&q=CERT_EXTENSION+site%3Amicrosoft.com) | | Vanara.PInvoke.Crypt32+CERT_EXTENSION -[CERT_INFO](https://www.google.com/search?num=5&q=CERT_INFO+site%3Amicrosoft.com) | | Vanara.PInvoke.Crypt32+CERT_INFO -[CERT_PUBLIC_KEY_INFO](https://www.google.com/search?num=5&q=CERT_PUBLIC_KEY_INFO+site%3Amicrosoft.com) | | Vanara.PInvoke.Crypt32+CERT_PUBLIC_KEY_INFO -[CRYPT_ALGORITHM_IDENTIFIER](https://www.google.com/search?num=5&q=CRYPT_ALGORITHM_IDENTIFIER+site%3Amicrosoft.com) | | Vanara.PInvoke.Crypt32+CRYPT_ALGORITHM_IDENTIFIER -[CRYPTOAPI_BLOB](https://www.google.com/search?num=5&q=CRYPTOAPI_BLOB+site%3Amicrosoft.com) | | Vanara.PInvoke.Crypt32+CRYPTOAPI_BLOB +[BCRYPT_ALG_HANDLE](https://www.google.com/search?num=5&q=BCRYPT_ALG_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.BCrypt+BCRYPT_ALG_HANDLE +[BCRYPT_ALGORITHM_IDENTIFIER](http://msdn2.microsoft.com/en-us/library/a49a21c9-5668-4709-b52a-f6cacd944845) | bcrypt.h | Vanara.PInvoke.BCrypt+BCRYPT_ALGORITHM_IDENTIFIER +[BCRYPT_HANDLE](https://www.google.com/search?num=5&q=BCRYPT_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.BCrypt+BCRYPT_HANDLE +[BCRYPT_HASH_HANDLE](https://www.google.com/search?num=5&q=BCRYPT_HASH_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.BCrypt+BCRYPT_HASH_HANDLE +[BCRYPT_KEY_HANDLE](https://www.google.com/search?num=5&q=BCRYPT_KEY_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.BCrypt+BCRYPT_KEY_HANDLE +[BCRYPT_MULTI_HASH_OPERATION](http://msdn2.microsoft.com/en-us/library/B0418A07-D2EE-4346-9971-676C8FB08FAA) | bcrypt.h | Vanara.PInvoke.BCrypt+BCRYPT_MULTI_HASH_OPERATION +[BCRYPT_OAEP_PADDING_INFO](http://msdn2.microsoft.com/en-us/library/19f48f2d-e952-4a01-8112-f298c79919b2) | bcrypt.h | Vanara.PInvoke.BCrypt+BCRYPT_OAEP_PADDING_INFO +[BCRYPT_PKCS1_PADDING_INFO](http://msdn2.microsoft.com/en-us/library/920fa461-5b7e-4429-972d-e7c83fb62c64) | bcrypt.h | Vanara.PInvoke.BCrypt+BCRYPT_PKCS1_PADDING_INFO +[BCRYPT_PROVIDER_NAME](http://msdn2.microsoft.com/en-us/library/0c57aa3f-1d9a-4bb2-b142-bce9c054e658) | bcrypt.h | Vanara.PInvoke.BCrypt+BCRYPT_PROVIDER_NAME +[BCRYPT_PSS_PADDING_INFO](http://msdn2.microsoft.com/en-us/library/28605b34-b1e1-4460-a8f0-b0fe9f9b94d4) | bcrypt.h | Vanara.PInvoke.BCrypt+BCRYPT_PSS_PADDING_INFO +[BCRYPT_SECRET_HANDLE](https://www.google.com/search?num=5&q=BCRYPT_SECRET_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.BCrypt+BCRYPT_SECRET_HANDLE +[CERT_CONTEXT](https://www.google.com/search?num=5&q=CERT_CONTEXT+site%3Amicrosoft.com) | wincrypt.h | Vanara.PInvoke.Crypt32+CERT_CONTEXT +[CERT_EXTENSION](https://www.google.com/search?num=5&q=CERT_EXTENSION+site%3Amicrosoft.com) | wincrypt.h | Vanara.PInvoke.Crypt32+CERT_EXTENSION +[CERT_INFO](https://www.google.com/search?num=5&q=CERT_INFO+site%3Amicrosoft.com) | wincrypt.h | Vanara.PInvoke.Crypt32+CERT_INFO +[CERT_PUBLIC_KEY_INFO](https://www.google.com/search?num=5&q=CERT_PUBLIC_KEY_INFO+site%3Amicrosoft.com) | wincrypt.h | Vanara.PInvoke.Crypt32+CERT_PUBLIC_KEY_INFO +[CRYPT_ALGORITHM_IDENTIFIER](https://www.google.com/search?num=5&q=CRYPT_ALGORITHM_IDENTIFIER+site%3Amicrosoft.com) | wincrypt.h | Vanara.PInvoke.Crypt32+CRYPT_ALGORITHM_IDENTIFIER +[CRYPT_CONTEXT_CONFIG](http://msdn2.microsoft.com/en-us/library/3e07b7ae-84ef-4b77-bd49-d96906eaa4f8) | bcrypt.h | Vanara.PInvoke.BCrypt+CRYPT_CONTEXT_CONFIG +[CRYPT_CONTEXT_FUNCTION_CONFIG](http://msdn2.microsoft.com/en-us/library/53026095-c871-4027-ac7d-428f1cb4aafe) | bcrypt.h | Vanara.PInvoke.BCrypt+CRYPT_CONTEXT_FUNCTION_CONFIG +[CRYPT_CONTEXT_FUNCTION_PROVIDERS](http://msdn2.microsoft.com/en-us/library/5e175ac2-38eb-44c4-a01a-fb436e833546) | bcrypt.h | Vanara.PInvoke.BCrypt+CRYPT_CONTEXT_FUNCTION_PROVIDERS +[CRYPT_CONTEXT_FUNCTIONS](http://msdn2.microsoft.com/en-us/library/c576f39c-a03a-47aa-90b7-500736070c6f) | bcrypt.h | Vanara.PInvoke.BCrypt+CRYPT_CONTEXT_FUNCTIONS +[CRYPT_CONTEXTS](http://msdn2.microsoft.com/en-us/library/a1b60660-a4c5-4880-8cd4-48d8717c77c3) | bcrypt.h | Vanara.PInvoke.BCrypt+CRYPT_CONTEXTS +[CRYPT_PROVIDERS](http://msdn2.microsoft.com/en-us/library/aef0e173-d3df-466e-ac2a-c686cae5edc9) | bcrypt.h | Vanara.PInvoke.BCrypt+CRYPT_PROVIDERS +[CRYPTOAPI_BLOB](https://www.google.com/search?num=5&q=CRYPTOAPI_BLOB+site%3Amicrosoft.com) | wincrypt.h | Vanara.PInvoke.Crypt32+CRYPTOAPI_BLOB +[NCRYPT_ALLOC_PARA](http://msdn2.microsoft.com/en-us/library/4F546F51-E4DE-4703-B1D1-F84165C3C31B) | ncrypt.h | Vanara.PInvoke.NCrypt+NCRYPT_ALLOC_PARA +[NCRYPT_DESCRIPTOR_HANDLE](https://www.google.com/search?num=5&q=NCRYPT_DESCRIPTOR_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.NCrypt+NCRYPT_DESCRIPTOR_HANDLE +[NCRYPT_HANDLE](https://www.google.com/search?num=5&q=NCRYPT_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.NCrypt+NCRYPT_HANDLE +[NCRYPT_KEY_HANDLE](https://www.google.com/search?num=5&q=NCRYPT_KEY_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.NCrypt+NCRYPT_KEY_HANDLE +[NCRYPT_PROTECT_STREAM_INFO](http://msdn2.microsoft.com/en-us/library/77FADFC1-6C66-4801-B0BD-263963555C3C) | ncryptprotect.h | Vanara.PInvoke.NCrypt+NCRYPT_PROTECT_STREAM_INFO +[NCRYPT_PROTECT_STREAM_INFO_EX](https://www.google.com/search?num=5&q=NCRYPT_PROTECT_STREAM_INFO_EX+site%3Amicrosoft.com) | ncryptprotect.h | Vanara.PInvoke.NCrypt+NCRYPT_PROTECT_STREAM_INFO_EX +[NCRYPT_PROV_HANDLE](https://www.google.com/search?num=5&q=NCRYPT_PROV_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.NCrypt+NCRYPT_PROV_HANDLE +[NCRYPT_SECRET_HANDLE](https://www.google.com/search?num=5&q=NCRYPT_SECRET_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.NCrypt+NCRYPT_SECRET_HANDLE +[NCRYPT_STREAM_HANDLE](https://www.google.com/search?num=5&q=NCRYPT_STREAM_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.NCrypt+NCRYPT_STREAM_HANDLE +[NCryptBuffer](http://msdn2.microsoft.com/en-us/library/474d3c0d-ae14-448a-a56d-25abc7e5de88) | bcrypt.h | Vanara.PInvoke.NCrypt+NCryptBuffer +[NCryptBufferDesc](http://msdn2.microsoft.com/en-us/library/aa375370) | Bcrypt.h | Vanara.PInvoke.NCrypt+NCryptBufferDesc +[TOKENBINDING_IDENTIFIER](http://msdn2.microsoft.com/en-us/library/301E099E-B621-41E1-BF9B-3AF8C53F9227) | tokenbinding.h | Vanara.PInvoke.TokenBinding+TOKENBINDING_IDENTIFIER +[TOKENBINDING_KEY_TYPES](http://msdn2.microsoft.com/en-us/library/E5029CE3-CD23-4566-A951-35374DC7BC57) | tokenbinding.h | Vanara.PInvoke.TokenBinding+TOKENBINDING_KEY_TYPES +[TOKENBINDING_RESULT_DATA](http://msdn2.microsoft.com/en-us/library/6C34E174-CCC4-451D-82C3-C410C8C92C8C) | tokenbinding.h | Vanara.PInvoke.TokenBinding+TOKENBINDING_RESULT_DATA +[TOKENBINDING_RESULT_LIST](http://msdn2.microsoft.com/en-us/library/D14CBEA3-5F46-4C45-8C11-407D6E70FD56) | tokenbinding.h | Vanara.PInvoke.TokenBinding+TOKENBINDING_RESULT_LIST diff --git a/PInvoke/Crypt32/Wincrypt.cs b/PInvoke/Cryptography/Crypt32/Wincrypt.cs similarity index 56% rename from PInvoke/Crypt32/Wincrypt.cs rename to PInvoke/Cryptography/Crypt32/Wincrypt.cs index 4c4d0365..a949b806 100644 --- a/PInvoke/Crypt32/Wincrypt.cs +++ b/PInvoke/Cryptography/Crypt32/Wincrypt.cs @@ -8,11 +8,22 @@ namespace Vanara.PInvoke /// Methods and data types found in Crypt32.dll. public static partial class Crypt32 { + /// Private key pair type. + [PInvokeData("wincrypt.h")] + public enum PrivateKeyType + { + /// Key exchange + AT_KEYEXCHANGE = 1, + /// Digital signature + AT_SIGNATURE = 2 + } + /// /// The CERT_CONTEXT structure contains both the encoded and decoded representations of a certificate. A certificate context returned /// by one of the functions defined in Wincrypt.h must be freed by calling the CertFreeCertificateContext function. The /// CertDuplicateCertificateContext function can be called to make a duplicate copy (which also must be freed by calling CertFreeCertificateContext). /// + [PInvokeData("wincrypt.h")] [StructLayout(LayoutKind.Sequential)] public struct CERT_CONTEXT { @@ -39,6 +50,7 @@ namespace Vanara.PInvoke /// The CERT_EXTENSION structure contains the extension information for a certificate, Certificate Revocation List (CRL) or /// Certificate Trust List (CTL). /// + [PInvokeData("wincrypt.h")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct CERT_EXTENSION { @@ -63,6 +75,7 @@ namespace Vanara.PInvoke } /// The CERT_INFO structure contains the information of a certificate. + [PInvokeData("wincrypt.h")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct CERT_INFO { @@ -126,6 +139,7 @@ namespace Vanara.PInvoke } /// The CERT_PUBLIC_KEY_INFO structure contains a public key and its algorithm. + [PInvokeData("wincrypt.h")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct CERT_PUBLIC_KEY_INFO { @@ -141,6 +155,7 @@ namespace Vanara.PInvoke /// identifier (OID) of the algorithm and any needed parameters for that algorithm. The parameters contained in its CRYPT_OBJID_BLOB /// are encoded. /// + [PInvokeData("wincrypt.h")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct CRYPT_ALGORITHM_IDENTIFIER { @@ -158,6 +173,7 @@ namespace Vanara.PInvoke /// The BLOB structure contains an arbitrary array of bytes. The structure definition includes aliases appropriate to the various /// functions that use it. /// + [PInvokeData("wincrypt.h")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct CRYPTOAPI_BLOB { @@ -167,5 +183,210 @@ namespace Vanara.PInvoke /// A pointer to the data buffer. public IntPtr pbData; } + + /*CertAddCertificateContextToStore + CertAddCertificateLinkToStore + CertAddCRLContextToStore + CertAddCRLLinkToStore + CertAddCTLContextToStore + CertAddCTLLinkToStore + CertAddEncodedCertificateToStore + CertAddEncodedCertificateToSystemStore + CertAddEncodedCRLToStore + CertAddEncodedCTLToStore + CertAddEnhancedKeyUsageIdentifier + CertAddRefServerOcspResponse + CertAddRefServerOcspResponseContext + CertAddSerializedElementToStore + CertAddStoreToCollection + CertAlgIdToOID + CertCloseServerOcspResponse + CertCloseStore + CertCompareCertificate + CertCompareCertificateName + CertCompareIntegerBlob + CertComparePublicKeyInfo + CertControlStore + CertCreateCertificateChainEngine + CertCreateCertificateContext + CertCreateContext + CertCreateCRLContext + CertCreateCTLContext + CertCreateCTLEntryFromCertificateContextProperties + CertCreateSelfSignCertificate + CertDeleteCertificateFromStore + CertDeleteCRLFromStore + CertDeleteCTLFromStore + CertDuplicateCertificateChain + CertDuplicateCertificateContext + CertDuplicateCRLContext + CertDuplicateCTLContext + CertDuplicateStore + CertEnumCertificateContextProperties + CertEnumCertificatesInStore + CertEnumCRLContextProperties + CertEnumCRLsInStore + CertEnumCTLContextProperties + CertEnumCTLsInStore + CertEnumPhysicalStore + CertEnumSubjectInSortedCTL + CertEnumSystemStore + CertEnumSystemStoreLocation + CertFindAttribute + CertFindCertificateInCRL + CertFindCertificateInStore + CertFindChainInStore + CertFindCRLInStore + CertFindCTLInStore + CertFindExtension + CertFindRDNAttr + CertFindSubjectInCTL + CertFindSubjectInSortedCTL + CertFreeCertificateChain + CertFreeCertificateChainEngine + CertFreeCertificateChainList + CertFreeCertificateContext + CertFreeCRLContext + CertFreeCTLContext + CertFreeServerOcspResponseContext + CertGetCertificateChain + CertGetCertificateContextProperty + CertGetCRLContextProperty + CertGetCRLFromStore + CertGetCTLContextProperty + CertGetEnhancedKeyUsage + CertGetIntendedKeyUsage + CertGetIssuerCertificateFromStore + CertGetNameString + CertGetPublicKeyLength + CertGetServerOcspResponseContext + CertGetStoreProperty + CertGetSubjectCertificateFromStore + CertGetValidUsages + CertIsRDNAttrsInCertificateName + CertIsStrongHashToSign + CertIsValidCRLForCertificate + CertNameToStr + CertOIDToAlgId + CertOpenServerOcspResponse + CertOpenStore + CertOpenSystemStore + CertRDNValueToStr + CertRegisterPhysicalStore + CertRegisterSystemStore + CertRemoveEnhancedKeyUsageIdentifier + CertRemoveStoreFromCollection + CertResyncCertificateChainEngine + CertRetrieveLogoOrBiometricInfo + CertSaveStore + CertSelectCertificateChains + CertSerializeCertificateStoreElement + CertSerializeCRLStoreElement + CertSerializeCTLStoreElement + CertSetCertificateContextPropertiesFromCTLEntry + CertSetCertificateContextProperty + CertSetCRLContextProperty + CertSetCTLContextProperty + CertSetEnhancedKeyUsage + CertSetStoreProperty + CertStrToName + CertUnregisterPhysicalStore + CertUnregisterSystemStore + CertVerifyCertificateChainPolicy + CertVerifyCRLRevocation + CertVerifyCRLTimeValidity + CertVerifyCTLUsage + CertVerifyRevocation + CertVerifySubjectCertificateContext + CertVerifyTimeValidity + CertVerifyValidityNesting + CryptAcquireCertificatePrivateKey + CryptBinaryToString + CryptCreateKeyIdentifierFromCSP + CryptDecodeMessage + CryptDecodeObject + CryptDecodeObjectEx + CryptDecryptAndVerifyMessageSignature + CryptDecryptMessage + CryptEncodeObject + CryptEncodeObjectEx + CryptEncryptMessage + CryptEnumKeyIdentifierProperties + CryptEnumOIDFunction + CryptEnumOIDInfo + CryptExportPublicKeyInfo + CryptExportPublicKeyInfoEx + CryptExportPublicKeyInfoFromBCryptKeyHandle + CryptFindCertificateKeyProvInfo + CryptFindLocalizedName + CryptFindOIDInfo + CryptFormatObject + CryptFreeOIDFunctionAddress + CryptGetDefaultOIDDllList + CryptGetDefaultOIDFunctionAddress + CryptGetKeyIdentifierProperty + CryptGetMessageCertificates + CryptGetMessageSignerCount + CryptGetOIDFunctionAddress + CryptGetOIDFunctionValue + CryptHashCertificate + CryptHashCertificate2 + CryptHashMessage + CryptHashPublicKeyInfo + CryptHashToBeSigned + CryptImportPublicKeyInfo + CryptImportPublicKeyInfoEx + CryptImportPublicKeyInfoEx2 + CryptInitOIDFunctionSet + CryptInstallDefaultContext + CryptInstallOIDFunctionAddress + CryptMemAlloc + CryptMemFree + CryptMemRealloc + CryptMsgCalculateEncodedLength + CryptMsgClose + CryptMsgControl + CryptMsgCountersign + CryptMsgCountersignEncoded + CryptMsgDuplicate + CryptMsgEncodeAndSignCTL + CryptMsgGetAndVerifySigner + CryptMsgGetParam + CryptMsgOpenToDecode + CryptMsgOpenToEncode + CryptMsgSignCTL + CryptMsgUpdate + CryptMsgVerifyCountersignatureEncoded + CryptMsgVerifyCountersignatureEncodedEx + CryptQueryObject + CryptRegisterDefaultOIDFunction + CryptRegisterOIDFunction + CryptRegisterOIDInfo + CryptRetrieveTimeStamp + CryptSetKeyIdentifierProperty + CryptSetOIDFunctionValue + CryptSignAndEncodeCertificate + CryptSignAndEncryptMessage + CryptSignCertificate + CryptSignMessage + CryptSignMessageWithKey + CryptStringToBinary + CryptUninstallDefaultContext + CryptUnregisterDefaultOIDFunction + CryptUnregisterOIDFunction + CryptUnregisterOIDInfo + CryptVerifyCertificateSignature + CryptVerifyCertificateSignatureEx + CryptVerifyDetachedMessageHash + CryptVerifyDetachedMessageSignature + CryptVerifyMessageHash + CryptVerifyMessageSignature + CryptVerifyMessageSignatureWithKey + CryptVerifyTimeStampSignature + PFXExportCertStore + PFXExportCertStoreEx + PFXImportCertStore + PFXIsPFXBlob + PFXVerifyPassword*/ } } \ No newline at end of file diff --git a/PInvoke/Cryptography/Crypt32/dpapi.cs b/PInvoke/Cryptography/Crypt32/dpapi.cs new file mode 100644 index 00000000..17a9e6d8 --- /dev/null +++ b/PInvoke/Cryptography/Crypt32/dpapi.cs @@ -0,0 +1,7 @@ +/* +CryptProtectData +CryptProtectMemory +CryptUnprotectData +CryptUnprotectMemory +CryptUpdateProtectedState +*/ \ No newline at end of file diff --git a/PInvoke/Cryptography/Crypt32/mssip.cs b/PInvoke/Cryptography/Crypt32/mssip.cs new file mode 100644 index 00000000..100fb3bd --- /dev/null +++ b/PInvoke/Cryptography/Crypt32/mssip.cs @@ -0,0 +1,13 @@ +/* +CryptSIPAddProvider +CryptSIPCreateIndirectData +CryptSIPGetCaps +CryptSIPGetSignedDataMsg +CryptSIPLoad +CryptSIPPutSignedDataMsg +CryptSIPRemoveProvider +CryptSIPRemoveSignedDataMsg +CryptSIPRetrieveSubjectGuid +CryptSIPRetrieveSubjectGuidForCatalogFile +CryptSIPVerifyIndirectData +*/ \ No newline at end of file diff --git a/PInvoke/Cryptography/NCrypt/NCrypt.cs b/PInvoke/Cryptography/NCrypt/NCrypt.cs new file mode 100644 index 00000000..43162fd2 --- /dev/null +++ b/PInvoke/Cryptography/NCrypt/NCrypt.cs @@ -0,0 +1,3295 @@ +using System; +using System.Linq; +using System.Runtime.InteropServices; +using Vanara.Extensions; +using Vanara.InteropServices; + +namespace Vanara.PInvoke +{ + /// Methods and data types found in NCrypt.dll. + public static partial class NCrypt + { + [UnmanagedFunctionPointer(CallingConvention.Winapi)] + public delegate IntPtr PFN_NCRYPT_ALLOC(SizeT cbSize); + + [UnmanagedFunctionPointer(CallingConvention.Winapi)] + public delegate void PFN_NCRYPT_FREE(IntPtr pv); + + public enum BufferType + { + /// + /// The buffer is a key derivation function (KDF) parameter that contains a null-terminated Unicode string that identifies the + /// hash algorithm. This can be one of the standard hash algorithm identifiers from CNG Algorithm Identifiers or the identifier + /// for another registered hash algorithm. + /// The size specified by the cbBuffer member of this structure must include the terminating NULL character. + /// + KDF_HASH_ALGORITHM = 0, + + /// + /// The buffer is a KDF parameter that contains the value to add to the beginning of the message input to the hash function. + /// + KDF_SECRET_PREPEND = 1, + + /// The buffer is a KDF parameter that contains the value to add to the end of the message input to the hash function. + KDF_SECRET_APPEND = 2, + + /// The buffer is a KDF parameter that contains the plain text value of the HMAC key. + KDF_HMAC_KEY = 3, + + /// + /// The buffer is a KDF parameter that contains an ANSI string that contains the transport layer security (TLS) pseudo-random + /// function (PRF) label. + /// + KDF_TLS_PRF_LABEL = 4, + + /// The buffer is a KDF parameter that contains the PRF seed value. The seed must be 64 bytes long. + KDF_TLS_PRF_SEED = 5, + + /// + /// The buffer is a KDF parameter that contains the secret agreement handle. The pvBuffer member contains a BCRYPT_SECRET_HANDLE + /// value and is not a pointer. + /// + KDF_SECRET_HANDLE = 6, + + /// + /// The buffer is a KDF parameter that contains a DWORD value identifying the SSL/TLS protocol version whose PRF algorithm is to + /// be used. + /// + KDF_TLS_PRF_PROTOCOL = 7, + + /// + /// The buffer is a KDF parameter that contains the byte array to use as the AlgorithmID subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + KDF_ALGORITHMID = 8, + + /// + /// The buffer is a KDF parameter that contains the byte array to use as the PartyUInfo subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + KDF_PARTYUINFO = 9, + + /// + /// The buffer is a KDF parameter that contains the byte array to use as the PartyVInfo subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + KDF_PARTYVINFO = 10, + + /// + /// The buffer is a KDF parameter that contains the byte array to use as the SuppPubInfo subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + KDF_SUPPPUBINFO = 11, + + /// + /// The buffer is a KDF parameter that contains the byte array to use as the SuppPrivInfo subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + KDF_SUPPPRIVINFO = 12, + + /// Undocumented. + KDF_LABEL = 0xD, + + /// Undocumented. + KDF_CONTEXT = 0xE, + + /// Undocumented. + KDF_SALT = 0xF, + + /// Undocumented. + KDF_ITERATION_COUNT = 0x10, + + /// Undocumented. + KDF_GENERIC_PARAMETER = 0x11, + + /// Undocumented. + KDF_KEYBITLENGTH = 0x12, + + /// Undocumented. + KDF_HKDF_SALT = 0x13, + + /// Undocumented. + KDF_HKDF_INFO = 0x14, + + /// The buffer contains the random number of the SSL client. + NCRYPTBUFFER_SSL_CLIENT_RANDOM = 20, + + /// The buffer contains the random number of the SSL server. + NCRYPTBUFFER_SSL_SERVER_RANDOM = 21, + + /// The buffer contains the highest SSL version supported. + NCRYPTBUFFER_SSL_HIGHEST_VERSION = 22, + + /// The buffer contains the clear portion of the SSL master key. + NCRYPTBUFFER_SSL_CLEAR_KEY = 23, + + /// The buffer contains the SSL key argument data. + NCRYPTBUFFER_SSL_KEY_ARG_DATA = 24, + + /// Undocumented. + NCRYPTBUFFER_SSL_SESSION_HASH = 25, + + /// The buffer contains a null-terminated ANSI string that contains the PKCS object identifier. + NCRYPTBUFFER_PKCS_OID = 40, + + /// The buffer contains a null-terminated ANSI string that contains the PKCS algorithm object identifier. + NCRYPTBUFFER_PKCS_ALG_OID = 41, + + /// The buffer contains the PKCS algorithm parameters. + NCRYPTBUFFER_PKCS_ALG_PARAM = 42, + + /// The buffer contains the PKCS algorithm identifier. + NCRYPTBUFFER_PKCS_ALG_ID = 43, + + /// The buffer contains the PKCS attributes. + NCRYPTBUFFER_PKCS_ATTRS = 44, + + /// The buffer contains a null-terminated Unicode string that contains the key name. + NCRYPTBUFFER_PKCS_KEY_NAME = 45, + + /// + /// The buffer contains a null-terminated Unicode string that contains the PKCS8 password. This parameter is optional and can be NULL. + /// + NCRYPTBUFFER_PKCS_SECRET = 46, + + /// + /// The buffer contains a serialized certificate store that contains the PKCS certificate. This serialized store is obtained by + /// using the CertSaveStore function with the CERT_STORE_SAVE_TO_MEMORY option. When this property is being retrieved, you can + /// access the certificate store by passing this serialized store to the CertOpenStore function with the + /// CERT_STORE_PROV_SERIALIZED option. + /// + NCRYPTBUFFER_CERT_BLOB = 47, + + /// Undocumented. + NCRYPTBUFFER_CLAIM_IDBINDING_NONCE = 48, + + /// Undocumented. + NCRYPTBUFFER_CLAIM_KEYATTESTATION_NONCE = 49, + + /// Undocumented. + NCRYPTBUFFER_KEY_PROPERTY_FLAGS = 50, + + /// Undocumented. + NCRYPTBUFFER_ATTESTATIONSTATEMENT_BLOB = 51, + + /// Undocumented. + NCRYPTBUFFER_ATTESTATION_CLAIM_TYPE = 52, + + /// Undocumented. + NCRYPTBUFFER_ATTESTATION_CLAIM_CHALLENGE_REQUIRED = 53, + + /// Undocumented. + NCRYPTBUFFER_VSM_KEY_ATTESTATION_CLAIM_RESTRICTIONS = 54, + + /// Undocumented. + NCRYPTBUFFER_ECC_CURVE_NAME = 60, + + /// Undocumented. + NCRYPTBUFFER_ECC_PARAMETERS = 61, + + /// Undocumented. + NCRYPTBUFFER_TPM_SEAL_PASSWORD = 70, + + /// Undocumented. + NCRYPTBUFFER_TPM_SEAL_POLICYINFO = 71, + + /// Undocumented. + NCRYPTBUFFER_TPM_SEAL_TICKET = 72, + + /// Undocumented. + NCRYPTBUFFER_TPM_SEAL_NO_DA_PROTECTION = 73, + + /// Undocumented. + NCRYPTBUFFER_TPM_PLATFORM_CLAIM_PCR_MASK = 80, + + /// Undocumented. + NCRYPTBUFFER_TPM_PLATFORM_CLAIM_NONCE = 81, + + /// Undocumented. + NCRYPTBUFFER_TPM_PLATFORM_CLAIM_STATIC_CREATE = 82, + } + + /// Flags used with NCryptCreatePersistedKey. + [Flags] + public enum CreatePersistedFlags + { + /// The key applies to the local computer. If this flag is not present, the key applies to the current user. + NCRYPT_MACHINE_KEY_FLAG = 0x00000020, + + /// + /// If a key already exists in the container with the specified name, the existing key will be overwritten. If this flag is not + /// specified and a key with the specified name already exists, this function will return NTE_EXISTS. + /// + NCRYPT_OVERWRITE_KEY_FLAG = 0x00000080, + } + + /// Flags for NCryptDeleteKey. + [Flags] + public enum DeleteKeyFlags : uint + { + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, + /// the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + NCRYPT_SILENT_FLAG = 0x00000040, + } + + /// Flags for NCryptExportKey. + [PInvokeData("ncrypt.h", MSDNShortId = "1588eb29-4026-4d1c-8bee-a035df38444a")] + [Flags] + public enum ExportKeyFlags + { + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, + /// the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + NCRYPT_SILENT_FLAG = 0x00000040, + } + + [Flags] + public enum ExportPolicy + { + NCRYPT_ALLOW_EXPORT_FLAG = 0x00000001, + NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG = 0x00000002, + NCRYPT_ALLOW_ARCHIVING_FLAG = 0x00000004, + NCRYPT_ALLOW_PLAINTEXT_ARCHIVING_FLAG = 0x00000008, + } + + /// Flags for NCryptFinalizeKey. + [PInvokeData("ncrypt.h", MSDNShortId = "4386030d-4ce6-4b2e-adc5-a15ddc869349")] + [Flags] + public enum FinalizeKeyFlags + { + /// + /// Also save the key in legacy storage. This allows the key to be used with CryptoAPI. This flag only applies to RSA keys. + /// + NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG = 0x00000200, + + /// Do not validate the public portion of the key pair. This flag only applies to public/private key pairs. + NCRYPT_NO_KEY_VALIDATION = 0x00000008, + + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, + /// the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + NCRYPT_SILENT_FLAG = 0x00000040, + } + + [Flags] + public enum ImplType + { + NCRYPT_IMPL_HARDWARE_FLAG = 0x00000001, + NCRYPT_IMPL_SOFTWARE_FLAG = 0x00000002, + NCRYPT_IMPL_REMOVABLE_FLAG = 0x00000008, + NCRYPT_IMPL_HARDWARE_RNG_FLAG = 0x00000010, + NCRYPT_IMPL_VIRTUAL_ISOLATION_FLAG = 0x00000020, + } + + /// Flags for NCryptImportKey. + [PInvokeData("ncrypt.h", MSDNShortId = "ede0e7e0-cb2c-44c0-b724-58db3480b781")] + [Flags] + public enum ImportKeyFlags + { + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, + /// the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + NCRYPT_SILENT_FLAG = 0x00000040, + } + + [Flags] + public enum KeyUsage + { + NCRYPT_ALLOW_DECRYPT_FLAG = 0x00000001, + NCRYPT_ALLOW_SIGNING_FLAG = 0x00000002, + NCRYPT_ALLOW_KEY_AGREEMENT_FLAG = 0x00000004, + NCRYPT_ALLOW_KEY_IMPORT_FLAG = 0x00000008, + NCRYPT_ALLOW_ALL_USAGES = 0x00ffffff, + } + + /// Flags used with NCryptOpenKey. + [Flags] + public enum OpenKeyFlags + { + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, + /// the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + NCRYPT_SILENT_FLAG = 0x00000040, + + /// Open the key for the local computer. If this flag is not present, the current user key is opened. + NCRYPT_MACHINE_KEY_FLAG = 0x00000020, + } + + /// Flags for NCryptSecretAgreement. + [PInvokeData("ncrypt.h")] + [Flags] + public enum SecretAgreementFlags + { + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, + /// the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + NCRYPT_SILENT_FLAG = 0x00000040, + } + + /// Used by NCryptSetProperty. + [PInvokeData("ncrypt.h", MSDNShortId = "ad1148aa-5f64-4867-9e17-6b41cc0c20b7")] + [Flags] + public enum SetPropFlags : uint + { + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, + /// the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + NCRYPT_SILENT_FLAG = 0x00000040, + + /// + /// Do not overwrite any built-in values for this property and only set the user-persisted properties of the key. The maximum + /// size of the data for any persisted property is NCRYPT_MAX_PROPERTY_DATA bytes. This flag cannot be used with the + /// NCRYPT_SECURITY_DESCR_PROPERTY property. + /// + NCRYPT_PERSIST_ONLY_FLAG = 0x40000000, + + /// + /// The property should be stored in key storage along with the key material. This flag can only be used when the hObject + /// parameter is the handle of a persisted key. The maximum size of the data for any persisted property is + /// NCRYPT_MAX_PROPERTY_DATA bytes. + /// + NCRYPT_PERSIST_FLAG = 0x80000000, + } + + [Flags] + public enum UIPolicy + { + NCRYPT_UI_PROTECT_KEY_FLAG = 0x00000001, + NCRYPT_UI_FORCE_HIGH_PROTECTION_FLAG = 0x00000002, + NCRYPT_UI_FINGERPRINT_PROTECTION_FLAG = 0x00000004, + NCRYPT_UI_APPCONTAINER_ACCESS_MEDIUM_FLAG = 0x00000008, + } + + [Flags] + private enum EncryptFlags : uint + { + NCRYPT_NO_PADDING_FLAG = 0x00000001, + NCRYPT_PAD_PKCS1_FLAG = 0x00000002, + NCRYPT_PAD_OAEP_FLAG = 0x00000004, + NCRYPT_PAD_PSS_FLAG = 0x00000008, + NCRYPT_PAD_CIPHER_FLAG = 0x00000010, + NCRYPT_ATTESTATION_FLAG = 0x00000020, + NCRYPT_SEALING_FLAG = 0x00000100, + } + + [Flags] + private enum NFlags : uint + { + NCRYPT_NAMED_DESCRIPTOR_FLAG = 0x00000001, + NCRYPT_REGISTER_NOTIFY_FLAG = 0x00000001, + NCRYPT_UNREGISTER_NOTIFY_FLAG = 0x00000002, + NCRYPT_MACHINE_KEY_FLAG = 0x00000020, + NCRYPT_OVERWRITE_KEY_FLAG = 0x00000080, + NCRYPT_DO_NOT_FINALIZE_FLAG = 0x00000400, + NCRYPT_EXPORT_LEGACY_FLAG = 0x00000800, + NCRYPT_IGNORE_DEVICE_STATE_FLAG = 0x00001000, + NCRYPT_TREAT_NIST_AS_GENERIC_ECC_FLAG = 0x00002000, + NCRYPT_NO_CACHED_PASSWORD = 0x00004000, + NCRYPT_PROTECT_TO_LOCAL_SYSTEM = 0x00008000, + NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG = 0x00000200, + NCRYPT_NO_KEY_VALIDATION = 0x00000008, + NCRYPT_SILENT_FLAG = 0x00000040, + NCRYPT_PERSIST_ONLY_FLAG = 0x40000000, + NCRYPT_PERSIST_FLAG = 0x80000000, + NCRYPT_PREFER_VIRTUAL_ISOLATION_FLAG = 0x00010000, + NCRYPT_USE_VIRTUAL_ISOLATION_FLAG = 0x00020000, + NCRYPT_USE_PER_BOOT_KEY_FLAG = 0x00040000, + } + + /// + /// The NCryptCreatePersistedKey function creates a new key and stores it in the specified key storage provider. After you + /// create a key by using this function, you can use the NCryptSetProperty function to set its properties; however, the key cannot be + /// used until the NCryptFinalizeKey function is called. + /// + /// + /// The handle of the key storage provider to create the key in. This handle is obtained by using the NCryptOpenStorageProvider function. + /// + /// + /// The address of an NCRYPT_KEY_HANDLE variable that receives the handle of the key. When you have finished using this + /// handle, release it by passing it to the NCryptFreeObject function. + /// + /// + /// A pointer to a null-terminated Unicode string that contains the identifier of the cryptographic algorithm to create the key. This + /// can be one of the standard CNG Algorithm Identifiers or the identifier for another registered algorithm. + /// + /// + /// A pointer to a null-terminated Unicode string that contains the name of the key. If this parameter is NULL, this function + /// will create an ephemeral key that is not persisted. + /// + /// + /// A legacy identifier that specifies the type of key. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// AT_KEYEXCHANGE + /// The key is a key exchange key. + /// + /// + /// AT_SIGNATURE + /// The key is a signature key. + /// + /// + /// 0 + /// The key is none of the above types. + /// + /// + /// + /// + /// + /// A set of flags that modify the behavior of this function. This can be zero or a combination of one or more of the following values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_MACHINE_KEY_FLAG + /// The key applies to the local computer. If this flag is not present, the key applies to the current user. + /// + /// + /// NCRYPT_OVERWRITE_KEY_FLAG + /// + /// If a key already exists in the container with the specified name, the existing key will be overwritten. If this flag is not + /// specified and a key with the specified name already exists, this function will return NTE_EXISTS. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_EXISTS + /// A key with the specified name already exists and the NCRYPT_OVERWRITE_KEY_FLAG was not specified. + /// + /// + /// NTE_INVALID_HANDLE + /// The hProvider parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// NTE_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// + /// If you are creating an RSA key pair, you can also have the key stored in legacy storage so that it can be used with the CryptoAPI + /// by passing the NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG flag to the NCryptFinalizeKey function when the key is finalized. + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptcreatepersistedkey SECURITY_STATUS + // NCryptCreatePersistedKey( NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY_HANDLE *phKey, LPCWSTR pszAlgId, LPCWSTR pszKeyName, DWORD + // dwLegacyKeySpec, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("ncrypt.h", MSDNShortId = "eeb1842f-fd9e-4edf-9db8-7b4e91760e9b")] + public static extern HRESULT NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE hProvider, out SafeNCRYPT_KEY_HANDLE phKey, string pszAlgId, [Optional] string pszKeyName, Crypt32.PrivateKeyType dwLegacyKeySpec = 0, CreatePersistedFlags dwFlags = 0); + + /// The NCryptDeleteKey function deletes a CNG key. + /// + /// The handle of the key to delete. This handle is obtained by using the NCryptOpenKey function. + /// + /// Note The NCryptDeleteKey function frees the handle. Applications must not use the handle or attempt to call the + /// NCryptFreeObject function on it after calling the NCryptDeleteKey function. + /// + /// + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of values that is specific to each key storage provider. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_INVALID_HANDLE + /// The hKey parameter is not valid. + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptdeletekey SECURITY_STATUS NCryptDeleteKey( + // NCRYPT_KEY_HANDLE hKey, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "2e1958a7-51e0-4731-b4cf-a90d6c1f9ae0")] + public static extern HRESULT NCryptDeleteKey(NCRYPT_KEY_HANDLE hKey, DeleteKeyFlags dwFlags = 0); + + /// + /// + /// The NCryptDeriveKey function derives a key from a secret agreement value. This function is intended to be used as part of + /// a secret agreement procedure using persisted secret agreement keys. To derive key material by using a persisted secret instead, + /// use the NCryptKeyDerivation function. + /// + /// + /// + /// The secret agreement handle to create the key from. This handle is obtained from the NCryptSecretAgreement function. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that identifies the key derivation function (KDF) to use to derive the key. This + /// can be one of the following strings. + /// + /// BCRYPT_KDF_HASH (L"HASH") + /// Use the hash key derivation function. + /// + /// If the cbDerivedKey parameter is less than the size of the derived key, this function will only copy the specified number of + /// bytes to the pbDerivedKey buffer. If the cbDerivedKey parameter is greater than the size of the derived key, this function will + /// copy the key to the pbDerivedKey buffer and set the variable pointed to by the pcbResult to the actual number of bytes copied. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// A null-terminated Unicode string that identifies the hash algorithm to use. This can be one of the standard hash algorithm + /// identifiers from CNG Algorithm Identifiers or the identifier for another registered hash algorithm. If this parameter is not + /// specified, the SHA1 hash algorithm is used. + /// + /// Optional + /// + /// + /// KDF_SECRET_PREPEND + /// A value to add to the beginning of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// KDF_SECRET_APPEND + /// A value to add to the end of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// + /// BCRYPT_KDF_HMAC (L"HMAC") + /// Use the Hash-Based Message Authentication Code (HMAC) key derivation function. + /// + /// If the cbDerivedKey parameter is less than the size of the derived key, this function will only copy the specified number of + /// bytes to the pbDerivedKey buffer. If the cbDerivedKey parameter is greater than the size of the derived key, this function will + /// copy the key to the pbDerivedKey buffer and set the variable pointed to by the pcbResult to the actual number of bytes copied. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// A null-terminated Unicode string that identifies the hash algorithm to use. This can be one of the standard hash algorithm + /// identifiers from CNG Algorithm Identifiers or the identifier for another registered hash algorithm. If this parameter is not + /// specified, the SHA1 hash algorithm is used. + /// + /// Optional + /// + /// + /// KDF_HMAC_KEY + /// The key to use for the pseudo-random function (PRF). + /// Optional + /// + /// + /// KDF_SECRET_PREPEND + /// A value to add to the beginning of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// KDF_SECRET_APPEND + /// A value to add to the end of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// + /// BCRYPT_KDF_TLS_PRF (L"TLS_PRF") + /// + /// Use the transport layer security (TLS) pseudo-random function (PRF) key derivation function. The size of the derived key is + /// always 48 bytes, so the cbDerivedKey parameter must be 48. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_TLS_PRF_LABEL + /// An ANSI string that contains the PRF label. + /// Required + /// + /// + /// KDF_TLS_PRF_SEED + /// The PRF seed. The seed must be 64 bytes long. + /// Required + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// + /// BCRYPT_KDF_SP80056A_CONCAT (L"SP800_56A_CONCAT") + /// Use the SP800-56A key derivation function. + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. All parameter values are treated as opaque byte arrays. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_ALGORITHMID + /// + /// Specifies the AlgorithmID subfield of the OtherInfo field in the SP800-56A key derivation function. Indicates the intended + /// purpose of the derived key. + /// + /// Required + /// + /// + /// KDF_PARTYUINFO + /// + /// Specifies the PartyUInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information contributed by the initiator. + /// + /// Required + /// + /// + /// KDF_PARTYVINFO + /// + /// Specifies the PartyVInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information contributed by the responder. + /// + /// Required + /// + /// + /// KDF_SUPPPUBINFO + /// + /// Specifies the SuppPubInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information known to both initiator and responder. + /// + /// Optional + /// + /// + /// KDF_SUPPPRIVINFO + /// + /// Specifies the SuppPrivInfo subfield of the OtherInfo field in the SP800-56A key derivation function. It contains private + /// information known to both initiator and responder, such as a shared secret. + /// + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// + /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported. + /// + /// + /// + /// The address of a NCryptBufferDesc structure that contains the KDF parameters. This parameter is optional and can be NULL + /// if it is not needed. + /// + /// + /// + /// + /// The address of a buffer that receives the key. The cbDerivedKey parameter contains the size of this buffer. If this parameter is + /// NULL, this function will place the required size, in bytes, in the DWORD pointed to by the pcbResult parameter. + /// + /// + /// + /// The size, in bytes, of the pbDerivedKey buffer. + /// + /// + /// + /// A pointer to a DWORD that receives the number of bytes that were copied to the pbDerivedKey buffer. If the pbDerivedKey + /// parameter is NULL, this function will place the required size, in bytes, in the DWORD pointed to by this parameter. + /// + /// + /// + /// A set of flags that modify the behavior of this function. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// KDF_USE_SECRET_AS_HMAC_KEY_FLAG + /// + /// The secret agreement value will also serve as the HMAC key. If this flag is specified, the KDF_HMAC_KEY parameter should not be + /// included in the set of parameters in the pParameterList parameter. This flag is only used by the BCRYPT_KDF_HMAC key derivation function. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_HANDLE + /// The hSharedSecret parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// The BCryptBufferDesc structure in the pParameterList parameter can contain more than one of the KDF_SECRET_PREPEND and + /// KDF_SECRET_APPEND parameters. If more than one of these parameters is specified, the parameter values are concatenated in + /// the order in which they are contained in the array before the KDF is called. For example, assume the following parameter values + /// are specified. + /// + /// If the above parameter values are specified, the concatenated values to the actual KDF are as follows. + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptderivekey SECURITY_STATUS NCryptDeriveKey( + // NCRYPT_SECRET_HANDLE hSharedSecret, LPCWSTR pwszKDF, NCryptBufferDesc *pParameterList, PBYTE pbDerivedKey, DWORD cbDerivedKey, + // DWORD *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "0ff08c6a-5f30-43ca-9db8-cda3e0704b0a")] + public static extern HRESULT NCryptDeriveKey(NCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc pParameterList, SafeAllocatedMemoryHandle pbDerivedKey, + uint cbDerivedKey, out uint pcbResult, BCrypt.DeriveKeyFlags dwFlags); + + /// + /// + /// The NCryptDeriveKey function derives a key from a secret agreement value. This function is intended to be used as part of + /// a secret agreement procedure using persisted secret agreement keys. To derive key material by using a persisted secret instead, + /// use the NCryptKeyDerivation function. + /// + /// + /// + /// The secret agreement handle to create the key from. This handle is obtained from the NCryptSecretAgreement function. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that identifies the key derivation function (KDF) to use to derive the key. This + /// can be one of the following strings. + /// + /// BCRYPT_KDF_HASH (L"HASH") + /// Use the hash key derivation function. + /// + /// If the cbDerivedKey parameter is less than the size of the derived key, this function will only copy the specified number of + /// bytes to the pbDerivedKey buffer. If the cbDerivedKey parameter is greater than the size of the derived key, this function will + /// copy the key to the pbDerivedKey buffer and set the variable pointed to by the pcbResult to the actual number of bytes copied. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// A null-terminated Unicode string that identifies the hash algorithm to use. This can be one of the standard hash algorithm + /// identifiers from CNG Algorithm Identifiers or the identifier for another registered hash algorithm. If this parameter is not + /// specified, the SHA1 hash algorithm is used. + /// + /// Optional + /// + /// + /// KDF_SECRET_PREPEND + /// A value to add to the beginning of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// KDF_SECRET_APPEND + /// A value to add to the end of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// + /// BCRYPT_KDF_HMAC (L"HMAC") + /// Use the Hash-Based Message Authentication Code (HMAC) key derivation function. + /// + /// If the cbDerivedKey parameter is less than the size of the derived key, this function will only copy the specified number of + /// bytes to the pbDerivedKey buffer. If the cbDerivedKey parameter is greater than the size of the derived key, this function will + /// copy the key to the pbDerivedKey buffer and set the variable pointed to by the pcbResult to the actual number of bytes copied. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_HASH_ALGORITHM + /// + /// A null-terminated Unicode string that identifies the hash algorithm to use. This can be one of the standard hash algorithm + /// identifiers from CNG Algorithm Identifiers or the identifier for another registered hash algorithm. If this parameter is not + /// specified, the SHA1 hash algorithm is used. + /// + /// Optional + /// + /// + /// KDF_HMAC_KEY + /// The key to use for the pseudo-random function (PRF). + /// Optional + /// + /// + /// KDF_SECRET_PREPEND + /// A value to add to the beginning of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// KDF_SECRET_APPEND + /// A value to add to the end of the message input to the hash function. For more information, see Remarks. + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// + /// BCRYPT_KDF_TLS_PRF (L"TLS_PRF") + /// + /// Use the transport layer security (TLS) pseudo-random function (PRF) key derivation function. The size of the derived key is + /// always 48 bytes, so the cbDerivedKey parameter must be 48. + /// + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_TLS_PRF_LABEL + /// An ANSI string that contains the PRF label. + /// Required + /// + /// + /// KDF_TLS_PRF_SEED + /// The PRF seed. The seed must be 64 bytes long. + /// Required + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// + /// BCRYPT_KDF_SP80056A_CONCAT (L"SP800_56A_CONCAT") + /// Use the SP800-56A key derivation function. + /// + /// The parameters identified by the pParameterList parameter either can or must contain the following parameters, as indicated by + /// the Required or optional column. All parameter values are treated as opaque byte arrays. + /// + /// + /// + /// Parameter + /// Description + /// Required or optional + /// + /// + /// KDF_ALGORITHMID + /// + /// Specifies the AlgorithmID subfield of the OtherInfo field in the SP800-56A key derivation function. Indicates the intended + /// purpose of the derived key. + /// + /// Required + /// + /// + /// KDF_PARTYUINFO + /// + /// Specifies the PartyUInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information contributed by the initiator. + /// + /// Required + /// + /// + /// KDF_PARTYVINFO + /// + /// Specifies the PartyVInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information contributed by the responder. + /// + /// Required + /// + /// + /// KDF_SUPPPUBINFO + /// + /// Specifies the SuppPubInfo subfield of the OtherInfo field in the SP800-56A key derivation function. The field contains public + /// information known to both initiator and responder. + /// + /// Optional + /// + /// + /// KDF_SUPPPRIVINFO + /// + /// Specifies the SuppPrivInfo subfield of the OtherInfo field in the SP800-56A key derivation function. It contains private + /// information known to both initiator and responder, such as a shared secret. + /// + /// Optional + /// + /// + /// The call to the KDF is made as shown in the following pseudocode. + /// + /// + /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported. + /// + /// + /// + /// The address of a NCryptBufferDesc structure that contains the KDF parameters. This parameter is optional and can be NULL + /// if it is not needed. + /// + /// + /// + /// + /// The address of a buffer that receives the key. The cbDerivedKey parameter contains the size of this buffer. If this parameter is + /// NULL, this function will place the required size, in bytes, in the DWORD pointed to by the pcbResult parameter. + /// + /// + /// + /// The size, in bytes, of the pbDerivedKey buffer. + /// + /// + /// + /// A pointer to a DWORD that receives the number of bytes that were copied to the pbDerivedKey buffer. If the pbDerivedKey + /// parameter is NULL, this function will place the required size, in bytes, in the DWORD pointed to by this parameter. + /// + /// + /// + /// A set of flags that modify the behavior of this function. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// KDF_USE_SECRET_AS_HMAC_KEY_FLAG + /// + /// The secret agreement value will also serve as the HMAC key. If this flag is specified, the KDF_HMAC_KEY parameter should not be + /// included in the set of parameters in the pParameterList parameter. This flag is only used by the BCRYPT_KDF_HMAC key derivation function. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_HANDLE + /// The hSharedSecret parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// The BCryptBufferDesc structure in the pParameterList parameter can contain more than one of the KDF_SECRET_PREPEND and + /// KDF_SECRET_APPEND parameters. If more than one of these parameters is specified, the parameter values are concatenated in + /// the order in which they are contained in the array before the KDF is called. For example, assume the following parameter values + /// are specified. + /// + /// If the above parameter values are specified, the concatenated values to the actual KDF are as follows. + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptderivekey SECURITY_STATUS NCryptDeriveKey( + // NCRYPT_SECRET_HANDLE hSharedSecret, LPCWSTR pwszKDF, NCryptBufferDesc *pParameterList, PBYTE pbDerivedKey, DWORD cbDerivedKey, + // DWORD *pcbResult, ULONG dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "0ff08c6a-5f30-43ca-9db8-cda3e0704b0a")] + public static extern HRESULT NCryptDeriveKey(NCRYPT_SECRET_HANDLE hSharedSecret, [MarshalAs(UnmanagedType.LPWStr)] string pwszKDF, [Optional] NCryptBufferDesc pParameterList, [Optional] IntPtr pbDerivedKey, + [Optional] uint cbDerivedKey, out uint pcbResult, BCrypt.DeriveKeyFlags dwFlags); + + /// + /// The NCryptExportKey function exports a CNG key to a memory BLOB. + /// + /// + /// A handle of the key to export. + /// + /// + /// + /// A handle to a cryptographic key of the destination user. The key data within the exported key BLOB is encrypted by using this + /// key. This ensures that only the destination user is able to make use of the key BLOB. + /// + /// + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the type of BLOB to export. This can be one of the + /// following values. + /// + /// BCRYPT_DH_PRIVATE_BLOB + /// + /// Export a Diffie-Hellman public/private key pair. The pbOutput buffer receives a BCRYPT_DH_KEY_BLOB structure immediately followed + /// by the key data. + /// + /// BCRYPT_DH_PUBLIC_BLOB + /// + /// Export a Diffie-Hellman public key. The pbOutput buffer receives a BCRYPT_DH_KEY_BLOB structure immediately followed by the key data. + /// + /// BCRYPT_DSA_PRIVATE_BLOB + /// + /// Export a DSA public/private key pair. The pbOutput buffer receives a BCRYPT_DSA_KEY_BLOB structure immediately followed by the + /// key data. + /// + /// BCRYPT_DSA_PUBLIC_BLOB + /// + /// Export a DSA public key. The pbOutput buffer receives a BCRYPT_DSA_KEY_BLOB structure immediately followed by the key data. + /// + /// BCRYPT_ECCPRIVATE_BLOB + /// + /// Export an elliptic curve cryptography (ECC) private key. The pbOutput buffer receives a BCRYPT_ECCKEY_BLOB structure immediately + /// followed by the key data. + /// + /// BCRYPT_ECCPUBLIC_BLOB + /// + /// Export an ECC public key. The pbOutput buffer receives a BCRYPT_ECCKEY_BLOB structure immediately followed by the key data. + /// + /// BCRYPT_PUBLIC_KEY_BLOB + /// + /// Export a generic public key of any type. The type of key in this BLOB is determined by the Magic member of the + /// BCRYPT_KEY_BLOB structure. + /// + /// BCRYPT_PRIVATE_KEY_BLOB + /// + /// Export a generic private key of any type. The private key does not necessarily contain the public key. The type of key in this + /// BLOB is determined by the Magic member of the BCRYPT_KEY_BLOB structure. + /// + /// BCRYPT_RSAFULLPRIVATE_BLOB + /// + /// Export a full RSA public/private key pair. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by + /// the key data. This BLOB will include additional key material compared to the BCRYPT_RSAPRIVATE_BLOB type. + /// + /// BCRYPT_RSAPRIVATE_BLOB + /// + /// Export an RSA public/private key pair. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by the + /// key data. + /// + /// BCRYPT_RSAPUBLIC_BLOB + /// + /// Export an RSA public key. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by the key data. + /// + /// LEGACY_DH_PRIVATE_BLOB + /// + /// Export a legacy Diffie-Hellman Version 3 Private Key BLOB that contains a Diffie-Hellman public/private key pair that can be + /// imported by using CryptoAPI. + /// + /// LEGACY_DH_PUBLIC_BLOB + /// + /// Export a legacy Diffie-Hellman Version 3 Private Key BLOB that contains a Diffie-Hellman public key that can be imported by using CryptoAPI. + /// + /// LEGACY_DSA_PRIVATE_BLOB + /// Export a DSA public/private key pair in a form that can be imported by using CryptoAPI. + /// LEGACY_DSA_PUBLIC_BLOB + /// Export a DSA public key in a form that can be imported by using CryptoAPI. + /// LEGACY_RSAPRIVATE_BLOB + /// Export an RSA public/private key pair in a form that can be imported by using CryptoAPI. + /// LEGACY_RSAPUBLIC_BLOB + /// Export an RSA public key in a form that can be imported by using CryptoAPI. + /// NCRYPT_CIPHER_KEY_BLOB + /// Export a cipher key in a NCRYPT_KEY_BLOB_HEADER structure. + /// Windows 8 and Windows Server 2012: Support for this value begins. + /// NCRYPT_OPAQUETRANSPORT_BLOB + /// + /// Export a key in a format that is specific to a single CSP and is suitable for transport. Opaque BLOBs are not transferable and + /// must be imported by using the same CSP that generated the BLOB. + /// + /// NCRYPT_PKCS7_ENVELOPE_BLOB + /// + /// Export a PKCS #7 envelope BLOB. The parameters identified by the pParameterList parameter either can or must contain the + /// following parameters, as indicated by the Required or optional column. + /// + /// + /// + /// Parameter + /// Required or optional + /// + /// + /// NCRYPTBUFFER_CERT_BLOB + /// Required + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_OID + /// Required + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_PARAM + /// Optional + /// + /// + /// NCRYPT_PKCS8_PRIVATE_KEY_BLOB + /// + /// Export a PKCS #8 private key BLOB. The parameters identified by the pParameterList parameter either can or must contain the + /// following parameters, as indicated by the Required or optional column. + /// + /// + /// + /// Parameter + /// Required or optional + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_OID + /// Optional + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_PARAM + /// Optional + /// + /// + /// NCRYPTBUFFER_PKCS_SECRET + /// Optional + /// + /// + /// NCRYPT_PROTECTED_KEY_BLOB + /// Export a protected key in a NCRYPT_KEY_BLOB_HEADER structure. + /// Windows 8 and Windows Server 2012: Support for this value begins. + /// + /// + /// + /// The address of an NCryptBufferDesc structure that receives parameter information for the key. This parameter can be NULL + /// if this information is not needed. + /// + /// + /// + /// + /// The address of a buffer that receives the key BLOB. The cbOutput parameter contains the size of this buffer. If this parameter is + /// NULL, this function will place the required size, in bytes, in the DWORD pointed to by the pcbResult parameter. + /// + /// + /// + /// The size, in bytes, of the pbOutput buffer. + /// + /// + /// + /// The address of a DWORD variable that receives the number of bytes copied to the pbOutput buffer. If the pbOutput parameter + /// is NULL, this function will place the required size, in bytes, in the DWORD pointed to by this parameter. + /// + /// + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of one or more of the following values. The set of valid + /// flags is specific to each key storage provider. The following flag applies to all providers. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_BAD_KEY_STATE + /// + /// The key specified by the hKey parameter is not valid. The most common cause of this error is that the key was not completed by + /// using the NCryptFinalizeKey function. + /// + /// + /// + /// NTE_BAD_TYPE + /// The key specified by the hKey parameter cannot be exported into the BLOB type specified by the pszBlobType parameter. + /// + /// + /// NTE_INVALID_HANDLE + /// The hKey or the hExportKey parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptexportkey SECURITY_STATUS NCryptExportKey( + // NCRYPT_KEY_HANDLE hKey, NCRYPT_KEY_HANDLE hExportKey, LPCWSTR pszBlobType, NCryptBufferDesc *pParameterList, PBYTE pbOutput, DWORD + // cbOutput, DWORD *pcbResult, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "1588eb29-4026-4d1c-8bee-a035df38444a")] + public static extern HRESULT NCryptExportKey(NCRYPT_KEY_HANDLE hKey, NCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, [Optional] NCryptBufferDesc pParameterList, SafeAllocatedMemoryHandle pbOutput, uint cbOutput, out uint pcbResult, ExportKeyFlags dwFlags = 0); + + /// + /// The NCryptExportKey function exports a CNG key to a memory BLOB. + /// + /// + /// A handle of the key to export. + /// + /// + /// + /// A handle to a cryptographic key of the destination user. The key data within the exported key BLOB is encrypted by using this + /// key. This ensures that only the destination user is able to make use of the key BLOB. + /// + /// + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the type of BLOB to export. This can be one of the + /// following values. + /// + /// BCRYPT_DH_PRIVATE_BLOB + /// + /// Export a Diffie-Hellman public/private key pair. The pbOutput buffer receives a BCRYPT_DH_KEY_BLOB structure immediately followed + /// by the key data. + /// + /// BCRYPT_DH_PUBLIC_BLOB + /// + /// Export a Diffie-Hellman public key. The pbOutput buffer receives a BCRYPT_DH_KEY_BLOB structure immediately followed by the key data. + /// + /// BCRYPT_DSA_PRIVATE_BLOB + /// + /// Export a DSA public/private key pair. The pbOutput buffer receives a BCRYPT_DSA_KEY_BLOB structure immediately followed by the + /// key data. + /// + /// BCRYPT_DSA_PUBLIC_BLOB + /// + /// Export a DSA public key. The pbOutput buffer receives a BCRYPT_DSA_KEY_BLOB structure immediately followed by the key data. + /// + /// BCRYPT_ECCPRIVATE_BLOB + /// + /// Export an elliptic curve cryptography (ECC) private key. The pbOutput buffer receives a BCRYPT_ECCKEY_BLOB structure immediately + /// followed by the key data. + /// + /// BCRYPT_ECCPUBLIC_BLOB + /// + /// Export an ECC public key. The pbOutput buffer receives a BCRYPT_ECCKEY_BLOB structure immediately followed by the key data. + /// + /// BCRYPT_PUBLIC_KEY_BLOB + /// + /// Export a generic public key of any type. The type of key in this BLOB is determined by the Magic member of the + /// BCRYPT_KEY_BLOB structure. + /// + /// BCRYPT_PRIVATE_KEY_BLOB + /// + /// Export a generic private key of any type. The private key does not necessarily contain the public key. The type of key in this + /// BLOB is determined by the Magic member of the BCRYPT_KEY_BLOB structure. + /// + /// BCRYPT_RSAFULLPRIVATE_BLOB + /// + /// Export a full RSA public/private key pair. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by + /// the key data. This BLOB will include additional key material compared to the BCRYPT_RSAPRIVATE_BLOB type. + /// + /// BCRYPT_RSAPRIVATE_BLOB + /// + /// Export an RSA public/private key pair. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by the + /// key data. + /// + /// BCRYPT_RSAPUBLIC_BLOB + /// + /// Export an RSA public key. The pbOutput buffer receives a BCRYPT_RSAKEY_BLOB structure immediately followed by the key data. + /// + /// LEGACY_DH_PRIVATE_BLOB + /// + /// Export a legacy Diffie-Hellman Version 3 Private Key BLOB that contains a Diffie-Hellman public/private key pair that can be + /// imported by using CryptoAPI. + /// + /// LEGACY_DH_PUBLIC_BLOB + /// + /// Export a legacy Diffie-Hellman Version 3 Private Key BLOB that contains a Diffie-Hellman public key that can be imported by using CryptoAPI. + /// + /// LEGACY_DSA_PRIVATE_BLOB + /// Export a DSA public/private key pair in a form that can be imported by using CryptoAPI. + /// LEGACY_DSA_PUBLIC_BLOB + /// Export a DSA public key in a form that can be imported by using CryptoAPI. + /// LEGACY_RSAPRIVATE_BLOB + /// Export an RSA public/private key pair in a form that can be imported by using CryptoAPI. + /// LEGACY_RSAPUBLIC_BLOB + /// Export an RSA public key in a form that can be imported by using CryptoAPI. + /// NCRYPT_CIPHER_KEY_BLOB + /// Export a cipher key in a NCRYPT_KEY_BLOB_HEADER structure. + /// Windows 8 and Windows Server 2012: Support for this value begins. + /// NCRYPT_OPAQUETRANSPORT_BLOB + /// + /// Export a key in a format that is specific to a single CSP and is suitable for transport. Opaque BLOBs are not transferable and + /// must be imported by using the same CSP that generated the BLOB. + /// + /// NCRYPT_PKCS7_ENVELOPE_BLOB + /// + /// Export a PKCS #7 envelope BLOB. The parameters identified by the pParameterList parameter either can or must contain the + /// following parameters, as indicated by the Required or optional column. + /// + /// + /// + /// Parameter + /// Required or optional + /// + /// + /// NCRYPTBUFFER_CERT_BLOB + /// Required + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_OID + /// Required + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_PARAM + /// Optional + /// + /// + /// NCRYPT_PKCS8_PRIVATE_KEY_BLOB + /// + /// Export a PKCS #8 private key BLOB. The parameters identified by the pParameterList parameter either can or must contain the + /// following parameters, as indicated by the Required or optional column. + /// + /// + /// + /// Parameter + /// Required or optional + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_OID + /// Optional + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_PARAM + /// Optional + /// + /// + /// NCRYPTBUFFER_PKCS_SECRET + /// Optional + /// + /// + /// NCRYPT_PROTECTED_KEY_BLOB + /// Export a protected key in a NCRYPT_KEY_BLOB_HEADER structure. + /// Windows 8 and Windows Server 2012: Support for this value begins. + /// + /// + /// + /// The address of an NCryptBufferDesc structure that receives parameter information for the key. This parameter can be NULL + /// if this information is not needed. + /// + /// + /// + /// + /// The address of a buffer that receives the key BLOB. The cbOutput parameter contains the size of this buffer. If this parameter is + /// NULL, this function will place the required size, in bytes, in the DWORD pointed to by the pcbResult parameter. + /// + /// + /// + /// The size, in bytes, of the pbOutput buffer. + /// + /// + /// + /// The address of a DWORD variable that receives the number of bytes copied to the pbOutput buffer. If the pbOutput parameter + /// is NULL, this function will place the required size, in bytes, in the DWORD pointed to by this parameter. + /// + /// + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of one or more of the following values. The set of valid + /// flags is specific to each key storage provider. The following flag applies to all providers. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_BAD_KEY_STATE + /// + /// The key specified by the hKey parameter is not valid. The most common cause of this error is that the key was not completed by + /// using the NCryptFinalizeKey function. + /// + /// + /// + /// NTE_BAD_TYPE + /// The key specified by the hKey parameter cannot be exported into the BLOB type specified by the pszBlobType parameter. + /// + /// + /// NTE_INVALID_HANDLE + /// The hKey or the hExportKey parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptexportkey SECURITY_STATUS NCryptExportKey( + // NCRYPT_KEY_HANDLE hKey, NCRYPT_KEY_HANDLE hExportKey, LPCWSTR pszBlobType, NCryptBufferDesc *pParameterList, PBYTE pbOutput, DWORD + // cbOutput, DWORD *pcbResult, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "1588eb29-4026-4d1c-8bee-a035df38444a")] + public static extern HRESULT NCryptExportKey(NCRYPT_KEY_HANDLE hKey, NCRYPT_KEY_HANDLE hExportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, [Optional] NCryptBufferDesc pParameterList, [Optional] IntPtr pbOutput, [Optional] uint cbOutput, out uint pcbResult, ExportKeyFlags dwFlags = 0); + + /// + /// + /// The NCryptFinalizeKey function completes a CNG key storage key. The key cannot be used until this function has been called. + /// + /// + /// + /// The handle of the key to complete. This handle is obtained by calling the NCryptCreatePersistedKey function. + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of one or more of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_NO_KEY_VALIDATION + /// Do not validate the public portion of the key pair. This flag only applies to public/private key pairs. + /// + /// + /// NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG + /// Also save the key in legacy storage. This allows the key to be used with CryptoAPI. This flag only applies to RSA keys. + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_INVALID_HANDLE + /// The hKey parameter is not valid. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptfinalizekey SECURITY_STATUS NCryptFinalizeKey( + // NCRYPT_KEY_HANDLE hKey, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "4386030d-4ce6-4b2e-adc5-a15ddc869349")] + public static extern HRESULT NCryptFinalizeKey(NCRYPT_KEY_HANDLE hKey, FinalizeKeyFlags dwFlags = 0); + + /// + /// The NCryptFreeObject function frees a CNG key storage object. + /// + /// + /// + /// The handle of the object to free. This can be either a provider handle ( NCRYPT_PROV_HANDLE) or a key handle ( NCRYPT_KEY_HANDLE). + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_HANDLE + /// The handle in the hObject parameter is not valid. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptfreeobject SECURITY_STATUS NCryptFreeObject( + // NCRYPT_HANDLE hObject ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "a5535cf9-ba8c-4212-badd-f1dc88903624")] + public static extern HRESULT NCryptFreeObject(IntPtr hObject); + + /// + /// The NCryptImportKey function imports a Cryptography API: Next Generation (CNG) key from a memory BLOB. + /// + /// + /// The handle of the key storage provider. + /// + /// + /// + /// The handle of the cryptographic key with which the key data within the imported key BLOB was encrypted. This must be a handle to + /// the same key that was passed in the hExportKey parameter of the NCryptExportKey function. If this parameter is NULL, the + /// key BLOB is assumed to not be encrypted. + /// + /// + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the format of the key BLOB. These formats are + /// specific to a particular key storage provider. For the BLOB formats supported by Microsoft providers, see Remarks. + /// + /// + /// + /// + /// The address of an NCryptBufferDesc structure that points to an array of buffers that contain parameter information for the key. + /// + /// + /// + /// + /// The address of an NCRYPT_KEY_HANDLE variable that receives the handle of the key. When you have finished using this + /// handle, release it by passing it to the NCryptFreeObject function. + /// + /// + /// + /// The address of a buffer that contains the key BLOB to be imported. The cbData parameter contains the size of this buffer. + /// + /// + /// The size, in bytes, of the pbData buffer. + /// + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of one or more of the following values. The set of valid + /// flags is specific to each key storage provider. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_EXISTS + /// A key with the specified name already exists and the NCRYPT_OVERWRITE_KEY_FLAG was not specified. + /// + /// + /// NTE_INVALID_HANDLE + /// The hProvider parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// NTE_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// The following sections describe behaviors specific to the Microsoft key storage providers: + /// + /// + /// Microsoft Software KSP + /// + /// + /// Microsoft Smart Card KSP + /// + /// + /// Microsoft Software KSP + /// The following constants are supported by the Microsoft software KSP for the pszBlobType parameter. + /// + /// If a key name is not supplied, the Microsoft Software KSP treats the key as ephemeral and does not store it persistently. For the + /// NCRYPT_OPAQUETRANSPORT_BLOB type, the key name is stored within the BLOB when it is exported. For other BLOB formats, the + /// name can be supplied in an NCRYPTBUFFER_PKCS_KEY_NAME buffer parameter within the pParameterList parameter. + /// + /// + /// On Windows Server 2008 and Windows Vista, only keys imported as PKCS #7 envelope BLOBs ( NCRYPT_PKCS7_ENVELOPE_BLOB) or + /// PKCS #8 private key BLOBs ( NCRYPT_PKCS8_PRIVATE_KEY_BLOB) can be persisted by using the above method. To persist keys + /// imported through other BLOB types on these platforms, use the method documented in Key Import and Export. + /// + /// The following flags are supported by this KSP. + /// + /// + /// Term + /// Description + /// + /// + /// NCRYPT_NO_KEY_VALIDATION + /// Do not validate the public portion of the key pair. This flag only applies to public/private key pairs. + /// + /// + /// NCRYPT_DO_NOT_FINALIZE_FLAG + /// + /// Do not finalize the key. This option is useful when you need to add or modify properties of the key after importing it. You must + /// finalize the key before it can be used by passing the key handle to the NCryptFinalizeKey function. This flag is supported for + /// the private keys PKCS #7 and PKCS #8 but not public keys. + /// + /// + /// + /// NCRYPT_MACHINE_KEY_FLAG + /// The key applies to the local computer. If this flag is not present, the key applies to the current user. + /// + /// + /// NCRYPT_OVERWRITE_KEY_FLAG + /// + /// If a key already exists in the container with the specified name, the existing key will be overwritten. If this flag is not + /// specified and a key with the specified name already exists, this function will return NTE_EXISTS. + /// + /// + /// + /// NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG + /// + /// Also save the key in legacy storage. This allows the key to be used with the CryptoAPI. This flag only applies to RSA keys. + /// + /// + /// + /// Microsoft Smart Card KSP + /// + /// The set of key BLOB formats and flags supported by this KSP is identical to the set supported by the Microsoft Software KSP. + /// + /// + /// On Windows Server 2008 and Windows Vista, the Microsoft Smart Card KSP imports all keys into the Microsoft Software KSP. Thus, + /// keys cannot be persisted on to a smart card by using this API, and the guidance in the above section applies when trying to + /// persist keys within the Microsoft Software KSP. + /// + /// + /// On Windows Server 2008 R2 and Windows 7, the Microsoft Smart Card Key Storage Provider can import a private key to a smart card, + /// provided the following conditions are met: + /// + /// + /// + /// The key container name on the card is valid. + /// + /// + /// Importing private keys is supported by the smart card. + /// + /// + /// The following two registry keys are set to a DWORD of 0x1: + /// + /// + /// + /// If the key container name is NULL, the Microsoft Smart Card KSP treats the key as ephemeral and imports it into the + /// Microsoft Software KSP. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptimportkey SECURITY_STATUS NCryptImportKey( + // NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY_HANDLE hImportKey, LPCWSTR pszBlobType, NCryptBufferDesc *pParameterList, + // NCRYPT_KEY_HANDLE *phKey, PBYTE pbData, DWORD cbData, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "ede0e7e0-cb2c-44c0-b724-58db3480b781")] + public static extern HRESULT NCryptImportKey(NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, NCryptBufferDesc pParameterList, + out SafeNCRYPT_KEY_HANDLE phKey, SafeAllocatedMemoryHandle pbData, uint cbData, ImportKeyFlags dwFlags = 0); + + /// + /// The NCryptImportKey function imports a Cryptography API: Next Generation (CNG) key from a memory BLOB. + /// + /// + /// The handle of the key storage provider. + /// + /// + /// + /// The handle of the cryptographic key with which the key data within the imported key BLOB was encrypted. This must be a handle to + /// the same key that was passed in the hExportKey parameter of the NCryptExportKey function. If this parameter is NULL, the + /// key BLOB is assumed to not be encrypted. + /// + /// + /// + /// + /// A null-terminated Unicode string that contains an identifier that specifies the format of the key BLOB. These formats are + /// specific to a particular key storage provider. For the BLOB formats supported by Microsoft providers, see Remarks. + /// + /// + /// + /// + /// The address of an NCryptBufferDesc structure that points to an array of buffers that contain parameter information for the key. + /// + /// + /// + /// + /// The address of an NCRYPT_KEY_HANDLE variable that receives the handle of the key. When you have finished using this + /// handle, release it by passing it to the NCryptFreeObject function. + /// + /// + /// + /// The address of a buffer that contains the key BLOB to be imported. The cbData parameter contains the size of this buffer. + /// + /// + /// The size, in bytes, of the pbData buffer. + /// + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of one or more of the following values. The set of valid + /// flags is specific to each key storage provider. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_EXISTS + /// A key with the specified name already exists and the NCRYPT_OVERWRITE_KEY_FLAG was not specified. + /// + /// + /// NTE_INVALID_HANDLE + /// The hProvider parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// NTE_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// The following sections describe behaviors specific to the Microsoft key storage providers: + /// + /// + /// Microsoft Software KSP + /// + /// + /// Microsoft Smart Card KSP + /// + /// + /// Microsoft Software KSP + /// The following constants are supported by the Microsoft software KSP for the pszBlobType parameter. + /// + /// If a key name is not supplied, the Microsoft Software KSP treats the key as ephemeral and does not store it persistently. For the + /// NCRYPT_OPAQUETRANSPORT_BLOB type, the key name is stored within the BLOB when it is exported. For other BLOB formats, the + /// name can be supplied in an NCRYPTBUFFER_PKCS_KEY_NAME buffer parameter within the pParameterList parameter. + /// + /// + /// On Windows Server 2008 and Windows Vista, only keys imported as PKCS #7 envelope BLOBs ( NCRYPT_PKCS7_ENVELOPE_BLOB) or + /// PKCS #8 private key BLOBs ( NCRYPT_PKCS8_PRIVATE_KEY_BLOB) can be persisted by using the above method. To persist keys + /// imported through other BLOB types on these platforms, use the method documented in Key Import and Export. + /// + /// The following flags are supported by this KSP. + /// + /// + /// Term + /// Description + /// + /// + /// NCRYPT_NO_KEY_VALIDATION + /// Do not validate the public portion of the key pair. This flag only applies to public/private key pairs. + /// + /// + /// NCRYPT_DO_NOT_FINALIZE_FLAG + /// + /// Do not finalize the key. This option is useful when you need to add or modify properties of the key after importing it. You must + /// finalize the key before it can be used by passing the key handle to the NCryptFinalizeKey function. This flag is supported for + /// the private keys PKCS #7 and PKCS #8 but not public keys. + /// + /// + /// + /// NCRYPT_MACHINE_KEY_FLAG + /// The key applies to the local computer. If this flag is not present, the key applies to the current user. + /// + /// + /// NCRYPT_OVERWRITE_KEY_FLAG + /// + /// If a key already exists in the container with the specified name, the existing key will be overwritten. If this flag is not + /// specified and a key with the specified name already exists, this function will return NTE_EXISTS. + /// + /// + /// + /// NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG + /// + /// Also save the key in legacy storage. This allows the key to be used with the CryptoAPI. This flag only applies to RSA keys. + /// + /// + /// + /// Microsoft Smart Card KSP + /// + /// The set of key BLOB formats and flags supported by this KSP is identical to the set supported by the Microsoft Software KSP. + /// + /// + /// On Windows Server 2008 and Windows Vista, the Microsoft Smart Card KSP imports all keys into the Microsoft Software KSP. Thus, + /// keys cannot be persisted on to a smart card by using this API, and the guidance in the above section applies when trying to + /// persist keys within the Microsoft Software KSP. + /// + /// + /// On Windows Server 2008 R2 and Windows 7, the Microsoft Smart Card Key Storage Provider can import a private key to a smart card, + /// provided the following conditions are met: + /// + /// + /// + /// The key container name on the card is valid. + /// + /// + /// Importing private keys is supported by the smart card. + /// + /// + /// The following two registry keys are set to a DWORD of 0x1: + /// + /// + /// + /// If the key container name is NULL, the Microsoft Smart Card KSP treats the key as ephemeral and imports it into the + /// Microsoft Software KSP. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptimportkey SECURITY_STATUS NCryptImportKey( + // NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY_HANDLE hImportKey, LPCWSTR pszBlobType, NCryptBufferDesc *pParameterList, + // NCRYPT_KEY_HANDLE *phKey, PBYTE pbData, DWORD cbData, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "ede0e7e0-cb2c-44c0-b724-58db3480b781")] + public static extern HRESULT NCryptImportKey(NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY_HANDLE hImportKey, [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, NCryptBufferDesc pParameterList, + out SafeNCRYPT_KEY_HANDLE phKey, [Optional] IntPtr pbData, [Optional] uint cbData, ImportKeyFlags dwFlags = 0); + + /// + /// The NCryptOpenKey function opens a key that exists in the specified CNG key storage provider. + /// + /// + /// The handle of the key storage provider to open the key from. + /// + /// + /// + /// A pointer to a NCRYPT_KEY_HANDLE variable that receives the key handle. When you have finished using this handle, release + /// it by passing it to the NCryptFreeObject function. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the name of the key to retrieve. + /// + /// + /// A legacy identifier that specifies the type of key. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// AT_KEYEXCHANGE + /// The key is a key exchange key. + /// + /// + /// AT_SIGNATURE + /// The key is a signature key. + /// + /// + /// 0 + /// The key is none of the above types. + /// + /// + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of one or more of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_MACHINE_KEY_FLAG + /// Open the key for the local computer. If this flag is not present, the current user key is opened. + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_BAD_KEYSET + /// The specified key was not found. + /// + /// + /// NTE_INVALID_HANDLE + /// The hProvider parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// NTE_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + /// For performance reasons, Microsoft software-based KSPs cache private key material in the Local Security Authority (LSA) for as + /// long as a handle to the key is open. The LSA is a privilidged system process. Therefore, other users cannot access this cached + /// copy of the key unless the user possesses administrator privileges on the system. This behavior cannot be altered through configuration. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptopenkey SECURITY_STATUS NCryptOpenKey( + // NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY_HANDLE *phKey, LPCWSTR pszKeyName, DWORD dwLegacyKeySpec, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "581c5d89-730d-4d8c-b3bb-a28edec25910")] + public static extern HRESULT NCryptOpenKey(NCRYPT_PROV_HANDLE hProvider, out SafeNCRYPT_KEY_HANDLE phKey, [MarshalAs(UnmanagedType.LPWStr)] string pszKeyName, Crypt32.PrivateKeyType dwLegacyKeySpec = 0, OpenKeyFlags dwFlags = 0); + + /// + /// The NCryptOpenStorageProvider function loads and initializes a CNG key storage provider. + /// + /// + /// + /// A pointer to a NCRYPT_PROV_HANDLE variable that receives the provider handle. When you have finished using this handle, + /// release it by passing it to the NCryptFreeObject function. + /// + /// + /// + /// + /// A pointer to a null-terminated Unicode string that identifies the key storage provider to load. This is the registered alias of + /// the key storage provider. This parameter is optional and can be NULL. If this parameter is NULL, the default key + /// storage provider is loaded. The following values identify the built-in key storage providers. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// MS_KEY_STORAGE_PROVIDER L"Microsoft Software Key Storage Provider" + /// Identifies the software key storage provider that is provided by Microsoft. + /// + /// + /// MS_SMART_CARD_KEY_STORAGE_PROVIDER L"Microsoft Smart Card Key Storage Provider" + /// Identifies the smart card key storage provider that is provided by Microsoft. + /// + /// + /// + /// + /// Flags that modify the behavior of the function. No flags are defined for this function. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains one or more flags that are not supported. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// NTE_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// + /// In the case that an error condition is returned, the provider will have been unloaded from memory. Functions within the provider + /// must not be called after a failure error is returned. + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptopenstorageprovider SECURITY_STATUS + // NCryptOpenStorageProvider( NCRYPT_PROV_HANDLE *phProvider, LPCWSTR pszProviderName, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "febcf440-78b3-420b-b13d-030e8071cd50")] + public static extern HRESULT NCryptOpenStorageProvider(out SafeNCRYPT_PROV_HANDLE phProvider, [MarshalAs(UnmanagedType.LPWStr)] string pszProviderName, uint dwFlags = 0); + + /// + /// The NCryptSecretAgreement function creates a secret agreement value from a private and a public key. + /// + /// + /// + /// The handle of the private key to use to create the secret agreement value. This key and the hPubKey key must come from the same + /// key storage provider. + /// + /// + /// + /// + /// The handle of the public key to use to create the secret agreement value. This key and the hPrivKey key must come from the same + /// key storage provider. + /// + /// + /// + /// + /// A pointer to an NCRYPT_SECRET_HANDLE variable that receives a handle that represents the secret agreement value. When this + /// handle is no longer needed, release it by passing it to the NCryptFreeObject function. + /// + /// + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of one or more of the following values. The set of valid + /// flags is specific to each key storage provider. The following flag applies to all providers. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_HANDLE + /// The hPrivKey or the hPubKey parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// NTE_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptsecretagreement SECURITY_STATUS NCryptSecretAgreement( + // NCRYPT_KEY_HANDLE hPrivKey, NCRYPT_KEY_HANDLE hPubKey, NCRYPT_SECRET_HANDLE *phAgreedSecret, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "b5bf3eac-1fae-43e2-84b6-e8e5e255d7c5")] + public static extern HRESULT NCryptSecretAgreement(NCRYPT_KEY_HANDLE hPrivKey, NCRYPT_KEY_HANDLE hPubKey, out SafeNCRYPT_SECRET_HANDLE phAgreedSecret, SecretAgreementFlags dwFlags = 0); + + /// + /// The NCryptSetProperty function sets the value for a named property for a CNG key storage object. + /// + /// + /// The handle of the key storage object to set the property for. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the name of the property to set. This can be one of the predefined + /// Key Storage Property Identifiers or a custom property identifier. + /// + /// + /// + /// The address of a buffer that contains the new property value. The cbInput parameter contains the size of this buffer. + /// + /// + /// The size, in bytes, of the pbInput buffer. + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of one or more of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_PERSIST_FLAG + /// + /// The property should be stored in key storage along with the key material. This flag can only be used when the hObject parameter + /// is the handle of a persisted key. The maximum size of the data for any persisted property is NCRYPT_MAX_PROPERTY_DATA bytes. + /// + /// + /// + /// NCRYPT_PERSIST_ONLY_FLAG + /// + /// Do not overwrite any built-in values for this property and only set the user-persisted properties of the key. The maximum size of + /// the data for any persisted property is NCRYPT_MAX_PROPERTY_DATA bytes. This flag cannot be used with the + /// NCRYPT_SECURITY_DESCR_PROPERTY property. + /// + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// For the NCRYPT_SECURITY_DESCR_PROPERTY property, this parameter must also contain one of the following values, which + /// identifies the part of the security descriptor to set. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// OWNER_SECURITY_INFORMATION + /// + /// Set the security identifier (SID) of the object's owner. Use the SetSecurityDescriptorOwner function to set the owner SID in the + /// SECURITY_DESCRIPTOR structure. + /// + /// + /// + /// GROUP_SECURITY_INFORMATION + /// + /// Set the SID of the object's primary group. Use the SetSecurityDescriptorGroup function to set the group SID in the + /// SECURITY_DESCRIPTOR structure. + /// + /// + /// + /// DACL_SECURITY_INFORMATION + /// + /// Set the discretionary access control list (DACL). Use the SetSecurityDescriptorSacl function to set the DACL in the + /// SECURITY_DESCRIPTOR structure. + /// + /// + /// + /// SACL_SECURITY_INFORMATION + /// + /// Set the system access control list (SACL). Use the SetSecurityDescriptorDacl function to set the SACL in the SECURITY_DESCRIPTOR structure. + /// + /// + /// + /// LABEL_SECURITY_INFORMATION + /// + /// Set the mandatory label access control entry in the SACL of the object. Use the SetSecurityDescriptorDacl function to set the + /// SACL in the SECURITY_DESCRIPTOR structure. For more information about the mandatory label access control entry, see Windows + /// Integrity Mechanism Design. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_INVALID_HANDLE + /// The hObject parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// NTE_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// NTE_NOT_SUPPORTED + /// The specified property is not supported for the object. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptsetproperty SECURITY_STATUS NCryptSetProperty( + // NCRYPT_HANDLE hObject, LPCWSTR pszProperty, PBYTE pbInput, DWORD cbInput, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "ad1148aa-5f64-4867-9e17-6b41cc0c20b7")] + public static extern HRESULT NCryptSetProperty(NCRYPT_HANDLE hObject, [MarshalAs(UnmanagedType.LPWStr)] string pszProperty, IntPtr pbInput, uint cbInput, SetPropFlags dwFlags); + + /// + /// The NCryptSetProperty function sets the value for a named property for a CNG key storage object. + /// + /// + /// The handle of the key storage object to set the property for. + /// + /// + /// + /// A pointer to a null-terminated Unicode string that contains the name of the property to set. This can be one of the predefined + /// Key Storage Property Identifiers or a custom property identifier. + /// + /// + /// + /// The address of a buffer that contains the new property value. The cbInput parameter contains the size of this buffer. + /// + /// + /// The size, in bytes, of the pbInput buffer. + /// + /// + /// Flags that modify function behavior. This can be zero or a combination of one or more of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_PERSIST_FLAG + /// + /// The property should be stored in key storage along with the key material. This flag can only be used when the hObject parameter + /// is the handle of a persisted key. The maximum size of the data for any persisted property is NCRYPT_MAX_PROPERTY_DATA bytes. + /// + /// + /// + /// NCRYPT_PERSIST_ONLY_FLAG + /// + /// Do not overwrite any built-in values for this property and only set the user-persisted properties of the key. The maximum size of + /// the data for any persisted property is NCRYPT_MAX_PROPERTY_DATA bytes. This flag cannot be used with the + /// NCRYPT_SECURITY_DESCR_PROPERTY property. + /// + /// + /// + /// NCRYPT_SILENT_FLAG + /// + /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the + /// call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. + /// + /// + /// + /// + /// For the NCRYPT_SECURITY_DESCR_PROPERTY property, this parameter must also contain one of the following values, which + /// identifies the part of the security descriptor to set. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// OWNER_SECURITY_INFORMATION + /// + /// Set the security identifier (SID) of the object's owner. Use the SetSecurityDescriptorOwner function to set the owner SID in the + /// SECURITY_DESCRIPTOR structure. + /// + /// + /// + /// GROUP_SECURITY_INFORMATION + /// + /// Set the SID of the object's primary group. Use the SetSecurityDescriptorGroup function to set the group SID in the + /// SECURITY_DESCRIPTOR structure. + /// + /// + /// + /// DACL_SECURITY_INFORMATION + /// + /// Set the discretionary access control list (DACL). Use the SetSecurityDescriptorSacl function to set the DACL in the + /// SECURITY_DESCRIPTOR structure. + /// + /// + /// + /// SACL_SECURITY_INFORMATION + /// + /// Set the system access control list (SACL). Use the SetSecurityDescriptorDacl function to set the SACL in the SECURITY_DESCRIPTOR structure. + /// + /// + /// + /// LABEL_SECURITY_INFORMATION + /// + /// Set the mandatory label access control entry in the SACL of the object. Use the SetSecurityDescriptorDacl function to set the + /// SACL in the SECURITY_DESCRIPTOR structure. For more information about the mandatory label access control entry, see Windows + /// Integrity Mechanism Design. + /// + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// Possible return codes include, but are not limited to, the following. + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter contains a value that is not valid. + /// + /// + /// NTE_INVALID_HANDLE + /// The hObject parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// One or more parameters are not valid. + /// + /// + /// NTE_NO_MEMORY + /// A memory allocation failure occurred. + /// + /// + /// NTE_NOT_SUPPORTED + /// The specified property is not supported for the object. + /// + /// + /// + /// + /// + /// A service must not call this function from its StartService Function. If a service calls this function from its StartService + /// function, a deadlock can occur, and the service may stop responding. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/nf-ncrypt-ncryptsetproperty SECURITY_STATUS NCryptSetProperty( + // NCRYPT_HANDLE hObject, LPCWSTR pszProperty, PBYTE pbInput, DWORD cbInput, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncrypt.h", MSDNShortId = "ad1148aa-5f64-4867-9e17-6b41cc0c20b7")] + public static extern HRESULT NCryptSetProperty(NCRYPT_HANDLE hObject, [MarshalAs(UnmanagedType.LPWStr)] string pszProperty, byte[] pbInput, uint cbInput, SetPropFlags dwFlags); + + /// + /// + /// The NCRYPT_ALLOC_PARA structure enables you to specify custom functions that can be used to allocate and free data. This + /// structure is used in the following functions: + /// + /// + /// + /// NCryptGetProtectionDescriptorInfo + /// + /// + /// NCryptProtectSecret + /// + /// + /// NCryptUnprotectSecret + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncrypt/ns-ncrypt-ncrypt_alloc_para typedef struct NCRYPT_ALLOC_PARA { DWORD + // cbSize; PFN_NCRYPT_ALLOC pfnAlloc; PFN_NCRYPT_FREE pfnFree; } NCRYPT_ALLOC_PARA; + [PInvokeData("ncrypt.h", MSDNShortId = "4F546F51-E4DE-4703-B1D1-F84165C3C31B")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct NCRYPT_ALLOC_PARA + { + /// The size, in bytes, of this structure. + public uint cbSize; + + /// Address of a custom function that can allocate memory. + public PFN_NCRYPT_ALLOC pfnAlloc; + + /// Address of a function that can free memory allocated by the function specified by the pfnAlloc member. + public PFN_NCRYPT_FREE pfnFree; + } + + /// Provides a handle to a key storage object. + [StructLayout(LayoutKind.Sequential)] + public struct NCRYPT_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public NCRYPT_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static NCRYPT_HANDLE NULL => new NCRYPT_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(NCRYPT_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator NCRYPT_HANDLE(IntPtr h) => new NCRYPT_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(NCRYPT_HANDLE h1, NCRYPT_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(NCRYPT_HANDLE h1, NCRYPT_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is NCRYPT_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// Provides a handle to a key. + [StructLayout(LayoutKind.Sequential)] + public struct NCRYPT_KEY_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public NCRYPT_KEY_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static NCRYPT_KEY_HANDLE NULL => new NCRYPT_KEY_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(NCRYPT_KEY_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator NCRYPT_KEY_HANDLE(IntPtr h) => new NCRYPT_KEY_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(NCRYPT_KEY_HANDLE h1, NCRYPT_KEY_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(NCRYPT_KEY_HANDLE h1, NCRYPT_KEY_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is NCRYPT_KEY_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// Provides a handle to a provider handle. + [StructLayout(LayoutKind.Sequential)] + public struct NCRYPT_PROV_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public NCRYPT_PROV_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static NCRYPT_PROV_HANDLE NULL => new NCRYPT_PROV_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(NCRYPT_PROV_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator NCRYPT_PROV_HANDLE(IntPtr h) => new NCRYPT_PROV_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(NCRYPT_PROV_HANDLE h1, NCRYPT_PROV_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(NCRYPT_PROV_HANDLE h1, NCRYPT_PROV_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is NCRYPT_PROV_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// Provides a handle to a secret agreement value. + [StructLayout(LayoutKind.Sequential)] + public struct NCRYPT_SECRET_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public NCRYPT_SECRET_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static NCRYPT_SECRET_HANDLE NULL => new NCRYPT_SECRET_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(NCRYPT_SECRET_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator NCRYPT_SECRET_HANDLE(IntPtr h) => new NCRYPT_SECRET_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(NCRYPT_SECRET_HANDLE h1, NCRYPT_SECRET_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(NCRYPT_SECRET_HANDLE h1, NCRYPT_SECRET_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is NCRYPT_SECRET_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// The NCryptBuffer structure is used to identify a variable-length memory buffer. + /// BCryptBuffer is an alias for this structure. + // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcryptbuffer typedef struct _BCryptBuffer { ULONG cbBuffer; + // ULONG BufferType; PVOID pvBuffer; } BCryptBuffer, *PBCryptBuffer; + [PInvokeData("bcrypt.h", MSDNShortId = "474d3c0d-ae14-448a-a56d-25abc7e5de88")] + public struct NCryptBuffer + { + /// + /// A value that identifies the type of data that is contained by the buffer. This can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// KDF_HASH_ALGORITHM 0 + /// + /// The buffer is a key derivation function (KDF) parameter that contains a null-terminated Unicode string that identifies the + /// hash algorithm. This can be one of the standard hash algorithm identifiers from CNG Algorithm Identifiers or the identifier + /// for another registered hash algorithm. The size specified by the cbBuffer member of this structure must include the + /// terminating NULL character. + /// + /// + /// + /// KDF_SECRET_PREPEND 1 + /// The buffer is a KDF parameter that contains the value to add to the beginning of the message input to the hash function. + /// + /// + /// KDF_SECRET_APPEND 2 + /// The buffer is a KDF parameter that contains the value to add to the end of the message input to the hash function. + /// + /// + /// KDF_HMAC_KEY 3 + /// The buffer is a KDF parameter that contains the plain text value of the HMAC key. + /// + /// + /// KDF_TLS_PRF_LABEL 4 + /// + /// The buffer is a KDF parameter that contains an ANSI string that contains the transport layer security (TLS) pseudo-random + /// function (PRF) label. + /// + /// + /// + /// KDF_TLS_PRF_SEED 5 + /// The buffer is a KDF parameter that contains the PRF seed value. The seed must be 64 bytes long. + /// + /// + /// KDF_SECRET_HANDLE 6 + /// + /// The buffer is a KDF parameter that contains the secret agreement handle. The pvBuffer member contains a BCRYPT_SECRET_HANDLE + /// value and is not a pointer. + /// + /// + /// + /// KDF_TLS_PRF_PROTOCOL 7 + /// + /// The buffer is a KDF parameter that contains a DWORD value identifying the SSL/TLS protocol version whose PRF algorithm is to + /// be used. + /// + /// + /// + /// KDF_ALGORITHMID 8 + /// + /// The buffer is a KDF parameter that contains the byte array to use as the AlgorithmID subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + /// + /// + /// KDF_PARTYUINFO 9 + /// + /// The buffer is a KDF parameter that contains the byte array to use as the PartyUInfo subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + /// + /// + /// KDF_PARTYVINFO 10 + /// + /// The buffer is a KDF parameter that contains the byte array to use as the PartyVInfo subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + /// + /// + /// KDF_SUPPPUBINFO 11 + /// + /// The buffer is a KDF parameter that contains the byte array to use as the SuppPubInfo subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + /// + /// + /// KDF_SUPPPRIVINFO 12 + /// + /// The buffer is a KDF parameter that contains the byte array to use as the SuppPrivInfo subfield of the OtherInfo parameter to + /// the SP 800-56A KDF. + /// + /// + /// + /// NCRYPTBUFFER_SSL_CLIENT_RANDOM 20 + /// The buffer contains the random number of the SSL client. + /// + /// + /// NCRYPTBUFFER_SSL_SERVER_RANDOM 21 + /// The buffer contains the random number of the SSL server. + /// + /// + /// NCRYPTBUFFER_SSL_HIGHEST_VERSION 22 + /// The buffer contains the highest SSL version supported. + /// + /// + /// NCRYPTBUFFER_SSL_CLEAR_KEY 23 + /// The buffer contains the clear portion of the SSL master key. + /// + /// + /// NCRYPTBUFFER_SSL_KEY_ARG_DATA 24 + /// The buffer contains the SSL key argument data. + /// + /// + /// NCRYPTBUFFER_PKCS_OID 40 + /// The buffer contains a null-terminated ANSI string that contains the PKCS object identifier. + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_OID 41 + /// The buffer contains a null-terminated ANSI string that contains the PKCS algorithm object identifier. + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_PARAM 42 + /// The buffer contains the PKCS algorithm parameters. + /// + /// + /// NCRYPTBUFFER_PKCS_ALG_ID 43 + /// The buffer contains the PKCS algorithm identifier. + /// + /// + /// NCRYPTBUFFER_PKCS_ATTRS 44 + /// The buffer contains the PKCS attributes. + /// + /// + /// NCRYPTBUFFER_PKCS_KEY_NAME 45 + /// The buffer contains a null-terminated Unicode string that contains the key name. + /// + /// + /// NCRYPTBUFFER_PKCS_SECRET 46 + /// + /// The buffer contains a null-terminated Unicode string that contains the PKCS8 password. This parameter is optional and can be NULL. + /// + /// + /// + /// NCRYPTBUFFER_CERT_BLOB 47 + /// + /// The buffer contains a serialized certificate store that contains the PKCS certificate. This serialized store is obtained by + /// using the CertSaveStore function with the CERT_STORE_SAVE_TO_MEMORY option. When this property is being retrieved, you can + /// access the certificate store by passing this serialized store to the CertOpenStore function with the + /// CERT_STORE_PROV_SERIALIZED option. + /// + /// + /// + /// + public BufferType BufferType; + + /// + /// The buffer. + /// The format and contents of this buffer are identified by the BufferType member. + /// + public byte[] pvBuffer; + + /// Initializes a new instance of the struct. + /// Type of the buffer. + /// The buffer. + public NCryptBuffer(BufferType bufferType, byte[] buffer) + { + BufferType = bufferType; + pvBuffer = buffer; + } + + /// Initializes a new instance of the struct. + /// Type of the buffer. + /// The buffer. + public NCryptBuffer(BufferType bufferType, string buffer) + { + BufferType = bufferType; + pvBuffer = System.Text.Encoding.Unicode.GetBytes(buffer); + } + } + + public static class KnownStorageProvider + { + public const string MS_KEY_STORAGE_PROVIDER = "Microsoft Software Key Storage Provider"; + public const string MS_NGC_KEY_STORAGE_PROVIDER = "Microsoft Passport Key Storage Provider"; + public const string MS_PLATFORM_KEY_STORAGE_PROVIDER = "Microsoft Platform Crypto Provider"; + public const string MS_SMART_CARD_KEY_STORAGE_PROVIDER = "Microsoft Smart Card Key Storage Provider"; + } + + /// The following values are used with the NCryptGetProperty and NCryptSetProperty functions to identify a property. + public static class PropertyName + { + public const string NCRYPT_ALGORITHM_GROUP_PROPERTY = "Algorithm Group"; + public const string NCRYPT_ALGORITHM_PROPERTY = "Algorithm Name"; + public const string NCRYPT_ASSOCIATED_ECDH_KEY = "SmartCardAssociatedECDHKey"; + public const string NCRYPT_AUTH_TAG_LENGTH = "AuthTagLength"; + public const string NCRYPT_BLOCK_LENGTH_PROPERTY = "Block Length"; + public const string NCRYPT_CERTIFICATE_PROPERTY = "SmartCardKeyCertificate"; + public const string NCRYPT_CHAINING_MODE_PROPERTY = "Chaining Mode"; + public const string NCRYPT_DISMISS_UI_TIMEOUT_SEC_PROPERTY = "SmartCardDismissUITimeoutSeconds"; + public const string NCRYPT_ECC_CURVE_NAME_LIST_PROPERTY = BCrypt.PropertyName.BCRYPT_ECC_CURVE_NAME_LIST; + public const string NCRYPT_ECC_CURVE_NAME_PROPERTY = BCrypt.PropertyName.BCRYPT_ECC_CURVE_NAME; + public const string NCRYPT_ECC_PARAMETERS_PROPERTY = BCrypt.PropertyName.BCRYPT_ECC_PARAMETERS; + public const string NCRYPT_EXPORT_POLICY_PROPERTY = "Export Policy"; + public const string NCRYPT_IMPL_TYPE_PROPERTY = "Impl Type"; + public const string NCRYPT_KDF_SECRET_VALUE = "KDFKeySecret"; + public const string NCRYPT_KEY_TYPE_PROPERTY = "Key Type"; + public const string NCRYPT_KEY_USAGE_PROPERTY = "Key Usage"; + public const string NCRYPT_LAST_MODIFIED_PROPERTY = "Modified"; + public const string NCRYPT_LENGTH_PROPERTY = "Length"; + public const string NCRYPT_LENGTHS_PROPERTY = "Lengths"; + public const string NCRYPT_MAX_NAME_LENGTH_PROPERTY = "Max Name Length"; + public const string NCRYPT_NAME_PROPERTY = "Name"; + public const string NCRYPT_PCP_ALTERNATE_KEY_STORAGE_LOCATION_PROPERTY = "PCP_ALTERNATE_KEY_STORAGE_LOCATION"; + public const string NCRYPT_PCP_CHANGEPASSWORD_PROPERTY = "PCP_CHANGEPASSWORD"; + public const string NCRYPT_PCP_ECC_EKCERT_PROPERTY = "PCP_ECC_EKCERT"; + public const string NCRYPT_PCP_ECC_EKNVCERT_PROPERTY = "PCP_ECC_EKNVCERT"; + public const string NCRYPT_PCP_ECC_EKPUB_PROPERTY = "PCP_ECC_EKPUB"; + public const string NCRYPT_PCP_EKCERT_PROPERTY = "PCP_EKCERT"; + public const string NCRYPT_PCP_EKNVCERT_PROPERTY = "PCP_EKNVCERT"; + public const string NCRYPT_PCP_EKPUB_PROPERTY = "PCP_EKPUB"; + public const string NCRYPT_PCP_EXPORT_ALLOWED_PROPERTY = "PCP_EXPORT_ALLOWED"; + public const string NCRYPT_PCP_HMAC_AUTH_NONCE = "PCP_HMAC_AUTH_NONCE"; + public const string NCRYPT_PCP_HMAC_AUTH_POLICYINFO = "PCP_HMAC_AUTH_POLICYINFO"; + public const string NCRYPT_PCP_HMAC_AUTH_POLICYREF = "PCP_HMAC_AUTH_POLICYREF"; + public const string NCRYPT_PCP_HMAC_AUTH_SIGNATURE = "PCP_HMAC_AUTH_SIGNATURE"; + public const string NCRYPT_PCP_HMAC_AUTH_TICKET = "PCP_HMAC_AUTH_TICKET"; + public const string NCRYPT_PCP_KEY_CREATIONHASH_PROPERTY = "PCP_KEY_CREATIONHASH"; + public const string NCRYPT_PCP_KEY_CREATIONTICKET_PROPERTY = "PCP_KEY_CREATIONTICKET"; + public const string NCRYPT_PCP_KEY_USAGE_POLICY_PROPERTY = "PCP_KEY_USAGE_POLICY"; + public const string NCRYPT_PCP_KEYATTESTATION_PROPERTY = "PCP_TPM12_KEYATTESTATION"; + public const string NCRYPT_PCP_MIGRATIONPASSWORD_PROPERTY = "PCP_MIGRATIONPASSWORD"; + public const string NCRYPT_PCP_NO_DA_PROTECTION_PROPERTY = "PCP_NO_DA_PROTECTION"; + public const string NCRYPT_PCP_PASSWORD_REQUIRED_PROPERTY = "PCP_PASSWORD_REQUIRED"; + public const string NCRYPT_PCP_PCRTABLE_PROPERTY = "PCP_PCRTABLE"; + public const string NCRYPT_PCP_PLATFORM_BINDING_PCRDIGEST_PROPERTY = "PCP_PLATFORM_BINDING_PCRDIGEST"; + public const string NCRYPT_PCP_PLATFORM_BINDING_PCRDIGESTLIST_PROPERTY = "PCP_PLATFORM_BINDING_PCRDIGESTLIST"; + public const string NCRYPT_PCP_PLATFORM_BINDING_PCRMASK_PROPERTY = "PCP_PLATFORM_BINDING_PCRMASK"; + public const string NCRYPT_PCP_PLATFORM_TYPE_PROPERTY = "PCP_PLATFORM_TYPE"; + public const string NCRYPT_PCP_PLATFORMHANDLE_PROPERTY = "PCP_PLATFORMHANDLE"; + public const string NCRYPT_PCP_PROVIDER_VERSION_PROPERTY = "PCP_PROVIDER_VERSION"; + public const string NCRYPT_PCP_PROVIDERHANDLE_PROPERTY = "PCP_PROVIDERMHANDLE"; + public const string NCRYPT_PCP_RAW_POLICYDIGEST_PROPERTY = "PCP_RAW_POLICYDIGEST"; + public const string NCRYPT_PCP_RSA_EKCERT_PROPERTY = "PCP_RSA_EKCERT"; + public const string NCRYPT_PCP_RSA_EKNVCERT_PROPERTY = "PCP_RSA_EKNVCERT"; + public const string NCRYPT_PCP_RSA_EKPUB_PROPERTY = "PCP_RSA_EKPUB"; + public const string NCRYPT_PCP_RSA_SCHEME_HASH_ALG_PROPERTY = "PCP_RSA_SCHEME_HASH_ALG"; + public const string NCRYPT_PCP_RSA_SCHEME_PROPERTY = "PCP_RSA_SCHEME"; + public const string NCRYPT_PCP_SESSIONID_PROPERTY = "PCP_SESSIONID"; + public const string NCRYPT_PCP_SRKPUB_PROPERTY = "PCP_SRKPUB"; + public const string NCRYPT_PCP_STORAGEPARENT_PROPERTY = "PCP_STORAGEPARENT"; + public const string NCRYPT_PCP_TPM_FW_VERSION_PROPERTY = "PCP_TPM_FW_VERSION"; + public const string NCRYPT_PCP_TPM_IFX_RSA_KEYGEN_PROHIBITED_PROPERTY = "PCP_TPM_IFX_RSA_KEYGEN_PROHIBITED"; + public const string NCRYPT_PCP_TPM_IFX_RSA_KEYGEN_VULNERABILITY_PROPERTY = "PCP_TPM_IFX_RSA_KEYGEN_VULNERABILITY"; + public const string NCRYPT_PCP_TPM_MANUFACTURER_ID_PROPERTY = "PCP_TPM_MANUFACTURER_ID"; + public const string NCRYPT_PCP_TPM_VERSION_PROPERTY = "PCP_TPM_VERSION"; + public const string NCRYPT_PCP_TPM12_IDACTIVATION_PROPERTY = "PCP_TPM12_IDACTIVATION"; + public const string NCRYPT_PCP_TPM12_IDBINDING_DYNAMIC_PROPERTY = "PCP_TPM12_IDBINDING_DYNAMIC"; + public const string NCRYPT_PCP_TPM12_IDBINDING_PROPERTY = "PCP_TPM12_IDBINDING"; + public const string NCRYPT_PCP_TPM2BNAME_PROPERTY = "PCP_TPM2BNAME"; + public const string NCRYPT_PCP_USAGEAUTH_PROPERTY = "PCP_USAGEAUTH"; + public const string NCRYPT_PIN_PROMPT_PROPERTY = "SmartCardPinPrompt"; + public const string NCRYPT_PIN_PROPERTY = "SmartCardPin"; + public const string NCRYPT_PROVIDER_HANDLE_PROPERTY = "Provider Handle"; + public const string NCRYPT_PUBLIC_LENGTH_PROPERTY = BCrypt.PropertyName.BCRYPT_PUBLIC_KEY_LENGTH; + public const string NCRYPT_READER_ICON_PROPERTY = "SmartCardReaderIcon"; + public const string NCRYPT_READER_PROPERTY = "SmartCardReader"; + public const string NCRYPT_ROOT_CERTSTORE_PROPERTY = "SmartcardRootCertStore"; + public const string NCRYPT_SCARD_PIN_ID = "SmartCardPinId"; + public const string NCRYPT_SCARD_PIN_INFO = "SmartCardPinInfo"; + public const string NCRYPT_SECURE_PIN_PROPERTY = "SmartCardSecurePin"; + public const string NCRYPT_SECURITY_DESCR_PROPERTY = "Security Descr"; + public const string NCRYPT_SECURITY_DESCR_SUPPORT_PROPERTY = "Security Descr Support"; + public const string NCRYPT_SIGNATURE_LENGTH_PROPERTY = BCrypt.PropertyName.BCRYPT_SIGNATURE_LENGTH; + public const string NCRYPT_SMARTCARD_GUID_PROPERTY = "SmartCardGuid"; + public const string NCRYPT_UI_POLICY_PROPERTY = "UI Policy"; + public const string NCRYPT_UNIQUE_NAME_PROPERTY = "Unique Name"; + public const string NCRYPT_USE_CONTEXT_PROPERTY = "Use Context"; + public const string NCRYPT_USE_COUNT_ENABLED_PROPERTY = "Enabled Use Count"; + public const string NCRYPT_USE_COUNT_PROPERTY = "Use Count"; + public const string NCRYPT_USE_PER_BOOT_KEY_PROPERTY = "Per Boot Key"; + public const string NCRYPT_USE_VIRTUAL_ISOLATION_PROPERTY = "Virtual Iso"; + public const string NCRYPT_USER_CERTSTORE_PROPERTY = "SmartCardUserCertStore"; + public const string NCRYPT_VERSION_PROPERTY = "Version"; + public const string NCRYPT_WINDOW_HANDLE_PROPERTY = "HWND Handle"; + } + + /// The BCryptBufferDesc structure is used to contain a set of generic CNG buffers. + // typedef struct _BCryptBufferDesc { ULONG ulVersion; ULONG cBuffers; PBCryptBuffer pBuffers;} BCryptBufferDesc, *PBCryptBufferDesc; https://msdn.microsoft.com/en-us/library/windows/desktop/aa375370(v=vs.85).aspx + [PInvokeData("Bcrypt.h", MSDNShortId = "aa375370")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public class NCryptBufferDesc : IDisposable + { + private const uint BCRYPTBUFFER_VERSION = 0; + + /// + /// The version of the structure. This must be the following value. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// BCRYPTBUFFER_VERSION + /// The default version number. + /// + /// + /// + /// + public uint ulVersion = BCRYPTBUFFER_VERSION; + + /// The number of elements in the pBuffers array. + public uint cBuffers; + + /// + /// The address of an array of BCryptBuffer structures that contain the buffers. The cBuffers member contains the + /// number of elements in this array. + /// + private IntPtr _pBuffers; + + /// + /// The address of an array of BCryptBuffer structures that contain the buffers. The cBuffers member contains the + /// number of elements in this array. + /// + public NCryptBuffer[] pBuffers + { + get => _pBuffers.ToIEnum<_NCryptBuffer>((int)cBuffers).Cast().ToArray(); + set + { + ((IDisposable)this).Dispose(); + if (value == null) return; + _pBuffers = InteropExtensions.MarshalToPtr(value.Select(b => new _NCryptBuffer(b)), Marshal.AllocCoTaskMem, out var _); + } + } + + /// + void IDisposable.Dispose() + { + if (_pBuffers == IntPtr.Zero) return; + foreach (var b in _pBuffers.ToIEnum<_NCryptBuffer>((int)cBuffers)) + Marshal.FreeCoTaskMem(b.pvBuffer); + Marshal.FreeCoTaskMem(_pBuffers); + _pBuffers = IntPtr.Zero; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + private struct _NCryptBuffer + { + /// + /// The size, in bytes, of the buffer. + /// + public uint cbBuffer; + + /// A value that identifies the type of data that is contained by the buffer. + public BufferType BufferType; + + /// + /// The address of the buffer. The size of this buffer is contained in the cbBuffer member. + /// The format and contents of this buffer are identified by the BufferType member. + /// + public IntPtr pvBuffer; + + public _NCryptBuffer(in NCryptBuffer b) + { + cbBuffer = (uint)(b.pvBuffer?.Length ?? 0); + BufferType = b.BufferType; + pvBuffer = b.pvBuffer?.MarshalToPtr(Marshal.AllocCoTaskMem, out var _) ?? IntPtr.Zero; + } + + public static implicit operator NCryptBuffer(_NCryptBuffer b) => new NCryptBuffer { BufferType = b.BufferType, pvBuffer = b.pvBuffer.ToArray((int)b.cbBuffer) }; + } + } + + /// Provides a for that is disposed using . + public class SafeNCRYPT_KEY_HANDLE : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeNCRYPT_KEY_HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeNCRYPT_KEY_HANDLE() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator NCRYPT_HANDLE(SafeNCRYPT_KEY_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator NCRYPT_KEY_HANDLE(SafeNCRYPT_KEY_HANDLE h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => NCryptFreeObject(handle).Succeeded; + } + + /// Provides a for that is disposed using . + public class SafeNCRYPT_PROV_HANDLE : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeNCRYPT_PROV_HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeNCRYPT_PROV_HANDLE() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator NCRYPT_HANDLE(SafeNCRYPT_PROV_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator NCRYPT_PROV_HANDLE(SafeNCRYPT_PROV_HANDLE h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => NCryptFreeObject(handle).Succeeded; + } + + /// Provides a for that is disposed using . + public class SafeNCRYPT_SECRET_HANDLE : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeNCRYPT_SECRET_HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeNCRYPT_SECRET_HANDLE() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator NCRYPT_SECRET_HANDLE(SafeNCRYPT_SECRET_HANDLE h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => NCryptFreeObject(handle).Succeeded; + } + + /* + NCryptCreateClaim + NCryptDecrypt + NCryptEncrypt + NCryptEnumAlgorithms + NCryptEnumKeys + NCryptEnumStorageProviders + NCryptFreeBuffer + NCryptGetProperty + NCryptIsAlgSupported + NCryptIsKeyHandle + NCryptKeyDerivation + NCryptNotifyChangeKey + NCryptSignHash + NCryptTranslateHandle + NCryptVerifyClaim + NCryptVerifySignature + */ + } +} \ No newline at end of file diff --git a/PInvoke/Cryptography/NCrypt/NCryptProtect.cs b/PInvoke/Cryptography/NCrypt/NCryptProtect.cs new file mode 100644 index 00000000..88e15018 --- /dev/null +++ b/PInvoke/Cryptography/NCrypt/NCryptProtect.cs @@ -0,0 +1,1490 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +using Vanara.InteropServices; + +namespace Vanara.PInvoke +{ + /// Methods and data types found in ncrypt.dll. + public static partial class NCrypt + { + /// + /// + /// The PFNCryptStreamOutputCallback function receives encrypted or decrypted data from tasks started by using the + /// NCryptStreamOpenToProtect or NCryptStreamOpenToUnprotect functions. This callback must be defined by your application using the + /// following syntax. + /// + /// + /// + /// Pointer to data that you can use to keep track of your application. The data is not modified by the data protection API. + /// + /// Note You can set a pointer to your context data in the pvCallbackCtxt member of the NCRYPT_PROTECT_STREAM_INFO + /// structure before passing a pointer to that structure in the pStreamInfo parameter of the NCryptStreamOpenToProtect or + /// NCryptStreamOpenToUnprotect functions. + /// + /// + /// + /// Pointer to a block of processed data that can be used by the application. + /// + /// + /// The size, in bytes, of the processed data pointed to by the pbData parameter. + /// + /// + /// + /// If this value is TRUE, the current data block is the last to be processed and this is the last time the callback will be called. + /// + /// + /// + /// + /// If you return any status code other than ERROR_SUCCESS from your implementation of this callback function, the stream + /// encryption or decryption process will fail. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// + /// + /// + /// Set a pointer to this callback function in the pfnStreamOutput member of the NCRYPT_PROTECT_STREAM_INFO structure. Set a + /// pointer to the structure in the pStreamInfo parameter of the NCryptStreamOpenToProtect or NCryptStreamOpenToUnprotect functions. + /// + /// + /// You can use this callback to further process the encrypted or decrypted data. A common use of the function is to write the data + /// to disk as it is received from the data protection API. The blocks of encrypted or unencrypted data are created by the + /// NCryptStreamUpdate function. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nc-ncryptprotect-pfncryptstreamoutputcallback + // PFNCryptStreamOutputCallback Pfncryptstreamoutputcallback; SECURITY_STATUS Pfncryptstreamoutputcallback( void *pvCallbackCtxt, + // const BYTE *pbData, SIZE_T cbData, BOOL fFinal ) {...} + [PInvokeData("ncryptprotect.h", MSDNShortId = "D07B2B63-306B-4C41-AA14-320EFEFFB939")] + [UnmanagedFunctionPointer(CallingConvention.Winapi)] + public delegate HRESULT PFNCryptStreamOutputCallback(IntPtr pvCallbackCtxt, IntPtr pbData, SizeT cbData, [MarshalAs(UnmanagedType.Bool)] bool fFinal); + + /// + /// The PFNCryptStreamOutputCallbackEx function receives encrypted or decrypted data from tasks started by using the + /// NCryptStreamOpenToProtectEx or NCryptStreamOpenToUnprotectEx functions. This callback must be defined by your application using + /// the following syntax. + /// + /// The arguments specified by NCRYPT_PROTECT_STREAM_INFO_EX. + /// + /// A pointer to a block of processed data that is available to the application. If data is not available yet, but the descriptor is, + /// this will be NULL. + /// + /// The size, in bytes, of the processed data pointed to by the pbData parameter. + /// Handle of Protection Descriptor. + /// + /// If this value is TRUE, the current data block is the last to be processed and this is the last time the callback will be called. + /// + /// + /// + /// If you return any status code other than ERROR_SUCCESS from your implementation of this callback function, the stream + /// encryption or decryption process will fail. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// + /// + /// + /// Set a pointer to this callback function in the pfnStreamOutput member of the NCRYPT_PROTECT_STREAM_INFO structure. Set a + /// pointer to the structure in the pStreamInfo parameter of the NCryptStreamOpenToProtect or NCryptStreamOpenToUnprotect functions. + /// + /// + /// You can use this callback to further process the encrypted or decrypted data. A common use of the function is to write the data + /// to disk as it is received from the data protection API. The blocks of encrypted or unencrypted data are created by the + /// NCryptStreamUpdate function. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nc-ncryptprotect-pfncryptstreamoutputcallback + [PInvokeData("ncryptprotect.h")] + [UnmanagedFunctionPointer(CallingConvention.Winapi)] + public delegate HRESULT PFNCryptStreamOutputCallbackEx(IntPtr pvCallbackCtxt, IntPtr pbData, SizeT cbData, NCRYPT_DESCRIPTOR_HANDLE hDescriptor, [MarshalAs(UnmanagedType.Bool)] bool fFinal); + + /// Flags for NCryptCreateProtectionDescriptor. + [PInvokeData("ncryptprotect.h", MSDNShortId = "BA6B15AC-2CD8-4D9A-817F-65CF9C09D22C")] + [Flags] + public enum CreateProtectionDescriptorFlags + { + /// + /// To indicate that the string is a display name and that it is saved, along with its associated descriptor string rule, in the + /// HKEY_CURRENT_USER registry hive, set only the NCRYPT_NAMED_DESCRIPTOR_FLAG value. That is, there is no unique flag to specify + /// the current user registry hive. + /// + NCRYPT_NAMED_DESCRIPTOR_FLAG = 0x00000001, + + /// + /// To indicate that the string is a display name and that it is saved, along with its associated descriptor rule string, in the + /// HKEY_LOCAL_MACHINE registry hive, bitwise-OR the NCRYPT_NAMED_DESCRIPTOR_FLAG value and the NCRYPT_MACHINE_KEY_FLAG value. + /// + NCRYPT_MACHINE_KEY_FLAG = 0x00000020, + } + + /// Flags for NCryptProtectSecret. + [PInvokeData("ncryptprotect.h", MSDNShortId = "8726F92B-34D5-4696-8803-3D7F50F1006D")] + [Flags] + public enum ProtectFlags + { + /// Requests that the key service provider not display a user interface. + NCRYPT_SILENT_FLAG = 0x00000040, + } + + /// Flags used by NCryptGetProtectionDescriptorInfo. + [PInvokeData("ncryptprotect.h", MSDNShortId = "EF4777D5-E218-4868-8D25-58E0EF8C9D30")] + [Flags] + public enum ProtectionDescriptorInfoType + { + /// The ppvInfo argument returns the descriptor rule string. + [CorrespondingType(typeof(string))] + NCRYPT_PROTECTION_INFO_TYPE_DESCRIPTOR_STRING = 0x00000001, + } + + /// Flags for NCryptQueryProtectionDescriptorName. + [PInvokeData("ncryptprotect.h", MSDNShortId = "32953AEC-01EE-4ED1-80F3-29963F43004F")] + [Flags] + public enum ProtectionDescriptorNameFlags + { + /// + /// To indicate that the string is a display name and that it is saved, along with its associated descriptor rule string, in the + /// HKEY_LOCAL_MACHINE registry hive, bitwise-OR the NCRYPT_NAMED_DESCRIPTOR_FLAG value and the NCRYPT_MACHINE_KEY_FLAG value. + /// + NCRYPT_MACHINE_KEY_FLAG = 0x00000020, + } + + /// Flags used by NCryptUnprotectSecret. + [PInvokeData("ncryptprotect.h", MSDNShortId = "F532F0ED-36F4-47E3-B478-089CC083E5D1")] + [Flags] + public enum UnprotectSecretFlags + { + /// Decodes only the header of the protected data blob. No actual decryption takes place. + NCRYPT_UNPROTECT_NO_DECRYPT = 0x00000001, + + /// Requests that the key service provider not display a user interface. + NCRYPT_SILENT_FLAG = 0x00000040, + } + + /// + /// The NCryptCloseProtectionDescriptor function zeros and frees a protection descriptor object and releases its handle. + /// + /// + /// Handle of a protection descriptor created by calling NCryptCreateProtectionDescriptor. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_HANDLE + /// The handle specified by the hDescriptor parameter cannot be NULL and it must represent a valid descriptor. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptcloseprotectiondescriptor + // SECURITY_STATUS NCryptCloseProtectionDescriptor( NCRYPT_DESCRIPTOR_HANDLE hDescriptor ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "523FD83E-85A3-4A0E-BA8D-2F27F82C1072")] + public static extern HRESULT NCryptCloseProtectionDescriptor(NCRYPT_DESCRIPTOR_HANDLE hDescriptor); + + /// + /// The NCryptCreateProtectionDescriptor function retrieves a handle to a protection descriptor object. + /// + /// + /// + /// Null-terminated Unicode string that contains a protection descriptor rule string or a registered display name for the rule. + /// + /// + /// If you specify the display name and you want this function to look in the registry for the associated protection descriptor rule + /// string, you must set the dwFlags parameter to NCRYPT_NAMED_DESCRIPTOR_FLAG. + /// + /// + /// + /// + /// Flag that specifies whether the string in pwszDescriptorString represents the display name of a protection descriptor and, if so, + /// where in the registry the function should search for the associated protection rule string. The following value combinations can + /// be set: + /// + /// + /// + /// + /// To indicate that the value set in the pwszDescriptorString parameter is a complete protection descriptor rule string rather than + /// a display name, set the dwFlags parameter to zero (0). + /// + /// + /// + /// + /// To indicate that the string is a display name and that it is saved, along with its associated descriptor rule string, in the + /// HKEY_LOCAL_MACHINE registry hive, bitwise-OR the NCRYPT_NAMED_DESCRIPTOR_FLAG value and the + /// NCRYPT_MACHINE_KEY_FLAG value. + /// + /// + /// + /// + /// To indicate that the string is a display name and that it is saved, along with its associated descriptor string rule, in the + /// HKEY_CURRENT_USER registry hive, set only the NCRYPT_NAMED_DESCRIPTOR_FLAG value. That is, there is no unique flag + /// to specify the current user registry hive. + /// + /// + /// + /// + /// Note To associate a descriptor rule with a display name and save both in the registry, call the + /// NCryptRegisterProtectionDescriptorName function. + /// + /// + /// + /// Pointer to a protection descriptor object handle. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_PARAMETER + /// + /// The phDescriptor parameter cannot be NULL. The pwszDescriptorString parameter cannot be NULL and it cannot be an empty sting. + /// + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter must be NCRYPT_MACHINE_KEY_FLAG or NCRYPT_NAMED_DESCRIPTOR_FLAG. + /// + /// + /// NTE_NO_MEMORY + /// Memory could not be allocated to retrieve the registered protection descriptor string. + /// + /// + /// NTE_NOT_FOUND + /// The protection descriptor name specified in the pwszDescriptorString parameter could not be found. + /// + /// + /// + /// + /// + /// The protection descriptor object created by this function is an internal data structure that contains information about the + /// descriptor. You cannot use it directly. Your application can, however, use the returned handle in the following functions: + /// + /// + /// + /// NCryptCloseProtectionDescriptor + /// + /// + /// NCryptGetProtectionDescriptorInfo + /// + /// + /// NCryptProtectSecret + /// + /// + /// NCryptProtectSecret + /// + /// + /// NCryptUnprotectSecret + /// + /// + /// NCryptStreamOpenToProtect + /// + /// + /// The following examples show protection descriptor rule strings: + /// + /// + /// "SID=S-1-5-21-4392301 AND SID=S-1-5-21-3101812" + /// + /// + /// "SDDL=O:S-1-5-5-0-290724G:SYD:(A;;CCDC;;;S-1-5-5-0-290724)(A;;DC;;;WD)" + /// + /// + /// "LOCAL=user" + /// + /// + /// "LOCAL=machine" + /// + /// + /// "WEBCREDENTIALS=MyPasswordName" + /// + /// + /// "WEBCREDENTIALS=MyPasswordName,myweb.com" + /// + /// + /// + /// You can use the NCryptRegisterProtectionDescriptorName function to associate a display name with a rule string and save both in + /// the registry. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptcreateprotectiondescriptor + // SECURITY_STATUS NCryptCreateProtectionDescriptor( LPCWSTR pwszDescriptorString, DWORD dwFlags, NCRYPT_DESCRIPTOR_HANDLE + // *phDescriptor ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "BA6B15AC-2CD8-4D9A-817F-65CF9C09D22C")] + public static extern HRESULT NCryptCreateProtectionDescriptor([MarshalAs(UnmanagedType.LPWStr)] string pwszDescriptorString, CreateProtectionDescriptorFlags dwFlags, out SafeNCRYPT_DESCRIPTOR_HANDLE phDescriptor); + + /// + /// The NCryptGetProtectionDescriptorInfo function retrieves a protection descriptor rule string. + /// + /// + /// Protection descriptor handle created by calling NCryptCreateProtectionDescriptor. + /// + /// + /// + /// Pointer to an NCRYPT_ALLOC_PARA structure that you can use to specify custom memory management functions. If you set this + /// argument to NULL, the LocalAlloc function is used internally to allocate memory and your application must call LocalFree + /// to release memory pointed to by the ppvInfo parameter. + /// + /// + /// + /// Specifies how to return descriptor information to the ppvInfo parameter. This can be the following value: + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_PROTECTION_INFO_TYPE_DESCRIPTOR_STRING + /// The ppvInfo argument returns the descriptor rule string. + /// + /// + /// + /// + /// Pointer to the descriptor information. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_PARAMETER + /// The ppvInfo parameter cannot be NULL. + /// + /// + /// NTE_NOT_SUPPORTED + /// An unsupported value was specified in the dwInfoType parameter. + /// + /// + /// NTE_INVALID_HANDLE + /// The handle specified by the hDescriptor parameter is not valid. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptgetprotectiondescriptorinfo + // SECURITY_STATUS NCryptGetProtectionDescriptorInfo( NCRYPT_DESCRIPTOR_HANDLE hDescriptor, const NCRYPT_ALLOC_PARA *pMemPara, DWORD + // dwInfoType, void **ppvInfo ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "EF4777D5-E218-4868-8D25-58E0EF8C9D30")] + public static extern HRESULT NCryptGetProtectionDescriptorInfo(NCRYPT_DESCRIPTOR_HANDLE hDescriptor, in NCRYPT_ALLOC_PARA pMemPara, ProtectionDescriptorInfoType dwInfoType, out IntPtr ppvInfo); + + /// + /// The NCryptGetProtectionDescriptorInfo function retrieves a protection descriptor rule string. + /// + /// + /// Protection descriptor handle created by calling NCryptCreateProtectionDescriptor. + /// + /// + /// + /// Pointer to an NCRYPT_ALLOC_PARA structure that you can use to specify custom memory management functions. If you set this + /// argument to NULL, the LocalAlloc function is used internally to allocate memory and your application must call LocalFree + /// to release memory pointed to by the ppvInfo parameter. + /// + /// + /// + /// Specifies how to return descriptor information to the ppvInfo parameter. This can be the following value: + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_PROTECTION_INFO_TYPE_DESCRIPTOR_STRING + /// The ppvInfo argument returns the descriptor rule string. + /// + /// + /// + /// + /// Pointer to the descriptor information. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_PARAMETER + /// The ppvInfo parameter cannot be NULL. + /// + /// + /// NTE_NOT_SUPPORTED + /// An unsupported value was specified in the dwInfoType parameter. + /// + /// + /// NTE_INVALID_HANDLE + /// The handle specified by the hDescriptor parameter is not valid. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptgetprotectiondescriptorinfo + // SECURITY_STATUS NCryptGetProtectionDescriptorInfo( NCRYPT_DESCRIPTOR_HANDLE hDescriptor, const NCRYPT_ALLOC_PARA *pMemPara, DWORD + // dwInfoType, void **ppvInfo ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "EF4777D5-E218-4868-8D25-58E0EF8C9D30")] + public static extern HRESULT NCryptGetProtectionDescriptorInfo(NCRYPT_DESCRIPTOR_HANDLE hDescriptor, [Optional] IntPtr pMemPara, ProtectionDescriptorInfoType dwInfoType, out IntPtr ppvInfo); + + /// + /// + /// The NCryptProtectSecret function encrypts data to a specified protection descriptor. Call NCryptUnprotectSecret to decrypt + /// the data. + /// + /// + /// + /// Handle of the protection descriptor object. Create the handle by calling NCryptCreateProtectionDescriptor. + /// + /// + /// The flag can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// Requests that the key service provider not display a user interface. + /// + /// + /// + /// + /// Pointer to the byte array to be protected. + /// + /// + /// Number of bytes in the binary array specified by the pbData parameter. + /// + /// + /// + /// Pointer to an NCRYPT_ALLOC_PARA structure that you can use to specify custom memory management functions. If you set this + /// argument to NULL, the LocalAlloc function is used internally to allocate memory and your application must call LocalFree + /// to release memory pointed to by the ppbProtectedBlob parameter. + /// + /// + /// + /// Handle to the parent window of the user interface, if any, to be displayed. + /// + /// + /// Address of a variable that receives a pointer to the encrypted data. + /// + /// + /// + /// Pointer to a ULONG variable that contains the size, in bytes, of the encrypted data pointed to by the ppbProtectedBlob variable. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_PARAMETER + /// + /// The pbData, ppbProtectedBlob, and pcbProtectedBlob parameters cannot be NULL. The cbData parameter cannot be less than one. + /// + /// + /// + /// NTE_NO_MEMORY + /// Insufficient memory exists to allocate the content encryption key. + /// + /// + /// NTE_INVALID_HANDLE + /// The handle specified by the hDescriptor parameter is not valid. + /// + /// + /// + /// + /// + /// Use the NCryptProtectSecret function to protect keys, key material, and passwords. Use the NCryptStreamOpenToProtect and + /// the NCryptStreamUpdate functions to encrypt larger messages. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptprotectsecret SECURITY_STATUS + // NCryptProtectSecret( NCRYPT_DESCRIPTOR_HANDLE hDescriptor, DWORD dwFlags, const BYTE *pbData, ULONG cbData, const + // NCRYPT_ALLOC_PARA *pMemPara, HWND hWnd, BYTE **ppbProtectedBlob, ULONG *pcbProtectedBlob ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "8726F92B-34D5-4696-8803-3D7F50F1006D")] + public static extern HRESULT NCryptProtectSecret(NCRYPT_DESCRIPTOR_HANDLE hDescriptor, ProtectFlags dwFlags, [In] IntPtr pbData, uint cbData, in NCRYPT_ALLOC_PARA pMemPara, HWND hWnd, + out IntPtr ppbProtectedBlob, out uint pcbProtectedBlob); + + /// + /// + /// The NCryptProtectSecret function encrypts data to a specified protection descriptor. Call NCryptUnprotectSecret to decrypt + /// the data. + /// + /// + /// + /// Handle of the protection descriptor object. Create the handle by calling NCryptCreateProtectionDescriptor. + /// + /// + /// The flag can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// Requests that the key service provider not display a user interface. + /// + /// + /// + /// + /// Pointer to the byte array to be protected. + /// + /// + /// Number of bytes in the binary array specified by the pbData parameter. + /// + /// + /// + /// Pointer to an NCRYPT_ALLOC_PARA structure that you can use to specify custom memory management functions. If you set this + /// argument to NULL, the LocalAlloc function is used internally to allocate memory and your application must call LocalFree + /// to release memory pointed to by the ppbProtectedBlob parameter. + /// + /// + /// + /// Handle to the parent window of the user interface, if any, to be displayed. + /// + /// + /// Address of a variable that receives a pointer to the encrypted data. + /// + /// + /// + /// Pointer to a ULONG variable that contains the size, in bytes, of the encrypted data pointed to by the ppbProtectedBlob variable. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_PARAMETER + /// + /// The pbData, ppbProtectedBlob, and pcbProtectedBlob parameters cannot be NULL. The cbData parameter cannot be less than one. + /// + /// + /// + /// NTE_NO_MEMORY + /// Insufficient memory exists to allocate the content encryption key. + /// + /// + /// NTE_INVALID_HANDLE + /// The handle specified by the hDescriptor parameter is not valid. + /// + /// + /// + /// + /// + /// Use the NCryptProtectSecret function to protect keys, key material, and passwords. Use the NCryptStreamOpenToProtect and + /// the NCryptStreamUpdate functions to encrypt larger messages. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptprotectsecret SECURITY_STATUS + // NCryptProtectSecret( NCRYPT_DESCRIPTOR_HANDLE hDescriptor, DWORD dwFlags, const BYTE *pbData, ULONG cbData, const + // NCRYPT_ALLOC_PARA *pMemPara, HWND hWnd, BYTE **ppbProtectedBlob, ULONG *pcbProtectedBlob ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "8726F92B-34D5-4696-8803-3D7F50F1006D")] + public static extern HRESULT NCryptProtectSecret(NCRYPT_DESCRIPTOR_HANDLE hDescriptor, ProtectFlags dwFlags, [In] IntPtr pbData, uint cbData, [Optional] IntPtr pMemPara, HWND hWnd, + out IntPtr ppbProtectedBlob, out uint pcbProtectedBlob); + + /// + /// + /// The NCryptQueryProtectionDescriptorName function retrieves the protection descriptor rule string associated with a + /// registered descriptor display name. + /// + /// + /// + /// + /// The registered display name for the protection descriptor. Register a name by calling the NCryptRegisterProtectionDescriptorName function. + /// + /// + /// + /// + /// A null-terminated Unicode string that contains the protection descriptor rule. Set this value to NULL and set the size of + /// the descriptor string pointed to by pcDescriptorString argument to zero on your initial call to this function. For more + /// information, see Remarks. + /// + /// + /// + /// + /// Pointer to a variable that contains the number of characters in the string retrieved in the pwszDescriptorString parameter. Set + /// the variable to zero on your initial call to this function. For more information, see Remarks. + /// + /// + /// + /// + /// Flag that specifies which registry hive to query for the registered name. This can be zero to look in the + /// HKEY_CURRENT_USER hive or you can specify NCRYPT_MACHINE_KEY_FLAG to query the HKEY_LOCAL_MACHINE hive. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_PARAMETER + /// The pwszName parameter cannot be NULL, and the value pointed to by the parameter cannot be an empty string. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter must be zero or NCRYPT_MACHINE_KEY_FLAG. + /// + /// + /// + /// + /// + /// To retrieve a protection descriptor rule string, you must call this function twice. The first time you call, set the + /// pwszDescriptorString argument to NULL and the value pointed to by the pcDescriptorString argument to zero. Your first call + /// retrieves the number of characters in the descriptor string. Use this number to allocate memory for the string and retrieve a + /// pointer to the allocated buffer. To retrieve the string, call the function again using the pointer. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptqueryprotectiondescriptorname + // SECURITY_STATUS NCryptQueryProtectionDescriptorName( LPCWSTR pwszName, LPWSTR pwszDescriptorString, SIZE_T *pcDescriptorString, + // DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "32953AEC-01EE-4ED1-80F3-29963F43004F")] + public static extern HRESULT NCryptQueryProtectionDescriptorName(string pwszName, StringBuilder pwszDescriptorString, out SizeT pcDescriptorString, ProtectionDescriptorNameFlags dwFlags); + + /// + /// + /// The NCryptRegisterProtectionDescriptorName function registers the display name and the associated rule string for a + /// protection descriptor. + /// + /// + /// + /// Pointer to a null-terminated Unicode string that contains the display name of the descriptor to be registered. + /// + /// + /// + /// Pointer to a null-terminated Unicode string that contains a protection descriptor rule. If this parameter is NULL or the + /// string is empty, the registry value previously created for the pwszName parameter will be deleted. + /// + /// + /// + /// + /// A constant that indicates the registry hive under which to register the new entry. If this value is zero (0), the registry root + /// is HKEY_CURRENT_USER. If this value is NCRYPT_MACHINE_KEY_FLAG, the root is HKEY_LOCAL_MACHINE. + /// + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_PARAMETER + /// The pwszName parameter cannot be NULL, and the value pointed to by the parameter cannot be an empty string. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter must be zero or NCRYPT_MACHINE_KEY_FLAG. + /// + /// + /// + /// + /// + /// The registry key created by using this function is not volatile. The information is stored in a file and preserved when the + /// computer shuts down. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptregisterprotectiondescriptorname + // SECURITY_STATUS NCryptRegisterProtectionDescriptorName( LPCWSTR pwszName, LPCWSTR pwszDescriptorString, DWORD dwFlags ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "DAB03CB2-630F-4BB3-93BD-06BE9126B1C4")] + public static extern HRESULT NCryptRegisterProtectionDescriptorName(string pwszName, string pwszDescriptorString, ProtectionDescriptorNameFlags dwFlags); + + /// + /// + /// The NCryptStreamClose function closes a data protection stream object opened by using the NCryptStreamOpenToProtect or + /// NCryptStreamOpenToUnprotect functions. + /// + /// + /// + /// Data stream handle returned by NCryptStreamOpenToProtect or NCryptStreamOpenToUnprotect. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_INVALID_HANDLE + /// The handle specified by the hStream parameter is not valid. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptstreamclose SECURITY_STATUS + // NCryptStreamClose( NCRYPT_STREAM_HANDLE hStream ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "770640F2-04C7-4512-8004-41F4ECDC110E")] + public static extern HRESULT NCryptStreamClose(NCRYPT_STREAM_HANDLE hStream); + + /// + /// + /// The NCryptStreamOpenToProtect function opens a stream object that can be used to encrypt large amounts of data to a given + /// protection descriptor. Call NCryptStreamUpdate to encrypt the content. To encrypt smaller messages such as keys and passwords, + /// call NCryptProtectSecret. + /// + /// + /// + /// Handle of the protection descriptor. Create the handle by calling NCryptCreateProtectionDescriptor. + /// + /// + /// The flag can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// Requests that the key service provider not display a user interface. + /// + /// + /// + /// + /// Handle to the parent window of the user interface, if any, to be displayed. + /// + /// + /// + /// Pointer to an NCRYPT_PROTECT_STREAM_INFO structure that contains the address of a user defined callback function to receive the + /// encrypted data and a pointer to user-defined context data. + /// + /// + /// + /// Pointer to the stream object handle. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter must contain zero (0), NCRYPT_MACHINE_KEY_FLAG, or NCRYPT_SILENT_FLAG. + /// + /// + /// NTE_INVALID_HANDLE + /// The handle specified by the hDescriptor parameter is not valid. + /// + /// + /// NTE_INVALID_PARAMETER + /// + /// The phStream and pStreamInfo parameters cannot be NULL. The callback function pointed to by the pfnStreamOutput member of the + /// NCRYPT_PROTECT_STREAM_INFO structure pointed to by the pStreamInfo parameter cannot be NULL. + /// + /// + /// + /// NTE_NO_MEMORY + /// There was insufficient memory to allocate a data stream. + /// + /// + /// + /// + /// + /// The NCryptStreamOpenToProtect function creates an internal stream object that can be used to encrypt large messages. You + /// cannot use the object directly. Instead, you must use the object handle returned by this function. + /// + /// + /// Call this function before calling the NCryptStreamUpdate function. If you are encrypting a large file, use + /// NCryptStreamUpdate in a loop that advances through the file block by block, encrypting each block as it advances and + /// notifying your callback when each block is finished. For more information, see NCryptStreamUpdate. + /// + /// + /// The NCryptStreamOpenToProtect function writes the unencrypted protection descriptor rule string to the stream object + /// header so that NCryptStreamOpenToUnprotect will be able to start the decrypting the stream by using the same protector used + /// during encryption. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptstreamopentoprotect SECURITY_STATUS + // NCryptStreamOpenToProtect( NCRYPT_DESCRIPTOR_HANDLE hDescriptor, DWORD dwFlags, HWND hWnd, NCRYPT_PROTECT_STREAM_INFO + // *pStreamInfo, NCRYPT_STREAM_HANDLE *phStream ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "7DE74BB1-1B84-4721-BE4A-4D2661E93E00")] + public static extern HRESULT NCryptStreamOpenToProtect(NCRYPT_DESCRIPTOR_HANDLE hDescriptor, ProtectFlags dwFlags, HWND hWnd, in NCRYPT_PROTECT_STREAM_INFO pStreamInfo, out SafeNCRYPT_STREAM_HANDLE phStream); + + /// + /// + /// The NCryptStreamOpenToUnprotect function opens a stream object that can be used to decrypt large amounts of data to the + /// same protection descriptor used for encryption. Call NCryptStreamUpdate to perform the decryption. To decrypt smaller messages + /// such as keys and passwords, call NCryptUnprotectSecret. + /// + /// + /// + /// + /// Pointer to an NCRYPT_PROTECT_STREAM_INFO structure that contains the address of a user defined callback function to receive the + /// decrypted data and a pointer to user-defined context data. + /// + /// + /// + /// A flag that specifies additional information for the key service provider. This can be zero or the following value. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// Requests that the key service provider not display a user interface. + /// + /// + /// + /// + /// Handle to the parent window of the user interface, if any, to be displayed. + /// + /// + /// Pointer to the handle of the decrypted stream of data. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter must contain zero (0) or NCRYPT_SILENT_FLAG. + /// + /// + /// NTE_INVALID_PARAMETER + /// + /// The phStream and pStreamInfo parameters cannot be NULL. The callback function pointed to by the pfnStreamOutput member of the + /// NCRYPT_PROTECT_STREAM_INFO structure pointed to by the pStreamInfo parameter cannot be NULL. + /// + /// + /// + /// NTE_NO_MEMORY + /// There was insufficient memory to allocate a data stream. + /// + /// + /// + /// + /// + /// The NCryptStreamOpenToUnprotect function creates an internal stream object that can be used to encrypt large messages. You + /// cannot use the object directly. Instead, you must use the object handle returned by this function. + /// + /// + /// Call this function before calling the NCryptStreamUpdate function. If you are encrypting a large file, use + /// NCryptStreamUpdate in a loop that advances through the file block by block, encrypting each block as it advances and + /// notifying your callback when each block is finished. For more information, see NCryptStreamUpdate. + /// + /// + /// The NCryptStreamOpenToUnprotect function retrieves the unencrypted protection descriptor rule string from the stream + /// header. The rule string is placed in the header by the NCryptStreamOpenToUnprotect function. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptstreamopentounprotect SECURITY_STATUS + // NCryptStreamOpenToUnprotect( NCRYPT_PROTECT_STREAM_INFO *pStreamInfo, DWORD dwFlags, HWND hWnd, NCRYPT_STREAM_HANDLE *phStream ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "9848082E-EDDA-4DA1-9896-42EAF2ADFAB4")] + public static extern HRESULT NCryptStreamOpenToUnprotect(in NCRYPT_PROTECT_STREAM_INFO pStreamInfo, ProtectFlags dwFlags, HWND hWnd, out SafeNCRYPT_STREAM_HANDLE phStream); + + /// + /// + /// [Some information relates to pre-released product which may be substantially modified before it's commercially released. + /// Microsoft makes no warranties, express or implied, with respect to the information provided here.] + /// + /// + /// Opens a stream object that can be used to decrypt large amounts of data to the same protection descriptor used for + /// encryption.Call NCryptStreamUpdate to perform the decryption. To decrypt smaller messages such as keys and passwords, call NCryptUnprotectSecret. + /// + /// + /// + /// A pointer to NCRYPT_PROTECT_STREAM_INFO_EX. + /// + /// + /// Only the NCRYPT_SILENT_FLAG is supported. + /// + /// + /// A window handle to be used as the parent of any user interface that is displayed. + /// + /// + /// Receives a pointer to a stream handle. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited to: + /// + /// + /// + /// ERROR_SUCCESS + /// + /// + /// NTE_INVALID_PARAMETER + /// + /// + /// NTE_BAD_FLAGS + /// + /// + /// NTE_BAD_DATA + /// + /// + /// NTE_NO_MEMORY + /// + /// + /// NTE_NOT_FOUND + /// + /// + /// NTE_NOT_SUPPORTED + /// + /// + /// NTE_INVALID_HANDLE + /// + /// + /// NTE_BAD_KEY + /// + /// + /// NTE_BAD_PROVIDER + /// + /// + /// NTE_BAD_TYPE + /// + /// + /// NTE_DECRYPTION_FAILURE + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptstreamopentounprotectex SECURITY_STATUS + // NCryptStreamOpenToUnprotectEx( NCRYPT_PROTECT_STREAM_INFO_EX *pStreamInfo, DWORD dwFlags, HWND hWnd, NCRYPT_STREAM_HANDLE + // *phStream ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "8E607F4F-4A0F-4796-8F40-D232687815AF")] + public static extern HRESULT NCryptStreamOpenToUnprotectEx(in NCRYPT_PROTECT_STREAM_INFO_EX pStreamInfo, ProtectFlags dwFlags, HWND hWnd, out SafeNCRYPT_STREAM_HANDLE phStream); + + /// + /// The NCryptStreamUpdate function encrypts and decrypts blocks of data. + /// + /// + /// Handle to the stream object created by calling NCryptStreamOpenToProtect or NCryptStreamOpenToUnprotect. + /// + /// + /// Pointer to the byte array to be processed. + /// + /// + /// Number of bytes in the binary array specified by the pbData parameter. + /// + /// + /// A Boolean value that specifies whether the last block of data has been processed. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_DATA + /// The content could not be decoded. + /// + /// + /// NTE_INVALID_HANDLE + /// The stream handle pointed to by the hStream parameter is not valid. + /// + /// + /// NTE_NO_MEMORY + /// There was insufficient memory available to process the content. + /// + /// + /// + /// + /// You must call NCryptStreamOpenToProtect or NCryptStreamOpenToUnprotect to open a stream before calling NCryptStreamUpdate + /// + /// Messages can be so large that processing them all at once by storing the entire message in memory can be difficult. It is + /// possible, however, to process large messages by partitioning the data to be processed into manageable blocks. + /// + /// + /// To do this, use NCryptStreamUpdate in a loop that advances through the file block by block. As the streamed message is + /// processed, the resulting output data is passed back to your application by using a callback function that you specify. This is + /// shown by the following example. For more information about the callback function, see PFNCryptStreamOutputCallback. + /// + /// + /// Note We recommend against using too small of a block size. Small blocks require more calls and therefore more calling + /// overhead. Further, the streaming APIs are optimized for larger blocks. You should experiment to find the best block size for the + /// data you must process. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptstreamupdate SECURITY_STATUS + // NCryptStreamUpdate( NCRYPT_STREAM_HANDLE hStream, const BYTE *pbData, SIZE_T cbData, BOOL fFinal ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "417F9267-6055-489C-AF26-BEF5E17CB8B4")] + public static extern HRESULT NCryptStreamUpdate(NCRYPT_STREAM_HANDLE hStream, IntPtr pbData, SizeT cbData, [MarshalAs(UnmanagedType.Bool)] bool fFinal); + + /// + /// + /// The NCryptUnprotectSecret function decrypts data to a specified protection descriptor. Call NCryptProtectSecret to encrypt + /// the data. + /// + /// + /// + /// Pointer to the protection descriptor handle. + /// + /// + /// The flag can be zero or a bitwise OR of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// Requests that the key service provider not display a user interface. + /// + /// + /// NCRYPT_UNPROTECT_NO_DECRYPT + /// Decodes only the header of the protected data blob. No actual decryption takes place. + /// + /// + /// + /// + /// Pointer to an array of bytes that contains the data to decrypt. + /// + /// + /// The number of bytes in the array pointed to by the pbProtectedBlob parameter. + /// + /// + /// + /// Pointer to an NCRYPT_ALLOC_PARA structure that you can use to specify custom memory management functions. If you set this + /// argument to NULL, the LocalAlloc function is used internally to allocate memory and your application must call LocalFree + /// to release memory pointed to by the ppbData parameter. + /// + /// + /// + /// Handle to the parent window of the user interface, if any, to be displayed. + /// + /// + /// Address of a variable that receives a pointer to the decrypted data. + /// + /// + /// Pointer to a ULONG variable that contains the size, in bytes, of the decrypted data pointed to by the ppbData variable. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter can only contain NCRYPT_SILENT_FLAG or NCRYPT_UNPROTECT_NO_DECRYPT. + /// + /// + /// NTE_INVALID_PARAMETER + /// The pbProtectedBlob, ppbData, and pcbData parameters cannot be NULL. The cbData parameter cannot be less than one. + /// + /// + /// + /// + /// + /// Use the NCryptUnprotectSecret function to decrypt keys, key material, and passwords. Use the NCryptStreamOpenToUnprotect + /// and the NCryptStreamUpdate functions to decrypt larger messages. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptunprotectsecret SECURITY_STATUS + // NCryptUnprotectSecret( NCRYPT_DESCRIPTOR_HANDLE *phDescriptor, DWORD dwFlags, const BYTE *pbProtectedBlob, ULONG cbProtectedBlob, + // const NCRYPT_ALLOC_PARA *pMemPara, HWND hWnd, BYTE **ppbData, ULONG *pcbData ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "F532F0ED-36F4-47E3-B478-089CC083E5D1")] + public static extern HRESULT NCryptUnprotectSecret(out SafeNCRYPT_DESCRIPTOR_HANDLE phDescriptor, UnprotectSecretFlags dwFlags, [In] IntPtr pbProtectedBlob, uint cbProtectedBlob, in NCRYPT_ALLOC_PARA pMemPara, + HWND hWnd, out IntPtr ppbData, out uint pcbData); + + /// + /// + /// The NCryptUnprotectSecret function decrypts data to a specified protection descriptor. Call NCryptProtectSecret to encrypt + /// the data. + /// + /// + /// + /// Pointer to the protection descriptor handle. + /// + /// + /// The flag can be zero or a bitwise OR of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// NCRYPT_SILENT_FLAG + /// Requests that the key service provider not display a user interface. + /// + /// + /// NCRYPT_UNPROTECT_NO_DECRYPT + /// Decodes only the header of the protected data blob. No actual decryption takes place. + /// + /// + /// + /// + /// Pointer to an array of bytes that contains the data to decrypt. + /// + /// + /// The number of bytes in the array pointed to by the pbProtectedBlob parameter. + /// + /// + /// + /// Pointer to an NCRYPT_ALLOC_PARA structure that you can use to specify custom memory management functions. If you set this + /// argument to NULL, the LocalAlloc function is used internally to allocate memory and your application must call LocalFree + /// to release memory pointed to by the ppbData parameter. + /// + /// + /// + /// Handle to the parent window of the user interface, if any, to be displayed. + /// + /// + /// Address of a variable that receives a pointer to the decrypted data. + /// + /// + /// Pointer to a ULONG variable that contains the size, in bytes, of the decrypted data pointed to by the ppbData variable. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. Possible return codes include, but are not limited + /// to, the following. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// ERROR_SUCCESS + /// The function was successful. + /// + /// + /// NTE_BAD_FLAGS + /// The dwFlags parameter can only contain NCRYPT_SILENT_FLAG or NCRYPT_UNPROTECT_NO_DECRYPT. + /// + /// + /// NTE_INVALID_PARAMETER + /// The pbProtectedBlob, ppbData, and pcbData parameters cannot be NULL. The cbData parameter cannot be less than one. + /// + /// + /// + /// + /// + /// Use the NCryptUnprotectSecret function to decrypt keys, key material, and passwords. Use the NCryptStreamOpenToUnprotect + /// and the NCryptStreamUpdate functions to decrypt larger messages. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/nf-ncryptprotect-ncryptunprotectsecret SECURITY_STATUS + // NCryptUnprotectSecret( NCRYPT_DESCRIPTOR_HANDLE *phDescriptor, DWORD dwFlags, const BYTE *pbProtectedBlob, ULONG cbProtectedBlob, + // const NCRYPT_ALLOC_PARA *pMemPara, HWND hWnd, BYTE **ppbData, ULONG *pcbData ); + [DllImport(Lib.Ncrypt, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ncryptprotect.h", MSDNShortId = "F532F0ED-36F4-47E3-B478-089CC083E5D1")] + public static extern HRESULT NCryptUnprotectSecret(out SafeNCRYPT_DESCRIPTOR_HANDLE phDescriptor, UnprotectSecretFlags dwFlags, [In] IntPtr pbProtectedBlob, uint cbProtectedBlob, [Optional] IntPtr pMemPara, + HWND hWnd, out IntPtr ppbData, out uint pcbData); + + /// Provides a handle to a protection descriptor. + [StructLayout(LayoutKind.Sequential)] + public struct NCRYPT_DESCRIPTOR_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public NCRYPT_DESCRIPTOR_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static NCRYPT_DESCRIPTOR_HANDLE NULL => new NCRYPT_DESCRIPTOR_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(NCRYPT_DESCRIPTOR_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator NCRYPT_DESCRIPTOR_HANDLE(IntPtr h) => new NCRYPT_DESCRIPTOR_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(NCRYPT_DESCRIPTOR_HANDLE h1, NCRYPT_DESCRIPTOR_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(NCRYPT_DESCRIPTOR_HANDLE h1, NCRYPT_DESCRIPTOR_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is NCRYPT_DESCRIPTOR_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// + /// The NCRYPT_PROTECT_STREAM_INFO structure is used by the NCryptStreamOpenToProtect and NCryptStreamOpenToUnprotect + /// functions to pass blocks of processed data to your application. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ncryptprotect/ns-ncryptprotect-ncrypt_protect_stream_info typedef struct + // NCRYPT_PROTECT_STREAM_INFO { PFNCryptStreamOutputCallback pfnStreamOutput; void *pvCallbackCtxt; } NCRYPT_PROTECT_STREAM_INFO; + [PInvokeData("ncryptprotect.h", MSDNShortId = "77FADFC1-6C66-4801-B0BD-263963555C3C")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct NCRYPT_PROTECT_STREAM_INFO + { + /// + /// Address of a callback function that accepts data from the stream encryption or decryption process. for more information, see PFNCryptStreamOutputCallback. + /// + public PFNCryptStreamOutputCallback pfnStreamOutput; + + /// + /// Pointer to a buffer supplied the caller. The buffer is not modified by the data protection API. You can use the buffer to + /// keep track of your application. + /// + public IntPtr pvCallbackCtxt; + } + + /// + /// The NCRYPT_PROTECT_STREAM_INFO_EX structure is used by the NCryptStreamOpenToProtectEx and NCryptStreamOpenToUnprotectEx + /// functions to pass blocks of processed data to your application. + /// + [PInvokeData("ncryptprotect.h")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct NCRYPT_PROTECT_STREAM_INFO_EX + { + /// + /// Address of a callback function that accepts data from the stream encryption or decryption process. for more information, see PFNCryptStreamOutputCallback. + /// + public PFNCryptStreamOutputCallbackEx pfnStreamOutput; + + /// + /// Pointer to a buffer supplied the caller. The buffer is not modified by the data protection API. You can use the buffer to + /// keep track of your application. + /// + public IntPtr pvCallbackCtxt; + } + + /// Provides a handle to a data protection stream object. + [StructLayout(LayoutKind.Sequential)] + public struct NCRYPT_STREAM_HANDLE : IHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public NCRYPT_STREAM_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static NCRYPT_STREAM_HANDLE NULL => new NCRYPT_STREAM_HANDLE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(NCRYPT_STREAM_HANDLE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator NCRYPT_STREAM_HANDLE(IntPtr h) => new NCRYPT_STREAM_HANDLE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(NCRYPT_STREAM_HANDLE h1, NCRYPT_STREAM_HANDLE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(NCRYPT_STREAM_HANDLE h1, NCRYPT_STREAM_HANDLE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is NCRYPT_STREAM_HANDLE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + + /// Provides a for that is disposed using . + public class SafeNCRYPT_DESCRIPTOR_HANDLE : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeNCRYPT_DESCRIPTOR_HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeNCRYPT_DESCRIPTOR_HANDLE() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator NCRYPT_DESCRIPTOR_HANDLE(SafeNCRYPT_DESCRIPTOR_HANDLE h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => NCryptCloseProtectionDescriptor(this).Succeeded; + } + + /// Provides a for that is disposed using . + public class SafeNCRYPT_STREAM_HANDLE : HANDLE + { + /// Initializes a new instance of the class and assigns an existing handle. + /// An object that represents the pre-existing handle to use. + /// + /// to reliably release the handle during the finalization phase; otherwise, (not recommended). + /// + public SafeNCRYPT_STREAM_HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeNCRYPT_STREAM_HANDLE() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator NCRYPT_STREAM_HANDLE(SafeNCRYPT_STREAM_HANDLE h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => NCryptStreamClose(this).Succeeded; + } + } +} \ No newline at end of file diff --git a/PInvoke/Cryptography/NCrypt/SslProvider.cs b/PInvoke/Cryptography/NCrypt/SslProvider.cs new file mode 100644 index 00000000..99ec223b --- /dev/null +++ b/PInvoke/Cryptography/NCrypt/SslProvider.cs @@ -0,0 +1,46 @@ +using System; +using System.Linq; +using System.Runtime.InteropServices; +using Vanara.Extensions; +using Vanara.InteropServices; + +namespace Vanara.PInvoke +{ + /// Methods and data types found in NCrypt.dll. + public static partial class NCrypt + { + /* + SslChangeNotify + SslComputeClientAuthHash + SslComputeEapKeyBlock + SslComputeFinishedHash + SslCreateClientAuthHash + SslCreateEphemeralKey + SslCreateHandshakeHash + SslDecrementProviderReferenceCount + SslDecryptPacket + SslEncryptPacket + SslEnumCipherSuites + SslEnumProtocolProviders + SslExportKey + SslExportKeyingMaterial + SslFreeBuffer + SslFreeObject + SslGenerateMasterKey + SslGenerateSessionKeys + SslGetCipherSuitePRFHashAlgorithm + SslGetKeyProperty + SslGetProviderProperty + SslHashHandshake + SslImportKey + SslImportMasterKey + SslIncrementProviderReferenceCount + SslLookupCipherLengths + SslLookupCipherSuiteInfo + SslOpenPrivateKey + SslOpenProvider + SslSignHash + SslVerifySignature + */ + } +} \ No newline at end of file diff --git a/PInvoke/Cryptography/TokenBinding/TokenBinding.cs b/PInvoke/Cryptography/TokenBinding/TokenBinding.cs new file mode 100644 index 00000000..ede8902f --- /dev/null +++ b/PInvoke/Cryptography/TokenBinding/TokenBinding.cs @@ -0,0 +1,426 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + /// Methods and data types found in TokenBinding.dll. + public static partial class TokenBinding + { + /// + /// Specifies the formats that are available to interpret extension data. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/ne-tokenbinding-tokenbinding_extension_format typedef enum + // TOKENBINDING_EXTENSION_FORMAT { TOKENBINDING_EXTENSION_FORMAT_UNDEFINED } ; + [PInvokeData("tokenbinding.h", MSDNShortId = "EBF14890-3F7D-4814-93E1-570E81E05DF2")] + public enum TOKENBINDING_EXTENSION_FORMAT + { + /// The format for interpreting the extension data is undefined. + TOKENBINDING_EXTENSION_FORMAT_UNDEFINED, + } + + /// Undocumented. + public enum TOKENBINDING_KEY_PARAMETERS_TYPE + { + /// Undocumented. + TOKENBINDING_KEY_PARAMETERS_TYPE_RSA2048_PKCS = 0, + + /// Undocumented. + TOKENBINDING_KEY_PARAMETERS_TYPE_RSA2048_PSS = 1, + + /// Undocumented. + TOKENBINDING_KEY_PARAMETERS_TYPE_ECDSAP256 = 2, + } + + /// + /// Specifies the possible types for a token binding. + /// + /// + /// + /// More information about the use of these Token Binding types can be found in the Token Binding over HTTP Internet draft. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/ne-tokenbinding-tokenbinding_type typedef enum TOKENBINDING_TYPE + // { TOKENBINDING_TYPE_PROVIDED, TOKENBINDING_TYPE_REFERRED } ; + [PInvokeData("tokenbinding.h", MSDNShortId = "7F126B3E-1033-4C0A-AD5F-0FAD951C85C6")] + public enum TOKENBINDING_TYPE + { + /// + /// This type of Token Binding is used to protect tokens issued by the Identity Provider for the client to present with + /// subsequent requests back to this Identity Provider. + /// + TOKENBINDING_TYPE_PROVIDED, + + /// + /// This type of Token Binding is used to protect tokens issued by the Identity Provider for the client to present to a Relying Party. + /// + TOKENBINDING_TYPE_REFERRED, + } + + /// + /// Deletes all token binding keys that are associated with the calling user or app container. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// You can call TokenBindingDeleteAllBindings from user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/nf-tokenbinding-tokenbindingdeleteallbindings SECURITY_STATUS + // TokenBindingDeleteAllBindings( ); + [DllImport(Lib.Tokenbinding, SetLastError = false, ExactSpelling = true)] + [PInvokeData("tokenbinding.h", MSDNShortId = "0446F62F-96B4-4F4B-9789-0CD12173E601")] + public static extern HRESULT TokenBindingDeleteAllBindings(); + + /// + /// Deletes the token binding key that is associated with the specified target string. + /// + /// + /// The target string for which TokenBindingDeleteBinding should delete the associated token binding key. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// You can call TokenBindingDeleteBinding from user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/nf-tokenbinding-tokenbindingdeletebinding SECURITY_STATUS + // TokenBindingDeleteBinding( PCWSTR targetURL ); + [DllImport(Lib.Tokenbinding, SetLastError = false, ExactSpelling = true)] + [PInvokeData("tokenbinding.h", MSDNShortId = "4258CC92-580E-403C-9AE4-4BB726255464")] + public static extern HRESULT TokenBindingDeleteBinding([MarshalAs(UnmanagedType.LPWStr)] string targetURL); + + /// + /// + /// Constructs one token binding that contains the exported public key and signature by using the specified key type for the token + /// binding, a target identifier string for creating and retrieving the token binding key, and the unique data. This function also + /// returns the token binding identifier, if needed. + /// + /// + /// + /// + /// The negotiated key type to use. Use a value from the list of key types that you retrieved by calling the + /// TokenBindingGetKeyTypesClient function. + /// + /// + /// + /// + /// The target string to use in conjunction with the key type to generate or retrieve a token binding key for the NCrypt operations + /// that build the buffer for the tokenBinding parameter. + /// + /// + /// + /// The type of token binding that TokenBindingGenerateBinding should generate. + /// + /// + /// A pointer to the buffer that contains unique data. + /// + /// + /// The size of the buffer that the tlsUnique parameter points to, in bytes. + /// + /// + /// The format to use to interpret the data in the extensionData parameter. This value must be TOKENBINDING_EXTENSION_FORMAT_UNDEFINED. + /// + /// + /// + /// A pointer to a buffer that contains extension data. The value of the extensionFormat parameter determines how to interpret this data. + /// + /// + /// + /// + /// A pointer that receives the address of the token binding buffer. Use the HeapAlloc function to allocate the memory for this + /// buffer, and the HeapFree function to free that memory. + /// + /// + /// + /// Pointer to a variable that receives the size of the buffer allocated for the tokenBinding parameter, in bytes. + /// + /// + /// + /// A pointer that receives the address of the buffer that contains result data that includes the token binding identifier of the + /// token binding that TokenBindingGenerateBinding generates. Use the HeapAlloc function to allocate the memory for this + /// buffer, and the HeapFree function to free that memory. Specify NULL is you do not need this information. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// You can call TokenBindingGenerateBinding from user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/nf-tokenbinding-tokenbindinggeneratebinding SECURITY_STATUS + // TokenBindingGenerateBinding( TOKENBINDING_KEY_PARAMETERS_TYPE keyType, PCWSTR targetURL, TOKENBINDING_TYPE bindingType, const void + // *tlsEKM, DWORD tlsEKMSize, TOKENBINDING_EXTENSION_FORMAT extensionFormat, const void *extensionData, void **tokenBinding, DWORD + // *tokenBindingSize, TOKENBINDING_RESULT_DATA **resultData ); + [DllImport(Lib.Tokenbinding, SetLastError = false, ExactSpelling = true)] + [PInvokeData("tokenbinding.h", MSDNShortId = "4289E3F0-17AC-485B-A326-2C8BECD5CABB")] + public static extern HRESULT TokenBindingGenerateBinding(TOKENBINDING_KEY_PARAMETERS_TYPE keyType, [MarshalAs(UnmanagedType.LPWStr)] string targetURL, TOKENBINDING_TYPE bindingType, [In] IntPtr tlsEKM, + uint tlsEKMSize, TOKENBINDING_EXTENSION_FORMAT extensionFormat, [In] IntPtr extensionData, out IntPtr tokenBinding, out uint tokenBindingSize, out IntPtr resultData); + + /// + /// + /// Constructs the token binding identifier by extracting the signature algorithm from the key type and copying the exported public key. + /// + /// + /// + /// + /// The negotiated key type to use. Use a value from the list of key types that you retrieved by calling the + /// TokenBindingGetKeyTypesClient function. + /// + /// + /// + /// An exported public key blob. + /// + /// + /// The size of the exported public key blob. + /// + /// + /// + /// A pointer that receives the address of the buffer that is allocated for the token binding result data. The token binding result + /// data contains the token binding identifier. + /// + /// Use the HeapAlloc function to allocate the memory for this buffer, and the HeapFree method to free that memory. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// You can call TokenBindingGenerateID from user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/nf-tokenbinding-tokenbindinggenerateid SECURITY_STATUS + // TokenBindingGenerateID( TOKENBINDING_KEY_PARAMETERS_TYPE keyType, const void *publicKey, DWORD publicKeySize, + // TOKENBINDING_RESULT_DATA **resultData ); + [DllImport(Lib.Tokenbinding, SetLastError = false, ExactSpelling = true)] + [PInvokeData("tokenbinding.h", MSDNShortId = "F3E30DF8-2A1D-445E-914B-62999428BB6F")] + public static extern HRESULT TokenBindingGenerateID(TOKENBINDING_KEY_PARAMETERS_TYPE keyType, [In] IntPtr publicKey, uint publicKeySize, out IntPtr resultData); + + /// + /// Assembles the list of token bindings and generates the final message for the client device to the server. + /// + /// + /// Pointer to an array of token binding structures. + /// + /// + /// + /// An array that contains the sizes of the corresponding token binding structures that the array in the tokenBindings parameter + /// contains, in bytes. + /// + /// + /// + /// The number of elements that the array in the tokenBindings parameter contains. This value cannot be 0. + /// + /// + /// + /// A pointer that receives the address of the buffer that is allocated for the token binding message. Use the HeapAlloc function to + /// allocate the memory for this buffer, and the HeapFree method to free that memory. + /// + /// + /// + /// A pointer to a variable that contains the size of the buffer allocated for the tokenBindingMessage parameter. + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// You can call TokenBindingGenerateMessage from user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/nf-tokenbinding-tokenbindinggeneratemessage SECURITY_STATUS + // TokenBindingGenerateMessage( const void * [] tokenBindings, const DWORD [] tokenBindingsSize, DWORD tokenBindingsCount, void + // **tokenBindingMessage, DWORD *tokenBindingMessageSize ); + [DllImport(Lib.Tokenbinding, SetLastError = false, ExactSpelling = true)] + [PInvokeData("tokenbinding.h", MSDNShortId = "7A268C6D-952B-482A-835D-89D6452D986D")] + public static extern HRESULT TokenBindingGenerateMessage([In] IntPtr[] tokenBindings, [In] uint[] tokenBindingsSize, uint tokenBindingsCount, out IntPtr tokenBindingMessage, out uint tokenBindingMessageSize); + + /// + /// Retrieves a list of the key types that the client device supports. + /// + /// + /// + /// A pointer to a buffer that contains the list of key types that the client device supports. TokenBindingGetKeyTypesClient + /// returns the string identifiers for well-known algorithms that correspond to the keys that the client device supports. Use + /// HeapAlloc to allocate the memory for the buffer, and HeapFree to free that memory. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// You can call TokenBindingGetKeyTypesClient from user mode. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/nf-tokenbinding-tokenbindinggetkeytypesclient SECURITY_STATUS + // TokenBindingGetKeyTypesClient( TOKENBINDING_KEY_TYPES **keyTypes ); + [DllImport(Lib.Tokenbinding, SetLastError = false, ExactSpelling = true)] + [PInvokeData("tokenbinding.h", MSDNShortId = "583687B6-5A87-4616-A5EE-4FECFF06749E")] + public static extern HRESULT TokenBindingGetKeyTypesClient(out IntPtr keyTypes); + + /// + /// Retrieves a list of the key types that the server supports. + /// + /// + /// + /// A pointer to a buffer that contains the list of key types that the server supports. TokenBindingGetKeyTypesServer returns + /// the string identifiers for well-known algorithms that correspond to the keys that the server supports. + /// + /// + /// In user mode, use HeapAlloc to allocate the memory for the buffer, and HeapFree to free that memory. In kernel mode, use + /// ExAllocatePoolWithTag to allocate the memory for the buffer, and ExFreePool to free that memory. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// + /// You can call TokenBindingGetKeyTypesServer from both user mode and kernel mode. To call this function in kernel mode, link + /// to Ksecdd.sys, and use the functions mentioned in the description for the keyTypes parameter for allocating and freeing memory. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/nf-tokenbinding-tokenbindinggetkeytypesserver SECURITY_STATUS + // TokenBindingGetKeyTypesServer( TOKENBINDING_KEY_TYPES **keyTypes ); + [DllImport(Lib.Tokenbinding, SetLastError = false, ExactSpelling = true)] + [PInvokeData("tokenbinding.h", MSDNShortId = "8ABAC0AF-AF68-4742-9C36-3FB17D303409")] + public static extern HRESULT TokenBindingGetKeyTypesServer(out IntPtr keyTypes); + + /// + /// Validates the token binding message and verifies the token bindings that the message contains. + /// + /// + /// A pointer to the buffer that contains the token binding message. + /// + /// + /// The size of the buffer that the tokenBindingMessage parameter points to, in bytes. + /// + /// + /// + /// The negotiated key algorithm to use. Use a value from the list of key types that you retrieved by calling the + /// TokenBindingGetKeyTypesServer function. + /// + /// + /// + /// A pointer to a buffer that contains unique data. + /// + /// + /// The size of the buffer that the tlsUnique parameter points to, in bytes. + /// + /// + /// + /// A pointer that receives the address for the buffer that contains the results for each of the token bindings that + /// TokenBindingVerifyMessage verifies. + /// + /// + /// In user mode, use HeapAlloc to allocate the memory for the buffer, and HeapFree to free that memory. In kernel mode, use + /// ExAllocatePoolWithTag to allocate the memory for the buffer, and ExFreePool to free that memory. + /// + /// + /// + /// Returns a status code that indicates the success or failure of the function. + /// + /// + /// + /// You can call TokenBindingVerifyMessage from both user mode and kernel mode. o call this function in kernel mode, link to + /// Ksecdd.sys, and use the functions mentioned in the description for the resultList parameter for allocating and freeing memory. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/nf-tokenbinding-tokenbindingverifymessage SECURITY_STATUS + // TokenBindingVerifyMessage( const void *tokenBindingMessage, DWORD tokenBindingMessageSize, TOKENBINDING_KEY_PARAMETERS_TYPE + // keyType, const void *tlsEKM, DWORD tlsEKMSize, TOKENBINDING_RESULT_LIST **resultList ); + [DllImport(Lib.Tokenbinding, SetLastError = false, ExactSpelling = true)] + [PInvokeData("tokenbinding.h", MSDNShortId = "D6827DA3-75DC-4F31-B57A-4ED5B5F03112")] + public static extern HRESULT TokenBindingVerifyMessage([In] IntPtr tokenBindingMessage, uint tokenBindingMessageSize, TOKENBINDING_KEY_PARAMETERS_TYPE keyType, [In] IntPtr tlsEKM, + uint tlsEKMSize, out IntPtr resultList); + + /// + /// Contains the information for representing a token binding identifier that results from a token binding message exchange. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/ns-tokenbinding-tokenbinding_identifier typedef struct + // TOKENBINDING_IDENTIFIER { BYTE keyType; } TOKENBINDING_IDENTIFIER; + [PInvokeData("tokenbinding.h", MSDNShortId = "301E099E-B621-41E1-BF9B-3AF8C53F9227")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct TOKENBINDING_IDENTIFIER + { + /// + public byte keyType; + } + + /// + /// Contains all of the combinations of types of token binding keys that a client device or server supports. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/ns-tokenbinding-tokenbinding_key_types typedef struct + // TOKENBINDING_KEY_TYPES { DWORD keyCount; TOKENBINDING_KEY_PARAMETERS_TYPE *keyType; } TOKENBINDING_KEY_TYPES; + [PInvokeData("tokenbinding.h", MSDNShortId = "E5029CE3-CD23-4566-A951-35374DC7BC57")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct TOKENBINDING_KEY_TYPES + { + /// + /// The number of elements in the array that the key member contains. + /// + public uint keyCount; + + /// + public IntPtr keyType; + } + + /// + /// + /// Contains data about the result of generating a token binding or verifying one of the token bindings in a token binding message. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/ns-tokenbinding-tokenbinding_result_data typedef struct + // TOKENBINDING_RESULT_DATA { TOKENBINDING_TYPE bindingType; DWORD identifierSize; TOKENBINDING_IDENTIFIER *identifierData; + // TOKENBINDING_EXTENSION_FORMAT extensionFormat; DWORD extensionSize; PVOID extensionData; } TOKENBINDING_RESULT_DATA; + [PInvokeData("tokenbinding.h", MSDNShortId = "6C34E174-CCC4-451D-82C3-C410C8C92C8C")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct TOKENBINDING_RESULT_DATA + { + /// + public TOKENBINDING_TYPE bindingType; + + /// + /// The size of the TOKENBINDING_IDENTIFIER structure that the identifierData member points to, in bytes. + /// + public uint identifierSize; + + /// + /// Pointer to the token binding identifier for the token binding that was generated or verified. + /// + public IntPtr identifierData; + + /// + /// The format to use to interpret the data in the extensionData parameter. This value must be TOKENBINDING_EXTENSION_FORMAT_UNDEFINED. + /// + public TOKENBINDING_EXTENSION_FORMAT extensionFormat; + + /// + /// The size of the buffer that the extensionData member points to, in bytes. + /// + public uint extensionSize; + + /// + /// + /// A pointer to a buffer that contains extension data. The value of the extensionFormat parameter determines how to interpret + /// this data. + /// + /// + public IntPtr extensionData; + } + + /// + /// Contains the results for each of the token bindings that TokenBindingVerifyMessage verified. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/tokenbinding/ns-tokenbinding-tokenbinding_result_list typedef struct + // TOKENBINDING_RESULT_LIST { DWORD resultCount; TOKENBINDING_RESULT_DATA *resultData; } TOKENBINDING_RESULT_LIST; + [PInvokeData("tokenbinding.h", MSDNShortId = "D14CBEA3-5F46-4C45-8C11-407D6E70FD56")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct TOKENBINDING_RESULT_LIST + { + /// + /// The number of elements in the array that the resultData member contains. + /// + public uint resultCount; + + /// + /// An array of results, one for each of the token bindings that TokenBindingVerifyMessage verified. + /// + public IntPtr resultData; + } + } +} \ No newline at end of file diff --git a/PInvoke/Cryptography/Vanara.PInvoke.Cryptography.csproj b/PInvoke/Cryptography/Vanara.PInvoke.Cryptography.csproj new file mode 100644 index 00000000..2854eb52 --- /dev/null +++ b/PInvoke/Cryptography/Vanara.PInvoke.Cryptography.csproj @@ -0,0 +1,61 @@ + + + + Methods, structures and constants imported from BCrypt.dll and NCrypt.dll. + Copyright © 2017-2018 + $(AssemblyName) + 2.0.1 + net20;net35;net40;net45;netstandard2.0 + Vanara.PInvoke.Cryptography + $(AssemblyName) + Vanara.PInvoke + David Hall + https://github.com/dahall/vanara + https://github.com/dahall/vanara/blob/master/LICENSE + https://raw.githubusercontent.com/dahall/Vanara/master/docs/icons/Vanara48x48.png + https://github.com/dahall/vanara + Git + pinvoke vanara net-extensions interop cryptography + en-US + true + true + GitHub Community + Vanara + True + Currently implements: + +Functions +BCryptAddContextFunction, BCryptCloseAlgorithmProvider, BCryptConfigureContext, BCryptConfigureContextFunction, BCryptCreateContext, BCryptCreateHash, BCryptCreateMultiHash, BCryptDecrypt, BCryptDeleteContext, BCryptDeriveKey, BCryptDeriveKeyCapi, BCryptDeriveKeyPBKDF2, BCryptDestroyHash, BCryptDestroyKey, BCryptDestroySecret, BCryptDuplicateHash, BCryptDuplicateKey, BCryptEncrypt, BCryptEnumAlgorithms, BCryptEnumContextFunctionProviders, BCryptEnumContextFunctions, BCryptEnumContexts, BCryptEnumProviders, BCryptEnumRegisteredProviders, BCryptExportKey, BCryptFinalizeKeyPair, BCryptFinishHash, BCryptFreeBuffer, BCryptGenerateKeyPair, BCryptGenerateSymmetricKey, BCryptGenRandom, BCryptGetFipsAlgorithmMode, BCryptGetProperty, BCryptHash, BCryptHashData, BCryptImportKey, BCryptImportKeyPair, BCryptKeyDerivation, BCryptOpenAlgorithmProvider, BCryptProcessMultiOperations, BCryptQueryContextConfiguration, BCryptQueryContextFunctionConfiguration, BCryptQueryContextFunctionProperty, BCryptQueryProviderRegistration, BCryptRegisterConfigChangeNotify, BCryptRemoveContextFunction, BCryptResolveProviders, BCryptSecretAgreement, BCryptSetContextFunctionProperty, BCryptSetProperty, BCryptSignHash, BCryptUnregisterConfigChangeNotify, BCryptVerifySignature, NCryptCloseProtectionDescriptor, NCryptCreatePersistedKey, NCryptCreateProtectionDescriptor, NCryptDeleteKey, NCryptDeriveKey, NCryptExportKey, NCryptFinalizeKey, NCryptFreeObject, NCryptGetProtectionDescriptorInfo, NCryptImportKey, NCryptOpenKey, NCryptOpenStorageProvider, NCryptProtectSecret, NCryptQueryProtectionDescriptorName, NCryptRegisterProtectionDescriptorName, NCryptSecretAgreement, NCryptSetProperty, NCryptStreamClose, NCryptStreamOpenToProtect, NCryptStreamOpenToUnprotect, NCryptStreamOpenToUnprotectEx, NCryptStreamUpdate, NCryptUnprotectSecret, TokenBindingDeleteAllBindings, TokenBindingDeleteBinding, TokenBindingGenerateBinding, TokenBindingGenerateID, TokenBindingGenerateMessage, TokenBindingGetKeyTypesClient, TokenBindingGetKeyTypesServer, TokenBindingVerifyMessage + +Structures +BCRYPT_ALG_HANDLE, BCRYPT_ALGORITHM_IDENTIFIER, BCRYPT_HANDLE, BCRYPT_HASH_HANDLE, BCRYPT_KEY_HANDLE, BCRYPT_MULTI_HASH_OPERATION, BCRYPT_OAEP_PADDING_INFO, BCRYPT_PKCS1_PADDING_INFO, BCRYPT_PROVIDER_NAME, BCRYPT_PSS_PADDING_INFO, BCRYPT_SECRET_HANDLE, CRYPT_CONTEXT_CONFIG, CRYPT_CONTEXT_FUNCTION_CONFIG, CRYPT_CONTEXT_FUNCTION_PROVIDERS, CRYPT_CONTEXT_FUNCTIONS, CRYPT_CONTEXTS, CRYPT_PROVIDERS, CERT_CONTEXT, CERT_EXTENSION, CERT_INFO, CERT_PUBLIC_KEY_INFO, CRYPT_ALGORITHM_IDENTIFIER, CRYPTOAPI_BLOB, NCRYPT_ALLOC_PARA, NCRYPT_HANDLE, NCRYPT_KEY_HANDLE, NCRYPT_PROV_HANDLE, NCRYPT_SECRET_HANDLE, NCryptBuffer, NCryptBufferDesc, NCRYPT_DESCRIPTOR_HANDLE, NCRYPT_PROTECT_STREAM_INFO, NCRYPT_PROTECT_STREAM_INFO_EX, NCRYPT_STREAM_HANDLE, TOKENBINDING_IDENTIFIER, TOKENBINDING_KEY_TYPES, TOKENBINDING_RESULT_DATA, TOKENBINDING_RESULT_LIST + + + latest + true + ..\..\Vanara.snk + + + + + + true + bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PInvoke/DwmApi/CorrelationReport.md b/PInvoke/DwmApi/CorrelationReport.md index db89f329..f3ec5607 100644 --- a/PInvoke/DwmApi/CorrelationReport.md +++ b/PInvoke/DwmApi/CorrelationReport.md @@ -1,5 +1,5 @@ ## Correlation report for dwmapi.dll -### Methods (100% complete) +### Methods (96% complete) Native Method | Native DLL | Header | Managed Method --- | --- | --- | --- [DwmDefWindowProc](https://www.google.com/search?num=5&q=DwmDefWindowProc+site%3Amicrosoft.com) | dwmapi.dll | dwmapi.h | Vanara.PInvoke.DwmApi.DwmDefWindowProc @@ -11,6 +11,7 @@ Native Method | Native DLL | Header | Managed Method [DwmGetColorizationColor](https://www.google.com/search?num=5&q=DwmGetColorizationColor+site%3Amicrosoft.com) | dwmapi.dll | dwmapi.h | Vanara.PInvoke.DwmApi.DwmGetColorizationColor [DwmGetCompositionTimingInfo](https://www.google.com/search?num=5&q=DwmGetCompositionTimingInfo+site%3Amicrosoft.com) | dwmapi.dll | dwmapi.h | Vanara.PInvoke.DwmApi.DwmGetCompositionTimingInfo [DwmGetTransportAttributes](https://www.google.com/search?num=5&q=DwmGetTransportAttributes+site%3Amicrosoft.com) | dwmapi.dll | dwmapi.h | Vanara.PInvoke.DwmApi.DwmGetTransportAttributes +[DwmGetUnmetTabRequirements](https://www.google.com/search?num=5&q=DwmGetUnmetTabRequirements+site%3Amicrosoft.com) | dwmapi.dll | | [DwmGetWindowAttribute](https://www.google.com/search?num=5&q=DwmGetWindowAttribute+site%3Amicrosoft.com) | dwmapi.dll | dwmapi.h | Vanara.PInvoke.DwmApi.DwmGetWindowAttribute [DwmInvalidateIconicBitmaps](https://www.google.com/search?num=5&q=DwmInvalidateIconicBitmaps+site%3Amicrosoft.com) | dwmapi.dll | dwmapi.h | Vanara.PInvoke.DwmApi.DwmInvalidateIconicBitmaps [DwmIsCompositionEnabled](https://www.google.com/search?num=5&q=DwmIsCompositionEnabled+site%3Amicrosoft.com) | dwmapi.dll | dwmapi.h | Vanara.PInvoke.DwmApi.DwmIsCompositionEnabled @@ -30,6 +31,7 @@ Native Method | Native DLL | Header | Managed Method ### Structures Native Structure | Header | Managed Structure --- | --- | --- +[DWM_BLURBEHIND](https://www.google.com/search?num=5&q=DWM_BLURBEHIND+site%3Amicrosoft.com) | dwmapi.h | Vanara.PInvoke.DwmApi+DWM_BLURBEHIND [DWM_COLORIZATION_PARAMS](https://www.google.com/search?num=5&q=DWM_COLORIZATION_PARAMS+site%3Amicrosoft.com) | dwmapi.h | Vanara.PInvoke.DwmApi+DWM_COLORIZATION_PARAMS [DWM_THUMBNAIL_PROPERTIES](http://msdn2.microsoft.com/en-us/library/aa969502) | Dwmapi.h | Vanara.PInvoke.DwmApi+DWM_THUMBNAIL_PROPERTIES [DWM_TIMING_INFO](https://www.google.com/search?num=5&q=DWM_TIMING_INFO+site%3Amicrosoft.com) | dwmapi.h | Vanara.PInvoke.DwmApi+DWM_TIMING_INFO diff --git a/PInvoke/DwmApi/Vanara.PInvoke.DwmApi.csproj b/PInvoke/DwmApi/Vanara.PInvoke.DwmApi.csproj index 439b5c23..3c59c03f 100644 --- a/PInvoke/DwmApi/Vanara.PInvoke.DwmApi.csproj +++ b/PInvoke/DwmApi/Vanara.PInvoke.DwmApi.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from DwmApi.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.PInvoke.DwmApi $(AssemblyName) @@ -28,10 +28,12 @@ Functions DwmDefWindowProc, DwmEnableBlurBehindWindow, DwmEnableComposition, DwmEnableMMCSS, DwmExtendFrameIntoClientArea, DwmFlush, DwmGetColorizationColor, DwmGetCompositionTimingInfo, DwmGetTransportAttributes, DwmGetWindowAttribute, DwmInvalidateIconicBitmaps, DwmIsCompositionEnabled, DwmpGetColorizationParameters, DwmpSetColorizationParameters, DwmQueryThumbnailSourceSize, DwmRegisterThumbnail, DwmRenderGesture, DwmSetIconicLivePreviewBitmap, DwmSetIconicThumbnail, DwmSetWindowAttribute, DwmShowContact, DwmTetherContact, DwmTransitionOwnedWindow, DwmUnregisterThumbnail, DwmUpdateThumbnailProperties Structures -DWM_COLORIZATION_PARAMS, DWM_THUMBNAIL_PROPERTIES, DWM_TIMING_INFO, MARGINS, UNSIGNED_RATIO +DWM_BLURBEHIND, DWM_COLORIZATION_PARAMS, DWM_THUMBNAIL_PROPERTIES, DWM_TIMING_INFO, MARGINS, UNSIGNED_RATIO latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/Gdi32/Vanara.PInvoke.Gdi32.csproj b/PInvoke/Gdi32/Vanara.PInvoke.Gdi32.csproj index 726b4e2f..f0471b3a 100644 --- a/PInvoke/Gdi32/Vanara.PInvoke.Gdi32.csproj +++ b/PInvoke/Gdi32/Vanara.PInvoke.Gdi32.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from Gdi32.dll Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.PInvoke.Gdi32 $(AssemblyName) @@ -32,6 +32,8 @@ BITMAP, BITMAPINFO, BITMAPINFOHEADER, DIBSECTION, RGBQUAD, BLENDFUNCTION, LOGBRU latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/IpHlpApi/Vanara.PInvoke.IpHlpApi.csproj b/PInvoke/IpHlpApi/Vanara.PInvoke.IpHlpApi.csproj index 89b533f6..fa7d9e1e 100644 --- a/PInvoke/IpHlpApi/Vanara.PInvoke.IpHlpApi.csproj +++ b/PInvoke/IpHlpApi/Vanara.PInvoke.IpHlpApi.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from IpHlpApi.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.IpHlpApi $(AssemblyName) @@ -32,6 +32,8 @@ IP_ADAPTER_INDEX_MAP, NET_LUID, FIXED_INFO, IP_ADAPTER_ADDRESSES, IP_ADAPTER_ANY latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/Kernel32/CorrelationReport.md b/PInvoke/Kernel32/CorrelationReport.md index e54ee6ba..3aeda668 100644 --- a/PInvoke/Kernel32/CorrelationReport.md +++ b/PInvoke/Kernel32/CorrelationReport.md @@ -1,5 +1,5 @@ ## Correlation report for kernel32.dll, kernelbase.dll -### Methods (98% complete) +### Methods (99% complete) Native Method | Native DLL | Header | Managed Method --- | --- | --- | --- [AcquireSRWLockExclusive](http://msdn2.microsoft.com/en-us/library/ms681930) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.AcquireSRWLockExclusive @@ -214,7 +214,6 @@ Native Method | Native DLL | Header | Managed Method [ExitProcess](http://msdn2.microsoft.com/en-us/library/ms682658) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.ExitProcess [ExitThread](http://msdn2.microsoft.com/en-us/library/ms682659) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.ExitThread [ExpandEnvironmentStrings](http://msdn2.microsoft.com/en-us/library/ms724265) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.ExpandEnvironmentStrings -[ExpungeConsoleCommandHistory](https://www.google.com/search?num=5&q=ExpungeConsoleCommandHistoryA+site%3Amicrosoft.com) | kernelbase.dll | | [FatalAppExit](http://msdn2.microsoft.com/en-us/library/ms679336) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.FatalAppExit [FatalExit](http://msdn2.microsoft.com/en-us/library/ms679337) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.FatalExit [FileTimeToDosDateTime](http://msdn2.microsoft.com/en-us/library/ms724274) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.FileTimeToDosDateTime @@ -290,7 +289,7 @@ Native Method | Native DLL | Header | Managed Method [GetCommConfig](http://msdn2.microsoft.com/en-us/library/aa363256) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetCommConfig [GetCommMask](http://msdn2.microsoft.com/en-us/library/aa363257) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetCommMask [GetCommModemStatus](http://msdn2.microsoft.com/en-us/library/aa363258) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetCommModemStatus -[GetCommPorts](https://www.google.com/search?num=5&q=GetCommPorts+site%3Amicrosoft.com) | kernelbase.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetCommPorts +[GetCommPorts](http://msdn2.microsoft.com/en-us/library/8E57FB62-D7A0-4B47-942B-E33E0B7A37B1) | kernelbase.dll | winbase.h | Vanara.PInvoke.Kernel32.GetCommPorts [GetCommProperties](http://msdn2.microsoft.com/en-us/library/aa363259) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetCommProperties [GetCommState](http://msdn2.microsoft.com/en-us/library/aa363260) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetCommState [GetCommTimeouts](http://msdn2.microsoft.com/en-us/library/aa363261) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetCommTimeouts @@ -501,7 +500,7 @@ Native Method | Native DLL | Header | Managed Method [GetSystemRegistryQuota](http://msdn2.microsoft.com/en-us/library/ms724387) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetSystemRegistryQuota [GetSystemTime](http://msdn2.microsoft.com/en-us/library/ms724390) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetSystemTime [GetSystemTimeAdjustment](http://msdn2.microsoft.com/en-us/library/ms724394) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetSystemTimeAdjustment -[GetSystemTimeAdjustmentPrecise](https://www.google.com/search?num=5&q=GetSystemTimeAdjustmentPrecise+site%3Amicrosoft.com) | kernelbase.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetSystemTimeAdjustmentPrecise +[GetSystemTimeAdjustmentPrecise](http://msdn2.microsoft.com/en-us/library/95EEE23D-01D8-49E1-BA64-49C07E8B1619) | kernelbase.dll | sysinfoapi.h | Vanara.PInvoke.Kernel32.GetSystemTimeAdjustmentPrecise [GetSystemTimeAsFileTime](http://msdn2.microsoft.com/en-us/library/ms724397) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetSystemTimeAsFileTime [GetSystemTimePreciseAsFileTime](http://msdn2.microsoft.com/en-us/library/hh706895) | kernel32.dll | WinBase.h | Vanara.PInvoke.Kernel32.GetSystemTimePreciseAsFileTime [GetSystemTimes](http://msdn2.microsoft.com/en-us/library/ms724400) | kernel32.dll | Winbase.h | Vanara.PInvoke.Kernel32.GetSystemTimes @@ -1101,9 +1100,11 @@ Native Method | Native DLL | Header | Managed Method ### Structures Native Structure | Header | Managed Structure --- | --- | --- +[ACTCTX](http://msdn2.microsoft.com/en-us/library/aa374149) | Winbase.h | Vanara.PInvoke.Kernel32+ACTCTX [ACTCTX_SECTION_KEYED_DATA](http://msdn2.microsoft.com/en-us/library/aa374148) | Winbase.h | Vanara.PInvoke.Kernel32+ACTCTX_SECTION_KEYED_DATA [APP_MEMORY_INFORMATION](http://msdn2.microsoft.com/en-us/library/mt767995) | WinBase.h | Vanara.PInvoke.Kernel32+APP_MEMORY_INFORMATION [BLOCK_DATA](https://www.google.com/search?num=5&q=BLOCK_DATA+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PROCESS_HEAP_ENTRY+BLOCK_REGION_UNION+BLOCK_DATA +[BoundaryDescriptorHandle](https://www.google.com/search?num=5&q=BoundaryDescriptorHandle+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+BoundaryDescriptorHandle [BY_HANDLE_FILE_INFORMATION](http://msdn2.microsoft.com/en-us/library/aa363788) | FileAPI.h | Vanara.PInvoke.Kernel32+BY_HANDLE_FILE_INFORMATION [CACHE_DESCRIPTOR](http://msdn2.microsoft.com/en-us/library/ms681979) | WinNT.h | Vanara.PInvoke.Kernel32+CACHE_DESCRIPTOR [CACHE_RELATIONSHIP](http://msdn2.microsoft.com/en-us/library/f8fe521b-02d6-4c58-8ef8-653280add111) | winnt.h | Vanara.PInvoke.Kernel32+CACHE_RELATIONSHIP @@ -1132,6 +1133,9 @@ Native Structure | Header | Managed Structure [CPINFO](http://msdn2.microsoft.com/en-us/library/dd317780) | Winnls.h | Vanara.PInvoke.Kernel32+CPINFO [CPINFOEX](http://msdn2.microsoft.com/en-us/library/dd317781) | Winnls.h | Vanara.PInvoke.Kernel32+CPINFOEX [CPU_RATE_CONTROL_UNION](https://www.google.com/search?num=5&q=CPU_RATE_CONTROL_UNION+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+JOBOBJECT_CPU_RATE_CONTROL_INFORMATION+CPU_RATE_CONTROL_UNION +[CREATE_PROCESS_DEBUG_INFO](http://msdn2.microsoft.com/en-us/library/ms679286) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+CREATE_PROCESS_DEBUG_INFO +[CREATE_THREAD_DEBUG_INFO](http://msdn2.microsoft.com/en-us/library/ms679287) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+CREATE_THREAD_DEBUG_INFO +[CREATEFILE2_EXTENDED_PARAMETERS](http://msdn2.microsoft.com/en-us/library/hh449426) | FileAPI.h | Vanara.PInvoke.Kernel32+CREATEFILE2_EXTENDED_PARAMETERS [CRITICAL_SECTION](https://www.google.com/search?num=5&q=CRITICAL_SECTION+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+CRITICAL_SECTION [CURRENCYFMT](http://msdn2.microsoft.com/en-us/library/dd317784) | Winnls.h | Vanara.PInvoke.Kernel32+CURRENCYFMT [DCB](http://msdn2.microsoft.com/en-us/library/aa363214) | Winbase.h | Vanara.PInvoke.Kernel32+DCB @@ -1165,6 +1169,7 @@ Native Structure | Header | Managed Structure [FILE_ID_INFO](http://msdn2.microsoft.com/en-us/library/e2774e29-1a90-44d6-9001-f73a98be6624) | winbase.h | Vanara.PInvoke.Kernel32+FILE_ID_INFO [FILE_IO_PRIORITY_HINT_INFO](http://msdn2.microsoft.com/en-us/library/a142b8fd-b71c-4449-a8c6-fb23715d1576) | winbase.h | Vanara.PInvoke.Kernel32+FILE_IO_PRIORITY_HINT_INFO [FILE_NAME_INFO](http://msdn2.microsoft.com/en-us/library/7ab98f41-b99e-4731-b803-921064a961c4) | winbase.h | Vanara.PInvoke.Kernel32+FILE_NAME_INFO +[FILE_RENAME_INFO](http://msdn2.microsoft.com/en-us/library/f4de0130-66fd-4847-bb6f-3f16fe17ca6e) | winbase.h | Vanara.PInvoke.Kernel32+FILE_RENAME_INFO [FILE_STANDARD_INFO](http://msdn2.microsoft.com/en-us/library/da3187de-7de2-4307-a083-ae5fff6d8096) | winbase.h | Vanara.PInvoke.Kernel32+FILE_STANDARD_INFO [FILE_STORAGE_INFO](http://msdn2.microsoft.com/en-us/library/1aa9585d-9001-4d94-babe-a39c8dde2332) | winbase.h | Vanara.PInvoke.Kernel32+FILE_STORAGE_INFO [FILE_STREAM_INFO](http://msdn2.microsoft.com/en-us/library/36d1b0b3-bd6b-41e7-937a-4e8deef6f9da) | winbase.h | Vanara.PInvoke.Kernel32+FILE_STREAM_INFO @@ -1181,7 +1186,10 @@ Native Structure | Header | Managed Structure [HEAP_SUMMARY](https://www.google.com/search?num=5&q=HEAP_SUMMARY+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+HEAP_SUMMARY [HEAPENTRY32](http://msdn2.microsoft.com/en-us/library/c5f1dc66-d44f-4491-b0b7-961b163d0f1f) | tlhelp32.h | Vanara.PInvoke.Kernel32+HEAPENTRY32 [HEAPLIST32](http://msdn2.microsoft.com/en-us/library/61e01d23-9f15-44c5-9f6d-45df4809ccad) | tlhelp32.h | Vanara.PInvoke.Kernel32+HEAPLIST32 +[HGLOBAL](https://www.google.com/search?num=5&q=HGLOBAL+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+HGLOBAL [HJOB](https://www.google.com/search?num=5&q=HJOB+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+HJOB +[HLOCAL](https://www.google.com/search?num=5&q=HLOCAL+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+HLOCAL +[HSNAPSHOT](https://www.google.com/search?num=5&q=HSNAPSHOT+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+HSNAPSHOT [INIT_ONCE](https://www.google.com/search?num=5&q=INIT_ONCE+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+INIT_ONCE [INPUT_RECORD](https://www.google.com/search?num=5&q=INPUT_RECORD+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+INPUT_RECORD [INPUT_RECORD_EVENT](https://www.google.com/search?num=5&q=INPUT_RECORD_EVENT+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+INPUT_RECORD+INPUT_RECORD_EVENT @@ -1210,12 +1218,14 @@ Native Structure | Header | Managed Structure [JOBOBJECT_SECURITY_LIMIT_INFORMATION](http://msdn2.microsoft.com/en-us/library/ms684159) | WinNT.h | Vanara.PInvoke.Kernel32+JOBOBJECT_SECURITY_LIMIT_INFORMATION [KEY_EVENT_RECORD](https://www.google.com/search?num=5&q=KEY_EVENT_RECORD+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+KEY_EVENT_RECORD [LDT_ENTRY](http://msdn2.microsoft.com/en-us/library/ms680348) | WinNT.h | Vanara.PInvoke.Kernel32+LDT_ENTRY +[LOAD_DLL_DEBUG_INFO](http://msdn2.microsoft.com/en-us/library/ms680351) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+LOAD_DLL_DEBUG_INFO [M128A](https://www.google.com/search?num=5&q=M128A+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+CONTEXT64+M128A [MEMORY_BASIC_INFORMATION](http://msdn2.microsoft.com/en-us/library/dc3fa48e-0986-49cc-88a9-ff8179fbe5f0) | winnt.h | Vanara.PInvoke.Kernel32+MEMORY_BASIC_INFORMATION [MEMORY_PRIORITY_INFORMATION](http://msdn2.microsoft.com/en-us/library/hh448387) | WinBase.h | Vanara.PInvoke.Kernel32+MEMORY_PRIORITY_INFORMATION [MEMORYSTATUS](http://msdn2.microsoft.com/en-us/library/aa366772) | WinBase.h | Vanara.PInvoke.Kernel32+MEMORYSTATUS [MEMORYSTATUSEX](http://msdn2.microsoft.com/en-us/library/aa366770) | WinBase.h | Vanara.PInvoke.Kernel32+MEMORYSTATUSEX [MENU_EVENT_RECORD](https://www.google.com/search?num=5&q=MENU_EVENT_RECORD+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+MENU_EVENT_RECORD +[MODULEENTRY32](http://msdn2.microsoft.com/en-us/library/305fab35-625c-42e3-a434-e2513e4c8870) | tlhelp32.h | Vanara.PInvoke.Kernel32+MODULEENTRY32 [MODULEINFO](http://msdn2.microsoft.com/en-us/library/583caafe-7fa3-4041-b5bc-4e8899b3a08a) | psapi.h | Vanara.PInvoke.Kernel32+MODULEINFO [MOUSE_EVENT_RECORD](https://www.google.com/search?num=5&q=MOUSE_EVENT_RECORD+site%3Amicrosoft.com) | Wincon.h | Vanara.PInvoke.Kernel32+MOUSE_EVENT_RECORD [Mutant](https://www.google.com/search?num=5&q=Mutant+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PSS_HANDLE_ENTRY+Mutant @@ -1274,6 +1284,7 @@ Native Structure | Header | Managed Structure [PSS_VA_CLONE_INFORMATION](http://msdn2.microsoft.com/en-us/library/F93D61B0-EDB2-4560-A69F-CF839EC98B53) | processsnapshot.h | Vanara.PInvoke.Kernel32+PSS_VA_CLONE_INFORMATION [PSS_VA_SPACE_ENTRY](http://msdn2.microsoft.com/en-us/library/69B8F6A3-76DF-421B-B89B-73BA3254F897) | processsnapshot.h | Vanara.PInvoke.Kernel32+PSS_VA_SPACE_ENTRY [PSS_VA_SPACE_INFORMATION](http://msdn2.microsoft.com/en-us/library/F38FF7EB-DDC5-4692-8F57-8D633193D891) | processsnapshot.h | Vanara.PInvoke.Kernel32+PSS_VA_SPACE_INFORMATION +[PTP_CALLBACK_ENVIRON](https://www.google.com/search?num=5&q=PTP_CALLBACK_ENVIRON+site%3Amicrosoft.com) | threadpoolapiset.h | Vanara.PInvoke.Kernel32+PTP_CALLBACK_ENVIRON [PTP_CALLBACK_INSTANCE](https://www.google.com/search?num=5&q=PTP_CALLBACK_INSTANCE+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_CALLBACK_INSTANCE [PTP_CLEANUP_GROUP](https://www.google.com/search?num=5&q=PTP_CLEANUP_GROUP+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_CLEANUP_GROUP [PTP_IO](https://www.google.com/search?num=5&q=PTP_IO+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PTP_IO @@ -1310,12 +1321,15 @@ Native Structure | Header | Managed Structure [THREAD_POWER_THROTTLING_STATE](http://msdn2.microsoft.com/en-us/library/mt804325) | Processthreadsapi.h | Vanara.PInvoke.Kernel32+THREAD_POWER_THROTTLING_STATE [THREADENTRY32](http://msdn2.microsoft.com/en-us/library/923feca1-8807-4752-8a5a-79075688aabd) | tlhelp32.h | Vanara.PInvoke.Kernel32+THREADENTRY32 [TIME_ZONE_INFORMATION](http://msdn2.microsoft.com/en-us/library/ms725481) | Winbase.h | Vanara.PInvoke.Kernel32+TIME_ZONE_INFORMATION +[TimerQueueHandle](https://www.google.com/search?num=5&q=TimerQueueHandle+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+TimerQueueHandle +[TimerQueueTimerHandle](https://www.google.com/search?num=5&q=TimerQueueTimerHandle+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+TimerQueueTimerHandle [TP_POOL_STACK_INFORMATION](https://www.google.com/search?num=5&q=TP_POOL_STACK_INFORMATION+site%3Amicrosoft.com) | threadpoolapiset.h | Vanara.PInvoke.Kernel32+TP_POOL_STACK_INFORMATION [UMS_SCHEDULER_STARTUP_INFO](http://msdn2.microsoft.com/en-us/library/e3f7b1b7-d2b8-432d-bce7-3633292e855b) | winbase.h | Vanara.PInvoke.Kernel32+UMS_SCHEDULER_STARTUP_INFO [UMS_SYSTEM_THREAD_INFORMATION](http://msdn2.microsoft.com/en-us/library/eecdc592-5046-47c3-a4c6-ecb10899db3c) | winbase.h | Vanara.PInvoke.Kernel32+UMS_SYSTEM_THREAD_INFORMATION [Union](https://www.google.com/search?num=5&q=Union+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+COPYFILE2_MESSAGE+Union [UNION](https://www.google.com/search?num=5&q=UNION+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+PSS_HANDLE_ENTRY+UNION [UNLOAD_DLL_DEBUG_INFO](http://msdn2.microsoft.com/en-us/library/ms681403) | WinBase.h | Vanara.PInvoke.Kernel32+DEBUG_EVENT+EXCEPTION_INFO+UNLOAD_DLL_DEBUG_INFO +[UpdateResourceHandle](https://www.google.com/search?num=5&q=UpdateResourceHandle+site%3Amicrosoft.com) | | Vanara.PInvoke.Kernel32+UpdateResourceHandle [WIN32_FILE_ATTRIBUTE_DATA](http://msdn2.microsoft.com/en-us/library/aa365739) | WinBase.h | Vanara.PInvoke.Kernel32+WIN32_FILE_ATTRIBUTE_DATA [WIN32_FIND_STREAM_DATA](http://msdn2.microsoft.com/en-us/library/aa365741) | WinBase.h | Vanara.PInvoke.Kernel32+WIN32_FIND_STREAM_DATA [WIN32_MEMORY_RANGE_ENTRY](http://msdn2.microsoft.com/en-us/library/hh780544) | WinBase.h | Vanara.PInvoke.Kernel32+WIN32_MEMORY_RANGE_ENTRY diff --git a/PInvoke/Kernel32/HeapApi.cs b/PInvoke/Kernel32/HeapApi.cs index 7a72c16d..675342b9 100644 --- a/PInvoke/Kernel32/HeapApi.cs +++ b/PInvoke/Kernel32/HeapApi.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; @@ -1172,6 +1173,40 @@ namespace Vanara.PInvoke if (disposing && mm.HeapHandle != GetProcessHeap()) mm.HeapHandle.DangerousRelease(); } + + /// Represents a NULL memory pointer. + public static SafeHeapBlock Null => new SafeHeapBlock(IntPtr.Zero, 0, false); + + /// Converts an to a where it owns the reference. + /// The . + /// The result of the conversion. + public static implicit operator SafeHeapBlock(IntPtr ptr) => new SafeHeapBlock(ptr, 0, true); + + /// Allocates from unmanaged memory sufficient memory to hold an object of type T. + /// Native type + /// The value. + /// object to an native (unmanaged) memory block the size of T. + public static SafeHeapBlock CreateFromStructure(T value = default) => new SafeHeapBlock(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s); + + /// + /// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure elements. It is the + /// callers responsibility to marshal what precedes the trailing array into the unmanaged memory. ONLY structures with attribute StructLayout of + /// LayoutKind.Sequential are supported. + /// + /// Type of the trailing array of structures + /// Collection of structure objects + /// Number of items in . Setting this value to -1 will cause the method to get the count by iterating through . + /// Number of bytes preceding the trailing array of structures + /// object to an native (unmanaged) structure with a trail array of structures + public static SafeHeapBlock CreateFromList(IEnumerable values, int count = -1, int prefixBytes = 0) => new SafeHeapBlock(InteropExtensions.MarshalToPtr(values, new CoTaskMemoryMethods().AllocMem, out int s, prefixBytes), s); + + /// Allocates from unmanaged memory sufficient memory to hold an array of strings. + /// The list of strings. + /// The packing type for the strings. + /// The character set to use for the strings. + /// Number of bytes preceding the trailing strings. + /// object to an native (unmanaged) array of strings stored using the model and the character set defined by . + public static SafeHeapBlock CreateFromStringList(IEnumerable values, StringListPackMethod packing = StringListPackMethod.Concatenated, CharSet charSet = CharSet.Auto, int prefixBytes = 0) => new SafeHeapBlock(InteropExtensions.MarshalToPtr(values, packing, new CoTaskMemoryMethods().AllocMem, out int s, charSet, prefixBytes), s); } /// Provides a to a that releases a created HHEAP instance at disposal using HeapDestroy. diff --git a/PInvoke/Kernel32/IoApiSet.Threading.cs b/PInvoke/Kernel32/IoApiSet.Threading.cs index 42df59f3..88356168 100644 --- a/PInvoke/Kernel32/IoApiSet.Threading.cs +++ b/PInvoke/Kernel32/IoApiSet.Threading.cs @@ -9,122 +9,150 @@ namespace Vanara.PInvoke { public static partial class Kernel32 { - /// - /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation. - /// - /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device - /// handle, use the CreateFile function. For more information, see Remarks. - /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it. - /// The input buffer required to perform the operation. Can be null if unnecessary. - /// The output buffer that is to receive the data returned by the operation. Can be null if unnecessary. - /// An asynchronous empty result. - /// - /// - /// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with - /// a device. To specify a device name, use the following format: - /// - /// \\.\DeviceName - /// - /// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive - /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the - /// physical drives on a system. - /// - /// - /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when - /// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when - /// opening a device handle: - /// - /// - /// - /// The fdwCreate parameter must specify OPEN_EXISTING. - /// - /// - /// The hTemplateFile parameter must be NULL. - /// - /// - /// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations. - /// - /// - /// - public static Task DeviceIoControlAsync(HFILE hDev, uint ioControlCode, byte[] inputBuffer, byte[] outputBuffer) { - var buf = Pack(inputBuffer, outputBuffer); - return Task.Factory.FromAsync(BeginDeviceIoControl, EndDeviceIoControl, hDev, ioControlCode, buf, null); - } + /// + /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation. + /// + /// + /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. + /// To retrieve a device handle, use the CreateFile function. For more information, see Remarks. + /// + /// + /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which + /// to perform it. + /// + /// The input buffer required to perform the operation. Can be null if unnecessary. + /// The output buffer that is to receive the data returned by the operation. Can be null if unnecessary. + /// An asynchronous empty result. + /// + /// + /// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the + /// driver associated with a device. To specify a device name, use the following format: + /// + /// \\.\DeviceName + /// + /// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive + /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to + /// open handles to the physical drives on a system. + /// + /// + /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device + /// driver. However, when you open a communications resource, such as a serial port, you must specify exclusive access. Use the other + /// CreateFile parameters as follows when opening a device handle: + /// + /// + /// + /// The fdwCreate parameter must specify OPEN_EXISTING. + /// + /// + /// The hTemplateFile parameter must be NULL. + /// + /// + /// + /// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped + /// (asynchronous) I/O operations. + /// + /// + /// + /// + public static Task DeviceIoControlAsync(HFILE hDev, uint ioControlCode, byte[] inputBuffer, byte[] outputBuffer) + { + var buf = Pack(inputBuffer, outputBuffer); + return Task.Factory.FromAsync(BeginDeviceIoControl, EndDeviceIoControl, hDev, ioControlCode, buf, null); + } - /// - /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation. - /// - /// The type of the . - /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device - /// handle, use the CreateFile function. For more information, see Remarks. - /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it. - /// The input value required to perform the operation. The type of this data depends on the value of the parameter. - /// An asynchronous empty result. - /// - /// - /// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with - /// a device. To specify a device name, use the following format: - /// - /// \\.\DeviceName - /// - /// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive - /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the - /// physical drives on a system. - /// - /// - /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when - /// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when - /// opening a device handle: - /// - /// - /// - /// The fdwCreate parameter must specify OPEN_EXISTING. - /// - /// - /// The hTemplateFile parameter must be NULL. - /// - /// - /// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations. - /// - /// - /// - public static Task DeviceIoControlAsync(HFILE hDev, uint ioControlCode, TIn inVal) where TIn : struct => + /// + /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation. + /// + /// The type of the . + /// + /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. + /// To retrieve a device handle, use the CreateFile function. For more information, see Remarks. + /// + /// + /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which + /// to perform it. + /// + /// + /// The input value required to perform the operation. The type of this data depends on the value of the parameter. + /// + /// An asynchronous empty result. + /// + /// + /// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the + /// driver associated with a device. To specify a device name, use the following format: + /// + /// \\.\DeviceName + /// + /// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive + /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to + /// open handles to the physical drives on a system. + /// + /// + /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device + /// driver. However, when you open a communications resource, such as a serial port, you must specify exclusive access. Use the other + /// CreateFile parameters as follows when opening a device handle: + /// + /// + /// + /// The fdwCreate parameter must specify OPEN_EXISTING. + /// + /// + /// The hTemplateFile parameter must be NULL. + /// + /// + /// + /// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped + /// (asynchronous) I/O operations. + /// + /// + /// + /// + public static Task DeviceIoControlAsync(HFILE hDev, uint ioControlCode, TIn inVal) where TIn : struct => DeviceIoControlAsync(hDev, ioControlCode, (TIn?)inVal, (int?)null); /// /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation. /// /// The type of the return value. - /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device - /// handle, use the CreateFile function. For more information, see Remarks. - /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it. + /// + /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. + /// To retrieve a device handle, use the CreateFile function. For more information, see Remarks. + /// + /// + /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which + /// to perform it. + /// /// An asynchronous result containing the resulting value of type . /// /// - /// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with - /// a device. To specify a device name, use the following format: + /// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the + /// driver associated with a device. To specify a device name, use the following format: /// /// \\.\DeviceName /// /// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive - /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the - /// physical drives on a system. + /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to + /// open handles to the physical drives on a system. /// /// - /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when - /// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when - /// opening a device handle: + /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device + /// driver. However, when you open a communications resource, such as a serial port, you must specify exclusive access. Use the other + /// CreateFile parameters as follows when opening a device handle: /// /// - /// - /// The fdwCreate parameter must specify OPEN_EXISTING. - /// - /// - /// The hTemplateFile parameter must be NULL. - /// - /// - /// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations. - /// + /// + /// The fdwCreate parameter must specify OPEN_EXISTING. + /// + /// + /// The hTemplateFile parameter must be NULL. + /// + /// + /// + /// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped + /// (asynchronous) I/O operations. + /// + /// /// /// public static Task DeviceIoControlAsync(HFILE hDev, uint ioControlCode) where TOut : struct @@ -138,38 +166,52 @@ namespace Vanara.PInvoke /// /// The type of the . /// The type of the . - /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device - /// handle, use the CreateFile function. For more information, see Remarks. - /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it. - /// The input value required to perform the operation. The type of this data depends on the value of the parameter. - /// The output value that is to receive the data returned by the operation. The type of this data depends on the value of the dwIoControlCode parameter. + /// + /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. + /// To retrieve a device handle, use the CreateFile function. For more information, see Remarks. + /// + /// + /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which + /// to perform it. + /// + /// + /// The input value required to perform the operation. The type of this data depends on the value of the parameter. + /// + /// + /// The output value that is to receive the data returned by the operation. The type of this data depends on the value of the + /// dwIoControlCode parameter. + /// /// An asynchronous result containing the populated data supplied by . /// /// - /// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the driver associated with - /// a device. To specify a device name, use the following format: + /// To retrieve a handle to the device, you must call the CreateFile function with either the name of a device or the name of the + /// driver associated with a device. To specify a device name, use the following format: /// /// \\.\DeviceName /// /// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive - /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to open handles to the - /// physical drives on a system. + /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to + /// open handles to the physical drives on a system. /// /// - /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when - /// you open a communications resource, such as a serial port, you must specify exclusive access. Use the other CreateFile parameters as follows when - /// opening a device handle: + /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device + /// driver. However, when you open a communications resource, such as a serial port, you must specify exclusive access. Use the other + /// CreateFile parameters as follows when opening a device handle: /// /// - /// - /// The fdwCreate parameter must specify OPEN_EXISTING. - /// - /// - /// The hTemplateFile parameter must be NULL. - /// - /// - /// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations. - /// + /// + /// The fdwCreate parameter must specify OPEN_EXISTING. + /// + /// + /// The hTemplateFile parameter must be NULL. + /// + /// + /// + /// The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped + /// (asynchronous) I/O operations. + /// + /// /// /// public static Task DeviceIoControlAsync(HFILE hDevice, uint ioControlCode, TIn? inVal, TOut? outVal) where TIn : struct where TOut : struct @@ -178,6 +220,15 @@ namespace Vanara.PInvoke return new TaskFactory().FromAsync(BeginDeviceIoControl, EndDeviceIoControl, hDevice, ioControlCode, buf, null); } + /// Explicits the device io control asynchronous. + /// The type of the in. + /// The type of the out. + /// The h device. + /// The io control code. + /// The in value. + /// The out value. + /// + /// private static unsafe Task ExplicitDeviceIoControlAsync(HFILE hDevice, uint ioControlCode, TIn? inVal, TOut? outVal) where TIn : struct where TOut : struct { #pragma warning disable CS0618 // Type or member is obsolete @@ -218,8 +269,7 @@ namespace Vanara.PInvoke var inSz = Marshal.SizeOf(typeof(TIn)); fixed (byte* pIn = buffer, pOut = &buffer[inSz]) { - uint bRet; - var ret = DeviceIoControl(hDevice, ioControlCode, pIn, (uint)inSz, pOut, (uint)(buffer.Length - inSz), out bRet, + var ret = DeviceIoControl(hDevice, ioControlCode, pIn, (uint)inSz, pOut, (uint)(buffer.Length - inSz), out var bRet, nativeOverlapped); if (ret) { diff --git a/PInvoke/Kernel32/IoApiSet.cs b/PInvoke/Kernel32/IoApiSet.cs index b7297559..7d99be9d 100644 --- a/PInvoke/Kernel32/IoApiSet.cs +++ b/PInvoke/Kernel32/IoApiSet.cs @@ -159,49 +159,50 @@ namespace Vanara.PInvoke return BeginDeviceIoControl(hDevice, dwIoControlCode, buffer, userCallback, null); } - /// - /// Starts the asynchronous operation of sending a control code directly to a specified device driver, causing the corresponding - /// device to perform the corresponding operation. - /// - /// - /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. - /// To retrieve a device handle, use the CreateFile function. For more information, see Remarks. - /// - /// - /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which - /// to perform it. - /// - /// The input buffer required to perform the operation. Can be null if unnecessary. - /// The output buffer that is to receive the data returned by the operation. Can be null if unnecessary. - /// An AsyncCallback delegate that references the method to invoke when the operation is complete. - /// An IAsyncResult instance that references the asynchronous request. - [PInvokeData("Winbase.h", MSDNShortId = "aa363216")] - public static IAsyncResult BeginDeviceIoControl(HFILE hDevice, uint dwIoControlCode, byte[] inputBuffer, byte[] outputBuffer, AsyncCallback userCallback) { - var buffer = Pack(inputBuffer, outputBuffer); - return BeginDeviceIoControl(hDevice, dwIoControlCode, buffer, userCallback, null); - } + /// + /// Starts the asynchronous operation of sending a control code directly to a specified device driver, causing the corresponding + /// device to perform the corresponding operation. + /// + /// + /// A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. + /// To retrieve a device handle, use the CreateFile function. For more information, see Remarks. + /// + /// + /// The control code for the operation. This value identifies the specific operation to be performed and the type of device on which + /// to perform it. + /// + /// The input buffer required to perform the operation. Can be null if unnecessary. + /// The output buffer that is to receive the data returned by the operation. Can be null if unnecessary. + /// An AsyncCallback delegate that references the method to invoke when the operation is complete. + /// An IAsyncResult instance that references the asynchronous request. + [PInvokeData("Winbase.h", MSDNShortId = "aa363216")] + public static IAsyncResult BeginDeviceIoControl(HFILE hDevice, uint dwIoControlCode, byte[] inputBuffer, byte[] outputBuffer, AsyncCallback userCallback) + { + var buffer = Pack(inputBuffer, outputBuffer); + return BeginDeviceIoControl(hDevice, dwIoControlCode, buffer, userCallback, null); + } - /// - /// - /// Cancels all pending input and output (I/O) operations that are issued by the calling thread for the specified file. The function - /// does not cancel I/O operations that other threads issue for a file handle. - /// - /// To cancel I/O operations from another thread, use the CancelIoEx function. - /// - /// - /// A handle to the file. - /// The function cancels all pending I/O operations for this file handle. - /// - /// - /// - /// If the function succeeds, the return value is nonzero. The cancel operation for all pending I/O operations issued by the calling - /// thread for the specified file handle was successfully requested. The thread can use the GetOverlappedResult function to - /// determine when the I/O operations themselves have been completed. - /// - /// If the function fails, the return value is zero (0). To get extended error information, call the GetLastError function. - /// - // BOOL WINAPI CancelIo( _In_ HANDLE hFile);// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363791(v=vs.85).aspx - [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] + /// + /// + /// Cancels all pending input and output (I/O) operations that are issued by the calling thread for the specified file. The function + /// does not cancel I/O operations that other threads issue for a file handle. + /// + /// To cancel I/O operations from another thread, use the CancelIoEx function. + /// + /// + /// A handle to the file. + /// The function cancels all pending I/O operations for this file handle. + /// + /// + /// + /// If the function succeeds, the return value is nonzero. The cancel operation for all pending I/O operations issued by the calling + /// thread for the specified file handle was successfully requested. The thread can use the GetOverlappedResult function to + /// determine when the I/O operations themselves have been completed. + /// + /// If the function fails, the return value is zero (0). To get extended error information, call the GetLastError function. + /// + // BOOL WINAPI CancelIo( _In_ HANDLE hFile);// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363791(v=vs.85).aspx + [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] [PInvokeData("IoAPI.h", MSDNShortId = "aa363791")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CancelIo([In] HFILE hFile); @@ -361,6 +362,7 @@ namespace Vanara.PInvoke /// /// /// The resulting I/O control code. + /// function public static uint CTL_CODE(ushort deviceType, ushort function, byte method, byte access) { if (function > 0xfff) @@ -460,7 +462,7 @@ namespace Vanara.PInvoke /// /// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to - /// open handles to the physical drives on a system. + /// open handles to the physical drives on a system. /// /// /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device @@ -559,7 +561,7 @@ namespace Vanara.PInvoke /// /// DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive /// A: with CreateFile, specify \\.\a:. Alternatively, you can use the names \\.\PhysicalDrive0, \\.\PhysicalDrive1, and so on, to - /// open handles to the physical drives on a system. + /// open handles to the physical drives on a system. /// /// /// You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device @@ -585,7 +587,7 @@ namespace Vanara.PInvoke [return: MarshalAs(UnmanagedType.Bool)] [PInvokeData("Winbase.h", MSDNShortId = "aa363216")] public static extern unsafe bool DeviceIoControl(HFILE hDevice, uint dwIoControlCode, byte* lpInBuffer, uint nInBufferSize, byte* lpOutBuffer, - uint nOutBufferSize, out uint lpBytesReturned, NativeOverlapped* lpOverlapped); + uint nOutBufferSize, out uint lpBytesReturned, NativeOverlapped* lpOverlapped); /// /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation. @@ -684,47 +686,48 @@ namespace Vanara.PInvoke return Unpack(ret as byte[]).Item2; } - /// Ends the asynchronous call to . + /// Ends the asynchronous call to . /// /// The asynchronous result returned from . /// /// The output buffer, if exists; null otherwise. - [PInvokeData("Winbase.h", MSDNShortId = "aa363216")] - public static byte[] EndDeviceIoControl(IAsyncResult asyncResult) { - var ret = OverlappedAsync.EndOverlappedFunction(asyncResult); - return Unpack(ret as byte[]).Item2; - } + [PInvokeData("Winbase.h", MSDNShortId = "aa363216")] + public static byte[] EndDeviceIoControl(IAsyncResult asyncResult) + { + var ret = OverlappedAsync.EndOverlappedFunction(asyncResult); + return Unpack(ret as byte[]).Item2; + } - /// - /// Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device. To specify a - /// timeout interval or wait on an alertable thread, use GetOverlappedResultEx. - /// - /// - /// A handle to the file, named pipe, or communications device. This is the same handle that was specified when the overlapped - /// operation was started by a call to the ReadFile, WriteFile, ConnectNamedPipe, TransactNamedPipe, - /// DeviceIoControl, or WaitCommEvent function. - /// - /// - /// A pointer to an OVERLAPPED structure that was specified when the overlapped operation was started. - /// - /// - /// A pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation. For a - /// TransactNamedPipe operation, this is the number of bytes that were read from the pipe. For a DeviceIoControl - /// operation, this is the number of bytes of output data returned by the device driver. For a ConnectNamedPipe or - /// WaitCommEvent operation, this value is undefined. - /// - /// - /// If this parameter is TRUE, and the Internal member of the lpOverlapped structure is STATUS_PENDING, the - /// function does not return until the operation has been completed. If this parameter is FALSE and the operation is still - /// pending, the function returns FALSE and the GetLastError function returns ERROR_IO_INCOMPLETE. - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - // BOOL WINAPI GetOverlappedResult( _In_ HANDLE hFile, _In_ LPOVERLAPPED lpOverlapped, _Out_ LPDWORD lpNumberOfBytesTransferred, _In_ - // BOOL bWait); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683209(v=vs.85).aspx - [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] + /// + /// Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device. To specify a + /// timeout interval or wait on an alertable thread, use GetOverlappedResultEx. + /// + /// + /// A handle to the file, named pipe, or communications device. This is the same handle that was specified when the overlapped + /// operation was started by a call to the ReadFile, WriteFile, ConnectNamedPipe, TransactNamedPipe, + /// DeviceIoControl, or WaitCommEvent function. + /// + /// + /// A pointer to an OVERLAPPED structure that was specified when the overlapped operation was started. + /// + /// + /// A pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation. For a + /// TransactNamedPipe operation, this is the number of bytes that were read from the pipe. For a DeviceIoControl + /// operation, this is the number of bytes of output data returned by the device driver. For a ConnectNamedPipe or + /// WaitCommEvent operation, this value is undefined. + /// + /// + /// If this parameter is TRUE, and the Internal member of the lpOverlapped structure is STATUS_PENDING, the + /// function does not return until the operation has been completed. If this parameter is FALSE and the operation is still + /// pending, the function returns FALSE and the GetLastError function returns ERROR_IO_INCOMPLETE. + /// + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + // BOOL WINAPI GetOverlappedResult( _In_ HANDLE hFile, _In_ LPOVERLAPPED lpOverlapped, _Out_ LPDWORD lpNumberOfBytesTransferred, _In_ + // BOOL bWait); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683209(v=vs.85).aspx + [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] [PInvokeData("WinBase.h", MSDNShortId = "ms683209")] [return: MarshalAs(UnmanagedType.Bool)] public static extern unsafe bool GetOverlappedResult([In] HFILE hFile, [In] NativeOverlapped* lpOverlapped, out uint lpNumberOfBytesTransferred, [MarshalAs(UnmanagedType.Bool)] bool bWait); @@ -885,10 +888,6 @@ namespace Vanara.PInvoke /// and the calling thread is the thread that initiated the operation. An APC is queued when you call QueueUserAPC. /// /// - /// - /// Returns nonzero ( TRUE) if successful or zero ( FALSE) otherwise. - /// To get extended error information, call GetLastError. - /// // BOOL WINAPI GetQueuedCompletionStatusEx( _In_ HANDLE CompletionPort, _Out_ LPOVERLAPPED_ENTRY lpCompletionPortEntries, _In_ ULONG // ulCount, _Out_ PULONG ulNumEntriesRemoved, _In_ DWORD dwMilliseconds, _In_ BOOL fAlertable); https://msdn.microsoft.com/en-us/library/windows/desktop/aa364988(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] @@ -917,23 +916,23 @@ namespace Vanara.PInvoke [return: MarshalAs(UnmanagedType.Bool)] public static extern unsafe bool PostQueuedCompletionStatus([In] IntPtr CompletionPort, uint dwNumberOfBytesTransferred, UIntPtr dwCompletionKey, NativeOverlapped* lpOverlapped); - private static unsafe IAsyncResult BeginDeviceIoControl(HFILE hDevice, uint dwIoControlCode, byte[] buffer, AsyncCallback userCallback, object userState) where TIn : struct where TOut : struct + private static unsafe IAsyncResult BeginDeviceIoControl(HFILE hDevice, uint dwIoControlCode, byte[] buffer, AsyncCallback userCallback, object userState) where TIn : struct where TOut : struct => + BeginDeviceIoControl(hDevice, dwIoControlCode, buffer, userCallback, userState); + + private static unsafe IAsyncResult BeginDeviceIoControl(HFILE hDevice, uint dwIoControlCode, byte[] buffer, AsyncCallback userCallback, object userState) { - return BeginDeviceIoControl(hDevice, dwIoControlCode, buffer, userCallback, userState); + var ar = OverlappedAsync.SetupOverlappedFunction(hDevice, userCallback, buffer); + var intSz = Marshal.SizeOf(typeof(int)); + var inSz = BitConverter.ToInt32(buffer, 0); + var outSz = BitConverter.ToInt32(buffer, intSz); + fixed (byte* pIn = &buffer[intSz * 2], pOut = &buffer[outSz == 0 ? 0 : intSz * 2 + inSz]) + { + var ret = DeviceIoControl(hDevice, dwIoControlCode, pIn, (uint)inSz, pOut, (uint)outSz, out var bRet, ar.Overlapped); + return OverlappedAsync.EvaluateOverlappedFunction(ar, ret); + } } - private static unsafe IAsyncResult BeginDeviceIoControl(HFILE hDevice, uint dwIoControlCode, byte[] buffer, AsyncCallback userCallback, object userState) { - var ar = OverlappedAsync.SetupOverlappedFunction(hDevice, userCallback, buffer); - var intSz = Marshal.SizeOf(typeof(int)); - var inSz = BitConverter.ToInt32(buffer, 0); - var outSz = BitConverter.ToInt32(buffer, intSz); - fixed (byte* pIn = &buffer[intSz * 2], pOut = &buffer[outSz == 0 ? 0 : intSz * 2 + inSz]) { - var ret = DeviceIoControl(hDevice, dwIoControlCode, pIn, (uint)inSz, pOut, (uint)outSz, out var bRet, ar.Overlapped); - return OverlappedAsync.EvaluateOverlappedFunction(ar, ret); - } - } - - private static T MemRead(byte[] buffer, ref int startIndex) where T : struct + private static T MemRead(byte[] buffer, ref int startIndex) where T : struct { using (var pin = new PinnedObject(buffer, startIndex)) { @@ -963,20 +962,22 @@ namespace Vanara.PInvoke } } - private static byte[] Pack(byte[] inputBuffer, byte[] outputBuffer) { - using (var ms = new MemoryStream()) - using (var wtr = new BinaryWriter(ms)) { - wtr.Write(inputBuffer != null ? inputBuffer.Length : 0); - wtr.Write(outputBuffer != null ? outputBuffer.Length : 0); - if (inputBuffer != null && inputBuffer.Length > 0) - wtr.Write(inputBuffer); - if (outputBuffer != null && outputBuffer.Length > 0) - wtr.Write(outputBuffer); - return ms.ToArray(); - } - } + private static byte[] Pack(byte[] inputBuffer, byte[] outputBuffer) + { + using (var ms = new MemoryStream()) + using (var wtr = new BinaryWriter(ms)) + { + wtr.Write(inputBuffer != null ? inputBuffer.Length : 0); + wtr.Write(outputBuffer != null ? outputBuffer.Length : 0); + if (inputBuffer != null && inputBuffer.Length > 0) + wtr.Write(inputBuffer); + if (outputBuffer != null && outputBuffer.Length > 0) + wtr.Write(outputBuffer); + return ms.ToArray(); + } + } - private static Tuple Unpack(byte[] buffer) where TIn : struct where TOut : struct + private static Tuple Unpack(byte[] buffer) where TIn : struct where TOut : struct { using (var ms = new MemoryStream(buffer)) using (var rdr = new BinaryReader(ms)) @@ -987,16 +988,18 @@ namespace Vanara.PInvoke } } - private static Tuple Unpack(byte[] buffer) { - using (var ms = new MemoryStream(buffer)) - using (var rdr = new BinaryReader(ms)) { - var inLen = rdr.ReadInt32(); - var outLen = rdr.ReadInt32(); - return new Tuple(rdr.ReadBytes(inLen), rdr.ReadBytes(outLen)); - } - } + private static Tuple Unpack(byte[] buffer) + { + using (var ms = new MemoryStream(buffer)) + using (var rdr = new BinaryReader(ms)) + { + var inLen = rdr.ReadInt32(); + var outLen = rdr.ReadInt32(); + return new Tuple(rdr.ReadBytes(inLen), rdr.ReadBytes(outLen)); + } + } - [PInvokeData("WinIOCtl.h")] + [PInvokeData("WinIOCtl.h")] public static class IOControlCode { public static uint FSCTL_GET_COMPRESSION diff --git a/PInvoke/Kernel32/Vanara.PInvoke.Kernel32.csproj b/PInvoke/Kernel32/Vanara.PInvoke.Kernel32.csproj index 1292cf01..92146f1e 100644 --- a/PInvoke/Kernel32/Vanara.PInvoke.Kernel32.csproj +++ b/PInvoke/Kernel32/Vanara.PInvoke.Kernel32.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from Kernel32.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard20 Vanara.PInvoke.Kernel32 $(AssemblyName) @@ -25,13 +25,15 @@ Currently implements: Functions -AcquireSRWLockExclusive, AcquireSRWLockShared, ActivateActCtx, AddAtomA, AddAtomW, AddConsoleAliasA, AddConsoleAliasW, AddDllDirectory, AddIntegrityLabelToBoundaryDescriptor, AddLocalAlternateComputerNameA, AddLocalAlternateComputerNameW, AddRefActCtx, AddSecureMemoryCacheCallback, AddSIDToBoundaryDescriptor, AddVectoredContinueHandler, AddVectoredExceptionHandler, AdjustCalendarDate, AllocateUserPhysicalPages, AllocateUserPhysicalPagesNuma, AllocConsole, ApplicationRecoveryFinished, ApplicationRecoveryInProgress, AppPolicyGetCreateFileAccess, AppPolicyGetProcessTerminationMethod, AppPolicyGetShowDeveloperDiagnostic, AppPolicyGetThreadInitializationType, AreFileApisANSI, AssignProcessToJobObject, AttachConsole, BackupRead, BackupSeek, BackupWrite, BaseFlushAppcompatCache, Beep, BeginUpdateResourceA, BeginUpdateResourceW, BindIoCompletionCallback, BuildCommDCBA, BuildCommDCBAndTimeoutsA, BuildCommDCBAndTimeoutsW, BuildCommDCBW, CallbackMayRunLong, CallEnclave, CallNamedPipeA, CallNamedPipeW, CancelIo, CancelIoEx, CancelSynchronousIo, CancelThreadpoolIo, CancelWaitableTimer, CeipIsOptedIn, ChangeTimerQueueTimer, CheckNameLegalDOS8Dot3A, CheckNameLegalDOS8Dot3W, CheckRemoteDebuggerPresent, ClearCommBreak, ClearCommError, CloseHandle, ClosePackageInfo, ClosePrivateNamespace, CloseThreadpool, CloseThreadpoolCleanupGroup, CloseThreadpoolCleanupGroupMembers, CloseThreadpoolIo, CloseThreadpoolTimer, CloseThreadpoolWait, CloseThreadpoolWork, CommConfigDialogA, CommConfigDialogW, CompareFileTime, CompareObjectHandles, CompareStringA, CompareStringEx, CompareStringOrdinal, CompareStringW, ConnectNamedPipe, ContinueDebugEvent, ConvertAuxiliaryCounterToPerformanceCounter, ConvertCalDateTimeToSystemTime, ConvertDefaultLocale, ConvertFiberToThread, ConvertPerformanceCounterToAuxiliaryCounter, ConvertSystemTimeToCalDateTime, ConvertThreadToFiber, ConvertThreadToFiberEx, CopyContext, CopyFile2, CopyFileA, CopyFileExA, CopyFileExW, CopyFileTransactedA, CopyFileTransactedW, CopyFileW, CreateActCtxA, CreateActCtxW, CreateBoundaryDescriptorA, CreateBoundaryDescriptorW, CreateConsoleScreenBuffer, CreateDirectoryA, CreateDirectoryExA, CreateDirectoryExW, CreateDirectoryTransactedA, CreateDirectoryTransactedW, CreateDirectoryW, CreateEnclave, CreateEventA, CreateEventExA, CreateEventExW, CreateEventW, CreateFiber, CreateFiberEx, CreateFile2, CreateFileA, CreateFileMappingA, CreateFileMappingFromApp, CreateFileMappingNumaA, CreateFileMappingNumaW, CreateFileMappingW, CreateFileTransactedA, CreateFileTransactedW, CreateFileW, CreateHardLinkA, CreateHardLinkTransactedA, CreateHardLinkTransactedW, CreateHardLinkW, CreateIoCompletionPort, CreateJobObjectA, CreateJobObjectW, CreateMailslotA, CreateMailslotW, CreateMemoryResourceNotification, CreateMutexA, CreateMutexExA, CreateMutexExW, CreateMutexW, CreateNamedPipeA, CreateNamedPipeW, CreatePipe, CreatePrivateNamespaceA, CreatePrivateNamespaceW, CreateProcessA, CreateProcessAsUserA, CreateProcessAsUserW, CreateProcessW, CreateRemoteThread, CreateRemoteThreadEx, CreateSemaphoreA, CreateSemaphoreExA, CreateSemaphoreExW, CreateSemaphoreW, CreateSymbolicLinkA, CreateSymbolicLinkW, CreateTapePartition, CreateThread, CreateThreadpool, CreateThreadpoolCleanupGroup, CreateThreadpoolIo, CreateThreadpoolTimer, CreateThreadpoolWait, CreateThreadpoolWork, CreateTimerQueue, CreateTimerQueueTimer, CreateToolhelp32Snapshot, CreateUmsCompletionList, CreateUmsThreadContext, CreateWaitableTimerA, CreateWaitableTimerExA, CreateWaitableTimerExW, CreateWaitableTimerW, DeactivateActCtx, DebugActiveProcess, DebugActiveProcessStop, DebugBreak, DebugBreakProcess, DebugSetProcessKillOnExit, DecodePointer, DecodeRemotePointer, DecodeSystemPointer, DefineDosDeviceA, DefineDosDeviceW, DeleteAtom, DeleteBoundaryDescriptor, DeleteCriticalSection, DeleteEnclave, DeleteFiber, DeleteFileA, DeleteFileTransactedA, DeleteFileTransactedW, DeleteFileW, DeleteProcThreadAttributeList, DeleteSynchronizationBarrier, DeleteTimerQueue, DeleteTimerQueueEx, DeleteTimerQueueTimer, DeleteUmsCompletionList, DeleteUmsThreadContext, DeleteVolumeMountPointA, DeleteVolumeMountPointW, DequeueUmsCompletionListItems, DeviceIoControl, DisableThreadLibraryCalls, DisableThreadProfiling, DisassociateCurrentThreadFromCallback, DiscardVirtualMemory, DisconnectNamedPipe, DnsHostnameToComputerNameA, DnsHostnameToComputerNameExW, DnsHostnameToComputerNameW, DosDateTimeToFileTime, DuplicateHandle, EmptyWorkingSet, EnableThreadProfiling, EncodePointer, EncodeRemotePointer, EncodeSystemPointer, EndUpdateResourceA, EndUpdateResourceW, EnterCriticalSection, EnterSynchronizationBarrier, EnterUmsSchedulingMode, EnumCalendarInfoA, EnumCalendarInfoExA, EnumCalendarInfoExEx, EnumCalendarInfoExW, EnumCalendarInfoW, EnumDateFormatsA, EnumDateFormatsExA, EnumDateFormatsExEx, EnumDateFormatsExW, EnumDateFormatsW, EnumDeviceDrivers, EnumDynamicTimeZoneInformation, EnumLanguageGroupLocalesA, EnumLanguageGroupLocalesW, EnumPageFilesA, EnumPageFilesW, EnumProcessesA, EnumProcessesW, EnumProcessModules, EnumProcessModulesEx, EnumResourceLanguagesExW, EnumResourceLanguagesW, EnumResourceNamesExW, EnumResourceNamesW, EnumResourceTypesExA, EnumResourceTypesExW, EnumResourceTypesW, EnumSystemCodePagesA, EnumSystemCodePagesW, EnumSystemFirmwareTables, EnumSystemGeoID, EnumSystemGeoNames, EnumSystemLanguageGroupsA, EnumSystemLanguageGroupsW, EnumSystemLocalesA, EnumSystemLocalesEx, EnumSystemLocalesW, EnumTimeFormatsA, EnumTimeFormatsEx, EnumTimeFormatsW, EnumUILanguagesA, EnumUILanguagesW, EraseTape, EscapeCommFunction, ExecuteUmsThread, ExitProcess, ExitThread, ExpandEnvironmentStringsA, ExpandEnvironmentStringsW, FatalAppExitA, FatalAppExitW, FatalExit, FileTimeToDosDateTime, FileTimeToLocalFileTime, FileTimeToSystemTime, FillConsoleOutputAttribute, FillConsoleOutputCharacterA, FillConsoleOutputCharacterW, FindActCtxSectionGuid, FindActCtxSectionStringA, FindActCtxSectionStringW, FindAtomA, FindAtomW, FindClose, FindCloseChangeNotification, FindFirstChangeNotificationA, FindFirstChangeNotificationW, FindFirstFileA, FindFirstFileExA, FindFirstFileExW, FindFirstFileNameTransactedW, FindFirstFileNameW, FindFirstFileTransactedA, FindFirstFileTransactedW, FindFirstFileW, FindFirstStreamTransactedW, FindFirstStreamW, FindFirstVolumeA, FindFirstVolumeMountPointA, FindFirstVolumeMountPointW, FindFirstVolumeW, FindNextChangeNotification, FindNextFileA, FindNextFileNameW, FindNextFileW, FindNextStreamW, FindNextVolumeA, FindNextVolumeMountPointA, FindNextVolumeMountPointW, FindNextVolumeW, FindNLSString, FindNLSStringEx, FindPackagesByPackageFamily, FindResourceExW, FindResourceW, FindStringOrdinal, FindVolumeClose, FindVolumeMountPointClose, FlsAlloc, FlsFree, FlsGetValue, FlsSetValue, FlushConsoleInputBuffer, FlushFileBuffers, FlushInstructionCache, FlushProcessWriteBuffers, FlushViewOfFile, FoldStringA, FoldStringW, FormatApplicationUserModelId, FormatMessageA, FormatMessageW, FreeConsole, FreeEnvironmentStringsA, FreeEnvironmentStringsW, FreeLibrary, FreeLibraryAndExitThread, FreeLibraryWhenCallbackReturns, FreeMemoryJobObject, FreeResource, FreeUserPhysicalPages, GenerateConsoleCtrlEvent, GetACP, GetActiveProcessorCount, GetActiveProcessorGroupCount, GetAppContainerNamedObjectPath, GetApplicationRecoveryCallback, GetApplicationRestartSettings, GetApplicationUserModelId, GetApplicationUserModelIdFromToken, GetAtomNameA, GetAtomNameW, GetBinaryTypeA, GetBinaryTypeW, GetCalendarDateFormatEx, GetCalendarInfoA, GetCalendarInfoEx, GetCalendarInfoW, GetCalendarSupportedDateRange, GetCommandLineA, GetCommandLineW, GetCommConfig, GetCommMask, GetCommModemStatus, GetCommProperties, GetCommState, GetCommTimeouts, GetComPlusPackageInstallStatus, GetCompressedFileSizeA, GetCompressedFileSizeW, GetComputerNameA, GetComputerNameExA, GetComputerNameExW, GetComputerNameW, GetConsoleAliasA, GetConsoleAliasesA, GetConsoleAliasesLengthA, GetConsoleAliasesLengthW, GetConsoleAliasesW, GetConsoleAliasExesA, GetConsoleAliasExesLengthA, GetConsoleAliasExesLengthW, GetConsoleAliasExesW, GetConsoleAliasW, GetConsoleCP, GetConsoleCursorInfo, GetConsoleDisplayMode, GetConsoleFontSize, GetConsoleHistoryInfo, GetConsoleMode, GetConsoleOriginalTitleA, GetConsoleOriginalTitleW, GetConsoleOutputCP, GetConsoleProcessList, GetConsoleScreenBufferInfo, GetConsoleScreenBufferInfoEx, GetConsoleSelectionInfo, GetConsoleTitleA, GetConsoleTitleW, GetConsoleWindow, GetCPInfo, GetCPInfoExW, GetCurrencyFormatA, GetCurrencyFormatEx, GetCurrencyFormatW, GetCurrentActCtx, GetCurrentApplicationUserModelId, GetCurrentConsoleFont, GetCurrentConsoleFontEx, GetCurrentDirectoryA, GetCurrentDirectoryW, GetCurrentPackageFamilyName, GetCurrentPackageFullName, GetCurrentPackageId, GetCurrentPackageInfo, GetCurrentPackagePath, GetCurrentProcess, GetCurrentProcessId, GetCurrentProcessorNumber, GetCurrentProcessorNumberEx, GetCurrentThread, GetCurrentThreadId, GetCurrentThreadStackLimits, GetCurrentUmsThread, GetDateFormatA, GetDateFormatEx, GetDateFormatW, GetDefaultCommConfigA, GetDefaultCommConfigW, GetDeviceDriverBaseNameA, GetDeviceDriverBaseNameW, GetDeviceDriverFileNameA, GetDeviceDriverFileNameW, GetDevicePowerState, GetDiskFreeSpaceA, GetDiskFreeSpaceExA, GetDiskFreeSpaceExW, GetDiskFreeSpaceW, GetDllDirectoryA, GetDllDirectoryW, GetDriveTypeA, GetDriveTypeW, GetDurationFormat, GetDurationFormatEx, GetDynamicTimeZoneInformation, GetDynamicTimeZoneInformationEffectiveYears, GetEnabledXStateFeatures, GetEnvironmentStringsA, GetEnvironmentStringsW, GetEnvironmentVariableA, GetEnvironmentVariableW, GetErrorMode, GetExitCodeProcess, GetExitCodeThread, GetFileAttributesA, GetFileAttributesExA, GetFileAttributesExW, GetFileAttributesTransactedA, GetFileAttributesTransactedW, GetFileAttributesW, GetFileBandwidthReservation, GetFileInformationByHandle, GetFileInformationByHandleEx, GetFileMUIInfo, GetFileMUIPath, GetFileSize, GetFileSizeEx, GetFileTime, GetFileType, GetFinalPathNameByHandleA, GetFinalPathNameByHandleW, GetFirmwareEnvironmentVariableA, GetFirmwareEnvironmentVariableExA, GetFirmwareEnvironmentVariableExW, GetFirmwareEnvironmentVariableW, GetFullPathNameA, GetFullPathNameTransactedA, GetFullPathNameTransactedW, GetFullPathNameW, GetGamingDeviceModelInformation, GetGeoInfoA, GetGeoInfoEx, GetGeoInfoW, GetHandleInformation, GetIntegratedDisplaySize, GetLargePageMinimum, GetLargestConsoleWindowSize, GetLastError, GetLocaleInfoA, GetLocaleInfoEx, GetLocaleInfoW, GetLocalTime, GetLogicalDrives, GetLogicalDriveStringsA, GetLogicalDriveStringsW, GetLogicalProcessorInformation, GetLogicalProcessorInformationEx, GetLongPathNameA, GetLongPathNameTransactedA, GetLongPathNameTransactedW, GetLongPathNameW, GetMailslotInfo, GetMappedFileNameA, GetMappedFileNameW, GetMaximumProcessorCount, GetMaximumProcessorGroupCount, GetMemoryErrorHandlingCapabilities, GetModuleBaseNameA, GetModuleBaseNameW, GetModuleFileNameA, GetModuleFileNameW, GetModuleHandleA, GetModuleHandleExA, GetModuleHandleExW, GetModuleHandleW, GetModuleInformation, GetNamedPipeClientComputerNameA, GetNamedPipeClientComputerNameW, GetNamedPipeClientProcessId, GetNamedPipeClientSessionId, GetNamedPipeHandleStateA, GetNamedPipeHandleStateW, GetNamedPipeInfo, GetNamedPipeServerProcessId, GetNamedPipeServerSessionId, GetNativeSystemInfo, GetNLSVersion, GetNLSVersionEx, GetNumaAvailableMemoryNode, GetNumaAvailableMemoryNodeEx, GetNumaHighestNodeNumber, GetNumaNodeNumberFromHandle, GetNumaNodeProcessorMask, GetNumaNodeProcessorMaskEx, GetNumaProcessorNode, GetNumaProcessorNodeEx, GetNumaProximityNode, GetNumaProximityNodeEx, GetNumberFormatA, GetNumberFormatEx, GetNumberFormatW, GetNumberOfConsoleInputEvents, GetNumberOfConsoleMouseButtons, GetOEMCP, GetOsManufacturingMode, GetOsSafeBootMode, GetOverlappedResult, GetOverlappedResultEx, GetPackageApplicationIds, GetPackageFamilyName, GetPackageFamilyNameFromToken, GetPackageFullNameFromToken, GetPackageInfo, GetPackagePath, GetPackagePathByFullName, GetPackagesByPackageFamily, GetPerformanceInfo, GetPhysicallyInstalledSystemMemory, GetPriorityClass, GetPrivateProfileIntA, GetPrivateProfileIntW, GetPrivateProfileSectionA, GetPrivateProfileSectionNamesA, GetPrivateProfileSectionNamesW, GetPrivateProfileSectionW, GetPrivateProfileStringA, GetPrivateProfileStringW, GetPrivateProfileStructA, GetPrivateProfileStructW, GetProcAddress, GetProcessAffinityMask, GetProcessDefaultCpuSets, GetProcessDEPPolicy, GetProcessGroupAffinity, GetProcessHandleCount, GetProcessHeap, GetProcessHeaps, GetProcessId, GetProcessIdOfThread, GetProcessImageFileNameA, GetProcessImageFileNameW, GetProcessInformation, GetProcessIoCounters, GetProcessMemoryInfoA, GetProcessMemoryInfoW, GetProcessMitigationPolicy, GetProcessorSystemCycleTime, GetProcessPreferredUILanguages, GetProcessPriorityBoost, GetProcessShutdownParameters, GetProcessTimes, GetProcessVersion, GetProcessWorkingSetSize, GetProcessWorkingSetSizeEx, GetProductInfo, GetProfileIntA, GetProfileIntW, GetProfileSectionA, GetProfileSectionW, GetProfileStringA, GetProfileStringW, GetQueuedCompletionStatus, GetQueuedCompletionStatusEx, GetShortPathNameA, GetShortPathNameW, GetStagedPackageOrigin, GetStagedPackagePathByFullName, GetStartupInfoA, GetStartupInfoW, GetStdHandle, GetStringScripts, GetStringTypeA, GetStringTypeExA, GetStringTypeExW, GetStringTypeW, GetSystemCpuSetInformation, GetSystemDefaultLangID, GetSystemDefaultLCID, GetSystemDefaultLocaleName, GetSystemDefaultUILanguage, GetSystemDEPPolicy, GetSystemDirectoryA, GetSystemDirectoryW, GetSystemFileCacheSize, GetSystemFirmwareTable, GetSystemInfo, GetSystemPowerStatus, GetSystemPreferredUILanguages, GetSystemRegistryQuota, GetSystemTime, GetSystemTimeAdjustment, GetSystemTimeAsFileTime, GetSystemTimePreciseAsFileTime, GetSystemTimes, GetSystemWindowsDirectoryA, GetSystemWindowsDirectoryW, GetSystemWow64Directory2A, GetSystemWow64Directory2W, GetSystemWow64DirectoryA, GetSystemWow64DirectoryW, GetTapeParameters, GetTapePosition, GetTapeStatus, GetTempFileNameA, GetTempFileNameW, GetTempPathA, GetTempPathW, GetThreadContext, GetThreadDescription, GetThreadErrorMode, GetThreadGroupAffinity, GetThreadId, GetThreadIdealProcessorEx, GetThreadInformation, GetThreadIOPendingFlag, GetThreadLocale, GetThreadPreferredUILanguages, GetThreadPriority, GetThreadPriorityBoost, GetThreadSelectedCpuSets, GetThreadSelectorEntry, GetThreadTimes, GetThreadUILanguage, GetTickCount, GetTickCount64, GetTimeFormatA, GetTimeFormatEx, GetTimeFormatW, GetTimeZoneInformation, GetTimeZoneInformationForYear, GetUILanguageInfo, GetUmsCompletionListEvent, GetUmsSystemThreadInformation, GetUserDefaultGeoName, GetUserDefaultLangID, GetUserDefaultLCID, GetUserDefaultLocaleName, GetUserDefaultUILanguage, GetUserGeoID, GetUserPreferredUILanguages, GetVersion, GetVersionExA, GetVersionExW, GetVolumeInformationA, GetVolumeInformationByHandleW, GetVolumeInformationW, GetVolumeNameForVolumeMountPointA, GetVolumeNameForVolumeMountPointW, GetVolumePathNameA, GetVolumePathNamesForVolumeNameA, GetVolumePathNamesForVolumeNameW, GetVolumePathNameW, GetWindowsDirectoryA, GetWindowsDirectoryW, GetWriteWatch, GetWsChanges, GetWsChangesExA, GetWsChangesExW, GetXStateFeaturesMask, GlobalAddAtomA, GlobalAddAtomExA, GlobalAddAtomExW, GlobalAddAtomW, GlobalAlloc, GlobalDeleteAtom, GlobalFindAtomA, GlobalFindAtomW, GlobalFlags, GlobalFree, GlobalGetAtomNameA, GlobalGetAtomNameW, GlobalHandle, GlobalLock, GlobalMemoryStatus, GlobalMemoryStatusEx, GlobalReAlloc, GlobalSize, GlobalUnlock, Heap32First, Heap32ListFirst, Heap32ListNext, Heap32Next, HeapAlloc, HeapCompact, HeapCreate, HeapDestroy, HeapFree, HeapLock, HeapQueryInformation, HeapReAlloc, HeapSetInformation, HeapSize, HeapSummary, HeapUnlock, HeapValidate, HeapWalk, IdnToAscii, IdnToNameprepUnicode, IdnToUnicode, InitAtomTable, InitializeConditionVariable, InitializeContext, InitializeCriticalSection, InitializeCriticalSectionAndSpinCount, InitializeCriticalSectionEx, InitializeEnclave, InitializeProcessForWsWatchA, InitializeProcessForWsWatchW, InitializeProcThreadAttributeList, InitializeSListHead, InitializeSRWLock, InitializeSynchronizationBarrier, InitOnceBeginInitialize, InitOnceComplete, InitOnceExecuteOnce, InitOnceInitialize, InstallELAMCertificateInfo, InterlockedCompareExchange, InterlockedDecrement, InterlockedExchange, InterlockedExchangeAdd, InterlockedFlushSList, InterlockedIncrement, InterlockedPopEntrySList, InterlockedPushEntrySList, InterlockedPushListSList, InterlockedPushListSListEx, IsBadCodePtr, IsBadReadPtr, IsBadStringPtrA, IsBadStringPtrW, IsBadWritePtr, IsDBCSLeadByte, IsDBCSLeadByteEx, IsDebuggerPresent, IsEnclaveTypeSupported, IsNativeVhdBoot, IsNLSDefinedString, IsNormalizedString, IsProcessCritical, IsProcessInJob, IsProcessorFeaturePresent, IsSystemResumeAutomatic, IsThreadAFiber, IsThreadpoolTimerSet, IsValidCodePage, IsValidLanguageGroup, IsValidLocale, IsValidLocaleName, IsValidNLSVersion, IsWow64GuestMachineSupported, IsWow64Process, IsWow64Process2, LCIDToLocaleName, LCMapStringA, LCMapStringEx, LCMapStringW, LeaveCriticalSection, LeaveCriticalSectionWhenCallbackReturns, LoadEnclaveData, LoadEnclaveImageA, LoadEnclaveImageW, LoadLibraryA, LoadLibraryExA, LoadLibraryExW, LoadLibraryW, LoadModule, LoadPackagedLibrary, LoadResource, LoadStringByReference, LocalAlloc, LocaleNameToLCID, LocalFileTimeToFileTime, LocalFlags, LocalFree, LocalHandle, LocalLock, LocalReAlloc, LocalSize, LocalUnlock, LocateXStateFeature, LockFile, LockFileEx, LockResource, lstrcmpA, lstrcmpiA, lstrcmpiW, lstrcmpW, lstrcpynA, lstrcpynW, lstrlenA, lstrlenW, MapUserPhysicalPages, MapUserPhysicalPagesScatter, MapViewOfFile, MapViewOfFileEx, MapViewOfFileExNuma, MapViewOfFileFromApp, MapViewOfFileNuma2, Module32First, Module32NextA, Module32NextW, MoveFileA, MoveFileExA, MoveFileExW, MoveFileTransactedA, MoveFileTransactedW, MoveFileW, MoveFileWithProgressA, MoveFileWithProgressW, MulDiv, MultiByteToWideChar, NeedCurrentDirectoryForExePathA, NeedCurrentDirectoryForExePathW, NormalizeString, OfferVirtualMemory, OpenCommPort, OpenEventA, OpenEventW, OpenFile, OpenFileById, OpenFileMappingA, OpenFileMappingFromApp, OpenFileMappingW, OpenJobObjectA, OpenJobObjectW, OpenMutexA, OpenMutexW, OpenPackageInfoByFullName, OpenPrivateNamespaceA, OpenPrivateNamespaceW, OpenProcess, OpenSemaphoreA, OpenSemaphoreW, OpenThread, OpenWaitableTimerA, OpenWaitableTimerW, OutputDebugStringA, OutputDebugStringW, PackageFamilyNameFromFullName, PackageFamilyNameFromId, PackageFullNameFromId, PackageIdFromFullName, PackageNameAndPublisherIdFromFamilyName, ParseApplicationUserModelId, PathAllocCanonicalize, PathAllocCombine, PathCchAddBackslash, PathCchAddBackslashEx, PathCchAddExtension, PathCchAppend, PathCchAppendEx, PathCchCanonicalize, PathCchCanonicalizeEx, PathCchCombine, PathCchCombineEx, PathCchFindExtension, PathCchIsRoot, PathCchRemoveBackslash, PathCchRemoveBackslashEx, PathCchRemoveExtension, PathCchRemoveFileSpec, PathCchRenameExtension, PathCchSkipRoot, PathCchStripPrefix, PathCchStripToRoot, PathIsUNCEx, PeekConsoleInputA, PeekConsoleInputW, PeekNamedPipe, PostQueuedCompletionStatus, PowerClearRequest, PowerCreateRequest, PowerSetRequest, PrefetchVirtualMemory, PrepareTape, Process32FirstA, Process32FirstW, Process32NextA, Process32NextW, ProcessIdToSessionId, PssCaptureSnapshot, PssDuplicateSnapshot, PssFreeSnapshot, PssQuerySnapshot, PssWalkMarkerCreate, PssWalkMarkerFree, PssWalkMarkerGetPosition, PssWalkMarkerSeekToBeginning, PssWalkMarkerSetPosition, PssWalkSnapshot, PulseEvent, PurgeComm, QueryActCtxSettingsW, QueryActCtxW, QueryAuxiliaryCounterFrequency, QueryDepthSList, QueryDosDeviceA, QueryDosDeviceW, QueryFullProcessImageNameA, QueryFullProcessImageNameW, QueryIdleProcessorCycleTime, QueryIdleProcessorCycleTimeEx, QueryInformationJobObject, QueryInterruptTime, QueryInterruptTimePrecise, QueryIoRateControlInformationJobObject, QueryMemoryResourceNotification, QueryOptionalDelayLoadedAPI, QueryPerformanceCounter, QueryPerformanceFrequency, QueryProcessAffinityUpdateMode, QueryProcessCycleTime, QueryProtectedPolicy, QueryThreadCycleTime, QueryThreadpoolStackInformation, QueryThreadProfiling, QueryUmsThreadInformation, QueryUnbiasedInterruptTime, QueryUnbiasedInterruptTimePrecise, QueryVirtualMemoryInformation, QueryWorkingSet, QueryWorkingSetEx, QueueUserAPC, QueueUserWorkItem, RaiseException, RaiseFailFastException, ReadConsoleA, ReadConsoleInputA, ReadConsoleInputW, ReadConsoleOutputA, ReadConsoleOutputAttribute, ReadConsoleOutputCharacterA, ReadConsoleOutputCharacterW, ReadConsoleOutputW, ReadConsoleW, ReadDirectoryChangesExW, ReadDirectoryChangesW, ReadFile, ReadFileEx, ReadFileScatter, ReadProcessMemory, ReadThreadProfilingData, ReclaimVirtualMemory, RegisterApplicationRecoveryCallback, RegisterApplicationRestart, RegisterBadMemoryNotification, RegisterWaitForSingleObject, ReleaseActCtx, ReleaseMutex, ReleaseMutexWhenCallbackReturns, ReleaseSemaphore, ReleaseSemaphoreWhenCallbackReturns, ReleaseSRWLockExclusive, ReleaseSRWLockShared, RemoveDirectoryA, RemoveDirectoryTransactedA, RemoveDirectoryTransactedW, RemoveDirectoryW, RemoveDllDirectory, RemoveSecureMemoryCacheCallback, RemoveVectoredContinueHandler, RemoveVectoredExceptionHandler, ReOpenFile, ReplaceFileA, ReplaceFileW, RequestWakeupLatency, ResetEvent, ResetWriteWatch, ResolveLocaleName, RestoreLastError, ResumeThread, RtlAddFunctionTable, RtlCaptureContext, RtlDeleteFunctionTable, RtlInstallFunctionTableCallback, RtlLookupFunctionEntry, RtlMoveMemory, RtlPcToFileHeader, RtlRestoreContext, RtlUnwind, RtlUnwindEx, RtlZeroMemory, ScrollConsoleScreenBufferA, ScrollConsoleScreenBufferW, SearchPathA, SearchPathW, SetCalendarInfoA, SetCalendarInfoW, SetCommBreak, SetCommConfig, SetCommMask, SetCommState, SetCommTimeouts, SetComputerNameA, SetComputerNameEx2W, SetComputerNameExA, SetComputerNameExW, SetComputerNameW, SetConsoleActiveScreenBuffer, SetConsoleCP, SetConsoleCtrlHandler, SetConsoleCursorInfo, SetConsoleCursorPosition, SetConsoleDisplayMode, SetConsoleHistoryInfo, SetConsoleMode, SetConsoleOutputCP, SetConsoleScreenBufferInfoEx, SetConsoleScreenBufferSize, SetConsoleTextAttribute, SetConsoleTitleA, SetConsoleTitleW, SetConsoleWindowInfo, SetCriticalSectionSpinCount, SetCurrentConsoleFontEx, SetCurrentDirectoryA, SetCurrentDirectoryW, SetDefaultCommConfigA, SetDefaultCommConfigW, SetDefaultDllDirectories, SetDllDirectoryA, SetDllDirectoryW, SetDynamicTimeZoneInformation, SetEndOfFile, SetEnvironmentStringsW, SetEnvironmentVariableA, SetEnvironmentVariableW, SetErrorMode, SetEvent, SetEventWhenCallbackReturns, SetFileApisToANSI, SetFileApisToOEM, SetFileAttributesA, SetFileAttributesTransactedA, SetFileAttributesTransactedW, SetFileAttributesW, SetFileBandwidthReservation, SetFileCompletionNotificationModes, SetFileInformationByHandle, SetFileIoOverlappedRange, SetFilePointer, SetFilePointerEx, SetFileShortNameA, SetFileShortNameW, SetFileTime, SetFileValidData, SetFirmwareEnvironmentVariableA, SetFirmwareEnvironmentVariableExA, SetFirmwareEnvironmentVariableExW, SetFirmwareEnvironmentVariableW, SetHandleInformation, SetInformationJobObject, SetIoRateControlInformationJobObject, SetLastError, SetLocaleInfoA, SetLocaleInfoW, SetLocalTime, SetMailslotInfo, SetNamedPipeHandleState, SetPriorityClass, SetProcessAffinityMask, SetProcessAffinityUpdateMode, SetProcessDefaultCpuSets, SetProcessDEPPolicy, SetProcessInformation, SetProcessMitigationPolicy, SetProcessPreferredUILanguages, SetProcessPriorityBoost, SetProcessShutdownParameters, SetProcessValidCallTargets, SetProcessWorkingSetSize, SetProcessWorkingSetSizeEx, SetProtectedPolicy, SetSearchPathMode, SetStdHandle, SetStdHandleEx, SetSystemFileCacheSize, SetSystemPowerState, SetSystemTime, SetSystemTimeAdjustment, SetTapeParameters, SetTapePosition, SetThreadAffinityMask, SetThreadContext, SetThreadDescription, SetThreadErrorMode, SetThreadExecutionState, SetThreadGroupAffinity, SetThreadIdealProcessor, SetThreadIdealProcessorEx, SetThreadInformation, SetThreadLocale, SetThreadpoolStackInformation, SetThreadpoolThreadMaximum, SetThreadpoolThreadMinimum, SetThreadpoolTimer, SetThreadpoolTimerEx, SetThreadpoolWait, SetThreadpoolWaitEx, SetThreadPreferredUILanguages, SetThreadPriority, SetThreadPriorityBoost, SetThreadSelectedCpuSets, SetThreadStackGuarantee, SetThreadUILanguage, SetTimeZoneInformation, SetUmsThreadInformation, SetUnhandledExceptionFilter, SetupComm, SetUserGeoID, SetUserGeoName, SetVolumeLabelA, SetVolumeLabelW, SetVolumeMountPointA, SetVolumeMountPointW, SetWaitableTimer, SetWaitableTimerEx, SetXStateFeaturesMask, SignalObjectAndWait, SizeofResource, Sleep, SleepConditionVariableCS, SleepConditionVariableSRW, SleepEx, StartThreadpoolIo, SubmitThreadpoolWork, SuspendThread, SwitchToFiber, SwitchToThread, SystemTimeToFileTime, SystemTimeToTzSpecificLocalTime, SystemTimeToTzSpecificLocalTimeEx, TerminateEnclave, TerminateJobObject, TerminateProcess, TerminateProcessOnMemoryExhaustion, TerminateThread, TermsrvAppInstallMode, Thread32First, Thread32Next, TlsAlloc, TlsFree, TlsGetValue, TlsSetValue, Toolhelp32ReadProcessMemory, TransactNamedPipe, TransmitCommChar, TryAcquireSRWLockExclusive, TryAcquireSRWLockShared, TryEnterCriticalSection, TrySubmitThreadpoolCallback, TzSpecificLocalTimeToSystemTime, TzSpecificLocalTimeToSystemTimeEx, UmsThreadYield, UnhandledExceptionFilter, UnlockFile, UnlockFileEx, UnmapViewOfFile, UnmapViewOfFile2, UnmapViewOfFileEx, UnregisterApplicationRecoveryCallback, UnregisterApplicationRestart, UnregisterBadMemoryNotification, UnregisterWait, UnregisterWaitEx, UpdateCalendarDayOfWeek, UpdateProcThreadAttribute, UpdateResourceA, UpdateResourceW, UserHandleGrantAccess, VerifyScripts, VerifyVersionInfoA, VerifyVersionInfoW, VerSetConditionMask, VirtualAlloc, VirtualAllocEx, VirtualAllocExNuma, VirtualAllocFromApp, VirtualFree, VirtualFreeEx, VirtualLock, VirtualProtect, VirtualProtectEx, VirtualProtectFromApp, VirtualQuery, VirtualQueryEx, VirtualUnlock, WaitCommEvent, WaitForDebugEvent, WaitForDebugEventEx, WaitForMultipleObjects, WaitForMultipleObjectsEx, WaitForSingleObject, WaitForSingleObjectEx, WaitForThreadpoolIoCallbacks, WaitForThreadpoolTimerCallbacks, WaitForThreadpoolWaitCallbacks, WaitForThreadpoolWorkCallbacks, WaitNamedPipeA, WaitNamedPipeW, WaitOnAddress, WakeAllConditionVariable, WakeByAddressAll, WakeByAddressSingle, WakeConditionVariable, WerGetFlags, WerRegisterAdditionalProcess, WerRegisterAppLocalDump, WerRegisterCustomMetadata, WerRegisterExcludedMemoryBlock, WerRegisterFile, WerRegisterMemoryBlock, WerRegisterRuntimeExceptionModule, WerSetFlags, WerUnregisterAdditionalProcess, WerUnregisterAppLocalDump, WerUnregisterCustomMetadata, WerUnregisterExcludedMemoryBlock, WerUnregisterFile, WerUnregisterMemoryBlock, WerUnregisterRuntimeExceptionModule, WideCharToMultiByte, WinExec, Wow64DisableWow64FsRedirection, Wow64EnableWow64FsRedirection, Wow64GetThreadContext, Wow64GetThreadSelectorEntry, Wow64RevertWow64FsRedirection, Wow64SetThreadContext, Wow64SetThreadDefaultGuestMachine, Wow64SuspendThread, WriteConsoleA, WriteConsoleInputA, WriteConsoleInputW, WriteConsoleOutputA, WriteConsoleOutputAttribute, WriteConsoleOutputCharacterA, WriteConsoleOutputCharacterW, WriteConsoleOutputW, WriteConsoleW, WriteFile, WriteFileEx, WriteFileGather, WritePrivateProfileSectionA, WritePrivateProfileSectionW, WritePrivateProfileStringA, WritePrivateProfileStringW, WritePrivateProfileStructA, WritePrivateProfileStructW, WriteProcessMemory, WriteProfileSectionA, WriteProfileSectionW, WriteProfileStringA, WriteProfileStringW, WriteTapemark, WTSGetActiveConsoleSessionId, ZombifyActCtx +AcquireSRWLockExclusive, AcquireSRWLockShared, ActivateActCtx, AddAtomA, AddAtomW, AddConsoleAliasA, AddConsoleAliasW, AddDllDirectory, AddIntegrityLabelToBoundaryDescriptor, AddLocalAlternateComputerNameA, AddLocalAlternateComputerNameW, AddRefActCtx, AddSecureMemoryCacheCallback, AddSIDToBoundaryDescriptor, AddVectoredContinueHandler, AddVectoredExceptionHandler, AdjustCalendarDate, AllocateUserPhysicalPages, AllocateUserPhysicalPagesNuma, AllocConsole, ApplicationRecoveryFinished, ApplicationRecoveryInProgress, AppPolicyGetCreateFileAccess, AppPolicyGetProcessTerminationMethod, AppPolicyGetShowDeveloperDiagnostic, AppPolicyGetThreadInitializationType, AreFileApisANSI, AssignProcessToJobObject, AttachConsole, BackupRead, BackupSeek, BackupWrite, BaseFlushAppcompatCache, Beep, BeginUpdateResourceA, BeginUpdateResourceW, BindIoCompletionCallback, BuildCommDCBA, BuildCommDCBAndTimeoutsA, BuildCommDCBAndTimeoutsW, BuildCommDCBW, CallbackMayRunLong, CallEnclave, CallNamedPipeA, CallNamedPipeW, CancelIo, CancelIoEx, CancelSynchronousIo, CancelThreadpoolIo, CancelWaitableTimer, CeipIsOptedIn, ChangeTimerQueueTimer, CheckNameLegalDOS8Dot3A, CheckNameLegalDOS8Dot3W, CheckRemoteDebuggerPresent, ClearCommBreak, ClearCommError, CloseHandle, ClosePackageInfo, ClosePrivateNamespace, CloseThreadpool, CloseThreadpoolCleanupGroup, CloseThreadpoolCleanupGroupMembers, CloseThreadpoolIo, CloseThreadpoolTimer, CloseThreadpoolWait, CloseThreadpoolWork, CommConfigDialogA, CommConfigDialogW, CompareFileTime, CompareObjectHandles, CompareStringA, CompareStringEx, CompareStringOrdinal, CompareStringW, ConnectNamedPipe, ContinueDebugEvent, ConvertAuxiliaryCounterToPerformanceCounter, ConvertCalDateTimeToSystemTime, ConvertDefaultLocale, ConvertFiberToThread, ConvertPerformanceCounterToAuxiliaryCounter, ConvertSystemTimeToCalDateTime, ConvertThreadToFiber, ConvertThreadToFiberEx, CopyContext, CopyFile2, CopyFileA, CopyFileExA, CopyFileExW, CopyFileTransactedA, CopyFileTransactedW, CopyFileW, CreateActCtxA, CreateActCtxW, CreateBoundaryDescriptorA, CreateBoundaryDescriptorW, CreateConsoleScreenBuffer, CreateDirectoryA, CreateDirectoryExA, CreateDirectoryExW, CreateDirectoryTransactedA, CreateDirectoryTransactedW, CreateDirectoryW, CreateEnclave, CreateEventA, CreateEventExA, CreateEventExW, CreateEventW, CreateFiber, CreateFiberEx, CreateFile2, CreateFileA, CreateFileMappingA, CreateFileMappingFromApp, CreateFileMappingNumaA, CreateFileMappingNumaW, CreateFileMappingW, CreateFileTransactedA, CreateFileTransactedW, CreateFileW, CreateHardLinkA, CreateHardLinkTransactedA, CreateHardLinkTransactedW, CreateHardLinkW, CreateIoCompletionPort, CreateJobObjectA, CreateJobObjectW, CreateMailslotA, CreateMailslotW, CreateMemoryResourceNotification, CreateMutexA, CreateMutexExA, CreateMutexExW, CreateMutexW, CreateNamedPipeA, CreateNamedPipeW, CreatePipe, CreatePrivateNamespaceA, CreatePrivateNamespaceW, CreateProcessA, CreateProcessAsUserA, CreateProcessAsUserW, CreateProcessW, CreateRemoteThread, CreateRemoteThreadEx, CreateSemaphoreA, CreateSemaphoreExA, CreateSemaphoreExW, CreateSemaphoreW, CreateSymbolicLinkA, CreateSymbolicLinkW, CreateTapePartition, CreateThread, CreateThreadpool, CreateThreadpoolCleanupGroup, CreateThreadpoolIo, CreateThreadpoolTimer, CreateThreadpoolWait, CreateThreadpoolWork, CreateTimerQueue, CreateTimerQueueTimer, CreateToolhelp32Snapshot, CreateUmsCompletionList, CreateUmsThreadContext, CreateWaitableTimerA, CreateWaitableTimerExA, CreateWaitableTimerExW, CreateWaitableTimerW, DeactivateActCtx, DebugActiveProcess, DebugActiveProcessStop, DebugBreak, DebugBreakProcess, DebugSetProcessKillOnExit, DecodePointer, DecodeRemotePointer, DecodeSystemPointer, DefineDosDeviceA, DefineDosDeviceW, DeleteAtom, DeleteBoundaryDescriptor, DeleteCriticalSection, DeleteEnclave, DeleteFiber, DeleteFileA, DeleteFileTransactedA, DeleteFileTransactedW, DeleteFileW, DeleteProcThreadAttributeList, DeleteSynchronizationBarrier, DeleteTimerQueue, DeleteTimerQueueEx, DeleteTimerQueueTimer, DeleteUmsCompletionList, DeleteUmsThreadContext, DeleteVolumeMountPointA, DeleteVolumeMountPointW, DequeueUmsCompletionListItems, DeviceIoControl, DisableThreadLibraryCalls, DisableThreadProfiling, DisassociateCurrentThreadFromCallback, DiscardVirtualMemory, DisconnectNamedPipe, DnsHostnameToComputerNameA, DnsHostnameToComputerNameExW, DnsHostnameToComputerNameW, DosDateTimeToFileTime, DuplicateHandle, EmptyWorkingSet, EnableThreadProfiling, EncodePointer, EncodeRemotePointer, EncodeSystemPointer, EndUpdateResourceA, EndUpdateResourceW, EnterCriticalSection, EnterSynchronizationBarrier, EnterUmsSchedulingMode, EnumCalendarInfoA, EnumCalendarInfoExA, EnumCalendarInfoExEx, EnumCalendarInfoExW, EnumCalendarInfoW, EnumDateFormatsA, EnumDateFormatsExA, EnumDateFormatsExEx, EnumDateFormatsExW, EnumDateFormatsW, EnumDeviceDrivers, EnumDynamicTimeZoneInformation, EnumLanguageGroupLocalesA, EnumLanguageGroupLocalesW, EnumPageFilesA, EnumPageFilesW, EnumProcessesA, EnumProcessesW, EnumProcessModules, EnumProcessModulesEx, EnumResourceLanguagesExW, EnumResourceLanguagesW, EnumResourceNamesExW, EnumResourceNamesW, EnumResourceTypesExA, EnumResourceTypesExW, EnumResourceTypesW, EnumSystemCodePagesA, EnumSystemCodePagesW, EnumSystemFirmwareTables, EnumSystemGeoID, EnumSystemGeoNames, EnumSystemLanguageGroupsA, EnumSystemLanguageGroupsW, EnumSystemLocalesA, EnumSystemLocalesEx, EnumSystemLocalesW, EnumTimeFormatsA, EnumTimeFormatsEx, EnumTimeFormatsW, EnumUILanguagesA, EnumUILanguagesW, EraseTape, EscapeCommFunction, ExecuteUmsThread, ExitProcess, ExitThread, ExpandEnvironmentStringsA, ExpandEnvironmentStringsW, FatalAppExitA, FatalAppExitW, FatalExit, FileTimeToDosDateTime, FileTimeToLocalFileTime, FileTimeToSystemTime, FillConsoleOutputAttribute, FillConsoleOutputCharacterA, FillConsoleOutputCharacterW, FindActCtxSectionGuid, FindActCtxSectionStringA, FindActCtxSectionStringW, FindAtomA, FindAtomW, FindClose, FindCloseChangeNotification, FindFirstChangeNotificationA, FindFirstChangeNotificationW, FindFirstFileA, FindFirstFileExA, FindFirstFileExW, FindFirstFileNameTransactedW, FindFirstFileNameW, FindFirstFileTransactedA, FindFirstFileTransactedW, FindFirstFileW, FindFirstStreamTransactedW, FindFirstStreamW, FindFirstVolumeA, FindFirstVolumeMountPointA, FindFirstVolumeMountPointW, FindFirstVolumeW, FindNextChangeNotification, FindNextFileA, FindNextFileNameW, FindNextFileW, FindNextStreamW, FindNextVolumeA, FindNextVolumeMountPointA, FindNextVolumeMountPointW, FindNextVolumeW, FindNLSString, FindNLSStringEx, FindPackagesByPackageFamily, FindResourceExW, FindResourceW, FindStringOrdinal, FindVolumeClose, FindVolumeMountPointClose, FlsAlloc, FlsFree, FlsGetValue, FlsSetValue, FlushConsoleInputBuffer, FlushFileBuffers, FlushInstructionCache, FlushProcessWriteBuffers, FlushViewOfFile, FoldStringA, FoldStringW, FormatApplicationUserModelId, FormatMessageA, FormatMessageW, FreeConsole, FreeEnvironmentStringsA, FreeEnvironmentStringsW, FreeLibrary, FreeLibraryAndExitThread, FreeLibraryWhenCallbackReturns, FreeMemoryJobObject, FreeResource, FreeUserPhysicalPages, GenerateConsoleCtrlEvent, GetACP, GetActiveProcessorCount, GetActiveProcessorGroupCount, GetAppContainerNamedObjectPath, GetApplicationRecoveryCallback, GetApplicationRestartSettings, GetApplicationUserModelId, GetApplicationUserModelIdFromToken, GetAtomNameA, GetAtomNameW, GetBinaryTypeA, GetBinaryTypeW, GetCalendarDateFormatEx, GetCalendarInfoA, GetCalendarInfoEx, GetCalendarInfoW, GetCalendarSupportedDateRange, GetCommandLineA, GetCommandLineW, GetCommConfig, GetCommMask, GetCommModemStatus, GetCommPorts, GetCommProperties, GetCommState, GetCommTimeouts, GetComPlusPackageInstallStatus, GetCompressedFileSizeA, GetCompressedFileSizeW, GetComputerNameA, GetComputerNameExA, GetComputerNameExW, GetComputerNameW, GetConsoleAliasA, GetConsoleAliasesA, GetConsoleAliasesLengthA, GetConsoleAliasesLengthW, GetConsoleAliasesW, GetConsoleAliasExesA, GetConsoleAliasExesLengthA, GetConsoleAliasExesLengthW, GetConsoleAliasExesW, GetConsoleAliasW, GetConsoleCP, GetConsoleCursorInfo, GetConsoleDisplayMode, GetConsoleFontSize, GetConsoleHistoryInfo, GetConsoleMode, GetConsoleOriginalTitleA, GetConsoleOriginalTitleW, GetConsoleOutputCP, GetConsoleProcessList, GetConsoleScreenBufferInfo, GetConsoleScreenBufferInfoEx, GetConsoleSelectionInfo, GetConsoleTitleA, GetConsoleTitleW, GetConsoleWindow, GetCPInfo, GetCPInfoExW, GetCurrencyFormatA, GetCurrencyFormatEx, GetCurrencyFormatW, GetCurrentActCtx, GetCurrentApplicationUserModelId, GetCurrentConsoleFont, GetCurrentConsoleFontEx, GetCurrentDirectoryA, GetCurrentDirectoryW, GetCurrentPackageFamilyName, GetCurrentPackageFullName, GetCurrentPackageId, GetCurrentPackageInfo, GetCurrentPackagePath, GetCurrentProcess, GetCurrentProcessId, GetCurrentProcessorNumber, GetCurrentProcessorNumberEx, GetCurrentThread, GetCurrentThreadId, GetCurrentThreadStackLimits, GetCurrentUmsThread, GetDateFormatA, GetDateFormatEx, GetDateFormatW, GetDefaultCommConfigA, GetDefaultCommConfigW, GetDeviceDriverBaseNameA, GetDeviceDriverBaseNameW, GetDeviceDriverFileNameA, GetDeviceDriverFileNameW, GetDevicePowerState, GetDiskFreeSpaceA, GetDiskFreeSpaceExA, GetDiskFreeSpaceExW, GetDiskFreeSpaceW, GetDllDirectoryA, GetDllDirectoryW, GetDriveTypeA, GetDriveTypeW, GetDurationFormat, GetDurationFormatEx, GetDynamicTimeZoneInformation, GetDynamicTimeZoneInformationEffectiveYears, GetEnabledXStateFeatures, GetEnvironmentStringsA, GetEnvironmentStringsW, GetEnvironmentVariableA, GetEnvironmentVariableW, GetErrorMode, GetExitCodeProcess, GetExitCodeThread, GetFileAttributesA, GetFileAttributesExA, GetFileAttributesExW, GetFileAttributesTransactedA, GetFileAttributesTransactedW, GetFileAttributesW, GetFileBandwidthReservation, GetFileInformationByHandle, GetFileInformationByHandleEx, GetFileMUIInfo, GetFileMUIPath, GetFileSize, GetFileSizeEx, GetFileTime, GetFileType, GetFinalPathNameByHandleA, GetFinalPathNameByHandleW, GetFirmwareEnvironmentVariableA, GetFirmwareEnvironmentVariableExA, GetFirmwareEnvironmentVariableExW, GetFirmwareEnvironmentVariableW, GetFullPathNameA, GetFullPathNameTransactedA, GetFullPathNameTransactedW, GetFullPathNameW, GetGamingDeviceModelInformation, GetGeoInfoA, GetGeoInfoEx, GetGeoInfoW, GetHandleInformation, GetIntegratedDisplaySize, GetLargePageMinimum, GetLargestConsoleWindowSize, GetLastError, GetLocaleInfoA, GetLocaleInfoEx, GetLocaleInfoW, GetLocalTime, GetLogicalDrives, GetLogicalDriveStringsA, GetLogicalDriveStringsW, GetLogicalProcessorInformation, GetLogicalProcessorInformationEx, GetLongPathNameA, GetLongPathNameTransactedA, GetLongPathNameTransactedW, GetLongPathNameW, GetMailslotInfo, GetMappedFileNameA, GetMappedFileNameW, GetMaximumProcessorCount, GetMaximumProcessorGroupCount, GetMemoryErrorHandlingCapabilities, GetModuleBaseNameA, GetModuleBaseNameW, GetModuleFileNameA, GetModuleFileNameW, GetModuleHandleA, GetModuleHandleExA, GetModuleHandleExW, GetModuleHandleW, GetModuleInformation, GetNamedPipeClientComputerNameA, GetNamedPipeClientComputerNameW, GetNamedPipeClientProcessId, GetNamedPipeClientSessionId, GetNamedPipeHandleStateA, GetNamedPipeHandleStateW, GetNamedPipeInfo, GetNamedPipeServerProcessId, GetNamedPipeServerSessionId, GetNativeSystemInfo, GetNLSVersion, GetNLSVersionEx, GetNumaAvailableMemoryNode, GetNumaAvailableMemoryNodeEx, GetNumaHighestNodeNumber, GetNumaNodeNumberFromHandle, GetNumaNodeProcessorMask, GetNumaNodeProcessorMaskEx, GetNumaProcessorNode, GetNumaProcessorNodeEx, GetNumaProximityNode, GetNumaProximityNodeEx, GetNumberFormatA, GetNumberFormatEx, GetNumberFormatW, GetNumberOfConsoleInputEvents, GetNumberOfConsoleMouseButtons, GetOEMCP, GetOsManufacturingMode, GetOsSafeBootMode, GetOverlappedResult, GetOverlappedResultEx, GetPackageApplicationIds, GetPackageFamilyName, GetPackageFamilyNameFromToken, GetPackageFullNameFromToken, GetPackageInfo, GetPackagePath, GetPackagePathByFullName, GetPackagesByPackageFamily, GetPerformanceInfo, GetPhysicallyInstalledSystemMemory, GetPriorityClass, GetPrivateProfileIntA, GetPrivateProfileIntW, GetPrivateProfileSectionA, GetPrivateProfileSectionNamesA, GetPrivateProfileSectionNamesW, GetPrivateProfileSectionW, GetPrivateProfileStringA, GetPrivateProfileStringW, GetPrivateProfileStructA, GetPrivateProfileStructW, GetProcAddress, GetProcessAffinityMask, GetProcessDefaultCpuSets, GetProcessDEPPolicy, GetProcessGroupAffinity, GetProcessHandleCount, GetProcessHeap, GetProcessHeaps, GetProcessId, GetProcessIdOfThread, GetProcessImageFileNameA, GetProcessImageFileNameW, GetProcessInformation, GetProcessIoCounters, GetProcessMemoryInfoA, GetProcessMemoryInfoW, GetProcessMitigationPolicy, GetProcessorSystemCycleTime, GetProcessPreferredUILanguages, GetProcessPriorityBoost, GetProcessShutdownParameters, GetProcessTimes, GetProcessVersion, GetProcessWorkingSetSize, GetProcessWorkingSetSizeEx, GetProductInfo, GetProfileIntA, GetProfileIntW, GetProfileSectionA, GetProfileSectionW, GetProfileStringA, GetProfileStringW, GetQueuedCompletionStatus, GetQueuedCompletionStatusEx, GetShortPathNameA, GetShortPathNameW, GetStagedPackageOrigin, GetStagedPackagePathByFullName, GetStartupInfoA, GetStartupInfoW, GetStdHandle, GetStringScripts, GetStringTypeA, GetStringTypeExA, GetStringTypeExW, GetStringTypeW, GetSystemCpuSetInformation, GetSystemDefaultLangID, GetSystemDefaultLCID, GetSystemDefaultLocaleName, GetSystemDefaultUILanguage, GetSystemDEPPolicy, GetSystemDirectoryA, GetSystemDirectoryW, GetSystemFileCacheSize, GetSystemFirmwareTable, GetSystemInfo, GetSystemPowerStatus, GetSystemPreferredUILanguages, GetSystemRegistryQuota, GetSystemTime, GetSystemTimeAdjustment, GetSystemTimeAdjustmentPrecise, GetSystemTimeAsFileTime, GetSystemTimePreciseAsFileTime, GetSystemTimes, GetSystemWindowsDirectoryA, GetSystemWindowsDirectoryW, GetSystemWow64Directory2A, GetSystemWow64Directory2W, GetSystemWow64DirectoryA, GetSystemWow64DirectoryW, GetTapeParameters, GetTapePosition, GetTapeStatus, GetTempFileNameA, GetTempFileNameW, GetTempPathA, GetTempPathW, GetThreadContext, GetThreadDescription, GetThreadErrorMode, GetThreadGroupAffinity, GetThreadId, GetThreadIdealProcessorEx, GetThreadInformation, GetThreadIOPendingFlag, GetThreadLocale, GetThreadPreferredUILanguages, GetThreadPriority, GetThreadPriorityBoost, GetThreadSelectedCpuSets, GetThreadSelectorEntry, GetThreadTimes, GetThreadUILanguage, GetTickCount, GetTickCount64, GetTimeFormatA, GetTimeFormatEx, GetTimeFormatW, GetTimeZoneInformation, GetTimeZoneInformationForYear, GetUILanguageInfo, GetUmsCompletionListEvent, GetUmsSystemThreadInformation, GetUserDefaultGeoName, GetUserDefaultLangID, GetUserDefaultLCID, GetUserDefaultLocaleName, GetUserDefaultUILanguage, GetUserGeoID, GetUserPreferredUILanguages, GetVersion, GetVersionExA, GetVersionExW, GetVolumeInformationA, GetVolumeInformationByHandleW, GetVolumeInformationW, GetVolumeNameForVolumeMountPointA, GetVolumeNameForVolumeMountPointW, GetVolumePathNameA, GetVolumePathNamesForVolumeNameA, GetVolumePathNamesForVolumeNameW, GetVolumePathNameW, GetWindowsDirectoryA, GetWindowsDirectoryW, GetWriteWatch, GetWsChanges, GetWsChangesExA, GetWsChangesExW, GetXStateFeaturesMask, GlobalAddAtomA, GlobalAddAtomExA, GlobalAddAtomExW, GlobalAddAtomW, GlobalAlloc, GlobalDeleteAtom, GlobalFindAtomA, GlobalFindAtomW, GlobalFlags, GlobalFree, GlobalGetAtomNameA, GlobalGetAtomNameW, GlobalHandle, GlobalLock, GlobalMemoryStatus, GlobalMemoryStatusEx, GlobalReAlloc, GlobalSize, GlobalUnlock, Heap32First, Heap32ListFirst, Heap32ListNext, Heap32Next, HeapAlloc, HeapCompact, HeapCreate, HeapDestroy, HeapFree, HeapLock, HeapQueryInformation, HeapReAlloc, HeapSetInformation, HeapSize, HeapSummary, HeapUnlock, HeapValidate, HeapWalk, IdnToAscii, IdnToNameprepUnicode, IdnToUnicode, InitAtomTable, InitializeConditionVariable, InitializeContext, InitializeCriticalSection, InitializeCriticalSectionAndSpinCount, InitializeCriticalSectionEx, InitializeEnclave, InitializeProcessForWsWatchA, InitializeProcessForWsWatchW, InitializeProcThreadAttributeList, InitializeSListHead, InitializeSRWLock, InitializeSynchronizationBarrier, InitOnceBeginInitialize, InitOnceComplete, InitOnceExecuteOnce, InitOnceInitialize, InstallELAMCertificateInfo, InterlockedCompareExchange, InterlockedDecrement, InterlockedExchange, InterlockedExchangeAdd, InterlockedFlushSList, InterlockedIncrement, InterlockedPopEntrySList, InterlockedPushEntrySList, InterlockedPushListSList, InterlockedPushListSListEx, IsBadCodePtr, IsBadReadPtr, IsBadStringPtrA, IsBadStringPtrW, IsBadWritePtr, IsDBCSLeadByte, IsDBCSLeadByteEx, IsDebuggerPresent, IsEnclaveTypeSupported, IsNativeVhdBoot, IsNLSDefinedString, IsNormalizedString, IsProcessCritical, IsProcessInJob, IsProcessorFeaturePresent, IsSystemResumeAutomatic, IsThreadAFiber, IsThreadpoolTimerSet, IsValidCodePage, IsValidLanguageGroup, IsValidLocale, IsValidLocaleName, IsValidNLSVersion, IsWow64GuestMachineSupported, IsWow64Process, IsWow64Process2, LCIDToLocaleName, LCMapStringA, LCMapStringEx, LCMapStringW, LeaveCriticalSection, LeaveCriticalSectionWhenCallbackReturns, LoadEnclaveData, LoadEnclaveImageA, LoadEnclaveImageW, LoadLibraryA, LoadLibraryExA, LoadLibraryExW, LoadLibraryW, LoadModule, LoadPackagedLibrary, LoadResource, LoadStringByReference, LocalAlloc, LocaleNameToLCID, LocalFileTimeToFileTime, LocalFlags, LocalFree, LocalHandle, LocalLock, LocalReAlloc, LocalSize, LocalUnlock, LocateXStateFeature, LockFile, LockFileEx, LockResource, lstrcmpA, lstrcmpiA, lstrcmpiW, lstrcmpW, lstrcpynA, lstrcpynW, lstrlenA, lstrlenW, MapUserPhysicalPages, MapUserPhysicalPagesScatter, MapViewOfFile, MapViewOfFileEx, MapViewOfFileExNuma, MapViewOfFileFromApp, MapViewOfFileNuma2, Module32First, Module32NextA, Module32NextW, MoveFileA, MoveFileExA, MoveFileExW, MoveFileTransactedA, MoveFileTransactedW, MoveFileW, MoveFileWithProgressA, MoveFileWithProgressW, MulDiv, MultiByteToWideChar, NeedCurrentDirectoryForExePathA, NeedCurrentDirectoryForExePathW, NormalizeString, OfferVirtualMemory, OpenCommPort, OpenEventA, OpenEventW, OpenFile, OpenFileById, OpenFileMappingA, OpenFileMappingFromApp, OpenFileMappingW, OpenJobObjectA, OpenJobObjectW, OpenMutexA, OpenMutexW, OpenPackageInfoByFullName, OpenPrivateNamespaceA, OpenPrivateNamespaceW, OpenProcess, OpenSemaphoreA, OpenSemaphoreW, OpenThread, OpenWaitableTimerA, OpenWaitableTimerW, OutputDebugStringA, OutputDebugStringW, PackageFamilyNameFromFullName, PackageFamilyNameFromId, PackageFullNameFromId, PackageIdFromFullName, PackageNameAndPublisherIdFromFamilyName, ParseApplicationUserModelId, PathAllocCanonicalize, PathAllocCombine, PathCchAddBackslash, PathCchAddBackslashEx, PathCchAddExtension, PathCchAppend, PathCchAppendEx, PathCchCanonicalize, PathCchCanonicalizeEx, PathCchCombine, PathCchCombineEx, PathCchFindExtension, PathCchIsRoot, PathCchRemoveBackslash, PathCchRemoveBackslashEx, PathCchRemoveExtension, PathCchRemoveFileSpec, PathCchRenameExtension, PathCchSkipRoot, PathCchStripPrefix, PathCchStripToRoot, PathIsUNCEx, PeekConsoleInputA, PeekConsoleInputW, PeekNamedPipe, PostQueuedCompletionStatus, PowerClearRequest, PowerCreateRequest, PowerSetRequest, PrefetchVirtualMemory, PrepareTape, Process32FirstA, Process32FirstW, Process32NextA, Process32NextW, ProcessIdToSessionId, PssCaptureSnapshot, PssDuplicateSnapshot, PssFreeSnapshot, PssQuerySnapshot, PssWalkMarkerCreate, PssWalkMarkerFree, PssWalkMarkerGetPosition, PssWalkMarkerSeekToBeginning, PssWalkMarkerSetPosition, PssWalkSnapshot, PulseEvent, PurgeComm, QueryActCtxSettingsW, QueryActCtxW, QueryAuxiliaryCounterFrequency, QueryDepthSList, QueryDosDeviceA, QueryDosDeviceW, QueryFullProcessImageNameA, QueryFullProcessImageNameW, QueryIdleProcessorCycleTime, QueryIdleProcessorCycleTimeEx, QueryInformationJobObject, QueryInterruptTime, QueryInterruptTimePrecise, QueryIoRateControlInformationJobObject, QueryMemoryResourceNotification, QueryOptionalDelayLoadedAPI, QueryPerformanceCounter, QueryPerformanceFrequency, QueryProcessAffinityUpdateMode, QueryProcessCycleTime, QueryProtectedPolicy, QueryThreadCycleTime, QueryThreadpoolStackInformation, QueryThreadProfiling, QueryUmsThreadInformation, QueryUnbiasedInterruptTime, QueryUnbiasedInterruptTimePrecise, QueryVirtualMemoryInformation, QueryWorkingSet, QueryWorkingSetEx, QueueUserAPC, QueueUserWorkItem, RaiseException, RaiseFailFastException, ReadConsoleA, ReadConsoleInputA, ReadConsoleInputW, ReadConsoleOutputA, ReadConsoleOutputAttribute, ReadConsoleOutputCharacterA, ReadConsoleOutputCharacterW, ReadConsoleOutputW, ReadConsoleW, ReadDirectoryChangesExW, ReadDirectoryChangesW, ReadFile, ReadFileEx, ReadFileScatter, ReadProcessMemory, ReadThreadProfilingData, ReclaimVirtualMemory, RegisterApplicationRecoveryCallback, RegisterApplicationRestart, RegisterBadMemoryNotification, RegisterWaitForSingleObject, ReleaseActCtx, ReleaseMutex, ReleaseMutexWhenCallbackReturns, ReleaseSemaphore, ReleaseSemaphoreWhenCallbackReturns, ReleaseSRWLockExclusive, ReleaseSRWLockShared, RemoveDirectoryA, RemoveDirectoryTransactedA, RemoveDirectoryTransactedW, RemoveDirectoryW, RemoveDllDirectory, RemoveSecureMemoryCacheCallback, RemoveVectoredContinueHandler, RemoveVectoredExceptionHandler, ReOpenFile, ReplaceFileA, ReplaceFileW, RequestWakeupLatency, ResetEvent, ResetWriteWatch, ResolveLocaleName, RestoreLastError, ResumeThread, RtlAddFunctionTable, RtlCaptureContext, RtlDeleteFunctionTable, RtlInstallFunctionTableCallback, RtlLookupFunctionEntry, RtlMoveMemory, RtlPcToFileHeader, RtlRestoreContext, RtlUnwind, RtlUnwindEx, RtlZeroMemory, ScrollConsoleScreenBufferA, ScrollConsoleScreenBufferW, SearchPathA, SearchPathW, SetCalendarInfoA, SetCalendarInfoW, SetCommBreak, SetCommConfig, SetCommMask, SetCommState, SetCommTimeouts, SetComputerNameA, SetComputerNameEx2W, SetComputerNameExA, SetComputerNameExW, SetComputerNameW, SetConsoleActiveScreenBuffer, SetConsoleCP, SetConsoleCtrlHandler, SetConsoleCursorInfo, SetConsoleCursorPosition, SetConsoleDisplayMode, SetConsoleHistoryInfo, SetConsoleMode, SetConsoleOutputCP, SetConsoleScreenBufferInfoEx, SetConsoleScreenBufferSize, SetConsoleTextAttribute, SetConsoleTitleA, SetConsoleTitleW, SetConsoleWindowInfo, SetCriticalSectionSpinCount, SetCurrentConsoleFontEx, SetCurrentDirectoryA, SetCurrentDirectoryW, SetDefaultCommConfigA, SetDefaultCommConfigW, SetDefaultDllDirectories, SetDllDirectoryA, SetDllDirectoryW, SetDynamicTimeZoneInformation, SetEndOfFile, SetEnvironmentStringsW, SetEnvironmentVariableA, SetEnvironmentVariableW, SetErrorMode, SetEvent, SetEventWhenCallbackReturns, SetFileApisToANSI, SetFileApisToOEM, SetFileAttributesA, SetFileAttributesTransactedA, SetFileAttributesTransactedW, SetFileAttributesW, SetFileBandwidthReservation, SetFileCompletionNotificationModes, SetFileInformationByHandle, SetFileIoOverlappedRange, SetFilePointer, SetFilePointerEx, SetFileShortNameA, SetFileShortNameW, SetFileTime, SetFileValidData, SetFirmwareEnvironmentVariableA, SetFirmwareEnvironmentVariableExA, SetFirmwareEnvironmentVariableExW, SetFirmwareEnvironmentVariableW, SetHandleInformation, SetInformationJobObject, SetIoRateControlInformationJobObject, SetLastError, SetLocaleInfoA, SetLocaleInfoW, SetLocalTime, SetMailslotInfo, SetNamedPipeHandleState, SetPriorityClass, SetProcessAffinityMask, SetProcessAffinityUpdateMode, SetProcessDefaultCpuSets, SetProcessDEPPolicy, SetProcessInformation, SetProcessMitigationPolicy, SetProcessPreferredUILanguages, SetProcessPriorityBoost, SetProcessShutdownParameters, SetProcessValidCallTargets, SetProcessWorkingSetSize, SetProcessWorkingSetSizeEx, SetProtectedPolicy, SetSearchPathMode, SetStdHandle, SetStdHandleEx, SetSystemFileCacheSize, SetSystemPowerState, SetSystemTime, SetSystemTimeAdjustment, SetTapeParameters, SetTapePosition, SetThreadAffinityMask, SetThreadContext, SetThreadDescription, SetThreadErrorMode, SetThreadExecutionState, SetThreadGroupAffinity, SetThreadIdealProcessor, SetThreadIdealProcessorEx, SetThreadInformation, SetThreadLocale, SetThreadpoolStackInformation, SetThreadpoolThreadMaximum, SetThreadpoolThreadMinimum, SetThreadpoolTimer, SetThreadpoolTimerEx, SetThreadpoolWait, SetThreadpoolWaitEx, SetThreadPreferredUILanguages, SetThreadPriority, SetThreadPriorityBoost, SetThreadSelectedCpuSets, SetThreadStackGuarantee, SetThreadUILanguage, SetTimeZoneInformation, SetUmsThreadInformation, SetUnhandledExceptionFilter, SetupComm, SetUserGeoID, SetUserGeoName, SetVolumeLabelA, SetVolumeLabelW, SetVolumeMountPointA, SetVolumeMountPointW, SetWaitableTimer, SetWaitableTimerEx, SetXStateFeaturesMask, SignalObjectAndWait, SizeofResource, Sleep, SleepConditionVariableCS, SleepConditionVariableSRW, SleepEx, StartThreadpoolIo, SubmitThreadpoolWork, SuspendThread, SwitchToFiber, SwitchToThread, SystemTimeToFileTime, SystemTimeToTzSpecificLocalTime, SystemTimeToTzSpecificLocalTimeEx, TerminateEnclave, TerminateJobObject, TerminateProcess, TerminateProcessOnMemoryExhaustion, TerminateThread, TermsrvAppInstallMode, Thread32First, Thread32Next, TlsAlloc, TlsFree, TlsGetValue, TlsSetValue, Toolhelp32ReadProcessMemory, TransactNamedPipe, TransmitCommChar, TryAcquireSRWLockExclusive, TryAcquireSRWLockShared, TryEnterCriticalSection, TrySubmitThreadpoolCallback, TzSpecificLocalTimeToSystemTime, TzSpecificLocalTimeToSystemTimeEx, UmsThreadYield, UnhandledExceptionFilter, UnlockFile, UnlockFileEx, UnmapViewOfFile, UnmapViewOfFile2, UnmapViewOfFileEx, UnregisterApplicationRecoveryCallback, UnregisterApplicationRestart, UnregisterBadMemoryNotification, UnregisterWait, UnregisterWaitEx, UpdateCalendarDayOfWeek, UpdateProcThreadAttribute, UpdateResourceA, UpdateResourceW, UserHandleGrantAccess, VerifyScripts, VerifyVersionInfoA, VerifyVersionInfoW, VerSetConditionMask, VirtualAlloc, VirtualAllocEx, VirtualAllocExNuma, VirtualAllocFromApp, VirtualFree, VirtualFreeEx, VirtualLock, VirtualProtect, VirtualProtectEx, VirtualProtectFromApp, VirtualQuery, VirtualQueryEx, VirtualUnlock, WaitCommEvent, WaitForDebugEvent, WaitForDebugEventEx, WaitForMultipleObjects, WaitForMultipleObjectsEx, WaitForSingleObject, WaitForSingleObjectEx, WaitForThreadpoolIoCallbacks, WaitForThreadpoolTimerCallbacks, WaitForThreadpoolWaitCallbacks, WaitForThreadpoolWorkCallbacks, WaitNamedPipeA, WaitNamedPipeW, WaitOnAddress, WakeAllConditionVariable, WakeByAddressAll, WakeByAddressSingle, WakeConditionVariable, WerGetFlags, WerRegisterAdditionalProcess, WerRegisterAppLocalDump, WerRegisterCustomMetadata, WerRegisterExcludedMemoryBlock, WerRegisterFile, WerRegisterMemoryBlock, WerRegisterRuntimeExceptionModule, WerSetFlags, WerUnregisterAdditionalProcess, WerUnregisterAppLocalDump, WerUnregisterCustomMetadata, WerUnregisterExcludedMemoryBlock, WerUnregisterFile, WerUnregisterMemoryBlock, WerUnregisterRuntimeExceptionModule, WideCharToMultiByte, WinExec, Wow64DisableWow64FsRedirection, Wow64EnableWow64FsRedirection, Wow64GetThreadContext, Wow64GetThreadSelectorEntry, Wow64RevertWow64FsRedirection, Wow64SetThreadContext, Wow64SetThreadDefaultGuestMachine, Wow64SuspendThread, WriteConsoleA, WriteConsoleInputA, WriteConsoleInputW, WriteConsoleOutputA, WriteConsoleOutputAttribute, WriteConsoleOutputCharacterA, WriteConsoleOutputCharacterW, WriteConsoleOutputW, WriteConsoleW, WriteFile, WriteFileEx, WriteFileGather, WritePrivateProfileSectionA, WritePrivateProfileSectionW, WritePrivateProfileStringA, WritePrivateProfileStringW, WritePrivateProfileStructA, WritePrivateProfileStructW, WriteProcessMemory, WriteProfileSectionA, WriteProfileSectionW, WriteProfileStringA, WriteProfileStringW, WriteTapemark, WTSGetActiveConsoleSessionId, ZombifyActCtx Structures -PACKAGE_ID, PACKAGE_INFO_REFERENCE, PACKAGE_VERSION, ENCLAVE_CREATE_INFO_SGX, ENCLAVE_CREATE_INFO_VBS, ENCLAVE_INIT_INFO_SGX, ENCLAVE_INIT_INFO_VBS, EXCEPTION_POINTERS, EXCEPTION_RECORD, BY_HANDLE_FILE_INFORMATION, GAMING_DEVICE_MODEL_INFORMATION, HEAP_OPTIMIZE_RESOURCES_INFORMATION, HEAP_SUMMARY, SLIST_ENTRY, HJOB, IO_COUNTERS, JOBOBJECT_ASSOCIATE_COMPLETION_PORT, JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, JOBOBJECT_BASIC_LIMIT_INFORMATION, JOBOBJECT_BASIC_PROCESS_ID_LIST, JOBOBJECT_BASIC_UI_RESTRICTIONS, JOBOBJECT_CPU_RATE_CONTROL_INFORMATION, JOBOBJECT_END_OF_JOB_TIME_INFORMATION, JOBOBJECT_EXTENDED_LIMIT_INFORMATION, JOBOBJECT_IO_ATTRIBUTION_INFORMATION, JOBOBJECT_IO_ATTRIBUTION_STATS, JOBOBJECT_IO_RATE_CONTROL_INFORMATION, JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE, JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE_V2, JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE_V3, JOBOBJECT_JOBSET_INFORMATION, JOBOBJECT_LIMIT_VIOLATION_INFORMATION, JOBOBJECT_LIMIT_VIOLATION_INFORMATION_2, JOBOBJECT_NET_RATE_CONTROL_INFORMATION, JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION, JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION_2, JOBOBJECT_SECURITY_LIMIT_INFORMATION, CFG_CALL_TARGET_INFO, WIN32_MEMORY_RANGE_ENTRY, NamespaceHandle, MEMORY_BASIC_INFORMATION, PSS_ALLOCATOR, PSS_AUXILIARY_PAGE_ENTRY, PSS_AUXILIARY_PAGES_INFORMATION, PSS_HANDLE_ENTRY, PSS_HANDLE_INFORMATION, PSS_HANDLE_TRACE_INFORMATION, PSS_PERFORMANCE_COUNTERS, PSS_PROCESS_INFORMATION, PSS_THREAD_ENTRY, PSS_THREAD_INFORMATION, PSS_VA_CLONE_INFORMATION, PSS_VA_SPACE_ENTRY, PSS_VA_SPACE_INFORMATION, APP_MEMORY_INFORMATION, CONTEXT, CONTEXT64, MEMORY_PRIORITY_INFORMATION, PROCESS_MEMORY_EXHAUSTION_INFO, PROCESS_MITIGATION_ASLR_POLICY, PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY, PROCESS_MITIGATION_CHILD_PROCESS_POLICY, PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY, PROCESS_MITIGATION_DEP_POLICY, PROCESS_MITIGATION_DYNAMIC_CODE_POLICY, PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY, PROCESS_MITIGATION_FONT_DISABLE_POLICY, PROCESS_MITIGATION_IMAGE_LOAD_POLICY, PROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY, PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY, PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY, PROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY, PROCESS_POWER_THROTTLING_STATE, PROCESS_PROTECTION_LEVEL_INFORMATION, PROCESSOR_NUMBER, STARTUPINFO, STARTUPINFOEX, SYSTEM_CPU_SET_INFORMATION, SYSTEM_CPU_SET_INFORMATION1, THREAD_POWER_THROTTLING_STATE, ENUM_PAGE_FILE_INFORMATION, MODULEINFO, PERFORMANCE_INFORMATION, PROCESS_MEMORY_COUNTERS, PSAPI_WS_WATCH_INFORMATION, PSAPI_WS_WATCH_INFORMATION_EX, CONDITION_VARIABLE, CRITICAL_SECTION, INIT_ONCE, REASON_CONTEXT, SRWLOCK, SYNCHRONIZATION_BARRIER, CACHE_DESCRIPTOR, CACHE_RELATIONSHIP, GROUP_RELATIONSHIP, MEMORYSTATUS, MEMORYSTATUSEX, NUMA_NODE_RELATIONSHIP, OSVERSIONINFOEX, PROCESSOR_GROUP_INFO, PROCESSOR_RELATIONSHIP, SYSTEM_INFO, SYSTEM_LOGICAL_PROCESSOR_INFORMATION, SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION, GROUP_AFFINITY, PTP_CALLBACK_INSTANCE, PTP_CLEANUP_GROUP, PTP_IO, PTP_POOL, PTP_TIMER, PTP_WAIT, PTP_WORK, TP_POOL_STACK_INFORMATION, DYNAMIC_TIME_ZONE_INFORMATION, TIME_ZONE_INFORMATION, HEAPENTRY32, HEAPLIST32, PROCESSENTRY32, THREADENTRY32, ACTCTX_SECTION_KEYED_DATA, HACTCTX, TAPE_GET_DRIVE_PARAMETERS, TAPE_GET_MEDIA_PARAMETERS, COMMCONFIG, COMMPROP, COMMTIMEOUTS, COMSTAT, DCB, COPYFILE2_EXTENDED_PARAMETERS, COPYFILE2_MESSAGE, PerformanceDataHandle, UMS_SCHEDULER_STARTUP_INFO, UMS_SYSTEM_THREAD_INFORMATION, LDT_ENTRY, FILE_ALIGNMENT_INFO, FILE_ALLOCATION_INFO, FILE_ATTRIBUTE_TAG_INFO, FILE_BASIC_INFO, FILE_COMPRESSION_INFO, FILE_DISPOSITION_INFO, FILE_END_OF_FILE_INFO, FILE_FULL_DIR_INFO, FILE_ID_128, FILE_ID_BOTH_DIR_INFO, FILE_ID_EXTD_DIR_INFO, FILE_ID_INFO, FILE_IO_PRIORITY_HINT_INFO, FILE_NAME_INFO, FILE_STANDARD_INFO, FILE_STORAGE_INFO, FILE_STREAM_INFO, OFSTRUCT, WIN32_FILE_ATTRIBUTE_DATA, WIN32_FIND_STREAM_DATA, SYSTEM_POWER_STATUS, CHAR_INFO, CONSOLE_CURSOR_INFO, CONSOLE_FONT_INFO, CONSOLE_FONT_INFOEX, CONSOLE_HISTORY_INFO, CONSOLE_SCREEN_BUFFER_INFO, CONSOLE_SCREEN_BUFFER_INFOEX, CONSOLE_SELECTION_INFO, COORD, ENCODING_INFO, FOCUS_EVENT_RECORD, INPUT_RECORD, KEY_EVENT_RECORD, MENU_EVENT_RECORD, MOUSE_EVENT_RECORD, SMALL_RECT, WINDOW_BUFFER_SIZE_RECORD, CALDATETIME, CPINFO, CPINFOEX, CURRENCYFMT, FILEMUIINFO, NLSVERSIONINFO, NLSVERSIONINFOEX, NUMBERFMT, HARDWARE_COUNTER_DATA, PERFORMANCE_DATA, WOW64_CONTEXT, WOW64_FLOATING_SAVE_AREA, WOW64_LDT_ENTRY, DUMMYSTRUCTNAME, CPU_RATE_CONTROL_UNION, UNION, Process, Thread, Mutant, Event, Section, Semaphore, FLOATING_SAVE_AREA, M128A, XSAVE_FORMAT64, SYSTEM_CPU_UNION, DETAIL, ProcessorRelationUnion, ProcessorRelationUnion, Union, ChunkStarted, ChunkFinished, StreamStarted, StreamFinished, PollContinue, Error, GenericReserved_, ProtocolSpecificReserved_, Server, Share, INPUT_RECORD_EVENT, EXCEPTION_DEBUG_INFO, EXIT_PROCESS_DEBUG_INFO, EXIT_THREAD_DEBUG_INFO, UNLOAD_DLL_DEBUG_INFO, OUTPUT_DEBUG_STRING_INFO, RIP_INFO, BLOCK_DATA, REGION_DATA +PACKAGE_ID, PACKAGE_INFO_REFERENCE, PACKAGE_VERSION, ENCLAVE_CREATE_INFO_SGX, ENCLAVE_CREATE_INFO_VBS, ENCLAVE_INIT_INFO_SGX, ENCLAVE_INIT_INFO_VBS, EXCEPTION_POINTERS, EXCEPTION_RECORD, BY_HANDLE_FILE_INFORMATION, CREATEFILE2_EXTENDED_PARAMETERS, GAMING_DEVICE_MODEL_INFORMATION, HEAP_OPTIMIZE_RESOURCES_INFORMATION, HEAP_SUMMARY, SLIST_ENTRY, HJOB, IO_COUNTERS, JOBOBJECT_ASSOCIATE_COMPLETION_PORT, JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, JOBOBJECT_BASIC_LIMIT_INFORMATION, JOBOBJECT_BASIC_PROCESS_ID_LIST, JOBOBJECT_BASIC_UI_RESTRICTIONS, JOBOBJECT_CPU_RATE_CONTROL_INFORMATION, JOBOBJECT_END_OF_JOB_TIME_INFORMATION, JOBOBJECT_EXTENDED_LIMIT_INFORMATION, JOBOBJECT_IO_ATTRIBUTION_INFORMATION, JOBOBJECT_IO_ATTRIBUTION_STATS, JOBOBJECT_IO_RATE_CONTROL_INFORMATION, JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE, JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE_V2, JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE_V3, JOBOBJECT_JOBSET_INFORMATION, JOBOBJECT_LIMIT_VIOLATION_INFORMATION, JOBOBJECT_LIMIT_VIOLATION_INFORMATION_2, JOBOBJECT_NET_RATE_CONTROL_INFORMATION, JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION, JOBOBJECT_NOTIFICATION_LIMIT_INFORMATION_2, JOBOBJECT_SECURITY_LIMIT_INFORMATION, CFG_CALL_TARGET_INFO, WIN32_MEMORY_RANGE_ENTRY, BoundaryDescriptorHandle, NamespaceHandle, MEMORY_BASIC_INFORMATION, PSS_ALLOCATOR, PSS_AUXILIARY_PAGE_ENTRY, PSS_AUXILIARY_PAGES_INFORMATION, PSS_HANDLE_ENTRY, PSS_HANDLE_INFORMATION, PSS_HANDLE_TRACE_INFORMATION, PSS_PERFORMANCE_COUNTERS, PSS_PROCESS_INFORMATION, PSS_THREAD_ENTRY, PSS_THREAD_INFORMATION, PSS_VA_CLONE_INFORMATION, PSS_VA_SPACE_ENTRY, PSS_VA_SPACE_INFORMATION, APP_MEMORY_INFORMATION, CONTEXT, CONTEXT64, MEMORY_PRIORITY_INFORMATION, PROCESS_MEMORY_EXHAUSTION_INFO, PROCESS_MITIGATION_ASLR_POLICY, PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY, PROCESS_MITIGATION_CHILD_PROCESS_POLICY, PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY, PROCESS_MITIGATION_DEP_POLICY, PROCESS_MITIGATION_DYNAMIC_CODE_POLICY, PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY, PROCESS_MITIGATION_FONT_DISABLE_POLICY, PROCESS_MITIGATION_IMAGE_LOAD_POLICY, PROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY, PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY, PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY, PROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY, PROCESS_POWER_THROTTLING_STATE, PROCESS_PROTECTION_LEVEL_INFORMATION, PROCESSOR_NUMBER, STARTUPINFO, STARTUPINFOEX, SYSTEM_CPU_SET_INFORMATION, SYSTEM_CPU_SET_INFORMATION1, THREAD_POWER_THROTTLING_STATE, ENUM_PAGE_FILE_INFORMATION, MODULEINFO, PERFORMANCE_INFORMATION, PROCESS_MEMORY_COUNTERS, PSAPI_WS_WATCH_INFORMATION, PSAPI_WS_WATCH_INFORMATION_EX, CONDITION_VARIABLE, CRITICAL_SECTION, INIT_ONCE, REASON_CONTEXT, SRWLOCK, SYNCHRONIZATION_BARRIER, CACHE_DESCRIPTOR, CACHE_RELATIONSHIP, GROUP_RELATIONSHIP, MEMORYSTATUS, MEMORYSTATUSEX, NUMA_NODE_RELATIONSHIP, OSVERSIONINFOEX, PROCESSOR_GROUP_INFO, PROCESSOR_RELATIONSHIP, SYSTEM_INFO, SYSTEM_LOGICAL_PROCESSOR_INFORMATION, SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION, GROUP_AFFINITY, PTP_CALLBACK_INSTANCE, PTP_CLEANUP_GROUP, PTP_IO, PTP_POOL, PTP_TIMER, PTP_WAIT, PTP_WORK, TP_POOL_STACK_INFORMATION, PTP_CALLBACK_ENVIRON, TimerQueueHandle, TimerQueueTimerHandle, DYNAMIC_TIME_ZONE_INFORMATION, TIME_ZONE_INFORMATION, HEAPENTRY32, HEAPLIST32, HSNAPSHOT, MODULEENTRY32, PROCESSENTRY32, THREADENTRY32, ACTCTX, ACTCTX_SECTION_KEYED_DATA, HACTCTX, TAPE_GET_DRIVE_PARAMETERS, TAPE_GET_MEDIA_PARAMETERS, COMMCONFIG, COMMPROP, COMMTIMEOUTS, COMSTAT, DCB, COPYFILE2_EXTENDED_PARAMETERS, COPYFILE2_MESSAGE, PerformanceDataHandle, UMS_SCHEDULER_STARTUP_INFO, UMS_SYSTEM_THREAD_INFORMATION, LDT_ENTRY, FILE_ALIGNMENT_INFO, FILE_ALLOCATION_INFO, FILE_ATTRIBUTE_TAG_INFO, FILE_BASIC_INFO, FILE_COMPRESSION_INFO, FILE_DISPOSITION_INFO, FILE_END_OF_FILE_INFO, FILE_FULL_DIR_INFO, FILE_ID_128, FILE_ID_BOTH_DIR_INFO, FILE_ID_EXTD_DIR_INFO, FILE_ID_INFO, FILE_IO_PRIORITY_HINT_INFO, FILE_NAME_INFO, FILE_RENAME_INFO, FILE_STANDARD_INFO, FILE_STORAGE_INFO, FILE_STREAM_INFO, OFSTRUCT, WIN32_FILE_ATTRIBUTE_DATA, WIN32_FIND_STREAM_DATA, HGLOBAL, HLOCAL, SYSTEM_POWER_STATUS, UpdateResourceHandle, CHAR_INFO, CONSOLE_CURSOR_INFO, CONSOLE_FONT_INFO, CONSOLE_FONT_INFOEX, CONSOLE_HISTORY_INFO, CONSOLE_SCREEN_BUFFER_INFO, CONSOLE_SCREEN_BUFFER_INFOEX, CONSOLE_SELECTION_INFO, COORD, ENCODING_INFO, FOCUS_EVENT_RECORD, INPUT_RECORD, KEY_EVENT_RECORD, MENU_EVENT_RECORD, MOUSE_EVENT_RECORD, SMALL_RECT, WINDOW_BUFFER_SIZE_RECORD, CALDATETIME, CPINFO, CPINFOEX, CURRENCYFMT, FILEMUIINFO, NLSVERSIONINFO, NLSVERSIONINFOEX, NUMBERFMT, HARDWARE_COUNTER_DATA, PERFORMANCE_DATA, WOW64_CONTEXT, WOW64_FLOATING_SAVE_AREA, WOW64_LDT_ENTRY, DUMMYSTRUCTNAME, CPU_RATE_CONTROL_UNION, UNION, Process, Thread, Mutant, Event, Section, Semaphore, FLOATING_SAVE_AREA, M128A, XSAVE_FORMAT64, SYSTEM_CPU_UNION, DETAIL, ProcessorRelationUnion, ProcessorRelationUnion, Union, ChunkStarted, ChunkFinished, StreamStarted, StreamFinished, PollContinue, Error, GenericReserved_, ProtocolSpecificReserved_, Server, Share, INPUT_RECORD_EVENT, EXCEPTION_DEBUG_INFO, CREATE_THREAD_DEBUG_INFO, CREATE_PROCESS_DEBUG_INFO, EXIT_PROCESS_DEBUG_INFO, EXIT_THREAD_DEBUG_INFO, LOAD_DLL_DEBUG_INFO, UNLOAD_DLL_DEBUG_INFO, OUTPUT_DEBUG_STRING_INFO, RIP_INFO, BLOCK_DATA, REGION_DATA latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/Mpr/CorrelationReport.md b/PInvoke/Mpr/CorrelationReport.md index 1880100b..d46fc8ad 100644 --- a/PInvoke/Mpr/CorrelationReport.md +++ b/PInvoke/Mpr/CorrelationReport.md @@ -27,6 +27,8 @@ Native Method | Native DLL | Header | Managed Method ### Structures Native Structure | Header | Managed Structure --- | --- | --- +[CONNECTDLGSTRUCT](http://msdn2.microsoft.com/en-us/library/aa385332) | Winnetwk.h | Vanara.PInvoke.Mpr+CONNECTDLGSTRUCT +[DISCDLGSTRUCT](http://msdn2.microsoft.com/en-us/library/aa385339) | Winnetwk.h | Vanara.PInvoke.Mpr+DISCDLGSTRUCT [NETCONNECTINFOSTRUCT](http://msdn2.microsoft.com/en-us/library/aa385345) | Winnetwk.h | Vanara.PInvoke.Mpr+NETCONNECTINFOSTRUCT [NETINFOSTRUCT](http://msdn2.microsoft.com/en-us/library/aa385349) | Winnetwk.h | Vanara.PInvoke.Mpr+NETINFOSTRUCT [NETRESOURCE](http://msdn2.microsoft.com/en-us/library/aa385353) | Winnetwk.h | Vanara.PInvoke.Mpr+NETRESOURCE diff --git a/PInvoke/Mpr/Vanara.PInvoke.Mpr.csproj b/PInvoke/Mpr/Vanara.PInvoke.Mpr.csproj index af1cd88f..c7d2e1c5 100644 --- a/PInvoke/Mpr/Vanara.PInvoke.Mpr.csproj +++ b/PInvoke/Mpr/Vanara.PInvoke.Mpr.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from Mpr.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.Mpr $(AssemblyName) @@ -28,10 +28,12 @@ Functions MultinetGetConnectionPerformanceA, MultinetGetConnectionPerformanceW, WNetAddConnection2A, WNetAddConnection2W, WNetAddConnection3A, WNetAddConnection3W, WNetAddConnectionA, WNetAddConnectionW, WNetCancelConnection2A, WNetCancelConnection2W, WNetCloseEnum, WNetConnectionDialog, WNetConnectionDialog1A, WNetConnectionDialog1W, WNetDisconnectDialog, WNetDisconnectDialog1A, WNetDisconnectDialog1W, WNetEnumResourceA, WNetEnumResourceW, WNetGetConnectionA, WNetGetConnectionW, WNetGetLastErrorA, WNetGetLastErrorW, WNetGetNetworkInformationA, WNetGetNetworkInformationW, WNetGetProviderNameA, WNetGetProviderNameW, WNetGetResourceInformationA, WNetGetResourceInformationW, WNetGetResourceParentA, WNetGetResourceParentW, WNetGetUniversalNameA, WNetGetUniversalNameW, WNetGetUserA, WNetGetUserW, WNetOpenEnumA, WNetOpenEnumW, WNetSetLastErrorA, WNetSetLastErrorW, WNetUseConnectionA, WNetUseConnectionW Structures -NETCONNECTINFOSTRUCT, NETINFOSTRUCT, NETRESOURCE, REMOTE_NAME_INFO, UNIVERSAL_NAME_INFO +CONNECTDLGSTRUCT, DISCDLGSTRUCT, NETCONNECTINFOSTRUCT, NETINFOSTRUCT, NETRESOURCE, REMOTE_NAME_INFO, UNIVERSAL_NAME_INFO latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/NTDSApi/CorrelationReport.md b/PInvoke/NTDSApi/CorrelationReport.md index 98c7e21f..35af0683 100644 --- a/PInvoke/NTDSApi/CorrelationReport.md +++ b/PInvoke/NTDSApi/CorrelationReport.md @@ -1,11 +1,10 @@ ## Correlation report for ntdsapi.dll -### Methods (57% complete) +### Methods (100% complete) Native Method | Native DLL | Header | Managed Method --- | --- | --- | --- [DsAddSidHistory](http://msdn2.microsoft.com/en-us/library/36ef8734-717a-4c3a-a839-6591d85c9734) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsAddSidHistory [DsBind](http://msdn2.microsoft.com/en-us/library/ms675931) | ntdsapi.dll | NTDSApi.h | Vanara.PInvoke.NTDSApi.DsBind -[DsBindByInstanceA](https://www.google.com/search?num=5&q=DsBindByInstanceA+site%3Amicrosoft.com) | Ntdsapi.dll | | Vanara.PInvoke.NTDSApi.DsBindByInstance -[DsBindByInstanceW](https://www.google.com/search?num=5&q=DsBindByInstanceW+site%3Amicrosoft.com) | Ntdsapi.dll | | Vanara.PInvoke.NTDSApi.DsBindByInstance +[DsBindByInstance](http://msdn2.microsoft.com/en-us/library/65302ddc-2bc0-4d80-b028-e268859be227) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsBindByInstance [DsBindingSetTimeout](http://msdn2.microsoft.com/en-us/library/abdaae89-fba3-4949-92a9-acd62898ec24) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsBindingSetTimeout [DsBindToISTG](http://msdn2.microsoft.com/en-us/library/bd53124c-8578-495d-b540-d4b4c09297c3) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsBindToISTG [DsBindWithCred](http://msdn2.microsoft.com/en-us/library/ms675961) | ntdsapi.dll | NTDSApi.h | Vanara.PInvoke.NTDSApi.DsBindWithCred @@ -18,44 +17,86 @@ Native Method | Native DLL | Header | Managed Method [DsFreeDomainControllerInfo](http://msdn2.microsoft.com/en-us/library/1b6d3136-91e2-4653-a4b0-ae2f66a6c5a2) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsFreeDomainControllerInfo [DsFreeNameResult](http://msdn2.microsoft.com/en-us/library/ms675978) | ntdsapi.dll | NTDSApi.h | Vanara.PInvoke.NTDSApi.DsFreeNameResult [DsFreePasswordCredentials](http://msdn2.microsoft.com/en-us/library/ms675979) | ntdsapi.dll | NTDSApi.h | Vanara.PInvoke.NTDSApi.DsFreePasswordCredentials +[DsFreeSchemaGuidMap](http://msdn2.microsoft.com/en-us/library/54d6acb9-5602-4996-a483-08534143bc0a) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsFreeSchemaGuidMap [DsFreeSpnArray](http://msdn2.microsoft.com/en-us/library/1c229933-432d-4ded-be3b-3bd339a0abe4) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsFreeSpnArray [DsGetDomainControllerInfo](http://msdn2.microsoft.com/en-us/library/52db3b25-e6b0-4a0d-831b-89a203580cf1) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsGetDomainControllerInfo [DsGetRdnW](http://msdn2.microsoft.com/en-us/library/22627f2e-adfb-49de-bae5-20aaf69830ac) | ntdsapi.dll | dsparse.h | Vanara.PInvoke.NTDSApi.DsGetRdnW [DsGetSpn](http://msdn2.microsoft.com/en-us/library/cbd53850-9b05-4f74-ab07-30dcad583fc5) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsGetSpn +[DsInheritSecurityIdentity](http://msdn2.microsoft.com/en-us/library/ea467069-f886-4e22-896c-16e6e01f3968) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsInheritSecurityIdentity [DsIsMangledDn](http://msdn2.microsoft.com/en-us/library/e4aaa83c-3bd6-48db-9d34-367b76ba629c) | ntdsapi.dll | dsparse.h | Vanara.PInvoke.NTDSApi.DsIsMangledDn [DsIsMangledRdnValue](http://msdn2.microsoft.com/en-us/library/adf5e133-9e48-4e97-af0c-4f8ea9b8bf8f) | ntdsapi.dll | dsparse.h | Vanara.PInvoke.NTDSApi.DsIsMangledRdnValue -[DsListDomainsInSite](https://www.google.com/search?num=5&q=DsListDomainsInSiteA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsListRoles](https://www.google.com/search?num=5&q=DsListRolesA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsListServersForDomainInSite](https://www.google.com/search?num=5&q=DsListServersForDomainInSiteA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsListServersInSite](https://www.google.com/search?num=5&q=DsListServersInSiteA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsListSites](https://www.google.com/search?num=5&q=DsListSitesA+site%3Amicrosoft.com) | ntdsapi.dll | | +[DsListDomainsInSite](http://msdn2.microsoft.com/en-us/library/3a039c0c-ac5b-4455-960d-b26a207693ed) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsListDomainsInSite +[DsListInfoForServer](http://msdn2.microsoft.com/en-us/library/15dcc7ac-4edb-42fa-8466-033794762046) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsListInfoForServer +[DsListRoles](http://msdn2.microsoft.com/en-us/library/679a2dca-019b-4f6e-acd9-efb30e0d4b44) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsListRoles +[DsListServersForDomainInSite](http://msdn2.microsoft.com/en-us/library/1e346532-bbbe-4b3b-a1cb-6a72319cb3e2) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsListServersForDomainInSite +[DsListServersInSite](http://msdn2.microsoft.com/en-us/library/46773631-d464-4d9e-83e7-aa502599df71) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsListServersInSite +[DsListSites](http://msdn2.microsoft.com/en-us/library/d424e750-6700-42b8-9d4f-e430cd0a7e4e) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsListSites [DsMakePasswordCredentials](http://msdn2.microsoft.com/en-us/library/ms676006) | ntdsapi.dll | NTDSApi.h | Vanara.PInvoke.NTDSApi.DsMakePasswordCredentials [DsMakeSpn](http://msdn2.microsoft.com/en-us/library/fca3c59c-bb81-42a0-acd3-2e55c902febe) | ntdsapi.dll | dsparse.h | Vanara.PInvoke.NTDSApi.DsMakeSpn -[DsMapSchemaGuids](https://www.google.com/search?num=5&q=DsMapSchemaGuidsA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsQuerySitesByCost](https://www.google.com/search?num=5&q=DsQuerySitesByCostA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsQuerySitesFree](https://www.google.com/search?num=5&q=DsQuerySitesFree+site%3Amicrosoft.com) | ntdsapi.dll | | +[DsMapSchemaGuids](http://msdn2.microsoft.com/en-us/library/439fff20-51eb-490d-a330-61d07f79c436) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsMapSchemaGuids +[DsQuerySitesByCost](http://msdn2.microsoft.com/en-us/library/7a4cbd1c-8445-4882-8559-d44b6e5693e7) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsQuerySitesByCost +[DsQuerySitesFree](http://msdn2.microsoft.com/en-us/library/810caa4f-8275-4ad8-ad3e-72061fc073dd) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsQuerySitesFree [DsQuoteRdnValue](http://msdn2.microsoft.com/en-us/library/a1e8a4c0-965a-4061-aab3-3e719ec6374d) | ntdsapi.dll | dsparse.h | Vanara.PInvoke.NTDSApi.DsQuoteRdnValue -[DsRemoveDsDomain](https://www.google.com/search?num=5&q=DsRemoveDsDomainA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsRemoveDsServer](https://www.google.com/search?num=5&q=DsRemoveDsServerA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaConsistencyCheck](https://www.google.com/search?num=5&q=DsReplicaConsistencyCheck+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaDel](https://www.google.com/search?num=5&q=DsReplicaDelA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaFreeInfo](https://www.google.com/search?num=5&q=DsReplicaFreeInfo+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaGetInfo2W](https://www.google.com/search?num=5&q=DsReplicaGetInfo2W+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaGetInfoW](https://www.google.com/search?num=5&q=DsReplicaGetInfoW+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaModify](https://www.google.com/search?num=5&q=DsReplicaModifyA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaSync](https://www.google.com/search?num=5&q=DsReplicaSyncA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaSyncAll](https://www.google.com/search?num=5&q=DsReplicaSyncAllA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaUpdateRefs](https://www.google.com/search?num=5&q=DsReplicaUpdateRefsA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsReplicaVerifyObjects](https://www.google.com/search?num=5&q=DsReplicaVerifyObjectsA+site%3Amicrosoft.com) | ntdsapi.dll | | -[DsServerRegisterSpn](https://www.google.com/search?num=5&q=DsServerRegisterSpnA+site%3Amicrosoft.com) | ntdsapi.dll | | +[DsRemoveDsDomain](http://msdn2.microsoft.com/en-us/library/0639cc04-2821-4421-8aa7-363621c1d6b5) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsRemoveDsDomain +[DsRemoveDsServer](http://msdn2.microsoft.com/en-us/library/a79a2b71-10c7-495b-861f-0c7a4d86f720) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsRemoveDsServer +[DsReplicaAdd](http://msdn2.microsoft.com/en-us/library/33bd1b61-b9ed-479f-a128-fb7ddbb5e9af) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaAdd +[DsReplicaConsistencyCheck](http://msdn2.microsoft.com/en-us/library/2a83ffcb-1ebd-4024-a186-9c079896f4e1) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaConsistencyCheck +[DsReplicaDel](http://msdn2.microsoft.com/en-us/library/68c767c4-bbb6-477b-8ffb-94f3ae235375) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaDel +[DsReplicaFreeInfo](http://msdn2.microsoft.com/en-us/library/32ce378e-a178-4970-b3bd-3887866e97af) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaFreeInfo +[DsReplicaGetInfo2W](http://msdn2.microsoft.com/en-us/library/5735d91d-1b7d-4dc6-b6c6-61ba38ebe50d) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaGetInfo2W +[DsReplicaGetInfoW](http://msdn2.microsoft.com/en-us/library/b7ab22fe-ed92-4213-9b66-2dd5526286fa) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaGetInfoW +[DsReplicaModify](http://msdn2.microsoft.com/en-us/library/aad20527-1211-41bc-b0e9-02e4ab28ae2e) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaModify +[DsReplicaSync](http://msdn2.microsoft.com/en-us/library/20c7f96d-f298-4321-a6f5-910c25e418db) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaSync +[DsReplicaSyncAll](http://msdn2.microsoft.com/en-us/library/2608adde-4f18-4048-a96f-d736ff09cd4b) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaSyncAll +[DsReplicaUpdateRefs](http://msdn2.microsoft.com/en-us/library/158c7e73-0e6c-4b71-a87f-2f60f3db91cb) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaUpdateRefs +[DsReplicaVerifyObjects](http://msdn2.microsoft.com/en-us/library/d0e139dc-6aaf-47e1-a76f-4e84f17aa7c6) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsReplicaVerifyObjects +[DsServerRegisterSpn](http://msdn2.microsoft.com/en-us/library/d95dfa55-f978-4d8d-a63d-cd1339769c79) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsServerRegisterSpn [DsUnBind](http://msdn2.microsoft.com/en-us/library/7106d67f-d421-4a7c-b775-440e5944f25e) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsUnBind [DsUnquoteRdnValue](http://msdn2.microsoft.com/en-us/library/6e3dd220-ba98-46b5-8522-93cbe2029aa4) | ntdsapi.dll | dsparse.h | Vanara.PInvoke.NTDSApi.DsUnquoteRdnValue [DsWriteAccountSpn](http://msdn2.microsoft.com/en-us/library/2b555f6b-643d-4fa0-9aca-701e6b3313fa) | ntdsapi.dll | ntdsapi.h | Vanara.PInvoke.NTDSApi.DsWriteAccountSpn ### Structures Native Structure | Header | Managed Structure --- | --- | --- +[DCInfoHandle](https://www.google.com/search?num=5&q=DCInfoHandle+site%3Amicrosoft.com) | | Vanara.PInvoke.NTDSApi+DCInfoHandle [DS_DOMAIN_CONTROLLER_INFO_1](http://msdn2.microsoft.com/en-us/library/6cc829ac-2aa6-49ef-b1ab-9c249249e0d6) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_DOMAIN_CONTROLLER_INFO_1 [DS_DOMAIN_CONTROLLER_INFO_2](http://msdn2.microsoft.com/en-us/library/9d45b732-363d-4b20-ae5c-e9e76264bf1f) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_DOMAIN_CONTROLLER_INFO_2 [DS_DOMAIN_CONTROLLER_INFO_3](http://msdn2.microsoft.com/en-us/library/510f458e-4c08-41c7-b290-1372ac9c8beb) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_DOMAIN_CONTROLLER_INFO_3 [DS_NAME_RESULT](http://msdn2.microsoft.com/en-us/library/ms676246) | NTDSApi.h | Vanara.PInvoke.NTDSApi+DS_NAME_RESULT [DS_NAME_RESULT_ITEM](http://msdn2.microsoft.com/en-us/library/ms676246) | NTDSApi.h | Vanara.PInvoke.NTDSApi+DS_NAME_RESULT_ITEM +[DS_REPL_ATTR_META_DATA](http://msdn2.microsoft.com/en-us/library/27ccc1c9-03d7-4d13-b9ec-65d6b8bdfd37) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_ATTR_META_DATA +[DS_REPL_ATTR_META_DATA_2](http://msdn2.microsoft.com/en-us/library/392457b7-df69-44d0-82b2-8381d5877354) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_ATTR_META_DATA_2 +[DS_REPL_ATTR_META_DATA_BLOB](http://msdn2.microsoft.com/en-us/library/eee12de1-287a-4e76-9a9c-37e6b967971f) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_ATTR_META_DATA_BLOB +[DS_REPL_ATTR_VALUE_META_DATA](http://msdn2.microsoft.com/en-us/library/b13cdd31-d154-4539-81d6-d7a449e2b3d5) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_ATTR_VALUE_META_DATA +[DS_REPL_ATTR_VALUE_META_DATA_2](http://msdn2.microsoft.com/en-us/library/2022362a-e2f7-4cfd-a512-cfe29e5d439d) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_ATTR_VALUE_META_DATA_2 +[DS_REPL_ATTR_VALUE_META_DATA_EXT](http://msdn2.microsoft.com/en-us/library/CA41C6BF-A485-4AC7-B761-3A07159C2FF1) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_ATTR_VALUE_META_DATA_EXT +[DS_REPL_CURSOR](http://msdn2.microsoft.com/en-us/library/ab4ee8d8-5ccd-4f3f-a1c0-de78c65a10d3) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_CURSOR +[DS_REPL_CURSOR_2](http://msdn2.microsoft.com/en-us/library/ff839372-41f0-499a-9582-59ace02f1485) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_CURSOR_2 +[DS_REPL_CURSOR_3W](http://msdn2.microsoft.com/en-us/library/0361a3e1-814c-4ef2-b574-2870a9289e52) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_CURSOR_3W +[DS_REPL_CURSOR_BLOB](http://msdn2.microsoft.com/en-us/library/c41e4737-5ef8-40ce-9af1-0afff7e11dc1) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_CURSOR_BLOB +[DS_REPL_CURSORS](http://msdn2.microsoft.com/en-us/library/0fe5ad72-d3f3-42a8-a36f-ca1fc9c55c50) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_CURSORS +[DS_REPL_CURSORS_2](http://msdn2.microsoft.com/en-us/library/5a1981ac-3b6a-4e48-8430-f8297ddd3283) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_CURSORS_2 +[DS_REPL_CURSORS_3W](http://msdn2.microsoft.com/en-us/library/7b8e0015-dd8f-4cba-8ea2-683cb107f294) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_CURSORS_3W +[DS_REPL_KCC_DSA_FAILURESW](http://msdn2.microsoft.com/en-us/library/bb011502-38ae-43b7-a6ad-de16b499f61b) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_KCC_DSA_FAILURESW +[DS_REPL_KCC_DSA_FAILUREW](http://msdn2.microsoft.com/en-us/library/7a7131ce-a647-4b3d-a9f3-091b6dcebff7) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_KCC_DSA_FAILUREW +[DS_REPL_KCC_DSA_FAILUREW_BLOB](http://msdn2.microsoft.com/en-us/library/b0df588a-2ef1-4870-b304-c6f9e07322b0) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_KCC_DSA_FAILUREW_BLOB +[DS_REPL_NEIGHBOR](http://msdn2.microsoft.com/en-us/library/acab74f4-5739-4310-895b-081062c0360b) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_NEIGHBOR +[DS_REPL_NEIGHBORS](http://msdn2.microsoft.com/en-us/library/1307399b-de29-43ec-97b4-05cd70c1a92d) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_NEIGHBORS +[DS_REPL_NEIGHBORW_BLOB](http://msdn2.microsoft.com/en-us/library/1a56968a-29ed-4c94-80ee-02bdd279f5c2) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_NEIGHBORW_BLOB +[DS_REPL_OBJ_META_DATA](http://msdn2.microsoft.com/en-us/library/7851ffbc-5d05-4ea7-b3b4-1b8b77299be5) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_OBJ_META_DATA +[DS_REPL_OBJ_META_DATA_2](http://msdn2.microsoft.com/en-us/library/2aed753f-432c-4de8-a6be-aa79833f002f) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_OBJ_META_DATA_2 +[DS_REPL_OPW](http://msdn2.microsoft.com/en-us/library/9ea783b3-1529-4424-a582-f46f2a239a60) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_OPW +[DS_REPL_OPW_BLOB](http://msdn2.microsoft.com/en-us/library/14676159-cc31-4254-b174-dcd84d9ceec1) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_OPW_BLOB +[DS_REPL_PENDING_OPSW](http://msdn2.microsoft.com/en-us/library/2e4b96cb-fbd6-496b-aff3-cb7d82f1fa39) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_PENDING_OPSW +[DS_REPL_QUEUE_STATISTICSW](http://msdn2.microsoft.com/en-us/library/bfddd7ed-0ff4-46ca-84c2-39020acb37d0) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_QUEUE_STATISTICSW +[DS_REPL_VALUE_META_DATA](http://msdn2.microsoft.com/en-us/library/294a466e-8a83-4b33-a8a8-ac7b51d081d4) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_VALUE_META_DATA +[DS_REPL_VALUE_META_DATA_2](http://msdn2.microsoft.com/en-us/library/747e32b8-2cc0-4fcd-88dc-027188598361) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_VALUE_META_DATA_2 +[DS_REPL_VALUE_META_DATA_BLOB](http://msdn2.microsoft.com/en-us/library/7d8bb666-c5d8-43de-ab72-5b02b6e0593d) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_VALUE_META_DATA_BLOB +[DS_REPL_VALUE_META_DATA_BLOB_EXT](http://msdn2.microsoft.com/en-us/library/095180F4-9E3F-47EE-B39E-107D7D219DCB) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_VALUE_META_DATA_BLOB_EXT +[DS_REPL_VALUE_META_DATA_EXT](http://msdn2.microsoft.com/en-us/library/2BE0F9C4-D688-4DE6-8DB2-15666D8BD070) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPL_VALUE_META_DATA_EXT +[DS_REPSYNCALL_ERRINFO](http://msdn2.microsoft.com/en-us/library/70af4e3e-1f0e-49c5-b8c6-5e89114ed4ea) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPSYNCALL_ERRINFO +[DS_REPSYNCALL_UPDATE](http://msdn2.microsoft.com/en-us/library/3b0005cb-0fb6-492c-89e5-8a18a88f881b) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_REPSYNCALL_UPDATE +[DS_SCHEMA_GUID_MAP](https://www.google.com/search?num=5&q=DS_SCHEMA_GUID_MAP+site%3Amicrosoft.com) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_SCHEMA_GUID_MAP +[DS_SITE_COST_INFO](https://www.google.com/search?num=5&q=DS_SITE_COST_INFO+site%3Amicrosoft.com) | ntdsapi.h | Vanara.PInvoke.NTDSApi+DS_SITE_COST_INFO +[SCHEDULE](http://msdn2.microsoft.com/en-us/library/d86890db-b34a-415a-820a-6d4790914218) | schedule.h | Vanara.PInvoke.NTDSApi+SCHEDULE +[SCHEDULE_HEADER](http://msdn2.microsoft.com/en-us/library/5453927e-306e-4442-a855-916005dc8e3b) | schedule.h | Vanara.PInvoke.NTDSApi+SCHEDULE_HEADER +[SpnArrayHandle](https://www.google.com/search?num=5&q=SpnArrayHandle+site%3Amicrosoft.com) | | Vanara.PInvoke.NTDSApi+SpnArrayHandle diff --git a/PInvoke/NTDSApi/NTDSAPI.cs b/PInvoke/NTDSApi/NTDSAPI.cs index 9578218e..5088a30d 100644 --- a/PInvoke/NTDSApi/NTDSAPI.cs +++ b/PInvoke/NTDSApi/NTDSAPI.cs @@ -1,11 +1,14 @@ using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; using System.Security; using System.Text; using Vanara.Extensions; using Vanara.InteropServices; +using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME; namespace Vanara.PInvoke { @@ -14,6 +17,37 @@ namespace Vanara.PInvoke { private const uint NO_ERROR = 0; + /// + /// The SyncUpdateProc function is an application-defined function that handles update messages passed from the + /// DsReplicaSyncAll function. SyncUpdateProc is a placeholder for the application-defined callback function name. + /// + /// + /// Pointer to application-defined data passed in the pCallbackData parameter of the DsReplicaSyncAll function. + /// + /// + /// Pointer to a DS_REPSYNCALL_UPDATE structure that describes the event in the DsReplicaSyncAll function that caused + /// the SyncUpdateProc callback function to be called. + /// + /// + /// Execution of the DsReplicaSyncAll function pauses when it calls the SyncUpdateProc callback function. If + /// SyncUpdateProc returns TRUE, execution of DsReplicaSyncAll resumes. Otherwise, the DsReplicaSyncAll + /// function terminates. + /// + // BOOL SyncUpdateProc( LPVOID pData, PDS_REPSYNCALL_UPDATE pUpdate ); https://msdn.microsoft.com/en-us/library/ms677968(v=vs.85).aspx + [UnmanagedFunctionPointer(CallingConvention.Winapi)] + [PInvokeData("ntdsapi.h", MSDNShortId = "ms677968")] + // [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SyncUpdateProc(IntPtr pData, PDS_REPSYNCALL_UPDATE pUpdate); + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool SyncUpdateProc(IntPtr pData, ref DS_REPSYNCALL_UPDATE pUpdate); + + /// Identifies the task that the KCC should execute. + [PInvokeData("ntdsapi.h", MSDNShortId = "2a83ffcb-1ebd-4024-a186-9c079896f4e1")] + public enum DS_KCC_TASKID + { + /// Update topology. + DS_KCC_TASKID_UPDATE_TOPOLOGY = 0 + } + /// /// Defines the errors returned by the status member of the structure. These are potential errors /// that may be encountered while a name is converted by the + /// Requests replication state data for naming context and source server pairs. Returns a pointer to a DS_REPL_NEIGHBORS structure. + /// + [CorrespondingType(typeof(DS_REPL_NEIGHBORS), CorrepsondingAction.Get)] + DS_REPL_INFO_NEIGHBORS, + + /// + /// Requests replication state data with respect to all replicas of a given naming context. Returns a pointer to a + /// DS_REPL_CURSORS structure. + /// + [CorrespondingType(typeof(DS_REPL_CURSORS), CorrepsondingAction.Get)] + DS_REPL_INFO_CURSORS_FOR_NC, + + /// + /// Requests replication state data for the attributes for the given object. Returns a pointer to a DS_REPL_OBJ_META_DATA structure. + /// + [CorrespondingType(typeof(DS_REPL_OBJ_META_DATA), CorrepsondingAction.Get)] + DS_REPL_INFO_METADATA_FOR_OBJ, + + /// + /// Requests replication state data with respect to connection failures between inbound replication partners. Returns a pointer + /// to a DS_REPL_KCC_DSA_FAILURES structure. + /// + [CorrespondingType(typeof(DS_REPL_KCC_DSA_FAILURESW), CorrepsondingAction.Get)] + DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES, + + /// + /// Requests replication state data with respect to link failures between inbound replication partners. Returns a pointer to a + /// DS_REPL_KCC_DSA_FAILURES structure. + /// + [CorrespondingType(typeof(DS_REPL_KCC_DSA_FAILURESW), CorrepsondingAction.Get)] + DS_REPL_INFO_KCC_DSA_LINK_FAILURES, + + /// + /// Requests the replication tasks currently executing or queued to execute. Returns a pointer to a DS_REPL_PENDING_OPS structure. + /// + [CorrespondingType(typeof(DS_REPL_PENDING_OPSW), CorrepsondingAction.Get)] + DS_REPL_INFO_PENDING_OPS, + + /// + /// Requests replication state data for a specific attribute for the given object. Returns a pointer to a + /// DS_REPL_ATTR_VALUE_META_DATA structure. + /// + [CorrespondingType(typeof(DS_REPL_ATTR_VALUE_META_DATA), CorrepsondingAction.Get)] + DS_REPL_INFO_METADATA_FOR_ATTR_VALUE, + + /// + /// Requests replication state data with respect to all replicas of a given naming context. Returns a pointer to a + /// DS_REPL_CURSORS_2 structure. + /// + [CorrespondingType(typeof(DS_REPL_CURSORS_2), CorrepsondingAction.Get)] + DS_REPL_INFO_CURSORS_2_FOR_NC, + + /// + /// Requests replication state data with respect to all replicas of a given naming context. Returns a pointer to a + /// DS_REPL_CURSORS_3 structure. + /// + [CorrespondingType(typeof(DS_REPL_CURSORS_3W), CorrepsondingAction.Get)] + DS_REPL_INFO_CURSORS_3_FOR_NC, + + /// + /// Requests replication state data for the attributes for the given object. Returns a pointer to a DS_REPL_OBJ_META_DATA_2 structure. + /// + [CorrespondingType(typeof(DS_REPL_OBJ_META_DATA_2), CorrepsondingAction.Get)] + DS_REPL_INFO_METADATA_2_FOR_OBJ, + + /// + /// Requests replication state data for a specific attribute for the given object. Returns a pointer to a + /// DS_REPL_ATTR_VALUE_META_DATA_2 structure. + /// + [CorrespondingType(typeof(DS_REPL_ATTR_VALUE_META_DATA_2), CorrepsondingAction.Get)] + DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE, + + /// + /// Requests replication state data for a specific attribute for the given object. Returns a pointer to a + /// DS_REPL_ATTR_VALUE_META_DATA_EXT structure. + /// + [CorrespondingType(typeof(DS_REPL_ATTR_VALUE_META_DATA_EXT), CorrepsondingAction.Get)] + DS_REPL_INFO_METADATA_EXT_FOR_ATTR_VALUE, + } + + /// + /// + /// The DS_REPL_OP_TYPE enumeration type is used to indicate the type of replication operation that a given entry in the + /// replication queue represents. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ne-ntdsapi-_ds_repl_op_type typedef enum _DS_REPL_OP_TYPE { + // DS_REPL_OP_TYPE_SYNC, DS_REPL_OP_TYPE_ADD, DS_REPL_OP_TYPE_DELETE, DS_REPL_OP_TYPE_MODIFY, DS_REPL_OP_TYPE_UPDATE_REFS } DS_REPL_OP_TYPE; + [PInvokeData("ntdsapi.h", MSDNShortId = "81d9f464-90f4-405c-b014-0a61f5a5b816")] + public enum DS_REPL_OP_TYPE + { + /// Indicates an inbound replication over an existing replication agreement from a direct replication partner. + DS_REPL_OP_TYPE_SYNC, + + /// Indicates the addition of a replication agreement for a new direct replication partner. + DS_REPL_OP_TYPE_ADD, + + /// Indicates the removal of a replication agreement for an existing direct replication partner. + DS_REPL_OP_TYPE_DELETE, + + /// Indicates the modification of a replication agreement for an existing direct replication partner. + DS_REPL_OP_TYPE_MODIFY, + + /// Indicates the addition, deletion, or update of outbound change notification data for a direct replication partner. + DS_REPL_OP_TYPE_UPDATE_REFS, + } + + /// + /// + /// The DS_REPSYNCALL_ERROR enumeration is used with the DS_REPSYNCALL_ERRINFO structure to indicate where in the replication + /// process an error occurred. + /// + /// + // https://webcache.googleusercontent.com/search?q=cache:ryUMFaJus6sJ:https://docs.microsoft.com/is-is/windows/desktop/api/Ntdsapi/ne-ntdsapi-ds_repsyncall_error+&cd=1&hl=en&ct=clnk&gl=us + // typedef enum DS_REPSYNCALL_ERROR { DS_REPSYNCALL_WIN32_ERROR_CONTACTING_SERVER , DS_REPSYNCALL_WIN32_ERROR_REPLICATING , + // DS_REPSYNCALL_SERVER_UNREACHABLE } ; + [PInvokeData("ntdsapi.h", MSDNShortId = "9c020046-ab52-4676-931e-12ce176e93fb")] + public enum DS_REPSYNCALL_ERROR + { + /// The server referred to by the pszSvrId member of the DS_REPSYNCALL_ERRINFO structure cannot be contacted. + DS_REPSYNCALL_WIN32_ERROR_CONTACTING_SERVER, + + /// + /// An error occurred during replication of the server identified by the pszSvrId member of the DS_REPSYNCALL_ERRINFO structure. + /// + DS_REPSYNCALL_WIN32_ERROR_REPLICATING, + + /// The server identified by the pszSvrId member of the DS_REPSYNCALL_ERRINFO structure cannot be contacted. + DS_REPSYNCALL_SERVER_UNREACHABLE, + } + + /// + /// + /// The DS_REPSYNCALL_EVENT enumeration is used with the DS_REPSYNCALL_UPDATE structure to define which event the + /// DS_REPSYNCALL_UPDATE structure represents. + /// + /// + // https://webcache.googleusercontent.com/search?q=cache:NyB4AWln394J:https://docs.microsoft.com/en-us/windows/desktop/api/Ntdsapi/ne-ntdsapi-ds_repsyncall_event+&cd=1&hl=en&ct=clnk&gl=us + // typedef enum DS_REPSYNCALL_EVENT { DS_REPSYNCALL_EVENT_ERROR , DS_REPSYNCALL_EVENT_SYNC_STARTED , + // DS_REPSYNCALL_EVENT_SYNC_COMPLETED , DS_REPSYNCALL_EVENT_FINISHED } ; + [PInvokeData("ntdsapi.h", MSDNShortId = "a732a906-0e26-45f6-b89c-58f2277057ba")] + public enum DS_REPSYNCALL_EVENT + { + /// An error occurred. Error data is stored in the pErrInfo member of the DS_REPSYNCALL_UPDATE structure. + DS_REPSYNCALL_EVENT_ERROR, + + /// + /// Synchronization of two servers has started. Both the pErrInfo and pSync members of the DS_REPSYNCALL_UPDATE structure are NULL. + /// + DS_REPSYNCALL_EVENT_SYNC_STARTED, + + /// + /// Synchronization of two servers has just finished. The servers involved in the synchronization are identified by the pSync + /// member of the DS_REPSYNCALL_UPDATE structure. The pErrInfo member of the DS_REPSYNCALL_UPDATE structure is NULL. + /// + DS_REPSYNCALL_EVENT_SYNC_COMPLETED, + + /// + /// Execution of DsReplicaSyncAll is complete. Both the pErrInfo and pSync members of the DS_REPSYNCALL_UPDATE structure are + /// NULL. The return value of the callback function is ignored. + /// + DS_REPSYNCALL_EVENT_FINISHED, + } + /// /// The DS_SPN_NAME_TYPE enumeration is used by the DsGetSPN function to identify the format for composing SPNs. /// @@ -165,11 +378,24 @@ namespace Vanara.PInvoke [PInvokeData("ntdsapi.h", MSDNShortId = "7aab22a6-1fe1-4127-97d3-54287d770790")] public enum DS_SPN_NAME_TYPE { + /// The SPN format for the distinguished name service of the host-based service, which provides services identified with its host computer. This SPN uses the following format: + /// jeffsmith.fabrikam.com DS_SPN_DNS_HOST, + /// The SPN format for the distinguished name of the host-based service, which provides services identified with its host computer. This SPN uses the following format: + /// cn=jeffsmith,ou=computers,dc=fabrikam,dc=com DS_SPN_DN_HOST, + /// The SPN format for the NetBIOS service of the host-based service, which provides services identified with its host computer. This SPN uses the following format: + /// jeffsmith-nec DS_SPN_NB_HOST, + /// The SPN format for a replicable service that provides services to the specified domain. This SPN uses the following format: + /// fabrikam.com DS_SPN_DOMAIN, + /// The SPN format for a replicable service that provides services to the specified NetBIOS domain. This SPN uses the following format: + /// fabrikam DS_SPN_NB_DOMAIN, + /// The SPN format for a specified service. This SPN uses the following formats, depending on which service is used: + /// cn=anRpcService,cn=RPC Services,cn=system,dc=fabrikam,dc=com + /// cn=aWsService,cn=Winsock Services,cn=system,dc=fabrikam,dc=com DS_SPN_SERVICE } @@ -233,6 +459,525 @@ namespace Vanara.PInvoke NTDSAPI_BIND_FORCE_KERBEROS = 0x00000004, } + /// Contains a set of flags that modify the function behavior. + [PInvokeData("ntdsapi.h", MSDNShortId = "2a83ffcb-1ebd-4024-a186-9c079896f4e1")] + [Flags] + public enum DsKCCFlags + { + /// The task is queued and then the function returns without waiting for the task to complete. + DS_KCC_FLAG_ASYNC_OP = (1 << 0), + + /// The task will not be added to the queue if another queued task will run soon. + DS_KCC_FLAG_DAMPED = (1 << 1), + } + + /// Passes additional data to be used to process the request. + [PInvokeData("ntdsapi.h", MSDNShortId = "33bd1b61-b9ed-479f-a128-fb7ddbb5e9af")] + [Flags] + public enum DsReplicaAddOptions + { + /// Performs this operation asynchronously. + DS_REPADD_ASYNCHRONOUS_OPERATION = 0x00000001, + + /// Creates a writable replica; otherwise, the replica is read-only. + DS_REPADD_WRITEABLE = 0x00000002, + + /// Synchronizes the NC from this source when the DSA is started. + DS_REPADD_INITIAL = 0x00000004, + + /// Synchronizes the NC from this source periodically, as defined in pSchedule. + DS_REPADD_PERIODIC = 0x00000008, + + /// + /// Synchronizes from the source DSA using the Intersite Messaging Service (IMS) transport, for example, by SMTP, rather than + /// using the native directory service RPC. + /// + DS_REPADD_INTERSITE_MESSAGING = 0x00000010, + + /// Does not replicate the NC. Instead, save enough state data such that it may be replicated later. + DS_REPADD_ASYNCHRONOUS_REPLICA = 0x00000020, + + /// + /// Disables notification-based synchronization for the NC from this source. This is expected to be a temporary state. Use + /// DS_REPADD_NEVER_NOTIFY to permanently disable synchronization. + /// + DS_REPADD_DISABLE_NOTIFICATION = 0x00000040, + + /// Disables periodic synchronization for the NC from this source. + DS_REPADD_DISABLE_PERIODIC = 0x00000080, + + /// + /// Uses compression when replicating. This saves network bandwidth at the expense of CPU overhead at both the source and + /// destination servers. + /// + DS_REPADD_USE_COMPRESSION = 0x00000100, + + /// + /// + /// Disables change notifications from this source. When this flag is set, the source does not notify the destination when + /// changes occur. This is recommended for all intersite replication that may occur over WAN links. + /// + /// This is expected to be a permanent state; use DS_REPADD_DISABLE_NOTIFICATION to temporarily disable notifications. + /// + DS_REPADD_NEVER_NOTIFY = 0x00000200, + + /// Undocumented. + DS_REPADD_TWO_WAY = 0x00000400, + + /// Undocumented. + DS_REPADD_CRITICAL = 0x00000800, + + /// Undocumented. + DS_REPADD_SELECT_SECRETS = 0x00001000, + + /// Undocumented. + DS_REPADD_NONGC_RO_REPLICA = 0x01000000, + } + + /// Passes additional data used to process the request. + [PInvokeData("ntdsapi.h", MSDNShortId = "68c767c4-bbb6-477b-8ffb-94f3ae235375")] + [Flags] + public enum DsReplicaDelOptions + { + /// Performs this operation asynchronously. + DS_REPDEL_ASYNCHRONOUS_OPERATION = 0x00000001, + + /// Signifies that the replica deleted can be written to. + DS_REPDEL_WRITEABLE = 0x00000002, + + /// Signifies the replica is mail-based rather than synchronized using native directory service RPC. + DS_REPDEL_INTERSITE_MESSAGING = 0x00000004, + + /// + /// Ignores any error generated from contacting the source to instruct it to remove this NC from its list of servers to which it replicates. + /// + DS_REPDEL_IGNORE_ERRORS = 0x00000008, + + /// + /// Does not contact the source to tell it to remove this NC from its list of servers to which it replicates. If this flag is not + /// set and the link is based in RPC, the source is contacted. + /// + DS_REPDEL_LOCAL_ONLY = 0x00000010, + + /// Deletes all the objects in the NC. This option is valid only for read-only NCs with no source. + DS_REPDEL_NO_SOURCE = 0x00000020, + + /// Allows deletion of a read-only replica even if it sources other read-only replicas. + DS_REPDEL_REF_OK = 0x00000040, + } + + /// Contains a set of flags that modify the behavior of the function. + [PInvokeData("ntdsapi.h", MSDNShortId = "5735d91d-1b7d-4dc6-b6c6-61ba38ebe50d")] + [Flags] + public enum DsReplInfoFlags + { + /// No flags are set. + DS_REPL_INFO_FLAG_NONE = 0, + + /// + /// Causes the attribute metadata to account for metadata on the attribute's linked values. The resulting vector represents + /// changes for all attributes. This modified vector is useful for clients that expect all attributes and metadata to be included + /// in the attribute metadata vector. + /// + DS_REPL_INFO_FLAG_IMPROVE_LINKED_ATTRS = 0x00000001, + } + + /// Specifies what fields should be modified. At least one field must be specified in ModifyFields. + [PInvokeData("ntdsapi.h", MSDNShortId = "aad20527-1211-41bc-b0e9-02e4ab28ae2e")] + [Flags] + public enum DsReplModFieldFlags + { + /// Updates the flags associated with the replica. + DS_REPMOD_UPDATE_FLAGS = 0x00000001, + + /// Updates the address associated with the referenced server. + DS_REPMOD_UPDATE_INSTANCE = 0x00000002, + + /// Updates the address associated with the referenced server. + DS_REPMOD_UPDATE_ADDRESS = DS_REPMOD_UPDATE_INSTANCE, + + /// Updates the periodic replication schedule associated with the replica. + DS_REPMOD_UPDATE_SCHEDULE = 0x00000004, + + /// Not used. Specifying updates of result values is not currently supported. Result values default to 0. + DS_REPMOD_UPDATE_RESULT = 0x00000008, + + /// Updates the transport associated with the replica. + DS_REPMOD_UPDATE_TRANSPORT = 0x00000010, + } + + /// Passes additional data used to process the request. + [PInvokeData("ntdsapi.h", MSDNShortId = "aad20527-1211-41bc-b0e9-02e4ab28ae2e")] + public enum DsReplModOptions + { + /// Performs this operation asynchronously. + DS_REPMOD_ASYNCHRONOUS_OPERATION = 0x00000001, + + /// Indicates that the replica being modified can be written to. + DS_REPMOD_WRITEABLE = 0x00000002 + } + + /// Contains a set of flags that specify attributes and options for the replication data. + [PInvokeData("ntdsapi.h", MSDNShortId = "acab74f4-5739-4310-895b-081062c0360b")] + [Flags] + public enum DsReplNeighborFlags + { + /// + /// The local copy of the naming context is writable. + /// + DS_REPL_NBR_WRITEABLE = 0x10, + + /// + /// + /// Replication of this naming context from this source is attempted when the destination server is booted. This normally only + /// applies to intra-site neighbors. + /// + /// + DS_REPL_NBR_SYNC_ON_STARTUP = 0x20, + + /// + /// + /// Perform replication on a schedule. This flag is normally set unless the schedule for this naming context/source is "never", + /// that is, the empty schedule. + /// + /// + DS_REPL_NBR_DO_SCHEDULED_SYNCS = 0x40, + + /// + /// + /// Perform replication indirectly through the Inter-Site Messaging Service. This flag is set only when replicating over SMTP. + /// This flag is not set when replicating over inter-site RPC/IP. + /// + /// + DS_REPL_NBR_USE_ASYNC_INTERSITE_TRANSPORT = 0x80, + + /// + /// + /// If set, indicates that when inbound replication is complete, the destination server must tell the source server to + /// synchronize in the reverse direction. This feature is used in dial-up scenarios where only one of the two servers can + /// initiate a dial-up connection. For example, this option would be used in a corporate headquarters and branch office, where + /// the branch office connects to the corporate headquarters over the Internet by means of a dial-up ISP connection. + /// + /// + DS_REPL_NBR_TWO_WAY_SYNC = 0x200, + + /// + /// + /// This neighbor is in a state where it returns parent objects before children objects. It goes into this state after it + /// receives a child object before its parent. + /// + /// + DS_REPL_NBR_RETURN_OBJECT_PARENTS = 0x800, + + /// + /// + /// The destination server is performing a full synchronization from the source server. Full synchronizations do not use vectors + /// that create updates (DS_REPL_CURSORS) for filtering updates. Full synchronizations are not used as a part of the normal + /// replication protocol. + /// + /// + DS_REPL_NBR_FULL_SYNC_IN_PROGRESS = 0x10000, + + /// + /// + /// The last packet from the source indicated a modification of an object that the destination server has not yet created. The + /// next packet to be requested instructs the source server to put all attributes of the modified object into the packet. + /// + /// + DS_REPL_NBR_FULL_SYNC_NEXT_PACKET = 0x20000, + + /// + /// A synchronization has never been successfully completed from this source. + /// + DS_REPL_NBR_NEVER_SYNCED = 0x200000, + + /// + /// + /// The replication engine has temporarily stopped processing this neighbor in order to service another higher-priority neighbor, + /// either for this partition or for another partition. The replication engine will resume processing this neighbor after the + /// higher-priority work is completed. + /// + /// + DS_REPL_NBR_PREEMPTED = 0x1000000, + + /// + /// + /// This neighbor is set to disable notification-based synchronizations. Within a site, domain controllers synchronize with each + /// other based on notifications when changes occur. This setting prevents this neighbor from performing syncs that are triggered + /// by notifications. The neighbor will still do synchronizations based on its schedule, or in response to manually requested synchronizations. + /// + /// + DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS = 0x4000000, + + /// + /// + /// This neighbor is set to not perform synchronizations based on its schedule. The only way this neighbor will perform + /// synchronizations is in response to change notifications or to manually requested synchronizations. + /// + /// + DS_REPL_NBR_DISABLE_SCHEDULED_SYNC = 0x8000000, + + /// + /// + /// Changes received from this source are to be compressed. This is normally set if, and only if, the source server is in a + /// different site. + /// + /// + DS_REPL_NBR_COMPRESS_CHANGES = 0x10000000, + + /// + /// + /// No change notifications should be received from this source. Normally set if, and only if, the source server is in a + /// different site. + /// + /// + DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS = 0x20000000, + + /// + /// + /// This neighbor is in a state where it is rebuilding the contents of this replica because of a change in the partial attribute set. + /// + /// + DS_REPL_NBR_PARTIAL_ATTRIBUTE_SET = 0x40000000, + } + + /// Passes additional data used to process the request. + [PInvokeData("ntdsapi.h", MSDNShortId = "2608adde-4f18-4048-a96f-d736ff09cd4b")] + [Flags] + public enum DsReplSyncAllFlags + { + /// This option has no effect. + DS_REPSYNCALL_NO_OPTIONS = 0x00000000, + + /// + /// Generates a fatal error if any server cannot be contacted or if any server is unreachable due to a disconnected or broken topology. + /// + DS_REPSYNCALL_ABORT_IF_SERVER_UNAVAILABLE = 0x00000001, + + /// Disables transitive replication. Synchronization is performed only with adjacent servers. + DS_REPSYNCALL_SYNC_ADJACENT_SERVERS_ONLY = 0x00000002, + + /// In the event of a non-fatal error, returns server distinguished names (DN) instead of their GUID DNS names. + DS_REPSYNCALL_ID_SERVERS_BY_DN = 0x00000004, + + /// + /// Disables all synchronization. The topology is still analyzed, and unavailable or unreachable servers are still identified. + /// + DS_REPSYNCALL_DO_NOT_SYNC = 0x00000008, + + /// + /// Assumes that all servers are responding. This speeds operation of the DsReplicaSyncAll function, but if some servers are not + /// responding, some transitive replications may be blocked. + /// + DS_REPSYNCALL_SKIP_INITIAL_CHECK = 0x00000010, + + /// + /// Pushes changes from the home server out to all partners using transitive replication. This reverses the direction of + /// replication, and the order of execution of the replication sets from the usual "pulling" mode of execution. + /// + DS_REPSYNCALL_PUSH_CHANGES_OUTWARD = 0x00000020, + + /// + /// Synchronizes across site boundaries. By default, DsReplicaSyncAll attempts to synchronize only with DCs in the same site as + /// the home system. Set this flag to attempt to synchronize with all DCs in the enterprise forest. However, the DCs can be + /// synchronized only if connected by a synchronous (RPC) transport. + /// + DS_REPSYNCALL_CROSS_SITE_BOUNDARIES = 0x00000040, + } + + /// These flag values are used both as input to DsReplicaSync and as output from DsReplicaGetInfo, PENDING_OPS, DS_REPL_OPW.ulOptions + [PInvokeData("ntdsapi.h", MSDNShortId = "20c7f96d-f298-4321-a6f5-910c25e418db")] + [Flags] + public enum DsReplSyncOptions + { + /// + /// Performs this operation asynchronously. + /// + /// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista and Windows Server 2003: Required when using DS_REPSYNC_ALL_SOURCES. + /// + /// + DS_REPSYNC_ASYNCHRONOUS_OPERATION = 0x00000001, + + /// Replica is writable. Otherwise, it is read-only. + DS_REPSYNC_WRITEABLE = 0x00000002, + + /// Indicates this operation is a periodic synchronization request as scheduled by the administrator. + DS_REPSYNC_PERIODIC = 0x00000004, + + /// Synchronizes using an ISM. + DS_REPSYNC_INTERSITE_MESSAGING = 0x00000008, + + /// Synchronizes starting from the first Update Sequence Number (USN). + DS_REPSYNC_FULL = 0x00000020, + + /// Indicates this operation is a notification of an update marked urgent. + DS_REPSYNC_URGENT = 0x00000040, + + /// Does not discard this synchronization request, even if a similar synchronization is pending. + DS_REPSYNC_NO_DISCARD = 0x00000080, + + /// Synchronizes even if the link is currently disabled. + DS_REPSYNC_FORCE = 0x00000100, + + /// + /// Causes the source directory system agent (DSA) to verify that the local DSA is present in the source replicates-to list. If + /// not, the local DSA is added. This ensures that the source sends change notifications. + /// + DS_REPSYNC_ADD_REFERENCE = 0x00000200, + + /// A sync from this source has never completed (e.g., a new source). + DS_REPSYNC_NEVER_COMPLETED = 0x00000400, + + /// When this sync is complete, requests a sync in the opposite direction. + DS_REPSYNC_TWO_WAY = 0x00000800, + + /// Do not request change notifications from this source. + DS_REPSYNC_NEVER_NOTIFY = 0x00001000, + + /// Sync the NC from this source when the DSA is started. + DS_REPSYNC_INITIAL = 0x00002000, + + /// + /// Use compression when replicating. Saves message size (e.g., network bandwidth) at the expense of extra CPU overhead at both + /// the source and destination servers. + /// + DS_REPSYNC_USE_COMPRESSION = 0x00004000, + + /// Sync was abandoned for lack of updates (W2K, W2K3) + DS_REPSYNC_ABANDONED = 0x00008000, + + /// Special secret processing + DS_REPSYNC_SELECT_SECRETS = 0x00008000, + + /// Initial sync in progress + DS_REPSYNC_INITIAL_IN_PROGRESS = 0x00010000, + + /// Partial Attribute Set sync in progress + DS_REPSYNC_PARTIAL_ATTRIBUTE_SET = 0x00020000, + + /// Sync is being retried + DS_REPSYNC_REQUEUE = 0x00040000, + + /// Sync is a notification request from a source + DS_REPSYNC_NOTIFICATION = 0x00080000, + + /// Sync is a special form which requests to establish contact now and do the rest of the sync later + DS_REPSYNC_ASYNCHRONOUS_REPLICA = 0x00100000, + + /// Request critical objects only + DS_REPSYNC_CRITICAL = 0x00200000, + + /// A full synchronization is in progress + DS_REPSYNC_FULL_IN_PROGRESS = 0x00400000, + + /// Synchronization request was previously preempted + DS_REPSYNC_PREEMPTED = 0x00800000, + + /// Non GC readonly replica + DS_REPSYNC_NONGC_RO_REPLICA = 0x01000000, + } + + /// Contains a set of flags that provide additional data used to process the request. + [PInvokeData("ntdsapi.h", MSDNShortId = "158c7e73-0e6c-4b71-a87f-2f60f3db91cb")] + [Flags] + public enum DsReplUpdateOptions + { + /// The operation is performed asynchronously. + DS_REPUPD_ASYNCHRONOUS_OPERATION = 0x00000001, + + /// The reference to the replica added or removed is writable. Otherwise, it is read-only. + DS_REPUPD_WRITEABLE = 0x00000002, + + /// A reference to the destination is added to the source server. + DS_REPUPD_ADD_REFERENCE = 0x00000004, + + /// A reference to the destination is removed from the source server. + DS_REPUPD_DELETE_REFERENCE = 0x00000008, + + /// Use GCSPN while notifying replica partner + DS_REPUPD_REFERENCE_GCSPN = 0x00000010, + } + + /// Contains a set of flags that modify the behavior of the function. + [PInvokeData("ntdsapi.h", MSDNShortId = "d0e139dc-6aaf-47e1-a76f-4e84f17aa7c6")] + [Flags] + public enum DsReplVerifyOptions + { + /// Do not delete objects in response to this function. + DS_EXIST_ADVISORY_MODE = 0x1, + } + + /// Indicates the type of GUID mapped by DsMapSchemaGuids. + [PInvokeData("ntdsapi.h")] + public enum DsSchemaGuidType + { + /// The GUID cannot be found in the directory service schema. + DS_SCHEMA_GUID_NOT_FOUND = 0, + + /// The GUID identifies a property. + DS_SCHEMA_GUID_ATTR = 1, + + /// The GUID identifies a property set. + DS_SCHEMA_GUID_ATTR_SET = 2, + + /// The GUID identifies a type of object. + DS_SCHEMA_GUID_CLASS = 3, + + /// The GUID identifies an extended access right. + DS_SCHEMA_GUID_CONTROL_RIGHT = 4, + } + + /// Defines the type of schedule data that is contained in the structure. + [PInvokeData("schedule.h", MSDNShortId = "5453927e-306e-4442-a855-916005dc8e3b")] + public enum ScheduleType + { + /// + /// + /// The schedule contains a set of intervals. The Offset member contains the offset to an array of bytes with + /// SCHEDULE_DATA_ENTRIES elements. Each byte in the array represents an hour of the week. The first hour is 00:00 on + /// Sunday morning GMT. + /// + /// + /// Each bit of the lower four bits of each byte represents a 15 minute block within the hour that the source is available for + /// replication. The following list lists the binary values and describes each bit of the lower four bits of the hour value. + /// + /// + /// + /// Binary value + /// Description + /// + /// + /// 1000 + /// The source is available for replication from 0 to 14 minutes after the hour. + /// + /// + /// 0100 + /// The source is available for replication from 15 to 29 minutes after the hour. + /// + /// + /// 0010 + /// The source is available for replication from 30 to 44 minutes after the hour. + /// + /// + /// 0001 + /// The source is available for replication from 45 to 59 minutes after the hour. + /// + /// + /// + /// These bits can be combined to create multiple 15 minute blocks that the source is available. For example, a binary value of + /// 0111 indicates that the source is available from 0 to 44 minutes after the hour. + /// + /// The upper fours bits of each byte are not used. + /// + SCHEDULE_INTERVAL = 0, + + /// Not supported. + SCHEDULE_BANDWIDTH = 1, + + /// Not supported. + SCHEDULE_PRIORITY = 2, + } + /// /// /// The DsAddSidHistory function retrieves the primary account security identifier (SID) of a security principal from one @@ -247,59 +992,35 @@ namespace Vanara.PInvoke /// see Using DsAddSidHistory. /// /// - /// - /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. - /// - /// - /// Reserved for future use. Set to NULL. - /// - /// - /// Pointer to a null-terminated string that specifies the name of the domain to query for the SID of SrcPrincipal. + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Reserved for future use. Set to NULL. + /// Pointer to a null-terminated string that specifies the name of the domain to query for the SID of SrcPrincipal. /// /// If the source domain runs on Windows Server operating systems, SrcDomain can be either a domain name system (DNS) name, for /// example, fabrikam.com, or a flat NetBIOS, for example, Fabrikam, name. DNS names should be used when possible. - /// - /// - /// - /// - /// Pointer to a null-terminated string that specifies the name of a security principal, user or group, in the source domain. This - /// name is a domain-relative Security Account Manager (SAM) name, for example: evacorets. - /// - /// - /// - /// + /// + /// Pointer to a null-terminated string that specifies the name of a security principal, user or group, in the source domain. This + /// name is a domain-relative Security Account Manager (SAM) name, for example: evacorets. + /// /// Pointer to a null-terminated string that specifies the name of the primary domain controller (PDC) Emulator in the source domain /// to use for secure retrieval of the source principal SID and audit generation. /// /// If this parameter is NULL, DSBindWithCred will select the primary domain controller. - /// SrcDomainController can be either a DNS name or a flat NetBIOS name. DNS names should be used when possible. - /// - /// - /// + /// SrcDomainController can be either a DNS name or a flat NetBIOS name. DNS names should be used when possible. + /// /// Contains an identity handle that represents the identity and credentials of a user with administrative rights in the source /// domain. To obtain this handle, call DsMakePasswordCredentials. This user must be a member of either the Administrators or the /// Domain Administrators group. If this call is made from a remote computer to the destination DC, then both the remote computer and /// the destination DC must support 128-bit encryption to privacy-protect the credentials. If 128-bit encryption is unavailable and /// SrcDomainCreds are provided, then the call must be made on the destination DC. /// - /// If this parameter is NULL, the credentials of the caller are used for access to the source domain. - /// - /// - /// - /// Pointer to a null-terminated string that specifies the name of the destination domain in which DstPrincipal resides. This name + /// If this parameter is NULL, the credentials of the caller are used for access to the source domain. + /// Pointer to a null-terminated string that specifies the name of the destination domain in which DstPrincipal resides. This name /// can either be a DNS name, for example, fabrikam.com, or a NetBIOS name, for example, Fabrikam. The destination domain must run - /// Windows 2000 native mode. - /// - /// - /// - /// - /// Pointer to a null-terminated string that specifies the name of a security principal, user or group, in the destination domain. - /// This domain-relative SAM name identifies the principal whose sIDHistory attribute is updated with the SID of the SrcPrincipal. - /// - /// - /// - /// Returns a Win32 error codes including the following. - /// + /// Windows 2000 native mode. + /// Pointer to a null-terminated string that specifies the name of a security principal, user or group, in the destination domain. + /// This domain-relative SAM name identifies the principal whose sIDHistory attribute is updated with the SID of the SrcPrincipal. + /// Returns a Win32 error codes including the following. // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsaddsidhistorya NTDSAPI DWORD DsAddSidHistoryA( HANDLE // hDS, DWORD Flags, LPCSTR SrcDomain, LPCSTR SrcPrincipal, LPCSTR SrcDomainController, RPC_AUTH_IDENTITY_HANDLE SrcDomainCreds, // LPCSTR DstDomain, LPCSTR DstPrincipal ); @@ -312,120 +1033,246 @@ namespace Vanara.PInvoke /// The DsBind function binds to a domain controller.DsBind uses the default process credentials to bind to the domain controller. To /// specify alternate credentials, use the DsBindWithCred function. /// + /// Pointer to a null-terminated string that contains the name of the domain controller to bind to. This name can be the name of the + /// domain controller or the fully qualified DNS name of the domain controller. Either name type can, optionally, be preceded by two + /// backslash characters. All of the following examples represent correctly formatted domain controller names: + /// "FAB-DC-01""\\FAB-DC-01""FAB-DC-01.fabrikam.com""\\FAB-DC-01.fabrikam.com"This parameter can be NULL. For more information, see Remarks. + /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind to. This parameter can be + /// NULL. For more information, see Remarks. + /// Address of a HANDLE value that receives the binding handle. To close this handle, pass it to the DsUnBind function. + /// + /// Returns ERROR_SUCCESS if successful or a Windows or RPC error code otherwise. + /// /// /// The behavior of the DsBind function is determined by the contents of the DomainControllerName and DnsDomainName parameters. The /// following list describes the behavior of this function based on the contents of these parameters. - /// - /// - /// DomainControllerName - /// DnsDomainName - /// Description - /// - /// - /// NULL - /// NULL - /// DsBind will attempt to bind to a global catalog server in the forest of the local computer. - /// - /// - /// (value) - /// NULL - /// DsBind will attempt to bind to the domain controller specified by the DomainControllerName parameter. - /// - /// - /// NULL - /// (value) - /// DsBind will attempt to bind to any domain controller in the domain specified by DnsDomainName parameter. - /// - /// - /// (value) - /// (value) - /// + /// DomainControllerNameDnsDomainNameDescriptionNULLNULLDsBind will attempt to bind to a global catalog server in the forest of the local computer.(value)NULLDsBind will attempt to bind to the domain controller specified by the DomainControllerName parameter.NULL(value)DsBind will attempt to bind to any domain controller in the domain specified by DnsDomainName parameter.(value)(value) /// The DomainControllerName parameter takes precedence. DsBind will attempt to bind to the domain controller specified by the /// DomainControllerName parameter. - /// - /// - /// + /// /// - /// - /// Pointer to a null-terminated string that contains the name of the domain controller to bind to. This name can be the name of the - /// domain controller or the fully qualified DNS name of the domain controller. Either name type can, optionally, be preceded by two - /// backslash characters. All of the following examples represent correctly formatted domain controller names: - /// - /// "FAB-DC-01" - /// "\\FAB-DC-01" - /// "FAB-DC-01.fabrikam.com" - /// "\\FAB-DC-01.fabrikam.com" - /// - /// This parameter can be NULL. For more information, see Remarks. - /// - /// - /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind to. This parameter can be - /// NULL. For more information, see Remarks. - /// - /// - /// Address of a HANDLE value that receives the binding handle. To close this handle, pass it to the DsUnBind function. - /// - /// Returns ERROR_SUCCESS if successful or a Windows or RPC error code otherwise. [DllImport(Lib.NTDSApi, CharSet = CharSet.Auto, SetLastError = true)] [PInvokeData("NTDSApi.h", MSDNShortId = "ms675931")] public static extern Win32Error DsBind([Optional] string DomainControllerName, [Optional] string DnsDomainName, out SafeDsHandle phDS); - /// The DsBindByInstance function explicitly binds to any AD LDS or Active Directory instance. - /// - /// (optional)Pointer to a null-terminated string that specifies the name of the instance. This parameter is required to bind to an - /// AD LDS instance. If this parameter is NULL when binding to an Active Directory instance, then the DnsDomainName parameter must - /// contain a value. If this parameter and the DnsDomainName parameter are both NULL, the function fails with the return value - /// ERROR_INVALID_PARAMETER (87). - /// - /// - /// (optional)Pointer to a null-terminated string that specifies the port number of the AD LDS instance or NULL when binding to an + /// + /// The DsBindByInstance function explicitly binds to any AD LDS or Active Directory instance. + /// + /// Pointer to a null-terminated string that specifies the name of the instance. This parameter is required to bind to an AD LDS + /// instance. If this parameter is NULL when binding to an Active Directory instance, then the DnsDomainName parameter must + /// contain a value. If this parameter and the DnsDomainName parameter are both NULL, the function fails with the return value + /// ERROR_INVALID_PARAMETER (87). + /// + /// Pointer to a null-terminated string that specifies the port number of the AD LDS instance or NULL when binding to an /// Active Directory instance. For example, "389". - /// - /// If this parameter is NULL when binding by domain to an Active Directory instance, then the DnsDomainName parameter must be - /// specified. If this parameter is NULL when binding to an AD LDS instance, then the InstanceGuid parameter must be specified. /// - /// - /// - /// (optional)Pointer to a GUID value that contains the GUID of the AD LDS instance. The GUID value is the objectGUID property of the - /// nTDSDSA object of the instance. If this parameter is NULL when binding to an AD LDS instance, the Annotation parameter must be specified. - /// - /// - /// (optional)Pointer to a null-terminated string that specifies the DNS name of the domain when binding to an Active Directory - /// instance by domain. Set this parameter to NULL to bind to an Active Directory instance by server or to an AD LDS instance. - /// - /// - /// (optional)Handle to the credentials used to start the RPC session. Use the DsMakePasswordCredentials function to create a - /// structure suitable for AuthIdentity. - /// - /// - /// (optional)Pointer to a null-terminated string that specifies the Service Principal Name to assign to the client. Passing NULL in - /// ServicePrincipalName is equivalent to a call to the DsBindWithCred function. - /// - /// - /// (optional)Contains a set of flags that define the behavior of this function. This parameter can contain zero or a combination of - /// the values listed in the following table. - /// NTDSAPI_BIND_ALLOW_DELEGATION, NTDSAPI_BIND_FIND_BINDING, NTDSAPI_BIND_FORCE_KERBEROS - /// - /// Address of a DsHandle value that receives the bind handle. To close this handle, call DsUnBind. - /// Returns NO_ERROR if successful or an RPC or Win32 error otherwise. - [DllImport("Ntdsapi.dll", CharSet = CharSet.Auto, EntryPoint = "DsBindByInstance", SetLastError = false, ThrowOnUnmappableChar = true), SuppressUnmanagedCodeSecurity] + /// + /// If this parameter is NULL when binding by domain to an Active Directory instance, then the DnsDomainName parameter must be + /// specified. If this parameter is NULL when binding to an AD LDS instance, then the InstanceGuid parameter must be specified. + /// + /// Pointer to a GUID value that contains the GUID of the AD LDS instance. The GUID value is the + /// objectGUID property of the nTDSDSA object of the instance. If this parameter is NULL when binding to an AD + /// LDS instance, the Annotation parameter must be specified. + /// Pointer to a null-terminated string that specifies the DNS name of the domain when binding to an Active Directory instance by + /// domain. Set this parameter to NULL to bind to an Active Directory instance by server or to an AD LDS instance. + /// Handle to the credentials used to start the RPC session. Use the DsMakePasswordCredentials function to create a structure + /// suitable for AuthIdentity. + /// Pointer to a null-terminated string that specifies the Service Principal Name to assign to the client. Passing NULL in + /// ServicePrincipalName is equivalent to a call to the DsBindWithCred function. + /// + /// Contains a set of flags that define the behavior of this function. This parameter can contain zero or a combination of one or + /// more of the following values. + /// + /// NTDSAPI_BIND_ALLOW_DELEGATION (1) + /// + /// Causes the bind to use the delegate impersonation level. This enables operations that require delegation, such as + /// DsAddSidHistory, to succeed. Specifying this flag also causes DsBindWithSpnEx to operate similar to DsBindWithSpn. + /// + /// + /// If this flag is not specified, the bind will use the impersonate impersonation level. For more information about impersonation + /// levels, see Impersonation Levels. + /// + /// + /// Most operations do not require the delegate impersonation level; this flag should only be specified if it is required. Binding to + /// a rogue server with the delegate impersonation level enables the rogue server to connect to a non-rogue server with your + /// credentials and perform unintended operations. + /// + /// NTDSAPI_BIND_FORCE_KERBEROS (4) + /// + /// Active Directory Lightweight Directory Services: If this flag is specified, DsBindWithSpnEx requires Kerberos + /// authentication to be used. If Kerberos authentication cannot be established, DsBindWithSpnEx will not attempt to + /// authenticate with any other mechanism. + /// + /// Address of a HANDLE value that receives the bind handle. To close this handle, call DsUnBind. + /// + /// Returns NO_ERROR if successful or an RPC or Win32 error otherwise. Possible error codes include those listed in the + /// following list. + /// + /// + /// The following list lists the required parameter values for binding to an instance. + /// + /// + /// Instance + /// ServerName + /// Annotation + /// InstanceGuid + /// DnsDomainName + /// + /// + /// Active Directory by server + /// Server Name + /// NULL + /// NULL + /// NULL + /// + /// + /// Active Directory by domain + /// NULL + /// NULL + /// NULL + /// DNS domain name + /// + /// + /// AD LDS by port + /// DNS Name of the computer with the AD LDS installation. + /// Port Number + /// NULL + /// NULL + /// + /// + /// AD LDS by GUID + /// DNS Name of the computer with the AD LDS installation. + /// NULL + /// Instance GUID + /// NULL + /// + /// + /// + /// Note For improved performance when binding to an AD LDS instance on a computer with several instances of AD LDS, bind by + /// the Instance GUID instead of the port number. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsbindbyinstancea NTDSAPI_POSTXP DWORD DsBindByInstanceA( + // LPCSTR ServerName, LPCSTR Annotation, GUID *InstanceGuid, LPCSTR DnsDomainName, RPC_AUTH_IDENTITY_HANDLE AuthIdentity, LPCSTR + // ServicePrincipalName, DWORD BindFlags, HANDLE *phDS ); + [PInvokeData("ntdsapi.h", MSDNShortId = "65302ddc-2bc0-4d80-b028-e268859be227")] + [DllImport(Lib.NTDSApi, CharSet = CharSet.Auto, EntryPoint = "DsBindByInstance", SetLastError = false, ThrowOnUnmappableChar = true), SuppressUnmanagedCodeSecurity] public static extern Win32Error DsBindByInstance([Optional] string ServerName, [Optional] string Annotation, in Guid InstanceGuid, [Optional] string DnsDomainName, - SafeAuthIdentityHandle AuthIdentity, [Optional] string ServicePrincipalName, DsBindFlags BindFlags, out SafeDsHandle phDS); + SafeAuthIdentityHandle AuthIdentity, [Optional] string ServicePrincipalName, [Optional] DsBindFlags BindFlags, out SafeDsHandle phDS); /// + /// The DsBindByInstance function explicitly binds to any AD LDS or Active Directory instance. + /// + /// Pointer to a null-terminated string that specifies the name of the instance. This parameter is required to bind to an AD LDS + /// instance. If this parameter is NULL when binding to an Active Directory instance, then the DnsDomainName parameter must + /// contain a value. If this parameter and the DnsDomainName parameter are both NULL, the function fails with the return value + /// ERROR_INVALID_PARAMETER (87). + /// + /// Pointer to a null-terminated string that specifies the port number of the AD LDS instance or NULL when binding to an + /// Active Directory instance. For example, "389". + /// /// + /// If this parameter is NULL when binding by domain to an Active Directory instance, then the DnsDomainName parameter must be + /// specified. If this parameter is NULL when binding to an AD LDS instance, then the InstanceGuid parameter must be specified. + /// + /// Pointer to a GUID value that contains the GUID of the AD LDS instance. The GUID value is the + /// objectGUID property of the nTDSDSA object of the instance. If this parameter is NULL when binding to an AD + /// LDS instance, the Annotation parameter must be specified. + /// Pointer to a null-terminated string that specifies the DNS name of the domain when binding to an Active Directory instance by + /// domain. Set this parameter to NULL to bind to an Active Directory instance by server or to an AD LDS instance. + /// Handle to the credentials used to start the RPC session. Use the DsMakePasswordCredentials function to create a structure + /// suitable for AuthIdentity. + /// Pointer to a null-terminated string that specifies the Service Principal Name to assign to the client. Passing NULL in + /// ServicePrincipalName is equivalent to a call to the DsBindWithCred function. + /// + /// Contains a set of flags that define the behavior of this function. This parameter can contain zero or a combination of one or + /// more of the following values. + /// + /// NTDSAPI_BIND_ALLOW_DELEGATION (1) + /// + /// Causes the bind to use the delegate impersonation level. This enables operations that require delegation, such as + /// DsAddSidHistory, to succeed. Specifying this flag also causes DsBindWithSpnEx to operate similar to DsBindWithSpn. + /// + /// + /// If this flag is not specified, the bind will use the impersonate impersonation level. For more information about impersonation + /// levels, see Impersonation Levels. + /// + /// + /// Most operations do not require the delegate impersonation level; this flag should only be specified if it is required. Binding to + /// a rogue server with the delegate impersonation level enables the rogue server to connect to a non-rogue server with your + /// credentials and perform unintended operations. + /// + /// NTDSAPI_BIND_FORCE_KERBEROS (4) + /// + /// Active Directory Lightweight Directory Services: If this flag is specified, DsBindWithSpnEx requires Kerberos + /// authentication to be used. If Kerberos authentication cannot be established, DsBindWithSpnEx will not attempt to + /// authenticate with any other mechanism. + /// + /// Address of a HANDLE value that receives the bind handle. To close this handle, call DsUnBind. + /// + /// Returns NO_ERROR if successful or an RPC or Win32 error otherwise. Possible error codes include those listed in the + /// following list. + /// + /// + /// The following list lists the required parameter values for binding to an instance. + /// + /// + /// Instance + /// ServerName + /// Annotation + /// InstanceGuid + /// DnsDomainName + /// + /// + /// Active Directory by server + /// Server Name + /// NULL + /// NULL + /// NULL + /// + /// + /// Active Directory by domain + /// NULL + /// NULL + /// NULL + /// DNS domain name + /// + /// + /// AD LDS by port + /// DNS Name of the computer with the AD LDS installation. + /// Port Number + /// NULL + /// NULL + /// + /// + /// AD LDS by GUID + /// DNS Name of the computer with the AD LDS installation. + /// NULL + /// Instance GUID + /// NULL + /// + /// + /// + /// Note For improved performance when binding to an AD LDS instance on a computer with several instances of AD LDS, bind by + /// the Instance GUID instead of the port number. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsbindbyinstancea NTDSAPI_POSTXP DWORD DsBindByInstanceA( + // LPCSTR ServerName, LPCSTR Annotation, GUID *InstanceGuid, LPCSTR DnsDomainName, RPC_AUTH_IDENTITY_HANDLE AuthIdentity, LPCSTR + // ServicePrincipalName, DWORD BindFlags, HANDLE *phDS ); + [PInvokeData("ntdsapi.h", MSDNShortId = "65302ddc-2bc0-4d80-b028-e268859be227")] + [DllImport(Lib.NTDSApi, CharSet = CharSet.Auto, EntryPoint = "DsBindByInstance", SetLastError = false, ThrowOnUnmappableChar = true), SuppressUnmanagedCodeSecurity] + public static extern Win32Error DsBindByInstance([Optional] string ServerName, [Optional] string Annotation, [Optional] IntPtr InstanceGuid, [Optional] string DnsDomainName, + SafeAuthIdentityHandle AuthIdentity, [Optional] string ServicePrincipalName, [Optional] DsBindFlags BindFlags, out SafeDsHandle phDS); + + /// /// The DsBindingSetTimeout function sets the timeout value that is honored by all RPC calls that use the specified binding /// handle. RPC calls that required more time than the timeout value are canceled. - /// /// - /// - /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. - /// - /// - /// Contains the new timeout value, in seconds. - /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Contains the new timeout value, in seconds. /// - /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error code otherwise. The following is a possible error code. + /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error code otherwise. The following is a possible error code. /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsbindingsettimeout NTDSAPI_POSTXP DWORD // DsBindingSetTimeout( HANDLE hDS, ULONG cTimeoutSecs ); @@ -434,55 +1281,37 @@ namespace Vanara.PInvoke public static extern Win32Error DsBindingSetTimeout(SafeDsHandle hDS, uint cTimeoutSecs); /// - /// /// The DsBindToISTG function binds to the computer that holds the Inter-Site Topology Generator (ISTG) role in the domain of /// the local computer. - /// /// - /// - /// - /// Pointer to a null-terminated string that contains the site name used when binding. If this parameter is NULL, the site of - /// the nearest domain controller is used. - /// - /// - /// - /// Address of a HANDLE value that receives the bind handle. To close this handle, call DsUnBind. - /// + /// Pointer to a null-terminated string that contains the site name used when binding. If this parameter is NULL, the site of + /// the nearest domain controller is used. + /// Address of a HANDLE value that receives the bind handle. To close this handle, call DsUnBind. /// - /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error code otherwise. The following are possible error codes. + /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error code otherwise. The following are possible error codes. /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsbindtoistga NTDSAPI_POSTXP DWORD DsBindToISTGA( LPCSTR // SiteName, HANDLE *phDS ); [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("ntdsapi.h", MSDNShortId = "bd53124c-8578-495d-b540-d4b4c09297c3")] - public static extern Win32Error DsBindToISTG(string SiteName, out SafeDsHandle phDS); + public static extern Win32Error DsBindToISTG([Optional] string SiteName, out SafeDsHandle phDS); - /// The DsBindWithCred function binds to a domain controller using the specified credentials. - /// - /// Pointer to a null-terminated string that contains the name of the domain controller to bind to. This name can be the name of the + /// + /// The DsBindWithCred function binds to a domain controller using the specified credentials. + /// + /// Pointer to a null-terminated string that contains the name of the domain controller to bind to. This name can be the name of the /// domain controller or the fully qualified DNS name of the domain controller. Either name type can, optionally, be preceded by two /// backslash characters. All of the following examples represent correctly formatted domain controller names: - /// - /// "FAB-DC-01" - /// "\\FAB-DC-01" - /// "FAB-DC-01.fabrikam.com" - /// "\\FAB-DC-01.fabrikam.com" - /// - /// This parameter can be NULL. For more information, see Remarks. - /// - /// - /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind to. This parameter can be - /// NULL. For more information, see Remarks. - /// - /// - /// Contains an RPC_AUTH_IDENTITY_HANDLE value that represents the credentials to be used for the bind. The DsMakePasswordCredentials + /// "FAB-DC-01""\\FAB-DC-01""FAB-DC-01.fabrikam.com""\\FAB-DC-01.fabrikam.com"This parameter can be NULL. For more information, see Remarks. + /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind to. This parameter can be + /// NULL. For more information, see Remarks. + /// Contains an RPC_AUTH_IDENTITY_HANDLE value that represents the credentials to be used for the bind. The DsMakePasswordCredentials /// function is used to obtain this value. If this parameter is NULL, the credentials of the calling thread are used. - /// DsUnBind must be called before freeing this handle with the DsFreePasswordCredentials function. - /// - /// - /// Address of a HANDLE value that receives the binding handle. To close this handle, pass it to the DsUnBind function. - /// - /// Returns ERROR_SUCCESS if successful or a Windows or RPC error code otherwise. + /// DsUnBind must be called before freeing this handle with the DsFreePasswordCredentials function. + /// Address of a HANDLE value that receives the binding handle. To close this handle, pass it to the DsUnBind function. + /// + /// Returns ERROR_SUCCESS if successful or a Windows or RPC error code otherwise. + /// [DllImport(Lib.NTDSApi, CharSet = CharSet.Auto, SetLastError = true)] [PInvokeData("NTDSApi.h", MSDNShortId = "ms675961")] public static extern Win32Error DsBindWithCred([Optional] string DomainControllerName, [Optional] string DnsDomainName, SafeAuthIdentityHandle AuthIdentity, out SafeDsHandle phDS); @@ -499,45 +1328,27 @@ namespace Vanara.PInvoke /// is identical to DsBindWithCred. /// /// - /// - /// - /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind to. For more information, - /// see the DomainControllerName description in the DsBind topic. - /// - /// - /// - /// - /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind to. For more information, - /// see the DnsDomainName description in the DsBind topic. - /// - /// - /// - /// Contains an RPC_AUTH_IDENTITY_HANDLE value that represents the credentials to be used for the bind. The + /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind to. For more information, + /// see the DomainControllerName description in the DsBind topic. + /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind to. For more information, + /// see the DnsDomainName description in the DsBind topic. + /// Contains an RPC_AUTH_IDENTITY_HANDLE value that represents the credentials to be used for the bind. The /// /// DsMakePasswordCredentialsfunction is used to obtain this value. If this parameter is NULL, the credentials of the calling /// thread are used. /// - /// DsUnBind must be called before freeing this handle with the DsFreePasswordCredentials function. - /// - /// - /// - /// Pointer to a null-terminated string that specifies the Service Principal Name to assign to the client. Passing NULL in - /// ServicePrincipalName is equivalent to a call to the DsBindWithCred function. - /// - /// - /// - /// Address of a HANDLE value that receives the binding handle. To close this handle, pass it to the DsUnBind function. - /// + /// DsUnBind must be called before freeing this handle with the DsFreePasswordCredentials function. + /// Pointer to a null-terminated string that specifies the Service Principal Name to assign to the client. Passing NULL in + /// ServicePrincipalName is equivalent to a call to the DsBindWithCred function. + /// Address of a HANDLE value that receives the binding handle. To close this handle, pass it to the DsUnBind function. /// - /// /// Returns ERROR_SUCCESS if successful or a Windows or RPC error code otherwise. The following are the most common error codes. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsbindwithspnw NTDSAPI DWORD DsBindWithSpnW( LPCWSTR // DomainControllerName, LPCWSTR DnsDomainName, RPC_AUTH_IDENTITY_HANDLE AuthIdentity, LPCWSTR ServicePrincipalName, HANDLE *phDS ); [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("ntdsapi.h", MSDNShortId = "9a149654-fd94-4b0c-b712-07fb827bef2f")] - public static extern Win32Error DsBindWithSpn([Optional] string DomainControllerName, [Optional] string DnsDomainName, SafeAuthIdentityHandle AuthIdentity, string ServicePrincipalName, out SafeDsHandle phDS); + public static extern Win32Error DsBindWithSpn([Optional] string DomainControllerName, [Optional] string DnsDomainName, SafeAuthIdentityHandle AuthIdentity, [Optional] string ServicePrincipalName, out SafeDsHandle phDS); /// /// @@ -552,34 +1363,19 @@ namespace Vanara.PInvoke /// identical to DsBindWithCred. /// /// - /// - /// - /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind. For more information, see - /// the DomainControllerName description in the DsBind topic. - /// - /// - /// - /// - /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind. For more information, see - /// the DnsDomainName description in the DsBind topic. - /// - /// - /// - /// Contains an RPC_AUTH_IDENTITY_HANDLE value that represents the credentials to be used for the bind. The + /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind. For more information, see + /// the DomainControllerName description in the DsBind topic. + /// Pointer to a null-terminated string that contains the fully qualified DNS name of the domain to bind. For more information, see + /// the DnsDomainName description in the DsBind topic. + /// Contains an RPC_AUTH_IDENTITY_HANDLE value that represents the credentials to be used for the bind. The /// /// DsMakePasswordCredentialsfunction is used to obtain this value. If this parameter is NULL, the credentials of the calling /// thread are used. /// - /// DsUnBind must be called before freeing this handle with the DsFreePasswordCredentials function. - /// - /// - /// - /// Pointer to a null-terminated string that specifies the Service Principal Name to assign to the client. Passing NULL in - /// ServicePrincipalName is equivalent to a call to the DsBindWithCred function. - /// - /// - /// - /// + /// DsUnBind must be called before freeing this handle with the DsFreePasswordCredentials function. + /// Pointer to a null-terminated string that specifies the Service Principal Name to assign to the client. Passing NULL in + /// ServicePrincipalName is equivalent to a call to the DsBindWithCred function. + /// /// Contains a set of flags that define the behavior of this function. This parameter can contain zero or a combination of the values /// listed in the following list. /// @@ -600,41 +1396,29 @@ namespace Vanara.PInvoke /// Reserved. /// NTDSAPI_BIND_FORCE_KERBEROS (4) /// - /// Active Directory Lightweight Directory Services: If this flag is specified, DsBindWithSpnEx forces Kerberos + /// Active Directory Lightweight Directory Services: If this flag is specified, DsBindWithSpnEx forces Kerberos /// authentication to be used. If Kerberos authentication cannot be established, DsBindWithSpnEx will not attempt to /// authenticate with any other method. - /// - /// - /// - /// Address of a HANDLE value that receives the binding handle. To close this handle, pass it to the DsUnBind function. - /// + /// + /// Address of a HANDLE value that receives the binding handle. To close this handle, pass it to the DsUnBind function. /// - /// /// Returns ERROR_SUCCESS if successful or a Windows or RPC error code otherwise. The following list lists common error codes. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsbindwithspnexw NTDSAPI_POSTXP DWORD DsBindWithSpnExW( // LPCWSTR DomainControllerName, LPCWSTR DnsDomainName, RPC_AUTH_IDENTITY_HANDLE AuthIdentity, LPCWSTR ServicePrincipalName, DWORD // BindFlags, HANDLE *phDS ); [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("ntdsapi.h", MSDNShortId = "52a5761d-5244-4bc9-8c09-fd08f10a9fff")] - public static extern Win32Error DsBindWithSpnEx([Optional] string DomainControllerName, [Optional] string DnsDomainName, SafeAuthIdentityHandle AuthIdentity, string ServicePrincipalName, + public static extern Win32Error DsBindWithSpnEx([Optional] string DomainControllerName, [Optional] string DnsDomainName, SafeAuthIdentityHandle AuthIdentity, [Optional] string ServicePrincipalName, DsBindFlags BindFlags, out SafeDsHandle phDS); /// - /// /// The DsClientMakeSpnForTargetServer function constructs a service principal name (SPN) that identifies a specific server to /// use for authentication. - /// /// - /// - /// - /// Pointer to a null-terminated string that contains the class of the service as defined by the service. This can be any string - /// unique to the service. - /// - /// - /// - /// + /// Pointer to a null-terminated string that contains the class of the service as defined by the service. This can be any string + /// unique to the service. + /// /// Pointer to a null-terminated string that contains the distinguished name service (DNS) host name. This can either be a fully /// qualified name or an IP address in the Internet standard format. /// @@ -642,20 +1426,11 @@ namespace Vanara.PInvoke /// Use of an IP address for ServiceName is not recommended because this can create a security issue. Before the SPN is constructed, /// the IP address must be translated to a computer name through DNS name resolution. It is possible for the DNS name resolution to /// be spoofed, replacing the intended computer name with an unauthorized computer name. - /// - /// - /// - /// - /// Pointer to a DWORD value that, on entry, contains the size of the pszSpn buffer, in characters. On output, this parameter - /// receives the number of characters copied to the pszSpn buffer, including the terminating NULL. - /// - /// - /// - /// Pointer to a string buffer that receives the SPN. - /// - /// - /// This function returns standard Windows error codes. - /// + /// + /// Pointer to a DWORD value that, on entry, contains the size of the pszSpn buffer, in characters. On output, this parameter + /// receives the number of characters copied to the pszSpn buffer, including the terminating NULL. + /// Pointer to a string buffer that receives the SPN. + /// This function returns standard Windows error codes. /// /// When using this function, supply the service class and part of a DNS host name. /// @@ -675,40 +1450,32 @@ namespace Vanara.PInvoke /// client applications to map between the multiple names used to identify various directory service objects. For example, user /// objects can be identified by SAM account names (Domain\UserName), user principal name (UserName@Domain.com), or distinguished /// name. This function uses many handles and memory allocations that can be unwieldy. It is recommended to use the - /// method instead. + /// method instead. /// - /// - /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. If flags contains - /// DS_NAME_FLAG_SYNTACTICAL_ONLY, hDS can be NULL. - /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. If flags contains + /// DS_NAME_FLAG_SYNTACTICAL_ONLY, hDS can be NULL. /// Contains one or more of the DS_NAME_FLAGS values used to determine how the name syntax will be cracked. /// Contains one of the DS_NAME_FORMAT values that identifies the format of the input names. - /// - /// Contains one of the DS_NAME_FORMAT values that identifies the format of the output names. The DS_SID_OR_SID_HISTORY_NAME value is - /// not supported. - /// + /// Contains one of the DS_NAME_FORMAT values that identifies the format of the output names. The DS_SID_OR_SID_HISTORY_NAME value is + /// not supported. /// Contains the number of elements in the rpNames array. /// Pointer to an array of pointers to null-terminated strings that contain names to be converted. - /// - /// Pointer to a PDS_NAME_RESULT value that receives a DS_NAME_RESULT structure that contains the converted names. The caller must - /// free this memory, when it is no longer required, by calling DsFreeNameResult. - /// - /// Returns a Win32 error value, an RPC error value, or one of the following. + /// Pointer to a PDS_NAME_RESULT value that receives a DS_NAME_RESULT structure that contains the converted names. The caller must + /// free this memory, when it is no longer required, by calling DsFreeNameResult. + /// + /// Returns a Win32 error value, an RPC error value, or one of the following. + /// [DllImport(Lib.NTDSApi, CharSet = CharSet.Auto, SetLastError = true)] [PInvokeData("NTDSApi.h", MSDNShortId = "ms675970")] public static extern Win32Error DsCrackNames(SafeDsHandle hSafeDs, DS_NAME_FLAGS flags, DS_NAME_FORMAT formatOffered, DS_NAME_FORMAT formatDesired, uint cNames, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPTStr, SizeParamIndex = 4)] string[] rpNames, out SafeDsNameResult ppResult); /// A wrapper function for the DsCrackNames OS call - /// - /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. If flags contains - /// DS_NAME_FLAG_SYNTACTICAL_ONLY, hDS can be NULL. - /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. If flags contains + /// DS_NAME_FLAG_SYNTACTICAL_ONLY, hDS can be NULL. /// The names to be converted. - /// - /// Contains one of the DS_NAME_FORMAT values that identifies the format of the output names. The DS_SID_OR_SID_HISTORY_NAME value is - /// not supported. - /// + /// Contains one of the DS_NAME_FORMAT values that identifies the format of the output names. The DS_SID_OR_SID_HISTORY_NAME value is + /// not supported. /// Contains one of the DS_NAME_FORMAT values that identifies the format of the input names. /// Contains one or m ore of the DS_NAME_FLAGS values used to determine how the name syntax will be cracked. /// The crack results. @@ -724,30 +1491,19 @@ namespace Vanara.PInvoke } /// - /// /// The DsFreeDomainControllerInfo function frees memory that is allocated by DsGetDomainControllerInfo for data about the /// domain controllers in a domain. - /// /// - /// - /// + /// /// Indicates what version of the DS_DOMAIN_CONTROLLER_INFO structure should be freed. This parameter can be one of the /// following values. /// /// 1 /// The function frees the structure that contains DS_DOMAIN_CONTROLLER_INFO_1 data. /// 2 - /// The function frees the structure that contains DS_DOMAIN_CONTROLLER_INFO_2 data. - /// - /// - /// Indicates the number of items in pInfo. - /// - /// - /// Pointer to an array of DS_DOMAIN_CONTROLLER_INFO structures to be freed. - /// - /// - /// This function does not return a value. - /// + /// The function frees the structure that contains DS_DOMAIN_CONTROLLER_INFO_2 data. + /// Indicates the number of items in pInfo. + /// Pointer to an array of DS_DOMAIN_CONTROLLER_INFO structures to be freed. // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsfreedomaincontrollerinfoa NTDSAPI VOID // DsFreeDomainControllerInfoA( DWORD InfoLevel, DWORD cInfo, VOID *pInfo ); [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] @@ -763,24 +1519,29 @@ namespace Vanara.PInvoke [PInvokeData("NTDSApi.h", MSDNShortId = "ms675978")] public static extern void DsFreeNameResult(IntPtr pResult); - /// Frees memory allocated for a credentials structure by the DsMakePasswordCredentials function. + /// + /// Frees memory allocated for a credentials structure by the DsMakePasswordCredentials function. + /// /// Handle of the credential structure to be freed. [DllImport(Lib.NTDSApi, ExactSpelling = true)] [PInvokeData("NTDSApi.h", MSDNShortId = "ms675979")] public static extern void DsFreePasswordCredentials(IntPtr AuthIdentity); /// - /// The DsFreeSpnArray function frees an array returned from the DsGetSpn function. + /// The DsFreeSchemaGuidMap function frees memory that the DsMapSchemaGuids function has allocated for a DS_SCHEMA_GUID_MAP structure. /// - /// - /// Specifies the number of elements contained in rpszSpn. - /// - /// - /// Pointer to an array returned from DsGetSpn. - /// - /// - /// This function does not return a value. - /// + /// Pointer to a DS_SCHEMA_GUID_MAP structure to deallocate. + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsfreeschemaguidmapa NTDSAPI VOID DsFreeSchemaGuidMapA( + // PDS_SCHEMA_GUID_MAPA pGuidMap ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "54d6acb9-5602-4996-a483-08534143bc0a")] + public static extern void DsFreeSchemaGuidMap(IntPtr pGuidMap); + + /// + /// The DsFreeSpnArray function frees an array returned from the DsGetSpn function. + /// + /// Specifies the number of elements contained in rpszSpn. + /// Pointer to an array returned from DsGetSpn. // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsfreespnarraya void DsFreeSpnArrayA( DWORD cSpn, LPSTR // *rpszSpn ); [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] @@ -788,16 +1549,11 @@ namespace Vanara.PInvoke public static extern void DsFreeSpnArray(uint cSpn, ref SpnArrayHandle rpszSpn); /// - /// The DsGetDomainControllerInfo function retrieves data about the domain controllers in a domain. + /// The DsGetDomainControllerInfo function retrieves data about the domain controllers in a domain. /// - /// - /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. - /// - /// - /// Pointer to a null-terminated string that specifies the domain name. - /// - /// - /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a null-terminated string that specifies the domain name. + /// /// Contains a value that indicates the version of the DS_DOMAIN_CONTROLLER_INFO structure to return. This can be one of the /// following values. /// @@ -806,18 +1562,11 @@ namespace Vanara.PInvoke /// 2 /// The function provides the domain data in the DS_DOMAIN_CONTROLLER_INFO_2 structure format. /// 3 - /// The function provides the domain data in the DS_DOMAIN_CONTROLLER_INFO_3 structure format. - /// - /// - /// Pointer to a DWORD variable that receives the number of items returned in ppInfo array. - /// - /// - /// - /// Pointer to a pointer variable that receives an array of DS_DOMAIN_CONTROLLER_INFO_* structures. The type of structures in + /// The function provides the domain data in the DS_DOMAIN_CONTROLLER_INFO_3 structure format. + /// Pointer to a DWORD variable that receives the number of items returned in ppInfo array. + /// Pointer to a pointer variable that receives an array of DS_DOMAIN_CONTROLLER_INFO_* structures. The type of structures in /// this array is defined by the InfoLevel parameter. The caller must free this array, when it is no longer required, by using the - /// DsFreeDomainControllerInfo function. - /// - /// + /// DsFreeDomainControllerInfo function. /// /// /// If the function returns domain controller data, the return value is ERROR_SUCCESS. If the caller does not have the @@ -833,13 +1582,44 @@ namespace Vanara.PInvoke public static extern Win32Error DsGetDomainControllerInfo(SafeDsHandle hDs, string DomainName, uint InfoLevel, out uint pcOut, out DCInfoHandle ppInfo); /// - /// + /// The DsGetDomainControllerInfo function retrieves data about the domain controllers in a domain. + /// + /// The type of the DS_DOMAIN_CONTROLLER_INFO_X structure to return. + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a null-terminated string that specifies the domain name. + /// + /// An array of returned by a call to the native DsGetDomainControllerInfo function. + /// + /// Unable to determine level from requested type. + public static T[] DsGetDomainControllerInfo(SafeDsHandle hDs, string DomainName) where T : struct, IDsGetDCResult + { + uint level = 0, cout = 0; + DCInfoHandle h = default; + try + { + level = uint.Parse(typeof(T).Name.Substring(typeof(T).Name.LastIndexOf('_') + 1)); + } + catch + { + throw new ArgumentException("Unable to determine level from requested type."); + } + try + { + DsGetDomainControllerInfo(hDs, DomainName, level, out cout, out h).ThrowIfFailed(); + return h.ToIEnum(cout).ToArray(); + } + finally + { + if (!h.IsNull) + DsFreeDomainControllerInfo(level, cout, h); + } + } + + /// /// The DsGetSpn function constructs an array of one or more service principal names (SPNs). Each name in the array identifies /// an instance of a service. These SPNs may be registered with the directory service (DS) using the DsWriteAccountSpn function. - /// /// - /// - /// Identifies the format of the SPNs to compose. The ServiceType parameter can have one of the following values. + /// Identifies the format of the SPNs to compose. The ServiceType parameter can have one of the following values. /// DS_SPN_DNS_HOST, DS_SPN_DN_HOST, DS_SPN_NB_HOST /// The SPNs have the following format. /// The @@ -864,76 +1644,53 @@ namespace Vanara.PInvoke /// /// parameter must be a canonical DN or DNS name that identifies an instance of the service. For example, it could be a DNS name of a /// SRV record, or the distinguished name of the service connection point for this service instance. - /// - /// - /// - /// - /// Pointer to a constant null-terminated string that specifies the class of the service; for example, http. Generally, this can be - /// any string that is unique to the service. - /// - /// - /// - /// - /// Pointer to a constant null-terminated string that specifies the DNS name or distinguished name (DN) of the service. ServiceName + /// + /// Pointer to a constant null-terminated string that specifies the class of the service; for example, http. Generally, this can be + /// any string that is unique to the service. + /// Pointer to a constant null-terminated string that specifies the DNS name or distinguished name (DN) of the service. ServiceName /// is not required for a host-based service. For more information, see the description of the ServiceType parameter for the possible - /// values of ServiceName. - /// - /// - /// - /// Specifies the port number of the service instance. If this value is zero, the SPN does not include a port number. - /// - /// - /// - /// Specifies the number of elements in the pInstanceNames and pInstancePorts arrays. If this value is zero, pInstanceNames must + /// values of ServiceName. + /// Specifies the port number of the service instance. If this value is zero, the SPN does not include a port number. + /// Specifies the number of elements in the pInstanceNames and pInstancePorts arrays. If this value is zero, pInstanceNames must /// point to an array of cInstanceNames strings, and pInstancePorts can be either NULL or a pointer to an array of /// cInstanceNames port numbers. If this value is zero, DsGetSpn returns only one SPN in the prpszSpn array and pInstanceNames - /// and pInstancePorts are ignored. - /// - /// - /// - /// - /// Pointer to an array of null-terminated strings that specify extra instance names (not used for host names). This parameter is + /// and pInstancePorts are ignored. + /// Pointer to an array of null-terminated strings that specify extra instance names (not used for host names). This parameter is /// ignored if cInstanceNames is zero. In that case, the InstanceName component of the SPN defaults to the fully qualified DNS name - /// of the local computer or the NetBIOS name if DS_SPN_NB_HOST or DS_SPN_NB_DOMAIN is specified. - /// - /// - /// - /// - /// Pointer to an array of extra instance ports. If this value is non- NULL, it must point to an array of cInstanceNames port - /// numbers. If this value is NULL, the SPNs do not include a port number. This parameter is ignored if cInstanceNames is zero. - /// - /// - /// - /// Pointer to a variable that receives the number of SPNs contained in prpszSpn. - /// - /// - /// Pointer to a variable that receives a pointer to an array of SPNs. This array must be freed with DsFreeSpnArray. - /// + /// of the local computer or the NetBIOS name if DS_SPN_NB_HOST or DS_SPN_NB_DOMAIN is specified. + /// Pointer to an array of extra instance ports. If this value is non- NULL, it must point to an array of cInstanceNames port + /// numbers. If this value is NULL, the SPNs do not include a port number. This parameter is ignored if cInstanceNames is zero. + /// Pointer to a variable that receives the number of SPNs contained in prpszSpn. + /// Pointer to a variable that receives a pointer to an array of SPNs. This array must be freed with DsFreeSpnArray. /// /// If the function returns an array of SPNs, the return value is ERROR_SUCCESS. /// If the function fails, the return value can be one of the following error codes. /// /// - /// To create SPNs for multiple instances of a replicated service running on multiple host computers + /// + /// To create SPNs for multiple instances of a replicated service running on multiple host computers + /// /// - /// - /// Set cInstanceNames to the number of instances. - /// - /// - /// Specify the names of the host computers in the pInstanceNames array. - /// + /// + /// Set cInstanceNames to the number of instances. + /// + /// + /// Specify the names of the host computers in the pInstanceNames array. + /// /// - /// To create SPNs for multiple instances of a service running on the same host computer + /// + /// To create SPNs for multiple instances of a service running on the same host computer + /// /// - /// - /// Set the cInstanceNames to the number of instances. - /// - /// - /// Set each entry in the pInstanceNames array to the DNS name of the host computer. - /// - /// - /// Use the pInstancePorts parameter to specify an array of unique port numbers for each instance to disambiguate the SPNs. - /// + /// + /// Set the cInstanceNames to the number of instances. + /// + /// + /// Set each entry in the pInstanceNames array to the DNS name of the host computer. + /// + /// + /// Use the pInstancePorts parameter to specify an array of unique port numbers for each instance to disambiguate the SPNs. + /// /// /// String parameters cannot include the forward slash (/), which is used to separate the components of the SPN. /// @@ -942,14 +1699,248 @@ namespace Vanara.PInvoke /// to authenticate the service. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsgetspna - // NTDSAPI DWORD DsGetSpnA( DS_SPN_NAME_TYPE ServiceType, LPCSTR ServiceClass, LPCSTR ServiceName, USHORT InstancePort, USHORT cInstanceNames, LPCSTR *pInstanceNames, const USHORT *pInstancePorts, DWORD *pcSpn, LPSTR **prpszSpn ); + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsgetspna NTDSAPI DWORD DsGetSpnA( DS_SPN_NAME_TYPE + // ServiceType, LPCSTR ServiceClass, LPCSTR ServiceName, USHORT InstancePort, USHORT cInstanceNames, LPCSTR *pInstanceNames, const + // USHORT *pInstancePorts, DWORD *pcSpn, LPSTR **prpszSpn ); [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("ntdsapi.h", MSDNShortId = "cbd53850-9b05-4f74-ab07-30dcad583fc5")] public static extern Win32Error DsGetSpn(DS_SPN_NAME_TYPE ServiceType, string ServiceClass, string ServiceName, ushort InstancePort, ushort cInstanceNames, string[] pInstanceNames, ushort[] pInstancePorts, ref uint pcSpn, out SpnArrayHandle prpszSpn); - /// Constructs a credential handle suitable for use with the DsBindWithCred function. + /// + /// The DsInheritSecurityIdentity function appends the objectSid and sidHistory attributes of SrcPrincipal to + /// the sidHistory of DstPrincipal and then deletes SrcPrincipal, all in a single transaction. To ensure that this operation + /// is atomic, SrcPrincipal and DstPrincipal must be in the same domain and hDS must be bound to a domain controller that the correct + /// permissions within that domain. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Reserved for future use. Must be zero. + /// Pointer to a null-terminated string that specifies the name of a security principal (user or group) in the source domain. This + /// name is a domain-relative SAM name. + /// Pointer to a null-terminated string that specifies the name of a security principal (user or group) in the destination domain. + /// This domain-relative SAM name identifies the principal whose sidHistory attribute will be updated with the SID of SrcPrincipal. + /// Returns a system or RPC error code including the following. + /// + /// + /// With an operating system upgrade domain applications, which span both upgraded and non-upgraded domains, may have security + /// principals inside and outside the forest for the same logical entity at the same time. + /// + /// + /// When all upgraded domains have joined the same forest, DsInheritSecurityIdentity eliminates the duplicate objects while + /// ensuring that the remaining objects have all the security rights and privileges belonging to their respective deleted object. + /// + /// A DsInheritSecurityIdentity implementation: + /// + /// + /// Verifies that SrcPrincipal and DstPrincipal are in the same domain. + /// + /// + /// Verifies that the domain is writable at the bind to the server. + /// + /// + /// Verifies that auditing is enabled for the domain. + /// + /// + /// Verifies that the caller is a member of the domain administrators for the domain. + /// + /// + /// Verifies that the domain is in the native mode. + /// + /// + /// + /// Verifies that SrcPrincipal exists, that it is a security principal and has read its objectSid and sidHistory properties. + /// + /// + /// + /// + /// Verifies that DstPrincipal exists, that it is a security principal, and has read certain properties required for auditing and verification. + /// + /// + /// + /// + /// Deletes SrcPrincipal in the database only if the entire operation is committed at completion. This operation fails if the caller + /// does not have delete rights or if SrcPrincipal has children. + /// + /// + /// + /// Fails the operation if the objectSid of SrcPrincipal or DstPrincipal is a well-known SID. + /// + /// + /// Adds the objectSid and the sidHistory (if present) of SrcPrincipal to the sidHistory of DstPrincipal. + /// + /// + /// Forces an audit event and fails the operation if the audit fails. + /// + /// + /// Enters events into the Directory Service Log. Do not confuse this with the Security Audit Log. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsinheritsecurityidentitya NTDSAPI DWORD + // DsInheritSecurityIdentityA( HANDLE hDS, DWORD Flags, LPCSTR SrcPrincipal, LPCSTR DstPrincipal ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "ea467069-f886-4e22-896c-16e6e01f3968")] + public static extern Win32Error DsInheritSecurityIdentity(SafeDsHandle hDS, [Optional] uint Flags, string SrcPrincipal, string DstPrincipal); + + /// + /// The DsListDomainsInSite function lists all the domains in a site. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a null-terminated string that specifies the site name. This string is taken from the list of site names returned by + /// the DsListSites function. + /// Pointer to a pointer to a DS_NAME_RESULT structure that receives the list of domains in the site. To free the returned structure, + /// call the DsFreeNameResult function. + /// + /// If the function returns a list of domains, the return value is NO_ERROR. If the function fails, the return value can be + /// one of the following error codes. + /// + /// + /// Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dslistdomainsinsitea NTDSAPI DWORD DsListDomainsInSiteA( + // HANDLE hDs, LPCSTR site, PDS_NAME_RESULTA *ppDomains ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "3a039c0c-ac5b-4455-960d-b26a207693ed")] + public static extern Win32Error DsListDomainsInSite(SafeDsHandle hDs, string site, out SafeDsNameResult ppDomains); + + /// + /// The DsListInfoForServer function lists miscellaneous data for a server. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a null-terminated string that specifies the server name. This name must be the same as one of the strings returned by + /// the DsListServersForDomainInSite or DsListServersInSite function. + /// + /// Pointer to a variable that receives a pointer to a DS_NAME_RESULT structure that contains the server data. The returned structure + /// must be deallocated using DsFreeNameResult. + /// + /// + /// The indexes of the array in the DS_NAME_RESULT structure indicate what data are contained by each array element. The following + /// constants may be used to specify the desired index for a particular piece of data. + /// + /// DS_LIST_ACCOUNT_OBJECT_FOR_SERVER + /// Name of the account object for the domain controller (DC). + /// DS_LIST_DNS_HOST_NAME_FOR_SERVER + /// DNS host name of the DC. + /// DS_LIST_DSA_OBJECT_FOR_SERVER + /// GUID of the directory service agent (DSA) for the domain controller (DC). + /// + /// If the function returns server data, the return value is NO_ERROR. + /// If the function fails, the return value can be one of the following error codes. + /// + /// + /// Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dslistinfoforservera NTDSAPI DWORD DsListInfoForServerA( + // HANDLE hDs, LPCSTR server, PDS_NAME_RESULTA *ppInfo ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "15dcc7ac-4edb-42fa-8466-033794762046")] + public static extern Win32Error DsListInfoForServer(SafeDsHandle hDs, string server, out SafeDsNameResult ppInfo); + + /// + /// The DsListRoles function lists roles recognized by the server. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// + /// Pointer to a variable that receives a pointer to a DS_NAME_RESULT structure containing the roles the server recognizes. The + /// returned structure must be deallocated using DsFreeNameResult. + /// + /// + /// The indexes of the array in the DS_NAME_RESULT structure indicate what data are contained by each array element. The following + /// constants may be used to specify the desired index for a particular piece of data. + /// + /// DS_ROLE_DOMAIN_OWNER + /// Server owns the domain. + /// DS_ROLE_INFRASTRUCTURE_OWNER + /// Server owns the infrastructure. + /// DS_ROLE_PDC_OWNER + /// Server owns the PDC. + /// DS_ROLE_RID_OWNER + /// Server owns the RID. + /// DS_ROLE_SCHEMA_OWNER + /// Server owns the schema. + /// + /// If the function returns a list of roles, the return value is NO_ERROR. + /// If the function fails, the return value can be one of the following error codes. + /// Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dslistrolesa NTDSAPI DWORD DsListRolesA( HANDLE hDs, + // PDS_NAME_RESULTA *ppRoles ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "679a2dca-019b-4f6e-acd9-efb30e0d4b44")] + public static extern Win32Error DsListRoles(SafeDsHandle hDs, out SafeDsNameResult ppRoles); + + /// + /// The DsListServersForDomainInSite function lists all the servers in a domain in a site. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a null-terminated string that specifies the domain name. This string must be the same as one of the strings returned + /// by DsListDomainsInSite function. + /// Pointer to a null-terminated string that specifies the site name. This string is taken from the list of site names returned by + /// the DsListSites function. + /// Pointer to a pointer to a DS_NAME_RESULT structure that receives the list of servers in the domain. The returned structure must + /// be freed using the DsFreeNameResult function. + /// + /// If the function returns a list of servers, the return value is NO_ERROR. If the function fails, the return value can be + /// one of the following error codes. + /// + /// + /// Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dslistserversfordomaininsitea NTDSAPI DWORD + // DsListServersForDomainInSiteA( HANDLE hDs, LPCSTR domain, LPCSTR site, PDS_NAME_RESULTA *ppServers ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "1e346532-bbbe-4b3b-a1cb-6a72319cb3e2")] + public static extern Win32Error DsListServersForDomainInSite(SafeDsHandle hDs, string domain, string site, out SafeDsNameResult ppServers); + + /// + /// The DsListServersInSite function lists all the servers in a site. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a null-terminated string that specifies the site name. The site name uses a distinguished name format. It is taken + /// from the list of sites returned by the DsListSites function. + /// Pointer to a pointer to a DS_NAME_RESULT structure that receives the list of servers in the site. The returned structure must be + /// freed using the DsFreeNameResult function. + /// + /// If the function returns a list of servers, the return value is NO_ERROR. If the function fails, the return value can be + /// one of the following error codes. + /// + /// + /// Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dslistserversinsitea NTDSAPI DWORD DsListServersInSiteA( + // HANDLE hDs, LPCSTR site, PDS_NAME_RESULTA *ppServers ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "46773631-d464-4d9e-83e7-aa502599df71")] + public static extern Win32Error DsListServersInSite(SafeDsHandle hDs, string site, out SafeDsNameResult ppServers); + + /// + /// The DsListSites function lists all the sites in the enterprise forest. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a pointer to a DS_NAME_RESULT structure that receives the list of sites in the enterprise. The site name is returned + /// in the distinguished name (DN) format. The returned structure must be freed using the DsFreeNameResult function. + /// + /// If the function returns a list of sites, the return value is NO_ERROR. If the function fails, the return value can be one + /// of the following error codes. + /// + /// + /// Individual name conversion errors are reported in the returned DS_NAME_RESULT structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dslistsitesw NTDSAPI DWORD DsListSitesW( HANDLE hDs, + // PDS_NAME_RESULTW *ppSites ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "d424e750-6700-42b8-9d4f-e430cd0a7e4e")] + public static extern Win32Error DsListSites(SafeDsHandle hDs, out SafeDsNameResult ppSites); + + /// + /// Constructs a credential handle suitable for use with the DsBindWithCred function. + /// + /// A string that contains the user name to use for the credentials. + /// A string that contains the domain that the user is a member of. + /// A string that contains the password to use for the credentials. + /// An RPC_AUTH_IDENTITY_HANDLE value that receives the credential handle. This handle is used in a subsequent call to + /// DsBindWithCred. This handle must be freed with the DsFreePasswordCredentials function when it is no longer required. + /// Returns a Windows error code. /// /// A null, default credential handle is created if User, Domain and Password are all NULL. Otherwise, User must be present. The /// Domain parameter may be NULL when User is fully qualified, such as a user in UPN format; for example, "someone@fabrikam.com". @@ -957,67 +1948,803 @@ namespace Vanara.PInvoke /// When the handle returned in pAuthIdentity is passed to DsBindWithCred, DsUnBind must be called before freeing the handle with DsFreePasswordCredentials. /// /// - /// A string that contains the user name to use for the credentials. - /// A string that contains the domain that the user is a member of. - /// A string that contains the password to use for the credentials. - /// - /// An RPC_AUTH_IDENTITY_HANDLE value that receives the credential handle. This handle is used in a subsequent call to - /// DsBindWithCred. This handle must be freed with the DsFreePasswordCredentials function when it is no longer required. - /// - /// Returns a Windows error code. [DllImport(Lib.NTDSApi, CharSet = CharSet.Auto)] [PInvokeData("NTDSApi.h", MSDNShortId = "ms676006")] public static extern Win32Error DsMakePasswordCredentials(string User, string Domain, string Password, out SafeAuthIdentityHandle pAuthIdentity); /// + /// The DsMapSchemaGuids function converts GUIDs of directory service schema objects to their display names. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Indicates the number of elements in rGuids. + /// Pointer to an array of GUID values for the objects to be mapped. + /// Pointer to a variable that receives a pointer to an array of DS_SCHEMA_GUID_MAP structures that contain the display names of the + /// objects in rGuids. This array must be deallocated using DsFreeSchemaGuidMap. + /// + /// Returns a standard error code that includes the following values. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsmapschemaguidsa NTDSAPI DWORD DsMapSchemaGuidsA( HANDLE + // hDs, DWORD cGuids, GUID *rGuids, DS_SCHEMA_GUID_MAPA **ppGuidMap ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "439fff20-51eb-490d-a330-61d07f79c436")] + public static extern Win32Error DsMapSchemaGuids(SafeDsHandle hDs, uint cGuids, [In] Guid[] rGuids, out SafeDsSchemaGuidMap ppGuidMap); + + /// + /// The DsQuerySitesByCost function gets the communication cost between one site and one or more other sites. + /// + /// A directory service handle. + /// Pointer to a null-terminated string that contains the relative distinguished name of the site the costs are measured from. + /// Contains an array of null-terminated string pointers that contain the relative distinguished names of the sites the costs are + /// measured to. + /// Contains the number of elements in the rgwszToSites array. + /// Reserved. + /// + /// Pointer to an array of DS_SITE_COST_INFO structures that receives the cost data. Each element in this array contains the cost + /// data between the site identified by the pwszFromSite parameter and the site identified by the corresponding rgwszToSites element. + /// + /// The caller must free this memory when it is no longer required by calling DsQuerySitesFree. + /// + /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error code otherwise. Possible error codes include values listed in + /// the following list. + /// + /// + /// The cost values obtained by this function are only used to compare and have no meaning by themselves. For example, the cost for + /// site 1 can be compared to the cost for site 2, but the cost for site 1 cannot be compared to a fixed value. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsquerysitesbycosta NTDSAPI_POSTXP DWORD + // DsQuerySitesByCostA( HANDLE hDS, LPSTR pszFromSite, LPSTR *rgszToSites, DWORD cToSites, DWORD dwFlags, PDS_SITE_COST_INFO + // *prgSiteInfo ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "7a4cbd1c-8445-4882-8559-d44b6e5693e7")] + public static extern Win32Error DsQuerySitesByCost(SafeDsHandle hDS, string pszFromSite, [In] string[] rgszToSites, + uint cToSites, [Optional] uint dwFlags, out SafeDsQuerySites prgSiteInfo); + + /// + /// The DsQuerySitesFree function frees the memory allocated by the DsQuerySitesByCost function. + /// + /// Pointer to an array of DS_SITE_COST_INFO structures allocated by a call to DsQuerySitesByCost. + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsquerysitesfree void DsQuerySitesFree( PDS_SITE_COST_INFO + // rgSiteInfo ); + [DllImport(Lib.NTDSApi, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ntdsapi.h", MSDNShortId = "810caa4f-8275-4ad8-ad3e-72061fc073dd")] + public static extern void DsQuerySitesFree(IntPtr rgSiteInfo); + + /// + /// The DsRemoveDsDomain function removes all traces of a domain naming context from the global area of the directory service. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a null-terminated string that specifies the distinguished name of the naming context to remove from the directory service. + /// + /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error code if unsuccessful. Possible error codes include the following. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsremovedsdomaina NTDSAPI DWORD DsRemoveDsDomainA( HANDLE + // hDs, LPSTR DomainDN ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "0639cc04-2821-4421-8aa7-363621c1d6b5")] + public static extern Win32Error DsRemoveDsDomain(SafeDsHandle hDs, string DomainDN); + + /// + /// The DsRemoveDsServer function removes all traces of a directory service agent (DSA) from the global area of the directory service. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a null-terminated string that specifies the fully qualified distinguished name of the domain controller to remove. + /// Pointer to a null-terminated string that specifies a domain hosted by ServerDN. If this parameter is NULL, no verification + /// is performed to ensure that ServerDN is the last domain controller in DomainDN. + /// Pointer to a Boolean value that receives TRUE if ServerDN is the last DC in DomainDN or FALSE otherwise. This + /// parameter receives FALSE if DomainDN is NULL. + /// Contains a Boolean value that specifies if the domain controller should actually be removed. If this parameter is nonzero, + /// ServerDN is removed. If this parameter is zero, the existence of ServerDN is checked and fLastDcInDomain is written, but the + /// domain controller is not removed. + /// + /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error code if unsuccessful. Possible error codes include the following. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsremovedsserverw NTDSAPI DWORD DsRemoveDsServerW( HANDLE + // hDs, LPWSTR ServerDN, LPWSTR DomainDN, BOOL *fLastDcInDomain, BOOL fCommit ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "a79a2b71-10c7-495b-861f-0c7a4d86f720")] + public static extern Win32Error DsRemoveDsServer(SafeDsHandle hDs, string ServerDN, [Optional] string DomainDN, [MarshalAs(UnmanagedType.Bool)] out bool fLastDcInDomain, [MarshalAs(UnmanagedType.Bool)] bool fCommit); + + /// + /// The DsReplicaAdd function adds a replication source reference to a destination naming context. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// The null-terminated string that specifies the distinguished name (DN) of the destination naming context (NC) for which to add the + /// replica. The destination NC record must exist locally as either an object, instantiated or not, or a reference phantom, for + /// example, a phantom with a GUID. + /// The null-terminated string that specifies the DN of the NTDS-DSA object for the source directory system agent. This + /// parameter is required if Options includes DS_REPADD_ASYNCHRONOUS_REPLICA; otherwise, it is ignored. + /// The null-terminated string that specifies the DN of the interSiteTransport object that represents the transport used for + /// communication with the source server. This parameter is required if Options includes DS_REPADD_INTERSITE_MESSAGING; + /// otherwise, it is ignored. + /// The null-terminated string that specifies the transport-specific address of the source DSA. This source server is identified by a + /// string name, not by its UUID. A string name appropriate for SourceDsaAddress is usually a DNS name based on a GUID, where the + /// GUID part of the name is the GUID of the NTDS-DSA object for the source server. + /// Pointer to a SCHEDULE structure that contains the replication schedule data for the replication source. This parameter is + /// optional and can be NULL if not used. + /// Passes additional data to be used to process the request. This parameter can be a combination of the following values. + /// DS_REPADD_ASYNCHRONOUS_OPERATION + /// Performs this operation asynchronously. + /// DS_REPADD_ASYNCHRONOUS_REPLICA + /// Does not replicate the NC. Instead, save enough state data such that it may be replicated later. + /// DS_REPADD_DISABLE_NOTIFICATION /// - /// The DsUnBind function finds an RPC session with a domain controller and unbinds a handle to the directory service (DS). + /// Disables notification-based synchronization for the NC from this source. This is expected to be a temporary state. Use + /// DS_REPADD_NEVER_NOTIFY to permanently disable synchronization. + /// + /// DS_REPADD_DISABLE_PERIODIC + /// Disables periodic synchronization for the NC from this source. + /// DS_REPADD_INITIAL + /// Synchronizes the NC from this source when the DSA is started. + /// DS_REPADD_INTERSITE_MESSAGING + /// + /// Synchronizes from the source DSA using the Intersite Messaging Service (IMS) transport, for example, by SMTP, rather than using + /// the native directory service RPC. + /// + /// DS_REPADD_NEVER_NOTIFY + /// + /// Disables change notifications from this source. When this flag is set, the source does not notify the destination when changes + /// occur. This is recommended for all intersite replication that may occur over WAN links. + /// + /// This is expected to be a permanent state; use DS_REPADD_DISABLE_NOTIFICATION to temporarily disable notifications. + /// DS_REPADD_PERIODIC + /// Synchronizes the NC from this source periodically, as defined in pSchedule. + /// DS_REPADD_USE_COMPRESSION + /// + /// Uses compression when replicating. This saves network bandwidth at the expense of CPU overhead at both the source and destination servers. + /// + /// DS_REPADD_WRITEABLE + /// Creates a writable replica; otherwise, the replica is read-only. + /// + /// If the function succeeds, the return value is ERROR_SUCCESS. + /// If the function fails, the return value can be one of the following. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicaadda NTDSAPI DWORD DsReplicaAddA( HANDLE hDS, + // LPCSTR NameContext, LPCSTR SourceDsaDn, LPCSTR TransportDn, LPCSTR SourceDsaAddress, const PSCHEDULE pSchedule, DWORD Options ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "33bd1b61-b9ed-479f-a128-fb7ddbb5e9af")] + public static extern Win32Error DsReplicaAdd(SafeDsHandle hDS, string NameContext, string SourceDsaDn, string TransportDn, string SourceDsaAddress, [Optional] SCHEDULE pSchedule, DsReplicaAddOptions Options); + + /// + /// The DsReplicaConsistencyCheck function invokes the Knowledge Consistency Checker (KCC) to verify the replication topology. + /// The KCC dynamically adjusts the data replication topology of your network when domain controllers are added to or removed from + /// the network, when a domain controller is unavailable, or when the data replication schedules are changed. + /// + /// Contains a directory service handle obtained from either the DSBind, DSBindWithCred, or DsBindWithSpn function. + /// Identifies the task that the KCC should execute. DS_KCC_TASKID_UPDATE_TOPOLOGY is the only currently supported value. + /// + /// Contains a set of flags that modify the function behavior. This can be zero or a combination of one or more of the following values. + /// + /// DS_KCC_FLAG_ASYNC_OP + /// The task is queued and then the function returns without waiting for the task to complete. + /// DS_KCC_FLAG_DAMPED + /// The task will not be added to the queue if another queued task will run soon. + /// + /// If the function performs its operation successfully, the return value is ERROR_SUCCESS. If the function fails, the return + /// value can be one of the following. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicaconsistencycheck NTDSAPI DWORD + // DsReplicaConsistencyCheck( HANDLE hDS, DS_KCC_TASKID TaskID, DWORD dwFlags ); + [DllImport(Lib.NTDSApi, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ntdsapi.h", MSDNShortId = "2a83ffcb-1ebd-4024-a186-9c079896f4e1")] + public static extern Win32Error DsReplicaConsistencyCheck(SafeDsHandle hDS, DS_KCC_TASKID TaskID, DsKCCFlags dwFlags); + + /// + /// The DsReplicaDel function removes a replication source reference from a destination naming context (NC). + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a constant null-terminated string that specifies the distinguished name (DN) of the destination NC from which to + /// remove the replica. The destination NC record must exist locally as either an object, instantiated or not, or a reference + /// phantom, for example, a phantom with a GUID. + /// Pointer to a constant null-terminated Unicode string that specifies the transport-specific address of the source directory system + /// agent (DSA). This source server is identified by a string name, not by its UUID. A string name appropriate for DsaSrc is + /// usually a DNS name that is based on a GUID, where the GUID part of the name is the GUID of the nTDSDSA + /// object for the source server. + /// Passes additional data used to process the request. This parameter can be a combination of the following values. + /// DS_REPDEL_ASYNCHRONOUS_OPERATION + /// Performs this operation asynchronously. + /// DS_REPDEL_IGNORE_ERRORS + /// + /// Ignores any error generated from contacting the source to instruct it to remove this NC from its list of servers to which it replicates. + /// + /// DS_REPDEL_INTERSITE_MESSAGING + /// Signifies the replica is mail-based rather than synchronized using native directory service RPC. + /// DS_REPDEL_LOCAL_ONLY + /// + /// Does not contact the source to tell it to remove this NC from its list of servers to which it replicates. If this flag is not set + /// and the link is based in RPC, the source is contacted. + /// + /// DS_REPDEL_NO_SOURCE + /// Deletes all the objects in the NC. This option is valid only for read-only NCs with no source. + /// DS_REPDEL_REF_OK + /// Allows deletion of a read-only replica even if it sources other read-only replicas. + /// DS_REPDEL_WRITEABLE + /// Signifies that the replica deleted can be written to. + /// + /// If the function succeeds, the return value is ERROR_SUCCESS. + /// + /// If the function fails, the return value is a standard Win32 API error or ERROR_INVALID_PARAMETER if a parameter is invalid. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicadela NTDSAPI DWORD DsReplicaDelA( HANDLE hDS, + // LPCSTR NameContext, LPCSTR DsaSrc, ULONG Options ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "68c767c4-bbb6-477b-8ffb-94f3ae235375")] + public static extern Win32Error DsReplicaDel(SafeDsHandle hDS, string NameContext, string DsaSrc, DsReplicaDelOptions Options); + + /// + /// The DsReplicaFreeInfo function frees the replication state data structure allocated by the DsReplicaGetInfo or + /// DsReplicaGetInfo2 functions. + /// + /// Contains one of the DS_REPL_INFO_TYPE values that specifies the type of replication data structure contained in pInfo. This must + /// be the same value passed to the DsReplicaGetInfo or DsReplicaGetInfo2 function when the structure was allocated. + /// Pointer to the replication data structure allocated by the DsReplicaGetInfo or DsReplicaGetInfo2 functions. + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicafreeinfo void DsReplicaFreeInfo( + // DS_REPL_INFO_TYPE InfoType, VOID *pInfo ); + [DllImport(Lib.NTDSApi, SetLastError = false, ExactSpelling = true)] + [PInvokeData("ntdsapi.h", MSDNShortId = "32ce378e-a178-4970-b3bd-3887866e97af")] + public static extern void DsReplicaFreeInfo(DS_REPL_INFO_TYPE InfoType, IntPtr pInfo); + + /// + /// The DsReplicaGetInfo2 function retrieves replication state data from the directory service. This function allows paging of + /// results in cases where there are more than 1000 entries to retrieve. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Contains one of the DS_REPL_INFO_TYPE values that specifies the type of replication data to retrieve. This value also determines + /// which type of structure is returned in ppInfo. + /// + /// Pointer to a constant null-terminated Unicode string that identifies the object to retrieve replication data for. The meaning of + /// this parameter depends on the value of the InfoType parameter. The following are possible value codes. + /// + /// DS_REPL_INFO_NEIGHBORS + /// pszObject identifies the naming context for which replication neighbors are requested. + /// DS_REPL_INFO_CURSORS_FOR_NC + /// pszObject identifies the naming context for which replication cursors are requested. + /// DS_REPL_INFO_METADATA_FOR_OBJ + /// pszObject identifies the object for which replication metadata is requested. + /// DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES + /// pszObject must be NULL. + /// DS_REPL_INFO_KCC_DSA_LINK_FAILURES + /// pszObject must be NULL. + /// DS_REPL_INFO_PENDING_OPS + /// pszObject must be NULL. + /// DS_REPL_INFO_METADATA_FOR_ATTR_VALUE + /// pszObject identifies the object for which attribute replication metadata is requested. + /// DS_REPL_INFO_CURSORS_2_FOR_NC + /// DS_REPL_INFO_CURSORS_3_FOR_NC + /// DS_REPL_INFO_METADATA_2_FOR_OBJ + /// pszObject identifies the object for which replication metadata is requested. + /// DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE + /// pszObject identifies the object for which attribute replication metadata is requested. + /// Pointer to a GUID value that identifies a specific replication source. If this parameter is not NULL and the + /// InfoType parameter contains DS_REPL_INFO_NEIGHBORS, only neighbor data for the source corresponding to the nTDSDSA object + /// with the given objectGuid in the directory is returned. This parameter is ignored if NULL or if the InfoType + /// parameter is anything other than DS_REPL_INFO_NEIGHBORS. + /// + /// Pointer to a null-terminated Unicode string that contains the name of the specific attribute to retrieve replication data for. + /// + /// This parameter is only used if the InfoType parameter contains one of the following values. + /// DS_REPL_INFO_METADATA_FOR_ATTR_VALUE + /// DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE + /// Pointer to a null-terminated Unicode string that contains the distinguished name value to match. If the requested attribute is a + /// distinguished name type value, this function return the attributes that contain the specified value. + /// Contains a set of flags that modify the behavior of the function. This parameter can be zero or the following value. + /// DS_REPL_INFO_FLAG_IMPROVE_LINKED_ATTRS + /// + /// Causes the attribute metadata to account for metadata on the attribute's linked values. The resulting vector represents changes + /// for all attributes. This modified vector is useful for clients that expect all attributes and metadata to be included in the + /// attribute metadata vector. + /// + /// Contains the index of the next entry to retrieve. This parameter must be set to zero the first time this function is called. + /// This parameter is only used if the InfoType parameter contains one of the following values. + /// DS_REPL_INFO_CURSORS_2_FOR_NC + /// DS_REPL_INFO_CURSORS_3_FOR_NC + /// DS_REPL_INFO_METADATA_FOR_ATTR_VALUE + /// DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE + /// + /// This function will retrieve a maximum of 1000 entries on each call. If after calling this function, more entries are available, + /// the dwEnumerationContext member of the retrieved structure will contain the index of the next entry to retrieve. The + /// dwEnumerationContext member of the retrieved structure is then used as the dwEnumerationContext parameter in the next call + /// to this function. When all of the entries have been retrieved, the dwEnumerationContext member of the retrieved structure + /// will contain -1. If -1 is passed for this parameter, this function will return ERROR_NO_MORE_ITEMS. + /// + /// + /// Address of a structure pointer that receives the requested data. The value of the InfoType parameter determines the format of + /// this structure. For more information and a list of possible InfoType values and the corresponding structure types, see DS_REPL_INFO_TYPE. + /// + /// The caller must free this memory when it is no longer required by calling DsReplicaFreeInfo. + /// + /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error otherwise. The following are possible error codes. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicagetinfo2w NTDSAPI DWORD DsReplicaGetInfo2W( + // HANDLE hDS, DS_REPL_INFO_TYPE InfoType, LPCWSTR pszObject, UUID *puuidForSourceDsaObjGuid, LPCWSTR pszAttributeName, LPCWSTR + // pszValue, DWORD dwFlags, DWORD dwEnumerationContext, VOID **ppInfo ); + [PInvokeData("ntdsapi.h", MSDNShortId = "5735d91d-1b7d-4dc6-b6c6-61ba38ebe50d")] + public static Win32Error DsReplicaGetInfo2W(SafeDsHandle hDS, DS_REPL_INFO_TYPE InfoType, [Optional] string pszObject, [Optional] Guid? puuidForSourceDsaObjGuid, [Optional] string pszAttributeName, + [Optional] string pszValue, DsReplInfoFlags dwFlags, uint dwEnumerationContext, out SafeDsReplicaInfo ppInfo) + { + unsafe + { + var guid = puuidForSourceDsaObjGuid.GetValueOrDefault(); + var ret = DsReplicaGetInfo2W(hDS, InfoType, pszObject, puuidForSourceDsaObjGuid.HasValue ? &guid : null, pszAttributeName, pszValue, dwFlags, dwEnumerationContext, out ppInfo); + ppInfo.Type = InfoType; + return ret; + } + } + + /// + /// The DsReplicaGetInfo function retrieves replication state data from the directory service. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// + /// Contains one of the DS_REPL_INFO_TYPE values that specifies the type of replication data to retrieve. This value also determines + /// which type of structure is returned in ppInfo. + /// + /// + /// Only the following values are supported for this function. If other data types are required, the DsReplicaGetInfo2 function must + /// be used. + /// + /// DS_REPL_INFO_NEIGHBORS + /// DS_REPL_INFO_CURSORS_FOR_NC + /// DS_REPL_INFO_METADATA_FOR_OBJ + /// DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES + /// DS_REPL_INFO_KCC_DSA_LINK_FAILURES + /// DS_REPL_INFO_PENDING_OPS + /// + /// Pointer to a constant null-terminated Unicode string that identifies the object to retrieve replication data for. The meaning of + /// this parameter depends on the value of the InfoType parameter. The following are possible value codes. + /// + /// DS_REPL_INFO_NEIGHBORS + /// pszObject identifies the naming context for which replication neighbors are requested. + /// DS_REPL_INFO_CURSORS_FOR_NC + /// pszObject identifies the naming context for which replication cursors are requested. + /// DS_REPL_INFO_METADATA_FOR_OBJ + /// pszObject identifies the object for which replication metadata is requested. + /// DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES + /// pszObject must be NULL. + /// DS_REPL_INFO_KCC_DSA_LINK_FAILURES + /// pszObject must be NULL. + /// DS_REPL_INFO_PENDING_OPS + /// pszObject must be NULL. + /// Pointer to a GUID value that identifies a specific replication source. If this parameter is not NULL and the + /// InfoType parameter contains DS_REPL_INFO_NEIGHBORS, only neighbor data for the source corresponding to the nTDSDSA object + /// with the given objectGuid in the directory is returned. This parameter is ignored if NULL or if the InfoType + /// parameter is anything other than DS_REPL_INFO_NEIGHBORS. + /// + /// Address of a structure pointer that receives the requested data. The value of the InfoType parameter determines the format of + /// this structure. For more information and list of possible InfoType values and the corresponding structure types, see DS_REPL_INFO_TYPE. + /// + /// The caller must free this memory when it is no longer required by calling DsReplicaFreeInfo. + /// + /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error otherwise. The following are possible error codes. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicagetinfow NTDSAPI DWORD DsReplicaGetInfoW( HANDLE + // hDS, DS_REPL_INFO_TYPE InfoType, LPCWSTR pszObject, UUID *puuidForSourceDsaObjGuid, VOID **ppInfo ); + [DllImport(Lib.NTDSApi, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("ntdsapi.h", MSDNShortId = "b7ab22fe-ed92-4213-9b66-2dd5526286fa")] + public static extern Win32Error DsReplicaGetInfoW(SafeDsHandle hDS, DS_REPL_INFO_TYPE InfoType, string pszObject, in Guid puuidForSourceDsaObjGuid, out SafeDsReplicaInfo ppInfo); + + /// + /// The DsReplicaModify function modifies an existing replication source reference for a destination naming context. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a constant null-terminated string that specifies the distinguished name (DN) of the destination naming context (NC). + /// Pointer to the UUID of the source directory system agent (DSA). This parameter may be null if ModifyFields does not include + /// DS_REPMOD_UPDATE_ADDRESS and SourceDsaAddress is not NULL. + /// Reserved for future use. Any value other than NULL results in ERROR_NOT_SUPPORTED being returned. + /// Pointer to a constant null-terminated Unicode string that specifies the transport-specific address of the source DSA. This + /// parameter is ignored if pUuidSourceDsa is not NULL and ModifyFields does not include DS_REPMOD_UPDATE_ADDRESS. + /// Pointer to a SCHEDULE structure that contains the replication schedule data for the replication source. This parameter is + /// optional and can be NULL if not used. This parameter is required if ModifyFields contains the + /// DS_REPMOD_UPDATE_SCHEDULE flag. + /// This parameter is used to control replication behavior and can take the following values. + /// DS_REPL_NBR_SYNC_ON_STARTUP + /// + /// Replication of this naming context from this source is attempted when the destination server is booted. This normally only + /// applies to intra-site neighbors. + /// + /// DS_REPL_NBR_DO_SCHEDULED_SYNCS + /// + /// Perform replication on a schedule. This flag is normally set unless the schedule for this naming context and source is "never", + /// that is, the empty schedule. + /// + /// DS_REPL_NBR_TWO_WAY_SYNC + /// + /// If set, indicates that when inbound replication is complete, the destination server must tell the source server to synchronize in + /// the reverse direction. This feature is used in dial-up scenarios where only one of the two servers can initiate a dial-up + /// connection. For example, this option would be used in a corporate headquarters and branch office, where the branch office + /// connects to the corporate headquarters over the Internet by means of a dial-up ISP connection. + /// + /// DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS + /// + /// This neighbor is set to disable notification-based synchronization. Within a site, domain controllers synchronize with each other + /// based on notifications when changes occur. This setting prevents this neighbor from performing a synchronization triggered by a + /// notification. The neighbor will still do synchronization based on its schedule or in response to manually requested synchronization. + /// + /// DS_REPL_NBR_DISABLE_SCHEDULED_SYNC + /// + /// This neighbor is set to not perform synchronization based on its schedule. The only way this neighbor will perform + /// synchronization is in response to change notifications or to manually requested synchronization. + /// + /// DS_REPL_NBR_COMPRESS_CHANGES + /// + /// Changes received from this source are to be compressed. This is normally set if, and only if, the source server is in a different site. + /// + /// DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS + /// + /// No change notifications should be received from this source. This is normally set if, and only if, the source server is in a + /// different site. + /// + /// + /// Specifies what fields should be modified. At least one field must be specified in ModifyFields. This parameter can be a + /// combination of the following values. + /// + /// DS_REPMOD_UPDATE_ADDRESS + /// Updates the address associated with the referenced server. + /// DS_REPMOD_UPDATE_FLAGS + /// Updates the flags associated with the replica. + /// DS_REPMOD_UPDATE_RESULT + /// Not used. Specifying updates of result values is not currently supported. Result values default to 0. + /// DS_REPMOD_UPDATE_SCHEDULE + /// Updates the periodic replication schedule associated with the replica. + /// DS_REPMOD_UPDATE_TRANSPORT + /// Updates the transport associated with the replica. + /// Passes additional data used to process the request. This parameter can be a combination of the following values. + /// DS_REPMOD_ASYNCHRONOUS_OPERATION + /// Performs this operation asynchronously. + /// DS_REPMOD_WRITEABLE + /// Indicates that the replica being modified can be written to. + /// + /// If the function succeeds, the return value is ERROR_SUCCESS. + /// If the function fails, the return value can be one of the following. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicamodifya NTDSAPI DWORD DsReplicaModifyA( HANDLE + // hDS, LPCSTR NameContext, const UUID *pUuidSourceDsa, LPCSTR TransportDn, LPCSTR SourceDsaAddress, const PSCHEDULE pSchedule, DWORD + // ReplicaFlags, DWORD ModifyFields, DWORD Options ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "aad20527-1211-41bc-b0e9-02e4ab28ae2e")] + public static extern Win32Error DsReplicaModify(SafeDsHandle hDS, string NameContext, in Guid pUuidSourceDsa, [Optional] string TransportDn, [Optional] string SourceDsaAddress, + [Optional] SCHEDULE pSchedule, DsReplNeighborFlags ReplicaFlags, DsReplModFieldFlags ModifyFields, DsReplModOptions Options); + + /// + /// The DsReplicaModify function modifies an existing replication source reference for a destination naming context. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a constant null-terminated string that specifies the distinguished name (DN) of the destination naming context (NC). + /// Pointer to the UUID of the source directory system agent (DSA). This parameter may be null if ModifyFields does not include + /// DS_REPMOD_UPDATE_ADDRESS and SourceDsaAddress is not NULL. + /// Reserved for future use. Any value other than NULL results in ERROR_NOT_SUPPORTED being returned. + /// Pointer to a constant null-terminated Unicode string that specifies the transport-specific address of the source DSA. This + /// parameter is ignored if pUuidSourceDsa is not NULL and ModifyFields does not include DS_REPMOD_UPDATE_ADDRESS. + /// Pointer to a SCHEDULE structure that contains the replication schedule data for the replication source. This parameter is + /// optional and can be NULL if not used. This parameter is required if ModifyFields contains the + /// DS_REPMOD_UPDATE_SCHEDULE flag. + /// This parameter is used to control replication behavior and can take the following values. + /// DS_REPL_NBR_SYNC_ON_STARTUP + /// + /// Replication of this naming context from this source is attempted when the destination server is booted. This normally only + /// applies to intra-site neighbors. + /// + /// DS_REPL_NBR_DO_SCHEDULED_SYNCS + /// + /// Perform replication on a schedule. This flag is normally set unless the schedule for this naming context and source is "never", + /// that is, the empty schedule. + /// + /// DS_REPL_NBR_TWO_WAY_SYNC + /// + /// If set, indicates that when inbound replication is complete, the destination server must tell the source server to synchronize in + /// the reverse direction. This feature is used in dial-up scenarios where only one of the two servers can initiate a dial-up + /// connection. For example, this option would be used in a corporate headquarters and branch office, where the branch office + /// connects to the corporate headquarters over the Internet by means of a dial-up ISP connection. + /// + /// DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS + /// + /// This neighbor is set to disable notification-based synchronization. Within a site, domain controllers synchronize with each other + /// based on notifications when changes occur. This setting prevents this neighbor from performing a synchronization triggered by a + /// notification. The neighbor will still do synchronization based on its schedule or in response to manually requested synchronization. + /// + /// DS_REPL_NBR_DISABLE_SCHEDULED_SYNC + /// + /// This neighbor is set to not perform synchronization based on its schedule. The only way this neighbor will perform + /// synchronization is in response to change notifications or to manually requested synchronization. + /// + /// DS_REPL_NBR_COMPRESS_CHANGES + /// + /// Changes received from this source are to be compressed. This is normally set if, and only if, the source server is in a different site. + /// + /// DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS + /// + /// No change notifications should be received from this source. This is normally set if, and only if, the source server is in a + /// different site. + /// + /// + /// Specifies what fields should be modified. At least one field must be specified in ModifyFields. This parameter can be a + /// combination of the following values. + /// + /// DS_REPMOD_UPDATE_ADDRESS + /// Updates the address associated with the referenced server. + /// DS_REPMOD_UPDATE_FLAGS + /// Updates the flags associated with the replica. + /// DS_REPMOD_UPDATE_RESULT + /// Not used. Specifying updates of result values is not currently supported. Result values default to 0. + /// DS_REPMOD_UPDATE_SCHEDULE + /// Updates the periodic replication schedule associated with the replica. + /// DS_REPMOD_UPDATE_TRANSPORT + /// Updates the transport associated with the replica. + /// Passes additional data used to process the request. This parameter can be a combination of the following values. + /// DS_REPMOD_ASYNCHRONOUS_OPERATION + /// Performs this operation asynchronously. + /// DS_REPMOD_WRITEABLE + /// Indicates that the replica being modified can be written to. + /// + /// If the function succeeds, the return value is ERROR_SUCCESS. + /// If the function fails, the return value can be one of the following. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicamodifya NTDSAPI DWORD DsReplicaModifyA( HANDLE + // hDS, LPCSTR NameContext, const UUID *pUuidSourceDsa, LPCSTR TransportDn, LPCSTR SourceDsaAddress, const PSCHEDULE pSchedule, DWORD + // ReplicaFlags, DWORD ModifyFields, DWORD Options ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "aad20527-1211-41bc-b0e9-02e4ab28ae2e")] + public static extern Win32Error DsReplicaModify(SafeDsHandle hDS, string NameContext, [Optional] IntPtr pUuidSourceDsa, [Optional] string TransportDn, [Optional] string SourceDsaAddress, + [Optional] SCHEDULE pSchedule, DsReplNeighborFlags ReplicaFlags, DsReplModFieldFlags ModifyFields, DsReplModOptions Options); + + /// + /// The DsReplicaSync function synchronizes a destination naming context (NC) with one of its sources. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a constant null-terminated string that specifies the distinguished name of the destination NC. + /// Pointer to the UUID of a source that replicates to the destination NC. + /// Passes additional data used to process the request. This parameter can be a combination of the following values. + /// DS_REPSYNC_ADD_REFERENCE + /// + /// Causes the source directory system agent (DSA) to verify that the local DSA is present in the source replicates-to list. If not, + /// the local DSA is added. This ensures that the source sends change notifications. + /// + /// DS_REPSYNC_ALL_SOURCES + /// This value is not supported. + /// + /// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista and Windows Server 2003: Synchronizes from all sources. + /// + /// DS_REPSYNC_ASYNCHRONOUS_OPERATION + /// Performs this operation asynchronously. + /// + /// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista and Windows Server 2003: Required when using DS_REPSYNC_ALL_SOURCES. + /// + /// DS_REPSYNC_FORCE + /// Synchronizes even if the link is currently disabled. + /// DS_REPSYNC_FULL + /// Synchronizes starting from the first Update Sequence Number (USN). + /// DS_REPSYNC_INTERSITE_MESSAGING + /// Synchronizes using an ISM. + /// DS_REPSYNC_NO_DISCARD + /// Does not discard this synchronization request, even if a similar synchronization is pending. + /// DS_REPSYNC_PERIODIC + /// Indicates this operation is a periodic synchronization request as scheduled by the administrator. + /// DS_REPSYNC_URGENT + /// Indicates this operation is a notification of an update marked urgent. + /// DS_REPSYNC_WRITEABLE + /// Replica is writable. Otherwise, it is read-only. + /// + /// If the function performs its operation successfully, the return value is ERROR_SUCCESS. + /// If the function fails, the return value is one of the standard Win32 API errors. + /// + /// + /// + /// The server that DsReplicaSync executes on is called the destination. The destination naming context is brought up-to-date + /// with respect to a source system, identified by the UUID of the source system NTDS Settings object. The destination system must + /// already be configured so that the source system is one of the systems from which it receives replication data. + /// + /// + /// Note Forcing manual synchronization can prevent the directory service from properly prioritizing replication operations. + /// For example, synchronizing a new user may preempt an urgent synchronization performed to provide access to a recently locked out + /// user or to add a new trust password. If you call this API often, you can flood the network with requests, which can interfere + /// with other replication operations. For this reason, it is strongly recommended that this function be used only for single-use + /// scenarios rather than incorporating it into an application that would use it on a regular basis. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicasynca NTDSAPI DWORD DsReplicaSyncA( HANDLE hDS, + // LPCSTR NameContext, const UUID *pUuidDsaSrc, ULONG Options ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "20c7f96d-f298-4321-a6f5-910c25e418db")] + public static extern Win32Error DsReplicaSync(SafeDsHandle hDS, string NameContext, in Guid pUuidDsaSrc, DsReplSyncOptions Options); + + /// + /// The DsReplicaSyncAll function synchronizes a server with all other servers, using transitive replication, as necessary. By + /// default, DsReplicaSyncAll synchronizes the server with all other servers in its site; however, you can also use it to + /// synchronize across site boundaries. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a null-terminated string that specifies the distinguished name of the naming context to synchronize. The + /// pszNameContext parameter is optional; if its value is NULL, the configuration naming context is replicated. + /// Passes additional data used to process the request. This parameter can be a combination of the following values. + /// DS_REPSYNCALL_ABORT_IF_SERVER_UNAVAILABLE + /// + /// Generates a fatal error if any server cannot be contacted or if any server is unreachable due to a disconnected or broken topology. + /// + /// DS_REPSYNCALL_CROSS_SITE_BOUNDARIES + /// + /// Synchronizes across site boundaries. By default, DsReplicaSyncAll attempts to synchronize only with DCs in the same site + /// as the home system. Set this flag to attempt to synchronize with all DCs in the enterprise forest. However, the DCs can be + /// synchronized only if connected by a synchronous (RPC) transport. + /// + /// DS_REPSYNCALL_DO_NOT_SYNC + /// Disables all synchronization. The topology is still analyzed, and unavailable or unreachable servers are still identified. + /// DS_REPSYNCALL_ID_SERVERS_BY_DN + /// In the event of a non-fatal error, returns server distinguished names (DN) instead of their GUID DNS names. + /// DS_REPSYNCALL_NO_OPTIONS + /// This option has no effect. + /// DS_REPSYNCALL_PUSH_CHANGES_OUTWARD + /// + /// Pushes changes from the home server out to all partners using transitive replication. This reverses the direction of replication, + /// and the order of execution of the replication sets from the usual "pulling" mode of execution. + /// + /// DS_REPSYNCALL_SKIP_INITIAL_CHECK + /// + /// Assumes that all servers are responding. This speeds operation of the DsReplicaSyncAll function, but if some servers are + /// not responding, some transitive replications may be blocked. + /// + /// DS_REPSYNCALL_SYNC_ADJACENT_SERVERS_ONLY + /// Disables transitive replication. Synchronization is performed only with adjacent servers. + /// Pointer to an application-defined SyncUpdateProc function called by the DsReplicaSyncAll function when it encounters an + /// error, initiates synchronization of two servers, completes synchronization of two servers, or finishes synchronization of all the + /// servers in the site. + /// Pointer to application-defined data passed as the first argument of the SyncUpdateProc callback function pointed to by the + /// pFnCallBack parameter. + /// A NULL-terminated array of pointers to DS_REPSYNCALL_ERRINFO structures that contain errors that occurred during synchronization. + /// The memory used to hold both the array of pointers and the MsCS\mscs\clusctl_resource_type_get_private_property_fmts.xml data is + /// allocated as a single block of memory and should be freed when no longer required by a single call to LocalFree with the + /// pointer value returned in pErrors used as the argument. + /// + /// If the function succeeds, the return value is ERROR_SUCCESS. + /// If the function fails, the return value is as follows. + /// + /// + /// + /// The DsReplicaSyncAll function attempts to bind to all servers before generating a topology to synchronize from. If a + /// server cannot be contacted, the function excludes that server from the topology and attempts to work around it. Setting the + /// DS_REPSYNCALL_SKIP_INITIAL_CHECK flag in ulFlags bypasses the initial binding. + /// + /// + /// If a server cannot be contacted, the DsReplicaSyncAll function attempts to route around it and replicate from as many + /// servers as possible, unless DS_REPSYNCALL_ABORT_IF_SERVER_UNAVAILABLE is set in ulFlags. + /// + /// + /// The DsReplicaSyncAll function can use the callback function pointed to by pFnCallBack to keep an end user informed about + /// the current status of the replication. Execution of the DsReplicaSyncAll function pauses when it calls the function + /// pointed to by pFnCallBack. If the return value from the callback function is TRUE, replication continues; otherwise, the + /// DsReplicaSyncAll function terminates replication. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicasyncalla NTDSAPI DWORD DsReplicaSyncAllA( HANDLE + // hDS, LPCSTR pszNameContext, ULONG ulFlags, BOOL(* )(LPVOID,PDS_REPSYNCALL_UPDATEA) pFnCallBack, LPVOID pCallbackData, + // PDS_REPSYNCALL_ERRINFOA **pErrors ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "2608adde-4f18-4048-a96f-d736ff09cd4b")] + public static extern Win32Error DsReplicaSyncAll(SafeDsHandle hDS, [Optional] string pszNameContext, DsReplSyncAllFlags ulFlags, SyncUpdateProc pFnCallBack, IntPtr pCallbackData, out SafeDS_REPSYNCALL_ERRINFOArray pErrors); + + /// + /// The DsReplicaUpdateRefs function adds or removes a replication reference for a destination from a source naming context. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Pointer to a constant null-terminated string that specifies the distinguished name of the source naming context. + /// Pointer to a constant null-terminated string that specifies the transport-specific address of the destination directory system agent. + /// Pointer to a UUID value that contains the destination directory system agent. + /// + /// Contains a set of flags that provide additional data used to process the request. This can be zero or a combination of one or + /// more of the following values. + /// + /// DS_REPUPD_ADD_REFERENCE + /// A reference to the destination is added to the source server. + /// DS_REPUPD_ASYNCHRONOUS_OPERATION + /// The operation is performed asynchronously. + /// DS_REPUPD_DELETE_REFERENCE + /// A reference to the destination is removed from the source server. + /// DS_REPUPD_WRITEABLE + /// The reference to the replica added or removed is writable. Otherwise, it is read-only. + /// + /// If the function succeeds, ERROR_SUCCESS is returned. + /// If the function fails, the return value can be one of the following. + /// + /// + /// If both DS_REPUPD_ADD_REFERENCE and DS_REPUPD_DELETE_REFERENCE are set in the Options parameter, a reference to the + /// destination is added if one does not already exist on the server. If a reference to the destination already exists, the reference + /// is updated. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicaupdaterefsa NTDSAPI DWORD DsReplicaUpdateRefsA( + // HANDLE hDS, LPCSTR NameContext, LPCSTR DsaDest, const UUID *pUuidDsaDest, ULONG Options ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "158c7e73-0e6c-4b71-a87f-2f60f3db91cb")] + public static extern Win32Error DsReplicaUpdateRefs(SafeDsHandle hDS, string NameContext, string DsaDest, in Guid pUuidDsaDest, DsReplUpdateOptions Options); + + /// + /// The DsReplicaVerifyObjects function verifies all objects for a naming context with a source. + /// + /// Contains a directory service handle obtained from either the DSBind, DSBindWithCred, or DsBindWithSpn function. + /// Pointer to a null-terminated string that contains the distinguished name of the naming context. + /// Pointer to a UUID value that contains the objectGuid of the directory system agent object. + /// Contains a set of flags that modify the behavior of the function. This can be zero or the following value. + /// DS_EXIST_ADVISORY_MODE + /// Do not delete objects in response to this function. + /// + /// Returns ERROR_SUCCESS if successful or a Win32 error otherwise. Possible error values include the following. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicaverifyobjectsa NTDSAPI DWORD + // DsReplicaVerifyObjectsA( HANDLE hDS, LPCSTR NameContext, const UUID *pUuidDsaSrc, ULONG ulOptions ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "d0e139dc-6aaf-47e1-a76f-4e84f17aa7c6")] + public static extern Win32Error DsReplicaVerifyObjects(SafeDsHandle hDS, string NameContext, in Guid pUuidDsaSrc, DsReplVerifyOptions ulOptions); + + /// + /// + /// The DsServerRegisterSpn function composes two SPNs for a host-based service. The names are based on the DNS and NetBIOS + /// names of the local computer. The function modifies the servicePrincipalName attribute of either a specified account or of + /// the account associated with the calling thread. The function either registers or unregisters the SPNs. + /// + /// + /// A host-based service is a service instance that provides services identified with its host computer, as distinguished from a + /// replicable service where clients have no preference which host computer a service instance runs on. /// /// - /// - /// Pointer to a bind handle to the directory service. This handle is provided by a call to DsBind, DsBindWithCred, or DsBindWithSpn. - /// + /// Specifies what operation DsServerRegisterSpn should perform. This parameter can have one of the following values. + /// DS_SPN_ADD_SPN_OP + /// Adds the SPNs to the user or computer account. + /// DS_SPN_DELETE_SPN_OP + /// Deletes the specified SPNs from the account. + /// DS_SPN_REPLACE_SPN_OP + /// Removes all SPNs currently registered on the user or computer account and replaces them with the new SPNs. + /// Pointer to a constant null-terminated string specifying the class of the service. This parameter may be any string unique to that + /// service; either the protocol name (for example, ldap) or the string form of a GUID will work. + /// Pointer to a constant null-terminated string specifying the distinguished name of a user or computer account object to write the + /// SPNs to. If this parameter is NULL, DsServerRegisterSpn writes to the account object of the primary or impersonated + /// user associated with the calling thread. If the thread is running in the security context of the LocalSystem account, the + /// function writes to the account object of the local computer. /// - /// NO_ERROR + /// If the function successfully registers one or more SPNs, it returns ERROR_SUCCESS. Modification is performed permissively, + /// so that adding a value that already exists does not return an error. /// + /// + /// The two SPNs composed by the DsServerRegisterSpn function have the following format: + /// + /// In one SPN, the host computer is the fully qualified DNS name of the local computer. In the other SPN, the host component is the + /// NetBIOS name of the local computer. + /// + /// + /// In most cases, the DsServerRegisterSpn caller must have domain administrator privileges to successfully modify the + /// servicePrincipalName attribute of an account object. The exception to this rule is if the calling thread is running under + /// the LocalSystem account, DsServerRegisterSpn is allowed if the UserObjectDN parameter is either NULL or specifies + /// the distinguished name of the local computer account. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsserverregisterspna NTDSAPI DWORD DsServerRegisterSpnA( + // DS_SPN_WRITE_OP Operation, LPCSTR ServiceClass, LPCSTR UserObjectDN ); + [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("ntdsapi.h", MSDNShortId = "d95dfa55-f978-4d8d-a63d-cd1339769c79")] + public static extern Win32Error DsServerRegisterSpn(DS_SPN_WRITE_OP Operation, string ServiceClass, [Optional] string UserObjectDN); + + /// + /// The DsUnBind function finds an RPC session with a domain controller and unbinds a handle to the directory service (DS). + /// + /// Pointer to a bind handle to the directory service. This handle is provided by a call to DsBind, DsBindWithCred, or DsBindWithSpn. + /// NO_ERROR // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsunbinda NTDSAPI DWORD DsUnBindA( HANDLE *phDS ); [DllImport(Lib.NTDSApi, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("ntdsapi.h", MSDNShortId = "7106d67f-d421-4a7c-b775-440e5944f25e")] public static extern Win32Error DsUnBind(ref IntPtr phDS); /// - /// /// The DsWriteAccountSpn function writes an array of service principal names (SPNs) to the servicePrincipalName /// attribute of a specified user or computer account object in Active Directory Domain Services. The function can either register or /// unregister the SPNs. - /// /// - /// - /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. - /// - /// - /// Contains one of the DS_SPN_WRITE_OP values that specifies the operation that DsWriteAccountSpn will perform. - /// - /// - /// - /// Pointer to a constant null-terminated string that specifies the distinguished name of a user or computer object in Active - /// Directory Domain Services. The caller must have write access to the servicePrincipalName property of this object. - /// - /// - /// - /// - /// Specifies the number of SPNs in rpszSpn. If this value is zero, and Operation contains DS_SPN_REPLACE_SPN_OP, the function - /// removes all values from the servicePrincipalName attribute of the specified account. - /// - /// - /// - /// - /// Pointer to an array of constant null-terminated strings that specify the SPNs to be added to or removed from the account - /// identified by the pszAccount parameter. The DsGetSpn function is used to compose SPNs for a service. - /// - /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Contains one of the DS_SPN_WRITE_OP values that specifies the operation that DsWriteAccountSpn will perform. + /// Pointer to a constant null-terminated string that specifies the distinguished name of a user or computer object in Active + /// Directory Domain Services. The caller must have write access to the servicePrincipalName property of this object. + /// Specifies the number of SPNs in rpszSpn. If this value is zero, and Operation contains DS_SPN_REPLACE_SPN_OP, the function + /// removes all values from the servicePrincipalName attribute of the specified account. + /// Pointer to an array of constant null-terminated strings that specify the SPNs to be added to or removed from the account + /// identified by the pszAccount parameter. The DsGetSpn function is used to compose SPNs for a service. /// - /// Returns ERROR_SUCCESS if successful or a Win32, RPC or directory service error if unsuccessful. + /// Returns ERROR_SUCCESS if successful or a Win32, RPC or directory service error if unsuccessful. /// /// /// @@ -1053,26 +2780,26 @@ namespace Vanara.PInvoke /// /// Below is a summary of rights per user on machine accounts: /// - /// - /// User Type - /// Rights - /// - /// - /// Person creating the Account - /// Write validated SPN - /// - /// - /// Account Operators - /// Write SPN and Write Validated SPN - /// - /// - /// Authenticated Users - /// None - /// - /// - /// (self) - /// Write Validated SPN - /// + /// + /// User Type + /// Rights + /// + /// + /// Person creating the Account + /// Write validated SPN + /// + /// + /// Account Operators + /// Write SPN and Write Validated SPN + /// + /// + /// Authenticated Users + /// None + /// + /// + /// (self) + /// Write Validated SPN + /// /// /// /// On user accounts there is no "Validated SPN" property or "Write SPN" right. Rather, the "Write public information" property set @@ -1085,6 +2812,85 @@ namespace Vanara.PInvoke [PInvokeData("ntdsapi.h", MSDNShortId = "2b555f6b-643d-4fa0-9aca-701e6b3313fa")] public static extern Win32Error DsWriteAccountSpn(SafeDsHandle hDS, DS_SPN_WRITE_OP Operation, string pszAccount, uint cSpn, SpnArrayHandle rpszSpn); + /// + /// The DsReplicaGetInfo2 function retrieves replication state data from the directory service. This function allows paging of + /// results in cases where there are more than 1000 entries to retrieve. + /// + /// Contains a directory service handle obtained from either the DSBind or DSBindWithCred function. + /// Contains one of the DS_REPL_INFO_TYPE values that specifies the type of replication data to retrieve. This value also determines + /// which type of structure is returned in ppInfo. + /// + /// Pointer to a constant null-terminated Unicode string that identifies the object to retrieve replication data for. The meaning of + /// this parameter depends on the value of the InfoType parameter. The following are possible value codes. + /// + /// DS_REPL_INFO_NEIGHBORS + /// pszObject identifies the naming context for which replication neighbors are requested. + /// DS_REPL_INFO_CURSORS_FOR_NC + /// pszObject identifies the naming context for which replication cursors are requested. + /// DS_REPL_INFO_METADATA_FOR_OBJ + /// pszObject identifies the object for which replication metadata is requested. + /// DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES + /// pszObject must be NULL. + /// DS_REPL_INFO_KCC_DSA_LINK_FAILURES + /// pszObject must be NULL. + /// DS_REPL_INFO_PENDING_OPS + /// pszObject must be NULL. + /// DS_REPL_INFO_METADATA_FOR_ATTR_VALUE + /// pszObject identifies the object for which attribute replication metadata is requested. + /// DS_REPL_INFO_CURSORS_2_FOR_NC + /// DS_REPL_INFO_CURSORS_3_FOR_NC + /// DS_REPL_INFO_METADATA_2_FOR_OBJ + /// pszObject identifies the object for which replication metadata is requested. + /// DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE + /// pszObject identifies the object for which attribute replication metadata is requested. + /// Pointer to a GUID value that identifies a specific replication source. If this parameter is not NULL and the + /// InfoType parameter contains DS_REPL_INFO_NEIGHBORS, only neighbor data for the source corresponding to the nTDSDSA object + /// with the given objectGuid in the directory is returned. This parameter is ignored if NULL or if the InfoType + /// parameter is anything other than DS_REPL_INFO_NEIGHBORS. + /// + /// Pointer to a null-terminated Unicode string that contains the name of the specific attribute to retrieve replication data for. + /// + /// This parameter is only used if the InfoType parameter contains one of the following values. + /// DS_REPL_INFO_METADATA_FOR_ATTR_VALUE + /// DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE + /// Pointer to a null-terminated Unicode string that contains the distinguished name value to match. If the requested attribute is a + /// distinguished name type value, this function return the attributes that contain the specified value. + /// Contains a set of flags that modify the behavior of the function. This parameter can be zero or the following value. + /// DS_REPL_INFO_FLAG_IMPROVE_LINKED_ATTRS + /// + /// Causes the attribute metadata to account for metadata on the attribute's linked values. The resulting vector represents changes + /// for all attributes. This modified vector is useful for clients that expect all attributes and metadata to be included in the + /// attribute metadata vector. + /// + /// Contains the index of the next entry to retrieve. This parameter must be set to zero the first time this function is called. + /// This parameter is only used if the InfoType parameter contains one of the following values. + /// DS_REPL_INFO_CURSORS_2_FOR_NC + /// DS_REPL_INFO_CURSORS_3_FOR_NC + /// DS_REPL_INFO_METADATA_FOR_ATTR_VALUE + /// DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE + /// + /// This function will retrieve a maximum of 1000 entries on each call. If after calling this function, more entries are available, + /// the dwEnumerationContext member of the retrieved structure will contain the index of the next entry to retrieve. The + /// dwEnumerationContext member of the retrieved structure is then used as the dwEnumerationContext parameter in the next call + /// to this function. When all of the entries have been retrieved, the dwEnumerationContext member of the retrieved structure + /// will contain -1. If -1 is passed for this parameter, this function will return ERROR_NO_MORE_ITEMS. + /// + /// + /// Address of a structure pointer that receives the requested data. The value of the InfoType parameter determines the format of + /// this structure. For more information and a list of possible InfoType values and the corresponding structure types, see DS_REPL_INFO_TYPE. + /// + /// The caller must free this memory when it is no longer required by calling DsReplicaFreeInfo. + /// + /// Returns ERROR_SUCCESS if successful or a Win32 or RPC error otherwise. The following are possible error codes. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/nf-ntdsapi-dsreplicagetinfo2w NTDSAPI DWORD DsReplicaGetInfo2W( + // HANDLE hDS, DS_REPL_INFO_TYPE InfoType, LPCWSTR pszObject, UUID *puuidForSourceDsaObjGuid, LPCWSTR pszAttributeName, LPCWSTR + // pszValue, DWORD dwFlags, DWORD dwEnumerationContext, VOID **ppInfo ); + [DllImport(Lib.NTDSApi, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("ntdsapi.h", MSDNShortId = "5735d91d-1b7d-4dc6-b6c6-61ba38ebe50d")] + private static unsafe extern Win32Error DsReplicaGetInfo2W(SafeDsHandle hDS, DS_REPL_INFO_TYPE InfoType, [Optional] string pszObject, Guid* puuidForSourceDsaObjGuid, [Optional] string pszAttributeName, + [Optional] string pszValue, DsReplInfoFlags dwFlags, uint dwEnumerationContext, out SafeDsReplicaInfo ppInfo); + /// Provides a handle to a domain controller info structure. [StructLayout(LayoutKind.Sequential)] public struct DCInfoHandle : IHandle @@ -1108,17 +2914,17 @@ namespace Vanara.PInvoke public IEnumerable ToIEnum(uint count) where T : struct => handle.ToIEnum((int)count); } + /// Indicates that the structure can be passed to DsGetDomainControllerInfo. + public interface IDsGetDCResult { } + /// - /// /// The DS_DOMAIN_CONTROLLER_INFO_1 structure contains data about a domain controller. This structure is returned by the /// DsGetDomainControllerInfo function. - /// /// + /// /// - /// /// The DsGetDomainControllerInfo function can return different versions of this structure. For more information and a list of the /// currently supported versions, see the InfoLevel parameter of DsGetDomainControllerInfo. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-ds_domain_controller_info_1a typedef struct // DS_DOMAIN_CONTROLLER_INFO_1A { #if ... CHAR *NetbiosName; #if ... CHAR *DnsHostName; #if ... CHAR *SiteName; #if ... CHAR @@ -1126,12 +2932,31 @@ namespace Vanara.PInvoke // SiteName; #endif #else LPSTR ComputerObjectName; #endif #else LPSTR ServerObjectName; #endif BOOL fIsPdc; BOOL fDsEnabled; } *PDS_DOMAIN_CONTROLLER_INFO_1A; [PInvokeData("ntdsapi.h", MSDNShortId = "6cc829ac-2aa6-49ef-b1ab-9c249249e0d6")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - public struct DS_DOMAIN_CONTROLLER_INFO_1 + public struct DS_DOMAIN_CONTROLLER_INFO_1 : IDsGetDCResult { + /// + /// Pointer to a null-terminated string that specifies the NetBIOS name of the domain controller. + /// public StrPtrAuto NetbiosName; + + /// + /// Pointer to a null-terminated string that specifies the DNS host name of the domain controller. + /// public StrPtrAuto DnsHostName; + + /// + /// Pointer to a null-terminated string that specifies the site to which the domain controller belongs. + /// public StrPtrAuto SiteName; + + /// + /// Pointer to a null-terminated string that specifies the name of the computer object on the domain controller. + /// public StrPtrAuto ComputerObjectName; + + /// + /// Pointer to a null-terminated string that specifies the name of the server object on the domain controller. + /// public StrPtrAuto ServerObjectName; /// @@ -1150,16 +2975,13 @@ namespace Vanara.PInvoke } /// - /// /// The DS_DOMAIN_CONTROLLER_INFO_2 structure contains data about a domain controller. This structure is returned by the /// DsGetDomainControllerInfo function. - /// /// + /// /// - /// /// The DsGetDomainControllerInfo function can return different versions of this structure. For more information and a list of the /// currently supported versions, see the InfoLevel parameter of DsGetDomainControllerInfo. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-ds_domain_controller_info_2a typedef struct // DS_DOMAIN_CONTROLLER_INFO_2A { #if ... CHAR *NetbiosName; #if ... CHAR *DnsHostName; #if ... CHAR *SiteName; #if ... CHAR @@ -1169,14 +2991,41 @@ namespace Vanara.PInvoke // fDsEnabled; BOOL fIsGc; GUID SiteObjectGuid; GUID ComputerObjectGuid; GUID ServerObjectGuid; GUID NtdsDsaObjectGuid; } *PDS_DOMAIN_CONTROLLER_INFO_2A; [PInvokeData("ntdsapi.h", MSDNShortId = "9d45b732-363d-4b20-ae5c-e9e76264bf1f")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - public struct DS_DOMAIN_CONTROLLER_INFO_2 + public struct DS_DOMAIN_CONTROLLER_INFO_2 : IDsGetDCResult { + /// + /// Pointer to a null-terminated string that specifies the NetBIOS name of the domain controller. + /// public StrPtrAuto NetbiosName; + + /// + /// Pointer to a null-terminated string that specifies the DNS host name of the domain controller. + /// public StrPtrAuto DnsHostName; + + /// + /// Pointer to a null-terminated string that specifies the site to which the domain controller belongs. + /// public StrPtrAuto SiteName; + + /// + /// Pointer to a null-terminated string that specifies the name of the site object on the domain controller. + /// public StrPtrAuto SiteObjectName; + + /// + /// Pointer to a null-terminated string that specifies the name of the computer object on the domain controller. + /// public StrPtrAuto ComputerObjectName; + + /// + /// Pointer to a null-terminated string that specifies the name of the server object on the domain controller. + /// public StrPtrAuto ServerObjectName; + + /// + /// Pointer to a null-terminated string that specifies the name of the NTDS DSA object on the domain controller. + /// public StrPtrAuto NtdsDsaObjectName; /// @@ -1200,30 +3049,35 @@ namespace Vanara.PInvoke [MarshalAs(UnmanagedType.Bool)] public bool fIsGc; - /// Contains the GUID for the site object on the domain controller. + /// + /// Contains the GUID for the site object on the domain controller. + /// public Guid SiteObjectGuid; - /// Contains the GUID for the computer object on the domain controller. + /// + /// Contains the GUID for the computer object on the domain controller. + /// public Guid ComputerObjectGuid; - /// Contains the GUID for the server object on the domain controller. + /// + /// Contains the GUID for the server object on the domain controller. + /// public Guid ServerObjectGuid; - /// Contains the GUID for the NTDS DSA object on the domain controller. + /// + /// Contains the GUID for the NTDS DSA object on the domain controller. + /// public Guid NtdsDsaObjectGuid; } /// - /// /// The DS_DOMAIN_CONTROLLER_INFO_3 structure contains data about a domain controller. This structure is returned by the /// DsGetDomainControllerInfo function. - /// /// + /// /// - /// /// The DsGetDomainControllerInfo function can return different versions of this structure. For more information and a list of the /// currently supported versions, see the InfoLevel parameter of DsGetDomainControllerInfo. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-ds_domain_controller_info_3a typedef struct // DS_DOMAIN_CONTROLLER_INFO_3A { #if ... CHAR *NetbiosName; #if ... CHAR *DnsHostName; #if ... CHAR *SiteName; #if ... CHAR @@ -1234,14 +3088,41 @@ namespace Vanara.PInvoke // } *PDS_DOMAIN_CONTROLLER_INFO_3A; [PInvokeData("ntdsapi.h", MSDNShortId = "510f458e-4c08-41c7-b290-1372ac9c8beb")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - public struct DS_DOMAIN_CONTROLLER_INFO_3 + public struct DS_DOMAIN_CONTROLLER_INFO_3 : IDsGetDCResult { + /// + /// Pointer to a null-terminated string that specifies the NetBIOS name of the domain controller. + /// public StrPtrAuto NetbiosName; + + /// + /// Pointer to a null-terminated string that specifies the DNS host name of the domain controller. + /// public StrPtrAuto DnsHostName; + + /// + /// Pointer to a null-terminated string that specifies the site to which the domain controller belongs. + /// public StrPtrAuto SiteName; + + /// + /// Pointer to a null-terminated string that specifies the name of the site object on the domain controller. + /// public StrPtrAuto SiteObjectName; + + /// + /// Pointer to a null-terminated string that specifies the name of the computer object on the domain controller. + /// public StrPtrAuto ComputerObjectName; + + /// + /// Pointer to a null-terminated string that specifies the name of the server object on the domain controller. + /// public StrPtrAuto ServerObjectName; + + /// + /// Pointer to a null-terminated string that specifies the name of the NTDS DSA object on the domain controller. + /// public StrPtrAuto NtdsDsaObjectName; /// @@ -1272,20 +3153,30 @@ namespace Vanara.PInvoke [MarshalAs(UnmanagedType.Bool)] public bool fIsRodc; - /// Contains the GUID for the site object on the domain controller. + /// + /// Contains the GUID for the site object on the domain controller. + /// public Guid SiteObjectGuid; - /// Contains the GUID for the computer object on the domain controller. + /// + /// Contains the GUID for the computer object on the domain controller. + /// public Guid ComputerObjectGuid; - /// Contains the GUID for the server object on the domain controller. + /// + /// Contains the GUID for the server object on the domain controller. + /// public Guid ServerObjectGuid; - /// Contains the GUID for the NTDS DSA object on the domain controller. + /// + /// Contains the GUID for the NTDS DSA object on the domain controller. + /// public Guid NtdsDsaObjectGuid; } - /// Used with the DsCrackNames function to contain the names converted by the function. + /// + /// Used with the DsCrackNames function to contain the names converted by the function. + /// [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [PInvokeData("NTDSApi.h", MSDNShortId = "ms676246")] public struct DS_NAME_RESULT @@ -1298,16 +3189,23 @@ namespace Vanara.PInvoke /// public IntPtr rItems; // PDS_NAME_RESULT_ITEM - /// Enumeration of DS_NAME_RESULT_ITEM structures. Each element of this array represents a single converted name. + /// + /// Enumeration of DS_NAME_RESULT_ITEM structures. Each element of this array represents a single converted name. + /// + /// The items. public DS_NAME_RESULT_ITEM[] Items => rItems.ToArray((int)cItems); } - /// Contains a name converted by the DsCrackNames function, along with associated error and domain data. + /// + /// Contains a name converted by the DsCrackNames function, along with associated error and domain data. + /// [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [PInvokeData("NTDSApi.h", MSDNShortId = "ms676246")] public struct DS_NAME_RESULT_ITEM { - /// Contains one of the DS_NAME_ERROR values that indicates the status of this name conversion. + /// + /// Contains one of the DS_NAME_ERROR values that indicates the status of this name conversion. + /// public DS_NAME_ERROR status; /// @@ -1319,11 +3217,1913 @@ namespace Vanara.PInvoke /// A string that specifies the newly formatted object name. public string pName; - /// Returns a that represents this instance. - /// A that represents this instance. + /// + /// Returns a that represents this instance. + /// + /// A that represents this instance. public override string ToString() => status == DS_NAME_ERROR.DS_NAME_NO_ERROR ? pName : $"{status}"; } + /// + /// The DS_REPL_ATTR_META_DATA structure is used with the DsReplicaGetInfo and DsReplicaGetInfo2 functions to contain + /// replication state data for an object attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_attr_meta_data typedef struct + // _DS_REPL_ATTR_META_DATA { LPWSTR pszAttributeName; DWORD dwVersion; FILETIME ftimeLastOriginatingChange; UUID + // uuidLastOriginatingDsaInvocationID; USN usnOriginatingChange; USN usnLocalChange; } DS_REPL_ATTR_META_DATA; + [PInvokeData("ntdsapi.h", MSDNShortId = "27ccc1c9-03d7-4d13-b9ec-65d6b8bdfd37")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_ATTR_META_DATA + { + /// + /// Pointer to a null-terminated Unicode string that contains the LDAP display name of the attribute corresponding to this metadata. + /// + public string pszAttributeName; + + /// + /// Contains the version of this attribute. Each originating modification of the attribute increases this value by one. + /// Replication of a modification does not affect the version. + /// + public uint dwVersion; + + /// + /// Contains the time at which the last originating change was made to this attribute. Replication of the change does not affect + /// this value. + /// + public FILETIME ftimeLastOriginatingChange; + + /// + /// Contains the invocation identification of the server on which the last change was made to this attribute. Replication of the + /// change does not affect this value. + /// + public Guid uuidLastOriginatingDsaInvocationID; + + /// + /// Contains the update sequence number (USN) on the originating server at which the last change to this attribute was made. + /// Replication of the change does not affect this value. + /// + public long usnOriginatingChange; + + /// + /// Contains the USN on the destination server (the server from which the DsReplicaGetInfo function retrieved the metadata) at + /// which the last change to this attribute was applied. This value typically is different on all servers. + /// + public long usnLocalChange; + } + + /// + /// The DS_REPL_ATTR_META_DATA_2 structure is used with the DsReplicaGetInfo and DsReplicaGetInfo2 functions to contain + /// replication state data for an object attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_attr_meta_data_2 typedef struct + // _DS_REPL_ATTR_META_DATA_2 { LPWSTR pszAttributeName; DWORD dwVersion; FILETIME ftimeLastOriginatingChange; UUID + // uuidLastOriginatingDsaInvocationID; USN usnOriginatingChange; USN usnLocalChange; LPWSTR pszLastOriginatingDsaDN; } DS_REPL_ATTR_META_DATA_2; + [PInvokeData("ntdsapi.h", MSDNShortId = "392457b7-df69-44d0-82b2-8381d5877354")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_ATTR_META_DATA_2 + { + /// + /// Pointer to a null-terminated Unicode string that contains the LDAP display name of the attribute that corresponds to this metadata. + /// + public string pszAttributeName; + + /// + /// Contains the version of this attribute. Each originating modification of the attribute increases this value by one. + /// Replication of a modification does not affect the version. + /// + public uint dwVersion; + + /// + /// Contains the time at which the last originating change was made to this attribute. Replication of the change does not affect + /// this value. + /// + public FILETIME ftimeLastOriginatingChange; + + /// + /// Contains the invocation identification of the server on which the last change was made to this attribute. Replication of the + /// change does not affect this value. + /// + public Guid uuidLastOriginatingDsaInvocationID; + + /// + /// Contains the update sequence number (USN) on the originating server at which the last change to this attribute was made. + /// Replication of the change does not affect this value. + /// + public long usnOriginatingChange; + + /// + /// Contains the USN on the destination server (the server from which the DsReplicaGetInfo function retrieved the metadata) at + /// which the last change to this attribute was applied. This value typically is different on all servers. + /// + public long usnLocalChange; + + /// + /// Pointer to a null-terminated Unicode string that contains the distinguished name of the directory system agent server that + /// originated the last replication. + /// + public string pszLastOriginatingDsaDN; + } + + /// + /// The DS_REPL_ATTR_META_DATA_BLOB structure is used to contain replication state data for an object attribute. This + /// structure is similar to the DS_REPL_ATTR_META_DATA_2 structure, but is obtained from the Lightweight Directory Access Protocol + /// API functions when obtaining binary data for the msDS-ReplAttributeMetaData attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_attr_meta_data_blob typedef struct + // _DS_REPL_ATTR_META_DATA_BLOB { DWORD oszAttributeName; DWORD dwVersion; FILETIME ftimeLastOriginatingChange; UUID + // uuidLastOriginatingDsaInvocationID; USN usnOriginatingChange; USN usnLocalChange; DWORD oszLastOriginatingDsaDN; } DS_REPL_ATTR_META_DATA_BLOB; + [PInvokeData("ntdsapi.h", MSDNShortId = "eee12de1-287a-4e76-9a9c-37e6b967971f")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_ATTR_META_DATA_BLOB + { + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the LDAP + /// display name of the attribute corresponding to this metadata. A value of zero indicates an empty or NULL string. + /// + public uint oszAttributeName; + + /// + /// Contains the version of this attribute. Each originating modification of the attribute increases this value by one. + /// Replication of a modification does not affect the version. + /// + public uint dwVersion; + + /// + /// Contains the time at which the last originating change was made to this attribute. Replication of the change does not affect + /// this value. + /// + public FILETIME ftimeLastOriginatingChange; + + /// + /// Contains the invocation identification of the server on which the last change was made to this attribute. Replication of the + /// change does not affect this value. + /// + public Guid uuidLastOriginatingDsaInvocationID; + + /// + /// Contains the update sequence number (USN) on the originating server at which the last change to this attribute was made. + /// Replication of the change does not affect this value. + /// + public long usnOriginatingChange; + + /// + /// Contains the USN on the destination server (the server from which the DsReplicaGetInfo function retrieved the metadata) at + /// which the last change to this attribute was applied. This value typically is different on all servers. + /// + public long usnLocalChange; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// distinguished name of the directory system agent server that originated the last replication. A value of zero indicates an + /// empty or NULL string. + /// + public uint oszLastOriginatingDsaDN; + } + + /// + /// The DS_REPL_ATTR_VALUE_META_DATA structure is used with the DsReplicaGetInfo2 function to provide metadata for a + /// collection of attribute values. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_attr_value_meta_data typedef struct + // _DS_REPL_ATTR_VALUE_META_DATA { DWORD cNumEntries; DWORD dwEnumerationContext; #if ... DS_REPL_VALUE_META_DATA rgMetaData[]; #else + // DS_REPL_VALUE_META_DATA rgMetaData[1]; #endif } DS_REPL_ATTR_VALUE_META_DATA; + [PInvokeData("ntdsapi.h", MSDNShortId = "b13cdd31-d154-4539-81d6-d7a449e2b3d5")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_ATTR_VALUE_META_DATA + { + /// + /// Contains the number of elements in the rgMetaData array. + /// + public uint cNumEntries; + + /// + /// Contains the zero-based index of the next entry to retrieve if more entries are available. This value is passed for the + /// dwEnumerationContext parameter in the next call to DsReplicaGetInfo2 to retrieve the next block of entries. If no more + /// entries are available, this member contains -1. + /// + public uint dwEnumerationContext; + + /// + /// Contains an array of DS_REPL_VALUE_META_DATA structures that contain the individual attribute replication values. The + /// cNumEntries member contains the number of elements in this array. + /// + public IntPtr _rgMetaData; + + /// + /// Gets an array of DS_REPL_VALUE_META_DATA structures that contain the individual attribute replication values. + /// + /// The rg meta data. + public DS_REPL_VALUE_META_DATA[] rgMetaData => _rgMetaData.ToArray((int)cNumEntries); + } + + /// + /// The DS_REPL_ATTR_VALUE_META_DATA_2 structure is used with the DsReplicaGetInfo2 function to provide metadata for a + /// collection of attribute values. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_attr_value_meta_data_2 typedef struct + // _DS_REPL_ATTR_VALUE_META_DATA_2 { DWORD cNumEntries; DWORD dwEnumerationContext; #if ... DS_REPL_VALUE_META_DATA_2 rgMetaData[]; + // #else DS_REPL_VALUE_META_DATA_2 rgMetaData[1]; #endif } DS_REPL_ATTR_VALUE_META_DATA_2; + [PInvokeData("ntdsapi.h", MSDNShortId = "2022362a-e2f7-4cfd-a512-cfe29e5d439d")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_ATTR_VALUE_META_DATA_2 + { + /// + /// Contains the number of elements in the rgMetaData array. + /// + public uint cNumEntries; + + /// + /// Contains the zero-based index of the next entry to retrieve if more entries are available. This value is passed for the + /// dwEnumerationContext parameter in the next call to DsReplicaGetInfo2 to retrieve the next block of entries. If no more + /// entries are available, this member contains -1. + /// + public uint dwEnumerationContext; + + /// + /// Contains an array of DS_REPL_VALUE_META_DATA_2 structures that contain the individual attribute replication values. The + /// cNumEntries member contains the number of elements in this array. + /// + public IntPtr _rgMetaData; + + /// + /// Gets an array of DS_REPL_VALUE_META_DATA_2 structures that contain the individual attribute replication values. + /// + /// The rg meta data. + public DS_REPL_VALUE_META_DATA_2[] rgMetaData => _rgMetaData.ToArray((int)cNumEntries); + } + + /// + /// Provides metadata for a collection of attribute replication values. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_attr_value_meta_data_ext typedef struct + // _DS_REPL_ATTR_VALUE_META_DATA_EXT { DWORD cNumEntries; DWORD dwEnumerationContext; #if ... DS_REPL_VALUE_META_DATA_EXT + // rgMetaData[]; #else DS_REPL_VALUE_META_DATA_EXT rgMetaData[1]; #endif } DS_REPL_ATTR_VALUE_META_DATA_EXT; + [PInvokeData("ntdsapi.h", MSDNShortId = "CA41C6BF-A485-4AC7-B761-3A07159C2FF1")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_ATTR_VALUE_META_DATA_EXT + { + /// The number of elements in the rgMetaData array. + public uint cNumEntries; + + /// + /// The zero-based index of the next entry to retrieve if more entries are available. This value is passed for the + /// dwEnumerationContext parameter in the next call to DsReplicaGetInfo2 to retrieve the next block of entries. If no more + /// entries are available, this member contains -1. + /// + public uint dwEnumerationContext; + + /// + /// Contains an array of DS_REPL_VALUE_META_DATA_EXT structures that contain the individual attribute replication values. The + /// cNumEntries member contains the number of elements in this array. + /// + public IntPtr _rgMetaData; + + /// + /// Gets an array of DS_REPL_VALUE_META_DATA_EXT structures that contain the individual attribute replication values. + /// + /// The rg meta data. + public DS_REPL_VALUE_META_DATA_EXT[] rgMetaData => _rgMetaData.ToArray((int)cNumEntries); + } + + /// + /// The DS_REPL_CURSOR structure contains inbound replication state data with respect to all replicas of a given naming + /// context, as returned by the DsReplicaGetInfo and DsReplicaGetInfo2 functions. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_cursor typedef struct _DS_REPL_CURSOR { UUID + // uuidSourceDsaInvocationID; USN usnAttributeFilter; } DS_REPL_CURSOR; + [PInvokeData("ntdsapi.h", MSDNShortId = "ab4ee8d8-5ccd-4f3f-a1c0-de78c65a10d3")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_CURSOR + { + /// + /// Contains the invocation identifier of the originating server to which the usnAttributeFilter corresponds. + /// + public Guid uuidSourceDsaInvocationID; + + /// + /// Contains the maximum update sequence number to which the destination server can indicate that it has recorded all changes + /// originated by the given server at update sequence numbers less than, or equal to, this update sequence number. This is used + /// to filter changes at replication source servers that the destination server has already applied. + /// + public long usnAttributeFilter; + } + + /// + /// The DS_REPL_CURSOR_2 structure contains inbound replication state data with respect to all replicas of a given naming + /// context, as returned by the DsReplicaGetInfo2 function. This structure is an enhanced version of the DS_REPL_CURSOR structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_cursor_2 typedef struct _DS_REPL_CURSOR_2 { UUID + // uuidSourceDsaInvocationID; USN usnAttributeFilter; FILETIME ftimeLastSyncSuccess; } DS_REPL_CURSOR_2; + [PInvokeData("ntdsapi.h", MSDNShortId = "ff839372-41f0-499a-9582-59ace02f1485")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_CURSOR_2 + { + /// + /// Contains the invocation identifier of the originating server to which the usnAttributeFilter corresponds. + /// + public Guid uuidSourceDsaInvocationID; + + /// + /// Contains the maximum update sequence number to which the destination server can indicate that it has recorded all changes + /// originated by the given server at update sequence numbers less than, or equal to, this update sequence number. This is used + /// to filter changes at replication source servers that the destination server has already applied. + /// + public long usnAttributeFilter; + + /// + /// Contains a FILETIME structure that contains the date and time of the last successful synchronization operation. + /// + public FILETIME ftimeLastSyncSuccess; + } + + /// + /// The DS_REPL_CURSOR_3 structure contains inbound replication state data with respect to all replicas of a given naming + /// context, as returned by the DsReplicaGetInfo2 function. This structure is an enhanced version of the DS_REPL_CURSOR and + /// DS_REPL_CURSOR_2 structures. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_cursor_3w typedef struct _DS_REPL_CURSOR_3W { + // UUID uuidSourceDsaInvocationID; USN usnAttributeFilter; FILETIME ftimeLastSyncSuccess; LPWSTR pszSourceDsaDN; } DS_REPL_CURSOR_3W; + [PInvokeData("ntdsapi.h", MSDNShortId = "0361a3e1-814c-4ef2-b574-2870a9289e52")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_CURSOR_3W + { + /// + /// Contains the invocation identifier of the originating server to which the usnAttributeFilter corresponds. + /// + public Guid uuidSourceDsaInvocationID; + + /// + /// Contains the maximum update sequence number to which the destination server can indicate that it has recorded all changes + /// originated by the given server at update sequence numbers less than, or equal to, this update sequence number. This is used + /// to filter changes at replication source servers that the destination server has already applied. + /// + public long usnAttributeFilter; + + /// + /// Contains a FILETIME structure that contains the date and time of the last successful synchronization operation. + /// + public FILETIME ftimeLastSyncSuccess; + + /// + /// Pointer to a null-terminated string that contains the distinguished name of the directory service agent that corresponds to + /// the source server to which this replication state data applies. + /// + public string pszSourceDsaDN; + } + + /// + /// The DS_REPL_CURSOR_BLOB structure contains inbound replication state data with respect to all replicas of a given naming + /// context. This structure is similar to the DS_REPL_CURSOR_3 structure, but is obtained from the Lightweight Directory Access + /// Protocol API functions when obtaining binary data for the msDS-NCReplCursors attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_cursor_blob typedef struct _DS_REPL_CURSOR_BLOB { + // UUID uuidSourceDsaInvocationID; USN usnAttributeFilter; FILETIME ftimeLastSyncSuccess; DWORD oszSourceDsaDN; } DS_REPL_CURSOR_BLOB; + [PInvokeData("ntdsapi.h", MSDNShortId = "c41e4737-5ef8-40ce-9af1-0afff7e11dc1")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_CURSOR_BLOB + { + /// + /// Contains the invocation identifier of the originating server to which the usnAttributeFilter corresponds. + /// + public Guid uuidSourceDsaInvocationID; + + /// + /// Contains the maximum update sequence number to which the destination server can indicate that it has recorded all changes + /// originated by the given server at update sequence numbers less than, or equal to, this update sequence number. This is used + /// to filter changes at replication source servers that the destination server has already applied. + /// + public long usnAttributeFilter; + + /// + /// Contains a FILETIME structure that contains the date and time of the last successful synchronization operation. + /// + public FILETIME ftimeLastSyncSuccess; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// distinguished name of the directory service agent that corresponds to the source server to which this replication state data applies. + /// + public uint oszSourceDsaDN; + } + + /// + /// The DS_REPL_CURSORS structure is used with the DsReplicaGetInfo and DsReplicaGetInfo2 function to provide replication + /// state data with respect to all replicas of a given naming context. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_cursors typedef struct _DS_REPL_CURSORS { DWORD + // cNumCursors; DWORD dwReserved; #if ... DS_REPL_CURSOR rgCursor[]; #else DS_REPL_CURSOR rgCursor[1]; #endif } DS_REPL_CURSORS; + [PInvokeData("ntdsapi.h", MSDNShortId = "0fe5ad72-d3f3-42a8-a36f-ca1fc9c55c50")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_CURSORS + { + /// Contains the number of elements in the rgCursor array. + public uint cNumCursors; + + /// Reserved for future use. + public uint dwReserved; + + /// + /// Contains an array of DS_REPL_CURSOR structures that contain the requested replication data. The cNumCursors member contains + /// the number of elements in this array. + /// + public IntPtr _rgCursor; + + /// + /// Contains an array of DS_REPL_CURSOR structures that contain the requested replication data. + /// + /// The rg cursor. + public DS_REPL_CURSOR[] rgCursor => _rgCursor.ToArray((int)cNumCursors); + } + + /// + /// The DS_REPL_CURSORS_2 structure is used with the DsReplicaGetInfo2 function to provide replication state data with respect + /// to all replicas of a given naming context. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_cursors_2 typedef struct _DS_REPL_CURSORS_2 { + // DWORD cNumCursors; DWORD dwEnumerationContext; #if ... DS_REPL_CURSOR_2 rgCursor[]; #else DS_REPL_CURSOR_2 rgCursor[1]; #endif } DS_REPL_CURSORS_2; + [PInvokeData("ntdsapi.h", MSDNShortId = "5a1981ac-3b6a-4e48-8430-f8297ddd3283")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_CURSORS_2 + { + /// Contains the number of elements in the rgCursor array. + public uint cNumCursors; + + /// + /// Contains the zero-based index of the next entry to retrieve if more entries are available. This value is passed for the + /// dwEnumerationContext parameter in the next call to DsReplicaGetInfo2 to retrieve the next block of entries. If no more + /// entries are available, this member contains -1. + /// + public uint dwEnumerationContext; + + /// + /// Contains an array of DS_REPL_CURSOR_2 structures that contain the requested replication data. The cNumCursors member contains + /// the number of elements in this array. + /// + public IntPtr _rgCursor; + + /// + /// Contains an array of DS_REPL_CURSOR_2 structures that contain the requested replication data. + /// + /// The rg cursor. + public DS_REPL_CURSOR_2[] rgCursor => _rgCursor.ToArray((int)cNumCursors); + } + + /// + /// The DS_REPL_CURSORS_3 structure is used with the DsReplicaGetInfo2 function to provide replication state data with respect + /// to all replicas of a given naming context. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_cursors_3w typedef struct _DS_REPL_CURSORS_3W { + // DWORD cNumCursors; DWORD dwEnumerationContext; #if ... DS_REPL_CURSOR_3W rgCursor[]; #else DS_REPL_CURSOR_3W rgCursor[1]; #endif } DS_REPL_CURSORS_3W; + [PInvokeData("ntdsapi.h", MSDNShortId = "7b8e0015-dd8f-4cba-8ea2-683cb107f294")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_CURSORS_3W + { + /// Contains the number of elements in the rgCursor array. + public uint cNumCursors; + + /// + /// Contains the zero-based index of the next entry to retrieve if more entries are available. This value is passed for the + /// dwEnumerationContext parameter in the next call to DsReplicaGetInfo2 to retrieve the next block of entries. If no more + /// entries are available, this member contains -1. + /// + public uint dwEnumerationContext; + + /// + /// Contains an array of DS_REPL_CURSOR_3W structures that contain the requested replication data. The cNumCursors member + /// contains the number of elements in this array. + /// + public IntPtr _rgCursor; + + /// + /// Contains an array of DS_REPL_CURSOR_3W structures that contain the requested replication data. + /// + /// The rg cursor. + public DS_REPL_CURSOR_3W[] rgCursor => _rgCursor.ToArray((int)cNumCursors); + } + + /// + /// The DS_REPL_KCC_DSA_FAILURES structure contains an array of DS_REPL_KCC_DSA_FAILURE structures, which in turn contain + /// replication state data with respect to inbound replication partners, as returned by the DsReplicaGetInfo and DsReplicaGetInfo2 functions. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_kcc_dsa_failuresw typedef struct + // _DS_REPL_KCC_DSA_FAILURESW { DWORD cNumEntries; DWORD dwReserved; #if ... DS_REPL_KCC_DSA_FAILUREW rgDsaFailure[]; #else + // DS_REPL_KCC_DSA_FAILUREW rgDsaFailure[1]; #endif } DS_REPL_KCC_DSA_FAILURESW; + [PInvokeData("ntdsapi.h", MSDNShortId = "bb011502-38ae-43b7-a6ad-de16b499f61b")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_KCC_DSA_FAILURESW + { + /// + /// Contains the number of elements in the rgMetaData array. + /// + public uint cNumEntries; + + /// Reserved for future use. + public uint dwReserved; + + /// + /// Contains an array of DS_REPL_KCC_DSA_FAILURE structures that contain the requested replication data. The cNumEntries member + /// contains the number of elements in this array. + /// + public IntPtr _rgDsaFailure; + + /// + /// Contains an array of DS_REPL_KCC_DSA_FAILURE structures that contain the requested replication data. + /// + /// The rg DSA failure. + public DS_REPL_KCC_DSA_FAILUREW[] rgDsaFailure => _rgDsaFailure.ToArray((int)cNumEntries); + } + + /// + /// The DS_REPL_KCC_DSA_FAILURE structure contains replication state data about a specific inbound replication partner, as + /// returned by the DsReplicaGetInfo and DsReplicaGetInfo2 function. This state data is compiled and used by the Knowledge + /// Consistency Checker (KCC) to decide when alternate replication routes must be added to account for unreachable servers. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_kcc_dsa_failurew typedef struct + // _DS_REPL_KCC_DSA_FAILUREW { LPWSTR pszDsaDN; UUID uuidDsaObjGuid; FILETIME ftimeFirstFailure; DWORD cNumFailures; DWORD + // dwLastResult; } DS_REPL_KCC_DSA_FAILUREW; + [PInvokeData("ntdsapi.h", MSDNShortId = "7a7131ce-a647-4b3d-a9f3-091b6dcebff7")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_KCC_DSA_FAILUREW + { + /// + /// Pointer to a null-terminated string that contains the distinguished name of the directory system agent object in the + /// directory that corresponds to the source server. + /// + public string pszDsaDN; + + /// + /// Contains the objectGuid of the directory system agent object represented by the pszDsaDN member. + /// + public Guid uuidDsaObjGuid; + + /// + /// + /// Contains a FILETIME structure which the contents of depends on the value passed for the InfoType parameter when + /// DsReplicaGetInfo or DsReplicaGetInfo2 function was called. + /// + /// DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES + /// Contains the date and time that the first failure occurred when replicating from the source server. + /// DS_REPL_INFO_KCC_DSA_LINK_FAILURES + /// Contains the date and time of the last successful replication. + /// + public FILETIME ftimeFirstFailure; + + /// + /// Contains the number of consecutive failures since the last successful replication. + /// + public uint cNumFailures; + + /// + /// Contains the error code associated with the most recent failure, or ERROR_SUCCESS if the specific error is unavailable. + /// + public Win32Error dwLastResult; + } + + /// + /// The DS_REPL_KCC_DSA_FAILUREW_BLOB structure contains replication state data with respect to a specific inbound replication + /// partner. This state data is compiled and used by the Knowledge Consistency Checker (KCC) to decide when alternate replication + /// routes must be added to account for unreachable servers. This structure is similar to the DS_REPL_KCC_DSA_FAILURE structure, but + /// is obtained from the Lightweight Directory Access Protocol API functions when obtaining binary data for the + /// msDS-ReplConnectionFailures or msDS-ReplLinkFailures attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_kcc_dsa_failurew_blob typedef struct + // _DS_REPL_KCC_DSA_FAILUREW_BLOB { DWORD oszDsaDN; UUID uuidDsaObjGuid; FILETIME ftimeFirstFailure; DWORD cNumFailures; DWORD + // dwLastResult; } DS_REPL_KCC_DSA_FAILUREW_BLOB; + [PInvokeData("ntdsapi.h", MSDNShortId = "b0df588a-2ef1-4870-b304-c6f9e07322b0")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_KCC_DSA_FAILUREW_BLOB + { + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated string that contains the distinguished + /// name of the directory system agent object in the directory that corresponds to the source server. + /// + public uint oszDsaDN; + + /// + /// Contains the objectGuid of the directory system agent object represented by the oszDsaDN member. + /// + public Guid uuidDsaObjGuid; + + /// + /// Contains a FILETIME structure which the contents of depends on the requested binary replication data. + /// msDS-ReplConnectionFailures + /// Contains the date and time that the first failure occurred when replicating from the source server. + /// msDS-ReplLinkFailures + /// Contains the date and time of the last successful replication. + /// + public FILETIME ftimeFirstFailure; + + /// + /// Contains the number of consecutive failures since the last successful replication. + /// + public uint cNumFailures; + + /// + /// Contains the error code associated with the most recent failure, or ERROR_SUCCESS if the specific error is unavailable. + /// + public Win32Error dwLastResult; + } + + /// + /// The DS_REPL_NEIGHBOR structure contains inbound replication state data for a particular naming context and source server + /// pair, as returned by the DsReplicaGetInfo and DsReplicaGetInfo2 functions. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_neighborw typedef struct _DS_REPL_NEIGHBORW { + // LPWSTR pszNamingContext; LPWSTR pszSourceDsaDN; LPWSTR pszSourceDsaAddress; LPWSTR pszAsyncIntersiteTransportDN; DWORD + // dwReplicaFlags; DWORD dwReserved; UUID uuidNamingContextObjGuid; UUID uuidSourceDsaObjGuid; UUID uuidSourceDsaInvocationID; UUID + // uuidAsyncIntersiteTransportObjGuid; USN usnLastObjChangeSynced; USN usnAttributeFilter; FILETIME ftimeLastSyncSuccess; FILETIME + // ftimeLastSyncAttempt; DWORD dwLastSyncResult; DWORD cNumConsecutiveSyncFailures; } DS_REPL_NEIGHBORW; + [PInvokeData("ntdsapi.h", MSDNShortId = "acab74f4-5739-4310-895b-081062c0360b")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_NEIGHBOR + { + /// + /// Pointer to a null-terminated string that contains the naming context to which this replication state data pertains. Each + /// naming context is replicated independently and has different associated neighbor data, even if the naming contexts are + /// replicated from the same source server. + /// + public string pszNamingContext; + + /// + /// Pointer to a null-terminated string that contains the distinguished name of the directory service agent corresponding to the + /// source server to which this replication state data pertains. Each source server has different associated neighbor data. + /// + public string pszSourceDsaDN; + + /// + /// Pointer to a null-terminated string that contains the transport-specific network address of the source server. That is, a + /// directory name service name for RPC/IP replication, or an SMTP address for an SMTP replication. + /// + public string pszSourceDsaAddress; + + /// + /// Pointer to a null-terminated string that contains the distinguished name of the interSiteTransport object that + /// corresponds to the transport over which replication is performed. This member contains NULL for RPC/IP replication. + /// + public string pszAsyncIntersiteTransportDN; + + /// + /// + /// Contains a set of flags that specify attributes and options for the replication data. This can be zero or a combination of + /// one or more of the following flags. + /// + /// DS_REPL_NBR_WRITEABLE (16 (0x10)) + /// The local copy of the naming context is writable. + /// DS_REPL_NBR_SYNC_ON_STARTUP (32 (0x20)) + /// + /// Replication of this naming context from this source is attempted when the destination server is booted. This normally only + /// applies to intra-site neighbors. + /// + /// DS_REPL_NBR_DO_SCHEDULED_SYNCS (64 (0x40)) + /// + /// Perform replication on a schedule. This flag is normally set unless the schedule for this naming context/source is "never", + /// that is, the empty schedule. + /// + /// DS_REPL_NBR_USE_ASYNC_INTERSITE_TRANSPORT (128 (0x80)) + /// + /// Perform replication indirectly through the Inter-Site Messaging Service. This flag is set only when replicating over SMTP. + /// This flag is not set when replicating over inter-site RPC/IP. + /// + /// DS_REPL_NBR_TWO_WAY_SYNC (512 (0x200)) + /// + /// If set, indicates that when inbound replication is complete, the destination server must tell the source server to + /// synchronize in the reverse direction. This feature is used in dial-up scenarios where only one of the two servers can + /// initiate a dial-up connection. For example, this option would be used in a corporate headquarters and branch office, where + /// the branch office connects to the corporate headquarters over the Internet by means of a dial-up ISP connection. + /// + /// DS_REPL_NBR_RETURN_OBJECT_PARENTS (2048 (0x800)) + /// + /// This neighbor is in a state where it returns parent objects before children objects. It goes into this state after it + /// receives a child object before its parent. + /// + /// DS_REPL_NBR_FULL_SYNC_IN_PROGRESS (65536 (0x10000)) + /// + /// The destination server is performing a full synchronization from the source server. Full synchronizations do not use vectors + /// that create updates (DS_REPL_CURSORS) for filtering updates. Full synchronizations are not used as a part of the normal + /// replication protocol. + /// + /// DS_REPL_NBR_FULL_SYNC_NEXT_PACKET (131072 (0x20000)) + /// + /// The last packet from the source indicated a modification of an object that the destination server has not yet created. The + /// next packet to be requested instructs the source server to put all attributes of the modified object into the packet. + /// + /// DS_REPL_NBR_NEVER_SYNCED (2097152 (0x200000)) + /// A synchronization has never been successfully completed from this source. + /// DS_REPL_NBR_PREEMPTED (16777216 (0x1000000)) + /// + /// The replication engine has temporarily stopped processing this neighbor in order to service another higher-priority neighbor, + /// either for this partition or for another partition. The replication engine will resume processing this neighbor after the + /// higher-priority work is completed. + /// + /// DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS (67108864 (0x4000000)) + /// + /// This neighbor is set to disable notification-based synchronizations. Within a site, domain controllers synchronize with each + /// other based on notifications when changes occur. This setting prevents this neighbor from performing syncs that are triggered + /// by notifications. The neighbor will still do synchronizations based on its schedule, or in response to manually requested synchronizations. + /// + /// DS_REPL_NBR_DISABLE_SCHEDULED_SYNC (134217728 (0x8000000)) + /// + /// This neighbor is set to not perform synchronizations based on its schedule. The only way this neighbor will perform + /// synchronizations is in response to change notifications or to manually requested synchronizations. + /// + /// DS_REPL_NBR_COMPRESS_CHANGES (268435456 (0x10000000)) + /// + /// Changes received from this source are to be compressed. This is normally set if, and only if, the source server is in a + /// different site. + /// + /// DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS (536870912 (0x20000000)) + /// + /// No change notifications should be received from this source. Normally set if, and only if, the source server is in a + /// different site. + /// + /// DS_REPL_NBR_PARTIAL_ATTRIBUTE_SET (1073741824 (0x40000000)) + /// + /// This neighbor is in a state where it is rebuilding the contents of this replica because of a change in the partial attribute set. + /// + /// + public DsReplNeighborFlags dwReplicaFlags; + + /// Reserved for future use. + public uint dwReserved; + + /// + /// Contains the objectGuid of the naming context corresponding to pszNamingContext. + /// + public Guid uuidNamingContextObjGuid; + + /// + /// Contains the objectGuid of the nTDSDSA object corresponding to pszSourceDsaDN. + /// + public Guid uuidSourceDsaObjGuid; + + /// + /// Contains the invocation identifier used by the source server as of the last replication attempt. + /// + public Guid uuidSourceDsaInvocationID; + + /// + /// Contains the objectGuid of the inter-site transport object corresponding to pszAsyncIntersiteTransportDN. + /// + public Guid uuidAsyncIntersiteTransportObjGuid; + + /// + /// Contains the update sequence number of the last object update received. + /// + public long usnLastObjChangeSynced; + + /// + /// Contains the usnLastObjChangeSynced value at the end of the last complete, successful replication cycle, or 0 if none. + /// Attributes at the source last updated at a update sequence number less than or equal to this value have already been received + /// and applied by the destination. + /// + public long usnAttributeFilter; + + /// + /// Contains a FILETIME structure that contains the date and time the last successful replication cycle was completed from this + /// source. All members of this structure are zero if the replication cycle has never been completed. + /// + public FILETIME ftimeLastSyncSuccess; + + /// + /// Contains a FILETIME structure that contains the date and time of the last replication attempt from this source. All members + /// of this structure are zero if the replication has never been attempted. + /// + public FILETIME ftimeLastSyncAttempt; + + /// + /// Contains an error code associated with the last replication attempt from this source. Contains ERROR_SUCCESS if the + /// last attempt succeeded. + /// + public Win32Error dwLastSyncResult; + + /// + /// Contains the number of failed replication attempts from this source since the last successful replication attempt - or since + /// the source was added as a neighbor, if no previous attempt was successful. + /// + public uint cNumConsecutiveSyncFailures; + } + + /// + /// The DS_REPL_NEIGHBORS structure is used with the DsReplicaGetInfo and DsReplicaGetInfo2 functions to provide inbound + /// replication state data for naming context and source server pairs. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_neighborsw typedef struct _DS_REPL_NEIGHBORSW { + // DWORD cNumNeighbors; DWORD dwReserved; #if ... DS_REPL_NEIGHBORW rgNeighbor[]; #else DS_REPL_NEIGHBORW rgNeighbor[1]; #endif } DS_REPL_NEIGHBORSW; + [PInvokeData("ntdsapi.h", MSDNShortId = "1307399b-de29-43ec-97b4-05cd70c1a92d")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct DS_REPL_NEIGHBORS + { + /// + /// Contains the number of elements in the rgNeighbor array. + /// + public uint cNumNeighbors; + + /// Reserved for future use. + public uint dwReserved; + + /// + /// Contains an array of DS_REPL_NEIGHBOR structures that contain the requested replication data. The cNumNeighbors member + /// contains the number of elements in this array. + /// + public IntPtr _rgNeighbor; + + /// + /// Contains an array of DS_REPL_NEIGHBOR structures that contain the requested replication data. + /// + /// The rg neighbor. + public DS_REPL_NEIGHBOR[] rgNeighbor => _rgNeighbor.ToArray((int)cNumNeighbors); + } + + /// + /// The DS_REPL_NEIGHBORW_BLOB structure contains inbound replication state data for a particular naming context and source + /// server pair. This structure is similar to the DS_REPL_NEIGHBOR structure, but is obtained from the Lightweight Directory Access + /// Protocol API functions when obtaining binary data for the msDS-NCReplInboundNeighbors attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_neighborw_blob typedef struct + // _DS_REPL_NEIGHBORW_BLOB { DWORD oszNamingContext; DWORD oszSourceDsaDN; DWORD oszSourceDsaAddress; DWORD + // oszAsyncIntersiteTransportDN; DWORD dwReplicaFlags; DWORD dwReserved; UUID uuidNamingContextObjGuid; UUID uuidSourceDsaObjGuid; + // UUID uuidSourceDsaInvocationID; UUID uuidAsyncIntersiteTransportObjGuid; USN usnLastObjChangeSynced; USN usnAttributeFilter; + // FILETIME ftimeLastSyncSuccess; FILETIME ftimeLastSyncAttempt; DWORD dwLastSyncResult; DWORD cNumConsecutiveSyncFailures; } DS_REPL_NEIGHBORW_BLOB; + [PInvokeData("ntdsapi.h", MSDNShortId = "1a56968a-29ed-4c94-80ee-02bdd279f5c2")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_NEIGHBORW_BLOB + { + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// naming context to which this replication state data pertains. Each naming context is replicated independently and has + /// different associated neighbor data, even if the naming contexts are replicated from the same source server. + /// + public uint oszNamingContext; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// distinguished name of the directory service agent corresponding to the source server to which this replication state data + /// pertains. Each source server has different associated neighbor data. + /// + public uint oszSourceDsaDN; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// transport-specific network address of the source server. That is, a directory name service name for RPC/IP replication, or an + /// SMTP address for an SMTP replication. + /// + public uint oszSourceDsaAddress; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// distinguished name of the interSiteTransport object that corresponds to the transport over which replication is + /// performed. This member contains NULL for RPC/IP replication. + /// + public uint oszAsyncIntersiteTransportDN; + + /// + /// + /// Contains a set of flags that specify attributes and options for the replication data. This can be zero or a combination of + /// one or more of the following flags. + /// + /// DS_REPL_NBR_WRITEABLE + /// The local copy of the naming context is writable. + /// DS_REPL_NBR_SYNC_ON_STARTUP + /// + /// Replication of this naming context from this source is attempted when the destination server is booted. This normally only + /// applies to intra-site neighbors. + /// + /// DS_REPL_NBR_DO_SCHEDULED_SYNCS + /// + /// Perform replication on a schedule. This flag is normally set unless the schedule for this naming context/source is "never", + /// that is, the empty schedule. + /// + /// DS_REPL_NBR_USE_ASYNC_INTERSITE_TRANSPORT + /// + /// Perform replication indirectly through the Inter-Site Messaging Service. This flag is set only when replicating over SMTP. + /// This flag is not set when replicating over inter-site RPC/IP. + /// + /// DS_REPL_NBR_TWO_WAY_SYNC + /// + /// If set, indicates that when inbound replication is complete, the destination server must tell the source server to + /// synchronize in the reverse direction. This feature is used in dial-up scenarios where only one of the two servers can + /// initiate a dial-up connection. For example, this option would be used in a corporate headquarters and branch office, where + /// the branch office connects to the corporate headquarters over the Internet by means of a dial-up ISP connection. + /// + /// DS_REPL_NBR_FULL_SYNC_IN_PROGRESS + /// + /// The destination server is performing a full synchronization from the source server. Full synchronizations do not use vectors + /// that create updates (DS_REPL_CURSORS) for filtering updates. Full synchronizations are not used as a part of the normal + /// replication protocol. + /// + /// DS_REPL_NBR_FULL_SYNC_NEXT_PACKET + /// + /// The last packet from the source indicated a modification of an object that the destination server has not yet created. The + /// next packet to be requested instructs the source server to put all attributes of the modified object into the packet. + /// + /// DS_REPL_NBR_NEVER_SYNCED + /// A synchronization has never been successfully completed from this source. + /// DS_REPL_NBR_COMPRESS_CHANGES + /// + /// Changes received from this source are to be compressed. This is normally set if, and only if, the source server is in a + /// different site. + /// + /// DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS + /// + /// No change notifications should be received from this source. Normally set if, and only if, the source server is in a + /// different site. + /// + /// + public uint dwReplicaFlags; + + /// Reserved for future use. + public uint dwReserved; + + /// + /// Contains the objectGuid of the naming context that corresponds to pszNamingContext. + /// + public Guid uuidNamingContextObjGuid; + + /// + /// Contains the objectGuid of the nTDSDSA object that corresponds to pszSourceDsaDN. + /// + public Guid uuidSourceDsaObjGuid; + + /// + /// Contains the invocation identifier used by the source server as of the last replication attempt. + /// + public Guid uuidSourceDsaInvocationID; + + /// + /// Contains the objectGuid of the inter-site transport object that corresponds to pszAsyncIntersiteTransportDN. + /// + public Guid uuidAsyncIntersiteTransportObjGuid; + + /// + /// Contains the update sequence number of the last object update received. + /// + public long usnLastObjChangeSynced; + + /// + /// Contains the usnLastObjChangeSynced value at the end of the last complete, successful replication cycle, or 0 if none. + /// Attributes at the source last updated at a update sequence number less than or equal to this value have already been received + /// and applied by the destination. + /// + public long usnAttributeFilter; + + /// + /// Contains a FILETIME structure that contains the date and time the last successful replication cycle was completed from this + /// source. All members of this structure are zero if the replication cycle has never been completed. + /// + public FILETIME ftimeLastSyncSuccess; + + /// + /// Contains a FILETIME structure that contains the date and time of the last replication attempt from this source. All members + /// of this structure are zero if the replication has never been attempted. + /// + public FILETIME ftimeLastSyncAttempt; + + /// + /// Contains a Windows error code associated with the last replication attempt from this source. Contains ERROR_SUCCESS if + /// the last attempt was successful. + /// + public uint dwLastSyncResult; + + /// + /// Contains the number of failed replication attempts that have been made from this source since the last successful replication + /// attempt or since the source was added as a neighbor, if no previous attempt succeeded. + /// + public uint cNumConsecutiveSyncFailures; + } + + /// + /// The DS_REPL_OBJ_META_DATA structure contains an array of DS_REPL_ATTR_META_DATA structures. These structures contain + /// replication state data for past and present attributes for a given object. The replication state data is returned from the + /// DsReplicaGetInfo and DsReplicaGetInfo2 functions. The metadata records data about the last modification of a given object attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_obj_meta_data typedef struct + // _DS_REPL_OBJ_META_DATA { DWORD cNumEntries; DWORD dwReserved; #if ... DS_REPL_ATTR_META_DATA rgMetaData[]; #else + // DS_REPL_ATTR_META_DATA rgMetaData[1]; #endif } DS_REPL_OBJ_META_DATA; + [PInvokeData("ntdsapi.h", MSDNShortId = "7851ffbc-5d05-4ea7-b3b4-1b8b77299be5")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_OBJ_META_DATA + { + /// + /// Contains the number of elements in the rgMetaData array. + /// + public uint cNumEntries; + + /// Not used. + public uint dwReserved; + + /// + /// Contains an array of DS_REPL_ATTR_META_DATA structures. The cNumEntries member contains the number of elements in this array. + /// + public IntPtr _rgMetaData; + + /// + /// Contains an array of DS_REPL_ATTR_META_DATA structures that contain the requested replication data. + /// + /// The rg meta data. + public DS_REPL_ATTR_META_DATA[] rgMetaData => _rgMetaData.ToArray((int)cNumEntries); + } + + /// + /// The DS_REPL_OBJ_META_DATA_2 structure contains an array of DS_REPL_ATTR_META_DATA_2 structures, which in turn contain + /// replication state data for the attributes (past and present) for a given object, as returned by the DsReplicaGetInfo2 function. + /// This structure is an enhanced version of the DS_REPL_OBJ_META_DATA structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_obj_meta_data_2 typedef struct + // _DS_REPL_OBJ_META_DATA_2 { DWORD cNumEntries; DWORD dwReserved; #if ... DS_REPL_ATTR_META_DATA_2 rgMetaData[]; #else + // DS_REPL_ATTR_META_DATA_2 rgMetaData[1]; #endif } DS_REPL_OBJ_META_DATA_2; + [PInvokeData("ntdsapi.h", MSDNShortId = "2aed753f-432c-4de8-a6be-aa79833f002f")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct DS_REPL_OBJ_META_DATA_2 + { + /// + /// Contains the number of elements in the rgMetaData array. + /// + public uint cNumEntries; + + /// Not used. + public uint dwReserved; + + /// + /// Contains an array of DS_REPL_ATTR_META_DATA_2 structures. The cNumEntries member contains the number of elements in this array. + /// + public IntPtr _rgMetaData; + + /// + /// Contains an array of DS_REPL_ATTR_META_DATA_2 structures that contain the requested replication data. + /// + /// The rg meta data. + public DS_REPL_ATTR_META_DATA_2[] rgMetaData => _rgMetaData.ToArray((int)cNumEntries); + } + + /// + /// The DS_REPL_OP structure describes a replication task currently executing or pending execution, as returned by the + /// DsReplicaGetInfo or DsReplicaGetInfo2 function. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_opw typedef struct _DS_REPL_OPW { FILETIME + // ftimeEnqueued; ULONG ulSerialNumber; ULONG ulPriority; DS_REPL_OP_TYPE OpType; ULONG ulOptions; LPWSTR pszNamingContext; LPWSTR + // pszDsaDN; LPWSTR pszDsaAddress; UUID uuidNamingContextObjGuid; UUID uuidDsaObjGuid; } DS_REPL_OPW; + [PInvokeData("ntdsapi.h", MSDNShortId = "9ea783b3-1529-4424-a582-f46f2a239a60")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_OPW + { + /// + /// Contains a FILETIME structure that contains the date and time that this operation was added to the queue. + /// + public FILETIME ftimeEnqueued; + + /// + /// Contains the operation identifier. This value is unique in the startup routine of every computer. When the computer is + /// restarted, the identifiers are no longer unique. + /// + public uint ulSerialNumber; + + /// + /// Contains the priority value of this operation. Tasks with a higher priority value are executed first. The priority is + /// calculated by the server based on the type of operation and its parameters. + /// + public uint ulPriority; + + /// + /// Contains one of the DS_REPL_OP_TYPE values that indicate the type of operation that this structure represents. + /// + public DS_REPL_OP_TYPE OpType; + + /// + /// + /// Zero or more bits, the interpretation of which depends on the OpType. For DS_REPL_OP_TYPE_SYNC, the bits should + /// be interpreted as DS_REPSYNC_. ADD, DELETE, MODIFY, and UPDATE_REFS use DS_REPADD_, + /// DS_REPDEL_, DS_REPMOD_, and DS_REPUPD_*. For more information and descriptions of these bits, see + /// DsReplicaSync, DsReplicaAdd, DsReplicaDel, DsReplicaModify, and DsReplicaUpdateRefs. + /// + /// + /// Contains a set of flags that provides additional data about the operation. The contents of this member is determined by the + /// contents of the OpType member. + /// + /// DS_REPL_OP_TYPE_SYNC + /// + /// Contains zero or a combination of one or more of the DS_REPSYNC_* values as defined for the Options parameter in DsReplicaSync. + /// + /// DS_REPL_OP_TYPE_ADD + /// + /// Contains zero or a combination of one or more of the DS_REPADD_* values as defined for the Options parameter in DsReplicaAdd. + /// + /// DS_REPL_OP_TYPE_DELETE + /// + /// Contains zero or a combination of one or more of the DS_REPDEL_* values as defined for the Options parameter in DsReplicaDel. + /// + /// DS_REPL_OP_TYPE_MODIFY + /// + /// Contains zero or a combination of one or more of the DS_REPMOD_* values as defined for the Options parameter in DsReplicaModify. + /// + /// DS_REPL_OP_TYPE_UPDATE_REFS + /// + /// Contains zero or a combination of one or more of the DS_REPSUPD_* values as defined for the Options parameter in DsReplicaUpdateRefs. + /// + /// + public uint ulOptions; + + /// + /// Pointer to a null-terminated string that contains the distinguished name of the naming context associated with this + /// operation. For example, the naming context to be synchronized for DS_REPL_OP_TYPE_SYNC. + /// + public string pszNamingContext; + + /// + /// Pointer to a null-terminated string that contains the distinguished name of the directory system agent object associated with + /// the remote server corresponding to this operation. For example, the server from which to request changes for + /// DS_REPL_OP_TYPE_SYNC. This can be NULL. + /// + public string pszDsaDN; + + /// + /// Pointer to a null-terminated string that contains the transport-specific network address of the remote server associated with + /// this operation. For example, the DNS or SMTP address of the server from which to request changes for + /// DS_REPL_OP_TYPE_SYNC. This can be NULL. + /// + public string pszDsaAddress; + + /// + /// Contains the objectGuid of the naming context identified by pszNamingContext. + /// + public Guid uuidNamingContextObjGuid; + + /// + /// Contains the objectGuid of the directory system agent object identified by pszDsaDN. + /// + public Guid uuidDsaObjGuid; + } + + /// + /// The DS_REPL_OPW_BLOB structure describes a replication task currently executing or pending execution. This structure is + /// similar to the DS_REPL_OP structure, but is obtained from the Lightweight Directory Access Protocol API functions when obtaining + /// binary data for the msDS-ReplPendingOps attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_opw_blob typedef struct _DS_REPL_OPW_BLOB { + // FILETIME ftimeEnqueued; ULONG ulSerialNumber; ULONG ulPriority; DS_REPL_OP_TYPE OpType; ULONG ulOptions; DWORD oszNamingContext; + // DWORD oszDsaDN; DWORD oszDsaAddress; UUID uuidNamingContextObjGuid; UUID uuidDsaObjGuid; } DS_REPL_OPW_BLOB; + [PInvokeData("ntdsapi.h", MSDNShortId = "14676159-cc31-4254-b174-dcd84d9ceec1")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_OPW_BLOB + { + /// + /// Contains a FILETIME structure that contains the date and time that this operation was added to the queue. + /// + public FILETIME ftimeEnqueued; + + /// + /// Contains the identifier of the operation. This value is unique in the startup routine of every computer. When the computer is + /// restarted, the identifiers are no longer unique. + /// + public uint ulSerialNumber; + + /// + /// Contains the priority value of this operation. Tasks with a higher priority value are executed first. The priority is + /// calculated by the server based on the type of operation and its parameters. + /// + public uint ulPriority; + + /// + /// Contains one of the DS_REPL_OP_TYPE values that indicate the type of operation that this structure represents. + /// + public DS_REPL_OP_TYPE OpType; + + /// + /// + /// Zero or more bits, the interpretation of which depends on the OpType. For DS_REPL_OP_TYPE_SYNC, the bits should + /// be interpreted as DS_REPSYNC_. ADD, DELETE, MODIFY, and UPDATE_REFS use DS_REPADD_, + /// DS_REPDEL_, DS_REPMOD_, and DS_REPUPD_*. For more information, and descriptions of these bits, see + /// DsReplicaSync, DsReplicaAdd, DsReplicaDel, DsReplicaModify, and DsReplicaUpdateRefs. + /// + /// + /// Contains a set of flags that provide additional data about the operation. The contents of this member is determined by the + /// contents of the OpType member. + /// + /// This list describes the contents of the ulOptions parameter for each OpType value. + /// DS_REPL_OP_TYPE_SYNC + /// + /// Contains zero or a combination of one or more of the DS_REPSYNC_* values as defined for the Options parameter in DsReplicaSync. + /// + /// DS_REPL_OP_TYPE_ADD + /// + /// Contains zero or a combination of one or more of the DS_REPADD_* values as defined for the Options parameter in DsReplicaAdd. + /// + /// DS_REPL_OP_TYPE_DELETE + /// + /// Contains zero or a combination of one or more of the DS_REPDEL_* values as defined for the Options parameter in DsReplicaDel. + /// + /// DS_REPL_OP_TYPE_MODIFY + /// + /// Contains zero or a combination of one or more of the DS_REPMOD_* values as defined for the Options parameter in DsReplicaModify. + /// + /// DS_REPL_OP_TYPE_UPDATE_REFS + /// + /// Contains zero or a combination of one or more of the DS_REPSUPD_* values as defined for the Options parameter in DsReplicaUpdateRefs. + /// + /// + public uint ulOptions; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated string that contains the distinguished + /// name of the naming context associated with this operation. For example, the naming context to be synchronized for DS_REPL_OP_TYPE_SYNC. + /// + public uint oszNamingContext; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated string that contains the distinguished + /// name of the directory system agent object associated with the remote server corresponding to this operation. For example, the + /// server from which to ask for changes for DS_REPL_OP_TYPE_SYNC. This can be NULL. + /// + public uint oszDsaDN; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated string that contains the + /// transport-specific network address of the remote server associated with this operation. For example, the DNS or SMTP address + /// of the server from which to ask for changes for DS_REPL_OP_TYPE_SYNC. This can be NULL. + /// + public uint oszDsaAddress; + + /// + /// Contains the objectGuid of the naming context identified by pszNamingContext. + /// + public Guid uuidNamingContextObjGuid; + + /// + /// Contains the objectGuid of the directory system agent object identified by pszDsaDN. + /// + public Guid uuidDsaObjGuid; + } + + /// + /// The DS_REPL_PENDING_OPS structure contains an array of DS_REPL_OP structures, which in turn describe the replication tasks + /// currently executing and queued to execute, as returned by the DsReplicaGetInfo and DsReplicaGetInfo2 functions. The entries in + /// the queue are processed in priority order, and the first entry is the one currently being executed. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_pending_opsw typedef struct _DS_REPL_PENDING_OPSW + // { FILETIME ftimeCurrentOpStarted; DWORD cNumPendingOps; #if ... DS_REPL_OPW rgPendingOp[]; #else DS_REPL_OPW rgPendingOp[1]; + // #endif } DS_REPL_PENDING_OPSW; + [PInvokeData("ntdsapi.h", MSDNShortId = "2e4b96cb-fbd6-496b-aff3-cb7d82f1fa39")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_PENDING_OPSW + { + /// + /// Contains a FILETIME structure that contains the date and time at which the first operation in the queue began executing. + /// + public FILETIME ftimeCurrentOpStarted; + + /// + /// Contains the number of elements in the rgPendingOps array. + /// + public uint cNumPendingOps; + + /// The sequence of replication operations to be performed. + public IntPtr _rgPendingOp; + + /// The sequence of replication operations to be performed. + /// The rg pending op. + public DS_REPL_OPW[] rgPendingOp => _rgPendingOp.ToArray((int)cNumPendingOps); + } + + /// + /// The DS_REPL_QUEUE_STATISTICSW structure is used to contain replication queue statistics. + /// + /// Reserved. Obtain this data using the DS_REPL_QUEUE_STATISTICSW_BLOB structure with the Lightweight Directory Access Protocol API + /// functions to obtain binary data for the msDS-ReplQueueStatistics attribute. + /// + /// + /// + /// DS_REPL_QUEUE_STATISTICSW_BLOB is an alias for this structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_queue_statisticsw typedef struct + // _DS_REPL_QUEUE_STATISTICSW { FILETIME ftimeCurrentOpStarted; DWORD cNumPendingOps; FILETIME ftimeOldestSync; FILETIME + // ftimeOldestAdd; FILETIME ftimeOldestMod; FILETIME ftimeOldestDel; FILETIME ftimeOldestUpdRefs; } DS_REPL_QUEUE_STATISTICSW, DS_REPL_QUEUE_STATISTICSW_BLOB; + [PInvokeData("ntdsapi.h", MSDNShortId = "bfddd7ed-0ff4-46ca-84c2-39020acb37d0")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_QUEUE_STATISTICSW + { + /// + /// Contains a FILETIME structure that contains the date and time that the currently running operation started. + /// + public FILETIME ftimeCurrentOpStarted; + + /// Contains the number of currently pending operations. + public uint cNumPendingOps; + + /// + /// Contains a FILETIME structure that contains the date and time of the oldest synchronization operation. + /// + public FILETIME ftimeOldestSync; + + /// + /// Contains a FILETIME structure that contains the date and time of the oldest add operation. + /// + public FILETIME ftimeOldestAdd; + + /// + /// Contains a FILETIME structure that contains the date and time of the oldest modification operation. + /// + public FILETIME ftimeOldestMod; + + /// + /// Contains a FILETIME structure that contains the date and time of the oldest delete operation. + /// + public FILETIME ftimeOldestDel; + + /// + /// Contains a FILETIME structure that contains the date and time of the oldest reference update operation. + /// + public FILETIME ftimeOldestUpdRefs; + } + + /// + /// The DS_REPL_VALUE_META_DATA structure is used with the DS_REPL_ATTR_VALUE_META_DATA structure to contain attribute value + /// replication metadata. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_value_meta_data typedef struct + // _DS_REPL_VALUE_META_DATA { LPWSTR pszAttributeName; LPWSTR pszObjectDn; DWORD cbData; #if ... BYTE *pbData; #else BYTE *pbData; + // #endif FILETIME ftimeDeleted; FILETIME ftimeCreated; DWORD dwVersion; FILETIME ftimeLastOriginatingChange; UUID + // uuidLastOriginatingDsaInvocationID; USN usnOriginatingChange; USN usnLocalChange; } DS_REPL_VALUE_META_DATA; + [PInvokeData("ntdsapi.h", MSDNShortId = "294a466e-8a83-4b33-a8a8-ac7b51d081d4")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_VALUE_META_DATA + { + /// + /// Pointer to a null-terminated Unicode string that contains the LDAP display name of the attribute corresponding to this metadata. + /// + public string pszAttributeName; + + /// + /// Pointer to a null-terminated Unicode string that contains the distinguished name of the object that this attribute belongs to. + /// + public string pszObjectDn; + + /// Contains the number of bytes in the pbData array. + public uint cbData; + + /// + /// The binary_value portion of the attribute value if the attribute is of syntax Object(DN-Binary), or the string_value portion + /// of the attribute value if the attribute is of syntax Object(DN-String); null otherwise. + /// + public IntPtr pbData; + + /// + /// Contains a FILETIME structure that contains the time this attribute was deleted. + /// + public FILETIME ftimeDeleted; + + /// + /// Contains a FILETIME structure that contains the time this attribute was created. + /// + public FILETIME ftimeCreated; + + /// + /// Contains the version of this attribute. Each originating modification of the attribute increases this value by one. + /// Replication of a modification does not affect the version. + /// + public uint dwVersion; + + /// + /// Contains a FILETIME structure that contains the time at which the last originating change was made to this attribute. + /// Replication of the change does not affect this value. + /// + public FILETIME ftimeLastOriginatingChange; + + /// + /// Contains the invocation identifier of the server on which the last change was made to this attribute. Replication of the + /// change does not affect this value. + /// + public Guid uuidLastOriginatingDsaInvocationID; + + /// + /// Contains the update sequence number (USN) on the originating server at which the last change to this attribute was made. + /// Replication of the change does not affect this value. + /// + public long usnOriginatingChange; + + /// + /// Contains the USN on the destination server, that is the server from which the DsReplicaGetInfo2 function retrieved the + /// metadata, at which the last change to this attribute was applied. This value is typically different on all servers. + /// + public long usnLocalChange; + } + + /// + /// The DS_REPL_VALUE_META_DATA_2 structure is used with the DS_REPL_ATTR_VALUE_META_DATA_2 structure to contain attribute + /// value replication metadata. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_value_meta_data_2 typedef struct + // _DS_REPL_VALUE_META_DATA_2 { LPWSTR pszAttributeName; LPWSTR pszObjectDn; DWORD cbData; #if ... BYTE *pbData; #else BYTE *pbData; + // #endif FILETIME ftimeDeleted; FILETIME ftimeCreated; DWORD dwVersion; FILETIME ftimeLastOriginatingChange; UUID + // uuidLastOriginatingDsaInvocationID; USN usnOriginatingChange; USN usnLocalChange; LPWSTR pszLastOriginatingDsaDN; } DS_REPL_VALUE_META_DATA_2; + [PInvokeData("ntdsapi.h", MSDNShortId = "747e32b8-2cc0-4fcd-88dc-027188598361")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_VALUE_META_DATA_2 + { + /// + /// Pointer to a null-terminated Unicode string that contains the LDAP display name of the attribute that corresponds to this metadata. + /// + public string pszAttributeName; + + /// + /// Pointer to a null-terminated Unicode string that contains the distinguished name of the object that this attribute belongs to. + /// + public string pszObjectDn; + + /// Contains the number of bytes in the pbData array. + public uint cbData; + + /// + /// The binary_value portion of the attribute value if the attribute is of syntax Object(DN-Binary), or the string_value portion + /// of the attribute value if the attribute is of syntax Object(DN-String); null otherwise. + /// + public IntPtr pbData; + + /// + /// Contains a FILETIME structure that contains the time this attribute was deleted. + /// + public FILETIME ftimeDeleted; + + /// + /// Contains a FILETIME structure that contains the time this attribute was created. + /// + public FILETIME ftimeCreated; + + /// + /// Contains the version of this attribute. Each originating modification of the attribute increases this value by one. + /// Replication of a modification does not affect the version. + /// + public uint dwVersion; + + /// + /// Contains a FILETIME structure that contains the time at which the last originating change was made to this attribute. + /// Replication of the change does not affect this value. + /// + public FILETIME ftimeLastOriginatingChange; + + /// + /// Contains the invocation identifier of the server on which the last change was made to this attribute. Replication of the + /// change does not affect this value. + /// + public Guid uuidLastOriginatingDsaInvocationID; + + /// + /// Contains the update sequence number (USN) on the originating server at which the last change to this attribute was made. + /// Replication of the change does not affect this value. + /// + public long usnOriginatingChange; + + /// + /// Contains the USN on the destination server, that is, the server from which the DsReplicaGetInfo2 function retrieved the + /// metadata, at which the last change to this attribute was applied. This value is typically different on all servers. + /// + public long usnLocalChange; + + /// + /// Pointer to a null-terminated Unicode string that contains the distinguished name of the directory system agent server that + /// originated the last replication. + /// + public string pszLastOriginatingDsaDN; + } + + /// + /// The DS_REPL_VALUE_META_DATA_BLOB structure is used to contain attribute value replication metadata. This structure is + /// similar to the DS_REPL_VALUE_META_DATA_2 structure, but is obtained from the Lightweight Directory Access Protocol API functions + /// when obtaining binary data for the msDS-ReplValueMetaData attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_value_meta_data_blob typedef struct + // _DS_REPL_VALUE_META_DATA_BLOB { DWORD oszAttributeName; DWORD oszObjectDn; DWORD cbData; DWORD obData; FILETIME ftimeDeleted; + // FILETIME ftimeCreated; DWORD dwVersion; FILETIME ftimeLastOriginatingChange; UUID uuidLastOriginatingDsaInvocationID; USN + // usnOriginatingChange; USN usnLocalChange; DWORD oszLastOriginatingDsaDN; } DS_REPL_VALUE_META_DATA_BLOB; + [PInvokeData("ntdsapi.h", MSDNShortId = "7d8bb666-c5d8-43de-ab72-5b02b6e0593d")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_VALUE_META_DATA_BLOB + { + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the LDAP + /// display name of the attribute corresponding to this metadata. A value of zero indicates an empty or NULL string. + /// + public uint oszAttributeName; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// distinguished name of the object that this attribute belongs to. A value of zero indicates an empty or NULL string. + /// + public uint oszObjectDn; + + /// Contains the number of bytes in the pbData array. + public uint cbData; + + /// + /// Contains a 32-bit offset, in bytes, from the address of this structure to a buffer that contains the attribute replication + /// metadata. The cbData member contains the length, in bytes, of this buffer. + /// + public uint obData; + + /// + /// Contains a FILETIME structure that contains the time that this attribute was deleted. + /// + public FILETIME ftimeDeleted; + + /// + /// Contains a FILETIME structure that contains the time that this attribute was created. + /// + public FILETIME ftimeCreated; + + /// + /// Contains the version of this attribute. Each originating modification of the attribute increases this value by one. + /// Replication of a modification does not affect the version. + /// + public uint dwVersion; + + /// + /// Contains a FILETIME structure that contains the time at which the last originating change was made to this attribute. + /// Replication of the change does not affect this value. + /// + public FILETIME ftimeLastOriginatingChange; + + /// + /// Contains the invocation identifier of the server on which the last change was made to this attribute. Replication of the + /// change does not affect this value. + /// + public Guid uuidLastOriginatingDsaInvocationID; + + /// + /// Contains the update sequence number (USN) on the originating server at which the last change to this attribute was made. + /// Replication of the change does not affect this value. + /// + public long usnOriginatingChange; + + /// + /// Contains the USN on the destination server, that is, the server from which the DsReplicaGetInfo2 function retrieved the + /// metadata, at which the last change to this attribute was applied. This value is typically different on all servers. + /// + public long usnLocalChange; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// distinguished name of the directory system agent server that originated the last replication. A value of zero indicates an + /// empty or NULL string. + /// + public uint oszLastOriginatingDsaDN; + } + + /// + /// Contains attribute value replication metadata. This structure is similar to the DS_REPL_VALUE_META_DATA_EXT structure, but is + /// obtained from the Lightweight Directory Access Protocol API functions when obtaining binary data for the + /// msDS-ReplValueMetaData attribute. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_value_meta_data_blob_ext typedef struct + // _DS_REPL_VALUE_META_DATA_BLOB_EXT { DWORD oszAttributeName; DWORD oszObjectDn; DWORD cbData; DWORD obData; FILETIME ftimeDeleted; + // FILETIME ftimeCreated; DWORD dwVersion; FILETIME ftimeLastOriginatingChange; UUID uuidLastOriginatingDsaInvocationID; USN + // usnOriginatingChange; USN usnLocalChange; DWORD oszLastOriginatingDsaDN; DWORD dwUserIdentifier; DWORD dwPriorLinkState; DWORD + // dwCurrentLinkState; } DS_REPL_VALUE_META_DATA_BLOB_EXT; + [PInvokeData("ntdsapi.h", MSDNShortId = "095180F4-9E3F-47EE-B39E-107D7D219DCB")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_VALUE_META_DATA_BLOB_EXT + { + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the LDAP + /// display name of the attribute corresponding to this metadata. A value of zero indicates an empty or NULL string. + /// + public uint oszAttributeName; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// distinguished name of the object that this attribute belongs to. A value of zero indicates an empty or NULL string. + /// + public uint oszObjectDn; + + /// Contains the number of bytes in the pbData array. + public uint cbData; + + /// + /// Pointer to a buffer that contains the attribute replication metadata. The cbData member contains the length, in bytes, + /// of this buffer. + /// + public uint obData; + + /// + /// Contains a FILETIME structure that contains the time that this attribute was deleted. + /// + public FILETIME ftimeDeleted; + + /// + /// Contains a FILETIME structure that contains the time that this attribute was created. + /// + public FILETIME ftimeCreated; + + /// + /// Contains the version of this attribute. Each originating modification of the attribute increases this value by one. + /// Replication of a modification does not affect the version. + /// + public uint dwVersion; + + /// + /// Contains a FILETIME structure that contains the time at which the last originating change was made to this attribute. + /// Replication of the change does not affect this value. + /// + public FILETIME ftimeLastOriginatingChange; + + /// + /// Contains the invocation identifier of the server on which the last change was made to this attribute. Replication of the + /// change does not affect this value. + /// + public Guid uuidLastOriginatingDsaInvocationID; + + /// + /// Contains the update sequence number (USN) on the originating server at which the last change to this attribute was made. + /// Replication of the change does not affect this value. + /// + public long usnOriginatingChange; + + /// + /// Contains the USN on the destination server, that is, the server from which the DsReplicaGetInfo2 function retrieved the + /// metadata, at which the last change to this attribute was applied. This value is typically different on all servers. + /// + public long usnLocalChange; + + /// + /// Contains the offset, in bytes, from the address of this structure to a null-terminated Unicode string that contains the + /// distinguished name of the directory system agent server that originated the last replication. A value of zero indicates an + /// empty or NULL string. + /// + public uint oszLastOriginatingDsaDN; + + /// TBD + public uint dwUserIdentifier; + + /// TBD + public uint dwPriorLinkState; + + /// TBD + public uint dwCurrentLinkState; + } + + /// + /// Contains attribute replication meta data for the DS_REPL_ATTR_VALUE_META_DATA_EXT structure. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-_ds_repl_value_meta_data_ext typedef struct + // _DS_REPL_VALUE_META_DATA_EXT { LPWSTR pszAttributeName; LPWSTR pszObjectDn; DWORD cbData; #if ... BYTE *pbData; #else BYTE + // *pbData; #endif FILETIME ftimeDeleted; FILETIME ftimeCreated; DWORD dwVersion; FILETIME ftimeLastOriginatingChange; UUID + // uuidLastOriginatingDsaInvocationID; USN usnOriginatingChange; USN usnLocalChange; LPWSTR pszLastOriginatingDsaDN; DWORD + // dwUserIdentifier; DWORD dwPriorLinkState; DWORD dwCurrentLinkState; } DS_REPL_VALUE_META_DATA_EXT; + [PInvokeData("ntdsapi.h", MSDNShortId = "2BE0F9C4-D688-4DE6-8DB2-15666D8BD070")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DS_REPL_VALUE_META_DATA_EXT + { + /// + /// Pointer to a null-terminated Unicode string that contains the LDAP display name of the attribute corresponding to this metadata. + /// + public string pszAttributeName; + + /// + /// Pointer to a null-terminated Unicode string that contains the distinguished name of the object that this attribute belongs to. + /// + public string pszObjectDn; + + /// Contains the number of bytes in the pbData array. + public uint cbData; + + /// + /// Pointer to a buffer that contains the attribute replication metadata. The cbData member contains the length, in bytes, + /// of this buffer. + /// + public IntPtr pbData; + + /// + /// Contains a FILETIME structure that contains the time this attribute was deleted. + /// + public FILETIME ftimeDeleted; + + /// + /// Contains a FILETIME structure that contains the time this attribute was created. + /// + public FILETIME ftimeCreated; + + /// + /// Contains the version of this attribute. Each originating modification of the attribute increases this value by one. + /// Replication of a modification does not affect the version. + /// + public uint dwVersion; + + /// + /// Contains a FILETIME structure that contains the time at which the last originating change was made to this attribute. + /// Replication of the change does not affect this value. + /// + public FILETIME ftimeLastOriginatingChange; + + /// + /// Contains the invocation identifier of the server on which the last change was made to this attribute. Replication of the + /// change does not affect this value. + /// + public Guid uuidLastOriginatingDsaInvocationID; + + /// + /// Contains the update sequence number (USN) on the originating server at which the last change to this attribute was made. + /// Replication of the change does not affect this value. + /// + public long usnOriginatingChange; + + /// + /// Contains the USN on the destination server, that is the server from which the DsReplicaGetInfo2 function retrieved the + /// metadata, at which the last change to this attribute was applied. This value is typically different on all servers. + /// + public long usnLocalChange; + + /// + /// Pointer to a null-terminated Unicode string that contains the distinguished name of the directory system agent server that + /// originated the last replication. + /// + public string pszLastOriginatingDsaDN; + + /// TBD + public uint dwUserIdentifier; + + /// TBD + public uint dwPriorLinkState; + + /// TBD + public uint dwCurrentLinkState; + } + + /// + /// The DS_REPSYNCALL_ERRINFO structure is used with the DS_REPSYNCALL_UPDATE structure to contain errors generated by the + /// DsReplicaSyncAll function during replication. + /// + // https://webcache.googleusercontent.com/search?q=cache:0plHTsXYeJ0J:https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-ds_repsyncall_errinfoa+&cd=1&hl=en&ct=clnk&gl=us + // typedef struct DS_REPSYNCALL_ERRINFOA { LPSTR pszSvrId; DS_REPSYNCALL_ERROR error; DWORD dwWin32Err; LPSTR pszSrcId; } *PDS_REPSYNCALL_ERRINFOA; + [PInvokeData("ntdsapi.h", MSDNShortId = "70af4e3e-1f0e-49c5-b8c6-5e89114ed4ea")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct DS_REPSYNCALL_ERRINFO + { + /// + /// Pointer to a null-terminated string that contains the DNS GUID of the server where the error occurred. Alternatively, this + /// member can contain the distinguished name of the server if DS_REPSYNCALL_ID_SERVERS_BY_DN is specified in the ulFlags + /// parameter of the DsReplicaSyncAll function. + /// + public string pszSvrId; + + /// + /// Contains one of the DS_REPSYNCALL_ERROR values that indicates where in the replication process the error occurred. + /// + public DS_REPSYNCALL_ERROR error; + + /// + /// Indicates the actual Win32 error code generated during replication between the source server referred to by pszSrcId + /// and the destination server referred to by pszSvrId. + /// + public Win32Error dwWin32Err; + + /// + /// Pointer to a null-terminated string that specifies the DNS GUID of the source server. Alternatively, this member can contain + /// the distinguished name of the source server if DS_REPSYNCALL_ID_SERVERS_BY_DN is specified in the ulFlags parameter of + /// the DsReplicaSyncAll function. + /// + public string pszSrcId; + } + + /// + /// The DS_REPSYNCALL_UPDATE structure contains status data about the replication performed by the DsReplicaSyncAll function. + /// The DsReplicaSyncAll function passes this structure to a callback function in its pFnCallBack parameter. For more + /// information about the callback function, see SyncUpdateProc. + /// + // https://webcache.googleusercontent.com/search?q=cache:-LzmvZ2eMGsJ:https://docs.microsoft.com/en-us/windows/desktop/api/ntdsapi/ns-ntdsapi-ds_repsyncall_updatea+&cd=1&hl=en&ct=clnk&gl=us + // typedef struct DS_REPSYNCALL_UPDATEA { DS_REPSYNCALL_EVENT event; DS_REPSYNCALL_ERRINFOA *pErrInfo; DS_REPSYNCALL_SYNCA *pSync; } *PDS_REPSYNCALL_UPDATEA; + [PInvokeData("ntdsapi.h", MSDNShortId = "3b0005cb-0fb6-492c-89e5-8a18a88f881b")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct DS_REPSYNCALL_UPDATE + { + /// + /// Contains a DS_REPSYNCALL_EVENT value that describes the event which the DS_REPSYNCALL_UPDATE structure represents. + /// + public DS_REPSYNCALL_EVENT cEvent; + + /// + /// Pointer to a DS_REPSYNCALL_ERRINFO structure that contains error data about the replication performed by the DsReplicaSyncAll function. + /// + public IntPtr pErrInfo; + + /// + /// Pointer to a DS_REPSYNCALL_SYNC structure that identifies the source and destination servers that have either initiated or + /// finished synchronization. + /// + public IntPtr pSync; + } + + /// + /// The DS_SCHEMA_GUID_MAP structure contains the results of a call to DsMapSchemaGuids. If DsMapSchemaGuids succeeds in mapping a + /// GUID, DS_SCHEMA_GUID_MAP contains both the GUID and a display name for the object to which the GUID refers. + /// + [PInvokeData("ntdsapi.h")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct DS_SCHEMA_GUID_MAP + { + /// GUID structure that specifies the object GUID. + public Guid guid; + + /// Indicates the type of GUID mapped by DsMapSchemaGuids. + public DsSchemaGuidType guidType; + + /// + /// Pointer to a null-terminated string value that specifies the display name associated with the GUID. This value may be NULL if + /// DsMapSchemaGuids was unable to map the GUID to a display name. + /// + public string pName; + } + + /// + /// The DS_SITE_COST_INFO structure is used with the DsQuerySitesByCost function to contain communication cost data. + /// + // https://msdn.microsoft.com/en-us/windows/ms676286(v=vs.80).aspx + [PInvokeData("ntdsapi.h")] + [StructLayout(LayoutKind.Sequential)] + public struct DS_SITE_COST_INFO + { + /// + /// Contains a success or error code that indicates if the cost data for the site could be obtained. This member can contain one + /// of the following values. + /// + /// + /// ERROR_SUCCESS + /// The communication cost of the site was obtained and is contained in the cost member of this structure. + /// + /// + /// ERROR_DS_OBJ_NOT_FOUND + /// The communication cost of the site cannot be obtained. The cost member of this structure should be ignored. + /// + /// + /// + public Win32Error errorCode; + + /// + /// If the errorCode member contains ERROR_SUCCESS, this member contains the communication cost value of the site. + /// If the errorCode member contains ERROR_DS_OBJ_NOT_FOUND, this contents of this member is undefined. + /// + public uint cost; + } + + /// + /// The SCHEDULE_HEADER structure is used to contain the replication schedule data for a replication source. The SCHEDULE + /// structure contains an array of SCHEDULE_HEADER structures. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/schedule/ns-schedule-_schedule_header typedef struct _SCHEDULE_HEADER { ULONG + // Type; ULONG Offset; } SCHEDULE_HEADER, *PSCHEDULE_HEADER; + [PInvokeData("schedule.h", MSDNShortId = "5453927e-306e-4442-a855-916005dc8e3b")] + [StructLayout(LayoutKind.Sequential)] + public struct SCHEDULE_HEADER + { + /// + /// Contains one of the following values that defines the type of schedule data that is contained in this structure. + /// SCHEDULE_INTERVAL + /// + /// The schedule contains a set of intervals. The Offset member contains the offset to an array of bytes with + /// SCHEDULE_DATA_ENTRIES elements. Each byte in the array represents an hour of the week. The first hour is 00:00 on + /// Sunday morning GMT. + /// + /// + /// Each bit of the lower four bits of each byte represents a 15 minute block within the hour that the source is available for + /// replication. The following list lists the binary values and describes each bit of the lower four bits of the hour value. + /// + /// + /// + /// Binary value + /// Description + /// + /// + /// 1000 + /// The source is available for replication from 0 to 14 minutes after the hour. + /// + /// + /// 0100 + /// The source is available for replication from 15 to 29 minutes after the hour. + /// + /// + /// 0010 + /// The source is available for replication from 30 to 44 minutes after the hour. + /// + /// + /// 0001 + /// The source is available for replication from 45 to 59 minutes after the hour. + /// + /// + /// + /// These bits can be combined to create multiple 15 minute blocks that the source is available. For example, a binary value of + /// 0111 indicates that the source is available from 0 to 44 minutes after the hour. + /// + /// The upper fours bits of each byte are not used. + /// SCHEDULE_BANDWIDTH + /// Not supported. + /// SCHEDULE_PRIORITY + /// Not supported. + /// + public ScheduleType Type; + + /// + /// Contains the offset, in bytes, from the beginning of the SCHEDULE structure to the data for this schedule. The size and form + /// of this data depends on the schedule type defined by the Type member. + /// + public uint Offset; + } + /// Provides a handle to an array of one or more service principal names (SPNs). [StructLayout(LayoutKind.Sequential)] public struct SpnArrayHandle : IHandle @@ -1356,10 +5156,37 @@ namespace Vanara.PInvoke /// Initializes a new instance of the class. private SafeAuthIdentityHandle() : base() { } + /// Gets a value that marshals as NULL so that the local thread's identity is used. + public static readonly SafeAuthIdentityHandle LocalThreadIdentity = new SafeAuthIdentityHandle(); + /// protected override bool InternalReleaseHandle() { DsFreePasswordCredentials(handle); return true; } } + /// Provides a safe handle to an array of DS_REPSYNCALL_ERRINFO structures returned from . + /// + public class SafeDS_REPSYNCALL_ERRINFOArray : GenericSafeHandle, IReadOnlyCollection + { + internal SafeDS_REPSYNCALL_ERRINFOArray() : base(IntPtr.Zero, h => LocalFree(h) == IntPtr.Zero) + { + } + + /// + public int Count => IsInvalid ? 0 : handle.GetNulledPtrArrayLength(); + + /// Gets the array of DS_REPSYNCALL_ERRINFO structures. + public DS_REPSYNCALL_ERRINFO[] Items => IsInvalid ? new DS_REPSYNCALL_ERRINFO[0] : handle.ToArray(Count); + + /// + public IEnumerator GetEnumerator() => Array.AsReadOnly(Items).GetEnumerator(); + + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] + private static extern IntPtr LocalFree(IntPtr hMem); + } + /// A for handles bound to directory services. /// [SuppressUnmanagedCodeSecurity, ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] @@ -1389,37 +5216,233 @@ namespace Vanara.PInvoke /// /// [PInvokeData("NTDSApi.h")] - public class SafeDsNameResult : GenericSafeHandle + public class SafeDsNameResult : GenericSafeHandle, IEnumerable { /// Initializes a new instance of the class. public SafeDsNameResult() : base(h => { DsFreeNameResult(h); return true; }) { } /// An array of DS_NAME_RESULT_ITEM structures. Each element of this array represents a single converted name. public DS_NAME_RESULT_ITEM[] Items => IsInvalid ? new DS_NAME_RESULT_ITEM[0] : handle.ToStructure().Items; + + /// + public IEnumerator GetEnumerator() => ((IEnumerable)Items).GetEnumerator(); + + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } - /* - DsListDomainsInSite - DsListRoles - DsListServersForDomainInSite - DsListServersInSite - DsListSites - DsMapSchemaGuids - DsQuerySitesByCost - DsQuerySitesFree - DsRemoveDsDomain - DsRemoveDsServer - DsReplicaConsistencyCheck - DsReplicaDel - DsReplicaFreeInfo - DsReplicaGetInfo2W - DsReplicaGetInfoW - DsReplicaModify - DsReplicaSync - DsReplicaSyncAll - DsReplicaUpdateRefs - DsReplicaVerifyObjects - DsServerRegisterSpn - */ + /// A for the results from . + /// + [PInvokeData("NTDSApi.h")] + public class SafeDsQuerySites : GenericSafeHandle + { + /// Initializes a new instance of the class. + public SafeDsQuerySites() : base(h => { DsQuerySitesFree(h); return true; }) { } + + /// Gets an array of DS_SITE_COST_INFO structures. + /// + /// Indicates the number of elements in the array. This value is the same value as that passed into . + /// + public DS_SITE_COST_INFO[] GetItems(int cToSites) => IsInvalid ? new DS_SITE_COST_INFO[0] : handle.ToArray(cToSites); + } + + /// A for the results from . + [PInvokeData("NTDSApi.h")] + public class SafeDsReplicaInfo : HANDLE + { + internal SafeDsReplicaInfo() + { + } + + /// Gets the value. + /// The value. + public object Value + { + get + { + var t = CorrespondingTypeAttribute.GetCorrespondingTypes(Type).FirstOrDefault(); + return t == null || IsInvalid ? null : Marshal.PtrToStructure(handle, t); + } + } + + internal DS_REPL_INFO_TYPE Type { get; set; } + + /// Gets the requested structure. + /// Type of the structure + /// The structure. + public T GetValue() where T : struct + { + if (!CorrespondingTypeAttribute.CanGet(Type, typeof(T))) throw new InvalidCastException(); + return handle.ToStructure(); + } + + /// + protected override bool InternalReleaseHandle() + { + DsReplicaFreeInfo(Type, handle); + return true; + } + } + + /// A for the results from . + /// + [PInvokeData("NTDSApi.h")] + public class SafeDsSchemaGuidMap : GenericSafeHandle + { + /// Initializes a new instance of the class. + public SafeDsSchemaGuidMap() : base(h => { DsFreeSchemaGuidMap(h); return true; }) { } + + /// Gets an array of DS_SCHEMA_GUID_MAP structures. + /// + /// Indicates the number of elements in the array. This value is the same value as that passed into . + /// + public DS_SCHEMA_GUID_MAP[] GetItems(int cGuids) => IsInvalid ? new DS_SCHEMA_GUID_MAP[0] : handle.ToArray(cGuids); + } + + /// + /// + /// The SCHEDULE structure is a variable-length structure used with the DsReplicaAdd and DsReplicaModify functions to contain + /// replication schedule data for a replication source. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/schedule/ns-schedule-_schedule typedef struct _SCHEDULE { ULONG Size; ULONG + // Bandwidth; ULONG NumberOfSchedules; SCHEDULE_HEADER Schedules[1]; } SCHEDULE, *PSCHEDULE; + [PInvokeData("schedule.h", MSDNShortId = "d86890db-b34a-415a-820a-6d4790914218")] + [StructLayout(LayoutKind.Sequential)] + public class SCHEDULE : IDisposable + { + private const int intervalByteCount = 24 * 7; + + /// Initializes a new instance of the class. + /// The schedule intervals. See for detail about this array. + /// + /// scheduleIntervals - Array must have at least 1 schedule and have a second dimension of 24 x 7 bytes. + /// + public SCHEDULE(byte[,] scheduleIntervals) + { + if (scheduleIntervals is null || scheduleIntervals.GetLength(0) == 0 || scheduleIntervals.GetLength(1) != intervalByteCount) + throw new ArgumentOutOfRangeException(nameof(scheduleIntervals), "Array must have at least 1 schedule and have a second dimension of 24 x 7 bytes."); + NumberOfSchedules = (uint)scheduleIntervals.GetLength(0); + var hdrSz = NumberOfSchedules * (intervalByteCount + 8); + _Schedules = Marshal.AllocCoTaskMem((int)hdrSz); + var scheds = new SCHEDULE_HEADER[NumberOfSchedules]; + Size = (uint)(12 + IntPtr.Size); + var schMemOffset = Size + NumberOfSchedules * Marshal.SizeOf(typeof(SCHEDULE_HEADER)); + var offset = 0; + for (var i = 0; i < NumberOfSchedules; i++) + { + scheds[i] = new SCHEDULE_HEADER { Type = ScheduleType.SCHEDULE_INTERVAL, Offset = (uint)(offset + schMemOffset) }; + unsafe + { + var schOff = (byte*)_Schedules.Offset(offset).ToPointer(); + fixed (byte* retptr = &scheduleIntervals[i, 0]) + { + for (var x = 0; x < intervalByteCount; x++) + schOff[x] = retptr[x]; + } + } + offset += intervalByteCount; + } + Size += hdrSz; + } + + /// + /// + /// Contains the size, in bytes, of the SCHEDULE structure, including the size of all of the elements and data of the + /// Schedules array. + /// + /// + public readonly uint Size; + + /// + /// Not used. + /// + public readonly uint Bandwidth; + + /// + /// Contains the number of elements in the Schedules array. + /// + public readonly uint NumberOfSchedules; + + /// + /// + /// Contains an array of SCHEDULE_HEADER structures that contain the replication schedule data for the replication source. The + /// NumberOfSchedules member contains the number of elements in this array. Currently, this array can only contain one element. + /// + /// + private IntPtr _Schedules; + + /// + /// + /// Contains an array of SCHEDULE_HEADER structures that contain the replication schedule data for the replication source. The + /// NumberOfSchedules member contains the number of elements in this array. Currently, this array can only contain one element. + /// + /// + public SCHEDULE_HEADER[] Schedules => _Schedules.ToArray((int)NumberOfSchedules); + + /// + /// + /// Gets a two-dimensional array of bytes for each schedule with 7 x 24 elements. Each byte in the array represents an hour of + /// the week. The first hour is 00:00 on Sunday morning GMT. + /// + /// + /// Each bit of the lower four bits of each byte represents a 15 minute block within the hour that the source is available for + /// replication. The following list lists the binary values and describes each bit of the lower four bits of the hour value. + /// + /// + /// + /// Binary value + /// Description + /// + /// + /// 1000 + /// The source is available for replication from 0 to 14 minutes after the hour. + /// + /// + /// 0100 + /// The source is available for replication from 15 to 29 minutes after the hour. + /// + /// + /// 0010 + /// The source is available for replication from 30 to 44 minutes after the hour. + /// + /// + /// 0001 + /// The source is available for replication from 45 to 59 minutes after the hour. + /// + /// + /// + /// These bits can be combined to create multiple 15 minute blocks that the source is available. For example, a binary value of + /// 0111 indicates that the source is available from 0 to 44 minutes after the hour. + /// + /// The upper fours bits of each byte are not used. + /// + public byte[,] ScheduleIntervals + { + get + { + var s = Schedules; + var ret = new byte[s.Length, intervalByteCount]; + for (var i = 0; i < s.Length; i++) + { + if (s[i].Type != ScheduleType.SCHEDULE_INTERVAL) continue; + var offset = (int)s[i].Offset; + unsafe + { + fixed (SCHEDULE_HEADER* sptr = &s[i]) + fixed (byte* retptr = &ret[i, 0]) + { + var sbptr = (byte*)sptr; + for (var x = 0; x < intervalByteCount; x++) + retptr[x] = sbptr[x + offset]; + } + } + } + return ret; + } + } + + void IDisposable.Dispose() => Marshal.FreeCoTaskMem(_Schedules); + } } } \ No newline at end of file diff --git a/PInvoke/NTDSApi/Vanara.PInvoke.NTDSApi.csproj b/PInvoke/NTDSApi/Vanara.PInvoke.NTDSApi.csproj index 683de22b..b9b7507a 100644 --- a/PInvoke/NTDSApi/Vanara.PInvoke.NTDSApi.csproj +++ b/PInvoke/NTDSApi/Vanara.PInvoke.NTDSApi.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from NTDSApi.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard20 Vanara.PInvoke.NTDSApi $(AssemblyName) @@ -25,13 +25,15 @@ Currently implements: Functions -DsAddSidHistoryA, DsAddSidHistoryW, DsBindA, DsBindByInstanceA, DsBindByInstanceW, DsBindingSetTimeout, DsBindToISTGA, DsBindToISTGW, DsBindW, DsBindWithCredA, DsBindWithCredW, DsBindWithSpnA, DsBindWithSpnExA, DsBindWithSpnExW, DsBindWithSpnW, DsClientMakeSpnForTargetServerA, DsClientMakeSpnForTargetServerW, DsCrackNamesA, DsCrackNamesW, DsCrackSpnA, DsCrackSpnW, DsCrackUnquotedMangledRdnA, DsCrackUnquotedMangledRdnW, DsFreeDomainControllerInfoA, DsFreeDomainControllerInfoW, DsFreeNameResultA, DsFreeNameResultW, DsFreePasswordCredentials, DsFreeSpnArrayA, DsFreeSpnArrayW, DsGetDomainControllerInfoA, DsGetDomainControllerInfoW, DsGetRdnW, DsGetSpnA, DsGetSpnW, DsIsMangledDnA, DsIsMangledDnW, DsIsMangledRdnValueA, DsIsMangledRdnValueW, DsMakePasswordCredentialsA, DsMakePasswordCredentialsW, DsMakeSpnA, DsMakeSpnW, DsQuoteRdnValueA, DsQuoteRdnValueW, DsUnBindA, DsUnBindW, DsUnquoteRdnValueA, DsUnquoteRdnValueW, DsWriteAccountSpnA, DsWriteAccountSpnW +DsAddSidHistoryA, DsAddSidHistoryW, DsBindA, DsBindByInstanceA, DsBindByInstanceW, DsBindingSetTimeout, DsBindToISTGA, DsBindToISTGW, DsBindW, DsBindWithCredA, DsBindWithCredW, DsBindWithSpnA, DsBindWithSpnExA, DsBindWithSpnExW, DsBindWithSpnW, DsClientMakeSpnForTargetServerA, DsClientMakeSpnForTargetServerW, DsCrackNamesA, DsCrackNamesW, DsCrackSpnA, DsCrackSpnW, DsCrackUnquotedMangledRdnA, DsCrackUnquotedMangledRdnW, DsFreeDomainControllerInfoA, DsFreeDomainControllerInfoW, DsFreeNameResultA, DsFreeNameResultW, DsFreePasswordCredentials, DsFreeSchemaGuidMapA, DsFreeSchemaGuidMapW, DsFreeSpnArrayA, DsFreeSpnArrayW, DsGetDomainControllerInfoA, DsGetDomainControllerInfoW, DsGetRdnW, DsGetSpnA, DsGetSpnW, DsInheritSecurityIdentityA, DsInheritSecurityIdentityW, DsIsMangledDnA, DsIsMangledDnW, DsIsMangledRdnValueA, DsIsMangledRdnValueW, DsListDomainsInSiteA, DsListDomainsInSiteW, DsListInfoForServerA, DsListInfoForServerW, DsListRolesA, DsListRolesW, DsListServersForDomainInSiteA, DsListServersForDomainInSiteW, DsListServersInSiteA, DsListServersInSiteW, DsListSitesA, DsListSitesW, DsMakePasswordCredentialsA, DsMakePasswordCredentialsW, DsMakeSpnA, DsMakeSpnW, DsMapSchemaGuidsA, DsMapSchemaGuidsW, DsQuerySitesByCostA, DsQuerySitesByCostW, DsQuerySitesFree, DsQuoteRdnValueA, DsQuoteRdnValueW, DsRemoveDsDomainA, DsRemoveDsDomainW, DsRemoveDsServerA, DsRemoveDsServerW, DsReplicaAddA, DsReplicaAddW, DsReplicaConsistencyCheck, DsReplicaDelA, DsReplicaDelW, DsReplicaFreeInfo, DsReplicaGetInfo2W, DsReplicaGetInfoW, DsReplicaModifyA, DsReplicaModifyW, DsReplicaSyncA, DsReplicaSyncAllA, DsReplicaSyncAllW, DsReplicaSyncW, DsReplicaUpdateRefsA, DsReplicaUpdateRefsW, DsReplicaVerifyObjectsA, DsReplicaVerifyObjectsW, DsServerRegisterSpnA, DsServerRegisterSpnW, DsUnBindA, DsUnBindW, DsUnquoteRdnValueA, DsUnquoteRdnValueW, DsWriteAccountSpnA, DsWriteAccountSpnW Structures -DS_DOMAIN_CONTROLLER_INFO_1, DS_DOMAIN_CONTROLLER_INFO_2, DS_DOMAIN_CONTROLLER_INFO_3, DS_NAME_RESULT, DS_NAME_RESULT_ITEM +DCInfoHandle, DS_DOMAIN_CONTROLLER_INFO_1, DS_DOMAIN_CONTROLLER_INFO_2, DS_DOMAIN_CONTROLLER_INFO_3, DS_NAME_RESULT, DS_NAME_RESULT_ITEM, DS_REPL_ATTR_META_DATA, DS_REPL_ATTR_META_DATA_2, DS_REPL_ATTR_META_DATA_BLOB, DS_REPL_ATTR_VALUE_META_DATA, DS_REPL_ATTR_VALUE_META_DATA_2, DS_REPL_ATTR_VALUE_META_DATA_EXT, DS_REPL_CURSOR, DS_REPL_CURSOR_2, DS_REPL_CURSOR_3W, DS_REPL_CURSOR_BLOB, DS_REPL_CURSORS, DS_REPL_CURSORS_2, DS_REPL_CURSORS_3W, DS_REPL_KCC_DSA_FAILURESW, DS_REPL_KCC_DSA_FAILUREW, DS_REPL_KCC_DSA_FAILUREW_BLOB, DS_REPL_NEIGHBOR, DS_REPL_NEIGHBORS, DS_REPL_NEIGHBORW_BLOB, DS_REPL_OBJ_META_DATA, DS_REPL_OBJ_META_DATA_2, DS_REPL_OPW, DS_REPL_OPW_BLOB, DS_REPL_PENDING_OPSW, DS_REPL_QUEUE_STATISTICSW, DS_REPL_VALUE_META_DATA, DS_REPL_VALUE_META_DATA_2, DS_REPL_VALUE_META_DATA_BLOB, DS_REPL_VALUE_META_DATA_BLOB_EXT, DS_REPL_VALUE_META_DATA_EXT, DS_REPSYNCALL_ERRINFO, DS_REPSYNCALL_UPDATE, DS_SCHEMA_GUID_MAP, DS_SITE_COST_INFO, SCHEDULE_HEADER, SpnArrayHandle, SCHEDULE latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/NTDll/Vanara.PInvoke.NTDll.csproj b/PInvoke/NTDll/Vanara.PInvoke.NTDll.csproj index b629ea44..9f603e04 100644 --- a/PInvoke/NTDll/Vanara.PInvoke.NTDll.csproj +++ b/PInvoke/NTDll/Vanara.PInvoke.NTDll.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from NtDll.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard20 Vanara.PInvoke.NtDll $(AssemblyName) @@ -32,6 +32,8 @@ CLIENT_ID, IO_STATUS_BLOCK, KEY_BASIC_INFORMATION, KEY_FULL_INFORMATION, KEY_NAM latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/NetApi32/DsGetDC.cs b/PInvoke/NetApi32/DsGetDC.cs index d80b720a..04f963dc 100644 --- a/PInvoke/NetApi32/DsGetDC.cs +++ b/PInvoke/NetApi32/DsGetDC.cs @@ -1023,7 +1023,7 @@ namespace Vanara.PInvoke // ComputerName, OUT LPSTR *SiteName ); [DllImport(Lib.NetApi32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("dsgetdc.h", MSDNShortId = "2dfffd9a-af4f-4a93-8b3c-966e4f7c455f")] - public static extern Win32Error DsGetSiteName(string ComputerName, out SafeNetApiBuffer SiteName); + public static extern Win32Error DsGetSiteName([Optional] string ComputerName, out SafeNetApiBuffer SiteName); /// /// diff --git a/PInvoke/NetApi32/Vanara.PInvoke.NetApi32.csproj b/PInvoke/NetApi32/Vanara.PInvoke.NetApi32.csproj index f71ce906..3d918a69 100644 --- a/PInvoke/NetApi32/Vanara.PInvoke.NetApi32.csproj +++ b/PInvoke/NetApi32/Vanara.PInvoke.NetApi32.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from NetApi32.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard20 Vanara.PInvoke.NetApi32 $(AssemblyName) @@ -32,6 +32,8 @@ DOMAIN_CONTROLLER_INFO, DS_DOMAIN_TRUSTS, DSROLE_OPERATION_STATE_INFO, DSROLE_PR latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/NetListMgr/Vanara.PInvoke.NetListMgr.csproj b/PInvoke/NetListMgr/Vanara.PInvoke.NetListMgr.csproj index 181f60e7..9fc6dff9 100644 --- a/PInvoke/NetListMgr/Vanara.PInvoke.NetListMgr.csproj +++ b/PInvoke/NetListMgr/Vanara.PInvoke.NetListMgr.csproj @@ -4,7 +4,7 @@ Methods, structures and constants for NetListMgr COM object. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard20 Vanara.PInvoke.NetListMgr $(AssemblyName) @@ -32,6 +32,8 @@ IEnumNetworkConnections, IEnumNetworks, INetwork, INetworkConnection, INetworkCo latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/Ole/Vanara.PInvoke.Ole.csproj b/PInvoke/Ole/Vanara.PInvoke.Ole.csproj index 1a525c79..7b1572c5 100644 --- a/PInvoke/Ole/Vanara.PInvoke.Ole.csproj +++ b/PInvoke/Ole/Vanara.PInvoke.Ole.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from Ole32.dll, OleAut32 and PropSys.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard20 Vanara.PInvoke.Ole $(AssemblyName) @@ -35,6 +35,8 @@ IErrorLog, IPropertyBag, IRecordInfo, IEnumSTATSTG, IStorage, IDropSource, IOleW latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/Security/CorrelationReport.md b/PInvoke/Security/CorrelationReport.md index e0dd2a54..5749267d 100644 --- a/PInvoke/Security/CorrelationReport.md +++ b/PInvoke/Security/CorrelationReport.md @@ -1,8 +1,8 @@ ## Correlation report for advapi32.dll, secur32.dll, authz.dll -### Methods (5% complete) +### Methods (28% complete) Native Method | Native DLL | Header | Managed Method --- | --- | --- | --- -[AbortSystemShutdown](https://www.google.com/search?num=5&q=AbortSystemShutdownA+site%3Amicrosoft.com) | advapi32.dll | | +[AbortSystemShutdown](http://msdn2.microsoft.com/en-us/library/aa376630) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.AbortSystemShutdown [AcceptSecurityContext](https://www.google.com/search?num=5&q=AcceptSecurityContext+site%3Amicrosoft.com) | secur32.dll | | [AccessCheck](https://www.google.com/search?num=5&q=AccessCheck+site%3Amicrosoft.com) | advapi32.dll | | [AccessCheckAndAuditAlarm](https://www.google.com/search?num=5&q=AccessCheckAndAuditAlarmA+site%3Amicrosoft.com) | advapi32.dll | | @@ -29,9 +29,9 @@ Native Method | Native DLL | Header | Managed Method [AddUsersToEncryptedFile](https://www.google.com/search?num=5&q=AddUsersToEncryptedFile+site%3Amicrosoft.com) | advapi32.dll | | [AddUsersToEncryptedFileEx](https://www.google.com/search?num=5&q=AddUsersToEncryptedFileEx+site%3Amicrosoft.com) | advapi32.dll | | [AdjustTokenGroups](https://www.google.com/search?num=5&q=AdjustTokenGroups+site%3Amicrosoft.com) | advapi32.dll | | -[AdjustTokenPrivileges](https://www.google.com/search?num=5&q=AdjustTokenPrivileges+site%3Amicrosoft.com) | advapi32.dll | | -[AllocateAndInitializeSid](https://www.google.com/search?num=5&q=AllocateAndInitializeSid+site%3Amicrosoft.com) | advapi32.dll | | -[AllocateLocallyUniqueId](https://www.google.com/search?num=5&q=AllocateLocallyUniqueId+site%3Amicrosoft.com) | advapi32.dll | | +[AdjustTokenPrivileges](http://msdn2.microsoft.com/en-us/library/aa375202) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.AdjustTokenPrivileges +[AllocateAndInitializeSid](http://msdn2.microsoft.com/en-us/library/aa375213) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.AllocateAndInitializeSid +[AllocateLocallyUniqueId](http://msdn2.microsoft.com/en-us/library/aa375260) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.AllocateLocallyUniqueId [ApplyControlToken](https://www.google.com/search?num=5&q=ApplyControlToken+site%3Amicrosoft.com) | secur32.dll | | [AreAllAccessesGranted](https://www.google.com/search?num=5&q=AreAllAccessesGranted+site%3Amicrosoft.com) | advapi32.dll | | [AreAnyAccessesGranted](https://www.google.com/search?num=5&q=AreAnyAccessesGranted+site%3Amicrosoft.com) | advapi32.dll | | @@ -125,18 +125,18 @@ Native Method | Native DLL | Header | Managed Method [BaseRegSetKeySecurity](https://www.google.com/search?num=5&q=BaseRegSetKeySecurity+site%3Amicrosoft.com) | advapi32.dll | | [BaseRegSetValue](https://www.google.com/search?num=5&q=BaseRegSetValue+site%3Amicrosoft.com) | advapi32.dll | | [BaseRegUnLoadKey](https://www.google.com/search?num=5&q=BaseRegUnLoadKey+site%3Amicrosoft.com) | advapi32.dll | | -[BuildExplicitAccessWithName](https://www.google.com/search?num=5&q=BuildExplicitAccessWithNameA+site%3Amicrosoft.com) | advapi32.dll | | +[BuildExplicitAccessWithName](http://msdn2.microsoft.com/en-us/library/5f12db19-63cf-4be6-9450-3c36e425967b) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.BuildExplicitAccessWithName [BuildImpersonateExplicitAccessWithName](https://www.google.com/search?num=5&q=BuildImpersonateExplicitAccessWithNameA+site%3Amicrosoft.com) | advapi32.dll | | [BuildImpersonateTrustee](https://www.google.com/search?num=5&q=BuildImpersonateTrusteeA+site%3Amicrosoft.com) | advapi32.dll | | -[BuildSecurityDescriptor](https://www.google.com/search?num=5&q=BuildSecurityDescriptorA+site%3Amicrosoft.com) | advapi32.dll | | -[BuildTrusteeWithName](https://www.google.com/search?num=5&q=BuildTrusteeWithNameA+site%3Amicrosoft.com) | advapi32.dll | | -[BuildTrusteeWithObjectsAndName](https://www.google.com/search?num=5&q=BuildTrusteeWithObjectsAndNameA+site%3Amicrosoft.com) | advapi32.dll | | -[BuildTrusteeWithObjectsAndSid](https://www.google.com/search?num=5&q=BuildTrusteeWithObjectsAndSidA+site%3Amicrosoft.com) | advapi32.dll | | -[BuildTrusteeWithSid](https://www.google.com/search?num=5&q=BuildTrusteeWithSidA+site%3Amicrosoft.com) | advapi32.dll | | +[BuildSecurityDescriptor](http://msdn2.microsoft.com/en-us/library/becc1218-5bc3-4ab2-86f8-3ebd10e16966) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.BuildSecurityDescriptor +[BuildTrusteeWithName](http://msdn2.microsoft.com/en-us/library/a66c23ac-8211-40fd-bfe8-ef9089bf3745) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.BuildTrusteeWithName +[BuildTrusteeWithObjectsAndName](http://msdn2.microsoft.com/en-us/library/62edadfe-0a7b-43ec-bd02-a63f928c7618) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.BuildTrusteeWithObjectsAndName +[BuildTrusteeWithObjectsAndSid](http://msdn2.microsoft.com/en-us/library/e940a87f-013e-458c-bdc1-9e81c7d905e0) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.BuildTrusteeWithObjectsAndSid +[BuildTrusteeWithSid](http://msdn2.microsoft.com/en-us/library/3745fbf2-911a-4cb6-81a8-6256c742c700) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.BuildTrusteeWithSid [CancelOverlappedAccess](https://www.google.com/search?num=5&q=CancelOverlappedAccess+site%3Amicrosoft.com) | advapi32.dll | | [ChangeAccountPassword](https://www.google.com/search?num=5&q=ChangeAccountPasswordA+site%3Amicrosoft.com) | secur32.dll | | -[ChangeServiceConfig](https://www.google.com/search?num=5&q=ChangeServiceConfigA+site%3Amicrosoft.com) | advapi32.dll | | -[ChangeServiceConfig2](https://www.google.com/search?num=5&q=ChangeServiceConfig2A+site%3Amicrosoft.com) | advapi32.dll | | +[ChangeServiceConfig](http://msdn2.microsoft.com/en-us/library/ms681987) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.ChangeServiceConfig +[ChangeServiceConfig2](http://msdn2.microsoft.com/en-us/library/ms681988) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.ChangeServiceConfig2 [CheckForHiberboot](https://www.google.com/search?num=5&q=CheckForHiberboot+site%3Amicrosoft.com) | advapi32.dll | | [CheckTokenMembership](https://www.google.com/search?num=5&q=CheckTokenMembership+site%3Amicrosoft.com) | advapi32.dll | | [ClearEventLog](https://www.google.com/search?num=5&q=ClearEventLogA+site%3Amicrosoft.com) | advapi32.dll | | @@ -144,7 +144,7 @@ Native Method | Native DLL | Header | Managed Method [CloseEncryptedFileRaw](https://www.google.com/search?num=5&q=CloseEncryptedFileRaw+site%3Amicrosoft.com) | advapi32.dll | | [CloseEventLog](https://www.google.com/search?num=5&q=CloseEventLog+site%3Amicrosoft.com) | advapi32.dll | | [CloseLsaPerformanceData](https://www.google.com/search?num=5&q=CloseLsaPerformanceData+site%3Amicrosoft.com) | secur32.dll | | -[CloseServiceHandle](https://www.google.com/search?num=5&q=CloseServiceHandle+site%3Amicrosoft.com) | advapi32.dll | | +[CloseServiceHandle](http://msdn2.microsoft.com/en-us/library/6cf25994-4939-4aff-af38-5ffc8fc606ae) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.CloseServiceHandle [CloseThreadWaitChainSession](https://www.google.com/search?num=5&q=CloseThreadWaitChainSession+site%3Amicrosoft.com) | advapi32.dll | | [CloseTrace](https://www.google.com/search?num=5&q=CloseTrace+site%3Amicrosoft.com) | advapi32.dll | | [CollectLsaPerformanceData](https://www.google.com/search?num=5&q=CollectLsaPerformanceData+site%3Amicrosoft.com) | secur32.dll | | @@ -159,14 +159,14 @@ Native Method | Native DLL | Header | Managed Method [ConvertSDToStringSDRootDomain](https://www.google.com/search?num=5&q=ConvertSDToStringSDRootDomainA+site%3Amicrosoft.com) | advapi32.dll | | [ConvertSecurityDescriptorToAccess](https://www.google.com/search?num=5&q=ConvertSecurityDescriptorToAccessA+site%3Amicrosoft.com) | advapi32.dll | | [ConvertSecurityDescriptorToAccessNamed](https://www.google.com/search?num=5&q=ConvertSecurityDescriptorToAccessNamedA+site%3Amicrosoft.com) | advapi32.dll | | -[ConvertSecurityDescriptorToStringSecurityDescriptor](https://www.google.com/search?num=5&q=ConvertSecurityDescriptorToStringSecurityDescriptorA+site%3Amicrosoft.com) | advapi32.dll | | -[ConvertSidToStringSid](https://www.google.com/search?num=5&q=ConvertSidToStringSidA+site%3Amicrosoft.com) | advapi32.dll | | +[ConvertSecurityDescriptorToStringSecurityDescriptor](http://msdn2.microsoft.com/en-us/library/36140833-8e30-4c32-a88a-c10751b6c223) | advapi32.dll | sddl.h | Vanara.PInvoke.AdvApi32.ConvertSecurityDescriptorToStringSecurityDescriptor +[ConvertSidToStringSid](http://msdn2.microsoft.com/en-us/library/aa376399) | advapi32.dll | sddl.h | Vanara.PInvoke.AdvApi32.ConvertSidToStringSid [ConvertStringSDToSDDomain](https://www.google.com/search?num=5&q=ConvertStringSDToSDDomainA+site%3Amicrosoft.com) | advapi32.dll | | [ConvertStringSDToSDRootDomain](https://www.google.com/search?num=5&q=ConvertStringSDToSDRootDomainA+site%3Amicrosoft.com) | advapi32.dll | | -[ConvertStringSecurityDescriptorToSecurityDescriptor](https://www.google.com/search?num=5&q=ConvertStringSecurityDescriptorToSecurityDescriptorA+site%3Amicrosoft.com) | advapi32.dll | | -[ConvertStringSidToSid](https://www.google.com/search?num=5&q=ConvertStringSidToSidA+site%3Amicrosoft.com) | advapi32.dll | | +[ConvertStringSecurityDescriptorToSecurityDescriptor](http://msdn2.microsoft.com/en-us/library/c5654148-fb4c-436d-9378-a1168fc82607) | advapi32.dll | sddl.h | Vanara.PInvoke.AdvApi32.ConvertStringSecurityDescriptorToSecurityDescriptor +[ConvertStringSidToSid](http://msdn2.microsoft.com/en-us/library/aa376402) | advapi32.dll | sddl.h | Vanara.PInvoke.AdvApi32.ConvertStringSidToSid [ConvertToAutoInheritPrivateObjectSecurity](https://www.google.com/search?num=5&q=ConvertToAutoInheritPrivateObjectSecurity+site%3Amicrosoft.com) | advapi32.dll | | -[CopySid](https://www.google.com/search?num=5&q=CopySid+site%3Amicrosoft.com) | advapi32.dll | | +[CopySid](http://msdn2.microsoft.com/en-us/library/aa376404) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.CopySid [CreateCodeAuthzLevel](https://www.google.com/search?num=5&q=CreateCodeAuthzLevel+site%3Amicrosoft.com) | advapi32.dll | | [CreatePrivateObjectSecurity](https://www.google.com/search?num=5&q=CreatePrivateObjectSecurity+site%3Amicrosoft.com) | advapi32.dll | | [CreatePrivateObjectSecurityEx](https://www.google.com/search?num=5&q=CreatePrivateObjectSecurityEx+site%3Amicrosoft.com) | advapi32.dll | | @@ -175,25 +175,29 @@ Native Method | Native DLL | Header | Managed Method [CreateProcessWithLogonW](https://www.google.com/search?num=5&q=CreateProcessWithLogonW+site%3Amicrosoft.com) | advapi32.dll | | [CreateProcessWithTokenW](https://www.google.com/search?num=5&q=CreateProcessWithTokenW+site%3Amicrosoft.com) | advapi32.dll | | [CreateRestrictedToken](https://www.google.com/search?num=5&q=CreateRestrictedToken+site%3Amicrosoft.com) | advapi32.dll | | -[CreateService](https://www.google.com/search?num=5&q=CreateServiceA+site%3Amicrosoft.com) | advapi32.dll | | +[CreateService](http://msdn2.microsoft.com/en-us/library/47288924-3294-4a50-b27d-7df80d5c957c) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.CreateService [CreateServiceEx](https://www.google.com/search?num=5&q=CreateServiceEx+site%3Amicrosoft.com) | advapi32.dll | | [CreateTraceInstanceId](https://www.google.com/search?num=5&q=CreateTraceInstanceId+site%3Amicrosoft.com) | advapi32.dll | | [CreateWellKnownSid](https://www.google.com/search?num=5&q=CreateWellKnownSid+site%3Amicrosoft.com) | advapi32.dll | | -[CredDelete](https://www.google.com/search?num=5&q=CredDeleteA+site%3Amicrosoft.com) | advapi32.dll | | -[CredEnumerate](https://www.google.com/search?num=5&q=CredEnumerateA+site%3Amicrosoft.com) | advapi32.dll | | -[CredFindBestCredential](https://www.google.com/search?num=5&q=CredFindBestCredentialA+site%3Amicrosoft.com) | advapi32.dll | | -[CredFree](https://www.google.com/search?num=5&q=CredFree+site%3Amicrosoft.com) | advapi32.dll | | -[CredGetSessionTypes](https://www.google.com/search?num=5&q=CredGetSessionTypes+site%3Amicrosoft.com) | advapi32.dll | | -[CredGetTargetInfo](https://www.google.com/search?num=5&q=CredGetTargetInfoA+site%3Amicrosoft.com) | advapi32.dll | | -[CredIsMarshaledCredential](https://www.google.com/search?num=5&q=CredIsMarshaledCredentialA+site%3Amicrosoft.com) | advapi32.dll | | -[CredIsProtected](https://www.google.com/search?num=5&q=CredIsProtectedA+site%3Amicrosoft.com) | advapi32.dll | | -[CredProtect](https://www.google.com/search?num=5&q=CredProtectA+site%3Amicrosoft.com) | advapi32.dll | | -[CredRead](https://www.google.com/search?num=5&q=CredReadA+site%3Amicrosoft.com) | advapi32.dll | | -[CredReadDomainCredentials](https://www.google.com/search?num=5&q=CredReadDomainCredentialsA+site%3Amicrosoft.com) | advapi32.dll | | -[CredRename](https://www.google.com/search?num=5&q=CredRenameA+site%3Amicrosoft.com) | advapi32.dll | | -[CredUnprotect](https://www.google.com/search?num=5&q=CredUnprotectA+site%3Amicrosoft.com) | advapi32.dll | | -[CredWrite](https://www.google.com/search?num=5&q=CredWriteA+site%3Amicrosoft.com) | advapi32.dll | | -[CredWriteDomainCredentials](https://www.google.com/search?num=5&q=CredWriteDomainCredentialsA+site%3Amicrosoft.com) | advapi32.dll | | +[CredDelete](http://msdn2.microsoft.com/en-us/library/154af9c8-18fd-412d-899d-7c6d2138380d) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredDelete +[CredEnumerate](http://msdn2.microsoft.com/en-us/library/ef0b7620-7b00-45f1-af16-141d2e940783) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredEnumerate +[CredFindBestCredential](http://msdn2.microsoft.com/en-us/library/b39e3167-dd63-4b81-b850-f3117be348a5) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredFindBestCredential +[CredFree](http://msdn2.microsoft.com/en-us/library/bc33ab1b-dd3f-4e1b-96d2-e32ceff89ada) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredFree +[CredGetSessionTypes](http://msdn2.microsoft.com/en-us/library/70f8d5e0-235b-4330-8add-566b41c91c17) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredGetSessionTypes +[CredGetTargetInfo](http://msdn2.microsoft.com/en-us/library/14dca0af-72d7-4ca8-84bb-c7040c5b5fb9) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredGetTargetInfo +[CredIsMarshaledCredential](http://msdn2.microsoft.com/en-us/library/fc902c0c-41e0-4178-8ca0-227a1d218388) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredIsMarshaledCredential +[CredIsProtected](http://msdn2.microsoft.com/en-us/library/3c38ecf5-1288-4a50-ad17-595e9ff4aaca) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredIsProtected +[CredMarshalCredentialA](http://msdn2.microsoft.com/en-us/library/20a1d54b-04a7-4b0a-88e4-1970d1f71502) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredMarshalCredential +[CredMarshalCredentialW](http://msdn2.microsoft.com/en-us/library/20a1d54b-04a7-4b0a-88e4-1970d1f71502) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredMarshalCredential +[CredProtect](http://msdn2.microsoft.com/en-us/library/1e299dfb-2ffe-463c-9e2c-b7774a2216e3) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredProtect +[CredRead](http://msdn2.microsoft.com/en-us/library/3222de7b-5290-4e82-a382-b2db6afc78cc) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredRead +[CredReadDomainCredentials](http://msdn2.microsoft.com/en-us/library/b62cb9c9-2a64-4ef4-97f0-e1ea85976d3e) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredReadDomainCredentials +[CredRename](http://msdn2.microsoft.com/en-us/library/e598f2ae-f975-4dd2-bf0b-e2fd96d4c940) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredRename +[CredUnmarshalCredentialA](http://msdn2.microsoft.com/en-us/library/65757235-d92c-479f-8e2b-1f8d8564792b) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredUnmarshalCredential +[CredUnmarshalCredentialW](http://msdn2.microsoft.com/en-us/library/65757235-d92c-479f-8e2b-1f8d8564792b) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredUnmarshalCredential +[CredUnprotect](http://msdn2.microsoft.com/en-us/library/7a22fb2b-edfc-45f2-b2d2-729f3761584d) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredUnprotect +[CredWrite](http://msdn2.microsoft.com/en-us/library/9a590347-d610-4916-bf63-60fbec173ac2) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredWrite +[CredWriteDomainCredentials](http://msdn2.microsoft.com/en-us/library/6b54c14f-a736-4fb0-b4e4-97765a792a5e) | advapi32.dll | wincred.h | Vanara.PInvoke.AdvApi32.CredWriteDomainCredentials [CveEventWrite](https://www.google.com/search?num=5&q=CveEventWrite+site%3Amicrosoft.com) | advapi32.dll | | [DecryptFile](https://www.google.com/search?num=5&q=DecryptFileA+site%3Amicrosoft.com) | advapi32.dll | | [DecryptMessage](https://www.google.com/search?num=5&q=DecryptMessage+site%3Amicrosoft.com) | secur32.dll | | @@ -201,11 +205,11 @@ Native Method | Native DLL | Header | Managed Method [DeleteSecurityContext](https://www.google.com/search?num=5&q=DeleteSecurityContext+site%3Amicrosoft.com) | secur32.dll | | [DeleteSecurityPackage](https://www.google.com/search?num=5&q=DeleteSecurityPackageA+site%3Amicrosoft.com) | secur32.dll | | [DeleteService](https://www.google.com/search?num=5&q=DeleteService+site%3Amicrosoft.com) | advapi32.dll | | -[DeregisterEventSource](https://www.google.com/search?num=5&q=DeregisterEventSource+site%3Amicrosoft.com) | advapi32.dll | | +[DeregisterEventSource](http://msdn2.microsoft.com/en-us/library/f5d1f4b0-5320-4aec-a129-cafff6f1fed1) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.DeregisterEventSource [DestroyPrivateObjectSecurity](https://www.google.com/search?num=5&q=DestroyPrivateObjectSecurity+site%3Amicrosoft.com) | advapi32.dll | | [DuplicateEncryptionInfoFile](https://www.google.com/search?num=5&q=DuplicateEncryptionInfoFile+site%3Amicrosoft.com) | advapi32.dll | | -[DuplicateToken](https://www.google.com/search?num=5&q=DuplicateToken+site%3Amicrosoft.com) | advapi32.dll | | -[DuplicateTokenEx](https://www.google.com/search?num=5&q=DuplicateTokenEx+site%3Amicrosoft.com) | advapi32.dll | | +[DuplicateToken](http://msdn2.microsoft.com/en-us/library/aa446616) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.DuplicateToken +[DuplicateTokenEx](http://msdn2.microsoft.com/en-us/library/aa446617) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.DuplicateTokenEx [EnableTrace](https://www.google.com/search?num=5&q=EnableTrace+site%3Amicrosoft.com) | advapi32.dll | | [EnableTraceEx](https://www.google.com/search?num=5&q=EnableTraceEx+site%3Amicrosoft.com) | advapi32.dll | | [EnableTraceEx2](https://www.google.com/search?num=5&q=EnableTraceEx2+site%3Amicrosoft.com) | advapi32.dll | | @@ -223,7 +227,7 @@ Native Method | Native DLL | Header | Managed Method [EnumServicesStatusEx](https://www.google.com/search?num=5&q=EnumServicesStatusExA+site%3Amicrosoft.com) | advapi32.dll | | [EqualDomainSid](https://www.google.com/search?num=5&q=EqualDomainSid+site%3Amicrosoft.com) | advapi32.dll | | [EqualPrefixSid](https://www.google.com/search?num=5&q=EqualPrefixSid+site%3Amicrosoft.com) | advapi32.dll | | -[EqualSid](https://www.google.com/search?num=5&q=EqualSid+site%3Amicrosoft.com) | advapi32.dll | | +[EqualSid](http://msdn2.microsoft.com/en-us/library/aa446622) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.EqualSid [EventAccessControl](https://www.google.com/search?num=5&q=EventAccessControl+site%3Amicrosoft.com) | advapi32.dll | | [EventAccessQuery](https://www.google.com/search?num=5&q=EventAccessQuery+site%3Amicrosoft.com) | advapi32.dll | | [EventAccessRemove](https://www.google.com/search?num=5&q=EventAccessRemove+site%3Amicrosoft.com) | advapi32.dll | | @@ -251,13 +255,13 @@ Native Method | Native DLL | Header | Managed Method [FreeEncryptedFileKeyInfo](https://www.google.com/search?num=5&q=FreeEncryptedFileKeyInfo+site%3Amicrosoft.com) | advapi32.dll | | [FreeEncryptedFileMetadata](https://www.google.com/search?num=5&q=FreeEncryptedFileMetadata+site%3Amicrosoft.com) | advapi32.dll | | [FreeEncryptionCertificateHashList](https://www.google.com/search?num=5&q=FreeEncryptionCertificateHashList+site%3Amicrosoft.com) | advapi32.dll | | -[FreeInheritedFromArray](https://www.google.com/search?num=5&q=FreeInheritedFromArray+site%3Amicrosoft.com) | advapi32.dll | | -[FreeSid](https://www.google.com/search?num=5&q=FreeSid+site%3Amicrosoft.com) | advapi32.dll | | +[FreeInheritedFromArray](http://msdn2.microsoft.com/en-us/library/aa446630) | advapi32.dll | Aclapi.h | Vanara.PInvoke.AdvApi32.FreeInheritedFromArray +[FreeSid](http://msdn2.microsoft.com/en-us/library/aa446631) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.FreeSid [GenerateNewCAPID](https://www.google.com/search?num=5&q=GenerateNewCAPID+site%3Amicrosoft.com) | authz.dll | | [GetAccessPermissionsForObject](https://www.google.com/search?num=5&q=GetAccessPermissionsForObjectA+site%3Amicrosoft.com) | advapi32.dll | | -[GetAce](https://www.google.com/search?num=5&q=GetAce+site%3Amicrosoft.com) | advapi32.dll | | -[GetAclInformation](https://www.google.com/search?num=5&q=GetAclInformation+site%3Amicrosoft.com) | advapi32.dll | | -[GetAuditedPermissionsFromAcl](https://www.google.com/search?num=5&q=GetAuditedPermissionsFromAclA+site%3Amicrosoft.com) | advapi32.dll | | +[GetAce](http://msdn2.microsoft.com/en-us/library/aa446634) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetAce +[GetAclInformation](http://msdn2.microsoft.com/en-us/library/aa446635) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetAclInformation +[GetAuditedPermissionsFromAcl](http://msdn2.microsoft.com/en-us/library/4381fe12-5fb3-4f9c-8daa-261cb1a466ec) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.GetAuditedPermissionsFromAcl [GetCentralAccessPoliciesByCapID](https://www.google.com/search?num=5&q=GetCentralAccessPoliciesByCapID+site%3Amicrosoft.com) | authz.dll | | [GetCentralAccessPoliciesByDN](https://www.google.com/search?num=5&q=GetCentralAccessPoliciesByDN+site%3Amicrosoft.com) | authz.dll | | [GetClaimDefinitions](https://www.google.com/search?num=5&q=GetClaimDefinitions+site%3Amicrosoft.com) | authz.dll | | @@ -266,60 +270,60 @@ Native Method | Native DLL | Header | Managed Method [GetCurrentHwProfile](https://www.google.com/search?num=5&q=GetCurrentHwProfileA+site%3Amicrosoft.com) | advapi32.dll | | [GetDefaultCAPESecurityDescriptor](https://www.google.com/search?num=5&q=GetDefaultCAPESecurityDescriptor+site%3Amicrosoft.com) | authz.dll | | [GetDynamicTimeZoneInformationEffectiveYears](https://www.google.com/search?num=5&q=GetDynamicTimeZoneInformationEffectiveYears+site%3Amicrosoft.com) | advapi32.dll | | -[GetEffectiveRightsFromAcl](https://www.google.com/search?num=5&q=GetEffectiveRightsFromAclA+site%3Amicrosoft.com) | advapi32.dll | | +[GetEffectiveRightsFromAcl](http://msdn2.microsoft.com/en-us/library/aa446637) | advapi32.dll | Aclapi.h | Vanara.PInvoke.AdvApi32.GetEffectiveRightsFromAcl [GetEncryptedFileMetadata](https://www.google.com/search?num=5&q=GetEncryptedFileMetadata+site%3Amicrosoft.com) | advapi32.dll | | [GetEventLogInformation](https://www.google.com/search?num=5&q=GetEventLogInformation+site%3Amicrosoft.com) | advapi32.dll | | -[GetExplicitEntriesFromAcl](https://www.google.com/search?num=5&q=GetExplicitEntriesFromAclA+site%3Amicrosoft.com) | advapi32.dll | | +[GetExplicitEntriesFromAcl](http://msdn2.microsoft.com/en-us/library/186aa6aa-efc3-4f8a-acad-e257da3dac0b) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.GetExplicitEntriesFromAcl [GetFileSecurity](https://www.google.com/search?num=5&q=GetFileSecurityA+site%3Amicrosoft.com) | advapi32.dll | | [GetInformationCodeAuthzLevelW](https://www.google.com/search?num=5&q=GetInformationCodeAuthzLevelW+site%3Amicrosoft.com) | advapi32.dll | | [GetInformationCodeAuthzPolicyW](https://www.google.com/search?num=5&q=GetInformationCodeAuthzPolicyW+site%3Amicrosoft.com) | advapi32.dll | | -[GetInheritanceSource](https://www.google.com/search?num=5&q=GetInheritanceSourceA+site%3Amicrosoft.com) | advapi32.dll | | +[GetInheritanceSource](http://msdn2.microsoft.com/en-us/library/aa446640) | advapi32.dll | Aclapi.h | Vanara.PInvoke.AdvApi32.GetInheritanceSource [GetKernelObjectSecurity](https://www.google.com/search?num=5&q=GetKernelObjectSecurity+site%3Amicrosoft.com) | advapi32.dll | | -[GetLengthSid](https://www.google.com/search?num=5&q=GetLengthSid+site%3Amicrosoft.com) | advapi32.dll | | +[GetLengthSid](http://msdn2.microsoft.com/en-us/library/aa446642) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetLengthSid [GetLocalManagedApplicationData](https://www.google.com/search?num=5&q=GetLocalManagedApplicationData+site%3Amicrosoft.com) | advapi32.dll | | [GetLocalManagedApplications](https://www.google.com/search?num=5&q=GetLocalManagedApplications+site%3Amicrosoft.com) | advapi32.dll | | [GetManagedApplicationCategories](https://www.google.com/search?num=5&q=GetManagedApplicationCategories+site%3Amicrosoft.com) | advapi32.dll | | [GetManagedApplications](https://www.google.com/search?num=5&q=GetManagedApplications+site%3Amicrosoft.com) | advapi32.dll | | [GetMultipleTrustee](https://www.google.com/search?num=5&q=GetMultipleTrusteeA+site%3Amicrosoft.com) | advapi32.dll | | [GetMultipleTrusteeOperation](https://www.google.com/search?num=5&q=GetMultipleTrusteeOperationA+site%3Amicrosoft.com) | advapi32.dll | | -[GetNamedSecurityInfo](https://www.google.com/search?num=5&q=GetNamedSecurityInfoA+site%3Amicrosoft.com) | advapi32.dll | | +[GetNamedSecurityInfo](http://msdn2.microsoft.com/en-us/library/aa446645) | advapi32.dll | Aclapi.h | Vanara.PInvoke.AdvApi32.GetNamedSecurityInfo [GetNamedSecurityInfoEx](https://www.google.com/search?num=5&q=GetNamedSecurityInfoExA+site%3Amicrosoft.com) | advapi32.dll | | [GetNumberOfEventLogRecords](https://www.google.com/search?num=5&q=GetNumberOfEventLogRecords+site%3Amicrosoft.com) | advapi32.dll | | [GetOldestEventLogRecord](https://www.google.com/search?num=5&q=GetOldestEventLogRecord+site%3Amicrosoft.com) | advapi32.dll | | [GetOverlappedAccessResults](https://www.google.com/search?num=5&q=GetOverlappedAccessResults+site%3Amicrosoft.com) | advapi32.dll | | -[GetPrivateObjectSecurity](https://www.google.com/search?num=5&q=GetPrivateObjectSecurity+site%3Amicrosoft.com) | advapi32.dll | | -[GetSecurityDescriptorControl](https://www.google.com/search?num=5&q=GetSecurityDescriptorControl+site%3Amicrosoft.com) | advapi32.dll | | -[GetSecurityDescriptorDacl](https://www.google.com/search?num=5&q=GetSecurityDescriptorDacl+site%3Amicrosoft.com) | advapi32.dll | | -[GetSecurityDescriptorGroup](https://www.google.com/search?num=5&q=GetSecurityDescriptorGroup+site%3Amicrosoft.com) | advapi32.dll | | -[GetSecurityDescriptorLength](https://www.google.com/search?num=5&q=GetSecurityDescriptorLength+site%3Amicrosoft.com) | advapi32.dll | | -[GetSecurityDescriptorOwner](https://www.google.com/search?num=5&q=GetSecurityDescriptorOwner+site%3Amicrosoft.com) | advapi32.dll | | +[GetPrivateObjectSecurity](http://msdn2.microsoft.com/en-us/library/aa446646) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetPrivateObjectSecurity +[GetSecurityDescriptorControl](http://msdn2.microsoft.com/en-us/library/d66682f2-8017-4245-9d93-5f8332a5b483) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetSecurityDescriptorControl +[GetSecurityDescriptorDacl](http://msdn2.microsoft.com/en-us/library/aa446648) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetSecurityDescriptorDacl +[GetSecurityDescriptorGroup](http://msdn2.microsoft.com/en-us/library/a920b49e-a4c2-4e49-b529-88c12205d995) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetSecurityDescriptorGroup +[GetSecurityDescriptorLength](http://msdn2.microsoft.com/en-us/library/eb331839-ff3e-4f4b-b93b-18da2ea72697) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetSecurityDescriptorLength +[GetSecurityDescriptorOwner](http://msdn2.microsoft.com/en-us/library/aa446651) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetSecurityDescriptorOwner [GetSecurityDescriptorRMControl](https://www.google.com/search?num=5&q=GetSecurityDescriptorRMControl+site%3Amicrosoft.com) | advapi32.dll | | -[GetSecurityDescriptorSacl](https://www.google.com/search?num=5&q=GetSecurityDescriptorSacl+site%3Amicrosoft.com) | advapi32.dll | | -[GetSecurityInfo](https://www.google.com/search?num=5&q=GetSecurityInfo+site%3Amicrosoft.com) | advapi32.dll | | +[GetSecurityDescriptorSacl](http://msdn2.microsoft.com/en-us/library/6bf59735-aaa3-4751-8c98-00cc197df4e5) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetSecurityDescriptorSacl +[GetSecurityInfo](http://msdn2.microsoft.com/en-us/library/64767a6b-cd79-4e02-881a-706a078ff446) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.GetSecurityInfo [GetSecurityInfoEx](https://www.google.com/search?num=5&q=GetSecurityInfoExA+site%3Amicrosoft.com) | advapi32.dll | | [GetSecurityUserInfo](https://www.google.com/search?num=5&q=GetSecurityUserInfo+site%3Amicrosoft.com) | secur32.dll | | [GetServiceDisplayName](https://www.google.com/search?num=5&q=GetServiceDisplayNameA+site%3Amicrosoft.com) | advapi32.dll | | [GetServiceKeyName](https://www.google.com/search?num=5&q=GetServiceKeyNameA+site%3Amicrosoft.com) | advapi32.dll | | -[GetSidIdentifierAuthority](https://www.google.com/search?num=5&q=GetSidIdentifierAuthority+site%3Amicrosoft.com) | advapi32.dll | | -[GetSidLengthRequired](https://www.google.com/search?num=5&q=GetSidLengthRequired+site%3Amicrosoft.com) | advapi32.dll | | -[GetSidSubAuthority](https://www.google.com/search?num=5&q=GetSidSubAuthority+site%3Amicrosoft.com) | advapi32.dll | | +[GetSidIdentifierAuthority](http://msdn2.microsoft.com/en-us/library/67a06e7b-775f-424c-ab36-0fc9b93b801a) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetSidIdentifierAuthority +[GetSidLengthRequired](http://msdn2.microsoft.com/en-us/library/a481fb4f-20bd-4f44-a3d5-d8b8d6228339) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetSidLengthRequired +[GetSidSubAuthority](http://msdn2.microsoft.com/en-us/library/aa446657) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetSidSubAuthority [GetSidSubAuthorityCount](https://www.google.com/search?num=5&q=GetSidSubAuthorityCount+site%3Amicrosoft.com) | advapi32.dll | | [GetStringConditionFromBinary](https://www.google.com/search?num=5&q=GetStringConditionFromBinary+site%3Amicrosoft.com) | advapi32.dll | | [GetThreadWaitChain](https://www.google.com/search?num=5&q=GetThreadWaitChain+site%3Amicrosoft.com) | advapi32.dll | | -[GetTokenInformation](https://www.google.com/search?num=5&q=GetTokenInformation+site%3Amicrosoft.com) | advapi32.dll | | +[GetTokenInformation](http://msdn2.microsoft.com/en-us/library/aa446671) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.GetTokenInformation [GetTraceEnableFlags](https://www.google.com/search?num=5&q=GetTraceEnableFlags+site%3Amicrosoft.com) | advapi32.dll | | [GetTraceEnableLevel](https://www.google.com/search?num=5&q=GetTraceEnableLevel+site%3Amicrosoft.com) | advapi32.dll | | [GetTraceLoggerHandle](https://www.google.com/search?num=5&q=GetTraceLoggerHandle+site%3Amicrosoft.com) | advapi32.dll | | -[GetTrusteeForm](https://www.google.com/search?num=5&q=GetTrusteeFormA+site%3Amicrosoft.com) | advapi32.dll | | -[GetTrusteeName](https://www.google.com/search?num=5&q=GetTrusteeNameA+site%3Amicrosoft.com) | advapi32.dll | | -[GetTrusteeType](https://www.google.com/search?num=5&q=GetTrusteeTypeA+site%3Amicrosoft.com) | advapi32.dll | | +[GetTrusteeForm](http://msdn2.microsoft.com/en-us/library/e5e450b8-0b7b-4324-b453-5c020e74b1ee) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.GetTrusteeForm +[GetTrusteeName](http://msdn2.microsoft.com/en-us/library/9d3ce528-fb28-4e2e-bf7f-7d84c697fcb6) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.GetTrusteeName +[GetTrusteeType](http://msdn2.microsoft.com/en-us/library/19777929-43cf-45ea-8283-e42bf9ce8d7a) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.GetTrusteeType [GetUserName](https://www.google.com/search?num=5&q=GetUserNameA+site%3Amicrosoft.com) | advapi32.dll | | [GetUserNameEx](https://www.google.com/search?num=5&q=GetUserNameExA+site%3Amicrosoft.com) | secur32.dll | | [GetWindowsAccountDomainSid](https://www.google.com/search?num=5&q=GetWindowsAccountDomainSid+site%3Amicrosoft.com) | advapi32.dll | | [IdentifyCodeAuthzLevelW](https://www.google.com/search?num=5&q=IdentifyCodeAuthzLevelW+site%3Amicrosoft.com) | advapi32.dll | | [ImpersonateAnonymousToken](https://www.google.com/search?num=5&q=ImpersonateAnonymousToken+site%3Amicrosoft.com) | advapi32.dll | | -[ImpersonateLoggedOnUser](https://www.google.com/search?num=5&q=ImpersonateLoggedOnUser+site%3Amicrosoft.com) | advapi32.dll | | -[ImpersonateNamedPipeClient](https://www.google.com/search?num=5&q=ImpersonateNamedPipeClient+site%3Amicrosoft.com) | advapi32.dll | | +[ImpersonateLoggedOnUser](http://msdn2.microsoft.com/en-us/library/cf5c31ae-6749-45c2-888f-697060cc8c75) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.ImpersonateLoggedOnUser +[ImpersonateNamedPipeClient](http://msdn2.microsoft.com/en-us/library/aa378618) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.ImpersonateNamedPipeClient [ImpersonateSecurityContext](https://www.google.com/search?num=5&q=ImpersonateSecurityContext+site%3Amicrosoft.com) | secur32.dll | | [ImpersonateSelf](https://www.google.com/search?num=5&q=ImpersonateSelf+site%3Amicrosoft.com) | advapi32.dll | | [ImportSecurityContext](https://www.google.com/search?num=5&q=ImportSecurityContextA+site%3Amicrosoft.com) | secur32.dll | | @@ -328,9 +332,9 @@ Native Method | Native DLL | Header | Managed Method [InitializeSecurityContext](https://www.google.com/search?num=5&q=InitializeSecurityContextA+site%3Amicrosoft.com) | secur32.dll | | [InitializeSecurityDescriptor](https://www.google.com/search?num=5&q=InitializeSecurityDescriptor+site%3Amicrosoft.com) | advapi32.dll | | [InitializeSid](https://www.google.com/search?num=5&q=InitializeSid+site%3Amicrosoft.com) | advapi32.dll | | -[InitiateShutdown](https://www.google.com/search?num=5&q=InitiateShutdownA+site%3Amicrosoft.com) | advapi32.dll | | -[InitiateSystemShutdown](https://www.google.com/search?num=5&q=InitiateSystemShutdownA+site%3Amicrosoft.com) | advapi32.dll | | -[InitiateSystemShutdownEx](https://www.google.com/search?num=5&q=InitiateSystemShutdownExA+site%3Amicrosoft.com) | advapi32.dll | | +[InitiateShutdown](http://msdn2.microsoft.com/en-us/library/aa376872) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.InitiateShutdown +[InitiateSystemShutdown](http://msdn2.microsoft.com/en-us/library/cad54fea-7f59-438c-83ac-f0160d81496b) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.InitiateSystemShutdown +[InitiateSystemShutdownEx](http://msdn2.microsoft.com/en-us/library/aa376874) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.InitiateSystemShutdownEx [InitSecurityInterface](https://www.google.com/search?num=5&q=InitSecurityInterfaceA+site%3Amicrosoft.com) | secur32.dll | | [InstallApplication](https://www.google.com/search?num=5&q=InstallApplication+site%3Amicrosoft.com) | advapi32.dll | | [IsTextUnicode](https://www.google.com/search?num=5&q=IsTextUnicode+site%3Amicrosoft.com) | advapi32.dll | | @@ -339,46 +343,46 @@ Native Method | Native DLL | Header | Managed Method [IsValidAcl](https://www.google.com/search?num=5&q=IsValidAcl+site%3Amicrosoft.com) | advapi32.dll | | [IsValidRelativeSecurityDescriptor](https://www.google.com/search?num=5&q=IsValidRelativeSecurityDescriptor+site%3Amicrosoft.com) | advapi32.dll | | [IsValidSecurityDescriptor](https://www.google.com/search?num=5&q=IsValidSecurityDescriptor+site%3Amicrosoft.com) | advapi32.dll | | -[IsValidSid](https://www.google.com/search?num=5&q=IsValidSid+site%3Amicrosoft.com) | advapi32.dll | | +[IsValidSid](http://msdn2.microsoft.com/en-us/library/aa379151) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.IsValidSid [IsWellKnownSid](https://www.google.com/search?num=5&q=IsWellKnownSid+site%3Amicrosoft.com) | advapi32.dll | | [LockServiceDatabase](https://www.google.com/search?num=5&q=LockServiceDatabase+site%3Amicrosoft.com) | advapi32.dll | | -[LogonUser](https://www.google.com/search?num=5&q=LogonUserA+site%3Amicrosoft.com) | advapi32.dll | | -[LogonUserEx](https://www.google.com/search?num=5&q=LogonUserExA+site%3Amicrosoft.com) | advapi32.dll | | +[LogonUser](http://msdn2.microsoft.com/en-us/library/aa378184) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.LogonUser +[LogonUserEx](http://msdn2.microsoft.com/en-us/library/aa378189) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.LogonUserEx [LogonUserExExW](https://www.google.com/search?num=5&q=LogonUserExExW+site%3Amicrosoft.com) | advapi32.dll | | -[LookupAccountName](https://www.google.com/search?num=5&q=LookupAccountNameA+site%3Amicrosoft.com) | advapi32.dll | | -[LookupAccountSid](https://www.google.com/search?num=5&q=LookupAccountSidA+site%3Amicrosoft.com) | advapi32.dll | | -[LookupPrivilegeDisplayName](https://www.google.com/search?num=5&q=LookupPrivilegeDisplayNameA+site%3Amicrosoft.com) | advapi32.dll | | -[LookupPrivilegeName](https://www.google.com/search?num=5&q=LookupPrivilegeNameA+site%3Amicrosoft.com) | advapi32.dll | | -[LookupPrivilegeValue](https://www.google.com/search?num=5&q=LookupPrivilegeValueA+site%3Amicrosoft.com) | advapi32.dll | | -[LookupSecurityDescriptorParts](https://www.google.com/search?num=5&q=LookupSecurityDescriptorPartsA+site%3Amicrosoft.com) | advapi32.dll | | -[LsaAddAccountRights](https://www.google.com/search?num=5&q=LsaAddAccountRights+site%3Amicrosoft.com) | advapi32.dll | | +[LookupAccountName](http://msdn2.microsoft.com/en-us/library/aa379159) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.LookupAccountName +[LookupAccountSid](http://msdn2.microsoft.com/en-us/library/aa379166) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.LookupAccountSid +[LookupPrivilegeDisplayName](http://msdn2.microsoft.com/en-us/library/1fbb26b6-615e-4883-9f4b-3a1d05d9feaa) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.LookupPrivilegeDisplayName +[LookupPrivilegeName](http://msdn2.microsoft.com/en-us/library/580fb58f-1470-4389-9f07-8f37403e2bdf) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.LookupPrivilegeName +[LookupPrivilegeValue](http://msdn2.microsoft.com/en-us/library/334b8ba8-101d-43a1-a8bf-1c7e0448c272) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.LookupPrivilegeValue +[LookupSecurityDescriptorParts](http://msdn2.microsoft.com/en-us/library/68c3f56b-6c48-4f4b-bd38-9f4e346c663b) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.LookupSecurityDescriptorParts +[LsaAddAccountRights](http://msdn2.microsoft.com/en-us/library/ms721786) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaAddAccountRights [LsaAddPrivilegesToAccount](https://www.google.com/search?num=5&q=LsaAddPrivilegesToAccount+site%3Amicrosoft.com) | advapi32.dll | | [LsaCallAuthenticationPackage](https://www.google.com/search?num=5&q=LsaCallAuthenticationPackage+site%3Amicrosoft.com) | secur32.dll | | [LsaClearAuditLog](https://www.google.com/search?num=5&q=LsaClearAuditLog+site%3Amicrosoft.com) | advapi32.dll | | -[LsaClose](https://www.google.com/search?num=5&q=LsaClose+site%3Amicrosoft.com) | advapi32.dll | | +[LsaClose](http://msdn2.microsoft.com/en-us/library/6283b1da-4ec3-48e1-91f6-321c6390befe) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaClose [LsaConnectUntrusted](http://msdn2.microsoft.com/en-us/library/b54917c8-51cd-4891-9613-f37a4a46448b) | secur32.dll | ntsecapi.h | Vanara.PInvoke.Secur32.LsaConnectUntrusted -[LsaCreateAccount](https://www.google.com/search?num=5&q=LsaCreateAccount+site%3Amicrosoft.com) | advapi32.dll | | +[LsaCreateAccount](https://www.google.com/search?num=5&q=LsaCreateAccount+site%3Amicrosoft.com) | advapi32.dll | | Vanara.PInvoke.AdvApi32.LsaCreateAccount [LsaCreateSecret](https://www.google.com/search?num=5&q=LsaCreateSecret+site%3Amicrosoft.com) | advapi32.dll | | [LsaCreateTrustedDomain](https://www.google.com/search?num=5&q=LsaCreateTrustedDomain+site%3Amicrosoft.com) | advapi32.dll | | [LsaCreateTrustedDomainEx](https://www.google.com/search?num=5&q=LsaCreateTrustedDomainEx+site%3Amicrosoft.com) | advapi32.dll | | [LsaDelete](https://www.google.com/search?num=5&q=LsaDelete+site%3Amicrosoft.com) | advapi32.dll | | [LsaDeleteTrustedDomain](https://www.google.com/search?num=5&q=LsaDeleteTrustedDomain+site%3Amicrosoft.com) | advapi32.dll | | [LsaDeregisterLogonProcess](http://msdn2.microsoft.com/en-us/library/aa378269) | secur32.dll | Ntsecapi.h | Vanara.PInvoke.Secur32.LsaDeregisterLogonProcess -[LsaEnumerateAccountRights](https://www.google.com/search?num=5&q=LsaEnumerateAccountRights+site%3Amicrosoft.com) | advapi32.dll | | +[LsaEnumerateAccountRights](http://msdn2.microsoft.com/en-us/library/3f4a4a9a-66ca-410a-8bdc-c390e8b966e3) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaEnumerateAccountRights [LsaEnumerateAccounts](https://www.google.com/search?num=5&q=LsaEnumerateAccounts+site%3Amicrosoft.com) | advapi32.dll | | -[LsaEnumerateAccountsWithUserRight](https://www.google.com/search?num=5&q=LsaEnumerateAccountsWithUserRight+site%3Amicrosoft.com) | advapi32.dll | | +[LsaEnumerateAccountsWithUserRight](http://msdn2.microsoft.com/en-us/library/97e7180e-4edb-4edd-915e-0477e7e7a9ff) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaEnumerateAccountsWithUserRight [LsaEnumerateLogonSessions](https://www.google.com/search?num=5&q=LsaEnumerateLogonSessions+site%3Amicrosoft.com) | secur32.dll | | [LsaEnumeratePrivileges](https://www.google.com/search?num=5&q=LsaEnumeratePrivileges+site%3Amicrosoft.com) | advapi32.dll | | [LsaEnumeratePrivilegesOfAccount](https://www.google.com/search?num=5&q=LsaEnumeratePrivilegesOfAccount+site%3Amicrosoft.com) | advapi32.dll | | [LsaEnumerateTrustedDomains](https://www.google.com/search?num=5&q=LsaEnumerateTrustedDomains+site%3Amicrosoft.com) | advapi32.dll | | [LsaEnumerateTrustedDomainsEx](https://www.google.com/search?num=5&q=LsaEnumerateTrustedDomainsEx+site%3Amicrosoft.com) | advapi32.dll | | -[LsaFreeMemory](https://www.google.com/search?num=5&q=LsaFreeMemory+site%3Amicrosoft.com) | advapi32.dll | | -[LsaFreeReturnBuffer](https://www.google.com/search?num=5&q=LsaFreeReturnBuffer+site%3Amicrosoft.com) | secur32.dll | | -[LsaGetAppliedCAPIDs](https://www.google.com/search?num=5&q=LsaGetAppliedCAPIDs+site%3Amicrosoft.com) | advapi32.dll | | +[LsaFreeMemory](http://msdn2.microsoft.com/en-us/library/6eb3d18f-c54c-4e51-8a4b-b7a3f930cfa9) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaFreeMemory +[LsaFreeReturnBuffer](http://msdn2.microsoft.com/en-us/library/e814ed68-07e7-4936-ba96-5411086f43f6) | secur32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaFreeReturnBuffer +[LsaGetAppliedCAPIDs](http://msdn2.microsoft.com/en-us/library/hh846251) | advapi32.dll | ntlsa.h | Vanara.PInvoke.AdvApi32.LsaGetAppliedCAPIDs [LsaGetLogonSessionData](https://www.google.com/search?num=5&q=LsaGetLogonSessionData+site%3Amicrosoft.com) | secur32.dll | | [LsaGetQuotasForAccount](https://www.google.com/search?num=5&q=LsaGetQuotasForAccount+site%3Amicrosoft.com) | advapi32.dll | | [LsaGetRemoteUserName](https://www.google.com/search?num=5&q=LsaGetRemoteUserName+site%3Amicrosoft.com) | advapi32.dll | | -[LsaGetSystemAccessAccount](https://www.google.com/search?num=5&q=LsaGetSystemAccessAccount+site%3Amicrosoft.com) | advapi32.dll | | +[LsaGetSystemAccessAccount](https://www.google.com/search?num=5&q=LsaGetSystemAccessAccount+site%3Amicrosoft.com) | advapi32.dll | | Vanara.PInvoke.AdvApi32.LsaGetSystemAccessAccount [LsaGetUserName](https://www.google.com/search?num=5&q=LsaGetUserName+site%3Amicrosoft.com) | advapi32.dll | | [LsaICLookupNames](https://www.google.com/search?num=5&q=LsaICLookupNames+site%3Amicrosoft.com) | advapi32.dll | | [LsaICLookupNamesWithCreds](https://www.google.com/search?num=5&q=LsaICLookupNamesWithCreds+site%3Amicrosoft.com) | advapi32.dll | | @@ -387,32 +391,32 @@ Native Method | Native DLL | Header | Managed Method [LsaLogonUser](https://www.google.com/search?num=5&q=LsaLogonUser+site%3Amicrosoft.com) | secur32.dll | | [LsaLookupAuthenticationPackage](http://msdn2.microsoft.com/en-us/library/aa378297) | secur32.dll | Ntsecapi.h | Vanara.PInvoke.Secur32.LsaLookupAuthenticationPackage [LsaLookupNames](https://www.google.com/search?num=5&q=LsaLookupNames+site%3Amicrosoft.com) | advapi32.dll | | -[LsaLookupNames2](https://www.google.com/search?num=5&q=LsaLookupNames2+site%3Amicrosoft.com) | advapi32.dll | | +[LsaLookupNames2](http://msdn2.microsoft.com/en-us/library/fe219070-6a00-4b8c-b2e4-2ad290a1cb9c) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaLookupNames2 [LsaLookupPrivilegeDisplayName](https://www.google.com/search?num=5&q=LsaLookupPrivilegeDisplayName+site%3Amicrosoft.com) | advapi32.dll | | [LsaLookupPrivilegeName](https://www.google.com/search?num=5&q=LsaLookupPrivilegeName+site%3Amicrosoft.com) | advapi32.dll | | -[LsaLookupPrivilegeValue](https://www.google.com/search?num=5&q=LsaLookupPrivilegeValue+site%3Amicrosoft.com) | advapi32.dll | | +[LsaLookupPrivilegeValue](http://msdn2.microsoft.com/en-us/library/4926fff9-6e1a-475c-95ab-78c9b67aaa87) | advapi32.dll | ntlsa.h | Vanara.PInvoke.AdvApi32.LsaLookupPrivilegeValue [LsaLookupSids](https://www.google.com/search?num=5&q=LsaLookupSids+site%3Amicrosoft.com) | advapi32.dll | | -[LsaLookupSids2](https://www.google.com/search?num=5&q=LsaLookupSids2+site%3Amicrosoft.com) | advapi32.dll | | +[LsaLookupSids2](http://msdn2.microsoft.com/en-us/library/6B30D1FF-35DC-44E8-A765-36A5761EC0CE) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaLookupSids2 [LsaManageSidNameMapping](https://www.google.com/search?num=5&q=LsaManageSidNameMapping+site%3Amicrosoft.com) | advapi32.dll | | -[LsaNtStatusToWinError](https://www.google.com/search?num=5&q=LsaNtStatusToWinError+site%3Amicrosoft.com) | advapi32.dll | | -[LsaOpenAccount](https://www.google.com/search?num=5&q=LsaOpenAccount+site%3Amicrosoft.com) | advapi32.dll | | -[LsaOpenPolicy](https://www.google.com/search?num=5&q=LsaOpenPolicy+site%3Amicrosoft.com) | advapi32.dll | | +[LsaNtStatusToWinError](http://msdn2.microsoft.com/en-us/library/fa91794c-c502-4b36-84cc-a8d77c8e9d9f) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaNtStatusToWinError +[LsaOpenAccount](https://www.google.com/search?num=5&q=LsaOpenAccount+site%3Amicrosoft.com) | advapi32.dll | | Vanara.PInvoke.AdvApi32.LsaOpenAccount +[LsaOpenPolicy](http://msdn2.microsoft.com/en-us/library/361bc962-1e97-4606-a835-cbce37692c55) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaOpenPolicy [LsaOpenPolicySce](https://www.google.com/search?num=5&q=LsaOpenPolicySce+site%3Amicrosoft.com) | advapi32.dll | | [LsaOpenSecret](https://www.google.com/search?num=5&q=LsaOpenSecret+site%3Amicrosoft.com) | advapi32.dll | | [LsaOpenTrustedDomain](https://www.google.com/search?num=5&q=LsaOpenTrustedDomain+site%3Amicrosoft.com) | advapi32.dll | | [LsaOpenTrustedDomainByName](https://www.google.com/search?num=5&q=LsaOpenTrustedDomainByName+site%3Amicrosoft.com) | advapi32.dll | | -[LsaQueryCAPs](https://www.google.com/search?num=5&q=LsaQueryCAPs+site%3Amicrosoft.com) | advapi32.dll | | +[LsaQueryCAPs](http://msdn2.microsoft.com/en-us/library/55D6FD6F-0FD5-41F6-967B-F5600E19C3EF) | advapi32.dll | ntlsa.h | Vanara.PInvoke.AdvApi32.LsaQueryCAPs [LsaQueryDomainInformationPolicy](https://www.google.com/search?num=5&q=LsaQueryDomainInformationPolicy+site%3Amicrosoft.com) | advapi32.dll | | [LsaQueryForestTrustInformation](https://www.google.com/search?num=5&q=LsaQueryForestTrustInformation+site%3Amicrosoft.com) | advapi32.dll | | [LsaQueryInformationPolicy](https://www.google.com/search?num=5&q=LsaQueryInformationPolicy+site%3Amicrosoft.com) | advapi32.dll | | [LsaQueryInfoTrustedDomain](https://www.google.com/search?num=5&q=LsaQueryInfoTrustedDomain+site%3Amicrosoft.com) | advapi32.dll | | [LsaQuerySecret](https://www.google.com/search?num=5&q=LsaQuerySecret+site%3Amicrosoft.com) | advapi32.dll | | [LsaQuerySecurityObject](https://www.google.com/search?num=5&q=LsaQuerySecurityObject+site%3Amicrosoft.com) | advapi32.dll | | -[LsaQueryTrustedDomainInfo](https://www.google.com/search?num=5&q=LsaQueryTrustedDomainInfo+site%3Amicrosoft.com) | advapi32.dll | | +[LsaQueryTrustedDomainInfo](http://msdn2.microsoft.com/en-us/library/62925515-a6f3-4b5f-bf97-edb968af19a3) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaQueryTrustedDomainInfo [LsaQueryTrustedDomainInfoByName](https://www.google.com/search?num=5&q=LsaQueryTrustedDomainInfoByName+site%3Amicrosoft.com) | advapi32.dll | | [LsaRegisterLogonProcess](http://msdn2.microsoft.com/en-us/library/aa378318) | secur32.dll | Ntsecapi.h | Vanara.PInvoke.Secur32.LsaRegisterLogonProcess [LsaRegisterPolicyChangeNotification](https://www.google.com/search?num=5&q=LsaRegisterPolicyChangeNotification+site%3Amicrosoft.com) | secur32.dll | | -[LsaRemoveAccountRights](https://www.google.com/search?num=5&q=LsaRemoveAccountRights+site%3Amicrosoft.com) | advapi32.dll | | +[LsaRemoveAccountRights](http://msdn2.microsoft.com/en-us/library/ad250a01-7a24-4fae-975c-aa3e65731c82) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaRemoveAccountRights [LsaRemovePrivilegesFromAccount](https://www.google.com/search?num=5&q=LsaRemovePrivilegesFromAccount+site%3Amicrosoft.com) | advapi32.dll | | [LsaRetrievePrivateData](https://www.google.com/search?num=5&q=LsaRetrievePrivateData+site%3Amicrosoft.com) | advapi32.dll | | [LsaSetCAPs](https://www.google.com/search?num=5&q=LsaSetCAPs+site%3Amicrosoft.com) | advapi32.dll | | @@ -423,16 +427,16 @@ Native Method | Native DLL | Header | Managed Method [LsaSetQuotasForAccount](https://www.google.com/search?num=5&q=LsaSetQuotasForAccount+site%3Amicrosoft.com) | advapi32.dll | | [LsaSetSecret](https://www.google.com/search?num=5&q=LsaSetSecret+site%3Amicrosoft.com) | advapi32.dll | | [LsaSetSecurityObject](https://www.google.com/search?num=5&q=LsaSetSecurityObject+site%3Amicrosoft.com) | advapi32.dll | | -[LsaSetSystemAccessAccount](https://www.google.com/search?num=5&q=LsaSetSystemAccessAccount+site%3Amicrosoft.com) | advapi32.dll | | +[LsaSetSystemAccessAccount](https://www.google.com/search?num=5&q=LsaSetSystemAccessAccount+site%3Amicrosoft.com) | advapi32.dll | | Vanara.PInvoke.AdvApi32.LsaSetSystemAccessAccount [LsaSetTrustedDomainInfoByName](https://www.google.com/search?num=5&q=LsaSetTrustedDomainInfoByName+site%3Amicrosoft.com) | advapi32.dll | | -[LsaSetTrustedDomainInformation](https://www.google.com/search?num=5&q=LsaSetTrustedDomainInformation+site%3Amicrosoft.com) | advapi32.dll | | +[LsaSetTrustedDomainInformation](http://msdn2.microsoft.com/en-us/library/a7b89ea7-af92-46ba-ac73-2fba1cc27680) | advapi32.dll | ntsecapi.h | Vanara.PInvoke.AdvApi32.LsaSetTrustedDomainInformation [LsaStorePrivateData](https://www.google.com/search?num=5&q=LsaStorePrivateData+site%3Amicrosoft.com) | advapi32.dll | | [LsaUnregisterPolicyChangeNotification](https://www.google.com/search?num=5&q=LsaUnregisterPolicyChangeNotification+site%3Amicrosoft.com) | secur32.dll | | [MakeAbsoluteSD](https://www.google.com/search?num=5&q=MakeAbsoluteSD+site%3Amicrosoft.com) | advapi32.dll | | [MakeAbsoluteSD2](https://www.google.com/search?num=5&q=MakeAbsoluteSD2+site%3Amicrosoft.com) | advapi32.dll | | [MakeSelfRelativeSD](https://www.google.com/search?num=5&q=MakeSelfRelativeSD+site%3Amicrosoft.com) | advapi32.dll | | [MakeSignature](https://www.google.com/search?num=5&q=MakeSignature+site%3Amicrosoft.com) | secur32.dll | | -[MapGenericMask](https://www.google.com/search?num=5&q=MapGenericMask+site%3Amicrosoft.com) | advapi32.dll | | +[MapGenericMask](http://msdn2.microsoft.com/en-us/library/aa379266) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.MapGenericMask [MD4Final](https://www.google.com/search?num=5&q=MD4Final+site%3Amicrosoft.com) | advapi32.dll | | [MD4Init](https://www.google.com/search?num=5&q=MD4Init+site%3Amicrosoft.com) | advapi32.dll | | [MD4Update](https://www.google.com/search?num=5&q=MD4Update+site%3Amicrosoft.com) | advapi32.dll | | @@ -454,10 +458,10 @@ Native Method | Native DLL | Header | Managed Method [OpenEncryptedFileRaw](https://www.google.com/search?num=5&q=OpenEncryptedFileRawA+site%3Amicrosoft.com) | advapi32.dll | | [OpenEventLog](https://www.google.com/search?num=5&q=OpenEventLogA+site%3Amicrosoft.com) | advapi32.dll | | [OpenLsaPerformanceData](https://www.google.com/search?num=5&q=OpenLsaPerformanceData+site%3Amicrosoft.com) | secur32.dll | | -[OpenProcessToken](https://www.google.com/search?num=5&q=OpenProcessToken+site%3Amicrosoft.com) | advapi32.dll | | -[OpenSCManager](https://www.google.com/search?num=5&q=OpenSCManagerA+site%3Amicrosoft.com) | advapi32.dll | | -[OpenService](https://www.google.com/search?num=5&q=OpenServiceA+site%3Amicrosoft.com) | advapi32.dll | | -[OpenThreadToken](https://www.google.com/search?num=5&q=OpenThreadToken+site%3Amicrosoft.com) | advapi32.dll | | +[OpenProcessToken](http://msdn2.microsoft.com/en-us/library/aa379295) | advapi32.dll | processthreadsapi.h | Vanara.PInvoke.AdvApi32.OpenProcessToken +[OpenSCManager](http://msdn2.microsoft.com/en-us/library/a0237989-e5a7-4a3a-ab23-e2474a995341) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.OpenSCManager +[OpenService](http://msdn2.microsoft.com/en-us/library/e0a42613-95ad-4d0f-a464-c6df33014064) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.OpenService +[OpenThreadToken](http://msdn2.microsoft.com/en-us/library/aa379296) | advapi32.dll | processthreadsapi.h | Vanara.PInvoke.AdvApi32.OpenThreadToken [OpenThreadWaitChainSession](https://www.google.com/search?num=5&q=OpenThreadWaitChainSession+site%3Amicrosoft.com) | advapi32.dll | | [OpenTrace](https://www.google.com/search?num=5&q=OpenTraceA+site%3Amicrosoft.com) | advapi32.dll | | [OperationEnd](https://www.google.com/search?num=5&q=OperationEnd+site%3Amicrosoft.com) | advapi32.dll | | @@ -491,7 +495,7 @@ Native Method | Native DLL | Header | Managed Method [PerfStartProvider](https://www.google.com/search?num=5&q=PerfStartProvider+site%3Amicrosoft.com) | advapi32.dll | | [PerfStartProviderEx](https://www.google.com/search?num=5&q=PerfStartProviderEx+site%3Amicrosoft.com) | advapi32.dll | | [PerfStopProvider](https://www.google.com/search?num=5&q=PerfStopProvider+site%3Amicrosoft.com) | advapi32.dll | | -[PrivilegeCheck](https://www.google.com/search?num=5&q=PrivilegeCheck+site%3Amicrosoft.com) | advapi32.dll | | +[PrivilegeCheck](http://msdn2.microsoft.com/en-us/library/aa379304) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.PrivilegeCheck [PrivilegedServiceAuditAlarm](https://www.google.com/search?num=5&q=PrivilegedServiceAuditAlarmA+site%3Amicrosoft.com) | advapi32.dll | | [ProcessIdleTasks](https://www.google.com/search?num=5&q=ProcessIdleTasks+site%3Amicrosoft.com) | advapi32.dll | | [ProcessTrace](https://www.google.com/search?num=5&q=ProcessTrace+site%3Amicrosoft.com) | advapi32.dll | | @@ -503,8 +507,8 @@ Native Method | Native DLL | Header | Managed Method [QuerySecurityAccessMask](https://www.google.com/search?num=5&q=QuerySecurityAccessMask+site%3Amicrosoft.com) | advapi32.dll | | [QuerySecurityContextToken](https://www.google.com/search?num=5&q=QuerySecurityContextToken+site%3Amicrosoft.com) | secur32.dll | | [QuerySecurityPackageInfo](https://www.google.com/search?num=5&q=QuerySecurityPackageInfoA+site%3Amicrosoft.com) | secur32.dll | | -[QueryServiceConfig](https://www.google.com/search?num=5&q=QueryServiceConfigA+site%3Amicrosoft.com) | advapi32.dll | | -[QueryServiceConfig2](https://www.google.com/search?num=5&q=QueryServiceConfig2A+site%3Amicrosoft.com) | advapi32.dll | | +[QueryServiceConfig](http://msdn2.microsoft.com/en-us/library/ms684932) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.QueryServiceConfig +[QueryServiceConfig2](http://msdn2.microsoft.com/en-us/library/cb090e59-aeff-4420-bb7c-912a4911006f) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.QueryServiceConfig2 [QueryServiceDynamicInformation](https://www.google.com/search?num=5&q=QueryServiceDynamicInformation+site%3Amicrosoft.com) | advapi32.dll | | [QueryServiceLockStatus](https://www.google.com/search?num=5&q=QueryServiceLockStatusA+site%3Amicrosoft.com) | advapi32.dll | | [QueryServiceObjectSecurity](https://www.google.com/search?num=5&q=QueryServiceObjectSecurity+site%3Amicrosoft.com) | advapi32.dll | | @@ -518,64 +522,64 @@ Native Method | Native DLL | Header | Managed Method [ReadEncryptedFileRaw](https://www.google.com/search?num=5&q=ReadEncryptedFileRaw+site%3Amicrosoft.com) | advapi32.dll | | [ReadEventLog](https://www.google.com/search?num=5&q=ReadEventLogA+site%3Amicrosoft.com) | advapi32.dll | | [RefreshClaimDictionary](https://www.google.com/search?num=5&q=RefreshClaimDictionary+site%3Amicrosoft.com) | authz.dll | | -[RegCloseKey](https://www.google.com/search?num=5&q=RegCloseKey+site%3Amicrosoft.com) | advapi32.dll | | -[RegConnectRegistry](https://www.google.com/search?num=5&q=RegConnectRegistryA+site%3Amicrosoft.com) | advapi32.dll | | -[RegCopyTree](https://www.google.com/search?num=5&q=RegCopyTreeA+site%3Amicrosoft.com) | advapi32.dll | | -[RegCreateKey](https://www.google.com/search?num=5&q=RegCreateKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegCreateKeyEx](https://www.google.com/search?num=5&q=RegCreateKeyExA+site%3Amicrosoft.com) | advapi32.dll | | -[RegCreateKeyTransacted](https://www.google.com/search?num=5&q=RegCreateKeyTransactedA+site%3Amicrosoft.com) | advapi32.dll | | -[RegDeleteKey](https://www.google.com/search?num=5&q=RegDeleteKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegDeleteKeyEx](https://www.google.com/search?num=5&q=RegDeleteKeyExA+site%3Amicrosoft.com) | advapi32.dll | | -[RegDeleteKeyTransacted](https://www.google.com/search?num=5&q=RegDeleteKeyTransactedA+site%3Amicrosoft.com) | advapi32.dll | | -[RegDeleteKeyValue](https://www.google.com/search?num=5&q=RegDeleteKeyValueA+site%3Amicrosoft.com) | advapi32.dll | | -[RegDeleteTree](https://www.google.com/search?num=5&q=RegDeleteTreeA+site%3Amicrosoft.com) | advapi32.dll | | -[RegDeleteValue](https://www.google.com/search?num=5&q=RegDeleteValueA+site%3Amicrosoft.com) | advapi32.dll | | -[RegDisablePredefinedCache](https://www.google.com/search?num=5&q=RegDisablePredefinedCache+site%3Amicrosoft.com) | advapi32.dll | | -[RegDisablePredefinedCacheEx](https://www.google.com/search?num=5&q=RegDisablePredefinedCacheEx+site%3Amicrosoft.com) | advapi32.dll | | -[RegDisableReflectionKey](https://www.google.com/search?num=5&q=RegDisableReflectionKey+site%3Amicrosoft.com) | advapi32.dll | | -[RegEnableReflectionKey](https://www.google.com/search?num=5&q=RegEnableReflectionKey+site%3Amicrosoft.com) | advapi32.dll | | -[RegEnumKey](https://www.google.com/search?num=5&q=RegEnumKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegEnumKeyEx](https://www.google.com/search?num=5&q=RegEnumKeyExA+site%3Amicrosoft.com) | advapi32.dll | | -[RegEnumValue](https://www.google.com/search?num=5&q=RegEnumValueA+site%3Amicrosoft.com) | advapi32.dll | | -[RegFlushKey](https://www.google.com/search?num=5&q=RegFlushKey+site%3Amicrosoft.com) | advapi32.dll | | -[RegGetKeySecurity](https://www.google.com/search?num=5&q=RegGetKeySecurity+site%3Amicrosoft.com) | advapi32.dll | | -[RegGetValue](https://www.google.com/search?num=5&q=RegGetValueA+site%3Amicrosoft.com) | advapi32.dll | | -[RegisterEventSource](https://www.google.com/search?num=5&q=RegisterEventSourceA+site%3Amicrosoft.com) | advapi32.dll | | -[RegisterServiceCtrlHandler](https://www.google.com/search?num=5&q=RegisterServiceCtrlHandlerA+site%3Amicrosoft.com) | advapi32.dll | | -[RegisterServiceCtrlHandlerEx](https://www.google.com/search?num=5&q=RegisterServiceCtrlHandlerExA+site%3Amicrosoft.com) | advapi32.dll | | +[RegCloseKey](http://msdn2.microsoft.com/en-us/library/ms724837) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegCloseKey +[RegConnectRegistry](http://msdn2.microsoft.com/en-us/library/d7fb41cc-4855-4ad7-879c-b1ac85ac5803) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegConnectRegistry +[RegCopyTree](http://msdn2.microsoft.com/en-us/library/d16f2b47-e537-42b0-90b3-9f9a00e61e76) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegCopyTree +[RegCreateKey](http://msdn2.microsoft.com/en-us/library/cb4d30f4-e288-41e8-86e0-807c313db53d) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegCreateKey +[RegCreateKeyEx](http://msdn2.microsoft.com/en-us/library/e9ffad7f-c0b6-44ce-bf22-fbe45ca98bf4) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegCreateKeyEx +[RegCreateKeyTransacted](http://msdn2.microsoft.com/en-us/library/f18e5ff9-41c3-4c26-8d01-a8ec69bcdef2) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegCreateKeyTransacted +[RegDeleteKey](http://msdn2.microsoft.com/en-us/library/a2310ca0-1b9f-48d1-a3b5-ea3a528bfaba) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegDeleteKey +[RegDeleteKeyEx](http://msdn2.microsoft.com/en-us/library/41fde6a5-647c-4293-92b8-74be54fa4136) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegDeleteKeyEx +[RegDeleteKeyTransacted](http://msdn2.microsoft.com/en-us/library/4c67e08b-4338-4441-8300-6b6ed31d4b21) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegDeleteKeyTransacted +[RegDeleteKeyValue](http://msdn2.microsoft.com/en-us/library/a4a082c2-8cf3-41eb-87c0-a6c453821f8b) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegDeleteKeyValue +[RegDeleteTree](http://msdn2.microsoft.com/en-us/library/984813a9-e191-498f-8288-b8a4c567112b) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegDeleteTree +[RegDeleteValue](http://msdn2.microsoft.com/en-us/library/4393b4ef-cd10-40d4-bb12-2d84e7cb7d3c) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegDeleteValue +[RegDisablePredefinedCache](http://msdn2.microsoft.com/en-us/library/837584b3-5f61-4535-9e66-56f50ab3fa46) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegDisablePredefinedCache +[RegDisablePredefinedCacheEx](http://msdn2.microsoft.com/en-us/library/a56cf7d9-0ac4-4719-af41-3c0cdcef6faf) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegDisablePredefinedCacheEx +[RegDisableReflectionKey](http://msdn2.microsoft.com/en-us/library/294a1d28-d09f-44a3-8bc0-6fae50c3a8f8) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegDisableReflectionKey +[RegEnableReflectionKey](http://msdn2.microsoft.com/en-us/library/6dfbc3d8-cd71-4ee9-a10b-955c26a6894c) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegEnableReflectionKey +[RegEnumKey](http://msdn2.microsoft.com/en-us/library/18a05c60-6c6d-438f-9003-f07d688d86a3) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegEnumKey +[RegEnumKeyEx](http://msdn2.microsoft.com/en-us/library/647d34cc-01ba-4389-be29-b099ed198e7c) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegEnumKeyEx +[RegEnumValue](http://msdn2.microsoft.com/en-us/library/7014ff96-c655-486f-af32-180b87281b06) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegEnumValue +[RegFlushKey](http://msdn2.microsoft.com/en-us/library/ae1160be-1da7-4621-a0fc-727aa229ec06) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegFlushKey +[RegGetKeySecurity](http://msdn2.microsoft.com/en-us/library/26bd8f89-9241-4c13-a214-c2b276d68c92) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegGetKeySecurity +[RegGetValue](http://msdn2.microsoft.com/en-us/library/1c06facb-6735-4b3f-b77d-f162e3faaada) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegGetValue +[RegisterEventSource](http://msdn2.microsoft.com/en-us/library/53706f83-6bc9-45d6-981c-bd0680d7bc08) | advapi32.dll | winbase.h | Vanara.PInvoke.AdvApi32.RegisterEventSource +[RegisterServiceCtrlHandler](http://msdn2.microsoft.com/en-us/library/31ec28fe-8774-48fc-91ba-6fa43108e2cc) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.RegisterServiceCtrlHandler +[RegisterServiceCtrlHandlerEx](http://msdn2.microsoft.com/en-us/library/23eea346-9899-4214-88f4-9b7eb7ce1332) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.RegisterServiceCtrlHandlerEx [RegisterTraceGuids](https://www.google.com/search?num=5&q=RegisterTraceGuidsA+site%3Amicrosoft.com) | advapi32.dll | | [RegisterWaitChainCOMCallback](https://www.google.com/search?num=5&q=RegisterWaitChainCOMCallback+site%3Amicrosoft.com) | advapi32.dll | | -[RegLoadAppKey](https://www.google.com/search?num=5&q=RegLoadAppKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegLoadKey](https://www.google.com/search?num=5&q=RegLoadKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegLoadMUIString](https://www.google.com/search?num=5&q=RegLoadMUIStringA+site%3Amicrosoft.com) | advapi32.dll | | -[RegNotifyChangeKeyValue](https://www.google.com/search?num=5&q=RegNotifyChangeKeyValue+site%3Amicrosoft.com) | advapi32.dll | | -[RegOpenCurrentUser](https://www.google.com/search?num=5&q=RegOpenCurrentUser+site%3Amicrosoft.com) | advapi32.dll | | -[RegOpenKey](https://www.google.com/search?num=5&q=RegOpenKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegOpenKeyEx](https://www.google.com/search?num=5&q=RegOpenKeyExA+site%3Amicrosoft.com) | advapi32.dll | | -[RegOpenKeyTransacted](https://www.google.com/search?num=5&q=RegOpenKeyTransactedA+site%3Amicrosoft.com) | advapi32.dll | | -[RegOpenUserClassesRoot](https://www.google.com/search?num=5&q=RegOpenUserClassesRoot+site%3Amicrosoft.com) | advapi32.dll | | -[RegOverridePredefKey](https://www.google.com/search?num=5&q=RegOverridePredefKey+site%3Amicrosoft.com) | advapi32.dll | | -[RegQueryInfoKey](https://www.google.com/search?num=5&q=RegQueryInfoKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegQueryMultipleValues](https://www.google.com/search?num=5&q=RegQueryMultipleValuesA+site%3Amicrosoft.com) | advapi32.dll | | -[RegQueryReflectionKey](https://www.google.com/search?num=5&q=RegQueryReflectionKey+site%3Amicrosoft.com) | advapi32.dll | | -[RegQueryValue](https://www.google.com/search?num=5&q=RegQueryValueA+site%3Amicrosoft.com) | advapi32.dll | | -[RegQueryValueEx](https://www.google.com/search?num=5&q=RegQueryValueExA+site%3Amicrosoft.com) | advapi32.dll | | -[RegReplaceKey](https://www.google.com/search?num=5&q=RegReplaceKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegRestoreKey](https://www.google.com/search?num=5&q=RegRestoreKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegSaveKey](https://www.google.com/search?num=5&q=RegSaveKeyA+site%3Amicrosoft.com) | advapi32.dll | | -[RegSaveKeyEx](https://www.google.com/search?num=5&q=RegSaveKeyExA+site%3Amicrosoft.com) | advapi32.dll | | -[RegSetKeySecurity](https://www.google.com/search?num=5&q=RegSetKeySecurity+site%3Amicrosoft.com) | advapi32.dll | | -[RegSetKeyValue](https://www.google.com/search?num=5&q=RegSetKeyValueA+site%3Amicrosoft.com) | advapi32.dll | | -[RegSetValue](https://www.google.com/search?num=5&q=RegSetValueA+site%3Amicrosoft.com) | advapi32.dll | | -[RegSetValueEx](https://www.google.com/search?num=5&q=RegSetValueExA+site%3Amicrosoft.com) | advapi32.dll | | -[RegUnLoadKey](https://www.google.com/search?num=5&q=RegUnLoadKeyA+site%3Amicrosoft.com) | advapi32.dll | | +[RegLoadAppKey](http://msdn2.microsoft.com/en-us/library/88eb79c1-9ea0-436e-ad2e-9ce05b8dcb2c) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegLoadAppKey +[RegLoadKey](http://msdn2.microsoft.com/en-us/library/536395aa-03ba-430d-a66d-fcabdc9dfe22) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegLoadKey +[RegLoadMUIString](http://msdn2.microsoft.com/en-us/library/76ffc77f-a1bc-4e01-858f-4a76563a2bbc) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegLoadMUIString +[RegNotifyChangeKeyValue](http://msdn2.microsoft.com/en-us/library/ms724892) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegNotifyChangeKeyValue +[RegOpenCurrentUser](http://msdn2.microsoft.com/en-us/library/10a8cbfb-52dc-436a-827e-78f12eb62af0) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegOpenCurrentUser +[RegOpenKey](http://msdn2.microsoft.com/en-us/library/bad0a0f8-1889-4eff-98be-084c95d69f3b) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegOpenKey +[RegOpenKeyEx](http://msdn2.microsoft.com/en-us/library/ms724897) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegOpenKeyEx +[RegOpenKeyTransacted](http://msdn2.microsoft.com/en-us/library/11663ed2-d17c-4f08-be7b-9b591271fbcd) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegOpenKeyTransacted +[RegOpenUserClassesRoot](http://msdn2.microsoft.com/en-us/library/bd068826-cf88-4fc7-a7d6-96cc03e923c7) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegOpenUserClassesRoot +[RegOverridePredefKey](http://msdn2.microsoft.com/en-us/library/ad58b7ff-cd61-4719-9028-b470ae7e9bb0) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegOverridePredefKey +[RegQueryInfoKey](http://msdn2.microsoft.com/en-us/library/25eb2cd2-9fdd-4d6f-8071-daab56f9aae1) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegQueryInfoKey +[RegQueryMultipleValues](http://msdn2.microsoft.com/en-us/library/e718534a-6e68-40f5-9cdd-170ce9b5e6e5) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegQueryMultipleValues +[RegQueryReflectionKey](http://msdn2.microsoft.com/en-us/library/d7516eab-dbcf-4ece-931e-d7bb2a983503) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegQueryReflectionKey +[RegQueryValue](http://msdn2.microsoft.com/en-us/library/18f27717-3bd9-45ac-a1ea-61abc1753a52) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegQueryValue +[RegQueryValueEx](http://msdn2.microsoft.com/en-us/library/202d253a-10ff-40e7-8eec-a49717443b81) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegQueryValueEx +[RegReplaceKey](http://msdn2.microsoft.com/en-us/library/f968fa71-edc8-4f49-b9fa-1e89224df33b) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegReplaceKey +[RegRestoreKey](http://msdn2.microsoft.com/en-us/library/6267383d-427a-4ae8-b9cc-9c1861d3b7bb) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegRestoreKey +[RegSaveKey](http://msdn2.microsoft.com/en-us/library/da80f40d-0099-4748-94ca-5d3b001e633e) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegSaveKey +[RegSaveKeyEx](http://msdn2.microsoft.com/en-us/library/f93b4162-cac4-42f7-bfd4-9e23fff80a03) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegSaveKeyEx +[RegSetKeySecurity](http://msdn2.microsoft.com/en-us/library/08bf8fc1-6a08-490e-b589-730211774257) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegSetKeySecurity +[RegSetKeyValue](http://msdn2.microsoft.com/en-us/library/e27d2dd6-b139-4ac1-8dd8-527022333364) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegSetKeyValue +[RegSetValue](http://msdn2.microsoft.com/en-us/library/f99774d4-575b-43a3-8887-e15acb0477fd) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegSetValue +[RegSetValueEx](http://msdn2.microsoft.com/en-us/library/29b0e27c-4999-4e92-bd8b-bba74920bccc) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegSetValueEx +[RegUnLoadKey](http://msdn2.microsoft.com/en-us/library/73b4b6a9-4acb-4247-bd7f-82024ba3e14a) | advapi32.dll | winreg.h | Vanara.PInvoke.AdvApi32.RegUnLoadKey [RemoteRegQueryMultipleValues2Wrapper](https://www.google.com/search?num=5&q=RemoteRegQueryMultipleValues2Wrapper+site%3Amicrosoft.com) | advapi32.dll | | [RemoteRegQueryMultipleValuesWrapper](https://www.google.com/search?num=5&q=RemoteRegQueryMultipleValuesWrapper+site%3Amicrosoft.com) | advapi32.dll | | [RemoveTraceCallback](https://www.google.com/search?num=5&q=RemoveTraceCallback+site%3Amicrosoft.com) | advapi32.dll | | [RemoveUsersFromEncryptedFile](https://www.google.com/search?num=5&q=RemoveUsersFromEncryptedFile+site%3Amicrosoft.com) | advapi32.dll | | [ReportEvent](https://www.google.com/search?num=5&q=ReportEventA+site%3Amicrosoft.com) | advapi32.dll | | [RevertSecurityContext](https://www.google.com/search?num=5&q=RevertSecurityContext+site%3Amicrosoft.com) | secur32.dll | | -[RevertToSelf](https://www.google.com/search?num=5&q=RevertToSelf+site%3Amicrosoft.com) | advapi32.dll | | +[RevertToSelf](http://msdn2.microsoft.com/en-us/library/aa379317) | advapi32.dll | securitybaseapi.h | Vanara.PInvoke.AdvApi32.RevertToSelf [SafeBaseRegGetKeySecurity](https://www.google.com/search?num=5&q=SafeBaseRegGetKeySecurity+site%3Amicrosoft.com) | advapi32.dll | | [SaferCloseLevel](https://www.google.com/search?num=5&q=SaferCloseLevel+site%3Amicrosoft.com) | advapi32.dll | | [SaferComputeTokenFromLevel](https://www.google.com/search?num=5&q=SaferComputeTokenFromLevel+site%3Amicrosoft.com) | advapi32.dll | | @@ -612,13 +616,13 @@ Native Method | Native DLL | Header | Managed Method [SetCredentialsAttributes](https://www.google.com/search?num=5&q=SetCredentialsAttributesA+site%3Amicrosoft.com) | secur32.dll | | [SetEncryptedFileMetadata](https://www.google.com/search?num=5&q=SetEncryptedFileMetadata+site%3Amicrosoft.com) | advapi32.dll | | [SetEntriesInAccessList](https://www.google.com/search?num=5&q=SetEntriesInAccessListA+site%3Amicrosoft.com) | advapi32.dll | | -[SetEntriesInAcl](https://www.google.com/search?num=5&q=SetEntriesInAclA+site%3Amicrosoft.com) | advapi32.dll | | +[SetEntriesInAcl](http://msdn2.microsoft.com/en-us/library/05960fc1-1ad2-4c19-a65c-62259af5e18c) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.SetEntriesInAcl [SetEntriesInAuditList](https://www.google.com/search?num=5&q=SetEntriesInAuditListA+site%3Amicrosoft.com) | advapi32.dll | | [SetFileSecurity](https://www.google.com/search?num=5&q=SetFileSecurityA+site%3Amicrosoft.com) | advapi32.dll | | [SetInformationCodeAuthzLevelW](https://www.google.com/search?num=5&q=SetInformationCodeAuthzLevelW+site%3Amicrosoft.com) | advapi32.dll | | [SetInformationCodeAuthzPolicyW](https://www.google.com/search?num=5&q=SetInformationCodeAuthzPolicyW+site%3Amicrosoft.com) | advapi32.dll | | [SetKernelObjectSecurity](https://www.google.com/search?num=5&q=SetKernelObjectSecurity+site%3Amicrosoft.com) | advapi32.dll | | -[SetNamedSecurityInfo](https://www.google.com/search?num=5&q=SetNamedSecurityInfoA+site%3Amicrosoft.com) | advapi32.dll | | +[SetNamedSecurityInfo](http://msdn2.microsoft.com/en-us/library/aa379579) | advapi32.dll | Aclapi.h | Vanara.PInvoke.AdvApi32.SetNamedSecurityInfo [SetNamedSecurityInfoEx](https://www.google.com/search?num=5&q=SetNamedSecurityInfoExA+site%3Amicrosoft.com) | advapi32.dll | | [SetPrivateObjectSecurity](https://www.google.com/search?num=5&q=SetPrivateObjectSecurity+site%3Amicrosoft.com) | advapi32.dll | | [SetPrivateObjectSecurityEx](https://www.google.com/search?num=5&q=SetPrivateObjectSecurityEx+site%3Amicrosoft.com) | advapi32.dll | | @@ -629,12 +633,12 @@ Native Method | Native DLL | Header | Managed Method [SetSecurityDescriptorOwner](https://www.google.com/search?num=5&q=SetSecurityDescriptorOwner+site%3Amicrosoft.com) | advapi32.dll | | [SetSecurityDescriptorRMControl](https://www.google.com/search?num=5&q=SetSecurityDescriptorRMControl+site%3Amicrosoft.com) | advapi32.dll | | [SetSecurityDescriptorSacl](https://www.google.com/search?num=5&q=SetSecurityDescriptorSacl+site%3Amicrosoft.com) | advapi32.dll | | -[SetSecurityInfo](https://www.google.com/search?num=5&q=SetSecurityInfo+site%3Amicrosoft.com) | advapi32.dll | | +[SetSecurityInfo](http://msdn2.microsoft.com/en-us/library/f1781ba9-81eb-46f9-b530-c390b67d65de) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.SetSecurityInfo [SetSecurityInfoEx](https://www.google.com/search?num=5&q=SetSecurityInfoExA+site%3Amicrosoft.com) | advapi32.dll | | [SetServiceBits](https://www.google.com/search?num=5&q=SetServiceBits+site%3Amicrosoft.com) | advapi32.dll | | [SetServiceObjectSecurity](https://www.google.com/search?num=5&q=SetServiceObjectSecurity+site%3Amicrosoft.com) | advapi32.dll | | -[SetServiceStatus](https://www.google.com/search?num=5&q=SetServiceStatus+site%3Amicrosoft.com) | advapi32.dll | | -[SetThreadToken](https://www.google.com/search?num=5&q=SetThreadToken+site%3Amicrosoft.com) | advapi32.dll | | +[SetServiceStatus](http://msdn2.microsoft.com/en-us/library/bb5943ff-2814-40f2-bee0-ae7132befde9) | advapi32.dll | winsvc.h | Vanara.PInvoke.AdvApi32.SetServiceStatus +[SetThreadToken](http://msdn2.microsoft.com/en-us/library/aa379590) | advapi32.dll | processthreadsapi.h | Vanara.PInvoke.AdvApi32.SetThreadToken [SetTokenInformation](https://www.google.com/search?num=5&q=SetTokenInformation+site%3Amicrosoft.com) | advapi32.dll | | [SetTraceCallback](https://www.google.com/search?num=5&q=SetTraceCallback+site%3Amicrosoft.com) | advapi32.dll | | [SetUserFileEncryptionKey](https://www.google.com/search?num=5&q=SetUserFileEncryptionKey+site%3Amicrosoft.com) | advapi32.dll | | @@ -669,8 +673,8 @@ Native Method | Native DLL | Header | Managed Method [TraceQueryInformation](https://www.google.com/search?num=5&q=TraceQueryInformation+site%3Amicrosoft.com) | advapi32.dll | | [TraceSetInformation](https://www.google.com/search?num=5&q=TraceSetInformation+site%3Amicrosoft.com) | advapi32.dll | | [TranslateName](https://www.google.com/search?num=5&q=TranslateNameA+site%3Amicrosoft.com) | secur32.dll | | -[TreeResetNamedSecurityInfo](https://www.google.com/search?num=5&q=TreeResetNamedSecurityInfoA+site%3Amicrosoft.com) | advapi32.dll | | -[TreeSetNamedSecurityInfo](https://www.google.com/search?num=5&q=TreeSetNamedSecurityInfoA+site%3Amicrosoft.com) | advapi32.dll | | +[TreeResetNamedSecurityInfo](http://msdn2.microsoft.com/en-us/library/adae7d07-a452-409e-b1a1-e9f86f873e39) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.TreeResetNamedSecurityInfo +[TreeSetNamedSecurityInfo](http://msdn2.microsoft.com/en-us/library/caa711c3-301b-4ed7-b1f4-dc6a48563905) | advapi32.dll | aclapi.h | Vanara.PInvoke.AdvApi32.TreeSetNamedSecurityInfo [TrusteeAccessToObject](https://www.google.com/search?num=5&q=TrusteeAccessToObjectA+site%3Amicrosoft.com) | advapi32.dll | | [UninstallApplication](https://www.google.com/search?num=5&q=UninstallApplication+site%3Amicrosoft.com) | advapi32.dll | | [UnlockServiceDatabase](https://www.google.com/search?num=5&q=UnlockServiceDatabase+site%3Amicrosoft.com) | advapi32.dll | | @@ -702,41 +706,64 @@ Native Method | Native DLL | Header | Managed Method ### Structures Native Structure | Header | Managed Structure --- | --- | --- +[ACCESS_ALLOWED_ACE](http://msdn2.microsoft.com/en-us/library/aa374847) | Winnt.h | Vanara.PInvoke.AdvApi32+ACCESS_ALLOWED_ACE [ACE_HEADER](http://msdn2.microsoft.com/en-us/library/aa374919) | Winnt.h | Vanara.PInvoke.AdvApi32+ACE_HEADER [ACL](http://msdn2.microsoft.com/en-us/library/aa374931) | Winnt.h | Vanara.PInvoke.AdvApi32+ACL [ACL_REVISION_INFORMATION](http://msdn2.microsoft.com/en-us/library/aa374942) | Winnt.h | Vanara.PInvoke.AdvApi32+ACL_REVISION_INFORMATION [ACL_SIZE_INFORMATION](http://msdn2.microsoft.com/en-us/library/aa374945) | Winnt.h | Vanara.PInvoke.AdvApi32+ACL_SIZE_INFORMATION +[ACTRL_ACCESS_ENTRY](http://msdn2.microsoft.com/en-us/library/bcb2ad72-7b00-4582-b05e-e00720a4db77) | accctrl.h | Vanara.PInvoke.AdvApi32+ACTRL_ACCESS_ENTRY [ACTRL_ACCESS_ENTRY_LIST](http://msdn2.microsoft.com/en-us/library/d0e71756-0247-4c6b-b8b5-a343121b7406) | accctrl.h | Vanara.PInvoke.AdvApi32+ACTRL_ACCESS_ENTRY_LIST [ACTRL_ALIST](http://msdn2.microsoft.com/en-us/library/d7fb10c1-ebb8-44cf-b61c-a70a787b324f) | accctrl.h | Vanara.PInvoke.AdvApi32+ACTRL_ALIST [ACTRL_PROPERTY_ENTRY](http://msdn2.microsoft.com/en-us/library/90b13dd1-0ca6-4674-b9fa-a61aed4637d7) | accctrl.h | Vanara.PInvoke.AdvApi32+ACTRL_PROPERTY_ENTRY +[AUTHZ_ACCESS_CHECK_RESULTS_HANDLE](https://www.google.com/search?num=5&q=AUTHZ_ACCESS_CHECK_RESULTS_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.Authz+AUTHZ_ACCESS_CHECK_RESULTS_HANDLE [AUTHZ_ACCESS_REPLY](http://msdn2.microsoft.com/en-us/library/7162bf80-3730-46d7-a603-2a55b969c9ba) | authz.h | Vanara.PInvoke.Authz+AUTHZ_ACCESS_REPLY [AUTHZ_ACCESS_REQUEST](http://msdn2.microsoft.com/en-us/library/3748075c-b31a-4669-b8a6-1a540449d8fa) | authz.h | Vanara.PInvoke.Authz+AUTHZ_ACCESS_REQUEST +[AUTHZ_AUDIT_EVENT_HANDLE](https://www.google.com/search?num=5&q=AUTHZ_AUDIT_EVENT_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.Authz+AUTHZ_AUDIT_EVENT_HANDLE +[AUTHZ_CLIENT_CONTEXT_HANDLE](https://www.google.com/search?num=5&q=AUTHZ_CLIENT_CONTEXT_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.Authz+AUTHZ_CLIENT_CONTEXT_HANDLE +[AUTHZ_RESOURCE_MANAGER_HANDLE](https://www.google.com/search?num=5&q=AUTHZ_RESOURCE_MANAGER_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.Authz+AUTHZ_RESOURCE_MANAGER_HANDLE [AUTHZ_SECURITY_ATTRIBUTE_FQBN_VALUE](http://msdn2.microsoft.com/en-us/library/05b4bf7d-a0d9-473c-b215-9cf566b2a996) | authz.h | Vanara.PInvoke.Authz+AUTHZ_SECURITY_ATTRIBUTE_FQBN_VALUE [AUTHZ_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE](http://msdn2.microsoft.com/en-us/library/aebe20d5-280f-45d3-a11d-279a08a1a165) | authz.h | Vanara.PInvoke.Authz+AUTHZ_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE [AUTHZ_SECURITY_ATTRIBUTE_V1](http://msdn2.microsoft.com/en-us/library/0c4778bb-1b5d-4422-b066-d2a6aaa1f351) | authz.h | Vanara.PInvoke.Authz+AUTHZ_SECURITY_ATTRIBUTE_V1 [AUTHZ_SECURITY_ATTRIBUTE_V1_Union](https://www.google.com/search?num=5&q=AUTHZ_SECURITY_ATTRIBUTE_V1_Union+site%3Amicrosoft.com) | | Vanara.PInvoke.Authz+AUTHZ_SECURITY_ATTRIBUTE_V1+AUTHZ_SECURITY_ATTRIBUTE_V1_Union [BINARY_BLOB_CREDENTIAL_INFO](http://msdn2.microsoft.com/en-us/library/20a1d54b-04a7-4b0a-88e4-1970d1f71502) | wincred.h | Vanara.PInvoke.AdvApi32+BINARY_BLOB_CREDENTIAL_INFO +[CENTRAL_ACCESS_POLICY](http://msdn2.microsoft.com/en-us/library/C1C2E8AE-0B7F-4620-9C27-31DAF683E342) | ntlsa.h | Vanara.PInvoke.AdvApi32+CENTRAL_ACCESS_POLICY +[CENTRAL_ACCESS_POLICY_ENTRY](http://msdn2.microsoft.com/en-us/library/8667848D-096C-422E-B4A6-38CC406F0F4A) | ntlsa.h | Vanara.PInvoke.AdvApi32+CENTRAL_ACCESS_POLICY_ENTRY [CERT_CREDENTIAL_INFO](http://msdn2.microsoft.com/en-us/library/acaa94c3-0562-420a-95c7-44a71374d5ea) | wincred.h | Vanara.PInvoke.AdvApi32+CERT_CREDENTIAL_INFO [CLAIM_SECURITY_ATTRIBUTE_INFORMATION_V1](http://msdn2.microsoft.com/en-us/library/hh448481) | Winnt.h | Vanara.PInvoke.AdvApi32+CLAIM_SECURITY_ATTRIBUTE_INFORMATION_V1 +[CLAIM_SECURITY_ATTRIBUTES_INFORMATION](http://msdn2.microsoft.com/en-us/library/hh448481) | Winnt.h | Vanara.PInvoke.AdvApi32+CLAIM_SECURITY_ATTRIBUTES_INFORMATION [CREDENTIAL](https://www.google.com/search?num=5&q=CREDENTIAL+site%3Amicrosoft.com) | wincred.h | Vanara.PInvoke.AdvApi32+CREDENTIAL [CREDENTIAL_TARGET_INFORMATION](http://msdn2.microsoft.com/en-us/library/92180f2c-ef7c-4481-9b6f-19234c114afb) | wincred.h | Vanara.PInvoke.AdvApi32+CREDENTIAL_TARGET_INFORMATION +[EXPLICIT_ACCESS](http://msdn2.microsoft.com/en-us/library/6fe09542-10dd-439c-adf8-a4e06943ddb2) | accctrl.h | Vanara.PInvoke.AdvApi32+EXPLICIT_ACCESS [GENERIC_MAPPING](http://msdn2.microsoft.com/en-us/library/aa446633) | Winnt.h | Vanara.PInvoke.AdvApi32+GENERIC_MAPPING +[HEVENTLOG](https://www.google.com/search?num=5&q=HEVENTLOG+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+HEVENTLOG +[INHERITED_FROM](http://msdn2.microsoft.com/en-us/library/aa378845) | AccCtrl.h | Vanara.PInvoke.AdvApi32+INHERITED_FROM [LSA_AUTH_INFORMATION](http://msdn2.microsoft.com/en-us/library/61c17831-4a82-4766-b5af-e97a6d467462) | ntsecapi.h | Vanara.PInvoke.AdvApi32+LSA_AUTH_INFORMATION +[LSA_ENUMERATION_INFORMATION](http://msdn2.microsoft.com/en-us/library/7577548f-3ceb-43a5-b447-6f66a09963fe) | ntsecapi.h | Vanara.PInvoke.AdvApi32+LSA_ENUMERATION_INFORMATION [LSA_FOREST_TRUST_BINARY_DATA](http://msdn2.microsoft.com/en-us/library/2ddcf54e-c30f-4146-8cb6-71fcdd42ae68) | ntsecapi.h | Vanara.PInvoke.AdvApi32+LSA_FOREST_TRUST_BINARY_DATA +[LSA_FOREST_TRUST_DOMAIN_INFO](http://msdn2.microsoft.com/en-us/library/c0e06735-ca10-4bee-a45b-6db5b6666e31) | ntsecapi.h | Vanara.PInvoke.AdvApi32+LSA_FOREST_TRUST_DOMAIN_INFO [LSA_FOREST_TRUST_INFORMATION](http://msdn2.microsoft.com/en-us/library/9e456462-59a9-4f18-ba47-92fc2350889b) | ntsecapi.h | Vanara.PInvoke.AdvApi32+LSA_FOREST_TRUST_INFORMATION +[LSA_HANDLE](https://www.google.com/search?num=5&q=LSA_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+LSA_HANDLE +[LSA_OBJECT_ATTRIBUTES](http://msdn2.microsoft.com/en-us/library/ad05cb52-8e58-46a9-b3e8-0c9c2a24a997) | lsalookup.h | Vanara.PInvoke.AdvApi32+LSA_OBJECT_ATTRIBUTES [LSA_REFERENCED_DOMAIN_LIST](http://msdn2.microsoft.com/en-us/library/ms721834) | Ntsecapi.h | Vanara.PInvoke.AdvApi32+LSA_REFERENCED_DOMAIN_LIST [LSA_STRING](http://msdn2.microsoft.com/en-us/library/aa378522) | LsaLookup.h | Vanara.PInvoke.AdvApi32+LSA_STRING +[LSA_TRANSLATED_NAME](http://msdn2.microsoft.com/en-us/library/edea8317-5cdf-4d1e-9e6d-fcf17b91adb7) | lsalookup.h | Vanara.PInvoke.AdvApi32+LSA_TRANSLATED_NAME [LSA_TRANSLATED_SID2](http://msdn2.microsoft.com/en-us/library/792de958-8e24-46d8-b484-159435bc96e3) | lsalookup.h | Vanara.PInvoke.AdvApi32+LSA_TRANSLATED_SID2 +[LSA_TRUST_INFORMATION](http://msdn2.microsoft.com/en-us/library/2b5e6f79-b97a-4018-a45a-37c300c3dc0d) | lsalookup.h | Vanara.PInvoke.AdvApi32+LSA_TRUST_INFORMATION [LSA_UNICODE_STRING](http://msdn2.microsoft.com/en-us/library/ms721841) | Ntsecapi.h | Vanara.PInvoke.AdvApi32+LSA_UNICODE_STRING +[LsaConnectionHandle](https://www.google.com/search?num=5&q=LsaConnectionHandle+site%3Amicrosoft.com) | | Vanara.PInvoke.Secur32+LsaConnectionHandle [LUID](https://www.google.com/search?num=5&q=LUID+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+LUID +[LUID_AND_ATTRIBUTES](https://www.google.com/search?num=5&q=LUID_AND_ATTRIBUTES+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+LUID_AND_ATTRIBUTES [OBJECTS_AND_NAME](http://msdn2.microsoft.com/en-us/library/ad91a302-f693-44e9-9655-ec4488ff78c4) | accctrl.h | Vanara.PInvoke.AdvApi32+OBJECTS_AND_NAME [OBJECTS_AND_SID](http://msdn2.microsoft.com/en-us/library/77ba8a3c-01e5-4a3e-835f-c7b9ef60035a) | accctrl.h | Vanara.PInvoke.AdvApi32+OBJECTS_AND_SID [PRIVILEGE_SET](https://www.google.com/search?num=5&q=PRIVILEGE_SET+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+PRIVILEGE_SET +[PSEC_WINNT_AUTH_IDENTITY_OPAQUE](https://www.google.com/search?num=5&q=PSEC_WINNT_AUTH_IDENTITY_OPAQUE+site%3Amicrosoft.com) | | Vanara.PInvoke.Secur32+PSEC_WINNT_AUTH_IDENTITY_OPAQUE [PSID_IDENTIFIER_AUTHORITY](http://msdn2.microsoft.com/en-us/library/450a6d2d-d2e4-4098-90af-a8024ddcfcb5) | winnt.h | Vanara.PInvoke.AdvApi32+PSID_IDENTIFIER_AUTHORITY [PTOKEN_PRIVILEGES](https://www.google.com/search?num=5&q=PTOKEN_PRIVILEGES+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+PTOKEN_PRIVILEGES [QUERY_SERVICE_CONFIG](http://msdn2.microsoft.com/en-us/library/ms684950) | Winsvc.h | Vanara.PInvoke.AdvApi32+QUERY_SERVICE_CONFIG [QUOTA_LIMITS](http://msdn2.microsoft.com/en-us/library/aa379363) | Winnt.h | Vanara.PInvoke.AdvApi32+QUOTA_LIMITS [SC_ACTION](http://msdn2.microsoft.com/en-us/library/e2c355a6-affe-46bf-a3e6-f8c420422d46) | winsvc.h | Vanara.PInvoke.AdvApi32+SC_ACTION +[SC_HANDLE](https://www.google.com/search?num=5&q=SC_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+SC_HANDLE +[SECURITY_DESCRIPTOR](http://msdn2.microsoft.com/en-us/library/aa379561) | Winnt.h | Vanara.PInvoke.AdvApi32+SECURITY_DESCRIPTOR [SERVICE_DELAYED_AUTO_START_INFO](http://msdn2.microsoft.com/en-us/library/16117450-eb73-47de-8be7-c7aff3d44c81) | winsvc.h | Vanara.PInvoke.AdvApi32+SERVICE_DELAYED_AUTO_START_INFO [SERVICE_DESCRIPTION](http://msdn2.microsoft.com/en-us/library/ms685156) | Winsvc.h | Vanara.PInvoke.AdvApi32+SERVICE_DESCRIPTION [SERVICE_FAILURE_ACTIONS](http://msdn2.microsoft.com/en-us/library/180ca6d9-f2c3-4ea1-b2c6-319d08ef88ee) | winsvc.h | Vanara.PInvoke.AdvApi32+SERVICE_FAILURE_ACTIONS @@ -747,15 +774,32 @@ Native Structure | Header | Managed Structure [SERVICE_REQUIRED_PRIVILEGES_INFO](http://msdn2.microsoft.com/en-us/library/15a2e042-cfd5-443e-a3b8-822f48eb9654) | winsvc.h | Vanara.PInvoke.AdvApi32+SERVICE_REQUIRED_PRIVILEGES_INFO [SERVICE_SID_INFO](http://msdn2.microsoft.com/en-us/library/cb1a32bd-aafb-4e41-8d6f-673c3d747f14) | winsvc.h | Vanara.PInvoke.AdvApi32+SERVICE_SID_INFO [SERVICE_STATUS](http://msdn2.microsoft.com/en-us/library/d268609b-d442-4d0f-9d49-ed23fee84961) | winsvc.h | Vanara.PInvoke.AdvApi32+SERVICE_STATUS +[SERVICE_STATUS_HANDLE](https://www.google.com/search?num=5&q=SERVICE_STATUS_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+SERVICE_STATUS_HANDLE [SERVICE_TRIGGER](http://msdn2.microsoft.com/en-us/library/a57aa702-40a2-4880-80db-6c4f43c3e7ea) | winsvc.h | Vanara.PInvoke.AdvApi32+SERVICE_TRIGGER [SERVICE_TRIGGER_INFO](http://msdn2.microsoft.com/en-us/library/8de46056-1ea5-46f2-a260-ad140fd77bc1) | winsvc.h | Vanara.PInvoke.AdvApi32+SERVICE_TRIGGER_INFO [SERVICE_TRIGGER_SPECIFIC_DATA_ITEM](http://msdn2.microsoft.com/en-us/library/670e6c49-bbc0-4af6-9e47-6c89801ebb45) | winsvc.h | Vanara.PInvoke.AdvApi32+SERVICE_TRIGGER_SPECIFIC_DATA_ITEM +[SID_AND_ATTRIBUTES](https://www.google.com/search?num=5&q=SID_AND_ATTRIBUTES+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+SID_AND_ATTRIBUTES [SID_IDENTIFIER_AUTHORITY](http://msdn2.microsoft.com/en-us/library/aa379598) | Winnt.h | Vanara.PInvoke.AdvApi32+SID_IDENTIFIER_AUTHORITY +[TOKEN_ACCESS_INFORMATION](http://msdn2.microsoft.com/en-us/library/bb394726) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_ACCESS_INFORMATION +[TOKEN_APPCONTAINER_INFORMATION](https://www.google.com/search?num=5&q=TOKEN_APPCONTAINER_INFORMATION+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+TOKEN_APPCONTAINER_INFORMATION +[TOKEN_DEFAULT_DACL](http://msdn2.microsoft.com/en-us/library/aa379623) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_DEFAULT_DACL [TOKEN_ELEVATION](https://www.google.com/search?num=5&q=TOKEN_ELEVATION+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+TOKEN_ELEVATION [TOKEN_GROUPS](https://www.google.com/search?num=5&q=TOKEN_GROUPS+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+TOKEN_GROUPS +[TOKEN_GROUPS_AND_PRIVILEGES](http://msdn2.microsoft.com/en-us/library/aa379625) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_GROUPS_AND_PRIVILEGES [TOKEN_LINKED_TOKEN](http://msdn2.microsoft.com/en-us/library/bb530719) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_LINKED_TOKEN +[TOKEN_MANDATORY_LABEL](https://www.google.com/search?num=5&q=TOKEN_MANDATORY_LABEL+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+TOKEN_MANDATORY_LABEL [TOKEN_MANDATORY_POLICY](http://msdn2.microsoft.com/en-us/library/bb394728) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_MANDATORY_POLICY +[TOKEN_ORIGIN](http://msdn2.microsoft.com/en-us/library/aa379627) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_ORIGIN +[TOKEN_OWNER](http://msdn2.microsoft.com/en-us/library/aa379628) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_OWNER +[TOKEN_PRIMARY_GROUP](http://msdn2.microsoft.com/en-us/library/aa379629) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_PRIMARY_GROUP +[TOKEN_SOURCE](http://msdn2.microsoft.com/en-us/library/aa379631) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_SOURCE +[TOKEN_STATISTICS](http://msdn2.microsoft.com/en-us/library/aa379632) | WinNT.h | Vanara.PInvoke.AdvApi32+TOKEN_STATISTICS +[TOKEN_USER](https://www.google.com/search?num=5&q=TOKEN_USER+site%3Amicrosoft.com) | | Vanara.PInvoke.AdvApi32+TOKEN_USER [TRUSTED_DOMAIN_AUTH_INFORMATION](http://msdn2.microsoft.com/en-us/library/2ec606d7-42bd-47cc-a4cd-82908774aa43) | ntsecapi.h | Vanara.PInvoke.AdvApi32+TRUSTED_DOMAIN_AUTH_INFORMATION +[TRUSTED_DOMAIN_FULL_INFORMATION](http://msdn2.microsoft.com/en-us/library/b7abfe1e-d9e6-4583-a738-c16190ffd44d) | ntsecapi.h | Vanara.PInvoke.AdvApi32+TRUSTED_DOMAIN_FULL_INFORMATION +[TRUSTED_DOMAIN_INFORMATION_EX](http://msdn2.microsoft.com/en-us/library/acf9a2b5-f301-4e6a-a515-df338658ad56) | ntsecapi.h | Vanara.PInvoke.AdvApi32+TRUSTED_DOMAIN_INFORMATION_EX +[TRUSTED_DOMAIN_NAME_INFO](http://msdn2.microsoft.com/en-us/library/9bc1301b-1d09-4cd2-8590-e7756ee4792d) | ntsecapi.h | Vanara.PInvoke.AdvApi32+TRUSTED_DOMAIN_NAME_INFO +[TRUSTED_PASSWORD_INFO](http://msdn2.microsoft.com/en-us/library/2c3aca10-8efd-4278-8127-2d31db776c0e) | ntsecapi.h | Vanara.PInvoke.AdvApi32+TRUSTED_PASSWORD_INFO [TRUSTED_POSIX_OFFSET_INFO](http://msdn2.microsoft.com/en-us/library/0686da5e-43d4-49ac-8c5d-5c56b8d12e50) | ntsecapi.h | Vanara.PInvoke.AdvApi32+TRUSTED_POSIX_OFFSET_INFO [TRUSTEE](http://msdn2.microsoft.com/en-us/library/aa379636) | AccCtrl.h | Vanara.PInvoke.AdvApi32+TRUSTEE [USERNAME_TARGET_CREDENTIAL_INFO](http://msdn2.microsoft.com/en-us/library/1cb56a85-fafd-4471-b0e9-660ac0dc0219) | wincred.h | Vanara.PInvoke.AdvApi32+USERNAME_TARGET_CREDENTIAL_INFO diff --git a/PInvoke/Security/Vanara.PInvoke.Security.csproj b/PInvoke/Security/Vanara.PInvoke.Security.csproj index 486fa616..30a509c7 100644 --- a/PInvoke/Security/Vanara.PInvoke.Security.csproj +++ b/PInvoke/Security/Vanara.PInvoke.Security.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from AdvApi32.dll, Authz.dll and Secur32.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.Security $(AssemblyName) @@ -25,13 +25,15 @@ Currently implements: Functions -AuthzAccessCheck, AuthzFreeAuditEvent, AuthzFreeContext, AuthzFreeHandle, AuthzFreeResourceManager, AuthzGetInformationFromContext, AuthzInitializeCompoundContext, AuthzInitializeContextFromSid, AuthzInitializeContextFromToken, AuthzInitializeObjectAccessAuditEvent, AuthzInitializeResourceManager, AuthzModifyClaims, AuthzModifySecurityAttributes, AuthzModifySids, LsaConnectUntrusted, LsaDeregisterLogonProcess, LsaLookupAuthenticationPackage, LsaRegisterLogonProcess, SspiCompareAuthIdentities, SspiCopyAuthIdentity, SspiDecryptAuthIdentity, SspiEncodeAuthIdentityAsStringsA, SspiEncodeAuthIdentityAsStringsW, SspiEncodeStringsAsAuthIdentity, SspiEncryptAuthIdentity, SspiExcludePackage, SspiFreeAuthIdentity, SspiGetTargetHostName, SspiIsAuthIdentityEncrypted, SspiLocalFree, SspiMarshalAuthIdentity, SspiPrepareForCredRead, SspiPrepareForCredWrite, SspiUnmarshalAuthIdentity, SspiValidateAuthIdentity, SspiZeroAuthIdentity +AbortSystemShutdownA, AbortSystemShutdownW, AdjustTokenPrivileges, AllocateAndInitializeSid, AllocateLocallyUniqueId, AuthzAccessCheck, AuthzFreeAuditEvent, AuthzFreeContext, AuthzFreeHandle, AuthzFreeResourceManager, AuthzGetInformationFromContext, AuthzInitializeCompoundContext, AuthzInitializeContextFromSid, AuthzInitializeContextFromToken, AuthzInitializeObjectAccessAuditEvent, AuthzInitializeResourceManager, AuthzModifyClaims, AuthzModifySecurityAttributes, AuthzModifySids, BuildExplicitAccessWithNameA, BuildExplicitAccessWithNameW, BuildSecurityDescriptorA, BuildSecurityDescriptorW, BuildTrusteeWithNameA, BuildTrusteeWithNameW, BuildTrusteeWithObjectsAndNameA, BuildTrusteeWithObjectsAndNameW, BuildTrusteeWithObjectsAndSidA, BuildTrusteeWithObjectsAndSidW, BuildTrusteeWithSidA, BuildTrusteeWithSidW, ChangeServiceConfig2A, ChangeServiceConfig2W, ChangeServiceConfigA, ChangeServiceConfigW, CloseServiceHandle, ConvertSecurityDescriptorToStringSecurityDescriptorA, ConvertSecurityDescriptorToStringSecurityDescriptorW, ConvertSidToStringSidA, ConvertSidToStringSidW, ConvertStringSecurityDescriptorToSecurityDescriptorA, ConvertStringSecurityDescriptorToSecurityDescriptorW, ConvertStringSidToSidA, ConvertStringSidToSidW, CopySid, CreateServiceA, CreateServiceW, CredDeleteA, CredDeleteW, CredEnumerateA, CredEnumerateW, CredFindBestCredentialA, CredFindBestCredentialW, CredFree, CredGetSessionTypes, CredGetTargetInfoA, CredGetTargetInfoW, CredIsMarshaledCredentialA, CredIsMarshaledCredentialW, CredIsProtectedA, CredIsProtectedW, CredMarshalCredentialA, CredMarshalCredentialW, CredProtectA, CredProtectW, CredReadA, CredReadDomainCredentialsA, CredReadDomainCredentialsW, CredReadW, CredRenameA, CredRenameW, CredUnmarshalCredentialA, CredUnmarshalCredentialW, CredUnprotectA, CredUnprotectW, CredWriteA, CredWriteDomainCredentialsA, CredWriteDomainCredentialsW, CredWriteW, DeregisterEventSource, DuplicateToken, DuplicateTokenEx, EqualSid, FreeInheritedFromArray, FreeSid, GetAce, GetAclInformation, GetAuditedPermissionsFromAclA, GetAuditedPermissionsFromAclW, GetEffectiveRightsFromAclA, GetEffectiveRightsFromAclW, GetExplicitEntriesFromAclA, GetExplicitEntriesFromAclW, GetInheritanceSourceA, GetInheritanceSourceW, GetLengthSid, GetNamedSecurityInfoA, GetNamedSecurityInfoW, GetPrivateObjectSecurity, GetSecurityDescriptorControl, GetSecurityDescriptorDacl, GetSecurityDescriptorGroup, GetSecurityDescriptorLength, GetSecurityDescriptorOwner, GetSecurityDescriptorSacl, GetSecurityInfo, GetSidIdentifierAuthority, GetSidLengthRequired, GetSidSubAuthority, GetTokenInformation, GetTrusteeFormA, GetTrusteeFormW, GetTrusteeNameA, GetTrusteeNameW, GetTrusteeTypeA, GetTrusteeTypeW, ImpersonateLoggedOnUser, ImpersonateNamedPipeClient, InitiateShutdownA, InitiateShutdownW, InitiateSystemShutdownA, InitiateSystemShutdownExA, InitiateSystemShutdownExW, InitiateSystemShutdownW, IsValidSid, LogonUserA, LogonUserExA, LogonUserExW, LogonUserW, LookupAccountNameA, LookupAccountNameW, LookupAccountSidA, LookupAccountSidW, LookupPrivilegeDisplayNameA, LookupPrivilegeDisplayNameW, LookupPrivilegeNameA, LookupPrivilegeNameW, LookupPrivilegeValueA, LookupPrivilegeValueW, LookupSecurityDescriptorPartsA, LookupSecurityDescriptorPartsW, LsaAddAccountRights, LsaClose, LsaConnectUntrusted, LsaCreateAccount, LsaDeregisterLogonProcess, LsaEnumerateAccountRights, LsaEnumerateAccountsWithUserRight, LsaFreeMemory, LsaFreeReturnBuffer, LsaGetAppliedCAPIDs, LsaGetSystemAccessAccount, LsaLookupAuthenticationPackage, LsaLookupNames2, LsaLookupPrivilegeValue, LsaLookupSids2, LsaNtStatusToWinError, LsaOpenAccount, LsaOpenPolicy, LsaQueryCAPs, LsaQueryTrustedDomainInfo, LsaRegisterLogonProcess, LsaRemoveAccountRights, LsaSetSystemAccessAccount, LsaSetTrustedDomainInformation, MapGenericMask, OpenProcessToken, OpenSCManagerA, OpenSCManagerW, OpenServiceA, OpenServiceW, OpenThreadToken, PrivilegeCheck, QueryServiceConfig2A, QueryServiceConfig2W, QueryServiceConfigA, QueryServiceConfigW, RegCloseKey, RegConnectRegistryA, RegConnectRegistryW, RegCopyTreeA, RegCopyTreeW, RegCreateKeyA, RegCreateKeyExA, RegCreateKeyExW, RegCreateKeyTransactedA, RegCreateKeyTransactedW, RegCreateKeyW, RegDeleteKeyA, RegDeleteKeyExA, RegDeleteKeyExW, RegDeleteKeyTransactedA, RegDeleteKeyTransactedW, RegDeleteKeyValueA, RegDeleteKeyValueW, RegDeleteKeyW, RegDeleteTreeA, RegDeleteTreeW, RegDeleteValueA, RegDeleteValueW, RegDisablePredefinedCache, RegDisablePredefinedCacheEx, RegDisableReflectionKey, RegEnableReflectionKey, RegEnumKeyA, RegEnumKeyExA, RegEnumKeyExW, RegEnumKeyW, RegEnumValueA, RegEnumValueW, RegFlushKey, RegGetKeySecurity, RegGetValueA, RegGetValueW, RegisterEventSourceA, RegisterEventSourceW, RegisterServiceCtrlHandlerA, RegisterServiceCtrlHandlerExA, RegisterServiceCtrlHandlerExW, RegisterServiceCtrlHandlerW, RegLoadAppKeyA, RegLoadAppKeyW, RegLoadKeyA, RegLoadKeyW, RegLoadMUIStringA, RegLoadMUIStringW, RegNotifyChangeKeyValue, RegOpenCurrentUser, RegOpenKeyA, RegOpenKeyExA, RegOpenKeyExW, RegOpenKeyTransactedA, RegOpenKeyTransactedW, RegOpenKeyW, RegOpenUserClassesRoot, RegOverridePredefKey, RegQueryInfoKeyA, RegQueryInfoKeyW, RegQueryMultipleValuesA, RegQueryMultipleValuesW, RegQueryReflectionKey, RegQueryValueA, RegQueryValueExA, RegQueryValueExW, RegQueryValueW, RegReplaceKeyA, RegReplaceKeyW, RegRestoreKeyA, RegRestoreKeyW, RegSaveKeyA, RegSaveKeyExA, RegSaveKeyExW, RegSaveKeyW, RegSetKeySecurity, RegSetKeyValueA, RegSetKeyValueW, RegSetValueA, RegSetValueExA, RegSetValueExW, RegSetValueW, RegUnLoadKeyA, RegUnLoadKeyW, RevertToSelf, SetEntriesInAclA, SetEntriesInAclW, SetNamedSecurityInfoA, SetNamedSecurityInfoW, SetSecurityInfo, SetServiceStatus, SetThreadToken, SspiCompareAuthIdentities, SspiCopyAuthIdentity, SspiDecryptAuthIdentity, SspiEncodeAuthIdentityAsStringsA, SspiEncodeAuthIdentityAsStringsW, SspiEncodeStringsAsAuthIdentity, SspiEncryptAuthIdentity, SspiExcludePackage, SspiFreeAuthIdentity, SspiGetTargetHostName, SspiIsAuthIdentityEncrypted, SspiLocalFree, SspiMarshalAuthIdentity, SspiPrepareForCredRead, SspiPrepareForCredWrite, SspiUnmarshalAuthIdentity, SspiValidateAuthIdentity, SspiZeroAuthIdentity, TreeResetNamedSecurityInfoA, TreeResetNamedSecurityInfoW, TreeSetNamedSecurityInfoA, TreeSetNamedSecurityInfoW Structures -ACTRL_ACCESS_ENTRY_LIST, ACTRL_ALIST, ACTRL_PROPERTY_ENTRY, OBJECTS_AND_NAME, OBJECTS_AND_SID, TRUSTEE, LSA_STRING, LSA_TRANSLATED_SID2, LSA_AUTH_INFORMATION, LSA_FOREST_TRUST_BINARY_DATA, LSA_FOREST_TRUST_INFORMATION, LSA_REFERENCED_DOMAIN_LIST, LSA_UNICODE_STRING, TRUSTED_DOMAIN_AUTH_INFORMATION, TRUSTED_POSIX_OFFSET_INFO, BINARY_BLOB_CREDENTIAL_INFO, CERT_CREDENTIAL_INFO, CREDENTIAL, CREDENTIAL_TARGET_INFORMATION, USERNAME_TARGET_CREDENTIAL_INFO, ACE_HEADER, ACL, ACL_REVISION_INFORMATION, ACL_SIZE_INFORMATION, CLAIM_SECURITY_ATTRIBUTE_INFORMATION_V1, GENERIC_MAPPING, LUID, QUOTA_LIMITS, SID_IDENTIFIER_AUTHORITY, TOKEN_ELEVATION, TOKEN_GROUPS, TOKEN_LINKED_TOKEN, TOKEN_MANDATORY_POLICY, PRIVILEGE_SET, PSID_IDENTIFIER_AUTHORITY, PTOKEN_PRIVILEGES, VALENT, QUERY_SERVICE_CONFIG, SC_ACTION, SERVICE_DELAYED_AUTO_START_INFO, SERVICE_DESCRIPTION, SERVICE_FAILURE_ACTIONS, SERVICE_FAILURE_ACTIONS_FLAG, SERVICE_LAUNCH_PROTECTED_INFO, SERVICE_PREFERRED_NODE_INFO, SERVICE_PRESHUTDOWN_INFO, SERVICE_REQUIRED_PRIVILEGES_INFO, SERVICE_SID_INFO, SERVICE_STATUS, SERVICE_TRIGGER, SERVICE_TRIGGER_INFO, SERVICE_TRIGGER_SPECIFIC_DATA_ITEM, AUTHZ_ACCESS_REQUEST, AUTHZ_SECURITY_ATTRIBUTE_FQBN_VALUE, AUTHZ_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE, AUTHZ_SECURITY_ATTRIBUTE_V1, AUTHZ_ACCESS_REPLY, AUTHZ_SECURITY_ATTRIBUTE_V1_Union +ACTRL_ACCESS_ENTRY, ACTRL_ACCESS_ENTRY_LIST, ACTRL_ALIST, ACTRL_PROPERTY_ENTRY, EXPLICIT_ACCESS, INHERITED_FROM, OBJECTS_AND_NAME, OBJECTS_AND_SID, TRUSTEE, LSA_OBJECT_ATTRIBUTES, LSA_STRING, LSA_TRANSLATED_NAME, LSA_TRANSLATED_SID2, CENTRAL_ACCESS_POLICY, CENTRAL_ACCESS_POLICY_ENTRY, LSA_AUTH_INFORMATION, LSA_ENUMERATION_INFORMATION, LSA_FOREST_TRUST_BINARY_DATA, LSA_FOREST_TRUST_DOMAIN_INFO, LSA_FOREST_TRUST_INFORMATION, LSA_HANDLE, LSA_REFERENCED_DOMAIN_LIST, LSA_TRUST_INFORMATION, LSA_UNICODE_STRING, TRUSTED_DOMAIN_AUTH_INFORMATION, TRUSTED_DOMAIN_FULL_INFORMATION, TRUSTED_DOMAIN_INFORMATION_EX, TRUSTED_DOMAIN_NAME_INFO, TRUSTED_PASSWORD_INFO, TRUSTED_POSIX_OFFSET_INFO, HEVENTLOG, BINARY_BLOB_CREDENTIAL_INFO, CERT_CREDENTIAL_INFO, CREDENTIAL, CREDENTIAL_TARGET_INFORMATION, USERNAME_TARGET_CREDENTIAL_INFO, ACCESS_ALLOWED_ACE, ACE_HEADER, ACL, ACL_REVISION_INFORMATION, ACL_SIZE_INFORMATION, CLAIM_SECURITY_ATTRIBUTE_INFORMATION_V1, CLAIM_SECURITY_ATTRIBUTES_INFORMATION, GENERIC_MAPPING, LUID, LUID_AND_ATTRIBUTES, QUOTA_LIMITS, SECURITY_DESCRIPTOR, SID_AND_ATTRIBUTES, SID_IDENTIFIER_AUTHORITY, TOKEN_ACCESS_INFORMATION, TOKEN_APPCONTAINER_INFORMATION, TOKEN_DEFAULT_DACL, TOKEN_ELEVATION, TOKEN_GROUPS, TOKEN_GROUPS_AND_PRIVILEGES, TOKEN_LINKED_TOKEN, TOKEN_MANDATORY_LABEL, TOKEN_MANDATORY_POLICY, TOKEN_ORIGIN, TOKEN_OWNER, TOKEN_PRIMARY_GROUP, TOKEN_SOURCE, TOKEN_STATISTICS, TOKEN_USER, PRIVILEGE_SET, PSID_IDENTIFIER_AUTHORITY, PTOKEN_PRIVILEGES, VALENT, QUERY_SERVICE_CONFIG, SC_ACTION, SC_HANDLE, SERVICE_DELAYED_AUTO_START_INFO, SERVICE_DESCRIPTION, SERVICE_FAILURE_ACTIONS, SERVICE_FAILURE_ACTIONS_FLAG, SERVICE_LAUNCH_PROTECTED_INFO, SERVICE_PREFERRED_NODE_INFO, SERVICE_PRESHUTDOWN_INFO, SERVICE_REQUIRED_PRIVILEGES_INFO, SERVICE_SID_INFO, SERVICE_STATUS, SERVICE_STATUS_HANDLE, SERVICE_TRIGGER, SERVICE_TRIGGER_INFO, SERVICE_TRIGGER_SPECIFIC_DATA_ITEM, AUTHZ_ACCESS_CHECK_RESULTS_HANDLE, AUTHZ_ACCESS_REQUEST, AUTHZ_AUDIT_EVENT_HANDLE, AUTHZ_CLIENT_CONTEXT_HANDLE, AUTHZ_RESOURCE_MANAGER_HANDLE, AUTHZ_SECURITY_ATTRIBUTE_FQBN_VALUE, AUTHZ_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE, AUTHZ_SECURITY_ATTRIBUTE_V1, AUTHZ_ACCESS_REPLY, LsaConnectionHandle, PSEC_WINNT_AUTH_IDENTITY_OPAQUE, AUTHZ_SECURITY_ATTRIBUTE_V1_Union latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/Shared/AssemblyReport.md b/PInvoke/Shared/AssemblyReport.md index c9876700..c8bf18b5 100644 --- a/PInvoke/Shared/AssemblyReport.md +++ b/PInvoke/Shared/AssemblyReport.md @@ -104,5 +104,5 @@ SeverityLevel | A value indicating whether an `HRESULT` is a success (Severity b SeverityLevel | A value indicating the severity of an `NTStatus` value (bits 30-31). | STATUS_SEVERITY_SUCCESS, STATUS_SEVERITY_INFORMATIONAL, STATUS_SEVERITY_WARNING, STATUS_SEVERITY_ERROR ShowWindowCommand | The flags that specify how an application is to be displayed when it is opened. | SW_HIDE, SW_SHOWNORMAL, SW_NORMAL, SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED, SW_MAXIMIZE, SW_SHOWNOACTIVATE, SW_SHOW, SW_MINIMIZE, SW_SHOWMINNOACTIVE, SW_SHOWNA, SW_RESTORE, SW_SHOWDEFAULT, SW_FORCEMINIMIZE STGM | The STGM constants are flags that indicate conditions for creating and deleting the object and access modes for the object. The STGM constants are included in the IStorage, IStream, and IPropertySetStorage interfaces and in the StgCreateDocfile, StgCreateStorageEx, StgCreateDocfileOnILockBytes, StgOpenStorage, and StgOpenStorageEx functions. These elements are often combined using an OR operator. They are interpreted in groups as listed in the following table. It is not valid to use more than one element from a single group. | STGM_DIRECT, STGM_FAILIFTHERE, STGM_READ, STGM_WRITE, STGM_READWRITE, STGM_SHARE_EXCLUSIVE, STGM_SHARE_DENY_WRITE, STGM_SHARE_DENY_READ, STGM_SHARE_DENY_NONE, STGM_CREATE, STGM_TRANSACTED, STGM_CONVERT, STGM_PRIORITY, STGM_NOSCRATCH, STGM_NOSNAPSHOT, STGM_DIRECT_SWMR, STGM_DELETEONRELEASE, STGM_SIMPLE -SystemColorIndex | Color index used to get a system color from . | COLOR_SCROLLBAR, COLOR_BACKGROUND, COLOR_DESKTOP, COLOR_ACTIVECAPTION, COLOR_INACTIVECAPTION, COLOR_MENU, COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_MENUTEXT, COLOR_WINDOWTEXT, COLOR_CAPTIONTEXT, COLOR_ACTIVEBORDER, COLOR_INACTIVEBORDER, COLOR_APPWORKSPACE, COLOR_HIGHLIGHT, COLOR_HIGHLIGHTTEXT, COLOR_BTNFACE, COLOR_3DFACE, COLOR_BTNSHADOW, COLOR_3DSHADOW, COLOR_GRAYTEXT, COLOR_BTNTEXT, COLOR_INACTIVECAPTIONTEXT, COLOR_3DHILIGHT, COLOR_BTNHILIGHT, COLOR_BTNHIGHLIGHT, COLOR_3DHIGHLIGHT, COLOR_3DDKSHADOW, COLOR_3DLIGHT, COLOR_INFOTEXT, COLOR_INFOBK, COLOR_HOTLIGHT, COLOR_GRADIENTACTIVECAPTION, COLOR_GRADIENTINACTIVECAPTION, COLOR_MENUHILIGHT, COLOR_MENUBAR +SystemColorIndex | Color index used to get a system color from GetSysColor. | COLOR_SCROLLBAR, COLOR_BACKGROUND, COLOR_DESKTOP, COLOR_ACTIVECAPTION, COLOR_INACTIVECAPTION, COLOR_MENU, COLOR_WINDOW, COLOR_WINDOWFRAME, COLOR_MENUTEXT, COLOR_WINDOWTEXT, COLOR_CAPTIONTEXT, COLOR_ACTIVEBORDER, COLOR_INACTIVEBORDER, COLOR_APPWORKSPACE, COLOR_HIGHLIGHT, COLOR_HIGHLIGHTTEXT, COLOR_BTNFACE, COLOR_3DFACE, COLOR_BTNSHADOW, COLOR_3DSHADOW, COLOR_GRAYTEXT, COLOR_BTNTEXT, COLOR_INACTIVECAPTIONTEXT, COLOR_3DHILIGHT, COLOR_BTNHILIGHT, COLOR_BTNHIGHLIGHT, COLOR_3DHIGHLIGHT, COLOR_3DDKSHADOW, COLOR_3DLIGHT, COLOR_INFOTEXT, COLOR_INFOBK, COLOR_HOTLIGHT, COLOR_GRADIENTACTIVECAPTION, COLOR_GRADIENTINACTIVECAPTION, COLOR_MENUHILIGHT, COLOR_MENUBAR SystemShutDownReason | Flags used in the ExitWindowsEx, InitiateShutdown and InitiateSystemShutdownEx functions. | SHTDN_REASON_MAJOR_OTHER, SHTDN_REASON_MINOR_OTHER, SHTDN_REASON_MAJOR_NONE, SHTDN_REASON_MINOR_MAINTENANCE, SHTDN_REASON_MINOR_INSTALLATION, SHTDN_REASON_MINOR_UPGRADE, SHTDN_REASON_MINOR_RECONFIG, SHTDN_REASON_MINOR_HUNG, SHTDN_REASON_MINOR_UNSTABLE, SHTDN_REASON_MINOR_DISK, SHTDN_REASON_MINOR_PROCESSOR, SHTDN_REASON_MINOR_NETWORKCARD, SHTDN_REASON_MINOR_POWER_SUPPLY, SHTDN_REASON_MINOR_CORDUNPLUGGED, SHTDN_REASON_MINOR_ENVIRONMENT, SHTDN_REASON_MINOR_HARDWARE_DRIVER, SHTDN_REASON_MINOR_OTHERDRIVER, SHTDN_REASON_MINOR_BLUESCREEN, SHTDN_REASON_MINOR_SERVICEPACK, SHTDN_REASON_MINOR_HOTFIX, SHTDN_REASON_MINOR_SECURITYFIX, SHTDN_REASON_MINOR_SECURITY, SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY, SHTDN_REASON_MINOR_WMI, SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL, SHTDN_REASON_MINOR_HOTFIX_UNINSTALL, SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL, SHTDN_REASON_MINOR_MMC, SHTDN_REASON_MINOR_SYSTEMRESTORE, SHTDN_REASON_MINOR_TERMSRV, SHTDN_REASON_MINOR_DC_PROMOTION, SHTDN_REASON_MINOR_DC_DEMOTION, SHTDN_REASON_MINOR_NONE, SHTDN_REASON_UNKNOWN, SHTDN_REASON_MAJOR_HARDWARE, SHTDN_REASON_MAJOR_OPERATINGSYSTEM, SHTDN_REASON_MAJOR_SOFTWARE, SHTDN_REASON_MAJOR_APPLICATION, SHTDN_REASON_MAJOR_SYSTEM, SHTDN_REASON_MAJOR_POWER, SHTDN_REASON_MAJOR_LEGACY_API, SHTDN_REASON_FLAG_COMMENT_REQUIRED, SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED, SHTDN_REASON_FLAG_CLEAN_UI, SHTDN_REASON_FLAG_DIRTY_UI, SHTDN_REASON_FLAG_MOBILE_UI_RESERVED, SHTDN_REASON_FLAG_USER_DEFINED, SHTDN_REASON_FLAG_PLANNED, SHTDN_REASON_LEGACY_API diff --git a/PInvoke/Shared/Lib.cs b/PInvoke/Shared/Lib.cs index e452dbbf..5029275c 100644 --- a/PInvoke/Shared/Lib.cs +++ b/PInvoke/Shared/Lib.cs @@ -12,6 +12,9 @@ /// The authz public const string Authz = "authz.dll"; + /// bcrypt.dll + public const string Bcrypt = "bcrypt.dll"; + /// The COM CTL32 public const string ComCtl32 = "comctl32.dll"; @@ -42,6 +45,9 @@ /// The mstask public const string Mstask = "mstask.dll"; + /// ncrypt.dll + public const string Ncrypt = "ncrypt.dll"; + /// The net api32 public const string NetApi32 = "netapi32.dll"; @@ -72,6 +78,8 @@ /// The shlwapi public const string Shlwapi = "Shlwapi.dll"; + public const string Tokenbinding = "tokenbinding.dll"; + /// The user32 public const string User32 = "user32.dll"; diff --git a/PInvoke/Shared/Vanara.PInvoke.Shared.csproj b/PInvoke/Shared/Vanara.PInvoke.Shared.csproj index 5eaa96d9..68f1f2f2 100644 --- a/PInvoke/Shared/Vanara.PInvoke.Shared.csproj +++ b/PInvoke/Shared/Vanara.PInvoke.Shared.csproj @@ -11,7 +11,7 @@ * Shared structures and enums (see release notes) Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.Shared @@ -43,6 +43,8 @@ ACCESS_MASK, DrawTextFlags, FacilityCode, FacilityCode, FileFlagsAndAttributes, latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/Shell32/CorrelationReport.md b/PInvoke/Shell32/CorrelationReport.md index 0d020d42..3b070516 100644 --- a/PInvoke/Shell32/CorrelationReport.md +++ b/PInvoke/Shell32/CorrelationReport.md @@ -193,32 +193,48 @@ Native Method | Native DLL | Header | Managed Method ### Structures Native Structure | Header | Managed Structure --- | --- | --- +[APPBARDATA](http://msdn2.microsoft.com/en-us/library/cf86fe15-4beb-49b7-b73e-2ad61cedc3f8) | shellapi.h | Vanara.PInvoke.Shell32+APPBARDATA +[ASSOCIATIONELEMENT](http://msdn2.microsoft.com/en-us/library/1d1a963f-7ebb-4ba6-9a97-795c8ef11ae4) | shellapi.h | Vanara.PInvoke.Shell32+ASSOCIATIONELEMENT +[BROWSEINFO](http://msdn2.microsoft.com/en-us/library/bb773205) | Shlobj.h | Vanara.PInvoke.Shell32+BROWSEINFO [CABINETSTATE](http://msdn2.microsoft.com/en-us/library/4b82b6a8-c4c0-4af2-9612-0551376c1c62) | shlobj_core.h | Vanara.PInvoke.Shell32+CABINETSTATE +[CMINVOKECOMMANDINFOEX](http://msdn2.microsoft.com/en-us/library/c4c7f053-fdb1-4bba-9eb9-a514ce1d90f6) | shobjidl_core.h | Vanara.PInvoke.Shell32+CMINVOKECOMMANDINFOEX [COMDLG_FILTERSPEC](http://msdn2.microsoft.com/en-us/library/bb773221) | Shtypes.h | Vanara.PInvoke.Shell32+COMDLG_FILTERSPEC [COORD](https://www.google.com/search?num=5&q=COORD+site%3Amicrosoft.com) | wincon.h | Vanara.PInvoke.Shell32+COORD [CSFV](http://msdn2.microsoft.com/en-us/library/9ec22fd4-1562-4ef0-b932-ebbf06082807) | shlobj_core.h | Vanara.PInvoke.Shell32+CSFV [DATABLOCKHEADER](http://msdn2.microsoft.com/en-us/library/bb773249) | Shlobj.h | Vanara.PInvoke.Shell32+DATABLOCKHEADER +[DEFCONTEXTMENU](https://www.google.com/search?num=5&q=DEFCONTEXTMENU+site%3Amicrosoft.com) | shlobj_core.h | Vanara.PInvoke.Shell32+DEFCONTEXTMENU [EXP_DARWIN_LINK](http://msdn2.microsoft.com/en-us/library/bb773274) | Shlobj.h | Vanara.PInvoke.Shell32+EXP_DARWIN_LINK [EXP_SPECIAL_FOLDER](http://msdn2.microsoft.com/en-us/library/bb773279) | Shlobj.h | Vanara.PInvoke.Shell32+EXP_SPECIAL_FOLDER [EXP_SZ_LINK](http://msdn2.microsoft.com/en-us/library/bb773282) | Shlobj.h | Vanara.PInvoke.Shell32+EXP_SZ_LINK [EXTRASEARCH](http://msdn2.microsoft.com/en-us/library/bb773283) | Shobjidl.h | Vanara.PInvoke.Shell32+EXTRASEARCH [FOLDERSETTINGS](https://www.google.com/search?num=5&q=FOLDERSETTINGS+site%3Amicrosoft.com) | Shobjidl.h | Vanara.PInvoke.Shell32+FOLDERSETTINGS +[HPIF](https://www.google.com/search?num=5&q=HPIF+site%3Amicrosoft.com) | | Vanara.PInvoke.Shell32+HPIF +[HPSXA](https://www.google.com/search?num=5&q=HPSXA+site%3Amicrosoft.com) | | Vanara.PInvoke.Shell32+HPSXA [ITEMIDLIST](http://msdn2.microsoft.com/en-us/library/bb773321) | Shtypes.h | Vanara.PInvoke.Shell32+ITEMIDLIST [KNOWNFOLDER_DEFINITION](http://msdn2.microsoft.com/en-us/library/bb773325) | Shobjidl.h | Vanara.PInvoke.Shell32+KNOWNFOLDER_DEFINITION +[NOTIFYICONDATA](http://msdn2.microsoft.com/en-us/library/fdcc42c1-b3e5-4b04-8d79-7b6c29699d53) | shellapi.h | Vanara.PInvoke.Shell32+NOTIFYICONDATA +[NOTIFYICONIDENTIFIER](http://msdn2.microsoft.com/en-us/library/2fe4ffba-6fe5-4d34-9cb1-f266e4594b8e) | shellapi.h | Vanara.PInvoke.Shell32+NOTIFYICONIDENTIFIER [NT_CONSOLE_PROPS](http://msdn2.microsoft.com/en-us/library/bb773359) | Shlobj.h | Vanara.PInvoke.Shell32+NT_CONSOLE_PROPS [NT_FE_CONSOLE_PROPS](http://msdn2.microsoft.com/en-us/library/bb773362) | Shlobj.h | Vanara.PInvoke.Shell32+NT_FE_CONSOLE_PROPS [OLECMD](https://www.google.com/search?num=5&q=OLECMD+site%3Amicrosoft.com) | docobj.h | Vanara.PInvoke.Shell32+OLECMD [OLECMDTEXT](https://www.google.com/search?num=5&q=OLECMDTEXT+site%3Amicrosoft.com) | | Vanara.PInvoke.Shell32+OLECMDTEXT [OPENASINFO](http://msdn2.microsoft.com/en-us/library/5486c4d3-c6c5-459d-aa7f-426971184876) | shlobj_core.h | Vanara.PInvoke.Shell32+OPENASINFO +[PREVIEWHANDLERFRAMEINFO](http://msdn2.microsoft.com/en-us/library/dd93675e-fd69-4fa3-a8e7-5238c27783d8) | shobjidl_core.h | Vanara.PInvoke.Shell32+PREVIEWHANDLERFRAMEINFO [PROPPRG](http://msdn2.microsoft.com/en-us/library/603f990b-efb8-4d72-bc96-27bda4ffcbd8) | shlobj_core.h | Vanara.PInvoke.Shell32+PROPPRG [SFV_CREATE](https://www.google.com/search?num=5&q=SFV_CREATE+site%3Amicrosoft.com) | Shlobj.h | Vanara.PInvoke.Shell32+SFV_CREATE [SHChangeNotifyEntry](http://msdn2.microsoft.com/en-us/library/cb11435a-86f0-4b06-bfc6-e0417f2897a1) | shlobj_core.h | Vanara.PInvoke.Shell32+SHChangeNotifyEntry [SHDESCRIPTIONID](http://msdn2.microsoft.com/en-us/library/bb759775) | Shlobj.h | Vanara.PInvoke.Shell32+SHDESCRIPTIONID +[SHELLEXECUTEINFO](http://msdn2.microsoft.com/en-us/library/bb759784) | Shellapi.h | Vanara.PInvoke.Shell32+SHELLEXECUTEINFO [SHELLFLAGSTATE](http://msdn2.microsoft.com/en-us/library/9968c7c9-79d9-4fb1-bda2-d6a2504cd3a3) | shlobj_core.h | Vanara.PInvoke.Shell32+SHELLFLAGSTATE [SHELLSTATE](http://msdn2.microsoft.com/en-us/library/bb759788) | Shlobj.h | Vanara.PInvoke.Shell32+SHELLSTATE +[SHFILEINFO](http://msdn2.microsoft.com/en-us/library/bb759792) | Shellapi.h | Vanara.PInvoke.Shell32+SHFILEINFO +[SHFILEOPSTRUCT](https://www.google.com/search?num=5&q=SHFILEOPSTRUCT+site%3Amicrosoft.com) | Shellapi.h | Vanara.PInvoke.Shell32+SHFILEOPSTRUCT [SHFOLDERCUSTOMSETTINGS](http://msdn2.microsoft.com/en-us/library/a6357372-80ef-4719-b53f-87eb3fdc1b0d) | shlobj_core.h | Vanara.PInvoke.Shell32+SHFOLDERCUSTOMSETTINGS [SHITEMID](http://msdn2.microsoft.com/en-us/library/bb759800) | Shtypes.h | Vanara.PInvoke.Shell32+SHITEMID [SHQUERYRBINFO](http://msdn2.microsoft.com/en-us/library/7e9bc7e9-5712-45e7-a424-0afb62f26450) | shellapi.h | Vanara.PInvoke.Shell32+SHQUERYRBINFO +[SHSTOCKICONINFO](http://msdn2.microsoft.com/en-us/library/4d32826a-bb40-4805-9826-801c142b8d28) | shellapi.h | Vanara.PInvoke.Shell32+SHSTOCKICONINFO +[SV2CVW2_PARAMS](http://msdn2.microsoft.com/en-us/library/7e165654-74ea-4d8b-81b7-11257f87af53) | shobjidl_core.h | Vanara.PInvoke.Shell32+SV2CVW2_PARAMS +[THUMBBUTTON](http://msdn2.microsoft.com/en-us/library/dd391559) | Shobjidl.h | Vanara.PInvoke.Shell32+THUMBBUTTON ### Interfaces Native Interface | Native DLL | Header | Managed Interface --- | --- | --- | --- diff --git a/PInvoke/Shell32/Vanara.PInvoke.Shell32.csproj b/PInvoke/Shell32/Vanara.PInvoke.Shell32.csproj index 21e31bf6..3faef4e8 100644 --- a/PInvoke/Shell32/Vanara.PInvoke.Shell32.csproj +++ b/PInvoke/Shell32/Vanara.PInvoke.Shell32.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from Shell32.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.PInvoke.Shell32 $(AssemblyName) @@ -28,13 +28,15 @@ Functions AssocCreateForClasses, AssocGetDetailsOfPropKey, CDefFolderMenu_Create2, CommandLineToArgvW, DragAcceptFiles, DragFinish, DragQueryFileA, DragQueryFileW, DragQueryPoint, DuplicateIcon, ExtractAssociatedIconA, ExtractAssociatedIconExA, ExtractAssociatedIconExW, ExtractAssociatedIconW, ExtractIconA, ExtractIconExA, ExtractIconExW, ExtractIconW, FindExecutableA, FindExecutableW, GetCurrentProcessExplicitAppUserModelID, GetFileNameFromBrowse, ILAppendID, ILClone, ILCloneFirst, ILCombine, ILCreateFromPathA, ILCreateFromPathW, ILFindChild, ILFindLastID, ILFree, ILGetNext, ILGetSize, ILIsEqual, ILIsParent, ILLoadFromStreamEx, ILRemoveLastID, ILSaveToStream, InitNetworkAddressControl, IsNetDrive, IsUserAnAdmin, OpenRegStream, PathCleanupSpec, PathGetShortPath, PathIsExe, PathIsSlowA, PathIsSlowW, PathMakeUniqueName, PathResolve, PathYetAnotherMakeUniqueName, PickIconDlg, PifMgr_CloseProperties, PifMgr_GetProperties, PifMgr_OpenProperties, PifMgr_SetProperties, ReadCabinetState, RealDriveType, RestartDialog, RestartDialogEx, SetCurrentProcessExplicitAppUserModelID, SHAddDefaultPropertiesByExt, SHAddFromPropSheetExtArray, SHAddToRecentDocs, SHAlloc, SHAppBarMessage, SHAssocEnumHandlers, SHAssocEnumHandlersForProtocolByApplication, SHBindToFolderIDListParent, SHBindToFolderIDListParentEx, SHBindToObject, SHBindToParent, SHBrowseForFolderA, SHBrowseForFolderW, SHChangeNotification_Lock, SHChangeNotification_Unlock, SHChangeNotify, SHChangeNotifyDeregister, SHChangeNotifyRegister, SHChangeNotifyRegisterThread, SHCreateAssociationRegistration, SHCreateDataObject, SHCreateDefaultContextMenu, SHCreateDefaultExtractIcon, SHCreateDefaultPropertiesOp, SHCreateDirectory, SHCreateDirectoryExA, SHCreateDirectoryExW, SHCreateFileExtractIconW, SHCreateItemFromIDList, SHCreateItemFromParsingName, SHCreateItemFromRelativeName, SHCreateItemInKnownFolder, SHCreateItemWithParent, SHCreatePropSheetExtArray, SHCreateShellFolderView, SHCreateShellFolderViewEx, SHCreateShellItem, SHCreateShellItemArray, SHCreateShellItemArrayFromDataObject, SHCreateShellItemArrayFromIDLists, SHCreateShellItemArrayFromShellItem, SHCreateStdEnumFmtEtc, SHDefExtractIconA, SHDefExtractIconW, SHDestroyPropSheetExtArray, SHDoDragDrop, Shell_GetCachedImageIndexA, Shell_GetCachedImageIndexW, Shell_GetImageLists, Shell_MergeMenus, Shell_NotifyIconA, Shell_NotifyIconGetRect, Shell_NotifyIconW, ShellAboutA, ShellAboutW, ShellExecuteA, ShellExecuteExA, ShellExecuteExW, ShellExecuteW, SHEmptyRecycleBinA, SHEmptyRecycleBinW, SHEnumerateUnreadMailAccountsA, SHEnumerateUnreadMailAccountsW, SHEvaluateSystemCommandTemplate, SHFileOperationA, SHFileOperationW, SHFind_InitMenuPopup, SHFindFiles, SHFlushSFCache, SHFormatDrive, SHFree, SHFreeNameMappings, SHGetAttributesFromDataObject, SHGetDataFromIDListA, SHGetDataFromIDListW, SHGetDesktopFolder, SHGetDiskFreeSpaceA, SHGetDiskFreeSpaceExA, SHGetDiskFreeSpaceExW, SHGetDiskFreeSpaceW, SHGetDriveMedia, SHGetFileInfoA, SHGetFileInfoW, SHGetFolderLocation, SHGetFolderPathA, SHGetFolderPathAndSubDirA, SHGetFolderPathAndSubDirW, SHGetFolderPathEx, SHGetFolderPathW, SHGetIconOverlayIndexA, SHGetIconOverlayIndexW, SHGetIDListFromObject, SHGetImageList, SHGetInstanceExplorer, SHGetItemFromDataObject, SHGetItemFromObject, SHGetKnownFolderIDList, SHGetKnownFolderItem, SHGetKnownFolderPath, SHGetLocalizedName, SHGetNameFromIDList, SHGetNewLinkInfoA, SHGetNewLinkInfoW, SHGetPathFromIDListA, SHGetPathFromIDListEx, SHGetPathFromIDListW, SHGetPropertyStoreForWindow, SHGetPropertyStoreFromIDList, SHGetPropertyStoreFromParsingName, SHGetRealIDL, SHGetSetFolderCustomSettings, SHGetSetSettings, SHGetSettings, SHGetStockIconInfo, SHGetTemporaryPropertyForItem, SHGetUnreadMailCountW, SHHandleUpdateImage, SHInvokePrinterCommandA, SHInvokePrinterCommandW, SHIsFileAvailableOffline, SHLimitInputEdit, SHLoadInProc, SHLoadNonloadedIconOverlayIdentifiers, SHMapPIDLToSystemImageListIndex, SHMultiFileProperties, SHObjectProperties, SHOpenFolderAndSelectItems, SHOpenWithDialog, SHParseDisplayName, SHPathPrepareForWriteA, SHPathPrepareForWriteW, SHPropStgCreate, SHPropStgReadMultiple, SHPropStgWriteMultiple, SHQueryRecycleBinA, SHQueryRecycleBinW, SHQueryUserNotificationState, SHRemoveLocalizedName, SHReplaceFromPropSheetExtArray, SHResolveLibrary, SHRestricted, SHSetDefaultProperties, SHSetInstanceExplorer, SHSetKnownFolderPath, SHSetLocalizedName, SHSetTemporaryPropertyForItem, SHSetUnreadMailCountW, SHShellFolderView_Message, SHShowManageLibraryUI, SHSimpleIDListFromPath, SHTestTokenMembership, SHUpdateImageA, SHUpdateImageW, SHValidateUNC, SignalFileOpen, StgMakeUniqueName, Win32DeleteFile, WriteCabinetState Structures -OLECMD, OLECMDTEXT, SHQUERYRBINFO, CABINETSTATE, COORD, CSFV, DATABLOCKHEADER, EXP_DARWIN_LINK, EXP_SPECIAL_FOLDER, EXP_SZ_LINK, NT_CONSOLE_PROPS, NT_FE_CONSOLE_PROPS, OPENASINFO, PROPPRG, SFV_CREATE, SHChangeNotifyEntry, SHDESCRIPTIONID, SHELLFLAGSTATE, SHELLSTATE, SHFOLDERCUSTOMSETTINGS, COMDLG_FILTERSPEC, KNOWNFOLDER_DEFINITION, EXTRASEARCH, FOLDERSETTINGS, ITEMIDLIST, SHITEMID +OLECMD, OLECMDTEXT, APPBARDATA, ASSOCIATIONELEMENT, NOTIFYICONDATA, NOTIFYICONIDENTIFIER, SHELLEXECUTEINFO, SHFILEINFO, SHFILEOPSTRUCT, SHQUERYRBINFO, SHSTOCKICONINFO, BROWSEINFO, CABINETSTATE, COORD, CSFV, DATABLOCKHEADER, DEFCONTEXTMENU, EXP_DARWIN_LINK, EXP_SPECIAL_FOLDER, EXP_SZ_LINK, HPIF, HPSXA, NT_CONSOLE_PROPS, NT_FE_CONSOLE_PROPS, OPENASINFO, PROPPRG, SFV_CREATE, SHChangeNotifyEntry, SHDESCRIPTIONID, SHELLFLAGSTATE, SHELLSTATE, SHFOLDERCUSTOMSETTINGS, CMINVOKECOMMANDINFOEX, COMDLG_FILTERSPEC, KNOWNFOLDER_DEFINITION, PREVIEWHANDLERFRAMEINFO, EXTRASEARCH, FOLDERSETTINGS, SV2CVW2_PARAMS, THUMBBUTTON, ITEMIDLIST, SHITEMID Interfaces IAutoComplete, IAutoComplete2, IOleCommandTarget, IObjectArray, IObjectCollection, IExtractIcon, IProgressDialog, IOpenControlPanel, IApplicationAssociationRegistration, IApplicationDestinations, IApplicationDocumentLists, IDefaultExtractIconInit, IEnumAssocHandlers, IEnumIDList, IFileSystemBindData, IFileSystemBindData2, IQueryInfo, IActionProgress, IActionProgressDialog, ICommDlgBrowser, ICommDlgBrowser2, ICommDlgBrowser3, IContextMenu, IContextMenu2, IContextMenu3, IContextMenuCB, ICopyHookA, ICopyHookW, IExplorerBrowser, IExplorerBrowserEvents, IExplorerPaneVisibility, IExtractImage, IFileDialog, IFileDialog2, IFileDialogControlEvents, IFileDialogCustomize, IFileDialogEvents, IFileOpenDialog, IFileOperationProgressSink, IFileSaveDialog, IModalWindow, IFileOperation, IInitializeWithFile, IInitializeWithItem, IInitializeWithStream, IInputObject, IInputObject2, IInputObjectSite, IKnownFolder, IKnownFolderManager, IObjectWithAppUserModelId, IObjectWithProgId, IObjectWithSite, IOperationsProgressDialog, IPreviewHandler, IPreviewHandlerFrame, IPreviewHandlerVisuals, IServiceProvider, IShellExtInit, IEnumExtraSearch, IShellFolder, IShellFolder2, IEnumShellItems, IShellItem, IShellItem2, IShellItemArray, IShellItemImageFactory, IShellLibrary, IShellLinkDataList, IShellLinkW, IShellPropSheetExt, IFolderViewOptions, IShellBrowser, IShellFolderViewCB, IShellView, IShellView2, IShellView3, IStartMenuPinnedList, ICustomDestinationList, ITaskbarList, ITaskbarList2, ITaskbarList3, ITaskbarList4, IThumbnailProvider latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/ShlwApi/CorrelationReport.md b/PInvoke/ShlwApi/CorrelationReport.md index 3d2dab50..10bbef9f 100644 --- a/PInvoke/ShlwApi/CorrelationReport.md +++ b/PInvoke/ShlwApi/CorrelationReport.md @@ -216,6 +216,7 @@ Native Method | Native DLL | Header | Managed Method ### Structures Native Structure | Header | Managed Structure --- | --- | --- +[HUSKEY](https://www.google.com/search?num=5&q=HUSKEY+site%3Amicrosoft.com) | | Vanara.PInvoke.ShlwApi+HUSKEY [PARSEDURL](http://msdn2.microsoft.com/en-us/library/9092dd7a-ff5b-465f-a808-ef4e0067f540) | shlwapi.h | Vanara.PInvoke.ShlwApi+PARSEDURL [QITAB](http://msdn2.microsoft.com/en-us/library/3a055773-6e53-45e1-8936-011a8b2b8b16) | shlwapi.h | Vanara.PInvoke.ShlwApi+QITAB ### Interfaces diff --git a/PInvoke/ShlwApi/Vanara.PInvoke.ShlwApi.csproj b/PInvoke/ShlwApi/Vanara.PInvoke.ShlwApi.csproj index 2e43df26..5d682cd1 100644 --- a/PInvoke/ShlwApi/Vanara.PInvoke.ShlwApi.csproj +++ b/PInvoke/ShlwApi/Vanara.PInvoke.ShlwApi.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from ShlwApi.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.ShlwApi $(AssemblyName) @@ -28,13 +28,15 @@ Functions AssocCreate, AssocGetPerceivedType, AssocIsDangerous, AssocQueryKeyA, AssocQueryKeyW, AssocQueryStringA, AssocQueryStringW, ChrCmpIA, ChrCmpIW, ColorAdjustLuma, ColorHLSToRGB, ColorRGBToHLS, ConnectToConnectionPoint, GetAcceptLanguagesA, GetAcceptLanguagesW, GetMenuPosFromID, HashData, IsCharSpaceA, IsCharSpaceW, IsInternetESCEnabled, IsOS, IStream_Copy, IStream_Read, IStream_ReadPidl, IStream_ReadStr, IStream_Reset, IStream_Size, IStream_Write, IStream_WritePidl, IStream_WriteStr, IUnknown_AtomicRelease, IUnknown_GetSite, IUnknown_GetWindow, IUnknown_QueryService, IUnknown_Set, IUnknown_SetSite, MLLoadLibraryA, MLLoadLibraryW, ParseURLA, ParseURLW, PathAddBackslashA, PathAddBackslashW, PathAddExtensionA, PathAddExtensionW, PathAppendA, PathAppendW, PathBuildRootA, PathBuildRootW, PathCanonicalizeA, PathCanonicalizeW, PathCombineA, PathCombineW, PathCommonPrefixA, PathCommonPrefixW, PathCompactPathA, PathCompactPathExA, PathCompactPathExW, PathCompactPathW, PathCreateFromUrlA, PathCreateFromUrlAlloc, PathCreateFromUrlW, PathFileExistsA, PathFileExistsW, PathFindExtensionA, PathFindExtensionW, PathFindFileNameA, PathFindFileNameW, PathFindNextComponentA, PathFindNextComponentW, PathFindOnPathA, PathFindOnPathW, PathFindSuffixArrayA, PathFindSuffixArrayW, PathGetArgsA, PathGetArgsW, PathGetCharTypeA, PathGetCharTypeW, PathGetDriveNumberA, PathGetDriveNumberW, PathIsContentTypeA, PathIsContentTypeW, PathIsDirectoryA, PathIsDirectoryEmptyA, PathIsDirectoryEmptyW, PathIsDirectoryW, PathIsFileSpecA, PathIsFileSpecW, PathIsLFNFileSpecA, PathIsLFNFileSpecW, PathIsNetworkPathA, PathIsNetworkPathW, PathIsPrefixA, PathIsPrefixW, PathIsRelativeA, PathIsRelativeW, PathIsRootA, PathIsRootW, PathIsSameRootA, PathIsSameRootW, PathIsSystemFolderA, PathIsSystemFolderW, PathIsUNCA, PathIsUNCServerA, PathIsUNCServerShareA, PathIsUNCServerShareW, PathIsUNCServerW, PathIsUNCW, PathIsURLA, PathIsURLW, PathMakePrettyA, PathMakePrettyW, PathMakeSystemFolderA, PathMakeSystemFolderW, PathMatchSpecA, PathMatchSpecExA, PathMatchSpecExW, PathMatchSpecW, PathParseIconLocationA, PathParseIconLocationW, PathQuoteSpacesA, PathQuoteSpacesW, PathRelativePathToA, PathRelativePathToW, PathRemoveArgsA, PathRemoveArgsW, PathRemoveBackslashA, PathRemoveBackslashW, PathRemoveBlanksA, PathRemoveBlanksW, PathRemoveExtensionA, PathRemoveExtensionW, PathRemoveFileSpecA, PathRemoveFileSpecW, PathRenameExtensionA, PathRenameExtensionW, PathSearchAndQualifyA, PathSearchAndQualifyW, PathSetDlgItemPathA, PathSetDlgItemPathW, PathSkipRootA, PathSkipRootW, PathStripPathA, PathStripPathW, PathStripToRootA, PathStripToRootW, PathUndecorateA, PathUndecorateW, PathUnExpandEnvStringsA, PathUnExpandEnvStringsW, PathUnmakeSystemFolderA, PathUnmakeSystemFolderW, PathUnquoteSpacesA, PathUnquoteSpacesW, QISearch, SHAllocShared, SHAnsiToAnsi, SHAnsiToUnicode, SHAutoComplete, SHCopyKeyA, SHCopyKeyW, SHCreateMemStream, SHCreateShellPalette, SHCreateStreamOnFileA, SHCreateStreamOnFileEx, SHCreateStreamOnFileW, SHCreateThread, SHCreateThreadRef, SHCreateThreadWithHandle, SHDeleteEmptyKeyA, SHDeleteEmptyKeyW, SHDeleteKeyA, SHDeleteKeyW, SHDeleteValueA, SHDeleteValueW, SHEnumKeyExA, SHEnumKeyExW, SHEnumValueA, SHEnumValueW, SHFormatDateTimeA, SHFormatDateTimeW, SHFreeShared, SHGetInverseCMAP, SHGetThreadRef, SHGetValueA, SHGetValueW, SHGetViewStatePropertyBag, SHIsChildOrSelf, SHIsLowMemoryMachine, SHLoadIndirectString, SHLockShared, SHMessageBoxCheckA, SHMessageBoxCheckW, SHOpenRegStream2A, SHOpenRegStream2W, SHQueryInfoKeyA, SHQueryInfoKeyW, SHQueryValueExA, SHQueryValueExW, SHRegCloseUSKey, SHRegCreateUSKeyA, SHRegCreateUSKeyW, SHRegDeleteEmptyUSKeyA, SHRegDeleteEmptyUSKeyW, SHRegDeleteUSValueA, SHRegDeleteUSValueW, SHRegDuplicateHKey, SHRegEnumUSKeyA, SHRegEnumUSKeyW, SHRegEnumUSValueA, SHRegEnumUSValueW, SHRegGetBoolUSValueA, SHRegGetBoolUSValueW, SHRegGetBoolValueFromHKCUHKLM, SHRegGetIntW, SHRegGetPathA, SHRegGetPathW, SHRegGetUSValueA, SHRegGetUSValueW, SHRegGetValueA, SHRegGetValueFromHKCUHKLM, SHRegGetValueW, SHRegOpenUSKeyA, SHRegOpenUSKeyW, SHRegQueryInfoUSKeyA, SHRegQueryInfoUSKeyW, SHRegQueryUSValueA, SHRegQueryUSValueW, SHRegSetPathA, SHRegSetPathW, SHRegSetUSValueA, SHRegSetUSValueW, SHRegWriteUSValueA, SHRegWriteUSValueW, SHReleaseThreadRef, SHSendMessageBroadcastA, SHSendMessageBroadcastW, SHSetThreadRef, SHSetValueA, SHSetValueW, SHSkipJunction, SHStrDupA, SHStrDupW, SHStripMneumonicA, SHStripMneumonicW, SHUnicodeToAnsi, SHUnicodeToUnicode, SHUnlockShared, StrCatBuffA, StrCatBuffW, StrCatChainW, StrCatW, StrChrA, StrChrIA, StrChrIW, StrChrNIW, StrChrNW, StrChrW, StrCmpCA, StrCmpCW, StrCmpICA, StrCmpICW, StrCmpIW, StrCmpLogicalW, StrCmpNA, StrCmpNCA, StrCmpNCW, StrCmpNIA, StrCmpNICA, StrCmpNICW, StrCmpNIW, StrCmpNW, StrCmpW, StrCpyNW, StrCpyW, StrCSpnA, StrCSpnIA, StrCSpnIW, StrCSpnW, StrDupA, StrDupW, StrFormatByteSize64A, StrFormatByteSizeA, StrFormatByteSizeEx, StrFormatByteSizeW, StrFormatKBSizeA, StrFormatKBSizeW, StrFromTimeIntervalA, StrFromTimeIntervalW, StrIsIntlEqualA, StrIsIntlEqualW, StrNCatA, StrNCatW, StrPBrkA, StrPBrkW, StrRChrA, StrRChrIA, StrRChrIW, StrRChrW, StrRetToBSTR, StrRetToBufA, StrRetToBufW, StrRetToStrA, StrRetToStrW, StrRStrIA, StrRStrIW, StrSpnA, StrSpnW, StrStrA, StrStrIA, StrStrIW, StrStrNIW, StrStrNW, StrStrW, StrToInt64ExA, StrToInt64ExW, StrToIntA, StrToIntExA, StrToIntExW, StrToIntW, StrTrimA, StrTrimW, UrlApplySchemeA, UrlApplySchemeW, UrlCanonicalizeA, UrlCanonicalizeW, UrlCombineA, UrlCombineW, UrlCompareA, UrlCompareW, UrlCreateFromPathA, UrlCreateFromPathW, UrlEscapeA, UrlEscapeW, UrlFixupW, UrlGetLocationA, UrlGetLocationW, UrlGetPartA, UrlGetPartW, UrlHashA, UrlHashW, UrlIsA, UrlIsNoHistoryA, UrlIsNoHistoryW, UrlIsOpaqueA, UrlIsOpaqueW, UrlIsW, UrlUnescapeA, UrlUnescapeW, WhichPlatform Structures -QITAB, PARSEDURL +HUSKEY, QITAB, PARSEDURL Interfaces IQueryAssociations latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/TaskSchd/Vanara.PInvoke.TaskSchd.csproj b/PInvoke/TaskSchd/Vanara.PInvoke.TaskSchd.csproj index b5492879..c1de0382 100644 --- a/PInvoke/TaskSchd/Vanara.PInvoke.TaskSchd.csproj +++ b/PInvoke/TaskSchd/Vanara.PInvoke.TaskSchd.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported for Task Scheduler 1.0 and 2.0 COM objects. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.TaskSchd $(AssemblyName) @@ -35,6 +35,8 @@ ITask, ITaskScheduler, IAction, IActionCollection, IBootTrigger, IComHandlerActi latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/User32.Gdi/Vanara.PInvoke.User32.Gdi.csproj b/PInvoke/User32.Gdi/Vanara.PInvoke.User32.Gdi.csproj index b0f93bf8..1b469255 100644 --- a/PInvoke/User32.Gdi/Vanara.PInvoke.User32.Gdi.csproj +++ b/PInvoke/User32.Gdi/Vanara.PInvoke.User32.Gdi.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from User32.dll and specific to graphics or window management. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.PInvoke.User32.Gdi $(AssemblyName) @@ -31,7 +31,9 @@ Structures ICONINFO, NMHDR, MINMAXINFO, WINDOWPOS, GRPICONDIR, GRPICONDIRENTRY - latest + latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/User32/CorrelationReport.md b/PInvoke/User32/CorrelationReport.md index e4b7c997..b96bddf2 100644 --- a/PInvoke/User32/CorrelationReport.md +++ b/PInvoke/User32/CorrelationReport.md @@ -623,27 +623,47 @@ Native Structure | Header | Managed Structure [ALTTABINFO](http://msdn2.microsoft.com/en-us/library/alttabinfo) | winuser.h | Vanara.PInvoke.User32_Gdi+ALTTABINFO [ANIMATIONINFO](http://msdn2.microsoft.com/en-us/library/ms724197) | Winuser.h | Vanara.PInvoke.User32+ANIMATIONINFO [AUDIODESCRIPTION](http://msdn2.microsoft.com/en-us/library/aa379651) | Winuser.h | Vanara.PInvoke.User32+AUDIODESCRIPTION +[CBT_CREATEWND](http://msdn2.microsoft.com/en-us/library/cbt_createwnd.htm) | winuser.h | Vanara.PInvoke.User32+CBT_CREATEWND +[CBTACTIVATESTRUCT](http://msdn2.microsoft.com/en-us/library/cbtactivatestruct.htm) | winuser.h | Vanara.PInvoke.User32+CBTACTIVATESTRUCT [CHANGEFILTERSTRUCT](http://msdn2.microsoft.com/en-us/library/changefilterstruct) | winuser.h | Vanara.PInvoke.User32_Gdi+CHANGEFILTERSTRUCT +[CURSORINFO](http://msdn2.microsoft.com/en-us/library/cursorinfo) | winuser.h | Vanara.PInvoke.User32_Gdi+CURSORINFO +[CWPRETSTRUCT](http://msdn2.microsoft.com/en-us/library/cwpretstruct.htm) | winuser.h | Vanara.PInvoke.User32+CWPRETSTRUCT +[CWPSTRUCT](http://msdn2.microsoft.com/en-us/library/cwpstruct.htm) | winuser.h | Vanara.PInvoke.User32+CWPSTRUCT [DEBUGHOOKINFO](http://msdn2.microsoft.com/en-us/library/debughookinfo.htm) | winuser.h | Vanara.PInvoke.User32+DEBUGHOOKINFO [DLGITEMTEMPLATE](http://msdn2.microsoft.com/en-us/library/dlgitemtemplate) | winuser.h | Vanara.PInvoke.User32_Gdi+DLGITEMTEMPLATE [DLGTEMPLATE](http://msdn2.microsoft.com/en-us/library/dlgtemplate) | winuser.h | Vanara.PInvoke.User32_Gdi+DLGTEMPLATE +[EVENTMSG](http://msdn2.microsoft.com/en-us/library/eventmsg.htm) | winuser.h | Vanara.PInvoke.User32+EVENTMSG [FILTERKEYS](https://www.google.com/search?num=5&q=FILTERKEYS+site%3Amicrosoft.com) | Winuser.h | Vanara.PInvoke.User32+FILTERKEYS [GRPICONDIR](https://www.google.com/search?num=5&q=GRPICONDIR+site%3Amicrosoft.com) | | Vanara.PInvoke.User32_Gdi+GRPICONDIR [GRPICONDIRENTRY](https://www.google.com/search?num=5&q=GRPICONDIRENTRY+site%3Amicrosoft.com) | | Vanara.PInvoke.User32_Gdi+GRPICONDIRENTRY +[GUITHREADINFO](http://msdn2.microsoft.com/en-us/library/guithreadinfo) | winuser.h | Vanara.PInvoke.User32_Gdi+GUITHREADINFO [HELPINFO](https://www.google.com/search?num=5&q=HELPINFO+site%3Amicrosoft.com) | Winuser.h | Vanara.PInvoke.User32+HELPINFO +[HHOOK](https://www.google.com/search?num=5&q=HHOOK+site%3Amicrosoft.com) | | Vanara.PInvoke.User32+HHOOK [HIGHCONTRAST](https://www.google.com/search?num=5&q=HIGHCONTRAST+site%3Amicrosoft.com) | Winuser.h | Vanara.PInvoke.User32+HIGHCONTRAST +[ICONINFO](https://www.google.com/search?num=5&q=ICONINFO+site%3Amicrosoft.com) | | Vanara.PInvoke.User32_Gdi+ICONINFO +[ICONINFOEX](http://msdn2.microsoft.com/en-us/library/iconinfoex) | winuser.h | Vanara.PInvoke.User32_Gdi+ICONINFOEX [ICONMETRICS](https://www.google.com/search?num=5&q=ICONMETRICS+site%3Amicrosoft.com) | Winuser.h | Vanara.PInvoke.User32+ICONMETRICS [KBDLLHOOKSTRUCT](http://msdn2.microsoft.com/en-us/library/kbdllhookstruct.htm) | winuser.h | Vanara.PInvoke.User32+KBDLLHOOKSTRUCT +[MDINEXTMENU](http://msdn2.microsoft.com/en-us/library/mdinextmenu.htm) | winuser.h | Vanara.PInvoke.User32_Gdi+MDINEXTMENU +[MENUBARINFO](http://msdn2.microsoft.com/en-us/library/menubarinfo.htm) | winuser.h | Vanara.PInvoke.User32_Gdi+MENUBARINFO [MENUEX_TEMPLATE_HEADER](http://msdn2.microsoft.com/en-us/library/df763349-7127-482e-8613-74e68addde5d) | winuser.h | Vanara.PInvoke.User32_Gdi+MENUEX_TEMPLATE_HEADER [MENUEX_TEMPLATE_ITEM](http://msdn2.microsoft.com/en-us/library/f6e2fd0a-16b8-48e3-8597-341085a7adbd) | winuser.h | Vanara.PInvoke.User32_Gdi+MENUEX_TEMPLATE_ITEM +[MENUGETOBJECTINFO](http://msdn2.microsoft.com/en-us/library/menugetobjectinfo.htm) | winuser.h | Vanara.PInvoke.User32_Gdi+MENUGETOBJECTINFO +[MENUINFO](http://msdn2.microsoft.com/en-us/library/menuinfo.htm) | winuser.h | Vanara.PInvoke.User32_Gdi+MENUINFO +[MENUITEMINFO](http://msdn2.microsoft.com/en-us/library/menuiteminfo.htm) | winuser.h | Vanara.PInvoke.User32_Gdi+MENUITEMINFO [MENUITEMTEMPLATE](http://msdn2.microsoft.com/en-us/library/menuitemtemplate.htm) | winuser.h | Vanara.PInvoke.User32_Gdi+MENUITEMTEMPLATE [MENUITEMTEMPLATEHEADER](http://msdn2.microsoft.com/en-us/library/menuitemtemplateheader.htm) | winuser.h | Vanara.PInvoke.User32_Gdi+MENUITEMTEMPLATEHEADER +[METAFILEPICT](http://msdn2.microsoft.com/en-us/library/metafilepict) | wingdi.h | Vanara.PInvoke.User32+METAFILEPICT [MINIMIZEDMETRICS](http://msdn2.microsoft.com/en-us/library/ms724500) | Winuser.h | Vanara.PInvoke.User32+MINIMIZEDMETRICS [MINMAXINFO](https://www.google.com/search?num=5&q=MINMAXINFO+site%3Amicrosoft.com) | | Vanara.PInvoke.User32_Gdi+MINMAXINFO [MONITORINFO](http://msdn2.microsoft.com/en-us/library/ca8ec86f-69ba-4cf8-a867-67182a3d630d) | winuser.h | Vanara.PInvoke.User32_Gdi+MONITORINFO [MONITORINFOEX](http://msdn2.microsoft.com/en-us/library/f296ce29-3fc8-41c9-a201-56e222aa2219) | winuser.h | Vanara.PInvoke.User32_Gdi+MONITORINFOEX +[MOUSEHOOKSTRUCT](http://msdn2.microsoft.com/en-us/library/mousehookstruct.htm) | winuser.h | Vanara.PInvoke.User32+MOUSEHOOKSTRUCT +[MOUSEHOOKSTRUCTEX](http://msdn2.microsoft.com/en-us/library/mousehookstructex.htm) | winuser.h | Vanara.PInvoke.User32+MOUSEHOOKSTRUCTEX [MOUSEKEYS](https://www.google.com/search?num=5&q=MOUSEKEYS+site%3Amicrosoft.com) | Winuser.h | Vanara.PInvoke.User32+MOUSEKEYS +[MSGBOXPARAMS](https://www.google.com/search?num=5&q=MSGBOXPARAMS+site%3Amicrosoft.com) | Winuser.h | Vanara.PInvoke.User32+MSGBOXPARAMS [MSLLHOOKSTRUCT](http://msdn2.microsoft.com/en-us/library/msllhookstruct.htm) | winuser.h | Vanara.PInvoke.User32+MSLLHOOKSTRUCT +[NMHDR](https://www.google.com/search?num=5&q=NMHDR+site%3Amicrosoft.com) | | Vanara.PInvoke.User32_Gdi+NMHDR [NONCLIENTMETRICS](http://msdn2.microsoft.com/en-us/library/ff729175) | Winuser.h | Vanara.PInvoke.User32+NONCLIENTMETRICS [SERIALKEYS](https://www.google.com/search?num=5&q=SERIALKEYS+site%3Amicrosoft.com) | Winuser.h | Vanara.PInvoke.User32+SERIALKEYS [SOUNDSENTRY](https://www.google.com/search?num=5&q=SOUNDSENTRY+site%3Amicrosoft.com) | Winuser.h | Vanara.PInvoke.User32+SOUNDSENTRY @@ -652,6 +672,9 @@ Native Structure | Header | Managed Structure [TOGGLEKEYS](https://www.google.com/search?num=5&q=TOGGLEKEYS+site%3Amicrosoft.com) | Winuser.h | Vanara.PInvoke.User32+TOGGLEKEYS [TOUCHPREDICTIONPARAMETERS](http://msdn2.microsoft.com/en-us/library/hh969214) | Winuser.h | Vanara.PInvoke.User32+TOUCHPREDICTIONPARAMETERS [TPMPARAMS](http://msdn2.microsoft.com/en-us/library/tpmparams.htm) | winuser.h | Vanara.PInvoke.User32_Gdi+TPMPARAMS +[TRACKMOUSEEVENT](http://msdn2.microsoft.com/en-us/library/ms645604) | Winuser.h | Vanara.PInvoke.User32+TRACKMOUSEEVENT +[UPDATELAYEREDWINDOWINFO](http://msdn2.microsoft.com/en-us/library/updatelayeredwindowinfo) | winuser.h | Vanara.PInvoke.User32_Gdi+UPDATELAYEREDWINDOWINFO [USEROBJECTFLAGS](http://msdn2.microsoft.com/en-us/library/5a973d45-5ff4-47e7-a927-72d3fdd61dc9) | winuser.h | Vanara.PInvoke.User32_Gdi+USEROBJECTFLAGS [WINDOWINFO](http://msdn2.microsoft.com/en-us/library/windowinfo) | winuser.h | Vanara.PInvoke.User32_Gdi+WINDOWINFO [WINDOWPLACEMENT](http://msdn2.microsoft.com/en-us/library/windowplacement) | winuser.h | Vanara.PInvoke.User32_Gdi+WINDOWPLACEMENT +[WINDOWPOS](https://www.google.com/search?num=5&q=WINDOWPOS+site%3Amicrosoft.com) | | Vanara.PInvoke.User32_Gdi+WINDOWPOS diff --git a/PInvoke/User32/Vanara.PInvoke.User32.csproj b/PInvoke/User32/Vanara.PInvoke.User32.csproj index 8c0f66bd..51886307 100644 --- a/PInvoke/User32/Vanara.PInvoke.User32.csproj +++ b/PInvoke/User32/Vanara.PInvoke.User32.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from User32.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard20 Vanara.PInvoke.User32 $(AssemblyName) @@ -28,10 +28,12 @@ Functions AddClipboardFormatListener, AdjustWindowRect, AdjustWindowRectEx, AllowSetForegroundWindow, AnimateWindow, AnyPopup, AppendMenuA, AppendMenuW, ArrangeIconicWindows, BeginDeferWindowPos, BringWindowToTop, CalculatePopupWindowPosition, CallMsgFilterA, CallMsgFilterW, CallNextHookEx, CascadeWindows, ChangeClipboardChain, ChangeWindowMessageFilter, ChangeWindowMessageFilterEx, CheckDlgButton, CheckMenuItem, CheckMenuRadioItem, CheckRadioButton, ChildWindowFromPoint, ChildWindowFromPointEx, ClipCursor, CloseClipboard, CloseDesktop, CloseWindow, CloseWindowStation, CopyIcon, CountClipboardFormats, CreateCursor, CreateDesktopA, CreateDesktopExA, CreateDesktopExW, CreateDesktopW, CreateDialogIndirectParamA, CreateDialogIndirectParamW, CreateDialogParamA, CreateDialogParamW, CreateIcon, CreateIconFromResource, CreateIconFromResourceEx, CreateIconIndirect, CreateMenu, CreatePopupMenu, CreateWindowExA, CreateWindowExW, CreateWindowStationA, CreateWindowStationW, DefDlgProc, DeferWindowPos, DeleteMenu, DeregisterShellHookWindow, DestroyCursor, DestroyIcon, DestroyMenu, DestroyWindow, DialogBoxIndirectParamA, DialogBoxIndirectParamW, DialogBoxParamA, DialogBoxParamW, DrawEdge, DrawIcon, DrawIconEx, DrawMenuBar, DrawTextA, DrawTextW, EmptyClipboard, EnableMenuItem, EndDeferWindowPos, EndDialog, EndMenu, EndTask, EnumChildWindows, EnumClipboardFormats, EnumDesktopsA, EnumDesktopsW, EnumDesktopWindows, EnumDisplayMonitors, EnumPropsA, EnumPropsExA, EnumPropsExW, EnumPropsW, EnumThreadWindows, EnumWindows, EnumWindowStationsA, EnumWindowStationsW, ExitWindowsEx, FindWindowA, FindWindowExA, FindWindowExW, FindWindowW, GetActiveWindow, GetAltTabInfoA, GetAltTabInfoW, GetAncestor, GetClientRect, GetClipboardData, GetClipboardFormatNameA, GetClipboardFormatNameW, GetClipboardOwner, GetClipboardSequenceNumber, GetClipboardViewer, GetClipCursor, GetCursor, GetCursorInfo, GetCursorPos, GetDC, GetDesktopWindow, GetDialogBaseUnits, GetDlgCtrlID, GetDlgItem, GetDlgItemInt, GetDlgItemTextA, GetDlgItemTextW, GetForegroundWindow, GetGUIThreadInfo, GetIconInfo, GetIconInfoExA, GetIconInfoExW, GetLastActivePopup, GetLayeredWindowAttributes, GetMenu, GetMenuBarInfo, GetMenuCheckMarkDimensions, GetMenuDefaultItem, GetMenuInfo, GetMenuItemCount, GetMenuItemID, GetMenuItemInfoA, GetMenuItemInfoW, GetMenuItemRect, GetMenuState, GetMenuStringA, GetMenuStringW, GetMonitorInfoA, GetMonitorInfoW, GetNextDlgGroupItem, GetNextDlgTabItem, GetOpenClipboardWindow, GetParent, GetPhysicalCursorPos, GetPriorityClipboardFormat, GetProcessDefaultLayout, GetProcessWindowStation, GetPropA, GetPropW, GetShellWindow, GetSubMenu, GetSysColor, GetSysColorBrush, GetSystemMenu, GetSystemMetrics, GetThreadDesktop, GetTitleBarInfo, GetTopWindow, GetUpdatedClipboardFormats, GetUserObjectInformationA, GetUserObjectInformationW, GetWindow, GetWindowDisplayAffinity, GetWindowInfo, GetWindowLongA, GetWindowLongPtrA, GetWindowLongPtrW, GetWindowLongW, GetWindowModuleFileNameA, GetWindowModuleFileNameW, GetWindowPlacement, GetWindowRect, GetWindowTextA, GetWindowTextLengthA, GetWindowTextLengthW, GetWindowTextW, GetWindowThreadProcessId, HiliteMenuItem, InsertMenuA, InsertMenuItemA, InsertMenuItemW, InsertMenuW, InternalGetWindowText, InvalidateRect, IsChild, IsClipboardFormatAvailable, IsDialogMessageA, IsDialogMessageW, IsDlgButtonChecked, IsGUIThread, IsHungAppWindow, IsIconic, IsMenu, IsProcessDPIAware, IsWindow, IsWindowUnicode, IsWindowVisible, IsZoomed, LoadCursorA, LoadCursorFromFileA, LoadCursorFromFileW, LoadCursorW, LoadIconA, LoadIconW, LoadImageA, LoadImageW, LoadMenuA, LoadMenuIndirectA, LoadMenuIndirectW, LoadMenuW, LoadStringA, LoadStringW, LockSetForegroundWindow, LockWorkStation, LogicalToPhysicalPoint, LookupIconIdFromDirectory, LookupIconIdFromDirectoryEx, MapDialogRect, MapWindowPoints, MenuItemFromPoint, MessageBeep, MessageBoxA, MessageBoxIndirectA, MessageBoxIndirectW, MessageBoxW, ModifyMenuA, ModifyMenuW, MonitorFromPoint, MonitorFromRect, MonitorFromWindow, MoveWindow, OpenClipboard, OpenDesktopA, OpenDesktopW, OpenIcon, OpenInputDesktop, OpenWindowStationA, OpenWindowStationW, PhysicalToLogicalPoint, PrivateExtractIconsA, PrivateExtractIconsW, RealChildWindowFromPoint, RealGetWindowClassA, RealGetWindowClassW, RegisterClipboardFormatA, RegisterClipboardFormatW, RegisterHotKey, RegisterShellHookWindow, RegisterWindowMessageA, RegisterWindowMessageW, RemoveClipboardFormatListener, RemoveMenu, RemovePropA, RemovePropW, ScreenToClient, SendDlgItemMessageA, SendDlgItemMessageW, SendMessage, SendMessageA, SendMessageW, SetClipboardData, SetClipboardViewer, SetCursor, SetCursorPos, SetDlgItemInt, SetDlgItemTextA, SetDlgItemTextW, SetForegroundWindow, SetLayeredWindowAttributes, SetMenu, SetMenuDefaultItem, SetMenuInfo, SetMenuItemBitmaps, SetMenuItemInfoA, SetMenuItemInfoW, SetParent, SetPhysicalCursorPos, SetProcessDefaultLayout, SetProcessDPIAware, SetProcessWindowStation, SetPropA, SetPropW, SetSysColors, SetSystemCursor, SetThreadDesktop, SetUserObjectInformationA, SetUserObjectInformationW, SetWindowDisplayAffinity, SetWindowLong, SetWindowLongPtr, SetWindowPlacement, SetWindowPos, SetWindowsHookExA, SetWindowsHookExW, SetWindowTextA, SetWindowTextW, ShowCursor, ShowOwnedPopups, ShowWindow, ShowWindowAsync, ShutdownBlockReasonCreate, ShutdownBlockReasonDestroy, ShutdownBlockReasonQuery, SoundSentry, SwitchDesktop, SwitchToThisWindow, SystemParametersInfoA, SystemParametersInfoW, TileWindows, TrackMouseEvent, TrackPopupMenu, TrackPopupMenuEx, UnhookWindowsHookEx, UnregisterHotKey, UpdateLayeredWindow, UpdateLayeredWindowIndirect, WindowFromPhysicalPoint, WindowFromPoint Structures -DEBUGHOOKINFO, KBDLLHOOKSTRUCT, MSLLHOOKSTRUCT, ACCESSTIMEOUT, ANIMATIONINFO, AUDIODESCRIPTION, FILTERKEYS, HELPINFO, HIGHCONTRAST, ICONMETRICS, MINIMIZEDMETRICS, MOUSEKEYS, NONCLIENTMETRICS, SERIALKEYS, SOUNDSENTRY, STICKYKEYS, TOGGLEKEYS, TOUCHPREDICTIONPARAMETERS, USEROBJECTFLAGS, DLGITEMTEMPLATE, DLGTEMPLATE, MINMAXINFO, MENUEX_TEMPLATE_HEADER, MENUEX_TEMPLATE_ITEM, MENUITEMTEMPLATE, MENUITEMTEMPLATEHEADER, TPMPARAMS, MONITORINFO, MONITORINFOEX, GRPICONDIR, GRPICONDIRENTRY, ALTTABINFO, CHANGEFILTERSTRUCT, TITLEBARINFO, WINDOWINFO, WINDOWPLACEMENT +METAFILEPICT, CBT_CREATEWND, CBTACTIVATESTRUCT, CWPRETSTRUCT, CWPSTRUCT, DEBUGHOOKINFO, EVENTMSG, HHOOK, KBDLLHOOKSTRUCT, MOUSEHOOKSTRUCT, MOUSEHOOKSTRUCTEX, MSLLHOOKSTRUCT, TRACKMOUSEEVENT, ACCESSTIMEOUT, ANIMATIONINFO, AUDIODESCRIPTION, FILTERKEYS, HELPINFO, HIGHCONTRAST, ICONMETRICS, MINIMIZEDMETRICS, MOUSEKEYS, MSGBOXPARAMS, NONCLIENTMETRICS, SERIALKEYS, SOUNDSENTRY, STICKYKEYS, TOGGLEKEYS, TOUCHPREDICTIONPARAMETERS, ICONINFO, NMHDR, CURSORINFO, USEROBJECTFLAGS, DLGITEMTEMPLATE, DLGTEMPLATE, MINMAXINFO, WINDOWPOS, ICONINFOEX, MDINEXTMENU, MENUBARINFO, MENUEX_TEMPLATE_HEADER, MENUEX_TEMPLATE_ITEM, MENUGETOBJECTINFO, MENUINFO, MENUITEMINFO, MENUITEMTEMPLATE, MENUITEMTEMPLATEHEADER, TPMPARAMS, MONITORINFO, MONITORINFOEX, GRPICONDIR, GRPICONDIRENTRY, ALTTABINFO, CHANGEFILTERSTRUCT, GUITHREADINFO, TITLEBARINFO, UPDATELAYEREDWINDOWINFO, WINDOWINFO, WINDOWPLACEMENT latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/UxTheme/CorrelationReport.md b/PInvoke/UxTheme/CorrelationReport.md index c71f56eb..c6b70d6a 100644 --- a/PInvoke/UxTheme/CorrelationReport.md +++ b/PInvoke/UxTheme/CorrelationReport.md @@ -86,6 +86,8 @@ Native Structure | Header | Managed Structure [BP_PAINTPARAMS](http://msdn2.microsoft.com/en-us/library/bb773228) | Uxtheme.h | Vanara.PInvoke.UxTheme+BP_PAINTPARAMS [DTBGOPTS](http://msdn2.microsoft.com/en-us/library/bb773233) | Uxtheme.h | Vanara.PInvoke.UxTheme+DTBGOPTS [DTTOPTS](http://msdn2.microsoft.com/en-us/library/bb773236) | Uxtheme.h | Vanara.PInvoke.UxTheme+DTTOPTS +[HANIMATIONBUFFER](https://www.google.com/search?num=5&q=HANIMATIONBUFFER+site%3Amicrosoft.com) | | Vanara.PInvoke.UxTheme+HANIMATIONBUFFER +[HPAINTBUFFER](https://www.google.com/search?num=5&q=HPAINTBUFFER+site%3Amicrosoft.com) | | Vanara.PInvoke.UxTheme+HPAINTBUFFER [INTLIST](http://msdn2.microsoft.com/en-us/library/bb773240) | UxTheme.h | Vanara.PInvoke.UxTheme+INTLIST [MARGINS](http://msdn2.microsoft.com/en-us/library/bb773244) | UxTheme.h | Vanara.PInvoke.UxTheme+MARGINS [TA_TIMINGFUNCTION](https://www.google.com/search?num=5&q=TA_TIMINGFUNCTION+site%3Amicrosoft.com) | | Vanara.PInvoke.UxTheme+TA_TIMINGFUNCTION diff --git a/PInvoke/UxTheme/Vanara.PInvoke.UxTheme.csproj b/PInvoke/UxTheme/Vanara.PInvoke.UxTheme.csproj index aa7102e7..860642e0 100644 --- a/PInvoke/UxTheme/Vanara.PInvoke.UxTheme.csproj +++ b/PInvoke/UxTheme/Vanara.PInvoke.UxTheme.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from UxTheme.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.PInvoke.UxTheme $(AssemblyName) @@ -28,10 +28,12 @@ Functions BeginBufferedAnimation, BeginBufferedPaint, BeginPanningFeedback, BufferedPaintClear, BufferedPaintInit, BufferedPaintRenderAnimation, BufferedPaintSetAlpha, BufferedPaintStopAllAnimations, BufferedPaintUnInit, CloseThemeData, DrawThemeBackground, DrawThemeBackgroundEx, DrawThemeEdge, DrawThemeIcon, DrawThemeParentBackground, DrawThemeParentBackgroundEx, DrawThemeText, DrawThemeTextEx, EnableThemeDialogTexture, EnableTheming, EndBufferedAnimation, EndBufferedPaint, EndPanningFeedback, GetBufferedPaintBits, GetBufferedPaintDC, GetBufferedPaintTargetDC, GetBufferedPaintTargetRect, GetCurrentThemeName, GetThemeAnimationProperty, GetThemeAnimationTransform, GetThemeAppProperties, GetThemeBackgroundContentRect, GetThemeBackgroundExtent, GetThemeBackgroundRegion, GetThemeBitmap, GetThemeBool, GetThemeColor, GetThemeDocumentationProperty, GetThemeEnumValue, GetThemeFilename, GetThemeFont, GetThemeInt, GetThemeIntList, GetThemeMargins, GetThemeMetric, GetThemePartSize, GetThemePosition, GetThemePropertyOrigin, GetThemeRect, GetThemeStream, GetThemeString, GetThemeSysBool, GetThemeSysColor, GetThemeSysColorBrush, GetThemeSysFont, GetThemeSysInt, GetThemeSysSize, GetThemeSysString, GetThemeTextExtent, GetThemeTextMetrics, GetThemeTimingFunction, GetThemeTransitionDuration, GetWindowTheme, HitTestThemeBackground, IsAppThemed, IsCompositionActive, IsThemeActive, IsThemeBackgroundPartiallyTransparent, IsThemeDialogTextureEnabled, IsThemePartDefined, OpenThemeData, OpenThemeDataEx, OpenThemeDataForDpi, SetThemeAppProperties, SetWindowTheme, SetWindowThemeAttribute, UpdatePanningFeedback Structures -DTTOPTS, INTLIST, MARGINS, TA_TIMINGFUNCTION, TA_TRANSFORM, WTA_OPTIONS, DTBGOPTS, BP_ANIMATIONPARAMS, BP_PAINTPARAMS +DTTOPTS, INTLIST, MARGINS, TA_TIMINGFUNCTION, TA_TRANSFORM, WTA_OPTIONS, DTBGOPTS, BP_ANIMATIONPARAMS, HANIMATIONBUFFER, HPAINTBUFFER, BP_PAINTPARAMS latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/VirtDisk/CorrelationReport.md b/PInvoke/VirtDisk/CorrelationReport.md index d6c8c2c9..ac222948 100644 --- a/PInvoke/VirtDisk/CorrelationReport.md +++ b/PInvoke/VirtDisk/CorrelationReport.md @@ -75,5 +75,6 @@ Native Structure | Header | Managed Structure [STORAGE_DEPENDENCY_INFO_TYPE_2](https://www.google.com/search?num=5&q=STORAGE_DEPENDENCY_INFO_TYPE_2+site%3Amicrosoft.com) | VirtDisk.h | Vanara.PInvoke.VirtDisk+STORAGE_DEPENDENCY_INFO_TYPE_2 [TAKE_SNAPSHOT_VHDSET_PARAMETERS](https://www.google.com/search?num=5&q=TAKE_SNAPSHOT_VHDSET_PARAMETERS+site%3Amicrosoft.com) | VirtDisk.h | Vanara.PInvoke.VirtDisk+TAKE_SNAPSHOT_VHDSET_PARAMETERS [TAKE_SNAPSHOT_VHDSET_PARAMETERS_Version1](https://www.google.com/search?num=5&q=TAKE_SNAPSHOT_VHDSET_PARAMETERS_Version1+site%3Amicrosoft.com) | VirtDisk.h | Vanara.PInvoke.VirtDisk+TAKE_SNAPSHOT_VHDSET_PARAMETERS+TAKE_SNAPSHOT_VHDSET_PARAMETERS_Version1 +[VIRTUAL_DISK_HANDLE](https://www.google.com/search?num=5&q=VIRTUAL_DISK_HANDLE+site%3Amicrosoft.com) | | Vanara.PInvoke.VirtDisk+VIRTUAL_DISK_HANDLE [VIRTUAL_DISK_PROGRESS](https://www.google.com/search?num=5&q=VIRTUAL_DISK_PROGRESS+site%3Amicrosoft.com) | VirtDisk.h | Vanara.PInvoke.VirtDisk+VIRTUAL_DISK_PROGRESS [VIRTUAL_STORAGE_TYPE](https://www.google.com/search?num=5&q=VIRTUAL_STORAGE_TYPE+site%3Amicrosoft.com) | VirtDisk.h | Vanara.PInvoke.VirtDisk+VIRTUAL_STORAGE_TYPE diff --git a/PInvoke/VirtDisk/Vanara.PInvoke.VirtDisk.csproj b/PInvoke/VirtDisk/Vanara.PInvoke.VirtDisk.csproj index 186801a8..5ba34423 100644 --- a/PInvoke/VirtDisk/Vanara.PInvoke.VirtDisk.csproj +++ b/PInvoke/VirtDisk/Vanara.PInvoke.VirtDisk.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from VirtDisk.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.VirtDisk $(AssemblyName) @@ -28,10 +28,12 @@ Functions AddVirtualDiskParent, ApplySnapshotVhdSet, AttachVirtualDisk, BreakMirrorVirtualDisk, CompactVirtualDisk, CreateVirtualDisk, DeleteSnapshotVhdSet, DeleteVirtualDiskMetadata, DetachVirtualDisk, EnumerateVirtualDiskMetadata, ExpandVirtualDisk, GetAllAttachedVirtualDiskPhysicalPaths, GetStorageDependencyInformation, GetVirtualDiskInformation, GetVirtualDiskMetadata, GetVirtualDiskOperationProgress, GetVirtualDiskPhysicalPath, MergeVirtualDisk, MirrorVirtualDisk, ModifyVhdSet, OpenVirtualDisk, QueryChangesVirtualDisk, RawSCSIVirtualDisk, ResizeVirtualDisk, SetVirtualDiskInformation, SetVirtualDiskMetadata, TakeSnapshotVhdSet Structures -APPLY_SNAPSHOT_VHDSET_PARAMETERS, ATTACH_VIRTUAL_DISK_PARAMETERS, COMPACT_VIRTUAL_DISK_PARAMETERS, CREATE_VIRTUAL_DISK_PARAMETERS, DELETE_SNAPSHOT_VHDSET_PARAMETERS, EXPAND_VIRTUAL_DISK_PARAMETERS, GET_VIRTUAL_DISK_INFO, MERGE_VIRTUAL_DISK_PARAMETERS, MIRROR_VIRTUAL_DISK_PARAMETERS, QUERY_CHANGES_VIRTUAL_DISK_RANGE, RAW_SCSI_VIRTUAL_DISK_PARAMETERS, RAW_SCSI_VIRTUAL_DISK_RESPONSE, RESIZE_VIRTUAL_DISK_PARAMETERS, STORAGE_DEPENDENCY_INFO, STORAGE_DEPENDENCY_INFO_TYPE_1, STORAGE_DEPENDENCY_INFO_TYPE_2, TAKE_SNAPSHOT_VHDSET_PARAMETERS, VIRTUAL_DISK_PROGRESS, VIRTUAL_STORAGE_TYPE, OPEN_VIRTUAL_DISK_PARAMETERS, APPLY_SNAPSHOT_VHDSET_PARAMETERS_Version1, ATTACH_VIRTUAL_DISK_PARAMETERS_Version1, COMPACT_VIRTUAL_DISK_PARAMETERS_Version1, CREATE_VIRTUAL_DISK_PARAMETERS_Version1, CREATE_VIRTUAL_DISK_PARAMETERS_Version2, CREATE_VIRTUAL_DISK_PARAMETERS_Version3, DELETE_SNAPSHOT_VHDSET_PARAMETERS_Version1, EXPAND_VIRTUAL_DISK_PARAMETERS_Version1, GET_VIRTUAL_DISK_INFO_ChangeTrackingState, GET_VIRTUAL_DISK_INFO_ParentLocation, GET_VIRTUAL_DISK_INFO_PhysicalDisk, GET_VIRTUAL_DISK_INFO_Size, MERGE_VIRTUAL_DISK_PARAMETERS_V1, MERGE_VIRTUAL_DISK_PARAMETERS_V2, MIRROR_VIRTUAL_DISK_PARAMETERS_Version1, MODIFY_VHDSET_PARAMETERS_Version1_SnapshotPath, RAW_SCSI_VIRTUAL_DISK_PARAMETERS_Version1, RAW_SCSI_VIRTUAL_DISK_RESPONSE_Version1, RESIZE_VIRTUAL_DISK_PARAMETERS_Version1, SET_VIRTUAL_DISK_INFO_ParentLocator, SET_VIRTUAL_DISK_INFO_ParentPathWithDepthInfo, TAKE_SNAPSHOT_VHDSET_PARAMETERS_Version1, OPEN_VIRTUAL_DISK_PARAMETERS_Version1, OPEN_VIRTUAL_DISK_PARAMETERS_Version2, OPEN_VIRTUAL_DISK_PARAMETERS_Version3 +APPLY_SNAPSHOT_VHDSET_PARAMETERS, ATTACH_VIRTUAL_DISK_PARAMETERS, COMPACT_VIRTUAL_DISK_PARAMETERS, CREATE_VIRTUAL_DISK_PARAMETERS, DELETE_SNAPSHOT_VHDSET_PARAMETERS, EXPAND_VIRTUAL_DISK_PARAMETERS, GET_VIRTUAL_DISK_INFO, MERGE_VIRTUAL_DISK_PARAMETERS, MIRROR_VIRTUAL_DISK_PARAMETERS, QUERY_CHANGES_VIRTUAL_DISK_RANGE, RAW_SCSI_VIRTUAL_DISK_PARAMETERS, RAW_SCSI_VIRTUAL_DISK_RESPONSE, RESIZE_VIRTUAL_DISK_PARAMETERS, STORAGE_DEPENDENCY_INFO, STORAGE_DEPENDENCY_INFO_TYPE_1, STORAGE_DEPENDENCY_INFO_TYPE_2, TAKE_SNAPSHOT_VHDSET_PARAMETERS, VIRTUAL_DISK_HANDLE, VIRTUAL_DISK_PROGRESS, VIRTUAL_STORAGE_TYPE, OPEN_VIRTUAL_DISK_PARAMETERS, APPLY_SNAPSHOT_VHDSET_PARAMETERS_Version1, ATTACH_VIRTUAL_DISK_PARAMETERS_Version1, COMPACT_VIRTUAL_DISK_PARAMETERS_Version1, CREATE_VIRTUAL_DISK_PARAMETERS_Version1, CREATE_VIRTUAL_DISK_PARAMETERS_Version2, CREATE_VIRTUAL_DISK_PARAMETERS_Version3, DELETE_SNAPSHOT_VHDSET_PARAMETERS_Version1, EXPAND_VIRTUAL_DISK_PARAMETERS_Version1, GET_VIRTUAL_DISK_INFO_ChangeTrackingState, GET_VIRTUAL_DISK_INFO_ParentLocation, GET_VIRTUAL_DISK_INFO_PhysicalDisk, GET_VIRTUAL_DISK_INFO_Size, MERGE_VIRTUAL_DISK_PARAMETERS_V1, MERGE_VIRTUAL_DISK_PARAMETERS_V2, MIRROR_VIRTUAL_DISK_PARAMETERS_Version1, MODIFY_VHDSET_PARAMETERS_Version1_SnapshotPath, RAW_SCSI_VIRTUAL_DISK_PARAMETERS_Version1, RAW_SCSI_VIRTUAL_DISK_RESPONSE_Version1, RESIZE_VIRTUAL_DISK_PARAMETERS_Version1, SET_VIRTUAL_DISK_INFO_ParentLocator, SET_VIRTUAL_DISK_INFO_ParentPathWithDepthInfo, TAKE_SNAPSHOT_VHDSET_PARAMETERS_Version1, OPEN_VIRTUAL_DISK_PARAMETERS_Version1, OPEN_VIRTUAL_DISK_PARAMETERS_Version2, OPEN_VIRTUAL_DISK_PARAMETERS_Version3 latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/WinINet/Vanara.PInvoke.WinINet.csproj b/PInvoke/WinINet/Vanara.PInvoke.WinINet.csproj index a0254738..53d98b6f 100644 --- a/PInvoke/WinINet/Vanara.PInvoke.WinINet.csproj +++ b/PInvoke/WinINet/Vanara.PInvoke.WinINet.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from WinINet.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.WinINet $(AssemblyName) @@ -32,6 +32,8 @@ HTTP_VERSION_INFO, INTERNET_CACHE_TIMESTAMPS, INTERNET_CERTIFICATE_INFO, INTERNE latest + true + ..\..\Vanara.snk true diff --git a/PInvoke/Ws2_32/Vanara.PInvoke.Ws2_32.csproj b/PInvoke/Ws2_32/Vanara.PInvoke.Ws2_32.csproj index 08c37cec..d2a2d3a2 100644 --- a/PInvoke/Ws2_32/Vanara.PInvoke.Ws2_32.csproj +++ b/PInvoke/Ws2_32/Vanara.PInvoke.Ws2_32.csproj @@ -4,7 +4,7 @@ Methods, structures and constants imported from Ws2_32.dll. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.PInvoke.Ws2_32 $(AssemblyName) @@ -29,6 +29,8 @@ IN_ADDR, IN6_ADDR, SOCKADDR_IN, SOCKADDR_IN6, SOCKADDR_IN6_PAIR, SOCKADDR_INET, latest + true + ..\..\Vanara.snk true diff --git a/README.md b/README.md index 5dfbf6bf..334b4b5f 100644 --- a/README.md +++ b/README.md @@ -20,21 +20,21 @@ All assemblies are available via NuGet and provide builds against .NET 2.0, 3.5, ## Design Concepts I have tried to follow the concepts below in laying out the libraries. -* All functions that are imported from a single DLL should be placed into a single assembly that is named after the DLL +* All functions that are imported from a single DLL should be placed into a single assembly that is named after the DLL. * (e.g. The assembly `Vanara.PInvoke.Gdi32.dll` hosts all functions and supporting enumerations, constants and structures that are exported from `gdi32.dll` in the system directory.) -* Any structure or macro or enumeration (no function) that is used by many libraries is put into either `Vanara.Core` or `Vanara.PInvoke.Shared` +* Any structure or macro or enumeration (no function) that is used by many libraries is put into either `Vanara.Core` or `Vanara.PInvoke.Shared`. * (e.g. The macro `HIWORD` and the structure `SIZE` are both in `Vanara.PInvoke.Shared` and classes to simplfy interop calls and native memory management are in `Vanara.Core`.) -* Inside a project, all constructs are contained in a file named after the header file (*.h) in which they are defined in the Windows API +* Inside a project, all constructs are contained in a file named after the header file (*.h) in which they are defined in the Windows API. * (e.g. In the Vanara.PInvoke.Kernel32 project directory, you'll find a FileApi.cs, a WinBase.cs and a WinNT.cs file representing fileapi.h, winbase.h and winnt.h respectively.) -* Where the direct interpretation of a structure leads to memory leaks or misuse, I have tried to simplify their use +* Where the direct interpretation of a structure leads to memory leaks or misuse, I have tried to simplify their use. * Where structures are always passed by reference and where that structure needs to clean up memory allocations, I have changed the structure to a class implementing `IDisposable`. * Wherever possible, all handles have been turned into `SafeHandle` derivatives named after the Windows API handle. If those handles require a call to a function to release/close/destroy, a derived `SafeHANDLE` exists that performs that function on disposal. - * (e.g. `HTOKEN` is defined. `SafeHTOKEN` builds upon that handle with an automated release calling `CloseHandle`) + * e.g. `HTOKEN` is defined. `SafeHTOKEN` builds upon that handle with an automated release calling `CloseHandle`. * Wherever possible, all functions that allocate memory that is to be freed by the caller use a safe memory handle. -* All PInvoke calls are in assemblies prefixed by `Vanara.PInvoke` -* If a structure is to passed into a function, and the structure is 64 bytes or less, that structure is marshaled using the `LPStruct` type which will pass the structure by reference without requiring the `ref` keyword. +* All PInvoke calls are in assemblies prefixed by `Vanara.PInvoke`. +* If a structure is to passed into a function, that structure is marshaled using the `in` statement which will pass the structure by reference without requiring the `ref` keyword. * Windows API: `BOOL MapDialogRect(HWND hDlg, LPRECT lpRect)` - * Vanara: `bool MapDialogRect(HWND hDlg, [MarshalAs(UnmanagedType.LPStruct)] RECT lpRect);` + * Vanara: `bool MapDialogRect(HWND hDlg, in RECT lpRect);` * If there are classes or extensions that make use of the PInvoke calls, they are in wrapper assemblies prefixed by `Vanara` and then followed by a logical name for the functionality. Today, those are Core, Security, SystemServices, Windows.Forms and Windows.Shell. ## Supported Libraries @@ -49,11 +49,11 @@ Crypt32.dll | [Vanara.PInvoke.Crypt32](https://github.com/dahall/Vanara/blob/mas DwmApi.dll | [Vanara.PInvoke.DwmApi](https://github.com/dahall/Vanara/blob/master/PInvoke/DwmApi/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-100%25-green.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.DwmApi.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.DwmApi) Gdi32.dll | [Vanara.PInvoke.Gdi32](https://github.com/dahall/Vanara/blob/master/PInvoke/Gdi32/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-3%25-red.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.Gdi32.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Gdi32) IpHlpApi.dll | [Vanara.PInvoke.IpHlpApi](https://github.com/dahall/Vanara/blob/master/PInvoke/IpHlpApi/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-57%25-yellow.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.IpHlpApi.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.IpHlpApi) -Kernel32.dll and KernelBase.dll | [Vanara.PInvoke.Kernel32](https://github.com/dahall/Vanara/blob/master/PInvoke/Kernel32/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-100%25-green.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.Kernel32.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Kernel32) +Kernel32.dll and KernelBase.dll | [Vanara.PInvoke.Kernel32](https://github.com/dahall/Vanara/blob/master/PInvoke/Kernel32/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-99%25-green.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.Kernel32.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Kernel32) Mpr.dll | [Vanara.PInvoke.Mpr](https://github.com/dahall/Vanara/blob/master/PInvoke/Mpr/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-100%25-green.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.Mpr.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Mpr) NetApi32.dll | [Vanara.PInvoke.NetApi32](https://github.com/dahall/Vanara/blob/master/PInvoke/NetApi32/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-11%25-red.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.NetApi32.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.NetApi32) NetListMgr.dll | [Vanara.PInvoke.NetListMgr](https://github.com/dahall/Vanara/blob/master/PInvoke/NetListMgr/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-100%25-green.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.NetListMgr.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.NetListMgr) -NTDSApi.dll | [Vanara.PInvoke.NTDSApi](https://github.com/dahall/Vanara/blob/master/PInvoke/NTDSApi/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-57%25-yellow.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.NTDSApi.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.NTDSApi) +NTDSApi.dll | [Vanara.PInvoke.NTDSApi](https://github.com/dahall/Vanara/blob/master/PInvoke/NTDSApi/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-100%25-yellow.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.NTDSApi.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.NTDSApi) NTDll.dll | [Vanara.PInvoke.NTDll](https://github.com/dahall/Vanara/blob/master/PInvoke/NTDll/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-4%25-red.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.NTDll.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.NTDll) Ole32.dll, OleAut32 and PropSys.dll | [Vanara.PInvoke.Ole](https://github.com/dahall/Vanara/blob/master/PInvoke/Ole/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-20%25-red.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.Ole.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Ole) AdvApi32.dll, Authz.dll and Secur32.dll | [Vanara.PInvoke.Security](https://github.com/dahall/Vanara/blob/master/PInvoke/Security/CorrelationReport.md)
![Coverage](https://img.shields.io/badge/coverage-5%25-red.svg) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.Security.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Security) @@ -72,11 +72,11 @@ Ws2_32.dll | [Vanara.PInvoke.Ws2_32](https://github.com/dahall/Vanara/blob/maste Assembly | NuGet Link | Description --- | --- | --- [Vanara.Core](https://github.com/dahall/Vanara/blob/master/Core/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.Core.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.Core) | Shared methods, structures and constants for use throughout the Vanara assemblies. Think of it as windows.h with some useful extensions. -[Vanara.PInvoke.Shared](https://github.com/dahall/Vanara/blob/master/PInvoke/Shared/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.Shared.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Shared) | Shared methods, structures and constants for use throughout the Vanara.PInvoke assemblies -[Vanara.Security](https://github.com/dahall/Vanara/blob/master/Security/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.Security.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.Security) | Wrapper classes for security related items in the PInvoke libraries -[Vanara.SystemServices](https://github.com/dahall/Vanara/blob/master/System/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.SystemServices.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.SystemServices) | Wrapper classes for system related items in the PInvoke libraries +[Vanara.PInvoke.Shared](https://github.com/dahall/Vanara/blob/master/PInvoke/Shared/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.PInvoke.Shared.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Shared) | Shared methods, structures and constants for use throughout the Vanara.PInvoke assemblies. +[Vanara.Security](https://github.com/dahall/Vanara/blob/master/Security/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.Security.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.Security) | Classes for Windows Security that are missing or incomplete in .NET. Includes claims, privileges, impersonation, Active Directory, and UAC. +[Vanara.SystemServices](https://github.com/dahall/Vanara/blob/master/System/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.SystemServices.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.SystemServices) | Classes for Windows system functions. Includes Background Transfer (BITS), Virtual Disk management, WOW64 interaction, and file, process, path, networking and service controller extensions. [Vanara.Windows.Forms](https://github.com/dahall/Vanara/blob/master/WIndows.Forms/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.Windows.Forms.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.Windows.Forms) | Classes for user interface related items derived from the Vanara PInvoke libraries. Includes extensions for almost all common controls to give post Vista capabilities, WinForms controls (panel, commandlink, enhanced combo boxes, IPAddress, split button, trackbar and themed controls), shutdown/restart/lock control, buffered painting, resource files, access control editor, simplified designer framework for Windows.Forms. -[Vanara.Windows.Shell](https://github.com/dahall/Vanara/blob/master/Windows.Shell/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.Windows.Shell.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.Windows.Shell) | Classes for Windows Shell items derived from the Vanara PInvoke libraries. Includes shell items, files, icons, links, and taskbar lists. +[Vanara.Windows.Shell](https://github.com/dahall/Vanara/blob/master/Windows.Shell/AssemblyReport.md) | [![NuGet Package](https://img.shields.io/nuget/v/Vanara.Windows.Shell.svg?style=flat-square)](https://www.nuget.org/packages/Vanara.Windows.Shell) | Classes for Windows Shell items derived from the Vanara PInvoke libraries. Includes shell items, files, icons, links, shell properties, shell registration and taskbar lists. ## Quick Links * [Documentation](https://github.com/dahall/Vanara/wiki) diff --git a/Security/Vanara.Security.csproj b/Security/Vanara.Security.csproj index 382bb7ed..805dcc79 100644 --- a/Security/Vanara.Security.csproj +++ b/Security/Vanara.Security.csproj @@ -4,7 +4,7 @@ Classes for security related items derived from the Vanara PInvoke libraries. Includes extension methods for Active Directory and access control classes, methods for working with accounts, UAC, privileges, system access, impersonation and SIDs, and a full LSA wrapper. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.Security $(AssemblyName) @@ -30,6 +30,8 @@ AccountLogonRights, DesiredAccess, SystemPrivilege latest + true + ..\Vanara.snk
true diff --git a/System/Vanara.SystemServices.csproj b/System/Vanara.SystemServices.csproj index fef3f131..3b61c467 100644 --- a/System/Vanara.SystemServices.csproj +++ b/System/Vanara.SystemServices.csproj @@ -4,7 +4,7 @@ Classes for system related items derived from the Vanara PInvoke libraries. Includes a class for working with virtual disks (including async methods), classes for BITS, and extensions for Process (privileges and elavation), FileInfo (compression info), and ServiceController (SetStartType) that pull extended information through native API calls. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45;netstandard2.0 Vanara.SystemServices $(AssemblyName) @@ -33,6 +33,8 @@ BackgroundCopyACLFlags, BackgroundCopyCost, BackgroundCopyErrorContext, Backgrou latest + true + ..\Vanara.snk true diff --git a/UnitTests/PInvoke/BCrypt/BCryptTests.cs b/UnitTests/PInvoke/BCrypt/BCryptTests.cs new file mode 100644 index 00000000..6cbfd43d --- /dev/null +++ b/UnitTests/PInvoke/BCrypt/BCryptTests.cs @@ -0,0 +1,297 @@ +using NUnit.Framework; +using System; +using System.Linq; +using System.Runtime.InteropServices; +using Vanara.InteropServices; +using static Vanara.PInvoke.BCrypt; +using static Vanara.PInvoke.Kernel32; +using static Vanara.PInvoke.NCrypt; + +namespace Vanara.PInvoke.Tests +{ + [TestFixture()] + public class BCryptTests + { + [Test] + public void ContextTest() + { + const string ctx = "Private"; + const string func = StandardAlgorithmId.BCRYPT_SHA256_ALGORITHM; + const string propName = "Test"; + object propVal = 255; + + var err = BCryptCreateContext(ContextConfigTable.CRYPT_LOCAL, ctx); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + try + { + err = BCryptQueryContextConfiguration(ContextConfigTable.CRYPT_LOCAL, ctx, out var _, out var buf); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + var ctxcfg = buf.ToStructure(); + Assert.That((int)ctxcfg.dwFlags, Is.Zero); + + err = BCryptConfigureContext(ContextConfigTable.CRYPT_LOCAL, ctx, new CRYPT_CONTEXT_CONFIG { dwFlags = ContextConfigFlags.CRYPT_EXCLUSIVE }); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + err = BCryptQueryContextConfiguration(ContextConfigTable.CRYPT_LOCAL, ctx, out var _, out buf); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + ctxcfg = buf.ToStructure(); + Assert.That(ctxcfg.dwFlags, Is.EqualTo(ContextConfigFlags.CRYPT_EXCLUSIVE)); + + err = BCryptAddContextFunction(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE, func, CryptPriority.CRYPT_PRIORITY_TOP); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + string[] funcs = null; + Assert.That(() => funcs = BCryptEnumContextFunctions(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE), Throws.Nothing); + Assert.That(funcs.Length, Is.EqualTo(1)); + Assert.That(funcs[0], Is.EqualTo(func)); + + err = BCryptQueryContextFunctionConfiguration(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE, func, out var _, out buf); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_NOT_FOUND)); + + err = BCryptConfigureContextFunction(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE, func, new CRYPT_CONTEXT_FUNCTION_CONFIG { dwFlags = ContextConfigFlags.CRYPT_EXCLUSIVE }); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + var propMem = SafeCoTaskMemHandle.CreateFromStructure(propVal); + err = BCryptSetContextFunctionProperty(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE, func, propName, (uint)propMem.Size, propMem); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + err = BCryptQueryContextFunctionProperty(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE, func, propName, out var _, out buf); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + var propRes = buf.ToStructure(); + Assert.That(propRes, Is.EqualTo(propVal)); + + err = BCryptQueryContextFunctionConfiguration(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE, func, out var _, out buf); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + var fcfg = buf.ToStructure(); + Assert.That(fcfg.dwFlags, Is.EqualTo(ContextConfigFlags.CRYPT_EXCLUSIVE)); + + err = BCryptRemoveContextFunction(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE, func); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + } + finally + { + err = BCryptDeleteContext(ContextConfigTable.CRYPT_LOCAL, ctx); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + } + } + + [Test] + public void CreateHashTest() + { + var err = BCryptOpenAlgorithmProvider(out var hAlg, StandardAlgorithmId.BCRYPT_SHA256_ALGORITHM); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + var cbHashObject = BCryptGetProperty(hAlg, BCrypt.PropertyName.BCRYPT_OBJECT_LENGTH); + Assert.That(cbHashObject, Is.GreaterThan(0)); + + var cbHash = BCryptGetProperty(hAlg, BCrypt.PropertyName.BCRYPT_HASH_LENGTH); + Assert.That(cbHash, Is.GreaterThan(0)); + + var pbHashObject = new SafeHeapBlock((int)cbHashObject); + var pbHash = new SafeHeapBlock((int)cbHash); + err = BCryptCreateHash(hAlg, out var hHash, pbHashObject, cbHashObject); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + var pbDupHashObj = new SafeCoTaskMemHandle((int)cbHashObject); + err = BCryptDuplicateHash(hHash, out var hDupHash, pbDupHashObj, cbHashObject); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + var rgbMsg = new byte[] { 0x61, 0x62, 0x63 }; + err = BCryptHashData(hHash, rgbMsg, (uint)rgbMsg.Length, 0); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + err = BCryptFinishHash(hHash, pbHash, cbHash); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + } + + [Test] + public void EncryptTest() + { + byte[] rgbPlaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] rgbIV = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] rgbAES128Key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + + var err = BCryptOpenAlgorithmProvider(out var hAlg, StandardAlgorithmId.BCRYPT_AES_ALGORITHM); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + var cbKeyObject = BCryptGetProperty(hAlg, BCrypt.PropertyName.BCRYPT_OBJECT_LENGTH); + Assert.That(cbKeyObject, Is.GreaterThan(0)); + + var cbBlockLen = BCryptGetProperty(hAlg, BCrypt.PropertyName.BCRYPT_BLOCK_LENGTH); + Assert.That(cbBlockLen, Is.GreaterThan(0)); + Assert.That(cbBlockLen, Is.LessThanOrEqualTo(rgbIV.Length)); + + var cm = System.Text.Encoding.Unicode.GetBytes(ChainingMode.BCRYPT_CHAIN_MODE_CBC); + err = BCryptSetProperty(hAlg, BCrypt.PropertyName.BCRYPT_CHAINING_MODE, cm, (uint)cm.Length); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + var pbKeyObject = new SafeCoTaskMemHandle((int)cbKeyObject); + err = BCryptGenerateSymmetricKey(hAlg, out var hKey, pbKeyObject, cbKeyObject, rgbAES128Key, (uint)rgbAES128Key.Length, 0); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + err = BCryptExportKey(hKey, default, BlobType.BCRYPT_OPAQUE_KEY_BLOB, IntPtr.Zero, 0, out var cbBlob); + Assert.That(cbBlob, Is.GreaterThan(0)); + + var pbBlob = new SafeCoTaskMemHandle((int)cbBlob); + err = BCryptExportKey(hKey, default, BlobType.BCRYPT_OPAQUE_KEY_BLOB, pbBlob, (uint)pbBlob.Size, out cbBlob); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + var pbIV = new SafeCoTaskMemHandle((int)cbBlockLen); + Marshal.Copy(rgbIV, 0, (IntPtr)pbIV, (int)cbBlockLen); + err = BCryptEncrypt(hKey, rgbPlaintext, (uint)rgbPlaintext.Length, IntPtr.Zero, pbIV, cbBlockLen, IntPtr.Zero, 0, out var cbCipherText, EncryptFlags.BCRYPT_BLOCK_PADDING); + Assert.That(cbCipherText, Is.GreaterThan(0)); + + var pbCipherText = new SafeCoTaskMemHandle((int)cbCipherText); + err = BCryptEncrypt(hKey, rgbPlaintext, (uint)rgbPlaintext.Length, IntPtr.Zero, pbIV, cbBlockLen, pbCipherText, cbCipherText, out cbCipherText, EncryptFlags.BCRYPT_BLOCK_PADDING); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + Marshal.Copy(rgbIV, 0, (IntPtr)pbIV, (int)cbBlockLen); + + err = BCryptImportKey(hAlg, default, BlobType.BCRYPT_OPAQUE_KEY_BLOB, out var hKey2, pbKeyObject, cbKeyObject, pbBlob, cbBlob); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + err = BCryptDecrypt(hKey2, pbCipherText, cbCipherText, IntPtr.Zero, pbIV, cbBlockLen, IntPtr.Zero, 0, out var cbPlainText, EncryptFlags.BCRYPT_BLOCK_PADDING); + Assert.That(cbPlainText, Is.GreaterThan(0)); + + var pbPlainText = new SafeCoTaskMemHandle((int)cbPlainText); + err = BCryptDecrypt(hKey2, pbCipherText, cbCipherText, IntPtr.Zero, pbIV, cbBlockLen, pbPlainText, cbPlainText, out cbPlainText, EncryptFlags.BCRYPT_BLOCK_PADDING); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + Assert.That(pbPlainText.ToArray(rgbPlaintext.Length), Is.EquivalentTo(rgbPlaintext)); + } + + [Test] + public void EnumTests() + { + var a = BCryptEnumAlgorithms((AlgOperations)0x3F); + Assert.That(a.Length, Is.Not.Zero); + TestContext.WriteLine("Alg: " + string.Join(", ", a.Select(s => $"{s.pszName} ({s.dwClass})"))); + + var c = BCryptEnumContexts(ContextConfigTable.CRYPT_LOCAL); + Assert.That(c.Length, Is.Not.Zero); + TestContext.WriteLine("Ctx: " + string.Join(", ", c)); + var ctx = c[0]; + + var p = BCryptEnumProviders(StandardAlgorithmId.BCRYPT_SHA256_ALGORITHM); + Assert.That(p.Length, Is.Not.Zero); + TestContext.WriteLine("Prov: " + string.Join(", ", p)); + + var f = BCryptEnumContextFunctions(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE); + Assert.That(p.Length, Is.Not.Zero); + TestContext.WriteLine("Func: " + string.Join(", ", f)); + var func = f[0]; + + var fp = BCryptEnumContextFunctionProviders(ContextConfigTable.CRYPT_LOCAL, ctx, InterfaceId.BCRYPT_HASH_INTERFACE, func); + Assert.That(fp.Length, Is.Not.Zero); + TestContext.WriteLine("FuncProv: " + string.Join(", ", fp)); + + var r = BCryptEnumRegisteredProviders(); + Assert.That(r.Length, Is.Not.Zero); + TestContext.WriteLine("RegProv: " + string.Join(", ", r)); + } + + [Test] + public void SecretAgreementWithPersistedKeysTest() + { + const string keyName = "Sample ECDH Key"; + byte[] SecretPrependArray = { 0x12, 0x34, 0x56 }; + byte[] SecretAppendArray = { 0xab, 0xcd, 0xef }; + + // Get a handle to MS KSP + var hr = NCryptOpenStorageProvider(out var ProviderHandleA, KnownStorageProvider.MS_KEY_STORAGE_PROVIDER); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + // Delete existing keys + hr = NCryptOpenKey(ProviderHandleA, out var PrivKeyHandleA, keyName); + if (hr.Succeeded) + { + hr = NCryptDeleteKey(PrivKeyHandleA, 0); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + PrivKeyHandleA = null; + } + + // A generates a private key + hr = NCryptCreatePersistedKey(ProviderHandleA, out PrivKeyHandleA, StandardAlgorithmId.BCRYPT_ECDH_P256_ALGORITHM, keyName); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + // Make the key exportable + var KeyPolicy = BitConverter.GetBytes((uint)ExportPolicy.NCRYPT_ALLOW_EXPORT_FLAG); + hr = NCryptSetProperty(PrivKeyHandleA, NCrypt.PropertyName.NCRYPT_EXPORT_POLICY_PROPERTY, KeyPolicy, (uint)KeyPolicy.Length, SetPropFlags.NCRYPT_PERSIST_FLAG); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + hr = NCryptFinalizeKey(PrivKeyHandleA); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + // A exports public key + hr = NCryptExportKey(PrivKeyHandleA, default, BlobType.BCRYPT_ECCPUBLIC_BLOB, pcbResult: out var PubBlobLengthA); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + var PubBlobA = new SafeCoTaskMemHandle((int)PubBlobLengthA); + hr = NCryptExportKey(PrivKeyHandleA, default, BlobType.BCRYPT_ECCPUBLIC_BLOB, null, PubBlobA, PubBlobLengthA, out PubBlobLengthA); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + // B generates a private key + var err = BCryptOpenAlgorithmProvider(out var ExchAlgHandleB, StandardAlgorithmId.BCRYPT_ECDH_P256_ALGORITHM, KnownProvider.MS_PRIMITIVE_PROVIDER); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + err = BCryptGenerateKeyPair(ExchAlgHandleB, out var PrivKeyHandleB, 256); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + err = BCryptFinalizeKeyPair(PrivKeyHandleB); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + // B exports public key + err = BCryptExportKey(PrivKeyHandleB, default, BlobType.BCRYPT_ECCPUBLIC_BLOB, pcbResult: out var PubBlobLengthB); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + var PubBlobB = new SafeCoTaskMemHandle((int)PubBlobLengthB); + err = BCryptExportKey(PrivKeyHandleB, default, BlobType.BCRYPT_ECCPUBLIC_BLOB, PubBlobB, PubBlobLengthB, out PubBlobLengthB); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + // A imports B's public key + hr = NCryptImportKey(ProviderHandleA, default, BlobType.BCRYPT_ECCPUBLIC_BLOB, null, out var PubKeyHandleA, PubBlobB, PubBlobLengthB); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + // A generates the agreed secret + hr = NCryptSecretAgreement(PrivKeyHandleA, PubKeyHandleA, out var AgreedSecretHandleA); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + // Build KDF parameter list Specify hash algorithm, secret to append and secret to prepend + var ParameterList = new NCryptBufferDesc + { + pBuffers = new[] { + new NCryptBuffer(BufferType.KDF_HASH_ALGORITHM, StandardAlgorithmId.BCRYPT_SHA256_ALGORITHM), + new NCryptBuffer(BufferType.KDF_SECRET_APPEND, SecretAppendArray), + new NCryptBuffer(BufferType.KDF_SECRET_PREPEND, SecretPrependArray) } + }; + + hr = NCryptDeriveKey(AgreedSecretHandleA, KDF.BCRYPT_KDF_HMAC, ParameterList, IntPtr.Zero, 0, out var AgreedSecretLengthA, DeriveKeyFlags.KDF_USE_SECRET_AS_HMAC_KEY_FLAG); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + var AgreedSecretA = new SafeCoTaskMemHandle((int)AgreedSecretLengthA); + hr = NCryptDeriveKey(AgreedSecretHandleA, KDF.BCRYPT_KDF_HMAC, ParameterList, AgreedSecretA, AgreedSecretLengthA, out AgreedSecretLengthA, DeriveKeyFlags.KDF_USE_SECRET_AS_HMAC_KEY_FLAG); + Assert.That((int)hr, Is.EqualTo(HRESULT.S_OK)); + + // B imports A's public key + err = BCryptImportKeyPair(ExchAlgHandleB, default, BlobType.BCRYPT_ECCPUBLIC_BLOB, out var PubKeyHandleB, PubBlobA, PubBlobLengthA); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + // B generates the agreed secret + err = BCryptSecretAgreement(PrivKeyHandleB, PubKeyHandleB, out var AgreedSecretHandleB); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + err = BCryptDeriveKey(AgreedSecretHandleB, KDF.BCRYPT_KDF_HMAC, ParameterList, IntPtr.Zero, 0, out var AgreedSecretLengthB, DeriveKeyFlags.KDF_USE_SECRET_AS_HMAC_KEY_FLAG); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + var AgreedSecretB = new SafeCoTaskMemHandle((int)AgreedSecretLengthB); + err = BCryptDeriveKey(AgreedSecretHandleB, KDF.BCRYPT_KDF_HMAC, ParameterList, AgreedSecretB, AgreedSecretLengthB, out AgreedSecretLengthB, DeriveKeyFlags.KDF_USE_SECRET_AS_HMAC_KEY_FLAG); + Assert.That((uint)err, Is.EqualTo(NTStatus.STATUS_SUCCESS)); + + // At this point the AgreedSecretA should be the same as AgreedSecretB. In a real scenario, the agreed secrets on both sides will + // probably be input to a BCryptGenerateSymmetricKey function. Optional : Compare them + Assert.That(AgreedSecretLengthA, Is.EqualTo(AgreedSecretLengthB)); + Assert.That(AgreedSecretA.ToEnumerable(AgreedSecretA.Size), Is.EquivalentTo(AgreedSecretB.ToEnumerable(AgreedSecretB.Size))); + } + } +} \ No newline at end of file diff --git a/UnitTests/PInvoke/NTDSApi/NTDSApiTests.cs b/UnitTests/PInvoke/NTDSApi/NTDSApiTests.cs index 4083f1b1..fa461ca4 100644 --- a/UnitTests/PInvoke/NTDSApi/NTDSApiTests.cs +++ b/UnitTests/PInvoke/NTDSApi/NTDSApiTests.cs @@ -1,4 +1,6 @@ using NUnit.Framework; +using System; +using System.DirectoryServices; using System.Linq; using System.Text; using static Vanara.PInvoke.NTDSApi; @@ -8,6 +10,16 @@ namespace Vanara.PInvoke.Tests [TestFixture()] public class NTDSApiTests { + public SafeDsHandle hDs; + public string dn; + + [OneTimeSetUp] + public void Setup() + { + dn = System.Environment.UserDomainName; + DsBind(null, dn, out hDs).ThrowIfFailed(); + } + [Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.AuthCasesFromFile))] public void DsBindTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes) { @@ -16,6 +28,18 @@ namespace Vanara.PInvoke.Tests Assert.That(DsBind(null, dn, out var dsb2).Succeeded && !dsb2.IsInvalid, Is.EqualTo(validUser)); } + [Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.AuthCasesFromFile))] + public void DsBindByInstanceTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes) + { + Assert.That(DsBindByInstance(DnsDomainName: dn, AuthIdentity: SafeAuthIdentityHandle.LocalThreadIdentity, phDS: out var dsb).Succeeded && !dsb.IsInvalid, Is.EqualTo(validUser)); + } + + [Test] + public void DsBindToISTGTest() + { + Assert.That(DsBindToISTG(null, out var dsb).Succeeded && !dsb.IsInvalid, Is.True); + } + [Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.AuthCasesFromFile))] public void DsBindWithCredTest(bool validUser, bool validCred, string urn, string dn, string dcn, string domain, string un, string pwd, string notes) { @@ -33,8 +57,7 @@ namespace Vanara.PInvoke.Tests [Test, TestCaseSource(typeof(AdvApi32Tests), nameof(AdvApi32Tests.AuthCasesFromFile))] public void DsCrackNamesTest(bool validUser, bool validCred, string urn, string dn, string dc, string domain, string un, string pwd, string notes) { - DsBind(null, null, out var dsb).ThrowIfFailed(); - var res = DsCrackNames(dsb, new[] {un}, DS_NAME_FORMAT.DS_NT4_ACCOUNT_NAME); + var res = DsCrackNames(hDs, new[] {un}, DS_NAME_FORMAT.DS_NT4_ACCOUNT_NAME); Assert.That(res, Has.Exactly(1).Items); for (var i = 0; i < res.Length; i++) TestContext.WriteLine($"{i}) {res[i]}"); @@ -66,13 +89,53 @@ namespace Vanara.PInvoke.Tests [Test] public void DsGetDCInfoTest() { - var dn = System.Environment.UserDomainName; // System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName; - DsBind(null, dn, out var dsb).ThrowIfFailed(); - var ret = DsGetDomainControllerInfo(dsb, dn, 1, out var u1, out var i1); - ret.ThrowIfFailed(); - var s1 = i1.ToIEnum(u1).ToArray(); + DS_DOMAIN_CONTROLLER_INFO_1[] s1 = null; + Assert.That(() => s1 = DsGetDomainControllerInfo(hDs, dn), Throws.Nothing); + Assert.That(s1, Is.Not.Null.And.Property("Length").GreaterThan(0)); Assert.That(s1[0].fDsEnabled); - DsFreeDomainControllerInfo(1, u1, i1); + + DS_DOMAIN_CONTROLLER_INFO_2[] s2 = null; + Assert.That(() => s2 = DsGetDomainControllerInfo(hDs, dn), Throws.Nothing); + Assert.That(s2, Is.Not.Null.And.Property("Length").GreaterThan(0)); + Assert.That(s2[0].fDsEnabled); + + DS_DOMAIN_CONTROLLER_INFO_3[] s3 = null; + Assert.That(() => s3 = DsGetDomainControllerInfo(hDs, dn), Throws.Nothing); + Assert.That(s3, Is.Not.Null.And.Property("Length").GreaterThan(0)); + Assert.That(s3[0].fDsEnabled); + foreach (var i3 in s3) + TestContext.WriteLine($"{(i3.fIsPdc?"PDC":"DC")}{(i3.fIsGc?",GC":"")}{(i3.fIsRodc?",RO":"")}:\t{i3.NetbiosName}\t{i3.DnsHostName}\t{i3.SiteName}\t{i3.SiteObjectName}\t{i3.ComputerObjectName}\t{i3.ServerObjectName}\t{i3.NtdsDsaObjectName}\t{(i3.fDsEnabled?"Enabled":"Disabled")}"); + } + + [Test] + public void DsListRolesTest() + { + TestNameResult((SafeDsHandle h, out SafeDsNameResult nr) => DsListRoles(h, out nr), "Roles"); + } + + [Test] + public void DsListDomainsInSiteTest() + { + var site = TestNameResult((SafeDsHandle h, out SafeDsNameResult nr) => DsListSites(h, out nr), "Sites"); + var dom = TestNameResult((SafeDsHandle h, out SafeDsNameResult nr) => DsListDomainsInSite(h, site, out nr), "Domains"); + var siteserver = TestNameResult((SafeDsHandle h, out SafeDsNameResult nr) => DsListServersInSite(h, site, out nr), "SiteServers"); + var dserver = TestNameResult((SafeDsHandle h, out SafeDsNameResult nr) => DsListServersForDomainInSite(h, dom, site, out nr), "DomServers"); + var item = TestNameResult((SafeDsHandle h, out SafeDsNameResult nr) => DsListInfoForServer(h, dserver, out nr), "SvrInfo"); + } + + private delegate Win32Error NRDel(SafeDsHandle h, out SafeDsNameResult nr); + + private string TestNameResult(NRDel f, string prefix) + { + var err = f(hDs, out var hnr); + Assert.That(err, Is.EqualTo(Win32Error.ERROR_SUCCESS)); + var nrs = hnr.ToArray(); + Assert.That(nrs.Length, Is.Not.Zero); + var nr = nrs[0]; + Assert.That(nr.pName, Is.Not.Null); + TestContext.WriteLine(prefix + ": " + string.Join(", ", nrs)); + TestContext.WriteLine(); + return nr.pName; } [Test] @@ -84,5 +147,45 @@ namespace Vanara.PInvoke.Tests Assert.That(key, Is.EqualTo("dc")); Assert.That(val, Is.EqualTo("corp")); } + + [Test] + public void DsMapSchemaGuidsTest() + { + var guid = new Guid("2BEC133B-AE2B-4C32-A3F5-036149C4E671"); + var err = DsMapSchemaGuids(hDs, 1, new[] { guid }, out var map); + Assert.That(err, Is.EqualTo(Win32Error.ERROR_SUCCESS)); + var items = map.GetItems(1); + var item = items[0]; + Assert.That(item.guid, Is.EqualTo(guid)); + } + + [Test] + public void DsQuerySitesByCostTest() + { + var err = DsBindToISTG(null, out var hDs); + Assert.That(err, Is.EqualTo(Win32Error.ERROR_SUCCESS)); + err = NetApi32.DsGetSiteName(null, out var hSiteName); + Assert.That(err, Is.EqualTo(Win32Error.ERROR_SUCCESS)); + var site = hSiteName.ToString(); + var sites = GetAllSiteNames(); + err = DsQuerySitesByCost(hDs, site, sites, (uint)sites.Length, 0, out var hnr); + Assert.That(err, Is.EqualTo(Win32Error.ERROR_SUCCESS)); + var nrs = hnr.GetItems(sites.Length); + Assert.That(nrs.Length, Is.EqualTo(sites.Length)); + var nr = nrs[0]; + Assert.That(nr.cost, Is.Not.Null); + for (var i = 0; i < sites.Length; i++) + TestContext.WriteLine($"{sites[i]}: {(nrs[i].errorCode == Win32Error.ERROR_SUCCESS ? nrs[i].cost.ToString() : "Not found")}"); + } + + private static string[] GetAllSiteNames() + { + var rootDSE = new DirectoryEntry("LDAP://RootDSE"); + var configNC = new DirectoryEntry("LDAP://" + rootDSE.Properties["configurationNamingContext"][0]); + var sitesContainer = new DirectoryEntry("LDAP://CN=Sites," + configNC.Properties["distinguishedName"][0]); + var siteFinder = new DirectorySearcher(sitesContainer, "(objectClass=site)") { PageSize = 100 }; + using (var results = siteFinder.FindAll()) + return results.Cast().Select(r => r.Properties["name"][0].ToString()).ToArray(); + } } } \ No newline at end of file diff --git a/UnitTests/Properties/AssemblyInfo.cs b/UnitTests/Properties/AssemblyInfo.cs index d17a2101..34e5573b 100644 --- a/UnitTests/Properties/AssemblyInfo.cs +++ b/UnitTests/Properties/AssemblyInfo.cs @@ -16,5 +16,5 @@ using System.Runtime.InteropServices; [assembly: Guid("3c9e407f-9d0b-4b54-b181-ba5476b8d2dc")] // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: AssemblyVersion("2.0.1.0")] +[assembly: AssemblyFileVersion("2.0.1.0")] diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index 11865000..0e27e30f 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -43,6 +43,7 @@ + @@ -75,6 +76,7 @@ + @@ -158,9 +160,9 @@ {1f0b972a-06da-4f6a-8b60-87d76fb1f2d9} Vanara.PInvoke.CredUI - - {bd86fd1b-d52e-4b78-89ac-36d89458ebd8} - Vanara.PInvoke.Crypt32 + + {b0df2976-be60-4856-a634-5487222360b2} + Vanara.PInvoke.Cryptography {e1c6d6af-60a0-42cd-af77-f0de0ffe1395} diff --git a/Vanara.sln b/Vanara.sln index a3e45909..cdc52bd8 100644 --- a/Vanara.sln +++ b/Vanara.sln @@ -67,8 +67,6 @@ Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "HelpBuilder", "HelpBuilder\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.Mpr", "PInvoke\Mpr\Vanara.PInvoke.Mpr.csproj", "{E91C263F-82D9-40A9-99A1-F879CB076BCE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.Crypt32", "PInvoke\Crypt32\Vanara.PInvoke.Crypt32.csproj", "{BD86FD1B-D52E-4B78-89AC-36D89458EBD8}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.User32.Gdi", "PInvoke\User32.Gdi\Vanara.PInvoke.User32.Gdi.csproj", "{FC7B25B5-3BB9-44F5-93D9-9AB7193B1BE9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.Windows.Shell", "Windows.Shell\Vanara.Windows.Shell.csproj", "{43685BE2-A65E-4B01-BE16-479526940F23}" @@ -83,6 +81,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.NtDll", "PIn EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.Ws2_32", "PInvoke\Ws2_32\Vanara.PInvoke.Ws2_32.csproj", "{74D00C4C-DA94-4046-B3CD-318FECDE3794}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.Cryptography", "PInvoke\Cryptography\Vanara.PInvoke.Cryptography.csproj", "{B0DF2976-BE60-4856-A634-5487222360B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -187,10 +187,6 @@ Global {E91C263F-82D9-40A9-99A1-F879CB076BCE}.Debug|Any CPU.Build.0 = Debug|Any CPU {E91C263F-82D9-40A9-99A1-F879CB076BCE}.Release|Any CPU.ActiveCfg = Release|Any CPU {E91C263F-82D9-40A9-99A1-F879CB076BCE}.Release|Any CPU.Build.0 = Release|Any CPU - {BD86FD1B-D52E-4B78-89AC-36D89458EBD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BD86FD1B-D52E-4B78-89AC-36D89458EBD8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BD86FD1B-D52E-4B78-89AC-36D89458EBD8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BD86FD1B-D52E-4B78-89AC-36D89458EBD8}.Release|Any CPU.Build.0 = Release|Any CPU {FC7B25B5-3BB9-44F5-93D9-9AB7193B1BE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FC7B25B5-3BB9-44F5-93D9-9AB7193B1BE9}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC7B25B5-3BB9-44F5-93D9-9AB7193B1BE9}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -219,6 +215,10 @@ Global {74D00C4C-DA94-4046-B3CD-318FECDE3794}.Debug|Any CPU.Build.0 = Debug|Any CPU {74D00C4C-DA94-4046-B3CD-318FECDE3794}.Release|Any CPU.ActiveCfg = Release|Any CPU {74D00C4C-DA94-4046-B3CD-318FECDE3794}.Release|Any CPU.Build.0 = Release|Any CPU + {B0DF2976-BE60-4856-A634-5487222360B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0DF2976-BE60-4856-A634-5487222360B2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0DF2976-BE60-4856-A634-5487222360B2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0DF2976-BE60-4856-A634-5487222360B2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -244,12 +244,12 @@ Global {392A14B0-1E10-4E88-9C13-0D965665FFB5} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} {BBE4A7D6-0B24-4F58-9726-E05F358C1256} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} {E91C263F-82D9-40A9-99A1-F879CB076BCE} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} - {BD86FD1B-D52E-4B78-89AC-36D89458EBD8} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} {FC7B25B5-3BB9-44F5-93D9-9AB7193B1BE9} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} {BBD8CE8D-31D2-4DFB-8D96-46825C09C7F1} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} {EF53ED51-C141-4525-A6B7-41109EE5F416} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} {9E0C0DC0-E1B6-42A7-BD31-9A62EEADA780} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} {74D00C4C-DA94-4046-B3CD-318FECDE3794} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} + {B0DF2976-BE60-4856-A634-5487222360B2} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {543FAC75-2AF1-4EF1-9609-B242B63FEED4} diff --git a/Vanara.snk b/Vanara.snk new file mode 100644 index 00000000..19b278be Binary files /dev/null and b/Vanara.snk differ diff --git a/WIndows.Forms/AssemblyReport.md b/WIndows.Forms/AssemblyReport.md index a8fe5ff6..58e119db 100644 --- a/WIndows.Forms/AssemblyReport.md +++ b/WIndows.Forms/AssemblyReport.md @@ -123,7 +123,7 @@ FilenameProperty | Properties accessible via `VisualTheme.GetFilename(System.Int Flip3DWindowPolicy | Flags used by the SetWindowAttr method to specify the Flip3D window policy. | Default, ExcludeBelow, ExcludeAbove FolderBrowserDialogOptions | | Folders, FoldersAndFiles, Computers, Printers FontProperty | Properties accessible via `VisualTheme.GetFont(System.Drawing.IDeviceContext,System.Int32,System.Int32,Vanara.Windows.Forms.VisualTheme.FontProperty)`. | Caption, SmallCaption, Menu, Status, MessageBox, IconTitle, Heading1, Heading2, Body, Glyph -IconSize | Used to determine the size of the icon returned by . | Large, Small, ExtraLarge, Jumbo +IconSize | Used to determine the size of the icon returned by various shell methods. | Large, Small, ExtraLarge, Jumbo IntProperty | Properties accessible via `VisualTheme.GetInt(System.Int32,System.Int32,Vanara.Windows.Forms.VisualTheme.IntProperty)`. | CharSet, MinimumColorDepth, FromHue1, FromHue2, FromHue3, FromHue4, FromHue5, ToHue1, ToHue2, ToHue3, ToHue4, ToHue5, ToColor1, ToColor2, ToColor3, ToColor4, ToColor5, TextGlowSize, FramesPerSecond, PixelsPerFrame, AnimationDelay, GlowIntensity, Opacity, ColorizationColor, ColorizationOpacity, AnimationDuration KnownFolder | Standard folders registered with the system as Known Folders. A computer will have only folders appropriate to it installed. | AccountPictures, AddNewPrograms, AdminTools, ApplicationShortcuts, AppsFolder, AppUpdates, CameraRoll, CDBurning, ChangeRemovePrograms, CommonAdminTools, CommonOEMLinks, CommonPrograms, CommonStartMenu, CommonStartup, CommonTemplates, ComputerFolder, ConflictFolder, ConnectionsFolder, Contacts, ControlPanelFolder, Cookies, Desktop, DeviceMetadataStore, Documents, DocumentsLibrary, Downloads, Favorites, Fonts, Games, GameTasks, History, HomeGroup, HomeGroupCurrentUser, ImplicitAppShortcuts, InternetCache, InternetFolder, Libraries, Links, LocalAppData, LocalAppDataLow, LocalizedResourcesDir, Music, MusicLibrary, NetHood, NetworkFolder, OriginalImages, PhotoAlbums, PicturesLibrary, Pictures, Playlists, PrintersFolder, PrintHood, Profile, ProgramData, ProgramFiles, ProgramFilesX64, ProgramFilesX86, ProgramFilesCommon, ProgramFilesCommonX64, ProgramFilesCommonX86, Programs, Public, PublicDesktop, PublicDocuments, PublicDownloads, PublicGameTasks, PublicLibraries, PublicMusic, PublicPictures, PublicRingtones, PublicUserTiles, PublicVideos, QuickLaunch, Recent, RecordedTVLibrary, RecycleBinFolder, ResourceDir, Ringtones, RoamingAppData, RoamedTileImages, RoamingTiles, SampleMusic, SamplePictures, SamplePlaylists, SampleVideos, SavedGames, SavedPictures, SavedPicturesLibrary, SavedSearches, Screenshots, SEARCH_CSC, SearchHistory, SearchHome, SEARCH_MAPI, SearchTemplates, SendTo, SidebarDefaultParts, SidebarParts, SkyDrive, SkyDriveCameraRoll, SkyDriveDocuments, SkyDrivePictures, StartMenu, Startup, SyncManagerFolder, SyncResultsFolder, SyncSetupFolder, System, SystemX86, Templates, UserPinned, UserProfiles, UserProgramFiles, UserProgramFilesCommon, UsersFiles, UsersLibraries, Videos, VideosLibrary, Windows, Undefined MarginsProperty | Properties accessible via `VisualTheme.GetMargins(System.Drawing.IDeviceContext,System.Int32,System.Int32,Vanara.Windows.Forms.VisualTheme.MarginsProperty)`. | Sizing, Content, Caption diff --git a/WIndows.Forms/Vanara.Windows.Forms.csproj b/WIndows.Forms/Vanara.Windows.Forms.csproj index ede7ec9d..658dde07 100644 --- a/WIndows.Forms/Vanara.Windows.Forms.csproj +++ b/WIndows.Forms/Vanara.Windows.Forms.csproj @@ -4,7 +4,7 @@ Classes for user interface related items derived from the Vanara PInvoke libraries. Includes extensions for almost all common controls to give post Vista capabilities, WinForms controls (panel, commandlink, enhanced combo boxes, IPAddress, split button, trackbar and themed controls), shutdown/restart/lock control, buffered painting, resource files, access control editor, simplifed designer framework for Windows.Forms. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.Windows.Forms $(AssemblyName) @@ -33,6 +33,8 @@ BitmapProperty, BoolProperty, CloakingSource, CollapsiblePanelBorderCondition, C latest + true + ..\Vanara.snk true diff --git a/Windows.Shell/Vanara.Windows.Shell.csproj b/Windows.Shell/Vanara.Windows.Shell.csproj index d9db3d62..b410fa7c 100644 --- a/Windows.Shell/Vanara.Windows.Shell.csproj +++ b/Windows.Shell/Vanara.Windows.Shell.csproj @@ -4,7 +4,7 @@ Classes for Windows Shell items derived from the Vanara PInvoke libraries. Includes shell items, files, icons, links, and taskbar lists. Copyright © 2017-2018 $(AssemblyName) - 2.0.0 + 2.0.1 net20;net35;net40;net45 Vanara.Windows.Shell $(AssemblyName) @@ -30,6 +30,8 @@ ChangeFilters, ExecutableType, FolderItemFilter, LibraryFolderFilter, LibraryVie latest + true + ..\Vanara.snk true