Skip to content

Commit 6e0d2b3

Browse files
author
dahall
committed
Adjustments to all assemblies after adding code generator for all methods that can retrieve a casted IUnknown pointer
1 parent f5e5282 commit 6e0d2b3

38 files changed

+74
-782
lines changed

Core/SuppressAutoGenAttribute.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Vanara.PInvoke;
2+
3+
/// <summary>An attribute that can be applied to a code element to suppress the automatic generation of P/Invoke methods for that element.</summary>
4+
/// <seealso cref="System.Attribute"/>
5+
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
6+
public sealed class SuppressAutoGenAttribute : Attribute
7+
{
8+
}

DirectoryServices/Vanara.DirectoryServices.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected ADsBaseObject(string pathName)
132132
/// <param name="password">The string that specifies the password to supply to the directory service to use for credentials.</param>
133133
protected ADsBaseObject(string pathName, ADS_AUTHENTICATION auth, [Optional] string? userName, [Optional] string? password)
134134
{
135-
ADsOpenObject<TInterface>(pathName, out var o, auth, userName, password).ThrowIfFailed();
135+
ADsOpenObject<TInterface>(pathName, userName, password, auth, out var o).ThrowIfFailed();
136136
Interface = o!;
137137
}
138138

@@ -1209,7 +1209,7 @@ public static IADsObject GetObject(string path)
12091209
public static IADsObject OpenObject(string path, [Optional] ADS_AUTHENTICATION auth, [Optional] string? userName,
12101210
[Optional] string? password)
12111211
{
1212-
ADsOpenObject(path, out IADs? o, auth, userName, password).ThrowIfFailed();
1212+
ADsOpenObject(path, userName, password, auth, out IADs? o).ThrowIfFailed();
12131213
return GetTypedObj(o!);
12141214
}
12151215

