1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-26 03:32:17 +00:00

gfx: Accept any type in gfx_hexdump

This commit is contained in:
CTCaer 2021-02-06 03:57:39 +02:00
parent 874c801772
commit 8683a0ff58
4 changed files with 18 additions and 14 deletions

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018-2020 CTCaer * Copyright (c) 2018-2021 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -397,11 +397,13 @@ void gfx_printf(const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void gfx_hexdump(u32 base, const u8 *buf, u32 len) void gfx_hexdump(u32 base, const void *buf, u32 len)
{ {
if (!gfx_con_init_done || gfx_con.mute) if (!gfx_con_init_done || gfx_con.mute)
return; return;
u8 *buff = (u8 *)buf;
u8 prevFontSize = gfx_con.fntsz; u8 prevFontSize = gfx_con.fntsz;
gfx_con.fntsz = 8; gfx_con.fntsz = 8;
for(u32 i = 0; i < len; i++) for(u32 i = 0; i < len; i++)
@ -413,7 +415,7 @@ void gfx_hexdump(u32 base, const u8 *buf, u32 len)
gfx_puts("| "); gfx_puts("| ");
for(u32 j = 0; j < 0x10; j++) for(u32 j = 0; j < 0x10; j++)
{ {
u8 c = buf[i - 0x10 + j]; u8 c = buff[i - 0x10 + j];
if(c >= 32 && c <= 126) if(c >= 32 && c <= 126)
gfx_putc(c); gfx_putc(c);
else else
@ -423,7 +425,7 @@ void gfx_hexdump(u32 base, const u8 *buf, u32 len)
} }
gfx_printf("%08x: ", base + i); gfx_printf("%08x: ", base + i);
} }
gfx_printf("%02x ", buf[i]); gfx_printf("%02x ", buff[i]);
if (i == len - 1) if (i == len - 1)
{ {
int ln = len % 0x10 != 0; int ln = len % 0x10 != 0;
@ -437,7 +439,7 @@ void gfx_hexdump(u32 base, const u8 *buf, u32 len)
gfx_puts("| "); gfx_puts("| ");
for(u32 j = 0; j < (ln ? k : k + 1); j++) for(u32 j = 0; j < (ln ? k : k + 1); j++)
{ {
u8 c = buf[i - k + j]; u8 c = buff[i - k + j];
if(c >= 32 && c <= 126) if(c >= 32 && c <= 126)
gfx_putc(c); gfx_putc(c);
else else

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018-2020 CTCaer * Copyright (c) 2018-2021 CTCaer
* Copyright (c) 2018 M4xw * Copyright (c) 2018 M4xw
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -63,7 +63,7 @@ void gfx_con_setpos(u32 x, u32 y);
void gfx_putc(char c); void gfx_putc(char c);
void gfx_puts(char *s); void gfx_puts(char *s);
void gfx_printf(const char *fmt, ...); void gfx_printf(const char *fmt, ...);
void gfx_hexdump(u32 base, const u8 *buf, u32 len); void gfx_hexdump(u32 base, const void *buf, u32 len);
void gfx_set_pixel(u32 x, u32 y, u32 color); void gfx_set_pixel(u32 x, u32 y, u32 color);
void gfx_line(int x0, int y0, int x1, int y1, u32 color); void gfx_line(int x0, int y0, int x1, int y1, u32 color);

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018-2020 CTCaer * Copyright (c) 2018-2021 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -379,11 +379,13 @@ void gfx_printf(const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void gfx_hexdump(u32 base, const u8 *buf, u32 len) void gfx_hexdump(u32 base, const void *buf, u32 len)
{ {
if (gfx_con.mute) if (gfx_con.mute)
return; return;
u8 *buff = (u8 *)buf;
u8 prevFontSize = gfx_con.fntsz; u8 prevFontSize = gfx_con.fntsz;
gfx_con.fntsz = 8; gfx_con.fntsz = 8;
for(u32 i = 0; i < len; i++) for(u32 i = 0; i < len; i++)
@ -395,7 +397,7 @@ void gfx_hexdump(u32 base, const u8 *buf, u32 len)
gfx_puts("| "); gfx_puts("| ");
for(u32 j = 0; j < 0x10; j++) for(u32 j = 0; j < 0x10; j++)
{ {
u8 c = buf[i - 0x10 + j]; u8 c = buff[i - 0x10 + j];
if(c >= 32 && c <= 126) if(c >= 32 && c <= 126)
gfx_putc(c); gfx_putc(c);
else else
@ -405,7 +407,7 @@ void gfx_hexdump(u32 base, const u8 *buf, u32 len)
} }
gfx_printf("%08x: ", base + i); gfx_printf("%08x: ", base + i);
} }
gfx_printf("%02x ", buf[i]); gfx_printf("%02x ", buff[i]);
if (i == len - 1) if (i == len - 1)
{ {
int ln = len % 0x10 != 0; int ln = len % 0x10 != 0;
@ -419,7 +421,7 @@ void gfx_hexdump(u32 base, const u8 *buf, u32 len)
gfx_puts("| "); gfx_puts("| ");
for(u32 j = 0; j < (ln ? k : k + 1); j++) for(u32 j = 0; j < (ln ? k : k + 1); j++)
{ {
u8 c = buf[i - k + j]; u8 c = buff[i - k + j];
if(c >= 32 && c <= 126) if(c >= 32 && c <= 126)
gfx_putc(c); gfx_putc(c);
else else

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018-2020 CTCaer * Copyright (c) 2018-2021 CTCaer
* Copyright (c) 2018 M4xw * Copyright (c) 2018 M4xw
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -62,7 +62,7 @@ void gfx_con_setpos(u32 x, u32 y);
void gfx_putc(char c); void gfx_putc(char c);
void gfx_puts(char *s); void gfx_puts(char *s);
void gfx_printf(const char *fmt, ...); void gfx_printf(const char *fmt, ...);
void gfx_hexdump(u32 base, const u8 *buf, u32 len); void gfx_hexdump(u32 base, const void *buf, u32 len);
void gfx_set_pixel(u32 x, u32 y, u32 color); void gfx_set_pixel(u32 x, u32 y, u32 color);