Line 31... |
Line 31... |
31 |
|
31 |
|
32 |
/* rewires my parent pointer, uninstalls rmod let DOS terminate me, UNLESS
|
32 |
/* rewires my parent pointer, uninstalls rmod let DOS terminate me, UNLESS
|
33 |
* my parent is unknown */
|
33 |
* my parent is unknown */
|
34 |
void sayonara(struct rmod_props far *rmod) {
|
34 |
void sayonara(struct rmod_props far *rmod) {
|
35 |
unsigned short rmodseg = rmod->rmodseg;
|
35 |
unsigned short rmodseg = rmod->rmodseg;
|
- |
|
36 |
unsigned long *myint22 = (void *)0x0A;
|
36 |
unsigned long *myparent = (void *)0x0A;
|
37 |
unsigned short *myparent = (void *)0x16;
|
37 |
unsigned short far *rmodenv_ptr = MK_FP(rmodseg, RMOD_OFFSET_ENVSEG);
|
38 |
unsigned short far *rmodenv_ptr = MK_FP(rmodseg, RMOD_OFFSET_ENVSEG);
|
38 |
unsigned short rmodenv = *rmodenv_ptr;
|
39 |
unsigned short rmodenv = *rmodenv_ptr;
|
39 |
|
40 |
|
40 |
/* detect "I am the origin shell" situations */
|
41 |
/* detect "I am the origin shell" situations */
|
41 |
if (rmod->flags & FLAG_PERMANENT) return; /* COMMAND.COM /P */
|
42 |
if (rmod->flags & FLAG_PERMANENT) return; /* COMMAND.COM /P */
|
42 |
if ((rmod->origparent >> 16) == 0xffff) return; /* original parent seg set to 0xffff (DOS-C / FreeDOS) */
|
43 |
if ((rmod->origint22 >> 16) == 0xffff) return; /* original int22h seg set to 0xffff (DOS-C / FreeDOS) */
|
43 |
if (rmod->origenvseg == 0) return; /* no original environment (MSDOS 5/6) */
|
44 |
if (rmod->origenvseg == 0) return; /* no original environment (MSDOS 5/6) */
|
44 |
|
45 |
|
- |
|
46 |
/* set my int 22h handler back to its original value */
|
- |
|
47 |
*myint22 = rmod->origint22;
|
- |
|
48 |
|
45 |
/* set my parent back to original value */
|
49 |
/* set my parent back to its original value */
|
46 |
*myparent = rmod->origparent;
|
50 |
*myparent = rmod->origparent;
|
47 |
|
51 |
|
48 |
_asm {
|
52 |
_asm {
|
49 |
/* free RMOD's code segment and env segment */
|
53 |
/* free RMOD's code segment and env segment */
|
50 |
mov ah, 0x49 /* DOS 2+ -- Free Memory Block */
|
54 |
mov ah, 0x49 /* DOS 2+ -- Free Memory Block */
|