Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/amishelp.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1249,11 +1249,11 @@ iispentry i2F, 0, i2D
mov [iregs.cx], CX
mov [iregs.bx], BX
mov [iregs.ax], AX
; don't need IP or CS or flags
; (flags weren't ever read or written,
; and setting flags before iret is pointless.
; setting them before chaining is minimally
; more useful but not needed here.)
; copy the caller's flags from the iret frame into iregs.flags
mov bp, sp
mov bx, [bp + 4] ; frame: ip, cs, flags (bp addresses SS)
mov [iregs.flags], bx
; don't need IP or CS

; setup stack
mov [old_ss], SS
Expand All @@ -1272,6 +1272,11 @@ iispentry i2F, 0, i2D
mov SS, [old_ss]
mov SP, [old_sp]

; write iregs.flags back into the iret frame
mov bp, sp
mov bx, [iregs.flags]
mov [bp + 4], bx

; restore register input values
mov BP, [iregs.bp]
mov DI, [iregs.di]
Expand Down
32 changes: 22 additions & 10 deletions src/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,23 @@ typedef struct {
} open_action_exception_t;

static open_action_exception_t open_exceptions[] = {
{ 0, 0, 2, 0, 3 },
{ 0, 0, 4, 0, 3 }, /* compatibility-read/deny none-read, MED 08/2004 */
{ 2, 0, 0, 0, 4 },
{ 0, 0, 2, 0, 1 },
{ 0, 0, 4, 0, 1 },
{ 2, 0, 0, 0, 2 },
{ 2, 0, 2, 0, 0 },
{ 2, 0, 4, 0, 0 },
{ 2, 1, 3, 0, 0 },
{ 2, 1, 4, 0, 0 },
{ 2, 2, 4, 0, 0 },
{ 3, 0, 2, 1, 0 },
{ 3, 0, 4, 1, 0 },
{ 3, 1, 3, 1, 0 },
{ 3, 1, 4, 1, 0 },
{ 3, 2, 3, 1, 1 },
{ 3, 2, 4, 1, 0 },
{ 4, 0, 0, 0, 4 },
{ 4, 0, 0, 1, 0 }, /* deny none-read/compatibility-write */
{ 4, 0, 0, 2, 0 }, /* deny none-read/compatibility-read+write */
{ 4, 0, 0, 0, 2 },
{ 4, 0, 0, 1, 2 },
{ 4, 0, 0, 2, 2 },
{ 4, 0, 2, 0, 0 },
{ 4, 0, 2, 1, 0 },
{ 4, 0, 2, 2, 0 },
Expand Down Expand Up @@ -277,7 +282,7 @@ static int lock_unlock
unsigned long len, /* length (in bytes) of region to lock or unlock */
int unlock); /* non-zero to unlock; zero to lock */

static int is_file_open(char far *filename);
static int is_file_open(char far *filename, unsigned *mode, unsigned *psp);

/* Multiplex interrupt handler */

Expand Down Expand Up @@ -413,7 +418,8 @@ void inner_handler(void) {

/* is_file_open (0xa6)*/
if ((iregs.ax & 0xff) == 0xa6) {
iregs.ax = is_file_open(MK_FP(iregs.ds, iregs.si));
iregs.ax = is_file_open(MK_FP(iregs.ds, iregs.si), &iregs.cx, &iregs.dx);
iregs.flags &= ~1;
return;
}
}
Expand Down Expand Up @@ -727,13 +733,19 @@ static int lock_unlock
}
}

static int is_file_open(char far *filename)
static int is_file_open(char far *filename, unsigned *mode, unsigned *psp)
{
int i;

for (i = 0; i < file_table_size; i++) {
if (fnmatches(filename, file_table[i].filename))
file_t *f = &file_table[i];
if (fnmatches(filename, f->filename)) {
if (mode)
*mode = ((unsigned)f->sharemode << 8) | f->openmode;
if (psp)
*psp = f->psp;
return 1;
}
}
return 0;
}
Expand Down