PInvoke/ActiveDS/ActiveDS.cs

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -384,41 +384,6 @@ public static extern HRESULT ADsGetLastError(out Win32Error lpError, [Out, Marsh
384384
public static extern HRESULT ADsGetObject([MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, in Guid riid,
385385
[MarshalAs(UnmanagedType.Interface, IidParameterIndex = 1)] out object? ppObject);
386386

387-
/// <summary>The <c>ADsGetObject</c> function binds to an object given its path and a specified interface identifier.</summary>
388-
/// <typeparam name="T">The type of the interface to retrieve.</typeparam>
389-
/// <param name="lpszPathName">
390-
/// The null-terminated Unicode string that specifies the path used to bind to the object in the underlying directory service. For more
391-
/// information and code examples for binding strings for this parameter, see LDAP ADsPath and WinNT ADsPath.
392-
/// </param>
393-
/// <param name="ppObject">The requested Interface.</param>
394-
/// <returns>
395-
/// <para>Type: <c>HRESULT</c></para>
396-
/// <para>This method supports the standard <c>HRESULT</c> return values, as well as the following.</para>
397-
/// <para>For more information about other return values, see ADSI Error Codes.</para>
398-
/// </returns>
399-
/// <remarks>
400-
/// <para>
401-
/// A C/C++ client calls the <c>ADsGetObject</c> helper function to bind to an ADSI object. It is equivalent to a Visual Basic client
402-
/// calling the GetObject function. They both take an ADsPath as input and returns a pointer to the requested interface. By default the
403-
/// binding uses ADS_SECURE_AUTHENTICATION option with the security context of the calling thread. However, if the authentication fails,
404-
/// the secure bind is downgraded to an anonymous bind, for example, a simple bind without user credentials. To securely bind to an ADSI
405-
/// object, use the ADsOpenObject function instead of the <c>ADsGetObject</c> function.
406-
/// </para>
407-
/// <para>
408-
/// It is possible to bind to an ADSI object with a user credential different from that of the currently logged-on user. To perform this
409-
/// operation, use the ADsOpenObject function.
410-
/// </para>
411-
/// </remarks>
412-
// https://learn.microsoft.com/en-us/windows/win32/api/adshlp/nf-adshlp-adsgetobject HRESULT ADsGetObject( [in] LPCWSTR lpszPathName,
413-
// [in] REFIID riid, [out] VOID **ppObject );
414-
[PInvokeData("adshlp.h", MSDNShortId = "NF:adshlp.ADsGetObject")]
415-
public static HRESULT ADsGetObject<T>(string lpszPathName, out T? ppObject) where T : class
416-
{
417-
var hr = ADsGetObject(lpszPathName, typeof(T).GUID, out var o);
418-
ppObject = hr.Succeeded ? (T)o! : null;
419-
return hr;
420-
}
421-
422387
/// <summary>
423388
/// The <c>ADsOpenObject</c> function binds to an ADSI object using explicit user name and password credentials. <c>ADsOpenObject</c> is
424389
/// a wrapper function for IADsOpenDSObject and is equivalent to the IADsOpenDSObject::OpenDsObject method.
@@ -522,97 +487,6 @@ public static HRESULT ADsGetObject<T>(string lpszPathName, out T? ppObject) wher
522487
public static extern HRESULT ADsOpenObject([MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, [MarshalAs(UnmanagedType.LPWStr), Optional] string? lpszUserName,
523488
[MarshalAs(UnmanagedType.LPWStr), Optional] string? lpszPassword, [Optional] ADS_AUTHENTICATION dwReserved, in Guid riid, [MarshalAs(UnmanagedType.Interface, IidParameterIndex = 4)] out object? ppObject);
524489

525-
/// <summary>
526-
/// The <c>ADsOpenObject</c> function binds to an ADSI object using explicit user name and password credentials. <c>ADsOpenObject</c> is
527-
/// a wrapper function for IADsOpenDSObject and is equivalent to the IADsOpenDSObject::OpenDsObject method.
528-
/// </summary>
529-
/// <typeparam name="T">The type of the interface to retrieve.</typeparam>
530-
/// <param name="lpszPathName">
531-
/// The null-terminated Unicode string that specifies the ADsPath of the ADSI object. For more information and code examples of binding
532-
/// strings for this parameter, see LDAP ADsPath and WinNT ADsPath.
533-
/// </param>
534-
/// <param name="lpszUserName">
535-
/// The null-terminated Unicode string that specifies the user name to supply to the directory service to use for credentials. This
536-
/// string should always be in the format "&lt;domain\&gt;&lt;user name&gt;" to avoid ambiguity. For example, if DomainA and DomainB have
537-
/// a trust relationship and both domains have a user with the name "user1", it is not possible to predict which domain
538-
/// <c>ADsOpenObject</c> will use to validate "user1".
539-
/// </param>
540-
/// <param name="lpszPassword">
541-
/// The null-terminated Unicode string that specifies the password to supply to the directory service to use for credentials.
542-
/// </param>
543-
/// <param name="ppObject">The requested interface.</param>
544-
/// <param name="dwReserved">Provider-specific authentication flags used to define the binding options. For more information, see ADS_AUTHENTICATION_ENUM.</param>
545-
/// <returns>
546-
/// <para>Type: <c>HRESULT</c></para>
547-
/// <para>This method supports the standard <c>HRESULT</c> return values, including the following.</para>
548-
/// <para>For more information, see ADSI Error Codes.</para>
549-
/// </returns>
550-
/// <remarks>
551-
/// <para>This function should not be used just to validate user credentials.</para>
552-
/// <para>
553-
/// A C/C++ client calls the <c>ADsOpenObject</c> helper function to bind to an ADSI object, using the user name and password supplied as
554-
/// credentials for the appropriate directory service. If <c>lpszUsername</c> and <c>lpszPassword</c> are <c>NULL</c> and
555-
/// <c>ADS_SECURE_AUTHENTICATION</c> is set, ADSI binds to the object using the security context of the calling thread, which is either
556-
/// the security context of the user account under which the application is running or of the client user account that the calling thread impersonates.
557-
/// </para>
558-
/// <para>
559-
/// The credentials passed to the <c>ADsOpenObject</c> function are used only with the particular object bound to and do not affect the
560-
/// security context of the calling thread. This means that, in the example below, the call to <c>ADsOpenObject</c> will use different
561-
/// credentials than the call to ADsGetObject.
562-
/// </para>
563-
/// <para>To work with the WinNT: provider, you can pass in <c>lpszUsername</c> as one of the following strings:</para>
564-
/// <list type="bullet">
565-
/// <item>
566-
/// <description>The name of a user account, that is, "jeffsmith".</description>
567-
/// </item>
568-
/// <item>
569-
/// <description>The Windows style user name, that is, "Fabrikam\jeffsmith".</description>
570-
/// </item>
571-
/// </list>
572-
/// <para>With the LDAP provider for Active Directory, you may pass in <c>lpszUsername</c> as one of the following strings:</para>
573-
/// <list type="bullet">
574-
/// <item>
575-
/// <description>
576-
/// The name of a user account, such as "jeffsmith". To use a user name by itself, you must set only the <c>ADS_SECURE_AUTHENTICATION</c>
577-
/// flag in the <c>dwReserved</c> parameter.
578-
/// </description>
579-
/// </item>
580-
/// <item>
581-
/// <description>The user path from a previous version of Windows, such as "Fabrikam\jeffsmith".</description>
582-
/// </item>
583-
/// <item>
584-
/// <description>
585-
/// Distinguished Name, such as "CN=Jeff Smith,OU=Sales,DC=Fabrikam,DC=Com". To use a DN, the <c>dwReserved</c> parameter must be zero or
586-
/// it must include the <c>ADS_USE_SSL</c> flag.
587-
/// </description>
588-
/// </item>
589-
/// <item>
590-
/// <description>
591-
/// User Principal Name (UPN), such as "jeffsmith@Fabrikam.com". To use a UPN, assign the appropriate UPN value for the
592-
/// <c>userPrincipalName</c> attribute of the target user object.
593-
/// </description>
594-
/// </item>
595-
/// </list>
596-
/// <para>
597-
/// If Kerberos authentication is required for the successful completion of a specific directory request using the LDAP provider, the
598-
/// <c>lpszPathName</c> binding string must use either a serverless ADsPath, such as "LDAP://CN=Jeff Smith,CN=admin,DC=Fabrikam,DC=com",
599-
/// or it must use an ADsPath with a fully qualified DNS server name, such as "LDAP://central3.corp.Fabrikam.com/CN=Jeff
600-
/// Smith,CN=admin,DC=Fabrikam,DC=com". Binding to the server using a flat NETBIOS name or a short DNS name, for example, using the short
601-
/// name "central3" instead of "central3.corp.Fabrikam.com", may or may not yield Kerberos authentication.
602-
/// </para>
603-
/// <para>The following code example shows how to bind to a directory service object with the requested user credentials.</para>
604-
/// </remarks>
605-
// https://learn.microsoft.com/en-us/windows/win32/api/adshlp/nf-adshlp-adsopenobject HRESULT ADsOpenObject( [in] LPCWSTR lpszPathName,
606-
// [in] LPCWSTR lpszUserName, [in] LPCWSTR lpszPassword, [in] DWORD dwReserved, [in] REFIID riid, [out] void **ppObject );
607-
[PInvokeData("adshlp.h", MSDNShortId = "NF:adshlp.ADsOpenObject")]
608-
public static HRESULT ADsOpenObject<T>(string lpszPathName, out T? ppObject, [Optional] ADS_AUTHENTICATION dwReserved, [Optional] string? lpszUserName,
609-
[Optional] string? lpszPassword) where T : class
610-
{
611-
var hr = ADsOpenObject(lpszPathName, lpszUserName, lpszPassword, dwReserved, typeof(T).GUID, out var o);
612-
ppObject = hr.Succeeded ? (T)o! : null;
613-
return hr;
614-
}
615-
616490
/// <summary>
617491
/// The <c>ADsSetLastError</c> sets the last-error code value for the calling thread. Directory service providers can use this function
618492
/// to set extended errors. The function saves the error data in a per-thread data structure. <c>ADsSetLastError</c> operates similar to

PInvoke/ComCtl32/CommCtrl.ImageList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ public static void ImageList_LoadBitmap([In, Optional] HINSTANCE hi, ResourceId
20592059
// HRESULT ImageList_ReadEx( _In_ DWORD dwFlags, _In_ LPSTREAM pstm, _Out_ REFIID riid, _Out_ void **ppv); https://msdn.microsoft.com/en-us/library/windows/desktop/bb761562(v=vs.85).aspx
20602060
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
20612061
[PInvokeData("Commctrl.h", MSDNShortId = "bb761562")]
2062-
public static extern void ImageList_ReadEx(ILP dwFlags, IStream pstm, out Guid riid, [Out, MarshalAs(UnmanagedType.IUnknown)] out object? ppv);
2062+
public static extern void ImageList_ReadEx(ILP dwFlags, IStream pstm, out Guid riid, [Out, MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 2)] out object? ppv);
20632063

20642064
/// <summary>Removes an image from an image list.</summary>
20652065
/// <param name="himl">

PInvoke/CoreAudio/MmDevApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ public interface IMMDevice
562562
// https://docs.microsoft.com/en-us/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdevice-activate HRESULT Activate( REFIID
563563
// iid, DWORD dwClsCtx, PROPVARIANT *pActivationParams, void **ppInterface );
564564
[PreserveSig]
565-
HRESULT Activate([In] in Guid iid, [In] CLSCTX dwClsCtx, [In, Optional] PROPVARIANT? pActivationParams, [MarshalAs(UnmanagedType.IUnknown)] out object? ppInterface);
565+
HRESULT Activate([In] in Guid iid, [In] CLSCTX dwClsCtx, [In, Optional] PROPVARIANT? pActivationParams, [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 0)] out object? ppInterface);
566566

567567
/// <summary>The <c>OpenPropertyStore</c> method retrieves an interface to the device's property store.</summary>
568568
/// <param name="stgmAccess">

PInvoke/D3DCompiler/D3DCompiler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,7 @@ public static extern HRESULT D3DPreprocess([In] IntPtr pSrcData, [In] SizeT SrcD
19511951
[PInvokeData("d3dcompiler.h", MSDNShortId = "NF:d3dcompiler.D3DReflect")]
19521952
[DllImport(Lib_D3dcompiler_47, SetLastError = false, ExactSpelling = true)]
19531953
public static extern HRESULT D3DReflect([In] IntPtr pSrcData, [In] SizeT SrcDataSize, in Guid pInterface,
1954-
[MarshalAs(UnmanagedType.Interface)] out object? ppReflector);
1954+
[MarshalAs(UnmanagedType.Interface, IidParameterIndex = 2)] out object? ppReflector);
19551955

19561956
/// <summary>
19571957
/// <para>Creates a library-reflection interface from source data that contains an HLSL library of functions.</para>
@@ -1987,7 +1987,7 @@ public static extern HRESULT D3DReflect([In] IntPtr pSrcData, [In] SizeT SrcData
19871987
[PInvokeData("d3dcompiler.h", MSDNShortId = "NF:d3dcompiler.D3DReflectLibrary")]
19881988
[DllImport(Lib_D3dcompiler_47, SetLastError = false, ExactSpelling = true)]
19891989
public static extern HRESULT D3DReflectLibrary([In] IntPtr pSrcData, [In] SizeT SrcDataSize, in Guid riid,
1990-
[MarshalAs(UnmanagedType.Interface)] out object? ppReflector);
1990+
[MarshalAs(UnmanagedType.Interface, IidParameterIndex = 2)] out object? ppReflector);
19911991

19921992
/// <summary>Sets information in a compilation result.</summary>
19931993
/// <param name="pSrcData">

0 commit comments

Comments
 (0)