China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

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!

中国DOS联盟论坛
The time now is 2026-06-29 11:12
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » How to convert an EXE or COM program into SYS format? View 868 Replies 6
Original Poster Posted 2003-05-19 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
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!
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 2 Posted 2003-05-19 00:00 ·  中国 台湾 远传电信
元老会员
★★★★★
Credits 8,312
Posts 3,551
Joined 2003-03-22 00:00
23-year member
UID 1225
Gender Male
Status Offline
Can't EXE and COM files also be loaded in config.sys??
MSN:tiqit2@hotmail.com
Floor 3 Posted 2003-05-19 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
No. EXE and COM programs usually cannot be loaded directly with the DEVICE command.
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 4 Posted 2005-11-09 14:46 ·  中国 江苏 苏州 电信
初级用户
Credits 112
Posts 4
Joined 2005-01-13 00:00
21-year member
UID 35315
Gender Male
Status Offline
I'd really like to know too
Floor 5 Posted 2005-11-09 14:47 ·  中国 江苏 苏州 电信
初级用户
Credits 112
Posts 4
Joined 2005-01-13 00:00
21-year member
UID 35315
Gender Male
Status Offline
It's been so long, surely nobody will answer now
Floor 6 Posted 2005-11-09 18:13 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re Wengier:

Not sure whether you're still interested in this question now? I found some materials, as follows:

Link: http://bbs.ee.ntu.edu.tw/boards/Programming/13/12.html



◇ 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?
==============================================================================

Poster: cschen@shts.seed.net.tw (Chih4-Shen1 Chen2), Board: programming
Posted from: TSD, III (Fri Jul 29 17:05:16 1994)

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.
=============================================================================

Poster: steven@cis_nctu (*** Birdy ***), Board: programming
Posted from: NCTU CS BBS (Jul 29 21:03:07 1994)

> 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....
=============================================================================

Poster: william@cis_nctu (OO/Win/Asm Master), Board: programming
Posted from: NCTU CS BBS (Jul 29 22:45:46 1994)

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.

The rough structure is as follows:

┌─────────────┐
│ Device Driver header │
├─────────────┤
│ Device Driver codes │
├─────────────┤
│main: │
│ EXE codes │
│ ... │
│ ... │
│ END main │
└─────────────┘

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?
==============================================================================

Poster: william@cis_nctu (OO/Win/Asm Master), Board: programming
Posted from: NCTU CS BBS (Aug 1 22:52:29 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?

.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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 7 Posted 2005-11-19 17:03 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 2,227
Posts 790
Joined 2005-01-27 00:00
21-year member
UID 35703
Gender Male
Status Offline
I made a "Chinese font loader .SYS and .EXE all-in-one multifunction edition!" (http://www.cn-dos.net/forum/viewthread.php?tid=17591&pid=105238&page=2&sid=b8jlta#pid105238).
my major is english----my love is dos----my teacher is the buddha----my friends--how about U
Forum Jump: