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
public static class BinaryUtilities | |
{ | |
[DllImport("dbghelp", CharSet = CharSet.Unicode)] | |
private static extern bool SymInitialize(nint hProcess, string? userSearchPath, bool fInvadeProcess); | |
[DllImport("dbghelp", CharSet = CharSet.Unicode)] | |
private static extern bool SymCleanup(nint hProcess); | |
[DllImport("dbghelp", CharSet = CharSet.Unicode)] | |
private static extern ulong SymLoadModuleEx(nint hProcess, nint hFile, string imageName, string? moduleName, long baseOfDll, int dllSize, nint data, int flags); |
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
extern "C" __declspec(dllimport) BOOL getCursorPos(LPPOINT); | |
extern "C" FARPROC __imp_getCursorPos = GetProcAddress(LoadLibrary(L"user32.dll"), "GetCursorPos"); | |
int main() | |
{ | |
POINT p{}; | |
getCursorPos(&p); | |
return 0; | |
} |
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
#include <windows.h> | |
#include <dxgi.h> | |
#include <D3dkmthk.h> | |
#include <stdio.h> | |
#include "nvml\include\nvml.h" | |
#pragma comment(lib, "nvml\\lib\\nvml.lib") | |
#pragma comment(lib, "dxgi.lib") |
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
using System; | |
using System.Collections.Generic; | |
using System.Drawing; | |
using System.IO; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using System.Runtime.InteropServices.ComTypes; | |
using System.Windows.Forms; | |
namespace OnDemandDataObject; |
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
#include <windows.h> | |
#include <userenv.h> | |
#include <atlbase.h> | |
#include <stdio.h> | |
#include <shlobj.h> | |
#include <string> | |
#pragma comment(lib, "userenv") |
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
var hr = GdiplusStartup(out var token, StartupInputEx.GetDefault(), out var output); | |
using var img = new Bitmap(Environment.GetCommandLineArgs()[1]); | |
[DllImport("gdiplus")] | |
private static extern int GdiplusStartup(out nint token, in StartupInputEx input, out StartupOutput output); | |
private struct StartupInputEx | |
{ | |
public int GdiplusVersion; | |
public nint DebugEventCallback; |
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
public class AuthenticodeSignature | |
{ | |
private AuthenticodeSignature() { } | |
public int Index { get; private set; } | |
public string ProgramName { get; private set; } | |
public string PublisherLink { get; private set; } | |
public string MoreLink { get; private set; } | |
public string SerialNumber { get; private set; } | |
public X509Certificate2 Certificate { get; private set; } | |
public string HashAlgorithm { get; private set; } |
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
using System; | |
using System.Runtime.InteropServices; | |
using System.Runtime.Versioning; | |
using Microsoft.Win32.SafeHandles; | |
using Windows.Win32; | |
using Windows.Win32.Foundation; | |
using Windows.Win32.Graphics.Direct3D; | |
using Windows.Win32.Graphics.Direct3D11; | |
using Windows.Win32.Graphics.Dxgi; | |
using Windows.Win32.Graphics.Dxgi.Common; |
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
public class ConsoleMallocSpy : MallocSpy | |
{ | |
protected override void Log(object message, [CallerMemberName] string methodName = null) => Console.WriteLine(methodName + ": " + message); | |
private readonly ConcurrentDictionary<IntPtr, IntPtr> _blocks = new(); | |
private IntPtr _allocRequest; | |
protected override IntPtr PreAlloc(IntPtr cbRequest) | |
{ |
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
public class JobObject : IDisposable | |
{ | |
private IntPtr _handle; | |
public JobObject(string name = null, bool terminateOnDispose = false) | |
{ | |
Name = name; | |
TerminateOnDispose = terminateOnDispose; | |
_handle = CreateJobObject(IntPtr.Zero, name); | |
if (_handle == IntPtr.Zero) |
NewerOlder