flat assembler
Message board for the users of flat assembler.

Index > DOS > how to determine if .com runs under DOS

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 23 Feb 2010, 00:42
hello guys!
I'm building a .com program that can be executed either under DOS, or not (i.e. loaded by a boot sector on a floppy). how should i determine if the program was started under DOS? I've implemented a PSP word 0 check (if it contains 0xcd, 0x20 then we're under DOS), but i'm not sure if this is enough. Maybe something else should be checked to be 100% sure?
Post 23 Feb 2010, 00:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20344
Location: In your JS exploiting you and your system
revolution 23 Feb 2010, 08:23
Perhaps you can call a harmless int 0x21 function (like get_version) and see if you get a proper response.
Post 23 Feb 2010, 08:23
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 23 Feb 2010, 08:35
revolution wrote:
Perhaps you can call a harmless int 0x21 function (like get_version) and see if you get a proper response.


Bad idea ... "get_version" usually returns garbage Wink

But you can peek the date http://www.ctyme.com/intr/rb-2686.htm after confirming that INT $21 target is non-ZERO. Also you can check other values inside the PSP.

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 23 Feb 2010, 08:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20344
Location: In your JS exploiting you and your system
revolution 23 Feb 2010, 08:43
DOS386 wrote:
Bad idea ... "get_version" usually returns garbage Wink
Garbage is okay. At least that means something is taking notice of the function and returning a result.
Post 23 Feb 2010, 08:43
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 23 Feb 2010, 08:52
How about passing a special value in a register (from booter).
Use a register that DOS normally sets to zero, and make it nonzero.
Now program can check for special value and determine who it is...
Post 23 Feb 2010, 08:52
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 23 Feb 2010, 12:38
hm... interesting idea about setting a register. i.e. some magic number can be passed in ax, or in a pair of registers (ax:cx, for example) to double-check and exclude possible collisions


OFFTOPIC: DOS386's signature always makes me smile )) I'm a QA engineer and I hate high-level languages, so this "bug" is double-funny )
Post 23 Feb 2010, 12:38
View user's profile Send private message Reply with quote
nop



Joined: 01 Sep 2008
Posts: 165
Location: right here left there
nop 25 Feb 2010, 04:35
@zhak offtopic
hehe i hate hlls too and even 100kb is tiny by todays bloatware standards! maybe dos386 should change his sig to 1Mb or 10Mb or even 100Mb Laughing
Post 25 Feb 2010, 04:35
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 25 Feb 2010, 10:50
yes, nobody takes care of software package size today. i laughed very loud some time ago when i loaded intel's web site and saw a banner stating that new Core processors are COMPATIBLE WITH VISTA!!! hahaha its now OS should be supported by hardware, not vice versa.

but, on the other hand, this possibly doesn't allow engineers to relax and they keep inventing more powerful hardware.

anyway, sometimes i wish it were late 80's - early 90's when i write system code... things used to be a lot more easier that days )
Post 25 Feb 2010, 10:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.