Fixed some HFILE vs. HANDLE mismatches.

If not used the last parameter of CreateFile must be 0, not -1.
This commit is contained in:
François Gouget 2001-01-06 01:29:18 +00:00 committed by Alexandre Julliard
parent c4c7324c45
commit da2b6a9f26
16 changed files with 40 additions and 40 deletions

View File

@ -1222,7 +1222,7 @@ LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename )
if (len > MAX_PATH*sizeof(WCHAR)) return ERROR_INVALID_PARAMETER;
if ((file = CreateFileW( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, -1 )) == INVALID_HANDLE_VALUE)
FILE_ATTRIBUTE_NORMAL, 0 )) == INVALID_HANDLE_VALUE)
{
ret = GetLastError();
goto done;
@ -1262,7 +1262,7 @@ LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
if (len > MAX_PATH*sizeof(WCHAR)) return ERROR_INVALID_PARAMETER;
if ((file = CreateFileA( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, -1 )) == INVALID_HANDLE_VALUE)
FILE_ATTRIBUTE_NORMAL, 0 )) == INVALID_HANDLE_VALUE)
{
ret = GetLastError();
goto done;
@ -1312,7 +1312,7 @@ LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
{
sprintf( name, "reg%04x.tmp", count++ );
handle = CreateFileA( buffer, GENERIC_WRITE, 0, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, -1 );
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
if (handle != INVALID_HANDLE_VALUE) break;
if ((ret = GetLastError()) != ERROR_ALREADY_EXISTS) goto done;

View File

@ -832,7 +832,7 @@ INT __cdecl CRTDLL__open(LPCSTR path,INT flags)
TRACE(":unsupported flags 0x%04x\n",flags);
hand = CreateFileA( path, access, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, creation, FILE_ATTRIBUTE_NORMAL, -1);
NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 );
if (hand == INVALID_HANDLE_VALUE)
{

View File

@ -1536,7 +1536,7 @@ int TLB_ReadTypeLib(LPSTR pszFileName, ITypeLib2 **ppTypeLib)
/* check the signature of the file */
hFile = CreateFileA( pszDllName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, -1 );
hFile = CreateFileA( pszDllName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
if (INVALID_HANDLE_VALUE != hFile)
{
HANDLE hMapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL );

View File

@ -135,7 +135,7 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
|| (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1 );
NULL, OPEN_EXISTING, 0, 0 );
if ( hfile == INVALID_HANDLE_VALUE ) return 0;
/* The next section is adapted from MODULE_GetBinaryType, as we need

View File

@ -242,7 +242,7 @@ static HRESULT ICO_ExtractIconExW(
TRACE("(file %s,start %d,extract %d\n", debugstr_w(lpszExeFileName), nIconIndex, nIcons);
hFile = CreateFileW( lpszExeFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, -1 );
hFile = CreateFileW( lpszExeFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
if (hFile == INVALID_HANDLE_VALUE) return hRet;
fsizel = GetFileSize(hFile,&fsizeh);

View File

@ -349,7 +349,7 @@ BOOL WINAPI MZ_LoadImage( LPCSTR cmdline )
if (!SearchPathA( NULL, name, ".exe", sizeof(buffer), buffer, NULL )) goto error;
if ((hFile = CreateFileA( buffer, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1 )) == INVALID_HANDLE_VALUE)
NULL, OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE)
goto error;
if (!MZ_DoLoadImage( hFile, buffer, NULL ))
{
@ -370,7 +370,7 @@ BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID para
* whether it's a NE/PE executable? */
LPDOSTASK lpDosTask = MZ_Current();
HFILE hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1);
NULL, OPEN_EXISTING, 0, 0);
BOOL ret = FALSE;
if (hFile == INVALID_HANDLE_VALUE) return FALSE;
switch (func) {

View File

@ -320,7 +320,7 @@ HDC WINAPI CreateEnhMetaFileW(
if (filename) /* disk based metafile */
{
if ((hFile = CreateFileW(filename, GENERIC_WRITE | GENERIC_READ, 0,
NULL, CREATE_ALWAYS, 0, -1)) == HFILE_ERROR) {
NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
EMFDRV_DeleteDC( dc );
return 0;
}

View File

@ -199,7 +199,7 @@ HDC16 WINAPI CreateMetaFile16(
{
physDev->mh->mtType = METAFILE_DISK;
if ((hFile = CreateFileA(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, -1)) == HFILE_ERROR) {
CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
MFDRV_DeleteDC( dc );
return 0;
}

View File

@ -687,7 +687,7 @@ BOOL WINAPI GetBinaryTypeA( LPCSTR lpApplicationName, LPDWORD lpBinaryType )
/* Open the file indicated by lpApplicationName for reading.
*/
hfile = CreateFileA( lpApplicationName, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1 );
NULL, OPEN_EXISTING, 0, 0 );
if ( hfile == INVALID_HANDLE_VALUE )
return FALSE;
@ -1083,7 +1083,7 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
/* Open file and determine executable type */
hFile = CreateFileA( name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, -1 );
hFile = CreateFileA( name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
if (hFile == INVALID_HANDLE_VALUE) goto done;
if ( !MODULE_GetBinaryType( hFile, name, &type ) )
@ -1254,14 +1254,14 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
if (flags & LOAD_LIBRARY_AS_DATAFILE)
{
char filename[256];
HFILE hFile;
HANDLE hFile;
HMODULE hmod = 0;
if (!SearchPathA( NULL, libname, ".dll", sizeof(filename), filename, NULL ))
return 0;
/* FIXME: maybe we should use the hfile parameter instead */
hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1 );
NULL, OPEN_EXISTING, 0, 0 );
if (hFile != INVALID_HANDLE_VALUE)
{
hmod = PE_LoadImage( hFile, filename, flags );

View File

@ -385,7 +385,7 @@ HANDLE NE_OpenFile( NE_MODULE *pModule )
{
char *name;
static HANDLE cachedfd = -1;
static HANDLE cachedfd = INVALID_HANDLE_VALUE;
TRACE("(%p) cache: mod=%p fd=%d\n",
pModule, pCachedModule, cachedfd );
@ -394,7 +394,7 @@ HANDLE NE_OpenFile( NE_MODULE *pModule )
pCachedModule = pModule;
name = NE_MODULE_NAME( pModule );
if ((cachedfd = CreateFileA( name, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1 )) == -1)
NULL, OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE)
MESSAGE( "Can't open file '%s' for module %04x\n", name, pModule->self );
TRACE("opened '%s' -> %d\n",
name, cachedfd );

View File

@ -697,7 +697,7 @@ WINE_MODREF *PE_LoadLibraryExA (LPCSTR name, DWORD flags)
HANDLE hFile;
hFile = CreateFileA( name, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1 );
NULL, OPEN_EXISTING, 0, 0 );
if ( hFile == INVALID_HANDLE_VALUE ) return NULL;
/* Load PE module */

View File

@ -625,7 +625,7 @@ LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
if (len > MAX_PATH*sizeof(WCHAR)) return ERROR_INVALID_PARAMETER;
if ((file = CreateFileA( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, -1 )) == INVALID_HANDLE_VALUE)
FILE_ATTRIBUTE_NORMAL, 0 )) == INVALID_HANDLE_VALUE)
{
ret = GetLastError();
goto done;
@ -663,7 +663,7 @@ LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
int count = 0;
LPSTR name;
DWORD ret, err;
HFILE handle;
HANDLE handle;
TRACE( "(%x,%s,%p)\n", hkey, debugstr_a(file), sa );
@ -675,7 +675,7 @@ LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
{
sprintf( name, "reg%04x.tmp", count++ );
handle = CreateFileA( buffer, GENERIC_WRITE, 0, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, -1 );
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
if (handle != INVALID_HANDLE_VALUE) break;
if ((ret = GetLastError()) != ERROR_ALREADY_EXISTS) goto done;

View File

@ -477,7 +477,7 @@ static HFILE16 _lcreat16_uniq( LPCSTR path, INT attr )
attr &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;
return Win32HandleToDosFileHandle( CreateFileA( path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_NEW, attr, -1 ));
CREATE_NEW, attr, 0 ));
}
static void OpenExistingFile( CONTEXT86 *context )

