VOGONS


First post, by curvedline

User metadata
Rank Newbie
Rank
Newbie

AA1=MAIN.EXE that has HEX 26 at the HEX position 0000E190
AA2=MAIN.EXE that has HEX 90 at the HEX position 0000E190

HEX = 0000E190 which is the same as decimal = 57744
HEX = 0000E190 (= decimal 57744)
HEX=26( = decimal 38)
HEX=90( = decimal 144)

AA1 and AA2's filesizes are equal, the only way to tell the difference is to check the location 57744+1 for its byte

if that location has "HEX=26( = decimal 38)" echo mana cheat is enabled
if that location has "HEX=90( = decimal 144)" echo mana cheat is disabled

i can do this easily with the True BASIC compiler but i dont even know how to tackle or where to start with batch commands.

Reply 1 of 79, by wierd_w

User metadata
Rank Oldbie
Rank
Oldbie

You want to do a POKE.

There are a few ways to do that. Using a debugger is the obvious one.

In this case, a TSR is the most sensible approach. It's just a program that starts, then returns control to the OS. It then 'does something' based on some trigger it monitors for.

In this case, 'MAIN.EXE' being loaded. It then reads the DOS memory allocation chain, gets the load address of the executable, and writes the magic bytes there with a short assembler routine.

'How do I write one of those!?' Is a question that involves learning x86 assembler.

As does 'how do I use a debugger?'

Reply 2 of 79, by jakethompson1

User metadata
Rank Oldbie
Rank
Oldbie

There is unfortunately no plain DOS equivalent to dd or od which is what you need here. You can fake it out with debug. The E290 (vs. E190) here is not a typo due to the Program Segment Prefix (since debug is not designed to be a hex dumper) :

echo D E290 L 1 > dbg.tmp
echo Q >> dbg.tmp
debug main.exe < dbg.tmp | find "E290 26" > nul
if errorlevel 1 goto nocheat
echo Cheat is enabled
goto done
:nocheat
echo Cheat is disabled
:done
del dbg.tmp

Another option would be to carry along a copy of the first 57,745 bytes of either the cheat or no-cheat version, and use fc /b and parse its output to see whether there were any mismatching bytes or not.

A third and most general option, is to carry along a small checksumming utility alongside your .bat file and use that.

Reply 3 of 79, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie
curvedline wrote on 2025-01-28, 02:09:

AA1=MAIN.EXE that has HEX 26 at the HEX position 0000E190
AA2=MAIN.EXE that has HEX 90 at the HEX position 0000E190

Are you talking about location in memory of loaded program?
or location at offset within .EXE file?

And how would you want this information sent back to the batch?

It would be fairly trivial for me to write you a little "testbyte" tool where you would
specify a file, an offset and possible content bytes where it would scan the file
at that offset and give ERRORLEVEL=1 if it matches the first byte, ERRORLEVEL=2 if it
matches the second byte and so on .. ERRORLEVEL=0 would mean that it didn't match
any of the bytes you supplied.

So something like:

testbyte main.exe e190 26 90
if errorlevel 2 goto aa2
if errorlevel 1 goto aa1
echo Not AA1 or AA2
goto ex
:AA1
echo AA1
goto ex
:AA2
echo AA2
:ex

Is that something you would want?
If so, I let me know and I can create it and drop it somewhere for you.

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Reply 4 of 79, by curvedline

User metadata
Rank Newbie
Rank
Newbie

correction: it was not 0000E190 line, it was 0000E1A0 hex line
main.exe is a file, i viewed it with the ztree's hex editor

(possible way 1)
these strings are also unique
5E FC 26 89 7F 3D EB 12 only one exists somewhere in main.exe original (cheat disabled)
5E FC 90 90 90 90 EB 12 only one exists somewhere in main.exe (cheat enabled)

(possible way 2)
how about this way if there is a way?
if comp main-or.exe main.exe identical echo cheat disabled

