int21 move a8
György 'Nog' Jeney
nog at sdf.lonestar.org
Sat Nov 9 11:35:37 CST 2002
ChangeLog:
* dlls/winedos/int21.c
* msdos/int21.c
- Move the file handle functions to winedos.
- Move Select defalut drive to winedos.
-------------- next part --------------
--- msdos/int21.c.a7 2002-11-09 11:43:23.000000000 +0200
+++ msdos/int21.c 2002-11-09 13:26:09.000000000 +0200
@@ -742,12 +742,6 @@
break;
}
- case 0x0e: /* SELECT DEFAULT DRIVE */
- TRACE("SELECT DEFAULT DRIVE %d\n", DL_reg(context));
- DRIVE_SetCurrentDrive( DL_reg(context) );
- SET_AL( context, MAX_DOS_DRIVES );
- break;
-
case 0x11: /* FIND FIRST MATCHING FILE USING FCB */
TRACE("FIND FIRST MATCHING FILE USING FCB %p\n",
CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
@@ -836,73 +830,6 @@
bSetDOSExtendedError = !INT21_ChangeDir(context);
break;
- case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
- TRACE("CREAT flag 0x%02x %s\n",CX_reg(context),
- (LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
- bSetDOSExtendedError = INT21_CreateFile( context );
- break;
-
- case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
- TRACE("OPEN mode 0x%02x %s\n",AL_reg(context),
- (LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
- OpenExistingFile(context);
- break;
-
- case 0x3e: /* "CLOSE" - CLOSE FILE */
- TRACE("CLOSE handle %d\n",BX_reg(context));
- bSetDOSExtendedError = ((SET_AX( context, _lclose16( BX_reg(context) )) != 0) );
- break;
-
- case 0x3f: /* "READ" - READ FROM FILE OR DEVICE */
- TRACE("READ from %d to %04lX:%04X for %d byte\n",BX_reg(context),
- context->SegDs,DX_reg(context),CX_reg(context) );
- {
- LONG result;
- if (ISV86(context))
- result = _hread16( BX_reg(context),
- CTX_SEG_OFF_TO_LIN(context, context->SegDs,
- context->Edx ),
- CX_reg(context) );
- else
- result = WIN16_hread( BX_reg(context),
- MAKESEGPTR( context->SegDs, context->Edx ),
- CX_reg(context) );
- if (result == -1) bSetDOSExtendedError = TRUE;
- else SET_AX( context, (WORD)result );
- }
- break;
-
- case 0x40: /* "WRITE" - WRITE TO FILE OR DEVICE */
- TRACE("WRITE from %04lX:%04X to handle %d for %d byte\n",
- context->SegDs,DX_reg(context),BX_reg(context),CX_reg(context) );
- {
- LONG result = _hwrite16( BX_reg(context),
- CTX_SEG_OFF_TO_LIN(context, context->SegDs,
- context->Edx ),
- CX_reg(context) );
- if (result == -1) bSetDOSExtendedError = TRUE;
- else SET_AX( context, (WORD)result );
- }
- break;
-
- case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */
- TRACE("LSEEK handle %d offset %ld from %s\n",
- BX_reg(context), MAKELONG(DX_reg(context),CX_reg(context)),
- (AL_reg(context)==0)?"start of file":(AL_reg(context)==1)?
- "current file position":"end of file");
- {
- LONG status = _llseek16( BX_reg(context),
- MAKELONG(DX_reg(context),CX_reg(context)),
- AL_reg(context) );
- if (status == -1) bSetDOSExtendedError = TRUE;
- else
- {
- SET_AX( context, LOWORD(status) );
- SET_DX( context, HIWORD(status) );
- }
- }
- break;
-
case 0x44: /* IOCTL */
switch (AL_reg(context))
{
--- dlls/winedos/int21.c.a7 2002-11-09 11:44:55.000000000 +0200
+++ dlls/winedos/int21.c 2002-11-09 13:26:10.000000000 +0200
@@ -619,6 +619,18 @@
RESET_CFLAG(context); /* dos 6+ only */
break;
+ case 0x0e: /* SELECT DEFAULT DRIVE */
+ {
+ char driveA[] = "a:";
+
+ *driveA += DL_reg(context);
+
+ TRACE("SELECT DEFAULT DRIVE %d\n", DL_reg(context));
+ SetCurrentDirectoryA(driveA);
+ SET_AL(context, MAX_DOS_DRIVES);
+ }
+ break;
+
case 0x13: /* DELETE FILE USING FCB */
FIXME("Delete file using FCB: stub\n");
break;
@@ -818,18 +830,76 @@
SET_CFLAG(context);
break;
+ case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
+ TRACE("CREAT flag 0x%02x %s\n",CX_reg(context),
+ (LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
+ {
+ HANDLE file =CreateFileA(CTX_SEG_OFF_TO_LIN(context, context->SegDs,
+ context->Edx),
+ GENERIC_READ | GENERIC_WRITE, 0, NULL,
+ CREATE_ALWAYS, CX_reg(context), NULL);
+
+ if(file == INVALID_HANDLE_VALUE) {
+ bSetDOSExtendedError = TRUE;
+ break;
+ }
+ SET_AX(context, Win32HandleToDosFileHandle(file));
+ }
+ break;
+
+ case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
+ TRACE("OPEN mode 0x%02x %s\n",AL_reg(context),
+ (LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx));
+ {
+ HANDLE file =CreateFileA(CTX_SEG_OFF_TO_LIN(context, context->SegDs,
+ context->Edx),
+ GENERIC_READ | GENERIC_WRITE, 0, NULL,
+ OPEN_EXISTING, 0, NULL);
+
+ if(file == INVALID_HANDLE_VALUE) {
+ TRACE("Open failed\n");
+ bSetDOSExtendedError = TRUE;
+ break;
+ }
+ SET_AX(context, Win32HandleToDosFileHandle(file));
+ }
+ break;
+
+ case 0x3e: /* "CLOSE" - CLOSE FILE */
+ TRACE("CLOSE handle %d\n", BX_reg(context));
+ if(!CloseHandle(DosFileHandleToWin32Handle(BX_reg(context))))
+ bSetDOSExtendedError = TRUE;
+ break;
+
+ case 0x3f: /* "READ" - READ FROM FILE OR DEVICE */
+ TRACE("READ from %d to %04lX:%04X for %d byte\n", BX_reg(context),
+ context->SegDs, DX_reg(context), CX_reg(context) );
+ {
+ DWORD read;
+ if(!ReadFile(DosFileHandleToWin32Handle(BX_reg(context)),
+ CTX_SEG_OFF_TO_LIN(context, context->SegDs,
+ context->Edx), CX_reg(context),
+ &read, NULL)) {
+ TRACE("Read failed %ld\n", GetLastError());
+ bSetDOSExtendedError = TRUE;
+ } else
+ SET_AX(context, read);
+ }
+ break;
+
case 0x40: /* WRITE TO FILE OR DEVICE */
- /* Writes to stdout are handled here. */
- if (BX_reg(context) == 1) {
- BYTE *ptr = CTX_SEG_OFF_TO_LIN(context,
- context->SegDs,
- context->Edx);
- int i;
-
- for(i=0; i<CX_reg(context); i++)
- DOSVM_PutChar(ptr[i]);
- } else
- DOS3Call( context );
+ TRACE("WRITE from %04lX:%04X to handle %d for %d byte\n",
+ context->SegDs, DX_reg(context), BX_reg(context), CX_reg(context));
+ {
+ DWORD wrote;
+ if(!WriteFile(DosFileHandleToWin32Handle(BX_reg(context)),
+ CTX_SEG_OFF_TO_LIN(context, context->SegDs,
+ context->Edx), CX_reg(context),
+ &wrote, NULL))
+ bSetDOSExtendedError = TRUE;
+ else
+ SET_AX(context, wrote);
+ }
break;
case 0x41: /* "UNLINK" - DELETE FILE */
@@ -840,6 +910,24 @@
context->Edx)));
break;
+ case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */
+ TRACE("LSEEK handle %d offset %ld from %s\n",
+ BX_reg(context), MAKELONG(DX_reg(context), CX_reg(context)),
+ (AL_reg(context) == 0) ? "start of file" : (AL_reg(context) == 1)?
+ "current file position" : "end of file");
+ {
+ DWORD pos;
+ if((pos =SetFilePointer(DosFileHandleToWin32Handle(BX_reg(context)),
+ MAKELONG(DX_reg(context), CX_reg(context)), NULL,
+ AL_reg(context))) == INVALID_SET_FILE_POINTER)
+ bSetDOSExtendedError = TRUE;
+ else {
+ SET_AX(context, LOWORD(pos));
+ SET_DX(context, HIWORD(pos));
+ }
+ }
+ break;
+
case 0x43: /* FILE ATTRIBUTES */
switch (AL_reg(context))
{
More information about the wine-patches
mailing list