Skip to content

Instantly share code, notes, and snippets.

@hamza-cskn
Created March 16, 2025 02:32
Show Gist options
  • Select an option

  • Save hamza-cskn/aa1fb6c8c8c0e4c1a7356288e3c53898 to your computer and use it in GitHub Desktop.

Select an option

Save hamza-cskn/aa1fb6c8c8c0e4c1a7356288e3c53898 to your computer and use it in GitHub Desktop.
memory debugger.c
⁠ void z(char c,int n){while (n--> 0)printf("%c",c);}void y(void *q,int k){while(k-->0)if(*(unsigned char*)q>=32&&*(unsigned char*)q<=126)printf("%c ",*(unsigned char*)q++);else printf(". ");}void x(void *q,int k){while(k-->0)printf("%02x ",*(unsigned char*)q++);}void print_memory(void *q,int k){unsigned char*mem=(unsigned char*)q;int n,d=8,f=0;while(f<=k/d){n=d<k-f*d?d:k-f*d;printf("%p: ",mem);x(mem,n);z(' ',(d - n)*3);printf("-> ");y(mem, n);printf("\n");mem += n;f++;}} ⁠
@hamza-cskn
Copy link
Author

print_memory(addr, size)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment