Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Sex is like air. It's only a big deal if you can't get any.


devel / comp.lang.forth / recalculating the checksum in a 64 bit windows executable

SubjectAuthor
* recalculating the checksum in a 64 bit windows executablealbert
+- Re: recalculating the checksum in a 64 bit windows executablemhx
`- Re: recalculating the checksum in a 64 bit windows executabledxf

1
recalculating the checksum in a 64 bit windows executable

<nnd$39d1d2fa$0f7859c5@8a871fc4cd2ed6af>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26646&group=comp.lang.forth#26646

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
From: albert@spenarnc.xs4all.nl
Subject: recalculating the checksum in a 64 bit windows executable
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$39d1d2fa$0f7859c5@8a871fc4cd2ed6af>
Organization: KPN B.V.
Date: Wed, 10 Apr 2024 15:46:12 +0200
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe004.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 53
Injection-Date: Wed, 10 Apr 2024 15:46:12 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: albert@spenarnc.xs4all.nl - Wed, 10 Apr 2024 13:46 UTC

It is comparatively easy to grow a windows 64 bit excitable
to allow more dictionary space. To do it properly one has to adjust
the redundancy check, that is a summation of 16 bit entities to which
is added the file length, generating 32 bits.

The following code is doing that:
(lina is a 64 bit windows Forth )

\ -------------------- 8< ----------------------------
#!/usr/bin/lina -s
\ Correct the checksum in the 64 bit executable in the first argument.
WANT -ROT $-PREFIX BOUNDS H. DUMP /STRING
: W@ @ $FFFF AND ; \ Intel only!
1 ARG[] GET-FILE .S
\ 0 , DUP 1 AND + \ make it even
OVER CONSTANT FILE
FILE 2 + W@ FILE + CONSTANT PE-header
PE-header 100 DUMP
PE-header 88 + CONSTANT checksum
\ PE-header FILE - /STRING
checksum L@ H.
0 checksum L!
2DUP 0 -ROT BOUNDS .S DO I W@ + 2 +LOOP .S
BEGIN DUP $FFFF > WHILE $10000 /MOD + REPEAT .S
\ INVERT $FFFF AND
OVER + .S checksum L! .S
1 ARG[] PUT-FILE
\ -------------------- 8< ----------------------------
The offsets 2 and 88 are found in
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format

There is an issue at stack overflow "Windows PE checksum algorithm"
with obscure java python c# code. The actual code is
"BOUNDS DO I W@ + 2 +LOOP "
followed by folding the overflowing bits into 16 bits.
"BEGIN DUP $FFFF > WHILE $10000 /MOD + REPEAT"

Correct checksums can become in issue in DLL's, Microsoft promises
to kill offending DLL's not so for executables.
wine doesn't care for my windows 32 or 64 bits executable.

One can now patch the filesize in the COFF header, and expand the
dictionary space from 4 megabyte to 1 megabyte and have a correct
header.

Groetjes
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat purring. - the Wise from Antrim -

Re: recalculating the checksum in a 64 bit windows executable

<5bbccd11e54ccc217bb1d649264eac23@www.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26648&group=comp.lang.forth#26648

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!.POSTED!not-for-mail
From: mhx@iae.nl (mhx)
Newsgroups: comp.lang.forth
Subject: Re: recalculating the checksum in a 64 bit windows executable
Date: Wed, 10 Apr 2024 16:42:52 +0000
Organization: novaBBS
Message-ID: <5bbccd11e54ccc217bb1d649264eac23@www.novabbs.com>
References: <nnd$39d1d2fa$0f7859c5@8a871fc4cd2ed6af>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="729420"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Site: $2y$10$KVjWaJLH3R/r59exxIyhO.L/iQ7XQ6FueXKewS52CVjkZiXSQVueC
X-Rslight-Posting-User: 59549e76d0c3560fb37b97f0b9407a8c14054f24
X-Spam-Checker-Version: SpamAssassin 4.0.0
 by: mhx - Wed, 10 Apr 2024 16:42 UTC

albert@spenarnc.xs4all.nl wrote:

> \ -------------------- 8< ----------------------------
> #!/usr/bin/lina -s
> \ Correct the checksum in the 64 bit executable in the first argument.
> WANT -ROT $-PREFIX BOUNDS H. DUMP /STRING
> : W@ @ $FFFF AND ; \ Intel only!
> 1 ARG[] GET-FILE .S
> \ 0 , DUP 1 AND + \ make it even
> OVER CONSTANT FILE
> FILE 2 + W@ FILE + CONSTANT PE-header
> PE-header 100 DUMP
> PE-header 88 + CONSTANT checksum
[..]

This is a script? Why does it have the " .S " and " DUMP " in it?
Or is " #!/usr/bin/lina " a Forth word?

-marcel

Re: recalculating the checksum in a 64 bit windows executable

<66172d39$1@news.ausics.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=26652&group=comp.lang.forth#26652

  copy link   Newsgroups: comp.lang.forth
Date: Thu, 11 Apr 2024 10:22:17 +1000
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: recalculating the checksum in a 64 bit windows executable
Newsgroups: comp.lang.forth
References: <nnd$39d1d2fa$0f7859c5@8a871fc4cd2ed6af>
Content-Language: en-GB
From: dxforth@gmail.com (dxf)
In-Reply-To: <nnd$39d1d2fa$0f7859c5@8a871fc4cd2ed6af>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: news.ausics.net
Message-ID: <66172d39$1@news.ausics.net>
Organization: Ausics - https://newsgroups.ausics.net
Lines: 14
X-Complaints: abuse@ausics.net
Path: i2pn2.org!i2pn.org!news.bbs.nz!news.ausics.net!not-for-mail
 by: dxf - Thu, 11 Apr 2024 00:22 UTC

On 10/04/2024 11:46 pm, albert@spenarnc.xs4all.nl wrote:
> ...
> Correct checksums can become in issue in DLL's, Microsoft promises
> to kill offending DLL's not so for executables.

Same for MS-DOS 'MZ' executables. There's a 16-bit field in the
header for a checksum apparently unused.

> wine doesn't care for my windows 32 or 64 bits executable.

By name and by nature?

"Wine Is Not an Emulator"

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor