delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2014/05/11/18:15:09

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Received: by 10.66.169.231 with SMTP id ah7mr10117572pac.40.1399845320450;
Sun, 11 May 2014 14:55:20 -0700 (PDT)
X-Received: by 10.140.44.75 with SMTP id f69mr4320qga.11.1399845320404; Sun,
11 May 2014 14:55:20 -0700 (PDT)
Newsgroups: comp.os.msdos.djgpp
Date: Sun, 11 May 2014 14:55:20 -0700 (PDT)
In-Reply-To: <op.xfpi0lzu6zenlw@localhost>
Complaints-To: groups-abuse AT google DOT com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=65.13.115.246;
posting-account=p5rsXQoAAAB8KPnVlgg9E_vlm2dvVhfO
NNTP-Posting-Host: 65.13.115.246
References: <op DOT xfpi0lzu6zenlw AT localhost>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <81056bd3-16cd-4a5d-befd-ceedfd3572fb@googlegroups.com>
Subject: Re: detecting DOSBox?
From: rugxulo AT gmail DOT com
Injection-Date: Sun, 11 May 2014 21:55:20 +0000
Bytes: 3849
Lines: 62
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Hi, Rod,

On Sunday, May 11, 2014 1:01:23 PM UTC-5, Rod Pemberton wrote:
>
> I'd like my program to exit gracefully instead of crashing under 
> emulated environments, such as DOSBox, dosemu, Windows 98/SE console,
> etc.  I'm having an especially difficult time detecting DOSBox.
> What are the known techniques for doing this?

First of all, "crashing" shouldn't bring the whole system down in most
cases. So I'm not sure it's worth worrying too too much.

> So far, I've looked at the results of 'mov cr0', 'smsw', and a
> variety of Int 0x2f calls, such as 0x1600, 0x160A, 0x4680, 0x4010.
> Of course, I don't have all possible environments where the code
> could be executed, e.g., I can't test OS/2, Win 3.11, Win NT,
> Win 95, etc.  So, compiled information on the expected results of
> those calls or any other suggested calls or techniques would be
> useful.

Let your users send in patches!  :-)   No, seriously, I sympathize,
but it's not feasible to test everything anymore. Some are just too
buggy, too expensive, too hard to find.

Focus on what you already have installed (or can get easily).
Personally, I'd focus on native FreeDOS (e.g. RUFUS or DOSEMU).
Though I'd say forget about DOSBox, it's too limited for real apps
(non-games).

Anyways, to try to pretend to answer your question, since I've never
bothered (much) with this personally, here's some boring details:

1). DOSEMU
http://www.delorie.com/djgpp/doc/rbinter/id/64/86.html

Now, whether you want to know about x86 or x64 host is another issue.
Presumably "unix uname -a" would tell you more.

2). DOSBox

I don't know of any specific INT calls offhand that would reveal this.
However, IIRC, it only emulates a 486 DX2 running DOS version 5 with
a maximum of 64 MB of RAM (but default 16 MB unless config file is
manually modified). So obviously anything above and beyond that means
it's not DOSBox anymore. (The date on my DOSBox.exe is four years old
tomorrow, and 0.74 is still latest, so I don't think anything is
improving any time soon.)

Oops, okay, I never change it, but you can actually change the cpu a
little in DOSBox, up to "slow pentium", IIRC. But my point is that
most "modern" setups of DOS environments have better features and
less limits.

I guess you could also check for specific DOS variants, e.g. OEM of
0xFD or int 21h, 4452h ("DR"). DOSBox has its own fake DOS instead,
so by elimination, you can make an educated guess. And yes, it does
support CPUID, so that should narrow things down even more.

P.S. I forgot all about sys/utsname.h and getdos_v.c (not perfect,
but better than nothing):

http://www.delorie.com/djgpp/doc/libc/libc_836.html
http://www.delorie.com/djgpp/doc/libc/libc_374.html

- Raw text -


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