ID: Q116438
1.00 1.50 MS-DOS kbprg kbbuglist
The information in this article applies to:
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.
As a workaround, save SI and DI before calling _dos_lock() and then restore them after the call to _dos_lock().
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.
You can use the following sample code to demonstrate this problem:
/* 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
Last Reviewed: July 23, 1997