(possible way 3)
the effected line is below, comparison between two files
0000E1A0 74 09 C4 5E FC 26 89 7F 3D EB 12 C4 5E FC 26 89 t··^·&ë=···^·&ë = cheat disabled because it is the original main.exe
0000E1A0 74 09 C4 5E FC 90 90 90 90 EB 12 C4 5E FC 26 89 t··^·ÉÉÉÉ···^·&ë = cheat enabled because it has some 90 90 90 90 in the line

0000E1A0 =57760
74=57761 (means hex value 74 is located at the hex location 57761 in decimal)
09=57762
c3=57763
5e=57764
fc=57765
26=57766 (=0000E1A6)
89=57767
7F=57768
3D =57769
EB =57770
12 =57771
C4 =57772
5E =57773
FC =57774
26=57775
89=57776
...... 0000E1A0 line ends here with 89 as the last byte
......the next new line of HEX tag starts with 0000E1B0 =57776 for HEX 89 which was the last HEX from the previous line

if 26 at 57766 is found echo cheat disabled
or
if 90 at 57766 is found echo cheat enabled
---------------------------------------------------------------------

echo D E1A6 L 1 > dbg.tmp
echo Q >> dbg.tmp
debug main.exe < dbg.tmp | find "E1A6 26" > nul
didnt work. it always gives cheat enabled
-----------------------------------------------------------------
Is that something you would want?
If so, I let me know and I can create it and drop it somewhere for you
yes, it doesnt have to be done by a batch file only, i could use "testbyte". if you even make it general, i could use it for checking other programs for the same purpose

Reply 5 of 79, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie
curvedline wrote on 2025-01-28, 07:26:

>If so, I let me know and I can create it and drop it somewhere for you
yes, it doesnt have to be done by a batch file only, i could use "testbyte". if you even make it general, i could use it for checking other programs for the same purpose

I'm not sure what what you mean by "even more general".
What I described would be very general, you could call if from anywhere and look at the returned ERRORLEVEL

How differently would you want it's results?
Do you just want it printed?
If so, I could have it display what value it was returning in addition to setting ERRORLEVEL,
(with a -Quiet command line option to make it Quiet for those cases where you wanted
to call it within another program and not be visible)

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Reply 6 of 79, by curvedline

User metadata
Rank Newbie
Rank
Newbie

testbyte "main.exe" 0000eE1A6 26

testbyte.exe "filename" "location" "one byte to check"
syntax in this way is good enough

checking for one byte is enough, i think
if errorlevel 1 usually means not found
if errorlevel 0 usually means found
this is good enough
and it can handle large filesizes like 8888E1A6, not limited to a small size file E1A6 but i dont know if DOS is limited to just 2 bytes, then any limit is ok
oh, i just checked the DOS limit with xtree, it was 3 bytes

---------------------------------
AskByte.exe "filename" "location" A
%A% returns with a decimal number (or a HEX number) for a batch file to use it
if %A%==26 echo cheat disabled
i would prefer if it could do this way, but i am not sure if external programs can pass variables to a batch file directly

Reply 7 of 79, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie

Ok, I have created a new "Drop" directory on my site and placed TESTBYTE.ZIP
there.. you should be able to get it at:

https://dunfield.themindfactory.com/Drop/TESTBYTE.ZIP

See the enclosed README.TXT for details.

Let me know when you get it so I can remove.

note1: I just "ripped it out" before I read your last message... It lets you check for several bytes -- see the
enclosed README.TXT and TST.BAT - if you need anything changed I can make it happen.

