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
| const std = @import("std"); | |
| use std.os.windows; | |
| pub extern "kernel32" stdcallcc fn GetCommandLineW() LPWSTR; | |
| pub extern "kernel32" stdcallcc fn LocalFree(hMem: *c_void) ?*c_void; | |
| pub extern "shell32" stdcallcc fn CommandLineToArgvW(lpCmdLine: LPCWSTR, out_pNumArgs: *c_int) ?[*]LPWSTR; | |
| fn getArgs(allocator: *std.mem.Allocator) ![][]u8 { | |
| var numArgs: c_int = undefined; | |
| var args = CommandLineToArgvW(GetCommandLineW(), &numArgs) orelse return error.OutOfMemory; |
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
| const std = @import("std"); | |
| const File = std.os.File; | |
| fn copyFile(src: File, dst: File) !void { | |
| var buf = []u8 {0} ** 1024; | |
| while (true) { | |
| const n = try src.read(&buf); | |
| if (n == 0) break; | |
| try dst.write(buf[0..n]); | |
| } |
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
| const std = @import("std"); | |
| pub fn main() !void { | |
| const stdout = try std.io.getStdOut(); | |
| var direct_allocator = std.heap.DirectAllocator.init(); | |
| defer direct_allocator.deinit(); | |
| var arena = std.heap.ArenaAllocator.init(&direct_allocator.allocator); | |
| defer arena.deinit(); |
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
| Get-WmiObject -query "SELECT * FROM Win32_DiskDrive WHERE MediaType = 'Removable Media'" | Select-Object * |
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
| Get-WmiObject -Class Win32_DiskDrive | | |
| Where-Object {$_.Capabilities -contains 3 -and $_.MediaType -eq "Removable Media"} | | |
| Select-Object Caption, Size, SerialNumber, InterfaceType, DeviceID, Status |
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
| format MZ | |
| entry main:start | |
| use16 | |
| segment main | |
| start: | |
| call detect_i386 | |
| mov dx, strings.error | |
| jnc .print |
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
| format MZ | |
| entry main:start | |
| use16 | |
| segment main | |
| start: | |
| call detect_cpu | |
| mov dx, strings | |
| mov ds, dx |
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
| format MZ | |
| entry main:start | |
| use16 | |
| segment main | |
| start: | |
| ; detect EGA BIOS | |
| mov ah, 0x12 | |
| mov bl, 0x10 |
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
| #!/usr/bin/env python3 | |
| import os | |
| import re | |
| import sys | |
| def incbin(filename): | |
| with open(filename, 'rb') as f: | |
| data = f.read() | |
| name = os.path.splitext(os.path.basename(filename))[0] |
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
| #include <assert.h> | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| size_t varint_size(uint32_t value) { | |
| return value < 0x80 ? 1 : | |
| value < 0x4000 ? 2 : | |
| value < 0x200000 ? 3 : | |
| value < 0x10000000 ? 4 : 5; |