internal static int DRMCreateLicenseStorageSession( SafeRightsManagementEnvironmentHandle hEnv, SafeRightsManagementHandle hDefLib, SafeRightsManagementSessionHandle hClientSession, uint uFlags, string IssuanceLicense, out SafeRightsManagementSessionHandle phLicenseStorageSession) { SecurityHelper.DemandRightsManagementPermission(); int res = UnsafeNativeMethods.DRMCreateLicenseStorageSession( hEnv, hDefLib, hClientSession, uFlags, IssuanceLicense, out phLicenseStorageSession); // on some platforms in the failure cases the out parameter is being created with the value 0 // in order to simplify error handling and Disposing of those handles we will just close them as // soon as we detect such case if ((phLicenseStorageSession != null) && phLicenseStorageSession.IsInvalid) { phLicenseStorageSession.Dispose(); phLicenseStorageSession = null; } return(res); }
internal static extern int DRMCreateLicenseStorageSession( [In] SafeRightsManagementEnvironmentHandle envHandle, [In] SafeRightsManagementHandle hDefLib, [In] SafeRightsManagementSessionHandle hClientSession, [In, MarshalAs(UnmanagedType.U4)] uint uFlags, [In, MarshalAs(UnmanagedType.LPWStr)] string IssuanceLicense, [Out] out SafeRightsManagementSessionHandle phLicenseStorageSession);
internal static int DRMCreateClientSession( CallbackDelegate pfnCallback, uint uCallbackVersion, string GroupIDProviderType, string GroupID, out SafeRightsManagementSessionHandle phSession) { SecurityHelper.DemandRightsManagementPermission(); int res = UnsafeNativeMethods.DRMCreateClientSession( pfnCallback, uCallbackVersion, GroupIDProviderType, GroupID, out phSession); // on some platforms in the failure cases the out parameter is being created with the value 0 // in order to simplify error handling and Disposing of those handles we will just close them as // soon as we detect such case if ((phSession != null) && phSession.IsInvalid) { phSession.Dispose(); phSession = null; } return(res); }
internal static extern int DRMActivate( [In] SafeRightsManagementSessionHandle hSession, [In, MarshalAs(UnmanagedType.U4)] uint uFlags, [In, MarshalAs(UnmanagedType.U4)] uint uLangID, [In, MarshalAs(UnmanagedType.LPStruct)] ActivationServerInfo activationServerInfo, IntPtr context, // this is a void* in the unmanaged SDK so IntPtr is the right (platform dependent declaration) IntPtr parentWindowHandle); // this a HWND in the unmanaged SDK so IntPtr is the right (platform dependent declaration)
internal static extern int DRMEnumerateLicense( [In] SafeRightsManagementSessionHandle hSession, [In, MarshalAs(UnmanagedType.U4)] uint uFlags, [In, MarshalAs(UnmanagedType.U4)] uint uIndex, [In, Out, MarshalAs(UnmanagedType.Bool)] ref bool pfSharedFlag, [In, Out, MarshalAs(UnmanagedType.U4)] ref uint puCertDataLen, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder wszCertificateData);
internal static int DRMCreateClientSession( CallbackDelegate pfnCallback, uint uCallbackVersion, string GroupIDProviderType, string GroupID, out SafeRightsManagementSessionHandle phSession) { SecurityHelper.DemandRightsManagementPermission(); int res = UnsafeNativeMethods.DRMCreateClientSession( pfnCallback, uCallbackVersion, GroupIDProviderType, GroupID, out phSession); // on some platforms in the failure cases the out parameter is being created with the value 0 // in order to simplify error handling and Disposing of those handles we will just close them as // soon as we detect such case if ((phSession != null) && phSession.IsInvalid) { phSession.Dispose(); phSession = null; } return res; }
internal static extern int DRMGetServiceLocation( [In] SafeRightsManagementSessionHandle clientSessionHandle, [In, MarshalAs(UnmanagedType.U4)] uint serviceType, [In, MarshalAs(UnmanagedType.U4)] uint serviceLocation, [In, MarshalAs(UnmanagedType.LPWStr)] string issuanceLicense, [In, Out, MarshalAs(UnmanagedType.U4)] ref uint serviceUrlLength, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder serviceUrl);
internal static int DRMDeleteLicense( SafeRightsManagementSessionHandle hSession, string wszLicenseId) { return(UnsafeNativeMethods.DRMDeleteLicense( hSession, wszLicenseId)); }
internal static extern int DRMAcquireLicense( [In] SafeRightsManagementSessionHandle hSession, [In, MarshalAs(UnmanagedType.U4)] uint uFlags, [In, MarshalAs(UnmanagedType.LPWStr)] string GroupIdentityCredential, [In, MarshalAs(UnmanagedType.LPWStr)] string RequestedRights, [In, MarshalAs(UnmanagedType.LPWStr)] string CustomData, [In, MarshalAs(UnmanagedType.LPWStr)] string url, IntPtr context); // this is a void* in the unmanaged SDK so IntPtr is the right (platform dependent declaration)
internal static int DRMDeleteLicense( SafeRightsManagementSessionHandle hSession, string wszLicenseId) { SecurityHelper.DemandRightsManagementPermission(); return(UnsafeNativeMethods.DRMDeleteLicense( hSession, wszLicenseId)); }
internal static int DRMIsActivated( SafeRightsManagementSessionHandle hSession, uint uFlags, ActivationServerInfo activationServerInfo) { return(UnsafeNativeMethods.DRMIsActivated( hSession, uFlags, activationServerInfo)); }
internal static int DRMIsActivated( SafeRightsManagementSessionHandle hSession, uint uFlags, ActivationServerInfo activationServerInfo) { SecurityHelper.DemandRightsManagementPermission(); return(UnsafeNativeMethods.DRMIsActivated( hSession, uFlags, activationServerInfo)); }
internal static int DRMEnumerateLicense( SafeRightsManagementSessionHandle hSession, uint uFlags, uint uIndex, ref bool pfSharedFlag, ref uint puCertDataLen, StringBuilder wszCertificateData) { return(UnsafeNativeMethods.DRMEnumerateLicense( hSession, uFlags, uIndex, ref pfSharedFlag, ref puCertDataLen, wszCertificateData)); }
internal static int DRMGetServiceLocation( SafeRightsManagementSessionHandle clientSessionHandle, uint serviceType, uint serviceLocation, string issuanceLicense, ref uint serviceUrlLength, StringBuilder serviceUrl) { return(UnsafeNativeMethods.DRMGetServiceLocation( clientSessionHandle, serviceType, serviceLocation, issuanceLicense, ref serviceUrlLength, serviceUrl)); }
internal static int DRMActivate( SafeRightsManagementSessionHandle hSession, uint uFlags, uint uLangID, ActivationServerInfo activationServerInfo, IntPtr context, IntPtr parentWindowHandle) { return(UnsafeNativeMethods.DRMActivate( hSession, uFlags, uLangID, activationServerInfo, context, parentWindowHandle)); }
internal static int DRMAcquireLicense( SafeRightsManagementSessionHandle hSession, uint uFlags, string GroupIdentityCredential, string RequestedRights, string CustomData, string url, IntPtr context) { return(UnsafeNativeMethods.DRMAcquireLicense( hSession, uFlags, GroupIdentityCredential, RequestedRights, CustomData, url, context)); }
internal static int DRMDeleteLicense( SafeRightsManagementSessionHandle hSession, string wszLicenseId) { SecurityHelper.DemandRightsManagementPermission(); return UnsafeNativeMethods.DRMDeleteLicense( hSession, wszLicenseId); }
internal static int DRMIsActivated( SafeRightsManagementSessionHandle hSession, uint uFlags, ActivationServerInfo activationServerInfo) { SecurityHelper.DemandRightsManagementPermission(); return UnsafeNativeMethods.DRMIsActivated( hSession, uFlags, activationServerInfo); }
internal static extern int DRMIsActivated( [In] SafeRightsManagementSessionHandle hSession, [In, MarshalAs(UnmanagedType.U4)] uint uFlags, [In, MarshalAs(UnmanagedType.LPStruct)] ActivationServerInfo activationServerInfo);
internal static int DRMActivate( SafeRightsManagementSessionHandle hSession, uint uFlags, uint uLangID, ActivationServerInfo activationServerInfo, IntPtr context, IntPtr parentWindowHandle) { SecurityHelper.DemandRightsManagementPermission(); return UnsafeNativeMethods.DRMActivate( hSession, uFlags, uLangID, activationServerInfo, context, parentWindowHandle); }
internal static int DRMCreateLicenseStorageSession( SafeRightsManagementEnvironmentHandle hEnv, SafeRightsManagementHandle hDefLib, SafeRightsManagementSessionHandle hClientSession, uint uFlags, string IssuanceLicense, out SafeRightsManagementSessionHandle phLicenseStorageSession) { SecurityHelper.DemandRightsManagementPermission(); int res = UnsafeNativeMethods.DRMCreateLicenseStorageSession( hEnv, hDefLib, hClientSession, uFlags, IssuanceLicense, out phLicenseStorageSession); // on some platforms in the failure cases the out parameter is being created with the value 0 // in order to simplify error handling and Disposing of those handles we will just close them as // soon as we detect such case if ((phLicenseStorageSession != null) && phLicenseStorageSession.IsInvalid) { phLicenseStorageSession.Dispose(); phLicenseStorageSession = null; } return res; }
internal static int DRMAcquireLicense( SafeRightsManagementSessionHandle hSession, uint uFlags, string GroupIdentityCredential, string RequestedRights, string CustomData, string url, IntPtr context) { SecurityHelper.DemandRightsManagementPermission(); return UnsafeNativeMethods.DRMAcquireLicense( hSession, uFlags, GroupIdentityCredential, RequestedRights, CustomData, url, context); }
internal static string GetLicenseOnSession(SafeRightsManagementSessionHandle sessionHandle, EnumerateLicenseFlags enumerateLicenseFlags, int index) { Invariant.Assert(index >= 0); if ((enumerateLicenseFlags != EnumerateLicenseFlags.Machine) && (enumerateLicenseFlags != EnumerateLicenseFlags.GroupIdentity) && (enumerateLicenseFlags != EnumerateLicenseFlags.GroupIdentityName) && (enumerateLicenseFlags != EnumerateLicenseFlags.GroupIdentityLid) && (enumerateLicenseFlags != EnumerateLicenseFlags.SpecifiedGroupIdentity) && (enumerateLicenseFlags != EnumerateLicenseFlags.Eul) && (enumerateLicenseFlags != EnumerateLicenseFlags.EulLid) && (enumerateLicenseFlags != EnumerateLicenseFlags.ClientLicensor) && (enumerateLicenseFlags != EnumerateLicenseFlags.ClientLicensorLid) && (enumerateLicenseFlags != EnumerateLicenseFlags.SpecifiedClientLicensor) && (enumerateLicenseFlags != EnumerateLicenseFlags.RevocationList) && (enumerateLicenseFlags != EnumerateLicenseFlags.RevocationListLid) && (enumerateLicenseFlags != EnumerateLicenseFlags.Expired)) { throw new ArgumentOutOfRangeException("enumerateLicenseFlags"); } int hr = 0; bool sharedFlag = false; uint dataLen = 0; StringBuilder license = null; hr = SafeNativeMethods.DRMEnumerateLicense( sessionHandle, (uint)enumerateLicenseFlags, (uint)index, ref sharedFlag, ref dataLen, null); if (hr == (int)RightsManagementFailureCode.NoMoreData) return null; Errors.ThrowOnErrorCode(hr); if (dataLen > System.Int32.MaxValue) return null; //returned size accounts for null termination; we do not need to add 1 checked { license = new StringBuilder((int)dataLen); } hr = SafeNativeMethods.DRMEnumerateLicense( sessionHandle, (uint)enumerateLicenseFlags, (uint)index, ref sharedFlag, ref dataLen, license); Errors.ThrowOnErrorCode(hr); return license.ToString(); }
internal static extern int DRMDeleteLicense( [In] SafeRightsManagementSessionHandle hSession, [In, MarshalAs(UnmanagedType.LPWStr)] string wszLicenseId);
internal static int DRMEnumerateLicense( SafeRightsManagementSessionHandle hSession, uint uFlags, uint uIndex, ref bool pfSharedFlag, ref uint puCertDataLen, StringBuilder wszCertificateData) { SecurityHelper.DemandRightsManagementPermission(); return UnsafeNativeMethods.DRMEnumerateLicense( hSession, uFlags, uIndex, ref pfSharedFlag, ref puCertDataLen, wszCertificateData); }
internal static int DRMGetServiceLocation( SafeRightsManagementSessionHandle clientSessionHandle, uint serviceType, uint serviceLocation, string issuanceLicense, ref uint serviceUrlLength, StringBuilder serviceUrl) { SecurityHelper.DemandRightsManagementPermission(); return UnsafeNativeMethods.DRMGetServiceLocation( clientSessionHandle, serviceType, serviceLocation, issuanceLicense, ref serviceUrlLength, serviceUrl); }
internal static extern int DRMCreateClientSession( [In, MarshalAs(UnmanagedType.FunctionPtr)] CallbackDelegate pfnCallback, [In, MarshalAs(UnmanagedType.U4)] uint uCallbackVersion, [In, MarshalAs(UnmanagedType.LPWStr)] string GroupIDProviderType, [In, MarshalAs(UnmanagedType.LPWStr)] string GroupID, [Out] out SafeRightsManagementSessionHandle phSession);
private static ArrayList EnumerateAllValuesOnSession(SafeRightsManagementSessionHandle sessionHandle, EnumerateLicenseFlags enumerateLicenseFlags) { ArrayList result = new ArrayList(5); int index = 0; while (true) { string currentRes = GetLicenseOnSession(sessionHandle, enumerateLicenseFlags, index); if (currentRes == null) { break; } result.Add(currentRes); index++; } return result; }