|
|
@ -2268,33 +2268,19 @@ exit /b |
|
|
|
:: Get Windows Subscription status |
|
|
|
:: Get Windows Subscription status |
|
|
|
|
|
|
|
|
|
|
|
:winsubstatus: |
|
|
|
:winsubstatus: |
|
|
|
$DM = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2) |
|
|
|
$DM = [AppDomain]::CurrentDomain.DefineDynamicAssembly(6, 1).DefineDynamicModule(4).DefineType(2) |
|
|
|
$SB = $DM.DefineType('sub_status', 9, [ValueType], 0) |
|
|
|
[void]$DM.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) |
|
|
|
|
|
|
|
$m = [System.Runtime.InteropServices.Marshal] |
|
|
|
('enabled#int', 'sku#int', 'state#int').ForEach({ |
|
|
|
$p = $m::AllocHGlobal(12) |
|
|
|
$i = $_ -split '#' |
|
|
|
$r = $DM.CreateType()::ClipGetSubscriptionStatus([ref]$p) |
|
|
|
$n = $i[0] |
|
|
|
|
|
|
|
$t = $i[1] -as [Type] |
|
|
|
|
|
|
|
[void]$SB.DefineField($n, $t, 6) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sub_status = $SB.CreateType() |
|
|
|
|
|
|
|
$MB = $DM.DefineType('PInvoke') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[void]$MB.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [UInt32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$Clipc = $MB.CreateType() |
|
|
|
|
|
|
|
$s = [Activator]::CreateInstance($sub_status) |
|
|
|
|
|
|
|
$p = [Runtime.InteropServices.Marshal]::AllocHGlobal([Runtime.InteropServices.Marshal]::SizeOf($s)) |
|
|
|
|
|
|
|
$r = $Clipc::ClipGetSubscriptionStatus([ref]$p) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($r -eq 0) { |
|
|
|
if ($r -eq 0) { |
|
|
|
$s = [Runtime.InteropServices.Marshal]::PtrToStructure($p, [type]$sub_status) |
|
|
|
$enabled = $m::ReadInt32($p) |
|
|
|
if ($s.enabled -ne 0) { |
|
|
|
if ($enabled -ge 1) { |
|
|
|
if ($s.state -eq 1) { |
|
|
|
$state = $m::ReadInt32($p, 8) |
|
|
|
"Subscription_is_activated." |
|
|
|
if ($state -eq 1) { |
|
|
|
} |
|
|
|
"Subscription_is_activated." |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
:winsubstatus: |
|
|
|
:winsubstatus: |
|
|
|
|
|
|
|
|
|
|
|