Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Swedeachu committed Aug 7, 2022
1 parent 7883bdc commit f30c7ca
Show file tree
Hide file tree
Showing 23 changed files with 2,142 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Swim Prevent.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32602.291
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Swim Prevent", "Swim Prevent\Swim Prevent.csproj", "{DD7BD759-DFB7-479B-BDAC-B11D11AA8E17}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DD7BD759-DFB7-479B-BDAC-B11D11AA8E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD7BD759-DFB7-479B-BDAC-B11D11AA8E17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD7BD759-DFB7-479B-BDAC-B11D11AA8E17}.Debug|x64.ActiveCfg = Debug|x64
{DD7BD759-DFB7-479B-BDAC-B11D11AA8E17}.Debug|x64.Build.0 = Debug|x64
{DD7BD759-DFB7-479B-BDAC-B11D11AA8E17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD7BD759-DFB7-479B-BDAC-B11D11AA8E17}.Release|Any CPU.Build.0 = Release|Any CPU
{DD7BD759-DFB7-479B-BDAC-B11D11AA8E17}.Release|x64.ActiveCfg = Release|x64
{DD7BD759-DFB7-479B-BDAC-B11D11AA8E17}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {370448E6-BCF6-4590-9469-8A8C8EAE54DB}
EndGlobalSection
EndGlobal
501 changes: 501 additions & 0 deletions Swim Prevent/App.Designer.cs

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Swim Prevent/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

