Mail Archives: djgpp/2005/07/21/13:47:06
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
From: | "Gundolf" <news1 AT vonbachhaus DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Generating a CRC over a DJGPP programs binary code in memory?
|
Date: | 21 Jul 2005 10:44:03 -0700
|
Organization: | http://groups.google.com
|
Lines: | 58
|
Message-ID: | <1121967843.477491.69130@g49g2000cwa.googlegroups.com>
|
NNTP-Posting-Host: | 213.198.84.193
|
Mime-Version: | 1.0
|
X-Trace: | posting.google.com 1121967852 32518 127.0.0.1 (21 Jul 2005 17:44:12 GMT)
|
X-Complaints-To: | groups-abuse AT google DOT com
|
NNTP-Posting-Date: | Thu, 21 Jul 2005 17:44:12 +0000 (UTC)
|
User-Agent: | G2/0.2
|
Complaints-To: | groups-abuse AT google DOT com
|
Injection-Info: | g49g2000cwa.googlegroups.com; posting-host=213.198.84.193;
|
| posting-account=rY35YA0AAAAyeF5kjpy8hQOSdJiziKje
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie 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
- Raw text -