OK, so that's the best way I could think of saying it.
I am modifying MS-DOS to better suit my needs. I have a .com file that I wrote that changes the layout a bit, text mode, colors, box cursor. I have this in my autoexec.bat. The problem is when I run a program and quit, it returns back to command.com in the original mode, so I have to run my .com file each time.
So I need to find the part in command.com (I assume it's in there) where the reentry point is so I can inject some code to execute my .com file. Can anyone help me with this?
I would REALLY appreciate it cause I love the way my program makes DOS look and I want to make it seamless so I don't have to keep typing it. Maybe there's a way to do this without hacking the file?
Can anyone help me hack command.com's reentry point?
-
- Posts: 2
- Joined: Sat Oct 03, 2020 6:51 am
Re: Can anyone help me hack command.com's reentry point?
Just load the already existing ANSI.SYS, all of these can be set with it.OgreVorbis wrote:changes the layout a bit, text mode, colors, box cursor.
You can write your own driver (.SYS) and load it from CONFIG.SYS.OgreVorbis wrote:Maybe there's a way to do this without hacking the file?
Cheers,
bzt
Re: Can anyone help me hack command.com's reentry point?
There used to be a number of TSR (Terminate and Stay Resident) programs that allowed one to reprogram the fonts (on EGA and VGA cards) and change the keyboard layout to support various national languages. They hooked several ISRs: to intercept keyboard input (IRQ 1 / INT 9) and video mode switches (INT 10H) and to check for presence (INT 2FH) before uninstallation.
You can do something similar as well.
You can do something similar as well.
Re: Can anyone help me hack command.com's reentry point?
In version 6.22, offset 108dh is where the main loop starts. It ends up back here after executing a program, after pressing control break, or after a critical error.
The transient portion of command.com begins at offset 26e0h in the file, and at offset 100h from the segment base. It is 0af95h bytes long. The main loop starts at 12ch.
Expanding either portion requires changing all of the places where their length appears.
The transient portion of command.com begins at offset 26e0h in the file, and at offset 100h from the segment base. It is 0af95h bytes long. The main loop starts at 12ch.
Expanding either portion requires changing all of the places where their length appears.
-
- Member
- Posts: 148
- Joined: Sun Aug 23, 2020 4:35 pm
Re: Can anyone help me hack command.com's reentry point?
Do you mean you would have to change the header to accommodate the larger amount of code, or the addresses of everything past the point changed? I don't think COM files have a header.Gigasoft wrote:Expanding either portion requires changing all of the places where their length appears.
In theory, wouldn't you be able to do something like this:
Code: Select all
CODE
{main_loop starts here}
CODE
SOMECODE -> replace with jmp MY_CODE. Surround with NOPs if necessary.
GO_BACK:
CODE...
{at the end of the binary}
MY_CODE:
SOMECODE
CUSTOM_CODE
jmp GO_BACK
Code: Select all
CODE
call 0x108D -> call MY_CODE
main_loop:
MAINLOOPCODE
CODE...
call main_loop -> call MY_CODE
CODE...
{at the end of the binary}
MY_CODE:
CUSTOM_CODE
jmp main_loop
I don't know. Just throwing out random ideas.
EDIT: I just hexdumped the FreeDOS command.com and it starts with "MZ." Maybe it is just an EXE in disguise and does actually have a header.
EDIT: ... But the MSDOS 6.22 COMMAND.COM is a .COM. No header
My OS: TritiumOS
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?