Skip to content

Instantly share code, notes, and snippets.

View DJm00n's full-sized avatar

Dimitriy Ryazantcev DJm00n

View GitHub Profile
using System;
class klGDIBitmapConversion
{
public static System.Drawing.Bitmap MainConv(System.Drawing.Bitmap img)
{
System.Drawing.Bitmap b = img;// new System.Drawing.Bitmap("test.jpg");
SplashImage(b, 0, 0);
DateTime dtFaq = DateTime.Now;
System.Drawing.Bitmap b0 = CopyToBpp(b, 8);
TimeSpan tsFaq = DateTime.Now - dtFaq;
@DJm00n
DJm00n / SearchCmp.cs
Created December 29, 2023 14:04
Search UAPKI public key on CMP server.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
namespace CA_Client.Helpers
{
internal static class SearchByCmp
{
@DJm00n
DJm00n / acc.cpp
Created December 7, 2023 11:08
Mouse acceleration
/*****************************************************************************
*
* The algorithm for applying acceleration is:
*
* dxC = dxR
* if A >= 1 and abs(dxR) > T1 then
* dxC = dxR * 2
* if A >= 2 and abs(dxR) > Thres2 then
* dxC = dxR * 4
* end if
@DJm00n
DJm00n / wgi.h
Created December 1, 2023 12:26
Windows.Gaming.Input GUIDs
#include <windows.gaming.input.h>
#include <windows.gaming.input.custom.h>
#include <initguid.h>
DEFINE_GUID(IID___FIEventHandler_1_Windows__CGaming__CInput__CArcadeStick, 0x6afb8188, 0xd28d, 0x539b, 0xbb,0x69, 0xea,0x17,0x63,0xfb,0x99,0x20);
DEFINE_GUID(IID___FIEventHandler_1_Windows__CGaming__CInput__CFlightStick, 0xd57470b1, 0xcc22, 0x5a43, 0x8e,0x18, 0x5c,0xa0,0x64,0xaa,0xfe,0x21);
DEFINE_GUID(IID___FIEventHandler_1_Windows__CGaming__CInput__CGamepad, 0x8a7639ee, 0x624a, 0x501a, 0xbb,0x53, 0x56,0x2d,0x1e,0xc1,0x1b,0x52);
DEFINE_GUID(IID___FIEventHandler_1_Windows__CGaming__CInput__CRacingWheel, 0x352ec824, 0xf64b, 0x5353, 0x80,0xea, 0x7f,0xf5,0x8e,0x3b,0x92,0xa4);
DEFINE_GUID(IID___FIEventHandler_1_Windows__CGaming__CInput__CRawGameController, 0x00621c22, 0x42e8, 0x529f, 0x92,0x70, 0x83,0x6b,0x32,0x93,0x1d,0x72);
DEFINE_GUID(IID___FIIterable_1_Windows__CGaming__CInput__CArcadeStick, 0x9376f457, 0x2da5, 0x544a, 0xa4,0x09, 0xc6,0x36,0xf5,0xd8,0x1c,0x35);
#include "pch.h"
#include "framework.h"
#include "utils_winrt.h"
#include "utils.h"
#include <windows.globalization.h>
#include <objidlbase.h>
/**************************************************************************\
*
* Function Description:
*
* Convert a 32bpp premultiplied ARGB value to
* a 32bpp non-premultiplied ARGB value
*
* Arguments:
*
* argb - Premultiplied ARGB value
@DJm00n
DJm00n / code7.cpp
Last active October 28, 2023 16:11
Make 1 Scancode to HID usage
static uint8_t Win32ScanCodeToHIDUsage(uint16_t scanCode)
{
uint8_t index = (scanCode & 0xff) < 0x80 ? (scanCode & 0xff) : 0x00;
if ((scanCode & 0xff00) != 0)
{
if ((scanCode & 0xff00) == 0xe000)
index |= 0x80;
else
index = 0;
}
@DJm00n
DJm00n / ANI.h
Created June 19, 2023 10:22
Undocumented ANI cursor Win32 API
// user32.dll
// provide either hcur or lpName and iFrame.
// outputs pjifRate (frame time in jiffles - 1/60 sec) and pccur (count of steps in animation sequence)
// returns cursor frame for iFrame
HCURSOR GetCursorFrameInfo(HCURSOR hcur, LPWSTR lpName, int iFrame, OUT LPDWORD pjifRate, OUT LPINT pccur);
@DJm00n
DJm00n / Bcp48Langs.cs
Last active July 3, 2023 18:09
Bcp48Langs PInvoke
[DllImport("winlangdb.dll", ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int GetLanguageNames(string Language, StringBuilder Autonym, StringBuilder EnglishName, StringBuilder LocalName, StringBuilder ScriptName);
[DllImport("winlangdb.dll", ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int LanguagesDatabaseGetChildLanguages(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(HStringMarshaler))] string language,
int sortOrder /*2 or 4*/,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(HStringMarshaler))] string customLanguage,
char delimeter,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(HStringMarshaler))] out string childLanguages);
@DJm00n
DJm00n / gist:ff49af518ddd55dd070f1242fec3039a
Created November 12, 2022 07:48
BitmapColorTranslate(HDC hdcBits, BITMAP* pbm, DWORD rgb)
/*
* using the first pixel as the "transparent" color, make all pixels
* in the hdc that are equal to the "transparent" color the passed
* color.
*/
PRIV VOID BitmapColorTranslate(HDC hdcBits, BITMAP* pbm, DWORD rgb)
{
HDC hdcMask;
HBITMAP hbmMask, hbmT;
HBRUSH hbrT;