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
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 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
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 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
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 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
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 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
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) |
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
[STAThread] | |
static void Main() | |
{ | |
var mgr = (IShellIconOverlayManager)new CLSID_CFSIconOverlayManager(); | |
Console.WriteLine(mgr.LoadNonloadedOverlayIdentifiers()); | |
} | |
[ComImport, Guid("63B51F81-C868-11D0-999C-00C04FD655E1")] | |
public class CLSID_CFSIconOverlayManager { }; |
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
using System.Drawing; | |
using System.IO; | |
using DirectN; | |
using WicNet; | |
namespace ConsoleApp2 | |
{ | |
internal class Program | |
{ | |
static void Main() |
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
static void Main() | |
{ | |
using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers", false)) | |
{ | |
foreach (var name in key.GetSubKeyNames()) | |
{ | |
Console.WriteLine("'" + name + "'"); | |
using (var sub = key.OpenSubKey(name, false)) | |
{ | |
if (!(sub.GetValue(null) is string def) || !Guid.TryParse(def, out var clsid)) |
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
public static void RunAsDesktopUser(string fileName) | |
{ | |
if (string.IsNullOrWhiteSpace(fileName)) | |
throw new ArgumentException("Value cannot be null or whitespace.", nameof(fileName)); | |
// To start process as shell user you will need to carry out these steps: | |
// 1. Enable the SeIncreaseQuotaPrivilege in your current token | |
// 2. Get an HWND representing the desktop shell (GetShellWindow) | |
// 3. Get the Process ID(PID) of the process associated with that window(GetWindowThreadProcessId) | |
// 4. Open that process(OpenProcess) |
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
static void Main(string[] args) | |
{ | |
var cache = (IImmersiveSettingsCache)new ImmersiveSettingsCache(); | |
var hr = cache.OnSettingChanged(0); | |
} | |
[ComImport, Guid("a919ea73-490e-4d5c-9ba7-97cbc73119fe")] // CLSID_ImmersiveSettingsCache | |
public class ImmersiveSettingsCache | |
{ | |
// don't put anything in there |