Skip to content

Instantly share code, notes, and snippets.

@AlexRasch
AlexRasch / MouseDistance.cs
Last active July 2, 2022 17:12
Basic PoC of mouse movement & distance
static void Main(string[] args)
{
/*
* Basic PoC of mouse movement & distance
*
*
*/
Console.Title = "~~* Mouse Distance Poc *~~";
@AlexRasch
AlexRasch / MouseDistance.cpp
Created July 2, 2022 17:10
Mouse Distance
POINT currentMousePosition;
POINT previousMousePosition;
GetCursorPos(&previousMousePosition);
double mouseDistance = 0;
while (true)
{
GetCursorPos(&currentMousePosition);
mouseDistance += sqrt(
pow(currentMousePosition.x - previousMousePosition.x, 2) +
pow(currentMousePosition.y - previousMousePosition.y, 2)
@AlexRasch
AlexRasch / MessageBoxA.cs
Last active July 4, 2022 14:38
MessageBoxA
using System.Runtime.InteropServices; // For Pinvoke & Win Api
namespace ConsoleApp1
{
internal class Program
{
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int MessageBoxA(IntPtr hWnd, String text, String caption, uint type);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
@AlexRasch
AlexRasch / Bitmap.cs
Last active November 16, 2022 20:51
Convert byte[] to bitmap
public static Bitmap CreateBitmapFromData(byte[] binaryData)
{
// calc padding amount
int iPaddedSize = binaryData.Length + (3 - binaryData.Length % 3) + 6;
int iPixelCount = iPaddedSize / 3;
int iCountPerRow = (int)Math.Ceiling(Math.Sqrt(iPixelCount));
Bitmap bmp = new Bitmap(iCountPerRow, iCountPerRow, PixelFormat.Format24bppRgb);
byte[] paddedData = new byte[iPaddedSize];
@AlexRasch
AlexRasch / Program.cs
Created October 17, 2023 13:53
Kod test
using System.Runtime;
namespace CodeTest
{
internal class Program
{
/*
* Complete the 'countSubstrings' function below.
* The function is expected to return an INTEGER.
* The function accepts STRING input_str as parameter.
@AlexRasch
AlexRasch / Program.cs
Created November 6, 2023 21:37
Read resource and dump to disk
using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Net.Mail;
namespace Stub
{
class Program
{
[DllImport("kernel32.dll", SetLastError = true)]