166 changes: 166 additions & 0 deletions Swim Prevent/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Swim_Prevent {
public partial class App : Form {
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool HideCaret(IntPtr hWnd);
public static bool closed = false;

public App() {
InitializeComponent();
ClickListener.Subscribe();
TimeManager.startTimers();
FileManager.createLogs();
Task.Run(() => Detections.runChecks());
// some info
string selfPath = InfoUtil.getSelfFilePath();
string checksum = InfoUtil.getCheckSum(selfPath);
int pid = InfoUtil.getSelfPID();
string currentDateAndTime = InfoUtil.getCurrentDateAndTime();
string usbDriveCheck = InfoUtil.scanForUsbDrives();
int inputDeviceCount = InfoUtil.getInputDeviceCount();
string recycleBinTime = InfoUtil.getRecycleBin();
// write it to app UI
timeInfoBox.AppendText(Environment.NewLine);
timeInfoBox.AppendText(" Swim Prevent Opened At " + currentDateAndTime);
systemInfoBox.AppendText(" Swim Prevent File Path: " + Environment.NewLine + " " + selfPath);
systemInfoBox.AppendText(Environment.NewLine);
systemInfoBox.AppendText(Environment.NewLine);
systemInfoBox.AppendText(" Swim Prevent MD5 CheckSum: " + Environment.NewLine + " " + checksum);
systemInfoBox.AppendText(Environment.NewLine);
systemInfoBox.AppendText(Environment.NewLine);
systemInfoBox.AppendText(" Swim Prevent PID: " + Environment.NewLine + " " + pid);
systemInfoBox.AppendText(Environment.NewLine);
systemInfoBox.AppendText(Environment.NewLine);
systemInfoBox.AppendText(" Recycle Bin Last Cleared: " + Environment.NewLine + " " + recycleBinTime);
// write it to the log file too
FileManager.appendLogs(" Swim Prevent Opened At " + currentDateAndTime + Environment.NewLine);
FileManager.appendLogs(" Swim Prevent File Path: " + selfPath + Environment.NewLine);
FileManager.appendLogs(" Swim Prevent MD5 CheckSum: " + checksum + Environment.NewLine);
FileManager.appendLogs(" Swim Prevent PID: " + pid + Environment.NewLine);
FileManager.appendLogs(" Recycle Bin Last Cleared: " + recycleBinTime + Environment.NewLine);
FileManager.appendLogs(" USB Drive Status: " + usbDriveCheck + Environment.NewLine);
FileManager.appendLogs(" USB Device Count: " + inputDeviceCount + Environment.NewLine);
}

public static void render(Object foo, System.Timers.ElapsedEventArgs bar) {
if (closed) return;
if (leftCPS.IsHandleCreated == false) return;
if (rightCPS.IsHandleCreated == false) return;
if (clockLabel.IsHandleCreated == false) return;
if (leftWithDC.IsHandleCreated == false) return;
if (rightWithDC.IsHandleCreated == false) return;
if (leftRecordText.IsHandleCreated == false) return;
if (rightRecord.IsHandleCreated == false) return;
if (leftDcCount.IsHandleCreated == false) return;
if (rightDcCount.IsHandleCreated == false) return;
if (leftAverage.IsHandleCreated == false) return;
if (rightAverage.IsHandleCreated == false) return;
if (leftTotalText.IsHandleCreated == false) return;
if (rightTotal.IsHandleCreated == false) return;
if (leftDcCount.IsHandleCreated == false) return;
if (rightDcCount.IsHandleCreated == false) return;
if (ratioLeftText.IsHandleCreated == false) return;
if (rightAverage.IsHandleCreated == false) return;

leftCPS.Invoke((MethodInvoker)delegate {
leftCPS.Text = ClickListener.leftClicks.Count.ToString();
});

rightCPS.Invoke((MethodInvoker)delegate {
rightCPS.Text = ClickListener.rightClicks.Count.ToString();
});

leftWithDC.Invoke((MethodInvoker)delegate {
leftWithDC.Text = ClickListener.unfilteredLeftClicks.Count.ToString();
});

rightWithDC.Invoke((MethodInvoker)delegate {
rightWithDC.Text = ClickListener.unfilteredRightClicks.Count.ToString();
});

leftRecordText.Invoke((MethodInvoker)delegate {
leftRecordText.Text = ClickListener.topLeftCPS.ToString();
});

rightRecord.Invoke((MethodInvoker)delegate {
rightRecord.Text = ClickListener.topRightCPS.ToString();
});

leftTotalText.Invoke((MethodInvoker)delegate {
leftTotalText.Text = ClickListener.totalLeftClicks.ToString();
});

rightTotal.Invoke((MethodInvoker)delegate {
rightTotal.Text = ClickListener.totalRightClicks.ToString();
});

leftDcCount.Invoke((MethodInvoker)delegate {
leftDcCount.Text = ClickListener.totalFilteredLeftClicks.ToString();
});

rightDcCount.Invoke((MethodInvoker)delegate {
rightDcCount.Text = ClickListener.totalFilteredRightClicks.ToString();
});

ratioLeftText.Invoke((MethodInvoker)delegate {
ratioLeftText.Text = ClickListener.ratioLeft.ToString();
});

rightAverage.Invoke((MethodInvoker)delegate {
rightAverage.Text = ClickListener.ratioRight.ToString();
});

clockLabel.Invoke((MethodInvoker)delegate {
clockLabel.Text = TimeManager.clock;
});
}

public static void updateLogBox(string msg) {
logBox.Invoke((MethodInvoker)delegate {
logBox.BackColor = Color.Black;
logBox.ForeColor = Color.White;
logBox.AppendText(msg);
logBox.AppendText(Environment.NewLine);
});
FileManager.appendLogs(msg);
}

private void hideCaret(object sender, EventArgs e) {
HideCaret(logBox.Handle);
HideCaret(clickInfoBox.Handle);
HideCaret(timeInfoBox.Handle);
HideCaret(systemInfoBox.Handle);
}

public static async Task closeAsync() {
closed = true;
TimeManager.stopTimers();
ClickListener.Unsubscribe();
// info dump that can be written to a log file after closing
string selfPath = InfoUtil.getSelfFilePath();
string checksum = InfoUtil.getCheckSum(selfPath);
int pid = InfoUtil.getSelfPID();
string currentDateAndTime = InfoUtil.getCurrentDateAndTime();
string usbDriveCheck = InfoUtil.scanForUsbDrives();
int inputDeviceCount = InfoUtil.getInputDeviceCount();
string parsedUSB = InfoUtil.readUSB();
string recycleBinTime = InfoUtil.getRecycleBin();
// write to log file
FileManager.appendLogs(Environment.NewLine);
FileManager.appendLogs(" Swim Prevent Closed At " + currentDateAndTime + Environment.NewLine);
FileManager.appendLogs(" Swim Prevent File Path: " + selfPath + Environment.NewLine);
FileManager.appendLogs(" Swim Prevent MD5 CheckSum: " + checksum + Environment.NewLine);
FileManager.appendLogs(" Swim Prevent PID: " + pid + Environment.NewLine);
FileManager.appendLogs(" Recycle Bin Last Cleared: " + recycleBinTime + Environment.NewLine);
FileManager.appendLogs(" USB Drive Status: " + usbDriveCheck + Environment.NewLine);
FileManager.appendLogs(" USB Device Count: " + inputDeviceCount + Environment.NewLine);
await Task.Run(() => Detections.runChecks());
// Debug.WriteLine("List of USB Input Devices: " + parsedUSB); // this is usually a lot of spam and not worth looking at half the time
}
}
}
120 changes: 120 additions & 0 deletions Swim Prevent/App.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
47 changes: 47 additions & 0 deletions Swim Prevent/CPS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Swim_Prevent {
class CPS {
// the way this works is if the click has been alive longer than 1000 milliseconds then remove it from the cps stack
// did it in differenent managers to be async
public static void leftCpsManager(Object foo, System.Timers.ElapsedEventArgs bar) {
if (ClickListener.leftClicks.Count <= 0 || App.closed) return;
var oldestLeftClickTime = Convert.ToInt64(ClickListener.leftClicks[0]);
var leftClickDeltaTime = Math.Abs(oldestLeftClickTime - InfoUtil.getTimeNow());
if (leftClickDeltaTime >= 1000 && ClickListener.leftClicks.Count > 0) {
ClickListener.leftClicks.RemoveAt(0);
}
}

public static void rightCpsManager(Object foo, System.Timers.ElapsedEventArgs bar) {
if (ClickListener.rightClicks.Count <= 0 || App.closed) return;
var oldestRightClickTime = Convert.ToInt64(ClickListener.rightClicks[0]);
var rightClickDeltaTime = Math.Abs(oldestRightClickTime - InfoUtil.getTimeNow());
if (rightClickDeltaTime >= 1000 && ClickListener.rightClicks.Count > 0) {
ClickListener.rightClicks.RemoveAt(0);
}
}

public static void uncappedLeftCpsManager(Object foo, System.Timers.ElapsedEventArgs bar) {
if (ClickListener.unfilteredLeftClicks.Count <= 0 || App.closed) return;
var oldestClickTime = Convert.ToInt64(ClickListener.unfilteredLeftClicks[0]);
var deltaTime = Math.Abs(oldestClickTime - InfoUtil.getTimeNow());
if (deltaTime >= 1000 && ClickListener.unfilteredLeftClicks.Count > 0) {
ClickListener.unfilteredLeftClicks.RemoveAt(0);
}
}

public static void uncappedRightCpsManager(Object foo, System.Timers.ElapsedEventArgs bar) {
if (ClickListener.unfilteredRightClicks.Count <= 0 || App.closed) return;
var oldestClickTime = Convert.ToInt64(ClickListener.unfilteredRightClicks[0]);
var deltaTime = Math.Abs(oldestClickTime - InfoUtil.getTimeNow());
if (deltaTime >= 1000 && ClickListener.unfilteredRightClicks.Count > 0) {
ClickListener.unfilteredRightClicks.RemoveAt(0);
}
}
}
}
Loading

0 comments on commit f30c7ca

Please sign in to comment.