ASCII case bit twiddling

If you pay a special sort of attention, you may notice that the upper-case and lower-case alphabet characters on the ASCII table are always exactly offset from each other by 32. For example, upper-case A is 65, while the lowercase a is 97 As such the way the binary place value works out, you can manipulate the case of a character by setting or clearing the sixth bit… (2^5 = 32, we start counting bits and everything at 0, we’re programmers!) Decimal 32 expressed as hexadecimal is 0x20 and expressed as binary is 00100000 ...

December 10, 2024 · 4 min

Environment variables

I had the sudden realization that I didn’t really know how environment variables work. I think We all take them for granted, regardless of OS… Some high level details about some such variables and their purpose can be found in the FreeBSD Handbook section 3.9. Shells. You can view such variables in your shell using the env command: root@freebsd:~ # env PAGER=less LANG=C.UTF-8 MAIL=/var/mail/root PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin ENV=/root/.shrc OLDPWD=/ PWD=/root TERM=xterm-256color USER=root HOME=/root SHELL=/bin/sh MM_CHARSET=UTF-8 BLOCKSIZE=K root@freebsd:~ # …but what are all the low level specifics that nobody bothers to ask? ...

November 27, 2024 · 2 min

Initialize your variables

There’s no shortage of material that explains variables in C should be initialized… but I’ve often found the explanation of why to be somewhat lacking. Where do the initial values of a variable come from if you don’t explicitly initialize? ...

August 17, 2024 · 3 min

Guess the number...

A quick demonstration of how one can use a debugger to interactively inspect variables in a running program… ...

April 5, 2024 · 2 min

Patching Binaries

Exercise Summary The idea of this self-inflicted exercise was to see if I could inspect and patch a binary to change the outcome of some conditional code. In days of long past up I had found tutorials on how to patch a binary to bypass copyright protection schemes. The type that would ask a random question, where the answer found in a manual. You know, the one you would have had if the game wasn’t recieved on bootleg floppy diskettes. ...

March 13, 2021 · 4 min