Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Credits 27,736 Posts 10,521 Joined 2002-10-09 12:00 23-year member UID 9
Status Offline
Can anyone tell me how to convert an executable in EXE or COM format into SYS (device driver) format so it can be loaded in CONFIG.SYS with the DEVICE command (methods like WRAPPER.SYS don't count)? Thanks!
◇ How to use a Device driver together with a .EXE
--------------------------------------------------------------------------------
-------------------------------------------------------------------------
NCTU-CIS BBS 'programming' board digest area
■■■ How to use a Device driver together with a .EXE ■■■
-------------------------------------------- compiled by: william@cis_nctu -----
-------------------------------------------------------------------------
Poster: elite.bbs@bbs.mgt.ncu ( ), Board: programming
Subject: Question: Can a Device Driver use .EXE ???
Posted from: National Central University MIS Totoro Information World (Fri Jul 29 16:23:35 1994)
Forwarded via: cis_nctu!news.cis.nctu!news.cc.nctu!news.csie.nctu!bbsroute!ncubbsrout
I don't know whether anyone has noticed that the EMM386.EXE loaded in Config.sys has the
extension .EXE,
not .SYS. How is this done?
If I load an ordinary .EXE this way, the machine hangs.
Also, EMM386.EXE can be executed too. Why?
==============================================================================
What you're referring to is the so-called installable device driver. This kind of file has a fixed
format (written one a long time ago, forgot the details, need to check a book. 8^P), and has nothing to do with the filename extension.
If it has an .EXE file header and also matches the device driver format, then both uses are possible.
=============================================================================
> I don't think you can RUN a normal DOS installable device driver.
> Another question: do DOS/V and MS-DOS use the same installable device
> driver format?
That file has two entry points... that's all....
There's mention of it in a device driver practical book....
=============================================================================
A year or two ago, in order to add this kind of function to the hard disk lock I wrote, I once used Sourcer to disassemble EMM386.exe
and take a look (I was afraid ordinary computer books would be too old and unable to provide this technique), and that's how I learned this trick. The trial results
were quite normal too. It can be put into config.sys and started with device= or DeviceHigh=, and when I want to debug it
I can load it from the command line, which is very convenient.
This way, loading it with device= will see the first two blocks and process them, while loading it from the command line
will use the part after main: as the entry point.
==============================================================================
Poster: PowerCC.bbs@bbs.ntu (Roaring Frog Jun), Board: programming
Posted from: NTU Computer Center BBS (Mon Aug 1 16:39:18 1994)
Yeah, it sounds good, but, but... I remember that *.SYS files must define its
header relative to an ABSOLUTE offset. Doesn't the *.EXE segments and headers
(PSPs) mess up the offsets required by Microsoft?
I'll go try it, anyway. Sounds interesting.
==============================================================================
Poster: elite.bbs@bbs.mgt.ncu ( ), Board: programming
Posted from: National Central University MIS Totoro Information World (Mon Aug 1 20:27:35 1994)
==> Poster: kuli.bbs@csie.nctu (ku li), Board: Program
> exe loading starts from seg:0, psp is created only by exec, it seems it won't be
> created when loaded with device,
> and the exe head is not loaded into memory
exe loading does not necessarily start from seg:0; IP can be at any position.
One more question: if the Header is not loaded, can call far or jmp far still be used?
==============================================================================
> Yeah, it sounds good, but, but... I remember that *.SYS files must define
> its header relative to an ABSOLUTE offset. Doesn't the *.EXE segments and
> headers (PSPs) mess up the offsets required by Microsoft?
.EXE files have a file header, but if loaded with device=, DOS will automatically skip that
EXE header first, and directly process the SYS header part. It looks like DOS first checks the extension; if
it's SYS it processes it directly, but if it's EXE it first skips the EXE file header...
I hadn't thought of this trick at first either. I only inferred it after disassembling EMM386.exe. I don't know when M$
came up with this method (who's interested in digging up the history? Or has any book mentioned it?).
As for programs loaded with device=, according to observation with debug, there is no PSP in memory,
and there is only one MCB, and that MCB begins with `D'. These are all differences from the EXE format.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!