Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.msdos.programmer > #1463

Re: detecting emulation or console windows

From "Rod Pemberton" <dont_use_email@xnothavet.cqm>
Newsgroups alt.os.development, comp.os.msdos.programmer, alt.lang.asm
Subject Re: detecting emulation or console windows
Date 2014-07-27 12:11 -0400
Organization Aioe.org NNTP Server
Message-ID <op.xjny9cg46zenlw@localhost> (permalink)
References (10 earlier) <6xvmv.779390$l83.633698@fx28.iad> <op.xhdto0px6zenlw@localhost> <bCRmv.1554351$Oa6.781381@fx14.iad> <lnh5q5$m8t$1@dont-email.me> <op.xhhcxflq6zenlw@localhost>

Cross-posted to 3 groups.

Show all headers | View raw


On Sun, 15 Jun 2014 01:16:17 -0400, Rod Pemberton  
<dont_use_email@xnothavet.cqm> wrote:
> On Sat, 14 Jun 2014 05:48:53 -0400, James Harris  
> <james.harris.1@gmail.com> wrote:

[from a.l.a. branch of this thread]

>> I have lost track of what Rod is now writing tests for.
>
> Sorry, the goalposts are movin'...
>
> I need a few things:
> 1) is the code executing in an emulator
> 2) is the code executing in a DOS console window
> 3) is the code executing under a DPMI host with sufficient capability
> 4) is the code executing with the first instance of COMMAND.COM or  
> spawned

This is an update on what I've found.

First, let's take those in reverse order:

> 4) is the code executing with the first instance of COMMAND.COM or  
> spawned

A suggested, the PSP address should work for this.  You compare the
PSP of the current app to the PSP of the parent.  If they're different,
the current app is the child.  If they're the same, it's the parent.

But, that test doesn't work for me in Windows 98/SE for some reason,
perhaps due to KernelEx.  So, I chose to use a lock file.  The first
process creates a file, and the spawn file checks for it.  Although,
the logic is far more complicated than that to ensure this works,
correctly.

> 3) is the code executing under a DPMI host with sufficient capability

I solved this one too.  I needed to detect if a DPMI host was "nestable".
Nestable means only a single instance of the DPMI host is needed to
allow many spawned DPMI applications to execute.  The DPMI has to
have two special properties: be reentrant and remain resident.
Normally, DPMI hosts are not reentrant and can't remain resident.
So, one DPMI host must be loaded for each and every executing
application in DOS.  This exhausts available low memory.

The solution to detecting this is much the same as the PSP.  If a DPMI
client loads a new instance for each application, then the segment part
of an address for one of the interrupts the DPMI host hooks changes for
each application.  If only one DPMI host is resident and stays resident,
then the segment portion of that interrupt address remains constant.

> 2) is the code executing in a DOS console window

This is solved via #3.  DOS console windows such as Windows 98 DOS
console or Linux dosemu console window will have a DPMI host which
remains resident.  Only some DOS DPMI hosts are nestable in RM DOS.
I provided a small list of these in a thread on comp.os.msdos.djgpp.

> 1) is the code executing in an emulator

This one may be difficult or utterly impossible.

I need it to determine if I'm either executing in RM DOS with a
nesting DPMI host or whether I'm executing under emulation with
a resident DPMI host, e.g., Windows 98/SE console or Linux dosemu.
The DPMI host remains resident for both situations, i.e., I can't
currently distinquish the two, i.e., RM DOS with nestable host
 from a DOS console window (emulation).

I've come up with a half dozen or so tests, but it's clear to
me these are not optimal.

The issues with the tests so far are:

1) The tests are arbitrary.  Any PC could have the problem
I'm testing for.  Even so, I think it's unlikely any do, i.e.,
they'd be technically "broken".  However, some could have the
problems and function correctly.  Importantly, I don't want
to block valid computers using tests which are arbitrary.

