MalwareSourceCode/MSIL/HackTool/Win32/K/HackTool.Win32.KMSAuto.i-f317ba4d4051fad64a0aa45b587fa3dcea795bac30acec2872779abe31a07cbe/TaskScheduler/ScheduledTasks.cs
2022-08-18 06:28:56 -05:00

111 lines
2.8 KiB
C#

// Decompiled with JetBrains decompiler
// Type: TaskScheduler.ScheduledTasks
// Assembly: AutoKMS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: D1CED9E3-1FC7-49B8-B3AC-44976AB7F6E4
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\HackTool.Win32.KMSAuto.i-f317ba4d4051fad64a0aa45b587fa3dcea795bac30acec2872779abe31a07cbe.exe
using System;
using System.Runtime.InteropServices;
using TaskSchedulerInterop;
namespace TaskScheduler
{
public class ScheduledTasks : IDisposable
{
private ITaskScheduler its;
internal static Guid ITaskGuid = Marshal.GenerateGuidForType(typeof (ITask));
internal static Guid CTaskGuid = Marshal.GenerateGuidForType(typeof (CTask));
public ScheduledTasks(string computer)
: this()
{
this.its.SetTargetComputer(computer);
}
public ScheduledTasks() => this.its = (ITaskScheduler) new CTaskScheduler();
private string[] GrowStringArray(string[] s, uint n)
{
string[] strArray = new string[(long) s.Length + (long) n];
for (int index = 0; index < s.Length; ++index)
strArray[index] = s[index];
return strArray;
}
public string[] GetTaskNames()
{
string[] s = new string[0];
int num = 0;
IEnumWorkItems EnumWorkItems;
this.its.Enum(out EnumWorkItems);
uint Fetched;
IntPtr Names;
while (EnumWorkItems.Next(10U, out Names, out Fetched) >= 0 && Fetched > 0U)
{
s = this.GrowStringArray(s, Fetched);
while (Fetched > 0U)
{
IntPtr ptr = Marshal.ReadIntPtr(Names, (int) --Fetched * IntPtr.Size);
s[num++] = Marshal.PtrToStringUni(ptr);
Marshal.FreeCoTaskMem(ptr);
}
Marshal.FreeCoTaskMem(Names);
}
return s;
}
public Task CreateTask(string name)
{
Task task = this.OpenTask(name);
if (task != null)
{
task.Close();
throw new ArgumentException("The task \"" + name + "\" already exists.");
}
try
{
object obj;
this.its.NewWorkItem(name, ref ScheduledTasks.CTaskGuid, ref ScheduledTasks.ITaskGuid, out obj);
return new Task((ITask) obj, name);
}
catch
{
return (Task) null;
}
}
public bool DeleteTask(string name)
{
try
{
this.its.Delete(name);
return true;
}
catch
{
return false;
}
}
public Task OpenTask(string name)
{
try
{
object obj;
this.its.Activate(name, ref ScheduledTasks.ITaskGuid, out obj);
return new Task((ITask) obj, name);
}
catch
{
return (Task) null;
}
}
public void Dispose()
{
Marshal.ReleaseComObject((object) this.its);
this.its = (ITaskScheduler) null;
}
}
}