Skip to content

Instantly share code, notes, and snippets.

View d3c0d3d's full-sized avatar
⌨️
hacking life...

d3c0d3d.exe d3c0d3d

⌨️
hacking life...
View GitHub Profile
// Use in a .NET console project
// Set <PublishAot>true</PublishAot> and <AllowUnsafeBlocks>true</AllowUnsafeBlocks> in the .csproj
// Run dotnet publish
// Create service: sc create MyService binPath= "C:\full\path\to\Release\net9.0\win-x64\publish\WatchTemp.exe"
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
class Service : IDisposable
{
@noumanurrahman
noumanurrahman / config.lua
Created August 14, 2023 16:56
My LunarVim config
-- Read the docs: https://www.lunarvim.org/docs/configuration
-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6
-- Forum: https://www.reddit.com/r/lunarvim/
-- Discord: https://discord.com/invite/Xb9B4Ny
local dap = require("dap")
lvim.plugins = {
{
"catppuccin/nvim",
name = "catppuccin"
@AndersonTorres
AndersonTorres / zig-em-30-minutos.org
Last active December 27, 2025 20:23
Zig em 30 Minutos (Tradução)
@bats3c
bats3c / ldrloaddll_hook.c
Last active February 22, 2026 16:42
Hook LdrLoadDll to whitelist DLLs being loaded into a process
#include <stdio.h>
#include <windows.h>
#include <winternl.h>
#define dwAllowDllCount 1
CHAR cAllowDlls[dwAllowDllCount][MAX_PATH] = {
"W:\\allowed.dll"
};
VOID HookLoadDll(LPVOID lpAddr);
@mjs3339
mjs3339 / CpuTotalPc.cs
Created March 24, 2020 09:22
Uses the PerformanceCounter to get the Cpu Usage
using System.Diagnostics;
public static class CpuTotalPc
{
private static PerformanceCounter _CPUsage;
public static double CPULoad
{
get
{
if (_CPUsage == null)
try
@Arno0x
Arno0x / TestAssembly.cs
Last active September 12, 2025 14:16
This code shows how to load a CLR in an unmanaged process, then load an assembly from memory (not from a file) and execute a method
/*
================================ Compile as a .Net DLL ==============================
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /target:library /out:TestAssembly.dll TestAssembly.cs
*/
using System.Windows.Forms;
namespace TestNamespace
@mjs3339
mjs3339 / StripHTMLAll.cs
Created October 4, 2018 07:00
C# Strip All Imbedded HTML Content from a String
public static string StripHTMLAll(string source)
{
try
{
string result;
result = source.Replace("\r", " ");
result = result.Replace("\n", " ");
result = result.Replace("\t", " ");
result = Regex.Replace(result, @"( )+", " ", RegexOptions.IgnoreCase);
result = Regex.Replace(result, @"<( )*head([^>])*>", "<head>", RegexOptions.IgnoreCase);
@mjs3339
mjs3339 / SmartI.cs
Last active March 2, 2025 11:17
C# Get Disk/Drive Physical/Logical and Smart Information
public class SmartI
{
private readonly Dictionary<int, Smart> _smartInfo = new Dictionary<int, Smart>();
public readonly HashSet<int> FutureReserchUnknownAttributes = new HashSet<int>();
private static bool Is64Bit => IntPtr.Size == 8;
private static uint OffsetSize => Is64Bit ? 8u : 6u;
public Dictionary<int, Smart> SmartInfo
{
get
{
@xpn
xpn / clr_via_native.c
Created April 11, 2018 21:34
A quick example showing loading CLR via native code
#include "stdafx.h"
int main()
{
ICLRMetaHost *metaHost = NULL;
IEnumUnknown *runtime = NULL;
ICLRRuntimeInfo *runtimeInfo = NULL;
ICLRRuntimeHost *runtimeHost = NULL;
IUnknown *enumRuntime = NULL;
LPWSTR frameworkName = NULL;
@bojanrajkovic
bojanrajkovic / option.cs
Last active March 14, 2024 20:13
Quick and dirty Rust-like Option<T> in C#. Basically untested, use at your own risk!
public static class Option
{
public static Option<T> None<T>() => new None<T>();
public static Option<T> Some<T>(T value) => new Some<T>(value);
}
public class Option<T> : IEquatable<Option<T>>
{
public static Option<T> None => new None<T>();
public bool IsNone => !hasValue;