Created
January 10, 2026 17:08
-
-
Save PatoFlamejanteTV/484e5aa568fe828528131b7e9b34fcb8 to your computer and use it in GitHub Desktop.
C# Lib for low level stuff, made by CYBERWARE too.
This file contains hidden or 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
| /* | |
| ################################################################################# | |
| # ____ _____ _ _ _ ______ # | |
| # |_ \|_ _| (_) / |_ (_) .' ____ \ # | |
| # | \ | | __ `| |-'_ .--. __ .---. __ _ | (___ \_| # | |
| # | |\ \| | [ | | | [ `/'`\][ | / /'`\][ | | | _.____`. # | |
| # _______ _| |_\ |_ | | | |, | | | | | \__. | \_/ |,| \____) | _______ # | |
| #|_______||_____|\____|[___]\__/[___] [___]'.___.' '.__.'_/ \______.'|_______|# | |
| # # | |
| ################################################################################# | |
| Copyright (c) 2025 UltimateQuack (PatoFlamejanteTV), CYBERWARE, MalwareLabs | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all | |
| copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| SOFTWARE. | |
| |======================================================================================| | |
| | CYBERWARE IS THE CREATOR OF THE WINAPI FUNCTIONS INTEROPERABILITY LIBRARY, | | |
| | AND THIS LIBRARY IS OFFICIALLY THEIR CREATION. IT WAS DEVELOPED TO FACILITATE | | |
| | THE INTERACTION BETWEEN WINDOWS API FUNCTIONS AND OTHER PROGRAMMING LANGUAGES OR | | |
| | DEVELOPMENT ENVIRONMENTS, PROVIDING A MORE EFFICIENT AND FLEXIBLE WAY TO UTILIZE | | |
| | WINDOWS PLATFORM RESOURCES IN PROGRAMMING AND CYBERSECURITY PROJECTS. | | |
| |======================================================================================| | |
| */ | |
| using System; | |
| using System.Drawing; | |
| using System.IO; | |
| using System.Runtime.InteropServices; | |
| using System.Text; | |
| namespace Windows | |
| { | |
| public class APIs | |
| { | |
| [DllImport("user32.dll")] | |
| public static extern bool UpdateWindow(IntPtr hWnd); | |
| [DllImport("gdi32.dll")] | |
| public static extern uint SetBkColor(IntPtr hdc, uint crColor); | |
| [DllImport("user32.dll")] | |
| public static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint); | |
| [DllImport("user32.dll", SetLastError = true)] | |
| public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo); | |
| public struct COLORREF | |
| { | |
| public byte R; | |
| public byte G; | |
| public byte B; | |
| public COLORREF(byte r, byte g, byte b) | |
| { | |
| R = r; | |
| G = g; | |
| B = b; | |
| } | |
| } | |
| public const uint KEYEVENTF_KEYUP = 0x0002; | |
| public static void InvalidateUpdate() | |
| { | |
| InvalidateRect(IntPtr.Zero, IntPtr.Zero, true); | |
| UpdateWindow(IntPtr.Zero); | |
| } | |
| public static void ClearScreen() | |
| { | |
| RedrawWindow(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN); | |
| } | |
| [DllImport("user32.dll")] | |
| public static extern bool DrawIcon(IntPtr hDC, int x, int y, IntPtr hIcon); | |
| [DllImport("user32.dll")] | |
| public static extern IntPtr LoadIcon(IntPtr hInstance, int lpIconName); | |
| [DllImport("user32.dll")] | |
| public static extern IntPtr GetWindowDC(IntPtr hwnd); | |
| public const int WAVE_FORMAT_PCM = 1; | |
| public const int WAVE_MAPPER = -1; | |
| public const int CALLBACK_NULL = 0; | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct WAVEFORMATEX | |
| { | |
| public ushort wFormatTag; | |
| public ushort nChannels; | |
| public uint nSamplesPerSec; | |
| public uint nAvgBytesPerSec; | |
| public ushort nBlockAlign; | |
| public ushort wBitsPerSample; | |
| public ushort cbSize; | |
| } | |
| public static WAVEFORMATEX wfx = new WAVEFORMATEX(); | |
| [DllImport("user32.dll")] | |
| public static extern bool GetCursorPos(out POINT lpPoint); | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct WAVEHDR | |
| { | |
| public IntPtr lpData; | |
| public uint dwBufferLength; | |
| public uint dwBytesRecorded; | |
| public uint dwUser; | |
| public uint dwFlags; | |
| public uint dwLoops; | |
| public IntPtr lpNext; | |
| public uint reserved; | |
| } | |
| [DllImport("winmm.dll", SetLastError = true)] | |
| public static extern int waveOutOpen(out IntPtr hWaveOut, uint uDeviceID, ref WAVEFORMATEX lpFormat, IntPtr dwCallback, IntPtr dwInstance, uint fdwOpen); | |
| [DllImport("winmm.dll", SetLastError = true)] | |
| public static extern int waveOutPrepareHeader(IntPtr hWaveOut, ref WAVEHDR lpWaveOutHdr, uint uSize); | |
| [DllImport("winmm.dll", SetLastError = true)] | |
| public static extern int waveOutWrite(IntPtr hWaveOut, ref WAVEHDR lpWaveOutHdr, uint uSize); | |
| [DllImport("winmm.dll", SetLastError = true)] | |
| public static extern int waveOutUnprepareHeader(IntPtr hWaveOut, ref WAVEHDR lpWaveOutHdr, uint uSize); | |
| [DllImport("winmm.dll", SetLastError = true)] | |
| public static extern int waveOutClose(IntPtr hWaveOut); | |
| [DllImport("winmm.dll", SetLastError = true)] | |
| public static extern int waveOutReset(IntPtr hWaveOut); | |
| [DllImport("user32.dll")] | |
| [return: MarshalAs(UnmanagedType.Bool)] | |
| public static extern bool SetCursorPos(int x, int y); [DllImport("user32.dll")] | |
| public static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, UIntPtr dwExtraInfo); | |
| const uint MOUSEEVENTF_ABSOLUTE = 0x8000; | |
| const uint MOUSEEVENTF_LEFTDOWN = 0x0002; | |
| const uint MOUSEEVENTF_LEFTUP = 0x0004; | |
| const uint MOUSEEVENTF_MIDDLEDOWN = 0x0020; | |
| const uint MOUSEEVENTF_MIDDLEUP = 0x0040; | |
| const uint MOUSEEVENTF_MOVE = 0x0001; | |
| const uint MOUSEEVENTF_RIGHTDOWN = 0x0008; | |
| const uint MOUSEEVENTF_RIGHTUP = 0x0010; | |
| const uint MOUSEEVENTF_XDOWN = 0x0080; | |
| const uint MOUSEEVENTF_XUP = 0x0100; | |
| const uint MOUSEEVENTF_WHEEL = 0x0800; | |
| const uint MOUSEEVENTF_HWHEEL = 0x01000; | |
| public enum MouseEventFlags : uint | |
| { | |
| LEFTDOWN = 0x00000002, | |
| LEFTUP = 0x00000004, | |
| MIDDLEDOWN = 0x00000020, | |
| MIDDLEUP = 0x00000040, | |
| MOVE = 0x00000001, | |
| ABSOLUTE = 0x00008000, | |
| RIGHTDOWN = 0x00000008, | |
| RIGHTUP = 0x00000010, | |
| WHEEL = 0x00000800, | |
| XDOWN = 0x00000080, | |
| XUP = 0x00000100 | |
| } | |
| public enum MouseEventDataXButtons : uint | |
| { | |
| XBUTTON1 = 0x00000001, | |
| XBUTTON2 = 0x00000002 | |
| } | |
| [DllImport("ntdll.dll", SetLastError = true)] | |
| public static extern int NtSetInformationProcess(IntPtr processHandle, int processInformationClass, ref int processInformation, int processInformationLength); | |
| [DllImport("kernel32.dll", SetLastError = true)] | |
| public static extern void Sleep(uint dwMilliseconds); | |
| [DllImport("gdi32.dll")] | |
| public static extern IntPtr CreatePen(PenStyle fnPenStyle, int nWidth, uint crColor); | |
| [DllImport("user32.dll", SetLastError = true)] | |
| public static extern IntPtr GetDC(IntPtr hWnd); | |
| [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleDC", SetLastError = true)] | |
| public static extern IntPtr CreateCompatibleDC(IntPtr hdc); | |
| [DllImport("gdi32.dll", EntryPoint = "SelectObject")] | |
| public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool MoveToEx(IntPtr hdc, int X, int Y, IntPtr lpPoint); | |
| [DllImport("gdi32.dll", SetLastError = true)] | |
| public static extern bool MaskBlt(IntPtr hdcDest, int xDest, int yDest, int width, int height, IntPtr hdcSrc, int xSrc, int ySrc, IntPtr hbmMask, int xMask, int yMask, uint rop); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool LineTo(IntPtr hdc, int nXEnd, int nYEnd); | |
| [DllImport("gdi32.dll", EntryPoint = "DeleteObject")] | |
| [return: MarshalAs(UnmanagedType.Bool)] | |
| public static extern bool DeleteObject(IntPtr hObject); | |
| [DllImport("gdi32.dll", EntryPoint = "BitBlt", SetLastError = true)] | |
| [return: MarshalAs(UnmanagedType.Bool)] | |
| public static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool StretchBlt(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, | |
| IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, | |
| uint dwRop); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool PlgBlt(IntPtr hdcDest, POINT[] lpPoint, IntPtr hdcSrc, | |
| int nXSrc, int nYSrc, int nWidth, int nHeight, IntPtr hbmMask, int xMask, | |
| int yMask); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool PatBlt(IntPtr hdc, int nXLeft, int nYLeft, int nWidth, int nHeight, uint dwRop); | |
| [DllImport("gdi32.dll", ExactSpelling = true, PreserveSig = true, SetLastError = true)] | |
| public static extern IntPtr Ellipse(IntPtr hdc, int nLeftRect, int nTopRect, | |
| int nRightRect, int nBottomRect); | |
| [DllImport("gdi32.dll", EntryPoint = "GdiAlphaBlend")] | |
| public static extern bool AlphaBlend(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, | |
| int nWidthDest, int nHeightDest, | |
| IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, | |
| BLENDFUNCTION blendFunction); | |
| [DllImport("gdi32.dll")] | |
| public static extern IntPtr CreateSolidBrush(uint crColor); | |
| [DllImport("user32.dll")] | |
| public static extern bool DrawIconEx(IntPtr hdc, int x, int y, | |
| IntPtr hIcon, int cx, int cy, | |
| uint istepIfAniCur, IntPtr hbrFlickerFreeDraw, uint diFlags); | |
| [DllImport("gdi32.dll")] | |
| public static extern IntPtr CreateBitmap(int nWidth, int nHeight, uint cPlanes, uint cBitsPerPel, IntPtr lpvBits); | |
| [DllImport("gdi32.dll", EntryPoint = "DeleteDC")] | |
| public static extern bool DeleteDC(IntPtr hdc); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool FloodFill(IntPtr hdc, int nXStart, int nYStart, uint crFill); | |
| [DllImport("gdi32.dll", EntryPoint = "GdiGradientFill", ExactSpelling = true)] | |
| public static extern bool GradientFill( | |
| IntPtr hdc, | |
| TRIVERTEX[] pVertex, | |
| uint dwNumVertex, | |
| GRADIENT_RECT[] pMesh, | |
| uint dwNumMesh, | |
| GRADIENT_FILL dwMode); | |
| [DllImport("user32.dll")] | |
| public static extern IntPtr GetDesktopWindow(); | |
| [DllImport("user32.dll")] | |
| public static extern bool InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase); | |
| [DllImport("User32.dll")] | |
| public static extern int ReleaseDC(IntPtr hwnd, IntPtr dc); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool FillRgn(IntPtr hdc, IntPtr hrgn, IntPtr hbr); | |
| [DllImport("gdi32.dll")] | |
| public static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, | |
| int nBottomRect); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool Pie(IntPtr hdc, int nLeftRect, int nTopRect, int nRightRect, | |
| int nBottomRect, int nXRadial1, int nYRadial1, int nXRadial2, int nYRadial2); | |
| [DllImport("gdi32.dll", SetLastError = true)] | |
| public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO pbmi, uint iUsage, out IntPtr ppvBits, IntPtr hSection, uint dwOffset); | |
| [DllImport("gdi32.dll", EntryPoint = "CreateCompatibleBitmap")] | |
| public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool Rectangle(IntPtr hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect); | |
| [DllImport("gdi32.dll")] | |
| public static extern uint SetPixel(IntPtr hdc, int X, int Y, int crColor); | |
| [DllImport("gdi32.dll")] | |
| public static extern IntPtr GetPixel(IntPtr hdc, int nXPos, int nYPos); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool AngleArc(IntPtr hdc, int X, int Y, uint dwRadius, | |
| float eStartAngle, float eSweepAngle); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool RoundRect(IntPtr hdc, int nLeftRect, int nTopRect, | |
| int nRightRect, int nBottomRect, int nWidth, int nHeight); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool DeleteMetaFile(IntPtr hmf); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool CancelDC(IntPtr hdc); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool Polygon(IntPtr hdc, POINT[] lpPoints, int nCount); | |
| [DllImport("gdi32.dll")] | |
| public static extern int SetBitmapBits(IntPtr hbmp, int cBytes, RGBQUAD[] lpBits); | |
| [DllImport("kernel32.dll", SetLastError = true)] | |
| public static extern bool Beep(uint dwFreq, uint dwDuration); | |
| [DllImport("user32.dll")] | |
| public static extern bool BlockInput(bool block); | |
| [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
| public static extern IntPtr LoadImage(IntPtr hinst, string lpszName, uint uType, | |
| int cxDesired, int cyDesired, uint fuLoad); | |
| [DllImport("user32.dll", SetLastError = true)] | |
| public static extern int DestroyIcon(IntPtr hIcon); | |
| [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
| public static extern IntPtr LoadLibraryEx(IntPtr lpFileName, IntPtr hFile, LoadLibraryFlags dwFlags); | |
| [DllImport("user32.dll")] | |
| public static extern IntPtr LoadBitmap(IntPtr hInstance, string lpBitmapName); | |
| [DllImport("user32.dll")] | |
| public static extern IntPtr BeginPaint(IntPtr hwnd, out PAINTSTRUCT lpPaint); | |
| [DllImport("user32.dll")] | |
| public static extern bool EndPaint(IntPtr hWnd, out PAINTSTRUCT lpPaint); | |
| [DllImport("gdi32.dll")] | |
| public static extern int SetStretchBltMode(IntPtr hdc, StretchBltMode iStretchMode); | |
| [DllImport("gdi32.dll")] | |
| public static extern int StretchDIBits(IntPtr hdc, int XDest, int YDest, | |
| int nDestWidth, int nDestHeight, int XSrc, int YSrc, int nSrcWidth, | |
| int nSrcHeight, RGBQUAD rgbq, [In] ref BITMAPINFO lpBitsInfo, DIB_Color_Mode dib_mode, | |
| uint dwRop); | |
| [DllImport("gdi32.dll")] | |
| public static extern bool SetDeviceGammaRamp(IntPtr hDC, ref RAMP lpRamp); | |
| [DllImport("Gdi32", EntryPoint = "GetBitmapBits")] | |
| public extern static long GetBitmapBits([In] IntPtr hbmp, [In] int cbBuffer, RGBQUAD[] lpvBits); | |
| [DllImport("gdi32.dll")] | |
| public static extern IntPtr CreateHatchBrush(int iHatch, uint Color); | |
| public static uint RGB(int r, int g, int b) | |
| { | |
| return (uint)((b << 16) | (g << 8) | r); | |
| } | |
| [DllImport("gdi32.dll")] | |
| static extern IntPtr CreatePatternBrush(IntPtr hbmp); | |
| [DllImport("user32.dll")] | |
| public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); | |
| [DllImport("user32.dll")] | |
| public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); | |
| [DllImport("gdi32.dll")] | |
| static extern IntPtr CreateDIBitmap(IntPtr hdc, [In] ref BITMAPINFOHEADER | |
| lpbmih, uint fdwInit, byte[] lpbInit, [In] ref BITMAPINFO lpbmi, | |
| uint fuUsage); | |
| [DllImport("gdi32.dll")] | |
| public static extern int SetDIBitsToDevice(IntPtr hdc, int XDest, int YDest, uint | |
| dwWidth, uint dwHeight, int XSrc, int YSrc, uint uStartScan, uint cScanLines, | |
| byte[] lpvBits, [In] ref BITMAPINFO lpbmi, uint fuColorUse); | |
| [DllImport("gdi32.dll")] | |
| public static extern IntPtr SetDIBits(IntPtr hdc, IntPtr hbm, uint start, int line, int lpBits, [In] ref BITMAPINFO lpbmi, DIB_Color_Mode ColorUse); | |
| [DllImport("ntdll.dll", SetLastError = true)] | |
| public static extern int RtlAdjustPrivilege(ulong privilege, bool enablePrivilege, bool isThreadPrivilege, out bool previousValue); | |
| [DllImport("ntdll.dll", SetLastError = true)] | |
| public static extern int NtRaiseHardError(uint ErrorStatus, uint NumberOfParameters, IntPtr UnicodeStringParamMask, IntPtr Parameters, uint ResponseOption, out uint Response); | |
| [DllImport("kernel32.dll", SetLastError = true)] | |
| [return: MarshalAs(UnmanagedType.Bool)] | |
| public static extern bool SetFileAttributes(string lpFileName, FileAttributes dwFileAttributes); | |
| [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] | |
| public static extern bool DeleteFile(string lpFileName); | |
| [DllImport("user32.dll")] | |
| public static extern int GetSystemMetrics(int nIndex); | |
| [DllImport("user32.dll", SetLastError = true)] | |
| public static extern bool RedrawWindow(IntPtr hwnd, IntPtr lprcInvalid, IntPtr hrgnUpdate, uint dwFlags); | |
| [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] | |
| public struct RAMP | |
| { | |
| [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] | |
| public UInt16[] Red; | |
| [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] | |
| public UInt16[] Green; | |
| [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] | |
| public UInt16[] Blue; | |
| } | |
| [StructLayoutAttribute(LayoutKind.Sequential)] | |
| public struct BITMAPINFO | |
| { | |
| public BITMAPINFOHEADER bmiHeader; | |
| [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 1, ArraySubType = UnmanagedType.Struct)] | |
| public RGBQUAD[] bmiColors; | |
| } | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct BITMAPINFOHEADER | |
| { | |
| public uint biSize; | |
| public int biWidth; | |
| public int biHeight; | |
| public ushort biPlanes; | |
| public ushort biBitCount; | |
| public uint biSizeImage; | |
| public int biXPelsPerMeter; | |
| public int biYPelsPerMeter; | |
| public uint biClrUsed; | |
| public uint biClrImportant; | |
| public uint biCompression; | |
| public void Init() | |
| { | |
| biSize = (uint)Marshal.SizeOf(this); | |
| } | |
| } | |
| [DllImport("user32.dll", CharSet = CharSet.Auto)] | |
| public static extern int MessageBox(IntPtr hWnd, string text, string caption, uint type); | |
| public enum BitmapCompressionMode : uint | |
| { | |
| BI_RGB = 0, | |
| BI_RLE8 = 1, | |
| BI_RLE4 = 2, | |
| BI_BITFIELDS = 3, | |
| BI_JPEG = 4, | |
| BI_PNG = 5 | |
| } | |
| public enum DIB_Color_Mode : uint | |
| { | |
| DIB_RGB_COLORS = 0, | |
| DIB_PAL_COLORS = 1 | |
| } | |
| public enum StretchBltMode : int | |
| { | |
| ANDSCANS = 1, | |
| ORSCANS = 2, | |
| DELETESCANS = 3, | |
| HALFTONE = 4, | |
| } | |
| public delegate bool EnumChildProc(IntPtr hWnd, IntPtr lParam); | |
| [DllImport("user32.dll", CharSet = CharSet.Auto)] | |
| public static extern bool EnumChildWindows(IntPtr hWndParent, EnumChildProc lpEnumFunc, IntPtr lParam); | |
| [DllImport("user32.dll", CharSet = CharSet.Auto)] | |
| public static extern bool SendMessageTimeout(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam, uint fuFlags, uint uTimeout, out IntPtr lpdwResult); | |
| [DllImport("user32.dll", CharSet = CharSet.Auto)] | |
| public static extern bool SendMessageTimeout(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam, uint fuFlags, uint uTimeout, out IntPtr lpdwResult); | |
| public const uint WM_GETTEXT = 0x000D; | |
| public const uint WM_SETTEXT = 0x000C; | |
| public const uint SMTO_ABORTIFHUNG = 0x0002; | |
| public const uint DIB_RGB_COLORS = 0; | |
| public const int BI_RGB = 0; | |
| public const int IDI_ERROR = 32513; | |
| public const int IDI_WARNING = 32515; | |
| public const int IDI_INFORMATION = 32516; | |
| public const int IDI_QUESTION = 32514; | |
| public const uint MB_OK = 0x00000000; | |
| public const uint MB_OKCANCEL = 0x00000001; | |
| public const uint MB_YESNO = 0x00000004; | |
| public const uint MB_YESNOCANCEL = 0x00000003; | |
| public const uint MB_ICONEXCLAMATION = 0x00000030; | |
| public const uint MB_ICONWARNING = 0x00000030; | |
| public const uint MB_ICONERROR = 0x00000010; | |
| public const uint MB_ICONINFORMATION = 0x00000040; | |
| public const uint MB_ICONQUESTION = 0x00000020; | |
| public const uint MB_DEFBUTTON1 = 0x00000000; | |
| public const uint MB_DEFBUTTON2 = 0x00000100; | |
| public const uint MB_DEFBUTTON3 = 0x00000200; | |
| public const uint MB_DEFBUTTON4 = 0x00000300; | |
| public const int LR_DEFAULTCOLOR = 0x0000; | |
| public const int LR_MONOCHROME = 0x0001; | |
| public const int LR_COPYRETURNORG = 0x0004; | |
| public const int LR_COPYDELETEORG = 0x0008; | |
| public const int LR_LOADFROMFILE = 0x0010; | |
| public const int LR_LOADTRANSPARENT = 0x0020; | |
| public const int LR_DEFAULTSIZE = 0x0040; | |
| public const int LR_VGACOLOR = 0x0080; | |
| public const int LR_LOADMAP3DCOLORS = 0x1000; | |
| public const int LR_CREATEDIBSECTION = 0x2000; | |
| public const int LR_COPYFROMRESOURCE = 0x4000; | |
| public const int LR_SHARED = 0x8000; | |
| public const int BreakOnTermination = 0x1D; | |
| public static int isCritical = 1; | |
| public const int SW_HIDE = 0; | |
| public const int SW_SHOWNORMAL = 1; | |
| public const int SW_SHOWMINIMIZED = 2; | |
| public const int SW_SHOWMAXIMIZED = 3; | |
| public const int SW_SHOWNOACTIVATE = 4; | |
| public const int SW_SHOW = 5; | |
| public const int SW_MINIMIZE = 6; | |
| public const int SW_SHOWMINNOACTIVE = 7; | |
| public const int SW_SHOWNA = 8; | |
| public const int SW_RESTORE = 9; | |
| public const int SW_SHOWDEFAULT = 10; | |
| public const int SW_FORCEMINIMIZE = 11; | |
| public const uint SRCCOPY = 0x00CC0020; | |
| public const uint SRCPAINT = 0x00EE0086; | |
| public const uint SRCAND = 0x008800C6; | |
| public const uint SRCINVERT = 0x00660046; | |
| public const uint SRCERASE = 0x00440328; | |
| public const uint NOTSRCCOPY = 0x00330008; | |
| public const uint NOTSRCERASE = 0x001100A6; | |
| public const uint MERGECOPY = 0x00C000CA; | |
| public const uint MERGEPAINT = 0x00BB0226; | |
| public const uint PATCOPY = 0x00F00021; | |
| public const uint PATPAINT = 0x00FB0A09; | |
| public const uint PATINVERT = 0x005A0049; | |
| public const uint DSTINVERT = 0x00550009; | |
| public const uint BLACKNESS = 0x00000042; | |
| public const uint WHITENESS = 0x00FF0062; | |
| public const uint CAPTUREBLT = 0x40000000; | |
| public const uint CUSTOM = 0x00100C85; | |
| public const uint RDW_INVALIDATE = 0x0001; | |
| public const uint RDW_ERASE = 0x0004; | |
| public const uint RDW_ALLCHILDREN = 0x0080; | |
| public const int RDW_INTERNALPAINT = 0x0002; | |
| public const int RDW_UPDATENOW = 0x0100; | |
| public const int RDW_NOERASE = 0x0020; | |
| public const uint STATUS_ASSERTION_FAILURE = 0xC0000420; | |
| public const uint INFINITE = 0xFFFFFFFF; | |
| public const int SM_CXSCREEN = 0; | |
| public const int SM_CYSCREEN = 1; | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct PAINTSTRUCT | |
| { | |
| public IntPtr hdc; | |
| public bool fErase; | |
| public RECT rcPaint; | |
| public bool fRestore; | |
| public bool fIncUpdate; | |
| [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] rgbReserved; | |
| } | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct RECT | |
| { | |
| public int Left, Top, Right, Bottom; | |
| public RECT(int left, int top, int right, int bottom) | |
| { | |
| Left = left; | |
| Top = top; | |
| Right = right; | |
| Bottom = bottom; | |
| } | |
| public RECT(System.Drawing.Rectangle r) : this(r.Left, r.Top, r.Right, r.Bottom) { } | |
| public int X | |
| { | |
| get { return Left; } | |
| set { Right -= (Left - value); Left = value; } | |
| } | |
| public int Y | |
| { | |
| get { return Top; } | |
| set { Bottom -= (Top - value); Top = value; } | |
| } | |
| public int Height | |
| { | |
| get { return Bottom - Top; } | |
| set { Bottom = value + Top; } | |
| } | |
| public int Width | |
| { | |
| get { return Right - Left; } | |
| set { Right = value + Left; } | |
| } | |
| public System.Drawing.Point Location | |
| { | |
| get { return new System.Drawing.Point(Left, Top); } | |
| set { X = value.X; Y = value.Y; } | |
| } | |
| public System.Drawing.Size Size | |
| { | |
| get { return new System.Drawing.Size(Width, Height); } | |
| set { Width = value.Width; Height = value.Height; } | |
| } | |
| public static implicit operator System.Drawing.Rectangle(RECT r) | |
| { | |
| return new System.Drawing.Rectangle(r.Left, r.Top, r.Width, r.Height); | |
| } | |
| public static implicit operator RECT(System.Drawing.Rectangle r) | |
| { | |
| return new RECT(r); | |
| } | |
| public static bool operator ==(RECT r1, RECT r2) | |
| { | |
| return r1.Equals(r2); | |
| } | |
| public static bool operator !=(RECT r1, RECT r2) | |
| { | |
| return !r1.Equals(r2); | |
| } | |
| public bool Equals(RECT r) | |
| { | |
| return r.Left == Left && r.Top == Top && r.Right == Right && r.Bottom == Bottom; | |
| } | |
| public override bool Equals(object obj) | |
| { | |
| if (obj is RECT) | |
| return Equals((RECT)obj); | |
| else if (obj is System.Drawing.Rectangle) | |
| return Equals(new RECT((System.Drawing.Rectangle)obj)); | |
| return false; | |
| } | |
| public override int GetHashCode() | |
| { | |
| return ((System.Drawing.Rectangle)this).GetHashCode(); | |
| } | |
| public override string ToString() | |
| { | |
| return string.Format(System.Globalization.CultureInfo.CurrentCulture, "{{Left={0},Top={1},Right={2},Bottom={3}}}", Left, Top, Right, Bottom); | |
| } | |
| } | |
| public enum LoadLibraryFlags : uint | |
| { | |
| DONT_RESOLVE_DLL_REFERENCES = 0x00000001, | |
| LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010, | |
| LOAD_LIBRARY_AS_DATAFILE = 0x00000002, | |
| LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040, | |
| LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020, | |
| LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008, | |
| } | |
| public enum PenStyle : int | |
| { | |
| PS_SOLID = 0, | |
| PS_DASH = 1, | |
| PS_DOT = 2, | |
| PS_DASHDOT = 3, | |
| PS_DASHDOTDOT = 4, | |
| PS_NULL = 5, | |
| PS_INSIDEFRAME = 6, | |
| PS_USERSTYLE = 7, | |
| PS_ALTERNATE = 8, | |
| PS_STYLE_MASK = 0x0000000F, | |
| PS_ENDCAP_ROUND = 0x00000000, | |
| PS_ENDCAP_SQUARE = 0x00000100, | |
| PS_ENDCAP_FLAT = 0x00000200, | |
| PS_ENDCAP_MASK = 0x00000F00, | |
| PS_JOIN_ROUND = 0x00000000, | |
| PS_JOIN_BEVEL = 0x00001000, | |
| PS_JOIN_MITER = 0x00002000, | |
| PS_JOIN_MASK = 0x0000F000, | |
| PS_COSMETIC = 0x00000000, | |
| PS_GEOMETRIC = 0x00010000, | |
| PS_TYPE_MASK = 0x000F0000, | |
| }; | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct POINT | |
| { | |
| public int X; | |
| public int Y; | |
| public POINT(int x, int y) | |
| { | |
| X = x; | |
| Y = y; | |
| } | |
| public static implicit operator System.Drawing.Point(POINT p) | |
| { | |
| return new System.Drawing.Point(p.X, p.Y); | |
| } | |
| public static implicit operator POINT(System.Drawing.Point p) | |
| { | |
| return new POINT(p.X, p.Y); | |
| } | |
| } | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct BLENDFUNCTION | |
| { | |
| public byte BlendOp; | |
| public byte BlendFlags; | |
| public byte SourceConstantAlpha; | |
| public byte AlphaFormat; | |
| public BLENDFUNCTION(byte op, byte flags, byte alpha, byte format) | |
| { | |
| BlendOp = op; | |
| BlendFlags = flags; | |
| SourceConstantAlpha = alpha; | |
| AlphaFormat = format; | |
| } | |
| } | |
| public const int AC_SRC_OVER = 0x00; | |
| public const int AC_SRC_ALPHA = 0x01; | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct GRADIENT_RECT | |
| { | |
| public uint UpperLeft; | |
| public uint LowerRight; | |
| public GRADIENT_RECT(uint upLeft, uint lowRight) | |
| { | |
| UpperLeft = upLeft; | |
| LowerRight = lowRight; | |
| } | |
| } | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct TRIVERTEX | |
| { | |
| public int x; | |
| public int y; | |
| public ushort Red; | |
| public ushort Green; | |
| public ushort Blue; | |
| public ushort Alpha; | |
| public TRIVERTEX(int x, int y, ushort red, ushort green, ushort blue, ushort alpha) | |
| { | |
| this.x = x; | |
| this.y = y; | |
| Red = red; | |
| Green = green; | |
| Blue = blue; | |
| Alpha = alpha; | |
| } | |
| } | |
| public enum GRADIENT_FILL : uint | |
| { | |
| RECT_H = 0, | |
| RECT_V = 1, | |
| TRIANGLE = 2, | |
| OP_FLAG = 0xff | |
| } | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct GRADIENT_TRIANGLE | |
| { | |
| public uint Vertex1; | |
| public uint Vertex2; | |
| public uint Vertex3; | |
| public GRADIENT_TRIANGLE(uint vertex1, uint vertex2, uint vertex3) | |
| { | |
| Vertex1 = vertex1; | |
| Vertex2 = vertex2; | |
| Vertex3 = vertex3; | |
| } | |
| } | |
| [StructLayout(LayoutKind.Sequential, Pack = 1)] | |
| public struct RGBQUAD | |
| { | |
| public byte rgbBlue; | |
| public byte rgbGreen; | |
| public byte rgbRed; | |
| public byte rgbReserved; | |
| } | |
| [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | |
| public struct LOGFONT | |
| { | |
| public int lfHeight; | |
| public int lfWidth; | |
| public int lfEscapement; | |
| public int lfOrientation; | |
| public int lfWeight; | |
| public byte lfItalic; | |
| public byte lfUnderline; | |
| public byte lfStrikeOut; | |
| public byte lfCharSet; | |
| public byte lfOutPrecision; | |
| public byte lfClipPrecision; | |
| public byte lfQuality; | |
| public byte lfPitchAndFamily; | |
| [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] | |
| public string lfFaceName; | |
| } | |
| public enum LogFontOutputQuality : byte | |
| { | |
| DEFAULT_QUALITY = 0, | |
| DRAFT_QUALITY = 1, | |
| PROOF_QUALITY = 2, | |
| } | |
| [DllImport("gdi32.dll", CharSet = CharSet.Unicode)] | |
| public static extern IntPtr CreateFontIndirect(LOGFONT lplf); | |
| [DllImport("gdi32.dll", SetLastError = true)] | |
| public static extern bool TextOut(IntPtr hdc, int nXStart, int nYStart, string lpString, int cbString); | |
| [DllImport("gdi32.dll")] | |
| public static extern int SetTextColor(IntPtr hdc, int crColor); | |
| public static int ColorToInt(Color color) | |
| { | |
| return (color.B << 16) | (color.G << 8) | color.R; | |
| } | |
| [DllImport("gdi32.dll")] | |
| public static extern int SetBkColor(IntPtr hdc, int crColor); | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct CURSORINFO | |
| { | |
| public int cbSize; | |
| public int flags; | |
| public IntPtr hCursor; | |
| public POINT ptScreenPos; | |
| } | |
| [DllImport("user32.dll")] | |
| public static extern bool GetCursorInfo(ref CURSORINFO pci); | |
| [DllImport("user32.dll", SetLastError = true)] | |
| public static extern IntPtr LoadCursorFromFile(string lpFileName); | |
| [DllImport("user32.dll", SetLastError = true)] | |
| public static extern bool SetSystemCursor(IntPtr hcur, uint id); | |
| [DllImport("user32.dll", SetLastError = true)] | |
| public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni); | |
| [DllImport("user32.dll")] | |
| public static extern bool DestroyCursor(IntPtr hCursor); | |
| public const uint OCR_NORMAL = 32512; | |
| public const uint SPI_SETCURSORS = 0x0057; | |
| public const uint SPIF_UPDATEINIFILE = 0x01; | |
| public const uint SPIF_SENDCHANGE = 0x02; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment