From owner-freebsd-hackers Sat Jul 13 13:44: 2 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5D72137B400 for ; Sat, 13 Jul 2002 13:44:00 -0700 (PDT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9353B43E58 for ; Sat, 13 Jul 2002 13:43:59 -0700 (PDT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.3/8.12.2) with ESMTP id g6DKfsXB008803; Sat, 13 Jul 2002 22:41:55 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: Luigi Rizzo Cc: David Malone , hackers@FreeBSD.ORG Subject: Re: how to find offset of a string in a binary file ? In-Reply-To: Your message of "Sat, 13 Jul 2002 13:21:44 PDT." <20020713132144.A68304@iguana.icir.org> Date: Sat, 13 Jul 2002 22:41:54 +0200 Message-ID: <8802.1026592914@critter.freebsd.dk> From: Poul-Henning Kamp Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <20020713132144.A68304@iguana.icir.org>, Luigi Rizzo writes: >On Sat, Jul 13, 2002 at 09:16:28PM +0100, David Malone wrote: >> On Sat, Jul 13, 2002 at 12:53:21PM -0700, Luigi Rizzo wrote: >> > So, does anyone know how to use the basic unix tools to find >> > the offset of a string in a binary file ? >> > Specifically, I would like to locate the offset of the string >> > >> > "MFS Filesystem goes here" >> >> Would grep -b do what you want? > >no, as i said in my email, it returns the offset of the "line", >so after it finds the string it goes back to the first newline >and returns the offset of the character after that. :( Luigi, get in touch with W Gerald Hicks , he has patches which does this by objcopy'ing the binary file to an elf-object and then linking that with the kernel. This is far superior to "overwrite the binary kernel" approach. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message