Re: Run file as exe?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Yeah, when I first read your message, the first thing that came to
mind were .sys files used to load drivers inside of config.sys.

Device=C:\DOS\HIMEM.SYS

And there was something funny about emm386.exe where it would
be loaded as a memory management layer. 1MB of memory was a
proper memory for a DOS system (about 1989/1990).

I'm thinking INSTALL= rather than a DEVICE= statement was used
for some specific files, maybe .EXE files, but I don't recall exactly
why it was used. I'm looking through an old config.sys and see it used
to load SHARE.EXE and then SHARE.EXE is also called from the
autoexec.bat.

Anyways, those were my first thoughts that came to mind and I thought
I should ask to see if there was something blatently obvious that I might
have missed out on. <g>

The "spawn" sounds familiar. Looking through a book titled "Programmer's
PROBLEM SOLVER for the IBM PC, XT & AT" by Robert Jourdain...

"1.3.2 Run one program from within another

DOS proviedes the EXEC function (number 4B of INT 21H) to run one
program from within another. The first program is called the "parent," and
the one that is loaded and run is called the "child."

High Level ---

BASIC 3.0 introduces the SHELL command. With considerable limitations,
it lets a BASIC program load and run another program. The format is
^ SHELL command-string ^ . The command string may be just the name
of a program <snip>...</snip>

There are a number of restricitions of the use of SHELL. If the program that
is loaded changes the screen mode, for example, the change will /not/ be
automatically remedied <snip>...</snip>

Middle Level ---

Function 4BH is more complicated than most, requiring four preparatory
steps:

(1) Make space available in memory for the program.
(3) Create a parameter block.
(2) Build a drive, path, and program name string.
(4) Save the SS and SP registers in variables.

<comment> the misnumbered steps are left intact here </comment>
<snip>... cut out a lot of talk about how to set it up...</snip>
;---IN THE DATA SEGMENT:
FILENAME DB 'C:HELLOW.COM',0 ;load HELLOW.COM
PARAMETERS DW 7 dup(0) ;parameter block all zeros
KEEP_SS DW 0 ;variable to keep SS
KEEP_SP DW 0 ;variable to keep SP

;---REALLOCATE MEMORY:
MOV BX,ZSEG ;get paragraph # of end of program
MOV AX,ES ;get paragraph # of start of program
SUB BX,AX ;calculate program size in paragraphs
MOV AH,4AH ;function 4AH
INT 21H ;invoke the interrupt

;---POINT TO PARAMETER BLOCK
MOV AX,SEG PARAMETERS ;ES holds segment
MOV ES,AX ;
MOV BX, OFFSET PARAMETERS ;BX holds offset

;---STORE COPIES OF SS AND SP:
MOV KEEP_SS,SS ;save SS
MOV KEEP_SP,SP ;save SP

;---POINT TO FILE NAME STRING:
MOV DX,OFFSET FILENAME ;offset in DX
MOV AX,SEG FILENAME ;segment in DS
MOV DS,AX ;

;---LOAD THE PROGRAM:
MOV AH,4BH ;EXEC function
MOV AL,0 ;choose "load and run" option
INT 21H ;run

;---AFTERWARDS, RESTORE THE REGISTERS:
MOV AX,DSEG ;restore DS
MOV DS,AX ;
MOV SS,KEEP_SS ;restore SS
MOV SP,KEEP_SP ;restore SP

;---AT END OF PROGRAM CREATE DUMMY SEGMENT (MARK END OF CODE):
ZSEG SEGMENT ;
;dummy segment for end of code calculations
ZSEG ENDS ;

"

That book is going way back to a PCJr for me. I didn't understand
much inside of it at the time when I was reading it.

The only thing I'm not seeing right at the moment, is how the program
knows where the DSEG is when the called program completes itself.
It looks almost as if the compiler is assembler is supposed to create
a variable to hold the DSEG pointer.

--
Jim Carlock
Please post replies to newsgroup.

"Jonathan Wood" <jwood@xxxxxxxxxxxxxxxx> wrote:
Jim,

> Learn something new everyday. Perhaps you could give a quick overview
> of what you're refering to? Maybe it's sitting in the back of my head
> along with Delphi. I'm having one of those senior moments I guess. I'm
> too young for these things.

Well, I did it in C at the time using some functions that had names which
were variations of spawn or something. I guess they, in turn, called some
DOS interrupts.

As I recall, they didn't care what the name of the file was that you wanted
to run. I once did a project where smaller EXEs were given a different
extension and called drivers. That was before DLLs of course.

--
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
Available for consulting: http://www.softcircuits.com/jwood/resume.htm


.



Relevant Pages

  • Re: BizTalk 2004 on Virtual Server 2005
    ... the app will always live in memory this way, ... keep that in mind of you stack alot of other things on the machine. ... >> little load. ... >>> if Virtual server mucks something up when running BizTalk on it. ...
    (microsoft.public.biztalk.general)
  • Re: Memory limit reached with Windows Mobile
    ... That would explain the memory problem - you just can't do that. ... You have to load stuff when it's ... All native DLLs get loaded ...
    (microsoft.public.pocketpc.developer)
  • Re: Memory limit reached with Windows Mobile
    ... That would explain the memory problem - you just can't do that. ... Once I reached the 12 Mb limit, I cannot load any DLLs, yet if I ... Actually, simply by loading our 18 Native DLLs, we reduce the Virtual ...
    (microsoft.public.pocketpc.developer)
  • Re: Generating one table with a terabyte of data
    ... Take any simple string matching issues and run them as external C code on the files before loading. ... not match the job but can be adjusted for greater performance by changing memory type or adjusting IO layouts. ... them after a bulk load. ... Another thing is to split the updates across file sets. ...
    (microsoft.public.sqlserver.dts)
  • Re: fps modding
    ... > Yeah the memory usage used to be really high for no reason - but they've ... hl2 without it bothering to log in and such. ... one can't expect new games to load as ... >> rebuild and load a map. ...
    (comp.games.development.programming.misc)