Skip to content

Instantly share code, notes, and snippets.

View ljmccarthy's full-sized avatar

Luke McCarthy ljmccarthy

View GitHub Profile
#!/bin/sh
HDA=disk.img
run_qemu() {
qemu-system-i386 \
-cpu pentium \
-m size=64M \
-vga cirrus \
-soundhw sb16,adlib \
fn cString(comptime str: []const u8) [*]const u8 {
return &(str ++ "\x00");
}
fn cStringArray(comptime strArray: [][]const u8) [*]const ?[*]const u8 {
comptime var out : [strArray.len + 1] ?[*]const u8 = undefined;
inline for (strArray) |str, i| {
out[i] = comptime cString(str);
}
out[strArray.len] = null;
const std = @import("std");
const ExprType = enum {
Val,
Var,
Add,
Mul,
};
const Value = u32;
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;
pub const ArgIteratorWindows = struct {
index: usize,
count: usize,
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;
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]);
}
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();
@ljmccarthy
ljmccarthy / removeable_drives_wmi.ps1
Created March 25, 2019 14:38
List removeable drives using WMI query
Get-WmiObject -query "SELECT * FROM Win32_DiskDrive WHERE MediaType = 'Removable Media'" | Select-Object *
@ljmccarthy
ljmccarthy / writable_removeable_drives.ps1
Last active March 25, 2019 10:53
List removable writable drives on Windows
Get-WmiObject -Class Win32_DiskDrive |
Where-Object {$_.Capabilities -contains 3 -and $_.MediaType -eq "Removable Media"} |
Select-Object Caption, Size, SerialNumber, InterfaceType, DeviceID, Status
@ljmccarthy
ljmccarthy / det386.asm
Last active December 9, 2018 01:15
Detect 32-bit processor
format MZ
entry main:start
use16
segment main
start:
call detect_i386
mov dx, strings.error
jnc .print