2) The tests are hardware, bios, etc based.  Software
instructions are very precisely emulated by many emulators,
but not all.  An academic paper I found indicates that Bochs
is extremely accurate, although not perfect, while QEMU has
(or had) many detectable errors.  An instruction based test
that worked everywhere, is difficult for emulations to emulate
correctly, would be optimal.  I understand this is unlikely
to exist or find.

3) The tests are trivial.  In part, this is so that valid
computers aren't rejected by the tests.  Unfortunately, that
also makes the test easy to bypass or fixed to work correctly
when under emulation.  If it's easy to fix, then it's of
little long-term value to me.  This implies the tests need
some aspect of complexity.

4) The tests are not universal.  There is no guarantee that
any of them will work everywhere.  I simply can't test
everywhere and for everything, i.e., conundrum.

5) There is an accumulating multitude of tests.  Without
a single, universal test that is guaranteed to detect all
emulators (or most), the numbers of tests is likely to increase.
Any increase in the numbers of tests has the effect of also
increasing the chance that valid computers won't work for
being failed by these tests which are mostly arbitrary.

6) The detection of emulation is difficult due to two advanced
areas of Computer Science: anti-virus software and software
emulators.  Both of these areas work extremely hard to
prevent detection of emulation by software.  Some of these
techniques are quite advanced.  However, they mostly
seem to target precise emulation of software instructions
and don't seem to be concerned with other issues, like
accuracy of hardware emulation, e.g., RTC, PIT, keyboard,
mouse, etc, nor are they concerned with correct BIOSes,
IVT table values, updating BDA values, etc.


Rod Pemberton

Back to comp.os.msdos.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-31 18:31 -0400
  Re: detecting emulation or console windows Ross Ridge <rridge@csclub.uwaterloo.ca> - 2014-05-31 19:59 -0400
    Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-31 20:54 -0400
      Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-05-31 21:43 -0400
        Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-01 22:48 +0100
          Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 00:46 -0400
            Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-02 06:15 +0100
              Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 03:21 -0400
                Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 03:32 -0400
                Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-02 09:51 +0100
                Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 09:27 -0400
                Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-02 17:05 +0100
                Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 19:25 -0400
                Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-04 07:55 +0100
                Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-04 03:20 -0400
      Re: detecting emulation or console windows Ross Ridge <rridge@csclub.uwaterloo.ca> - 2014-06-01 14:03 -0400
        Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 00:53 -0400
          Re: detecting emulation or console windows Ross Ridge <rridge@csclub.uwaterloo.ca> - 2014-06-02 15:55 -0400
            Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 19:27 -0400
              Re: detecting emulation or console windows Ross Ridge <rridge@csclub.uwaterloo.ca> - 2014-06-03 17:00 -0400
  Re: detecting emulation or console windows Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2014-06-01 06:25 +0200
    Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-01 02:50 -0400
  Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-01 07:53 +0100
    Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-01 04:53 -0400
      Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-01 20:57 +0100
        Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 00:48 -0400
      Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 03:20 -0400
  Re: detecting emulation or console windows JJ <duh@nah.meh> - 2014-06-02 03:43 +0700
    Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-02 00:34 -0400
    Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-03 07:06 -0400
      Re: detecting emulation or console windows JJ <duh@nah.meh> - 2014-06-03 20:25 +0700
  Re: detecting emulation or console windows "wolfgang kern" <nowhere@never.at> - 2014-06-03 20:52 +0200
  Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-03 22:59 +0100
    Re: detecting emulation or console windows CN <qmbmnp3799@pacbell.net> - 2014-06-03 18:39 -0700
      Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-04 07:06 +0100
        Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-04 03:07 -0400
          Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-04 09:16 +0100
  Re: detecting emulation or console windows "James Harris" <james.harris.1@gmail.com> - 2014-06-03 23:00 +0100
  Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-06-10 17:37 -0400
    Re: detecting emulation or console windows Wildman <best_lay@yahoo.com> - 2014-06-11 00:37 +0000
      Re: detecting emulation or console windows "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-07-27 12:11 -0400

csiph-web