aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/OS
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-01-21 13:53:00 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-01-21 13:53:00 +0200
commit63579cee4493c4a8e3d64348d644fd2eecaca055 (patch)
treebc8e92b3a2751c5fe186ad9af08d88ad8fc02628 /Software/Visual_Studio/PPC/Tango.PPC.Common/OS
parent1d69ae8399a8e2419af3c4391ea387f5180561c3 (diff)
downloadTango-63579cee4493c4a8e3d64348d644fd2eecaca055.tar.gz
Tango-63579cee4493c4a8e3d64348d644fd2eecaca055.zip
PPC v1.0.0
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/OS')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs25
1 files changed, 19 insertions, 6 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs
index 36b31e888..23722319c 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs
@@ -10,13 +10,14 @@ using Tango.PPC.Common.Scripting;
namespace Tango.PPC.Common.OS
{
using System.Collections.ObjectModel;
+ using Tango.Core;
using SLID = Guid; //SLID id declaration as typedef GUID SLID; in slpublic.h
/// <summary>
/// Represents the default windows activation manager.
/// </summary>
/// <seealso cref="Tango.PPC.Common.OS.IOperationSystemManager" />
- public class DefaultOperationSystemManager : IOperationSystemManager
+ public class DefaultOperationSystemManager : ExtendedObject, IOperationSystemManager
{
#region Win32
@@ -43,6 +44,8 @@ namespace Tango.PPC.Common.OS
{
return Task.Factory.StartNew<bool>(() =>
{
+ LogManager.Log("Validating windows activation...");
+
Guid ApplicationID = new Guid("55c92734-d682-4d71-983e-d6ec3f16059f"); //Application ID GUID http://technet.microsoft.com/en-us/library/dd772270.aspx
SLID windowsSlid = (Guid)ApplicationID;
try
@@ -51,11 +54,12 @@ namespace Tango.PPC.Common.OS
uint ResultInt = SLIsGenuineLocal(ref windowsSlid, ref genuineState, IntPtr.Zero);
if (ResultInt == 0)
{
+ LogManager.Log("OS activation status: " + genuineState.ToString());
return (genuineState == SL_GENUINE_STATE.SL_GEN_STATE_IS_GENUINE);
}
else
{
- throw new InvalidOperationException("An error occurred while trying to get the OS activation status.");
+ throw LogManager.Log(new InvalidOperationException("An error occurred while trying to get the OS activation status."));
}
}
@@ -73,12 +77,21 @@ namespace Tango.PPC.Common.OS
/// <returns></returns>
public async Task Activate(string activationKey)
{
- CmdCommand command = new CmdCommand("cscript", $"C:\\Windows\\System32\\slmgr.vbs -ipk {activationKey}");
- await command.Run();
+ if (!(await IsActivated()))
+ {
+ CmdCommand command = new CmdCommand("cscript", $"C:\\Windows\\System32\\slmgr.vbs -ipk {activationKey}");
+ await command.Run();
+
+ await Task.Delay(5000);
- if (!await IsActivated())
+ if (!await IsActivated())
+ {
+ throw new ApplicationException("The activation was completed but activation status returned a false response.");
+ }
+ }
+ else
{
- throw new ApplicationException("The activation was completed but activation status returned a false response.");
+ LogManager.Log("Windows is already activated. Skipping activation...");
}
}