View File

@ -93,7 +93,7 @@ static void EMF_ReleaseEnhMetaHeader( HENHMETAFILE hmf )
* EMF_GetEnhMetaFile
*
*/
static HENHMETAFILE EMF_GetEnhMetaFile( HFILE hFile )
static HENHMETAFILE EMF_GetEnhMetaFile( HANDLE hFile )
{
ENHMETAHEADER *emh;
HANDLE hMapping;
@ -122,7 +122,7 @@ HENHMETAFILE WINAPI GetEnhMetaFileA(
)
{
HENHMETAFILE hmf;
HFILE hFile;
HANDLE hFile;
hFile = CreateFileA(lpszMetaFile, GENERIC_READ, FILE_SHARE_READ, 0,
OPEN_EXISTING, 0, 0);
@ -143,7 +143,7 @@ HENHMETAFILE WINAPI GetEnhMetaFileW(
LPCWSTR lpszMetaFile) /* [in] filename of enhanced metafile */
{
HENHMETAFILE hmf;
HFILE hFile;
HANDLE hFile;
hFile = CreateFileW(lpszMetaFile, GENERIC_READ, FILE_SHARE_READ, 0,
OPEN_EXISTING, 0, 0);
@ -1367,9 +1367,9 @@ HENHMETAFILE WINAPI CopyEnhMetaFileA(
memcpy( emrDst, emrSrc, emrSrc->nBytes );
hmfDst = EMF_Create_HENHMETAFILE( emrDst, 0, 0 );
} else {
HFILE hFile;
HANDLE hFile;
hFile = CreateFileA( file, GENERIC_WRITE | GENERIC_READ, 0, NULL,
CREATE_ALWAYS, 0, -1);
CREATE_ALWAYS, 0, 0);
WriteFile( hFile, emrSrc, emrSrc->nBytes, 0, 0);
hmfDst = EMF_GetEnhMetaFile( hFile );
}

View File

@ -215,7 +215,7 @@ static METAHEADER *MF_ReadMetaFile(HFILE hfile)
HMETAFILE16 WINAPI GetMetaFile16( LPCSTR lpFilename )
{
METAHEADER *mh;
HFILE hFile;
HANDLE hFile;
TRACE("%s\n", lpFilename);
@ -223,7 +223,7 @@ HMETAFILE16 WINAPI GetMetaFile16( LPCSTR lpFilename )
return 0;
if((hFile = CreateFileA(lpFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, -1)) == HFILE_ERROR)
OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
return 0;
mh = MF_ReadMetaFile(hFile);
@ -240,7 +240,7 @@ HMETAFILE16 WINAPI GetMetaFile16( LPCSTR lpFilename )
HMETAFILE WINAPI GetMetaFileA( LPCSTR lpFilename )
{
METAHEADER *mh;
HFILE hFile;
HANDLE hFile;
TRACE("%s\n", lpFilename);
@ -248,7 +248,7 @@ HMETAFILE WINAPI GetMetaFileA( LPCSTR lpFilename )
return 0;
if((hFile = CreateFileA(lpFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, -1)) == HFILE_ERROR)
OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
return 0;
mh = MF_ReadMetaFile(hFile);
@ -265,7 +265,7 @@ HMETAFILE WINAPI GetMetaFileA( LPCSTR lpFilename )
HMETAFILE WINAPI GetMetaFileW( LPCWSTR lpFilename )
{
METAHEADER *mh;
HFILE hFile;
HANDLE hFile;
TRACE("%s\n", debugstr_w(lpFilename));
@ -273,7 +273,7 @@ HMETAFILE WINAPI GetMetaFileW( LPCWSTR lpFilename )
return 0;
if((hFile = CreateFileW(lpFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, -1)) == HFILE_ERROR)
OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
return 0;
mh = MF_ReadMetaFile(hFile);
@ -291,7 +291,7 @@ HMETAFILE WINAPI GetMetaFileW( LPCWSTR lpFilename )
static METAHEADER *MF_LoadDiskBasedMetaFile(METAHEADER *mh)
{
METAHEADERDISK *mhd;
HFILE hfile;
HANDLE hfile;
METAHEADER *mh2;
if(mh->mtType != METAFILE_DISK) {
@ -301,7 +301,7 @@ static METAHEADER *MF_LoadDiskBasedMetaFile(METAHEADER *mh)
mhd = (METAHEADERDISK *)((char *)mh + sizeof(METAHEADER));
if((hfile = CreateFileA(mhd->filename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, -1)) == HFILE_ERROR) {
OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
WARN("Can't open file of disk based metafile\n");
return NULL;
}
@ -337,7 +337,7 @@ HMETAFILE16 WINAPI CopyMetaFile16( HMETAFILE16 hSrcMetaFile, LPCSTR lpFilename)
{
METAHEADER *mh = MF_GetMetaHeader16( hSrcMetaFile );
METAHEADER *mh2 = NULL;
HFILE hFile;
HANDLE hFile;
TRACE("(%08x,%s)\n", hSrcMetaFile, lpFilename);
@ -353,7 +353,7 @@ HMETAFILE16 WINAPI CopyMetaFile16( HMETAFILE16 hSrcMetaFile, LPCSTR lpFilename)
if(lpFilename) { /* disk based metafile */
if((hFile = CreateFileA(lpFilename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, -1)) == HFILE_ERROR) {
CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
HeapFree( GetProcessHeap(), 0, mh2 );
return 0;
}
@ -387,7 +387,7 @@ HMETAFILE WINAPI CopyMetaFileA(
) {
METAHEADER *mh = MF_GetMetaHeader( hSrcMetaFile );
METAHEADER *mh2 = NULL;
HFILE hFile;
HANDLE hFile;
TRACE("(%08x,%s)\n", hSrcMetaFile, lpFilename);
@ -403,7 +403,7 @@ HMETAFILE WINAPI CopyMetaFileA(
if(lpFilename) { /* disk based metafile */
if((hFile = CreateFileA(lpFilename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, -1)) == HFILE_ERROR) {
CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
HeapFree( GetProcessHeap(), 0, mh2 );
return 0;
}

View File

@ -464,7 +464,7 @@ void PROCESS_InitWine( int argc, char *argv[] )
if (!main_exe_file)
{
if ((main_exe_file = CreateFileA( main_exe_name, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1 )) == INVALID_HANDLE_VALUE)
NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
{
MESSAGE( "%s: cannot open '%s'\n", argv0, main_exe_name );
goto error;