delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/08/04/02:30:31

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "greenberg moshe" <mina-g AT bezeqint DOT net>
Newsgroups: comp.os.msdos.djgpp
References: <1121967843 DOT 477491 DOT 69130 AT g49g2000cwa DOT googlegroups DOT com>
Subject: Re: Generating a CRC over a DJGPP programs binary code in memory?
Date: Sun, 31 Jul 2005 09:33:25 +0300
Lines: 68
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 82.81.13.198
Message-ID: <42f1b1d9$1@news.bezeqint.net>
X-Trace: news.bezeqint.net 1123135961 82.81.13.198 (4 Aug 2005 09:12:41 +0300)
Organization: Bezeq International Ltd.
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Gundolf" <news1 AT vonbachhaus DOT net> ??? 
??????:1121967843 DOT 477491 DOT 69130 AT g49g2000cwa DOT googlegroups DOT com...
> Hello all,
>
> Maybe someone can help me, I need to get an application to self-check
> that certain portions of its binary code haven't been altered once it
> has been started.
> To do that, I'd like to generate a CRC over the code between certain
> markers inserted into the binary code via something like "asm DB ..."
> (assuming there is an equivalent for that in DJGPP)
>
> So in a nutshell, the source code could look like something like this:
>
> ... bunch of code not to be crc'd
>
> void start_marker ()
> {
> asm db 'S','T','A','R','T';
> }
>
> void some_code_to_crc ()
> {
> ...
> }
>
> void end_marker ()
> {
> asm db 'E','N',D';
> }
>
> ... more code not to be crc'd
>
> The idea is to then run through the binary code in memory, look for the
> string "START" and generate a CRC until "END" is found.
>
> The next sub-problem: Does anybody how I can access the loaded code,
> and scan it from position "0" to the "end".
> As a fallback, I could always scan the .EXE file on disk, but I would
> prefer the memory option as it's more reliable and the .EXE could then
> be packed.
>
> --- So to summarize it, I'm looking for solutions the following 3
> sub-problems:
>
> 1) How can I insert arbitrary bytes into the program code, like with
> "asm db ..." or "__emit__ (...)" in other compilers?
> 2a) How can I figure out the beginning and end of the program code in
> memory once the program has been loaded, and having done that ...
> 2b) How can I read the program code byte for byte.
>
>
> BTW: Using static variables for the markers doesn't work - variables
> seem to be stored at the beginnig/end of the code, not where they are
> placed in-between functions. I guess it's a code/data segment thing,
> and I need to use the code segment.
>
> Any tips would be very much appreciated! Thanks ..!
>
> Gundolf

Hi
The best way to look for crc code is to look in  the PNG  graphic standat.
It contain crc and I found a lot of  code semples to do the crc.

Moshe 


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019