Skip to content

Instantly share code, notes, and snippets.

View caloni's full-sized avatar

Wanderley Caloni caloni

View GitHub Profile
#include <windows.h>
#include <windns.h>
#include <iostream>
#pragma comment(lib, "Dnsapi.lib")
#pragma comment(lib, "Ws2_32.lib")
int main() {
PDNS_RECORD pResult = nullptr;
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
class PrinterMonitor
{
private const int PRINTER_CHANGE_ADD_JOB = 0x00000100;
private const int PRINTER_CHANGE_SET_JOB = 0x00000200;
private const int PRINTER_CHANGE_DELETE_JOB = 0x00000400;
@caloni
caloni / SpawnControlCenter.cpp
Created July 9, 2025 13:11
Win32 GUI "control‑center" that can spawn further copies of itself
// spawn_control_center.cpp – Win32 GUI "control‑center" that can spawn further
// copies of itself under a (parametrizable) Job Object, optionally at Low‑IL, and
// demonstrates ChangeWindowMessageFilterEx + UserHandleGrantAccess so processes can
// PostMessage across UIPI.
//
// Build (VS Developer Prompt):
// cl /EHsc /W4 /nologo /D_UNICODE /DUNICODE spawn_control_center.cpp \
// user32.lib advapi32.lib
//
// Notes / How to use at runtime
#include <windows.h>
#include <dbghelp.h>
#include <algorithm>
#include <cstdint>
#include <filesystem>
#include <iostream>
#include <string>
#include <vector>
@caloni
caloni / hook_using_detour_sample.cpp
Created March 21, 2025 13:20
A small base to maintain hooks using Detour. Inject DLL using ProcessHacker 2.
#include "pch.h"
#include <detours.h>
#include <windows.h>
#include <wincred.h>
#include <strsafe.h>
#include <mutex>
#include <vector>
using namespace std;
/* Solves
* https://www.hackerrank.com/challenges/array-and-simple-queries/problem
* But without caring about limited resources =)
* @author Wanderley Caloni <[email protected]>
* @date 2024-09-05
*/
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
/*
Multiple peers Wireguard calculation
Wireguard does not support overlapping allowed ips for multiple peers. To cover all possible ips excluding others for secondary peers some calculation is needed to mount the allowed ips list derived from 0.0.0.0.
*/
using System.Net;
public class Program
{
private static void CalculateWireguardAllowedIps(ref HashSet<IPNetwork2> list, IPNetwork2 ip, IPNetwork2 remove)
@caloni
caloni / joao_pedro_brites.cpp
Last active February 10, 2023 10:21
João Pedro Brites no Império C++
//******TESTAR EM LINUX******
//*******CONFERIR SE A IDENTAÇÃO ESTÁ HOMOGENEA OU ESPACOS OU TAB********
//*****CRIAR CABEÇALHO******
//TODO colocar exemplo de CSV, já que ele começa lendo um.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#define MAX_BEBIDAS_NA_ESTEIRA 3
#define MAX_ESTEIRAS 2
typedef struct esteira_s
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmpstr(void const *a, void const *b)
{
const char const *aa = *(const char const **)a;
const char const *bb = *(const char const **)b;
return strcmp(aa, bb);