blob: dc391152c37f718cd6664ccf8ca776e4ad1fb9b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/***********************************************************************
*
* Module Name: load
*
* Purpose: To provide support for loading files.
*
* Functions in Module:
* load
************************************************************************/
#include <dos.h> /* Borland header file */
#include <fcntl.h> /* Borland header file */
#include <dir.h> /* Borland header file */
#include "mpx.h"
#define intnum 33 /* int86 number for load only */
#define success 0 /* return code for successful process load */
#define error -1 /* return code for failure on process load */
/**************************************************************************
*
* Function: load
* Abstract: Dynamically loads a file from disk
* Algorithm:
* This procedure dynamically loads a process with a
* file extension of .MPX. The memory address provided
* is the segment address at which to load the process.
* The process with the name in the string pname is
* loaded into memory at the segment address found in
* load_addr. If load is successful, load returns a 0
* return code, otherwise it returns a -1 return code
*
**************************************************************************/
int load(unsigned *load_addr,char pname[])
{
int i,flags,carry;
char fname[30];
struct PRMBLK
{
int segaddr;
int reloctn;
};
struct PRMBLK prmbk;
union REGS *inregs; /* input registers pointer */
union REGS *outregs; /* output registers pointer */
struct SREGS *segregs; /* segment registers pointer */
union REGS inr; /* input register structure */
union REGS outr; /* output register structure */
struct SREGS segr; /* segment register structure */
disable();
/* SEGMENT REGISTER VALUE CALL */
segregs = &segr;
segread(segregs); /* returns current segme disablter values */
strcpy(fname, pname);
strcat(fname, ".MPX");
inregs = &inr;
outregs = &outr;
inregs->h.ah = 75;
inregs->x.dx = &fname[0];
prmbk.segaddr = load_addr;
prmbk.reloctn = load_addr;
segr.es = segr.ds; /* assigning the ES to the data segment */
inregs->x.bx = &prmbk;
inregs->h.al = 3; /* load only */
flags = int86x(intnum,inregs,outregs,segregs);
carry = flags; /* Could be omitted */
carry = outregs->x.cflag;
if(carry)
{
printf("\nerror code:%3d",outregs->x.ax);
enable();
return(error);
}
/* load successful */
enable();
return(success);
}
/***********************************************************************/
|