BUG: _dos_lock() Uses SI and DI Without Restoring Values

Last reviewed: July 22, 1997
Article ID: Q116438
1.00 1.50 MS-DOS kbprg kbbuglist

The information in this article applies to:

  • The C Run-time (CRT), included with: Microsoft Visual C++ for Windows, versions 1.0 and 1.5

SYMPTOMS

After returning from a call to _dos_lock(), both the SI and the DI registers change their values. Their original values before the call to _dos_lock() are not restored.

RESOLUTION

As a workaround, save SI and DI before calling _dos_lock() and then restore them after the call to _dos_lock().

STATUS

Microsoft has confirmed this to be a bug with Visual C++ for Windows, versions 1.0 and 1.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

You can use the following sample code to demonstrate this problem:

Sample Code

/* Compile options needed: none
*/

   #include <fcntl.h>
   #include <stdio.h>
   #include <dos.h>

   void main()
   {
      int fh;

      if( _dos_open( "c:\\config.sb", _O_RDONLY, &fh ) != 0 )
         perror( "Open failed on input file" );
      else
      {
         printf( "Open succeeded on input file\n" );

         // Save the SI And DI registers and then
         // restore them

         __asm push si
         __asm push di
         _dos_lock(fh,0, 0L,20);
         __asm pop di
         __asm pop si

         if( _dos_close( fh ) != 0 )
            perror( "Close failed" );
         else
            printf( "File successfully closed\n" );
      }
   }


Additional reference words: 1.00 1.50
KBCategory: kbprg kbbuglist
KBSubcategory: CRTIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.