From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregor Zattler Newsgroups: gmane.emacs.help Subject: Re: Fix the destroyed disk image partition table in a raw image file using Emacs. Date: Sun, 11 Apr 2021 21:18:03 +0200 Message-ID: <87tuocfx5g.fsf@no.workgroup> References: Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15576"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 11 21:19:33 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVfcK-0003wV-Sv for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 11 Apr 2021 21:19:32 +0200 Original-Received: from localhost ([::1]:44518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVfcJ-0006HD-Ue for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 11 Apr 2021 15:19:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVfb6-0006H4-Q0 for help-gnu-emacs@gnu.org; Sun, 11 Apr 2021 15:18:16 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:43785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVfb3-00080R-SE for help-gnu-emacs@gnu.org; Sun, 11 Apr 2021 15:18:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1618168687; bh=9l/TSCvnx8o4FH0M91Ntr7QC7WsC4Dwg6t1SUNa88LE=; h=X-UI-Sender-Class:From:To:Subject:In-Reply-To:References:Date; b=HszDkAUFKfPL2cBnbfYqbMEirJvSZdeL/1HWBuRoi4FyppQLansTlodOW1B/t+gpw djY5fKvNHiuMEeEmhUMTvEC2eHlabZckRrGL0484CPnhmsj5WcTB+aX8gMqfYu+H7J brqo8LiTnj/LuFsZNZl++m4kHVdyg7xQK8u0ubdQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from no.workgroup ([46.94.159.150]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MKKZ3-1lGT9k2k6p-00LogK; Sun, 11 Apr 2021 21:18:07 +0200 In-Reply-To: Mail-Followup-To: help-gnu-emacs X-Provags-ID: V03:K1:PiIn2y65QFchKPEcasj3sA2VxOcwD9J2d8AoenurNNQfnDZmvTe CBpiU59GHC2c9jxNFt6O6QQMP0jsy6ng2V0pcm0IqGKgb7mxPpxDznaSKG0XIm2UVcfQzdM Q7+vOnsn6JGHAUGDeRKA/SOqr2p9rWIRdLLxS4thBEvOpmTHd0zeLPamPzHxIk2odZT9svu VIVB5Y51D4Dcpg4fHyzzA== X-UI-Out-Filterresults: notjunk:1;V03:K0:K10nv7us7r4=:6/2GVi2mXtV++VBaL14xPB F/W6UG1qb92CMKhGF8iQZjw/AV6wW2IVhRHFKOywgbgbT106rEww33X6Y1ULUQN4v9fe0B1Pp wf6rd74WigcB8BPIzHqKfx2NDqNSk/8QVc1cqo2g07fmy0MzqXS3PzalqdRm7yv/qJgyayNPU ZPgvJIMuaMd8eLlUWW5SZjdVeh/do+1yw1Rj0iW4Tzjd1j91TuU/VOXVDrNOzEgTQuDSRZgbR QVcfBGDDyHbDUjV38Hw1DLVZmnFe176t92xaqW6vgZPJ+CN9x8YiR45RkQ/ud02UWYVjGrbmh cV6sw4+IGNZZJSX1JLt9adU03VBV3cWRwUqVN5HUIvwlGp9tDQLej/x5yIzdAsZtGW3Qkb7vm wqDcSyg7DKigziWY/JLNmo4o30GTN4Hb4b89aYWr3Ds2VOClNbZeu9xRRfh1ar88o9ldK1CBD UXQetnSbbbJfQ32FuXIfMc2YmhuE5xTFR81MyrO+X+XwjkJSTzQmdU92ZsOknGnRfVzjv6Itc rieyaz6JVRoxKN6oh1DBuF1bORDWgbRMb/5gtJ+ebESrb7lntY5qHyYKHYF6iWsIFa/wwREKK 3d1BorSDMvkB2rQA/Cc3aZFcjefMRvJ/wEzRv3mvUX//PwtwEn+1obHUrQXgDBNgszdy3E8qj 5lghGBMSBixBSv08lTH7DbODM9m25sUDC9vM9Gt12A6C5w7aXboAd4tMzcf25Jm9Ze9QCcShJ eohh3qQofjR3h9QtJaJzTdhgKFbm34cNoMNB9adpQOAs8nvDcDYbiRwLWpc2xeLVAMNz+TQc Received-SPF: pass client-ip=212.227.15.15; envelope-from=telegraph@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128953 Archived-At: Hi Hongyi Zhao, * Hongyi Zhao [2021-04-11; 21:34]: > $ dd if=3Ddisk.img bs=3D1 count=3D4 skip=3D440 2>/dev/null | od -t x4 -A= n > 761b36b0 > > It's well known that Emacs is an 8-bit clean editor which makes it > safe to edit binary files. So, I want to whether I can fix the above > destroyed disk image file with Emacs for my scenario. If your emacs is able to handle the disk image in memory (which probably means you need a 64bit emacs and enough RAM installed) you could open the file of the disk image with find-file-literally Visit file FILENAME with no conversion of any kind. Format conversion and character code conversion are both disabled, and multibyte characters are disabled in the resulting buffer. The major mode used is Fundamental mode regardless of the file name, and local variable specifications in the file are ignored. Automatic uncompression and adding a newline at the end of the file due to require-final-newline is also disabled. And then the first thing to do would be binary-overwrite-mode When Binary Overwrite mode is enabled, printing characters typed in replace existing text. Newlines are not treated specially, so typing at the end of a line joins the line to the next, with the typed character between them. Typing before a tab character simply replaces the tab with the character typed. C-q replaces the text at the cursor, just as ordinary typing characters do. You then can move point in the disk image to the desired place and type in whatever you want and later save the buffer to its file. Ciao; Gregor =2D- -... --- .-. . -.. ..--.. ...-.-