From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,884bd0881834ece8,start X-Google-Attributes: gid103376,public From: castroto@remus.rutgers.edu (Fabrizio Castrotorres) Subject: Problem using DLLTOOL that comes with GNAT 3.10p for Windows NT Date: 1998/06/05 Message-ID: <6l9120$61g$1@remus.rutgers.edu> X-Deja-AN: 359847451 Organization: Rutgers University LCSR Newsgroups: comp.lang.ada Date: 1998-06-05T00:00:00+00:00 List-Id: I'm trying to produce an import library to use with GNAT 3.10p for Windows NT from a DLL I created using the DLLTOOL that comes with GNAT. I used the commandline dll2def nt_sequential_io.dll nt_sequential_io.def dlltool --dllname nt_sequential_io.dll --def nt_sequential_io.def --output-lib libnt_sequential_io.a Everytime I specify these options it goes into an infinite loop when it calls as.exe and a message saying something about a "exception handler failed" keeps coming up until the "Dr Watson" program comes in and stops it. I created the DLL using Borland C++ 5.02, and can use if from other programs created by this compiler. I am enclosing the C code to see if anyone sees anything wrong with the DLL code. Thanks for your help. ====================================================================== nt_sequential_io.h ====================================================================== #ifndef __NT_SEQUENTIAL_IO__ #define __NT_SEQUENTIAL_IO__ #define FILE_MODE_OUT_FILE ((BYTE)0x01) #define FILE_MODE_IN_FILE ((BYTE)0x02) #define FILE_MODE_APPEND_FILE ((BYTE)0x04) const BYTE FILE_ATTRIBUTE_OPEN = 0x01; const BYTE FILE_ATTRIBUTE_SHARED = 0x02; const WORD EXCEPTION_STATUS_ERROR = 0x0001; //IO_Exceptions.Status_Error; const WORD EXCEPTION_MODE_ERROR = 0x0002; //IO_Exceptions.Mode_Error; const WORD EXCEPTION_NAME_ERROR = 0x0004; //IO_Exceptions.Name_Error; const WORD EXCEPTION_USE_ERROR = 0x0008; //IO_Exceptions.Use_Error; const WORD EXCEPTION_DEVICE_ERROR = 0x0010; //IO_Exceptions.Device_Error; const WORD EXCEPTION_END_ERROR = 0x0020; //IO_Exceptions.End_Error; const WORD EXCEPTION_DATA_ERROR = 0x0040; //IO_Exceptions.Data_Error; typedef struct { HANDLE Handle; DWORD dwPosition; DWORD dwSize; BYTE bMode; BYTE bAttributes; char lpszPath[MAX_PATH]; DWORD nPathLength; } FILE_TYPE; WORD NT__Open( FILE_TYPE *hFile, BYTE uFileMode, const char *szFileName ); WORD NT__Read( FILE_TYPE *hFile, LPVOID lpData, DWORD nLength ); WORD NT__Write( FILE_TYPE *hFile, LPVOID lpData, DWORD nLength ); WORD NT__Close( FILE_TYPE *hFile ); BYTE NT__Mode( FILE_TYPE *hFile ); BOOL NT__EOF( FILE_TYPE *hFile ); #endif ====================================================================== nt_sequential_io.c ====================================================================== // // DLL wrapper to access NT I/O // #include #include #include #include #include "nt_sequential_io.h" BOOL _cdecl _export NT__Is_Open( FILE_TYPE *File ) { return ( File->bAttributes & FILE_ATTRIBUTE_OPEN ); } WORD _cdecl _export NT__Close( FILE_TYPE *File ) { File->dwPosition = 0L; File->dwSize = 0L; File->bMode = 0; File->bAttributes = 0; File->nPathLength = 0; CloseHandle( File->Handle ); return 0; } BOOL _cdecl _export NT__EOF( FILE_TYPE *File ) { return( File->dwPosition == File->dwSize ); } WORD _cdecl _export NT__Read( FILE_TYPE *File, LPVOID lpData, DWORD nDataLen) { BOOL bStatus=FALSE; WORD wStatus=0; DWORD nBytesRead=0; if ( File->bMode & ( FILE_MODE_OUT_FILE | FILE_MODE_APPEND_FILE ) ) return( wStatus = EXCEPTION_MODE_ERROR ); bStatus = ReadFile(File->Handle, lpData, nDataLen, &nBytesRead, NULL); File->dwPosition += nBytesRead; if (bStatus && nBytesRead==0) wStatus |= EXCEPTION_END_ERROR; return wStatus; } WORD _cdecl _export NT__Write( FILE_TYPE *File, LPVOID lpData, DWORD nDataLen) { WORD wStatus=0; BOOL bStatus=FALSE; DWORD nBytesWritten=0; if (File->bMode & FILE_MODE_IN_FILE) return( wStatus = EXCEPTION_MODE_ERROR ); bStatus = WriteFile(File->Handle, lpData, nDataLen, &nBytesWritten, NULL); File->dwPosition += nBytesWritten; File->dwSize = File->dwPosition; if (bStatus && nBytesWritten==0) wStatus |= EXCEPTION_END_ERROR; return wStatus; } WORD _cdecl _export NT__Open( FILE_TYPE *File, BYTE uFileMode, const char *lpszName) { WORD wStatus=0; LPTSTR lpPathFile; memset( File->lpszPath, 0, MAX_PATH); memset( (void *)File, 0, sizeof(FILE_TYPE)); switch( uFileMode ) { case FILE_MODE_OUT_FILE: { File->Handle = CreateFile( lpszName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); File->dwPosition = 0; File->dwSize = 0; File->bMode = FILE_MODE_OUT_FILE; } break; case FILE_MODE_IN_FILE: File->Handle = CreateFile( lpszName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); File->dwPosition = 0; File->dwSize = GetFileSize( File->Handle, NULL ); File->bMode = FILE_MODE_IN_FILE; break; case FILE_MODE_APPEND_FILE: File->Handle = CreateFile( lpszName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); File->dwSize = GetFileSize( File->Handle, NULL ); File->dwPosition = File->dwSize; File->bMode = FILE_MODE_APPEND_FILE; SetFilePointer( File->Handle, 0L, NULL, FILE_END); break; };// end of switch if ( File->Handle == INVALID_HANDLE_VALUE ) wStatus |= EXCEPTION_NAME_ERROR; else { File->nPathLength = GetFullPathName( lpszName, MAX_PATH, File->lpszPath, &lpPathFile); if( File->nPathLength > MAX_PATH ) wStatus |= EXCEPTION_NAME_ERROR; } File->bAttributes |= FILE_ATTRIBUTE_OPEN; return wStatus; }