From 267ca68253323c35f26157c9f809a7ae8aff7122 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 31 Jul 2002 17:20:00 +0000 Subject: [PATCH] Fixed HANDLE<->HFILE conversions, since they will be different types when handles are void*. --- dlls/gdi/enhmfdrv/enhmetafiledrv.h | 3 +- dlls/gdi/enhmfdrv/init.c | 2 +- dlls/gdi/mfdrv/init.c | 2 +- dlls/gdi/mfdrv/metafiledrv.h | 3 +- dlls/oleaut32/typelib.c | 2 +- dlls/user/exticon.c | 3 +- dlls/winedos/module.c | 2 +- files/dos_fs.c | 6 +-- files/file.c | 85 ++++++++++++++++-------------- include/file.h | 2 +- include/module.h | 6 +-- include/winbase.h | 2 +- loader/module.c | 14 ++--- loader/ne/resource.c | 8 +-- loader/ne/segment.c | 6 +-- loader/resource.c | 22 ++++---- objects/metafile.c | 2 +- scheduler/handle.c | 8 +-- scheduler/process.c | 10 ++-- 19 files changed, 95 insertions(+), 93 deletions(-) diff --git a/dlls/gdi/enhmfdrv/enhmetafiledrv.h b/dlls/gdi/enhmfdrv/enhmetafiledrv.h index ab2ef5446fc..28d1f8c956a 100644 --- a/dlls/gdi/enhmfdrv/enhmetafiledrv.h +++ b/dlls/gdi/enhmfdrv/enhmetafiledrv.h @@ -33,7 +33,7 @@ typedef struct DC *dc; ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */ UINT nextHandle; /* Next handle number */ - HFILE hFile; /* HFILE for disk based MetaFile */ + HANDLE hFile; /* Handle for disk based MetaFile */ } EMFDRV_PDEVICE; @@ -139,4 +139,3 @@ extern BOOL EMFDRV_WidenPath( PHYSDEV dev ); #endif /* __WINE_METAFILEDRV_H */ - diff --git a/dlls/gdi/enhmfdrv/init.c b/dlls/gdi/enhmfdrv/init.c index 42653ab4d6a..c44f0d449ef 100644 --- a/dlls/gdi/enhmfdrv/init.c +++ b/dlls/gdi/enhmfdrv/init.c @@ -277,7 +277,7 @@ HDC WINAPI CreateEnhMetaFileW( DC *dc; HDC hRefDC = hdc ? hdc : CreateDCA("DISPLAY",NULL,NULL,NULL); /* If no ref, use current display */ EMFDRV_PDEVICE *physDev; - HFILE hFile; + HANDLE hFile; DWORD size = 0, length = 0; TRACE("%s\n", debugstr_w(filename) ); diff --git a/dlls/gdi/mfdrv/init.c b/dlls/gdi/mfdrv/init.c index b67d505a5dc..8a4d4389c29 100644 --- a/dlls/gdi/mfdrv/init.c +++ b/dlls/gdi/mfdrv/init.c @@ -219,7 +219,7 @@ HDC16 WINAPI CreateMetaFile16( HDC ret; DC *dc; METAFILEDRV_PDEVICE *physDev; - HFILE hFile; + HANDLE hFile; TRACE("'%s'\n", filename ); diff --git a/dlls/gdi/mfdrv/metafiledrv.h b/dlls/gdi/mfdrv/metafiledrv.h index caca363cc36..7cc904ef08e 100644 --- a/dlls/gdi/mfdrv/metafiledrv.h +++ b/dlls/gdi/mfdrv/metafiledrv.h @@ -33,7 +33,7 @@ typedef struct DC *dc; METAHEADER *mh; /* Pointer to metafile header */ UINT nextHandle; /* Next handle number */ - HFILE hFile; /* HFILE for disk based MetaFile */ + HANDLE hFile; /* Handle for disk based MetaFile */ } METAFILEDRV_PDEVICE; @@ -152,4 +152,3 @@ extern BOOL MFDRV_StrokePath( PHYSDEV dev ); extern BOOL MFDRV_WidenPath( PHYSDEV dev ); #endif /* __WINE_METAFILEDRV_H */ - diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 20550f1f698..65028db840a 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -2044,7 +2044,7 @@ int TLB_ReadTypeLib(LPCWSTR pszFileName, INT index, ITypeLib2 **ppTypeLib) { int ret = TYPE_E_CANTLOADLIBRARY; DWORD dwSignature = 0; - HFILE hFile; + HANDLE hFile; TRACE_(typelib)("%s:%d\n", debugstr_w(pszFileName), index); diff --git a/dlls/user/exticon.c b/dlls/user/exticon.c index 8200c0d85af..bcc706351a3 100644 --- a/dlls/user/exticon.c +++ b/dlls/user/exticon.c @@ -251,7 +251,7 @@ static HRESULT ICO_ExtractIconExW( HGLOBAL hRet = E_FAIL; LPBYTE pData; DWORD sig; - HFILE hFile; + HANDLE hFile; UINT16 iconDirCount = 0,iconCount = 0; LPBYTE peimage; HANDLE fmapping; @@ -676,4 +676,3 @@ HRESULT WINAPI PrivateExtractIconExA ( HeapFree(GetProcessHeap(), 0, lpwstrFile); return ret; } - diff --git a/dlls/winedos/module.c b/dlls/winedos/module.c index d2b8a58c818..b55d50be841 100644 --- a/dlls/winedos/module.c +++ b/dlls/winedos/module.c @@ -342,7 +342,7 @@ BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID para * (i.e. one DOS app spawning another) */ /* FIXME: do we want to check binary type first, to check * whether it's a NE/PE executable? */ - HFILE hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, + HANDLE hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); BOOL ret = FALSE; if (hFile == INVALID_HANDLE_VALUE) return FALSE; diff --git a/files/dos_fs.c b/files/dos_fs.c index 0ed17de12b9..da71ae23ddb 100644 --- a/files/dos_fs.c +++ b/files/dos_fs.c @@ -684,7 +684,7 @@ BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf, */ const DOS_DEVICE *DOSFS_GetDevice( const char *name ) { - int i; + unsigned int i; const char *p; if (!name) return NULL; /* if FILE_DupUnixHandle was used */ @@ -707,7 +707,7 @@ const DOS_DEVICE *DOSFS_GetDevice( const char *name ) /*********************************************************************** * DOSFS_GetDeviceByHandle */ -const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile ) +const DOS_DEVICE *DOSFS_GetDeviceByHandle( HANDLE hFile ) { const DOS_DEVICE *ret = NULL; SERVER_START_REQ( get_file_info ) @@ -769,7 +769,7 @@ static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access, DWORD attributes, */ HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa ) { - int i; + unsigned int i; const char *p; HANDLE handle; diff --git a/files/file.c b/files/file.c index b1a596127b8..05f971a46d3 100644 --- a/files/file.c +++ b/files/file.c @@ -936,8 +936,8 @@ static UINT FILE_GetTempFileName( LPCSTR path, LPCSTR prefix, UINT unique, { do { - HFILE handle = CreateFileA( buffer, GENERIC_WRITE, 0, NULL, - CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 ); + HANDLE handle = CreateFileA( buffer, GENERIC_WRITE, 0, NULL, + CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 ); if (handle != INVALID_HANDLE_VALUE) { /* We created it */ TRACE("created %s\n", @@ -1031,6 +1031,7 @@ static HFILE FILE_DoOpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode, BOOL win32 ) { HFILE hFileRet; + HANDLE handle; FILETIME filetime; WORD filedatetime[2]; DOS_FULL_NAME full_name; @@ -1094,9 +1095,9 @@ static HFILE FILE_DoOpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode, if (mode & OF_CREATE) { - if ((hFileRet = CreateFileA( name, GENERIC_READ | GENERIC_WRITE, - sharing, NULL, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0 ))== INVALID_HANDLE_VALUE) + if ((handle = CreateFileA( name, GENERIC_READ | GENERIC_WRITE, + sharing, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, 0 ))== INVALID_HANDLE_VALUE) goto error; goto success; } @@ -1153,19 +1154,19 @@ found: return 1; } - hFileRet = FILE_CreateFile( full_name.long_name, access, sharing, - NULL, OPEN_EXISTING, 0, 0, - DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY, - GetDriveTypeA( full_name.short_name ) ); - if (!hFileRet) goto not_found; + handle = FILE_CreateFile( full_name.long_name, access, sharing, + NULL, OPEN_EXISTING, 0, 0, + DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY, + GetDriveTypeA( full_name.short_name ) ); + if (!handle) goto not_found; - GetFileTime( hFileRet, NULL, NULL, &filetime ); + GetFileTime( handle, NULL, NULL, &filetime ); FileTimeToDosDateTime( &filetime, &filedatetime[0], &filedatetime[1] ); if ((mode & OF_VERIFY) && (mode & OF_REOPEN)) { if (memcmp( ofs->reserved, filedatetime, sizeof(ofs->reserved) )) { - CloseHandle( hFileRet ); + CloseHandle( handle ); WARN("(%s): OF_VERIFY failed\n", name ); /* FIXME: what error here? */ SetLastError( ERROR_FILE_NOT_FOUND ); @@ -1175,15 +1176,16 @@ found: memcpy( ofs->reserved, filedatetime, sizeof(ofs->reserved) ); success: /* We get here if the open was successful */ - TRACE("(%s): OK, return = %d\n", name, hFileRet ); + TRACE("(%s): OK, return = %x\n", name, handle ); if (win32) { + hFileRet = (HFILE)handle; if (mode & OF_EXIST) /* Return the handle, but close it first */ - CloseHandle( hFileRet ); + CloseHandle( handle ); } else { - hFileRet = Win32HandleToDosFileHandle( hFileRet ); + hFileRet = Win32HandleToDosFileHandle( handle ); if (hFileRet == HFILE_ERROR16) goto error; if (mode & OF_EXIST) /* Return the handle, but close it first */ _lclose16( hFileRet ); @@ -1374,7 +1376,7 @@ HFILE16 WINAPI _lclose16( HFILE16 hFile ) HFILE WINAPI _lclose( HFILE hFile ) { TRACE("handle %d\n", hFile ); - return CloseHandle( hFile ) ? 0 : HFILE_ERROR; + return CloseHandle( (HANDLE)hFile ) ? 0 : HFILE_ERROR; } /*********************************************************************** @@ -1881,7 +1883,7 @@ LONG WINAPI WIN16_hread( HFILE16 hFile, SEGPTR buffer, LONG count ) /* Some programs pass a count larger than the allocated buffer */ maxlen = GetSelectorLimit16( SELECTOROF(buffer) ) - OFFSETOF(buffer) + 1; if (count > maxlen) count = maxlen; - return _lread(DosFileHandleToWin32Handle(hFile), MapSL(buffer), count ); + return _lread((HFILE)DosFileHandleToWin32Handle(hFile), MapSL(buffer), count ); } @@ -1900,7 +1902,7 @@ UINT16 WINAPI WIN16_lread( HFILE16 hFile, SEGPTR buffer, UINT16 count ) UINT WINAPI _lread( HFILE handle, LPVOID buffer, UINT count ) { DWORD result; - if (!ReadFile( handle, buffer, count, &result, NULL )) return -1; + if (!ReadFile( (HANDLE)handle, buffer, count, &result, NULL )) return -1; return result; } @@ -1910,7 +1912,7 @@ UINT WINAPI _lread( HFILE handle, LPVOID buffer, UINT count ) */ UINT16 WINAPI _lread16( HFILE16 hFile, LPVOID buffer, UINT16 count ) { - return (UINT16)_lread(DosFileHandleToWin32Handle(hFile), buffer, (LONG)count ); + return (UINT16)_lread((HFILE)DosFileHandleToWin32Handle(hFile), buffer, (LONG)count ); } @@ -1919,7 +1921,7 @@ UINT16 WINAPI _lread16( HFILE16 hFile, LPVOID buffer, UINT16 count ) */ HFILE16 WINAPI _lcreat16( LPCSTR path, INT16 attr ) { - return Win32HandleToDosFileHandle( _lcreat( path, attr ) ); + return Win32HandleToDosFileHandle( (HANDLE)_lcreat( path, attr ) ); } @@ -1931,9 +1933,9 @@ HFILE WINAPI _lcreat( LPCSTR path, INT attr ) /* Mask off all flags not explicitly allowed by the doc */ attr &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM; TRACE("%s %02x\n", path, attr ); - return CreateFileA( path, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - CREATE_ALWAYS, attr, 0 ); + return (HFILE)CreateFileA( path, GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + CREATE_ALWAYS, attr, 0 ); } @@ -1986,7 +1988,7 @@ LONG WINAPI _llseek16( HFILE16 hFile, LONG lOffset, INT16 nOrigin ) */ LONG WINAPI _llseek( HFILE hFile, LONG lOffset, INT nOrigin ) { - return SetFilePointer( hFile, lOffset, NULL, nOrigin ); + return SetFilePointer( (HANDLE)hFile, lOffset, NULL, nOrigin ); } @@ -1995,7 +1997,7 @@ LONG WINAPI _llseek( HFILE hFile, LONG lOffset, INT nOrigin ) */ HFILE16 WINAPI _lopen16( LPCSTR path, INT16 mode ) { - return Win32HandleToDosFileHandle( _lopen( path, mode ) ); + return Win32HandleToDosFileHandle( (HANDLE)_lopen( path, mode ) ); } @@ -2008,7 +2010,7 @@ HFILE WINAPI _lopen( LPCSTR path, INT mode ) TRACE("('%s',%04x)\n", path, mode ); FILE_ConvertOFMode( mode, &access, &sharing ); - return CreateFileA( path, access, sharing, NULL, OPEN_EXISTING, 0, 0 ); + return (HFILE)CreateFileA( path, access, sharing, NULL, OPEN_EXISTING, 0, 0 ); } @@ -2017,7 +2019,7 @@ HFILE WINAPI _lopen( LPCSTR path, INT mode ) */ UINT16 WINAPI _lwrite16( HFILE16 hFile, LPCSTR buffer, UINT16 count ) { - return (UINT16)_hwrite( DosFileHandleToWin32Handle(hFile), buffer, (LONG)count ); + return (UINT16)_hwrite( (HFILE)DosFileHandleToWin32Handle(hFile), buffer, (LONG)count ); } /*********************************************************************** @@ -2034,7 +2036,7 @@ UINT WINAPI _lwrite( HFILE hFile, LPCSTR buffer, UINT count ) */ LONG WINAPI _hread16( HFILE16 hFile, LPVOID buffer, LONG count) { - return _lread( DosFileHandleToWin32Handle(hFile), buffer, count ); + return _lread( (HFILE)DosFileHandleToWin32Handle(hFile), buffer, count ); } @@ -2052,7 +2054,7 @@ LONG WINAPI _hread( HFILE hFile, LPVOID buffer, LONG count) */ LONG WINAPI _hwrite16( HFILE16 hFile, LPCSTR buffer, LONG count ) { - return _hwrite( DosFileHandleToWin32Handle(hFile), buffer, count ); + return _hwrite( (HFILE)DosFileHandleToWin32Handle(hFile), buffer, count ); } @@ -2075,10 +2077,10 @@ LONG WINAPI _hwrite( HFILE handle, LPCSTR buffer, LONG count ) if (!count) { /* Expand or truncate at current position */ - if (!SetEndOfFile( handle )) return HFILE_ERROR; + if (!SetEndOfFile( (HANDLE)handle )) return HFILE_ERROR; return 0; } - if (!WriteFile( handle, buffer, count, &result, NULL )) + if (!WriteFile( (HANDLE)handle, buffer, count, &result, NULL )) return HFILE_ERROR; return result; } @@ -2542,14 +2544,16 @@ BOOL WINAPI MoveFileW( LPCWSTR fn1, LPCWSTR fn2 ) */ BOOL WINAPI CopyFileA( LPCSTR source, LPCSTR dest, BOOL fail_if_exists ) { - HFILE h1, h2; + HANDLE h1, h2; BY_HANDLE_FILE_INFORMATION info; - UINT count; + DWORD count; BOOL ret = FALSE; int mode; char buffer[2048]; - if ((h1 = _lopen( source, OF_READ )) == HFILE_ERROR) return FALSE; + if ((h1 = CreateFileA( source, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE) + return FALSE; if (!GetFileInformationByHandle( h1, &info )) { CloseHandle( h1 ); @@ -2563,13 +2567,14 @@ BOOL WINAPI CopyFileA( LPCSTR source, LPCSTR dest, BOOL fail_if_exists ) CloseHandle( h1 ); return FALSE; } - while ((count = _lread( h1, buffer, sizeof(buffer) )) > 0) + + while (ReadFile( h1, buffer, sizeof(buffer), &count, NULL ) && count > 0) { char *p = buffer; while (count > 0) { - INT res = _lwrite( h2, p, count ); - if (res <= 0) goto done; + DWORD res; + if (!WriteFile( h2, p, count, &res, NULL ) || !res) goto done; p += res; count -= res; } @@ -2753,7 +2758,7 @@ BOOL WINAPI UnlockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetH * UnlockFileEx (KERNEL32.@) */ BOOL WINAPI UnlockFileEx( - HFILE hFile, + HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh, @@ -2881,7 +2886,7 @@ static BOOL DOS_RemoveLock(FILE_OBJECT *file, struct flock *f) * LockFile (KERNEL32.@) */ BOOL WINAPI LockFile( - HFILE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh, + HANDLE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh, DWORD nNumberOfBytesToLockLow,DWORD nNumberOfBytesToLockHigh ) { struct flock f; @@ -2932,7 +2937,7 @@ BOOL WINAPI LockFile( * UnlockFile (KERNEL32.@) */ BOOL WINAPI UnlockFile( - HFILE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh, + HANDLE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh, DWORD nNumberOfBytesToUnlockLow,DWORD nNumberOfBytesToUnlockHigh ) { FILE_OBJECT *file; diff --git a/include/file.h b/include/file.h index 25549cc1b42..cfd35ac226c 100644 --- a/include/file.h +++ b/include/file.h @@ -95,7 +95,7 @@ extern void DOSFS_UnixTimeToFileTime( time_t unixtime, LPFILETIME ft, extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder ); extern BOOL DOSFS_ToDosFCBFormat( LPCSTR name, LPSTR buffer ); extern const DOS_DEVICE *DOSFS_GetDevice( const char *name ); -extern const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile ); +extern const DOS_DEVICE *DOSFS_GetDeviceByHandle( HANDLE hFile ); extern HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa); extern BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf, INT long_len, LPSTR short_buf, diff --git a/include/module.h b/include/module.h index d1d5ccd3fbc..ef9145003df 100644 --- a/include/module.h +++ b/include/module.h @@ -207,7 +207,7 @@ extern BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved ); extern void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved ); extern void MODULE_DllThreadAttach( LPVOID lpReserved ); extern void MODULE_DllThreadDetach( LPVOID lpReserved ); -extern WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags ); +extern WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HANDLE hfile, DWORD flags ); extern BOOL MODULE_FreeLibrary( WINE_MODREF *wm ); extern WINE_MODREF *MODULE_FindModule( LPCSTR path ); extern HMODULE16 MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 ); @@ -231,8 +231,8 @@ extern DWORD NE_StartTask(void); /* loader/ne/resource.c */ extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16); extern BOOL NE_InitResourceHandler( HMODULE16 hModule ); -extern HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type ); -extern DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc ); +extern HRSRC NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type ); +extern DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC hRsrc ); extern HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc ); extern BOOL16 NE_FreeResource( NE_MODULE *pModule, HGLOBAL16 handle ); extern NE_TYPEINFO *NE_FindTypeSection( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR typeId ); diff --git a/include/winbase.h b/include/winbase.h index 3584c31675c..a27ded143d4 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -1487,6 +1487,7 @@ LPVOID WINAPI TlsGetValue(DWORD); BOOL WINAPI TlsSetValue(DWORD,LPVOID); BOOL WINAPI TransmitCommChar(HANDLE,CHAR); BOOL WINAPI UnlockFile(HANDLE,DWORD,DWORD,DWORD,DWORD); +BOOL WINAPI UnlockFileEx(HANDLE,DWORD,DWORD,DWORD,LPOVERLAPPED); BOOL WINAPI UnmapViewOfFile(LPVOID); BOOL WINAPI VerifyVersionInfoA(LPOSVERSIONINFOEXA,DWORD,DWORDLONG); BOOL WINAPI VerifyVersionInfoW(LPOSVERSIONINFOEXW,DWORD,DWORDLONG); @@ -1703,7 +1704,6 @@ BOOL WINAPI SetVolumeLabelA(LPCSTR,LPCSTR); BOOL WINAPI SetVolumeLabelW(LPCWSTR,LPCWSTR); #define SetVolumeLabel WINELIB_NAME_AW(SetVolumeLabel) DWORD WINAPI SizeofResource(HMODULE,HRSRC); -BOOL WINAPI UnlockFileEx(HFILE,DWORD,DWORD,DWORD,LPOVERLAPPED); #define UnlockSegment(handle) GlobalUnfix((HANDLE)(handle)) BOOL WINAPI WritePrivateProfileSectionA(LPCSTR,LPCSTR,LPCSTR); BOOL WINAPI WritePrivateProfileSectionW(LPCWSTR,LPCWSTR,LPCWSTR); diff --git a/loader/module.c b/loader/module.c index 6cd398e8160..6a41cb5f2d6 100644 --- a/loader/module.c +++ b/loader/module.c @@ -899,8 +899,8 @@ UINT WINAPI WinExec( LPCSTR lpCmdLine, UINT nCmdShow ) { PROCESS_INFORMATION info; STARTUPINFOA startup; - HINSTANCE hInstance; char *cmdline; + UINT ret; memset( &startup, 0, sizeof(startup) ); startup.cb = sizeof(startup); @@ -917,18 +917,18 @@ UINT WINAPI WinExec( LPCSTR lpCmdLine, UINT nCmdShow ) /* Give 30 seconds to the app to come up */ if (wait_input_idle( info.hProcess, 30000 ) == 0xFFFFFFFF) WARN("WaitForInputIdle failed: Error %ld\n", GetLastError() ); - hInstance = (HINSTANCE)33; + ret = 33; /* Close off the handles */ CloseHandle( info.hThread ); CloseHandle( info.hProcess ); } - else if ((hInstance = (HINSTANCE)GetLastError()) >= (HINSTANCE)32) + else if ((ret = GetLastError()) >= 32) { - FIXME("Strange error set by CreateProcess: %d\n", hInstance ); - hInstance = (HINSTANCE)11; + FIXME("Strange error set by CreateProcess: %d\n", ret ); + ret = 11; } HeapFree( GetProcessHeap(), 0, cmdline ); - return hInstance; + return ret; } /********************************************************************** @@ -1188,7 +1188,7 @@ static LPCSTR allocate_lib_dir(LPCSTR libname) * init function into load_library). * allocated_libdir is TRUE in the stack frame that allocated libdir */ -WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags ) +WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HANDLE hfile, DWORD flags ) { DWORD err = GetLastError(); WINE_MODREF *pwm; diff --git a/loader/ne/resource.c b/loader/ne/resource.c index b7139be4fda..57118d7db34 100644 --- a/loader/ne/resource.c +++ b/loader/ne/resource.c @@ -311,7 +311,7 @@ FARPROC16 WINAPI SetResourceHandler16( HMODULE16 hModule, LPCSTR typeId, /********************************************************************** * NE_FindResource */ -HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type ) +HRSRC NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type ) { NE_TYPEINFO *pTypeInfo; NE_NAMEINFO *pNameInfo; @@ -363,7 +363,7 @@ HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type ) if ((pNameInfo = NE_FindResourceFromType( pResTab, pTypeInfo, name ))) { TRACE(" Found id %08lx\n", (DWORD)name ); - return (HRSRC16)( (int)pNameInfo - (int)pModule ); + return (HRSRC)( (char *)pNameInfo - (char *)pModule ); } TRACE(" Not found, going on\n" ); pTypeInfo = NEXT_TYPEINFO(pTypeInfo); @@ -443,7 +443,7 @@ INT16 WINAPI AccessResource16( HINSTANCE16 hModule, HRSRC16 hRsrc ) /********************************************************************** * NE_SizeofResource */ -DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc ) +DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC hRsrc ) { NE_NAMEINFO *pNameInfo=NULL; WORD sizeShift; @@ -453,7 +453,7 @@ DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc ) TRACE("module=%04x res=%04x\n", pModule->self, hRsrc ); sizeShift = *(WORD *)((char *)pModule + pModule->res_table); - pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc); + pNameInfo = (NE_NAMEINFO*)((char*)pModule + LOWORD(hRsrc)); return (DWORD)pNameInfo->length << sizeShift; } diff --git a/loader/ne/segment.c b/loader/ne/segment.c index 6124bf40db3..198576fb740 100644 --- a/loader/ne/segment.c +++ b/loader/ne/segment.c @@ -111,7 +111,7 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum ) WORD count, i, offset, next_offset; HMODULE16 module; FARPROC16 address = 0; - HFILE hf; + HANDLE hf; DWORD res; struct relocation_entry_s *rep, *reloc_entries; BYTE *func_name; @@ -152,7 +152,7 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum ) /* Implement self-loading segments */ SELFLOADHEADER *selfloadheader; DWORD oldstack; - HFILE hFile32; + HANDLE hFile32; HFILE16 hFile16; selfloadheader = MapSL( MAKESEGPTR(SEL(pSegTable->hSeg),0) ); @@ -437,7 +437,7 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule ) if (pModule->flags & NE_FFLAGS_SELFLOAD) { - HFILE hf; + HANDLE hf; HFILE16 hFile16; HGLOBAL16 sel; /* Handle self-loading modules */ diff --git a/loader/resource.c b/loader/resource.c index e4d3e853c51..5d778798a2a 100644 --- a/loader/resource.c +++ b/loader/resource.c @@ -59,7 +59,7 @@ typedef struct _HRSRC_MAP /********************************************************************** * MapHRsrc32To16 */ -static HRSRC16 MapHRsrc32To16( NE_MODULE *pModule, HANDLE hRsrc32, WORD type ) +static HRSRC MapHRsrc32To16( NE_MODULE *pModule, HANDLE hRsrc32, WORD type ) { HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap; HRSRC_ELEM *newElem; @@ -80,7 +80,7 @@ static HRSRC16 MapHRsrc32To16( NE_MODULE *pModule, HANDLE hRsrc32, WORD type ) /* Check whether HRSRC32 already in map */ for ( i = 0; i < map->nUsed; i++ ) if ( map->elem[i].hRsrc == hRsrc32 ) - return (HRSRC16)(i + 1); + return (HRSRC)(i + 1); /* If no space left, grow table */ if ( map->nUsed == map->nAlloc ) @@ -102,13 +102,13 @@ static HRSRC16 MapHRsrc32To16( NE_MODULE *pModule, HANDLE hRsrc32, WORD type ) map->elem[map->nUsed].type = type; map->nUsed++; - return (HRSRC16)map->nUsed; + return (HRSRC)map->nUsed; } /********************************************************************** * MapHRsrc16To32 */ -static HANDLE MapHRsrc16To32( NE_MODULE *pModule, HRSRC16 hRsrc16 ) +static HRSRC MapHRsrc16To32( NE_MODULE *pModule, HRSRC hRsrc16 ) { HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap; if ( !map || !hRsrc16 || (int)hRsrc16 > map->nUsed ) return 0; @@ -119,7 +119,7 @@ static HANDLE MapHRsrc16To32( NE_MODULE *pModule, HRSRC16 hRsrc16 ) /********************************************************************** * MapHRsrc16ToType */ -static WORD MapHRsrc16ToType( NE_MODULE *pModule, HRSRC16 hRsrc16 ) +static WORD MapHRsrc16ToType( NE_MODULE *pModule, HRSRC hRsrc16 ) { HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap; if ( !map || !hRsrc16 || (int)hRsrc16 > map->nUsed ) return 0; @@ -293,7 +293,7 @@ static HGLOBAL RES_LoadResource( HMODULE hModule, HRSRC hRsrc, BOOL bRet16 ) /* 16-bit NE module */ /* If we got a 32-bit hRsrc, we don't need to convert it */ - hMem = NE_LoadResource( pModule, hRsrc ); + hMem = NE_LoadResource( pModule, LOWORD(hRsrc) ); /* If we are to return a 32-bit resource, we should probably convert it but we don't for now. FIXME !!! */ @@ -332,8 +332,8 @@ static HGLOBAL RES_LoadResource( HMODULE hModule, HRSRC hRsrc, BOOL bRet16 ) */ HRSRC16 WINAPI FindResource16( HMODULE16 hModule, LPCSTR name, LPCSTR type ) { - return RES_FindResource( hModule, type, name, - MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), FALSE, TRUE ); + return LOWORD( RES_FindResource( hModule, type, name, + MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), FALSE, TRUE ) ); } /********************************************************************** @@ -420,7 +420,7 @@ LPVOID WINAPI LockResource( HGLOBAL handle ) return (LPVOID)handle; /* 16-bit memory handle */ - return LockResource16( handle ); + return LockResource16( LOWORD(handle) ); } typedef WORD (WINAPI *pDestroyIcon32Proc)( HGLOBAL16 handle, UINT16 flags ); @@ -432,7 +432,7 @@ typedef WORD (WINAPI *pDestroyIcon32Proc)( HGLOBAL16 handle, UINT16 flags ); */ BOOL16 WINAPI FreeResource16( HGLOBAL16 handle ) { - HGLOBAL retv = handle; + HGLOBAL16 retv = handle; NE_MODULE *pModule = NE_GetPtr( FarGetOwner16( handle ) ); TRACE("(%04x)\n", handle ); @@ -463,7 +463,7 @@ BOOL WINAPI FreeResource( HGLOBAL handle ) { if (HIWORD(handle)) return 0; /* 32-bit memory handle: nothing to do */ - return FreeResource16( handle ); + return FreeResource16( LOWORD(handle) ); } /********************************************************************** diff --git a/objects/metafile.c b/objects/metafile.c index ad0404a1df1..8bd1c80cbed 100644 --- a/objects/metafile.c +++ b/objects/metafile.c @@ -209,7 +209,7 @@ BOOL WINAPI DeleteMetaFile( HMETAFILE hmf ) * Returns a pointer to a memory based METAHEADER read in from file HFILE * */ -static METAHEADER *MF_ReadMetaFile(HFILE hfile) +static METAHEADER *MF_ReadMetaFile(HANDLE hfile) { METAHEADER *mh; DWORD BytesRead, size; diff --git a/scheduler/handle.c b/scheduler/handle.c index b19db57a875..683e574bd1f 100644 --- a/scheduler/handle.c +++ b/scheduler/handle.c @@ -37,10 +37,10 @@ BOOL WINAPI CloseHandle( HANDLE handle ) NTSTATUS status; /* stdio handles need special treatment */ - if ((handle == STD_INPUT_HANDLE) || - (handle == STD_OUTPUT_HANDLE) || - (handle == STD_ERROR_HANDLE)) - handle = GetStdHandle( handle ); + if ((handle == (HANDLE)STD_INPUT_HANDLE) || + (handle == (HANDLE)STD_OUTPUT_HANDLE) || + (handle == (HANDLE)STD_ERROR_HANDLE)) + handle = GetStdHandle( (DWORD)handle ); status = NtClose( handle ); if (status) SetLastError( RtlNtStatusToDosError(status) ); diff --git a/scheduler/process.c b/scheduler/process.c index e95812dd7e9..040f68bccaf 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -449,7 +449,7 @@ static void start_process(void) int debugged, console_app; LPTHREAD_START_ROUTINE entry; WINE_MODREF *wm; - HFILE main_file = main_exe_file; + HANDLE main_file = main_exe_file; /* use original argv[0] as name for the main module */ if (!main_exe_name[0]) @@ -1332,7 +1332,7 @@ DWORD WINAPI GetProcessDword( DWORD dwProcessID, INT offset ) return GetAppCompatFlags16(0); case GPD_LOAD_DONE_EVENT: - return current_process.load_done_evt; + return (DWORD)current_process.load_done_evt; case GPD_HINSTANCE16: return GetTaskDS16(); @@ -1347,10 +1347,10 @@ DWORD WINAPI GetProcessDword( DWORD dwProcessID, INT offset ) return (DWORD)¤t_process; case GPD_STARTF_SHELLDATA: /* return stdoutput handle from startupinfo ??? */ - return current_startupinfo.hStdOutput; + return (DWORD)current_startupinfo.hStdOutput; case GPD_STARTF_HOTKEY: /* return stdinput handle from startupinfo ??? */ - return current_startupinfo.hStdInput; + return (DWORD)current_startupinfo.hStdInput; case GPD_STARTF_SHOWWINDOW: return current_startupinfo.wShowWindow; @@ -1920,5 +1920,5 @@ BOOL WINAPI TlsSetValue( #undef GetCurrentProcess HANDLE WINAPI GetCurrentProcess(void) { - return 0xffffffff; + return (HANDLE)0xffffffff; }