mirror of https://github.com/pwndbg/pwndbg.git
Malloc chunk dump (#2085)
* Added dump flag which prints hexdump Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> * Lint updates Signed-off-by: root <root@kali.Lalit> * Add machine word size to hexdump bytes Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> * Lint Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> * Added test Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> * Refactor Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> * Lint Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> * Minor Refactor and type casted str in test binary Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> * Pass dump flag on next Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> * Pass on dump flag on next Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> --------- Signed-off-by: Chirag Aggarwal <thechiragaggarwal@outlook.com> Signed-off-by: root <root@kali.Lalit> Co-authored-by: root <root@kali.Lalit>pull/2129/head
parent
87c042d077
commit
da94871adb
@ -0,0 +1,25 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define INTERNAL_SIZE_T size_t
|
||||
#define SIZE_SZ (sizeof (INTERNAL_SIZE_T))
|
||||
#define CHUNK_HDR_SZ (2 * SIZE_SZ)
|
||||
#define mem2chunk(mem) ((void*)(mem) - CHUNK_HDR_SZ)
|
||||
|
||||
void break_here(void) {}
|
||||
|
||||
void* test_chunk = NULL;
|
||||
|
||||
int main() {
|
||||
char* str = (char*)malloc(0x20);
|
||||
strncpy(str, "This is a test string", 0x20);
|
||||
|
||||
test_chunk = mem2chunk(str);
|
||||
|
||||
break_here();
|
||||
|
||||
free(test_chunk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in new issue