I've also included the source-code ... so you could make desired changes yourself if you need...
(You'd need my Micro-C/PC compiler - another free download on my site)

note2: I've kinda been assuming that this is under DOS (people don't use .BATs nearly as much under Windows, and it's *way* easier/faster for me to rip stuff out with my own DOS compiler) - if you need it under Winblows you could adapt my source code to something like LCC - but it will be a LOT bigger!

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Reply 8 of 79, by curvedline

User metadata
Rank Newbie
Rank
Newbie

i need to make a correction
the location starts from o to 15 and not from 1 to 16, i just learned this from running testbyte.com, this means

this was not true
0000E1A0 =57760
74=57761
09=57762
c3=57763
5e=57764
fc=57765
26=57766 (=0000E1A6)

it was this
0000E1A0 =57760
74=57760
09=57761
c3=57762
5e=57763
fc=57764
26=57765 (=0000E1A5)

********************************
ECHO 1. Cheat - infinite mana - enable
ECHO 2. Cheat - infinite mana - disable
TESTBYTE.COM MAIN.EXE 0000E1A5 26
IF ErrorLevel 1 ECHO Cheat - infinite mana is disabled
IF NOT ErrorLevel 1 ECHO Cheat - infinite mana is enabled
************************************
this worked well
but i have one question
it returns with a message
Byte 1[26] at E1A5E1A5 and NOT 0000E1A5
because E1A5E1A5 is a huge number, what could be wrong?

>I've also included the source-code ... so you could make desired changes yourself if you need...
>(You'd need my Micro-C/PC compiler - another free download on my site)
i will try but i am not a system engineer, i barely know batch operators, and much much less C-compiler or assembler
i have no idea about TESTBYTE.C but i always wanted to get a taste of C-complier, and learn how to load c-files and learn to run them at least even though i dont know what i run
i only know number crunching true basic lingo and fortran, i write a lot of maths for doing numerical analysis and playing some games

>people don't use .BATs nearly as much under Windows
it is very ok for me, i am very used to with DOS Xtree and windows ZTree, they both heavily work with the command line types like DOS batch files, and they both are keyboard file managers, i mostly learned batch commands through ztree

and thanks very much for testbyte.com
it was fun completely controlling the game batch through testbyte

Reply 10 of 79, by jakethompson1

User metadata
Rank Oldbie
Rank
Oldbie
curvedline wrote on 2025-01-28, 07:26:

(possible way 2)
how about this way if there is a way?
if comp main-or.exe main.exe identical echo cheat disabled

If all you want to do is compare two files, use fc /b and then if errorlevel 1 goto label, to test for the not-identical branch.

curvedline wrote on 2025-01-28, 07:26:
echo D E1A6 L 1 > dbg.tmp echo Q >> dbg.tmp debug main.exe < dbg.tmp | find "E1A6 26" > nul didnt work. it always gives cheat e […]
Show full quote

echo D E1A6 L 1 > dbg.tmp
echo Q >> dbg.tmp
debug main.exe < dbg.tmp | find "E1A6 26" > nul
didnt work. it always gives cheat enabled

You need to offset by 100h, and if it isn't 16-byte aligned, there will be some spacing issues to deal with. Run that D command in debug in interactive mode to see the exact string (including spaces) that you're looking for.

Reply 11 of 79, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie
jakethompson1 wrote on 2025-01-28, 18:14:

If all you want to do is compare two files, use fc /b and then if errorlevel 1 goto label, to test for the not-identical branch.

This was my initial thought, but since he's only testing the one file, it's likely that he has a means of "patching" it
as he wants to enable/disable the cheat.

He could keep a copy of the unpatched file and compare it to that.. but we don't know how big this particular .EXE is,
and not sure he wants to keep a whold extra copy (and perhaps other patches may or may not also be active)...
TESTBYTE is nice and small, and independent of other bytes values within the file!

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Last edited by DaveDDS on 2025-01-28, 20:38. Edited 1 time in total.

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Reply 12 of 79, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie
curvedline wrote on 2025-01-28, 16:07:

it returns with a message
Byte 1[26] at E1A5E1A5 and NOT 0000E1A5
because E1A5E1A5 is a huge number, what could be wrong?

Apologies... Internally I keep track of the address as High:Low, and mistakenly printed LowLow
(Ok - I admit I didn't test it all that much)

I've updated TESTBYTE.ZIP - download it again and it should be good!

Dave

Btw: There is a -Q(uiet) option if you'd rather not see those messages at all!

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Reply 13 of 79, by curvedline

User metadata
Rank Newbie
Rank
Newbie

@echo off
1>nul 2>nul fc /b m1.exe m3.exe
if errorlevel 1 echo different
if not errorlevel 1 echo same
dosbox-x doesnt work
dosbox doesnt work
but works in windows

@echo off
1>nul 2>nul comp m1.exe m2.exe
if errorlevel 1 echo different
if not errorlevel 1 echo same
dosbox-x doesnt work
dosbox doesnt work
but works in windows
********************************
fc /b m1.exe m3.exe
if errorlevel 1 echo different
if not errorlevel 1 echo same
dosbox-x WORKS
dosbox doesnt work
but works in windows

@echo off
comp m1.exe m2.exe
if errorlevel 1 echo different
if not errorlevel 1 echo same
dosbox-x doesnt work, probably because errorlevel # is different in comp command
dosbox doesnt work
but works in windows
******************************

dosbox didnt seem to have comp and fc commands implemented

and more in doxboxx, i still need to find a way to remove the messages and not 1>nul 2>nul in front of them

if i find other DOS game like main.exe (which came from westwood's lands of lore 1), i am gonna use FC or comp this time to learn more about FC command and errorlevel relation, so far year 1993's shadowcaster's HP cheat is on my list but the savegame editor doesnt work with the CD version of shadowcaster, but i also have the floppy version so i might try... but HP cheat is boring, and savedgame file editing is not even worth much the time because it is not permanent, but for a learning purpose i might

********************************
truebyte
worked well, thanks again for fixing it
message:
Byte 1[26] at 0000E1A5
Byte at 0000E1A5[90] not listed

Last edited by curvedline on 2025-01-29, 08:03. Edited 1 time in total.

Reply 14 of 79, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie
curvedline wrote on 2025-01-29, 03:08:
truebyte <==== think he means testbyte worked well, thanks again for fixing it message: Byte 1[26] at 0000E1A5 Byte at 0000E1A5[ […]
Show full quote

truebyte <==== think he means testbyte
worked well, thanks again for fixing it
message:
Byte 1[26] at 0000E1A5
Byte at 0000E1A5[90] not listed

Good to know - and you're welcome.

Btw, you could be a little more certain that your testing the right thing....

testbyte main.exe e1a5 26 90 -q
if errorlevel 2 goto is90
if errorlevel 1 goto is26
echo main.exe appears to be corrupt!
goto ex
:is26
echo Cheat is enabled <==== I don't know which is enabled or
goto ex
:is90
echo Cheat is disabled <==== disabled - reverse if I guessed wrong
:ex

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Reply 15 of 79, by curvedline

User metadata
Rank Newbie
Rank
Newbie

ECHO 1. Cheat - infinite mana - enable
ECHO 2. Cheat - infinite mana - disable
TESTBYTE.COM MAIN.EXE -Q 0000E1A5 26
IF ErrorLevel 1 ECHO Cheat - infinite mana is disabled
IF NOT ErrorLevel 1 ECHO Cheat - infinite mana is enabled
simple and works
*********************************************
ECHO 1. Cheat - infinite mana - enable
ECHO 2. Cheat - infinite mana - disable
TESTBYTE.COM MAIN.EXE -Q 0000E1A5 26 90
IF ErrorLevel 2 ECHO Cheat - infinite mana is enabled
IF ErrorLevel 1 ECHO Cheat - infinite mana is disabled

doesnt work, because ErrorLevel 2 is also ErrorLevel 1
*********************************************
ECHO 1. Cheat - infinite mana - enable
ECHO 2. Cheat - infinite mana - disable
TESTBYTE.COM MAIN.EXE -Q 0000E1A5 26 90
IF ErrorLevel 2 ECHO Cheat - infinite mana is enabled &GOTO :DONE
IF ErrorLevel 1 ECHO Cheat - infinite mana is disabled &GOTO :DONE

:DONE
adding extra command with"&" doesnt work in dosbox
*********************************************
ECHO 1. Cheat - infinite mana - enable
ECHO 2. Cheat - infinite mana - disable
TESTBYTE.COM MAIN.EXE -Q 0000E1A5 26 90
IF NOT "%ErrorLevel%"=="0" SET Err1=%ErrorLevel%
IF %Err1%==1 ECHO Cheat - infinite mana is disabled
IF %Err1%==2 ECHO Cheat - infinite mana is enabled

%ErrorLevel% doesnt work in dosbox , now the script is going to have to take the long way
***********************************************
ECHO 1. Cheat - infinite mana - enable
ECHO 2. Cheat - infinite mana - disable
TESTBYTE.COM MAIN.EXE -Q 0000E1A5 26 90

IF ErrorLevel 2 GOTO :90
IF ErrorLevel 1 GOTO :26
ECHO main.exe is corrupted
PAUSE
GOTO :EOF

:90
ECHO Cheat - infinite mana is enabled
GOTO :DONE

:26
ECHO Cheat - infinite mana is disabled
GOTO :DONE
:DONE

this syntax teaches how to check two inputs, i will use this way once so that i know i have two input syntax reference somewhere

Reply 16 of 79, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie

Yeah, DOS ERRORLEVEL can be somewhat of a pain...

I've not found a reliable way to actually get the value in a .BAT, only test
it with "if errorlevel ..."

In the past I'd written some tools to help:

-An EXEC tool which would run the program and then store the returned
exit code in a known/accessible place (like in a file on my RamDrive or in
an environment variable).

- I also wrote a tool to find where in DOS memory the value was being stored,
and be able to retrieve it. The main problem with this is that it's not a
documented DOS "feature" and could move from version to version. So I had to
run the scan ever time I changed DOS versions.

Alas, both of these are "long gone" - the first was easy and it would be
fairly trivial to recreate.

IIRC, the second was a lot more work - it has to execute itself with a command
line option causing it to return a specific exit code -- run itself with an certain
exit value, then scan DOS memory to see what locations have that value - repeat
with different values until you can narrow it down to one location!
* I also doubt this would work in DosBox as unlike true DOS DosBox stores some things
in memory not accessible to the virtual machine *

I do still have one tool I sometimes use when working with ERRORLEVEL:
ERRLVL number <- Exits with the specified exit code
ERRLVL program ... <- Runs the named program with it's arguments, then shows
the exit code it returned.
If program does not have an extension, tries .BAT, .COM and .EXE
If it doesn't specify a directory, walks your PATH looking for it.

I can certainly make this available if it would help!

Dave

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Reply 17 of 79, by curvedline

User metadata
Rank Newbie
Rank
Newbie

i'd like to show what i have done next with testbyte.com, i found another use for it, i already had fun dong it on several games

E:\Utility\DOSBOX\TESTBYTE.COM HOF.CFG -Q 00000008 00 01 02
IF ErrorLevel 3 GOTO :ger
IF ErrorLevel 2 GOTO :fre
IF ErrorLevel 1 GOTO :eng

now i have a proper use of "IF ErrorLevel and GOTO : combo" and not "IF ErrorLevel and IF NOT ErrorLevel "
i uploaded the screenshot of it

https://mega.nz/file/LIgEiTwK#kJRdiUv5ur8jQcf … pfchbW_-yhkiz_A

this is my 1st time linking something in dosbox forum, so i am not sure how it's gonna go

>Yeah, DOS ERRORLEVEL can be somewhat of a pain...
errorlevel is a global parameter and not a local parameter, it can go to one batch to other batch without saying anything. it took several decades for me to get 10% used to it.

ok i will try them, you can post
ERRLVL number <- Exits with the specified exit code
ERRLVL program ... <- Runs the named program with it's arguments, then shows

Reply 18 of 79, by igully

User metadata
Rank Newbie
Rank
Newbie

Find attached:

SEL.COM - Allows you to set a specific errorlevel you want from within, for example, a batch file.
ERRLEVEL.BAT - After you run a program, ERRLEVEL will show you the return code (errorlevel) that the program pulled out.

I hope they help.

Reply 19 of 79, by DaveDDS

User metadata
Rank Oldbie
Rank
Oldbie
curvedline wrote on 2025-01-30, 08:08:

ok i will try them, you can post
ERRLVL number <- Exits with the specified exit code
ERRLVL program ... <- Runs the named program with it's arguments, then shows

Ok - I have placed ERRLVL.ZIP in the Drop directory on my site.

Enjoy!

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal

Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal