Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Q]: Independent date in DOS windows

0 views
Skip to first unread message

Wayne McDougall

unread,
May 16, 2001, 7:00:38 PM5/16/01
to
Greetings!

I'm wanting some sort of utility/TSR that I can run in a DOS box under
Windows, that will intercept BIOS calls for the system date, and return a
user designated date.

Why? I'm running an accounting package (DOS based), and I need it to stay
the 30 April for a couple of weeks. So I achieve that now by changing the
system date. But that interferes with the backup scheduler and the fax
scheduler, and document dates and .....it's a mess.

So I want to be able to tell the DOS programme it is 30 April (or 31 May or
30 June), regardless of the system date which I don't want to have changed.

Does anyone know of such a utility? Is it possible (my limited knowledge
suggest yes).

If such a thing doesn't exist, I'd be willing to commission someone to write
it.


Note follow-ups set to comp.os.msdos.misc

Gordon Gidluck

unread,
May 16, 2001, 11:58:31 PM5/16/01
to
Hi Wayne,
I think it is possible to intercept the DOS date/time functions, but any
changes to it would also affect any processes on the machine.

Here is one suggestion. :-)
You might want to consider using an older computer and run
DOS/accounting on that. Network the systems together so you can share
files across computers. Buy a KVM switch so you can use one
keyboard/mouse/VGA to control both systems. This way you can set the
time on the DOS system to whatever it needs to be. The scheduler and fax
processes will be unaffected by the change. You can read files from the
accounting computer to the other one (or vice-versa).

Gordon

Outsider

unread,
May 17, 2001, 1:35:09 PM5/17/01
to


You can easily do that in batch language.


Set a variable with current system date, change the system date,
run the program, restore the system date.


--
<!-Outsider//->
MS-DOS 6.22, Windows for Workgroups 3.11, Netscape Navigator 4.08
MS-DOS 7.1, Windows 4.1 (a.k.a. 98), Netscape Navigator 4.74

Dr John Stockton

unread,
May 18, 2001, 11:55:00 AM5/18/01
to
JRS: In article <3B040BCD...@yahoo.com>, seen in
news:comp.os.msdos.misc, Outsider <nonvali...@yahoo.com> wrote at
Thu, 17 May 2001 19:35:09 :-

>Wayne McDougall wrote:
>> I'm wanting some sort of utility/TSR that I can run in a DOS box under
>> Windows, that will intercept BIOS calls for the system date, and return a
>> user designated date.
>>
>> Why? I'm running an accounting package (DOS based), and I need it to stay
>> the 30 April for a couple of weeks. So I achieve that now by changing the
>> system date. But that interferes with the backup scheduler and the fax
>> scheduler, and document dates and .....it's a mess.
>>
>> So I want to be able to tell the DOS programme it is 30 April (or 31 May or
>> 30 June), regardless of the system date which I don't want to have changed.
>>
>> Does anyone know of such a utility? Is it possible (my limited knowledge
>> suggest yes).
>>
>> If such a thing doesn't exist, I'd be willing to commission someone to write
>> it.
>>
>> Note follow-ups set to comp.os.msdos.misc
>
>
>You can easily do that in batch language.
>
>
>Set a variable with current system date, change the system date,
>run the program, restore the system date.

IMHO, he has explained why that is unacceptable. Lying to an active
Windows misinforms anything else running at the same time.

A solution might be to write a TSR (I'm not skilled at that) which would
intercept calls to read date/time (care - DOS calls and/or BIOS calls),
would examine the interrupt return address and the MCB chain to
determine the owner of the calling code, and lie ONLY to the package in
question, recognised by owner filename. How well that might work in
Windows I don't know; it could be important to know which Windows.


It should be safer to boot from floppy to DOS in order to run this
specific application, then setting the system date incorrectly. There
might, however, be a need for any files created to bear the actual date
rather than the false date.

To change the date from a batch file is easy; NOWMINUS (via sig line 3)
can be used to save the current date in order to generate the set-it-
back command; those in countries not using ISO date order will need to
rearrange the components.

--
© John Stockton, Surrey, UK. j...@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS, EXE in <URL: http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)

Wayne McDougall

unread,
May 20, 2001, 10:42:28 PM5/20/01
to

"Dr John Stockton" <sp...@merlyn.demon.co.uk> wrote in message
news:cvOL3tLU...@merlyn.demon.co.uk...

> JRS: In article <3B040BCD...@yahoo.com>, seen in
> news:comp.os.msdos.misc, Outsider <nonvali...@yahoo.com> wrote at
> Thu, 17 May 2001 19:35:09 :-
> >Wayne McDougall wrote:
> >> I'm wanting some sort of utility/TSR that I can run in a DOS box under
> >> Windows, that will intercept BIOS calls for the system date, and return
a
> >> user designated date.
> >>
> >> If such a thing doesn't exist, I'd be willing to commission someone to
write
> >> it.

> A solution might be to write a TSR (I'm not skilled at that) which would


> intercept calls to read date/time (care - DOS calls and/or BIOS calls),
> would examine the interrupt return address and the MCB chain to
> determine the owner of the calling code, and lie ONLY to the package in
> question, recognised by owner filename. How well that might work in
> Windows I don't know; it could be important to know which Windows.

Yes, that does sound like what is required - whether it would work I don't
know. But I'd be willing to pay someone to write it. That would probably be
cheaper than setting up another machine (even though it is a DOS programme
it makes extensive hardware demands and network resources - it's not simply
a case of taking a 486 and plunking the accounting package on there - there
are also issues of usability - there is limited office space).

The Windows is version 95b.

So if anyone is willing to offer to write a TSR that intercepts a date call
for one DOS in a box under Windows 95b programme only, please write to me at
sys...@codeworks.gen.nz

Thanks to everyone for their input.


Dave Dunfield

unread,
May 21, 2001, 9:07:28 AM5/21/01
to
>So if anyone is willing to offer to write a TSR that intercepts a date call
>for one DOS in a box under Windows 95b programme only, please write to me at
>sys...@codeworks.gen.nz

executable has been mailed.

/*
* "Quick and Dirty" TSR to override the DOS date.
*
* Intercepts Int-21 Function-2A and returns the user specified date
* instead of the current one.
*
* If deployed within a Win95 DOS box, only that box will be affected.
*
* I have not provided an "unload" function (the TSR will disappear when
* the W95 DOS box is closed) or extensive checking of the validity of
* the specified replacement date ... these are left as "an excersise
* for the reader".
*
* Compile to a .COM file with my Micro-C/PC compiler: cc FIXDATE -fop
* Micro-C/PC is available free from: www.dunfield.com
*
* Dave Dunfield - May 21, 2001
*/
#include <stdio.h> // Standard I/O definitions
#include <file.h> // For low-level output functions
#include <tsr.h> // For tsr() function

/*
* Global data - set by main program, read by Int21 handler
*/
unsigned char
day, // day to report
month, // month to report
dow; // day of week to report

unsigned
year; // year to report

// Help message shown on any command syntax error
static char help_msg[] = { "\n\
Use: FIXDATE day(1-31) month(1-12) year(0-9999)\n\n\
Copyright 2001 Dave Dunfield - Freeware.\n" };

/*
* Calculate the day of the week for a given date
*/
static unsigned calc_dow(unsigned y, unsigned m, unsigned d)
{
return (3*y - (7*(y+(m+9)/12))/4 + (23*m)/9 + d + 2) % 7;
}

/*
* Interrupt 21 handler - Intercept function 2A (get date),
* otherwise just far-jump to old vector.
*/
asm {
int21: CMP AH,2Ah ; Get date function?
JZ xdate ; Special case
DB 0EAh ; Far JMP opcode
into: DW 0 ; Interrupt offset
ints: DW 0 ; Interrupt segment
;
; "get date" request
; - set DS so we can access 'C' DGRP
; - load date information to report
; - restore DS and return to caller
;
xdate: PUSH DS ; Save DS
MOV CX,CS ; Get CS
MOV DS,CX ; Set DS
MOV CX,DGRP:_year ; Get year
MOV DH,DGRP:_month ; Get month
MOV DL,DGRP:_day ; Get day
MOV AL,DGRP:_dow ; Day of week
POP DS ; Restore DS
IRET ; And return
}

/*
* Save the old DOS Int21 vector in the handlers JMP instruction
* operands, then install a new vector to point to the handler.
*/
static void get_vector() asm
{
; Get old vector and patch handlers "JMP" instruction
MOV AX,3521h ; Get vector 21
INT 21h ; Ask DOS
MOV word ptr ints,ES ; Patch segment
MOV word ptr into,BX ; Patch offset
; Direct handler to our vector
MOV DX,offset int21 ; Get offset of handler
MOV AX,2521h ; Set vector 21
INT 21h ; Ask DOS
}

/*
* This function is not used since our "Quick and Dirty" TSR has
* no unload function ... however this is how we would restore the
* original Int21 vector.
*
static void restore_vector() asm
{
PUSH DS ; Save DS
MOV DX,word ptr into ; Get original offset
MOV DS,word ptr ints ; Get original segment
MOV AX,2521h ; Set vector 21
INT 21h ; Ask DOS
POP DS ; Restore DS
} */

/*
* Dummy target for tsr() function hotkey handler ...
* this should never get called, however if the tsr() function
* were to immagine for some reason that it's hotkeys had been
* pressed, this would do nothing...
*/
static void hotkey_func()
{
}

/*
* Main program
*/
main(int argc, char *argv[])
{
// Parse command line arguments
if(argc != 4) {
help: lputs(help_msg, L_stderr);
return; }
day = atoi(argv[1]);
month = atoi(argv[2]);
year = atoi(argv[3]);
if((day < 1) || (day > 31) || (month < 1) || (month > 12) || (year > 9999))
goto help;

// Calculate correct day-of-week for entered date
dow = calc_dow(year, month, day);

// Take over Int21 vector to intercept function 2A (get date)
get_vector();

// terminate-and-stay-resident - No hotkeys, 128 bytes of stack
tsr(&hotkey_func, -1, 128);
}


--
dave@ Dunfield Development Systems http://www.dunfield.com
dunfield. Low cost software development tools for embedded systems
com Software/firmware development services Fax:613-256-5821

0 new messages