Skip to content

Instantly share code, notes, and snippets.

#include <windows.h>
#include <stdio.h>
int main()
{
// The drive letter of the hard drive you want to get the serial number for
wchar_t drive[] = L"C:\\";
// Buffer to receive the volume serial number
DWORD serial_number;
@duketwo
duketwo / gist:df82510046ded027ff1686f23edead2b
Created January 5, 2023 06:53
HDD Serial DeviceIoControl
#include <windows.h>
#include <memory>
#include <string>
//returns the serial number of the first physical drive in a std::string or an empty std::string in case of failure
//based on http://codexpert.ro/blog/2013/10/26/get-physical-drive-serial-number-part-1/
std::string getFirstHddSerialNumber() {
//get a handle to the first physical drive
HANDLE h = CreateFileW(L"\\\\.\\PhysicalDrive0", 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (h == INVALID_HANDLE_VALUE) return {};
@duketwo
duketwo / mac-vendor.txt
Created April 2, 2023 02:39 — forked from aallan/mac-vendor.txt
List of MAC addresses with vendors identities
000000 Officially Xerox
000001 SuperLAN-2U
000002 BBN (was internal usage only, no longer used)
000003 XEROX CORPORATION
000004 XEROX CORPORATION
000005 XEROX CORPORATION
000006 XEROX CORPORATION
000007 XEROX CORPORATION
000008 XEROX CORPORATION
000009 powerpipes?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@duketwo
duketwo / gist:8f96f860d36803ec6d66d6531c74c92b
Created March 14, 2024 08:06
C# Enumerate TCP connections
using System;
using System.Collections.Generic;
using System.Net;
using System.Runtime.InteropServices;
namespace YourNamespace
{
public class TcpConnectionInfo
{
public IPAddress LocalIPAddress { get; }