Add new bios_string() which will hunt for a string inside a given range

of the BIOS.  This can be used for finding arbitrary magic in the BIOS
in order to recognize particular platforms.
This commit is contained in:
Poul-Henning Kamp 2004-06-03 22:36:24 +00:00
parent 7bbdbe1482
commit 79005bbdbe
4 changed files with 46 additions and 0 deletions

View File

@ -474,6 +474,21 @@ bios16(struct bios_args *args, char *fmt, ...)
return (i);
}
const u_char *
bios_string(u_int from, u_int to, const u_char *string, int len)
{
const char *t, *te;
if (len == 0)
len = strlen(string);
t = (const char *)(KERNBASE + from);
te = (const char *)(KERNBASE + to);
for (; t <= te; t++)
if (!memcmp(string, t, len))
return (t);
return (NULL);
}
#ifdef DEV_ISA
/*
* PnP BIOS interface; enumerate devices only known to the system

View File

@ -27,6 +27,9 @@
* $FreeBSD$
*/
#ifndef _MACHINE_PC_BIOS_H_
#define _MACHINE_PC_BIOS_H_
/*
* Signature structure for the BIOS32 Service Directory header
*/
@ -278,3 +281,8 @@ struct bios_smap {
u_int64_t length;
u_int32_t type;
} __packed;
const u_char *bios_string(u_int from, u_int to, const u_char *string, int len);
#endif /* _MACHINE_PC_BIOS_H_ */

View File

@ -474,6 +474,21 @@ bios16(struct bios_args *args, char *fmt, ...)
return (i);
}
const u_char *
bios_string(u_int from, u_int to, const u_char *string, int len)
{
const char *t, *te;
if (len == 0)
len = strlen(string);
t = (const char *)(KERNBASE + from);
te = (const char *)(KERNBASE + to);
for (; t <= te; t++)
if (!memcmp(string, t, len))
return (t);
return (NULL);
}
#ifdef DEV_ISA
/*
* PnP BIOS interface; enumerate devices only known to the system

View File

@ -27,6 +27,9 @@
* $FreeBSD$
*/
#ifndef _MACHINE_PC_BIOS_H_
#define _MACHINE_PC_BIOS_H_
/*
* Signature structure for the BIOS32 Service Directory header
*/
@ -278,3 +281,8 @@ struct bios_smap {
u_int64_t length;
u_int32_t type;
} __packed;
const u_char *bios_string(u_int from, u_int to, const u_char *string, int len);
#endif /* _MACHINE_PC_BIOS_H_ */