Skip to content

Instantly share code, notes, and snippets.

View yalayabeeb's full-sized avatar

Yala whonow yalayabeeb

View GitHub Profile
@yalayabeeb
yalayabeeb / FileInformation.cs
Last active March 28, 2016 21:47
A class to determine whether an assembly is managed or native. Added process architecture.
using System;
using System.IO;
using System.Reflection;
public static class FileInformation
{
public static ProcessorArchitecture GetArchitecture(string filePath)
{
if (!File.Exists(filePath))
{
@yalayabeeb
yalayabeeb / ThreadingExample.cs
Created December 26, 2015 09:50
Different methods on how to use threads. It also shows which methods wait for the jobs to finish before performing the next block of code and which don't.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ThreadingExample
{
class ThreadingExample
{
private static void Method1()
{
@yalayabeeb
yalayabeeb / Data.cs
Last active December 26, 2015 08:15
A class to save and read data to an XML file.
using System.Collections.Generic;
using System.IO;
using System.Xml;
public class Data
{
public readonly XmlDocument Document;
private readonly string _filePath;
private string CorePath { get; set; }
@yalayabeeb
yalayabeeb / Keyboard.cs
Last active December 28, 2015 06:48
Changes the position of the cursor according to the speed that is set and the key that was pressed. (Mouse Keys)
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class Keyboard
{
#region WinAPI
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr SetWindowsHookEx(int hookType, HookProc lpfn, IntPtr hMod, uint dwThreadId);
@yalayabeeb
yalayabeeb / Resource.cs
Created December 23, 2015 13:09
A simple to use class to write data as a resource to a file.
using System;
using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;
public static class Resource
{
#region WinAPI
[DllImport("kernel32.dll", SetLastError = true)]
@yalayabeeb
yalayabeeb / Log.cs
Last active December 7, 2015 14:01
A class used to create and write to a log file in order to report errors.
using System;
using System.IO;
public class Log
{
public string FilePath { get; set; }
public bool UseCustomFormat { get; set; }
public string Format { get; set; }
@yalayabeeb
yalayabeeb / ImageFunctions.cs
Last active December 27, 2015 12:29
Functions to manipulate images. Planning to add more in the future. (Update: added a function to put the split images back together)
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Windows.Forms;
public static class ImageFunctions
{
@yalayabeeb
yalayabeeb / Sock.cs
Last active May 2, 2017 04:59
A simple wrapper for the Socket class with an example of usage. Updated with encryption & compression/decompression. Fixed crashing when sending data too quickly.
using System;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography;
using System.Text;
public class Sock
@yalayabeeb
yalayabeeb / Memory.cs
Last active October 21, 2018 14:11
A class to read/write mainly integers to a process's memory address.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
public class Memory
{
#region WinAPI
[DllImport("kernel32.dll")]
private static extern IntPtr OpenProcess(uint processAccess, bool bInheritHandle, int processId);