|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | + |
| 6 | +using System.Runtime.InteropServices; |
| 7 | + |
| 8 | +namespace MetroUnlocker.LibTSForge.SPP |
| 9 | +{ |
| 10 | + public enum SLIDType |
| 11 | + { |
| 12 | + Application, |
| 13 | + ProductSku, |
| 14 | + LicenseFile, |
| 15 | + License, |
| 16 | + ProductKey, |
| 17 | + AllLicenses, |
| 18 | + AllLicenseFiles, |
| 19 | + StoreToken, |
| 20 | + Last |
| 21 | + } |
| 22 | + |
| 23 | + public enum SLDataType |
| 24 | + { |
| 25 | + None, |
| 26 | + String, |
| 27 | + DWord, |
| 28 | + Binary, |
| 29 | + MultiString, |
| 30 | + Sum |
| 31 | + } |
| 32 | + |
| 33 | + [StructLayout(LayoutKind.Sequential)] |
| 34 | + public struct SLLicensingStatus |
| 35 | + { |
| 36 | + public Guid SkuId; |
| 37 | + public uint Status; |
| 38 | + public uint GraceTimeDWord; |
| 39 | + public uint TotalGraceDaysDWord; |
| 40 | + public uint ReasonHResult; |
| 41 | + public ulong ValidityExpiration; |
| 42 | + } |
| 43 | + |
| 44 | + public class NativeMethods |
| 45 | + { |
| 46 | + [DllImport("kernel32.dll")] |
| 47 | + internal static extern uint GetSystemDefaultLCID(); |
| 48 | + |
| 49 | + [DllImport("sppc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] |
| 50 | + internal static extern void SLOpen(out IntPtr hSLC); |
| 51 | + |
| 52 | + [DllImport("sppc.dll", CharSet = CharSet.Unicode, PreserveSig = false)] |
| 53 | + internal static extern void SLClose(IntPtr hSLC); |
| 54 | + |
| 55 | + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] |
| 56 | + internal static extern uint SLInstallProofOfPurchase(IntPtr hSLC, string pwszPKeyAlgorithm, string pwszPKeyString, uint cbPKeySpecificData, byte[] pbPKeySpecificData, ref Guid PKeyId); |
| 57 | + |
| 58 | + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] |
| 59 | + internal static extern uint SLUninstallProofOfPurchase(IntPtr hSLC, ref Guid PKeyId); |
| 60 | + |
| 61 | + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] |
| 62 | + internal static extern uint SLGenerateOfflineInstallationId(IntPtr hSLC, ref Guid pProductSkuId, ref string ppwszInstallationId); |
| 63 | + |
| 64 | + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] |
| 65 | + internal static extern uint SLDepositOfflineConfirmationId(IntPtr hSLC, ref Guid pProductSkuId, string pwszInstallationId, string pwszConfirmationId); |
| 66 | + |
| 67 | + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] |
| 68 | + internal static extern uint SLGetSLIDList(IntPtr hSLC, SLIDType eQueryIdType, ref Guid pQueryId, SLIDType eReturnIdType, out uint pnReturnIds, out IntPtr ppReturnIds); |
| 69 | + |
| 70 | + [DllImport("sppc.dll", CharSet = CharSet.Unicode)] |
| 71 | + internal static extern uint SLGetInstalledProductKeyIds(IntPtr hSLC, ref Guid pProductSkuId, out uint pnProductKeyIds, out IntPtr ppProductKeyIds); |
| 72 | + |
| 73 | + [DllImport("slc.dll", CharSet = CharSet.Unicode)] |
| 74 | + internal static extern uint SLConsumeWindowsRight(uint unknown); |
| 75 | + |
| 76 | + [DllImport("slc.dll", CharSet = CharSet.Unicode)] |
| 77 | + internal static extern uint SLGetProductSkuInformation(IntPtr hSLC, ref Guid pProductSkuId, string pwszValueName, out SLDataType peDataType, out uint pcbValue, out IntPtr ppbValue); |
| 78 | + |
| 79 | + [DllImport("slc.dll", CharSet = CharSet.Unicode)] |
| 80 | + internal static extern uint SLGetProductSkuInformation(IntPtr hSLC, ref Guid pProductSkuId, string pwszValueName, IntPtr peDataType, out uint pcbValue, out IntPtr ppbValue); |
| 81 | + |
| 82 | + [DllImport("slc.dll", CharSet = CharSet.Unicode)] |
| 83 | + internal static extern uint SLGetLicense(IntPtr hSLC, ref Guid pLicenseFileId, out uint pcbLicenseFile, out IntPtr ppbLicenseFile); |
| 84 | + |
| 85 | + [DllImport("slc.dll", CharSet = CharSet.Unicode)] |
| 86 | + internal static extern uint SLSetCurrentProductKey(IntPtr hSLC, ref Guid pProductSkuId, ref Guid pProductKeyId); |
| 87 | + |
| 88 | + [DllImport("slc.dll", CharSet = CharSet.Unicode)] |
| 89 | + internal static extern uint SLFireEvent(IntPtr hSLC, string pwszEventId, ref Guid pApplicationId); |
| 90 | + } |
| 91 | +} |
0 commit comments