Skip to content

Instantly share code, notes, and snippets.

View bitRAKE's full-sized avatar
🏠
Working from home.

Rickey Bowers Jr. bitRAKE

🏠
Working from home.
View GitHub Profile
@bitRAKE
bitRAKE / onetime.inc
Created April 13, 2025 17:10
#pragma once, for fasmg / fasm2:
; We can make a global "#pragma once" mechanism if we assume all files have
; a unique path. Non-cannonical path are fine as long as it's always the same
; form. Be mindful of file organization if you're going to use this.
; Primary benefits:
; + files are not loaded multiple times
; + no change to file needed (i.e. if/endif wrapper)
;macro onetime?: line&
; local name
; match any rest,line
@mmozeiko
mmozeiko / _miniperf_readme.md
Last active April 16, 2025 11:17
get PMU counter values with ETW, perf or kperf

MiniPerf

Example of how to capture CPU counters with ETW on Windows, perf on Linux or kperf on Apple.

Using ETW needs somewhat recently updated Windows 10 or 11. Not sure about exact version.

Currently tested on:

  • etw on Qualcomm Snapdragon X Elite, Windows 11, arm64
  • etw on AMD Zen 3, Windows 11 (with virtualization enabled in BIOS)
@Chillee
Chillee / 1-pw_op_fusion.py
Last active April 6, 2025 19:04
PT 2.0 Benchmarks
import torch
import torch._inductor.config
import time
torch._inductor.config.triton.cudagraphs = False
torch.set_float32_matmul_precision('high')
def bench(f, name=None, iters=100, warmup=5, display=True, profile=False):
for _ in range(warmup):
f()
@bitRAKE
bitRAKE / taskbar.asm
Created June 8, 2022 09:43
Taskbar show/hide app icon example:
format PE64 GUI 6.2 at 0x1234_56780000
include 'mywin.inc'
GWL_EXSTYLE := -20
TaskbarDemo:
iterate msg, WM_INITDIALOG,WM_COMMAND,WM_CLOSE
cmp edx,msg
jz .msg
end iterate
@bitRAKE
bitRAKE / CheckElevation.inc
Last active April 13, 2025 17:17
Checks if the current process in running with elevation ...
; kernel32.dll, advapi32.dll, 79 bytes
CheckElevation:
virtual at RBP-.FRAME
rq 4
.P5 dq ?
.hTok dq ? ; HANDLE
.tLen dd ?
.tInfo TOKEN_ELEVATION
@bitRAKE
bitRAKE / sqrt.g
Last active April 13, 2025 17:17
general square root for fasmg
; with the remainder calculations can be split into pieces and extended later
calminstruction ROOT? result*, remainder*, N*
local rem, prox, bit, temp
compute rem, 0
check N = 0
jyes done
compute prox, 0
compute bit, 1 shl (((bsr N) + 1) and -2)
@bitRAKE
bitRAKE / bitvec.asm
Last active April 13, 2025 17:18
Bit vectors are a native type on x86 ...
; Create static bit vector:
; + ignore value set duplicates
; + invert value set when bit length is negative
struc(name) BITVECTOR bits,values&
local result,offset,char,inverted,_bits
virtual
offset = $
db values ; string or byte array
result = 0
while offset < $
@bitRAKE
bitRAKE / UUID.asm
Last active April 13, 2025 17:19
GUID, UUID, ... ?
; it's many forms and names ...
macro UUID line&
match A - B - C - D - E, line
dd 0x#A
dw 0x#B,0x#C
dq 0x#D#E bswap 8
else match { A =, B =, C =, D { E } },line
dd A
dw B,C
@bitRAKE
bitRAKE / mkdb.asm
Created May 11, 2022 19:30
Create data statement from binary file.
; Make data statements from file (don't use this - just use FILE directive).
calminstruction hex_nibble digit*, command: display
compute digit, 0FFh and '0123456789ABCDEF' shr (digit*8)
arrange command, command digit
assemble command
end calminstruction
define _db
@bitRAKE
bitRAKE / Euler.five.asm
Last active April 13, 2025 17:20
Euler's sum of powers conjecture, k=5
; couldn't help myself after watching the video:
; https://www.youtube.com/watch?v=YMpdGLvqlrM
; (there is a better way, tomorrow perhaps)
; Euler's sum of powers conjecture.
; https://en.wikipedia.org/wiki/Euler%27s_sum_of_powers_conjecture
;
; It is unknown whether the conjecture fails or holds for any value k ≥ 6.
;
; Euler's conjecture was disproven by L. J. Lander and T. R. Parkin in 1966 when,