Fixed HANDLE<->HFILE conversions, since they will be different types

when handles are void*.
This commit is contained in:
Alexandre Julliard 2002-07-31 17:20:00 +00:00
parent 04b5a86c46
commit 267ca68253
19 changed files with 95 additions and 93 deletions

View File

@ -33,7 +33,7 @@ typedef struct
DC *dc; DC *dc;
ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */ ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */
UINT nextHandle; /* Next handle number */ UINT nextHandle; /* Next handle number */
HFILE hFile; /* HFILE for disk based MetaFile */ HANDLE hFile; /* Handle for disk based MetaFile */
} EMFDRV_PDEVICE; } EMFDRV_PDEVICE;
@ -139,4 +139,3 @@ extern BOOL EMFDRV_WidenPath( PHYSDEV dev );
#endif /* __WINE_METAFILEDRV_H */ #endif /* __WINE_METAFILEDRV_H */

View File

@ -277,7 +277,7 @@ HDC WINAPI CreateEnhMetaFileW(
DC *dc; DC *dc;
HDC hRefDC = hdc ? hdc : CreateDCA("DISPLAY",NULL,NULL,NULL); /* If no ref, use current display */ HDC hRefDC = hdc ? hdc : CreateDCA("DISPLAY",NULL,NULL,NULL); /* If no ref, use current display */
EMFDRV_PDEVICE *physDev; EMFDRV_PDEVICE *physDev;
HFILE hFile; HANDLE hFile;
DWORD size = 0, length = 0; DWORD size = 0, length = 0;
TRACE("%s\n", debugstr_w(filename) ); TRACE("%s\n", debugstr_w(filename) );

View File

@ -219,7 +219,7 @@ HDC16 WINAPI CreateMetaFile16(
HDC ret; HDC ret;
DC *dc; DC *dc;
METAFILEDRV_PDEVICE *physDev; METAFILEDRV_PDEVICE *physDev;
HFILE hFile; HANDLE hFile;
TRACE("'%s'\n", filename ); TRACE("'%s'\n", filename );

View File

@ -33,7 +33,7 @@ typedef struct
DC *dc; DC *dc;
METAHEADER *mh; /* Pointer to metafile header */ METAHEADER *mh; /* Pointer to metafile header */
UINT nextHandle; /* Next handle number */ UINT nextHandle; /* Next handle number */
HFILE hFile; /* HFILE for disk based MetaFile */ HANDLE hFile; /* Handle for disk based MetaFile */
} METAFILEDRV_PDEVICE; } METAFILEDRV_PDEVICE;
@ -152,4 +152,3 @@ extern BOOL MFDRV_StrokePath( PHYSDEV dev );
extern BOOL MFDRV_WidenPath( PHYSDEV dev ); extern BOOL MFDRV_WidenPath( PHYSDEV dev );
#endif /* __WINE_METAFILEDRV_H */ #endif /* __WINE_METAFILEDRV_H */

View File

@ -2044,7 +2044,7 @@ int TLB_ReadTypeLib(LPCWSTR pszFileName, INT index, ITypeLib2 **ppTypeLib)
{ {
int ret = TYPE_E_CANTLOADLIBRARY; int ret = TYPE_E_CANTLOADLIBRARY;
DWORD dwSignature = 0; DWORD dwSignature = 0;
HFILE hFile; HANDLE hFile;
TRACE_(typelib)("%s:%d\n", debugstr_w(pszFileName), index); TRACE_(typelib)("%s:%d\n", debugstr_w(pszFileName), index);

View File

@ -251,7 +251,7 @@ static HRESULT ICO_ExtractIconExW(
HGLOBAL hRet = E_FAIL; HGLOBAL hRet = E_FAIL;
LPBYTE pData; LPBYTE pData;
DWORD sig; DWORD sig;
HFILE hFile; HANDLE hFile;
UINT16 iconDirCount = 0,iconCount = 0; UINT16 iconDirCount = 0,iconCount = 0;
LPBYTE peimage; LPBYTE peimage;
HANDLE fmapping; HANDLE fmapping;
@ -676,4 +676,3 @@ HRESULT WINAPI PrivateExtractIconExA (
HeapFree(GetProcessHeap(), 0, lpwstrFile); HeapFree(GetProcessHeap(), 0, lpwstrFile);
return ret; return ret;
} }

View File

@ -342,7 +342,7 @@ BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID para
* (i.e. one DOS app spawning another) */ * (i.e. one DOS app spawning another) */
/* FIXME: do we want to check binary type first, to check /* FIXME: do we want to check binary type first, to check
* whether it's a NE/PE executable? */ * 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); NULL, OPEN_EXISTING, 0, 0);
BOOL ret = FALSE; BOOL ret = FALSE;
if (hFile == INVALID_HANDLE_VALUE) return FALSE; if (hFile == INVALID_HANDLE_VALUE) return FALSE;

View File

@ -684,7 +684,7 @@ BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf,
*/ */
const DOS_DEVICE *DOSFS_GetDevice( const char *name ) const DOS_DEVICE *DOSFS_GetDevice( const char *name )
{ {
int i; unsigned int i;
const char *p; const char *p;
if (!name) return NULL; /* if FILE_DupUnixHandle was used */ if (!name) return NULL; /* if FILE_DupUnixHandle was used */
@ -707,7 +707,7 @@ const DOS_DEVICE *DOSFS_GetDevice( const char *name )
/*********************************************************************** /***********************************************************************
* DOSFS_GetDeviceByHandle * DOSFS_GetDeviceByHandle
*/ */
const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile ) const DOS_DEVICE *DOSFS_GetDeviceByHandle( HANDLE hFile )
{ {
const DOS_DEVICE *ret = NULL; const DOS_DEVICE *ret = NULL;
SERVER_START_REQ( get_file_info ) 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 ) HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa )
{ {
int i; unsigned int i;
const char *p; const char *p;
HANDLE handle; HANDLE handle;

View File

@ -936,7 +936,7 @@ static UINT FILE_GetTempFileName( LPCSTR path, LPCSTR prefix, UINT unique,
{ {
do do
{ {
HFILE handle = CreateFileA( buffer, GENERIC_WRITE, 0, NULL, HANDLE handle = CreateFileA( buffer, GENERIC_WRITE, 0, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 ); CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
if (handle != INVALID_HANDLE_VALUE) if (handle != INVALID_HANDLE_VALUE)
{ /* We created it */ { /* We created it */
@ -1031,6 +1031,7 @@ static HFILE FILE_DoOpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode,
BOOL win32 ) BOOL win32 )
{ {
HFILE hFileRet; HFILE hFileRet;
HANDLE handle;
FILETIME filetime; FILETIME filetime;
WORD filedatetime[2]; WORD filedatetime[2];
DOS_FULL_NAME full_name; DOS_FULL_NAME full_name;
@ -1094,7 +1095,7 @@ static HFILE FILE_DoOpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode,
if (mode & OF_CREATE) if (mode & OF_CREATE)
{ {
if ((hFileRet = CreateFileA( name, GENERIC_READ | GENERIC_WRITE, if ((handle = CreateFileA( name, GENERIC_READ | GENERIC_WRITE,
sharing, NULL, CREATE_ALWAYS, sharing, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0 ))== INVALID_HANDLE_VALUE) FILE_ATTRIBUTE_NORMAL, 0 ))== INVALID_HANDLE_VALUE)
goto error; goto error;
@ -1153,19 +1154,19 @@ found:
return 1; return 1;
} }
hFileRet = FILE_CreateFile( full_name.long_name, access, sharing, handle = FILE_CreateFile( full_name.long_name, access, sharing,
NULL, OPEN_EXISTING, 0, 0, NULL, OPEN_EXISTING, 0, 0,
DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY, DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY,
GetDriveTypeA( full_name.short_name ) ); GetDriveTypeA( full_name.short_name ) );
if (!hFileRet) goto not_found; if (!handle) goto not_found;
GetFileTime( hFileRet, NULL, NULL, &filetime ); GetFileTime( handle, NULL, NULL, &filetime );
FileTimeToDosDateTime( &filetime, &filedatetime[0], &filedatetime[1] ); FileTimeToDosDateTime( &filetime, &filedatetime[0], &filedatetime[1] );
if ((mode & OF_VERIFY) && (mode & OF_REOPEN)) if ((mode & OF_VERIFY) && (mode & OF_REOPEN))
{ {
if (memcmp( ofs->reserved, filedatetime, sizeof(ofs->reserved) )) if (memcmp( ofs->reserved, filedatetime, sizeof(ofs->reserved) ))
{ {
CloseHandle( hFileRet ); CloseHandle( handle );
WARN("(%s): OF_VERIFY failed\n", name ); WARN("(%s): OF_VERIFY failed\n", name );
/* FIXME: what error here? */ /* FIXME: what error here? */
SetLastError( ERROR_FILE_NOT_FOUND ); SetLastError( ERROR_FILE_NOT_FOUND );
@ -1175,15 +1176,16 @@ found:
memcpy( ofs->reserved, filedatetime, sizeof(ofs->reserved) ); memcpy( ofs->reserved, filedatetime, sizeof(ofs->reserved) );
success: /* We get here if the open was successful */ 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) if (win32)
{ {
hFileRet = (HFILE)handle;
if (mode & OF_EXIST) /* Return the handle, but close it first */ if (mode & OF_EXIST) /* Return the handle, but close it first */
CloseHandle( hFileRet ); CloseHandle( handle );
} }
else else
{ {
hFileRet = Win32HandleToDosFileHandle( hFileRet ); hFileRet = Win32HandleToDosFileHandle( handle );
if (hFileRet == HFILE_ERROR16) goto error; if (hFileRet == HFILE_ERROR16) goto error;
if (mode & OF_EXIST) /* Return the handle, but close it first */ if (mode & OF_EXIST) /* Return the handle, but close it first */
_lclose16( hFileRet ); _lclose16( hFileRet );
@ -1374,7 +1376,7 @@ HFILE16 WINAPI _lclose16( HFILE16 hFile )
HFILE WINAPI _lclose( HFILE hFile ) HFILE WINAPI _lclose( HFILE hFile )
{ {
TRACE("handle %d\n", 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 */ /* Some programs pass a count larger than the allocated buffer */
maxlen = GetSelectorLimit16( SELECTOROF(buffer) ) - OFFSETOF(buffer) + 1; maxlen = GetSelectorLimit16( SELECTOROF(buffer) ) - OFFSETOF(buffer) + 1;
if (count > maxlen) count = maxlen; 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 ) UINT WINAPI _lread( HFILE handle, LPVOID buffer, UINT count )
{ {
DWORD result; DWORD result;
if (!ReadFile( handle, buffer, count, &result, NULL )) return -1; if (!ReadFile( (HANDLE)handle, buffer, count, &result, NULL )) return -1;
return result; return result;
} }
@ -1910,7 +1912,7 @@ UINT WINAPI _lread( HFILE handle, LPVOID buffer, UINT count )
*/ */
UINT16 WINAPI _lread16( HFILE16 hFile, LPVOID buffer, UINT16 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 ) HFILE16 WINAPI _lcreat16( LPCSTR path, INT16 attr )
{ {
return Win32HandleToDosFileHandle( _lcreat( path, attr ) ); return Win32HandleToDosFileHandle( (HANDLE)_lcreat( path, attr ) );
} }
@ -1931,7 +1933,7 @@ HFILE WINAPI _lcreat( LPCSTR path, INT attr )
/* Mask off all flags not explicitly allowed by the doc */ /* Mask off all flags not explicitly allowed by the doc */
attr &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM; attr &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM;
TRACE("%s %02x\n", path, attr ); TRACE("%s %02x\n", path, attr );
return CreateFileA( path, GENERIC_READ | GENERIC_WRITE, return (HFILE)CreateFileA( path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, attr, 0 ); 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 ) 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 ) 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 ); TRACE("('%s',%04x)\n", path, mode );
FILE_ConvertOFMode( mode, &access, &sharing ); 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 ) 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) 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 ) 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) if (!count)
{ {
/* Expand or truncate at current position */ /* Expand or truncate at current position */
if (!SetEndOfFile( handle )) return HFILE_ERROR; if (!SetEndOfFile( (HANDLE)handle )) return HFILE_ERROR;
return 0; return 0;
} }
if (!WriteFile( handle, buffer, count, &result, NULL )) if (!WriteFile( (HANDLE)handle, buffer, count, &result, NULL ))
return HFILE_ERROR; return HFILE_ERROR;
return result; return result;
} }
@ -2542,14 +2544,16 @@ BOOL WINAPI MoveFileW( LPCWSTR fn1, LPCWSTR fn2 )
*/ */
BOOL WINAPI CopyFileA( LPCSTR source, LPCSTR dest, BOOL fail_if_exists ) BOOL WINAPI CopyFileA( LPCSTR source, LPCSTR dest, BOOL fail_if_exists )
{ {
HFILE h1, h2; HANDLE h1, h2;
BY_HANDLE_FILE_INFORMATION info; BY_HANDLE_FILE_INFORMATION info;
UINT count; DWORD count;
BOOL ret = FALSE; BOOL ret = FALSE;
int mode; int mode;
char buffer[2048]; 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 )) if (!GetFileInformationByHandle( h1, &info ))
{ {
CloseHandle( h1 ); CloseHandle( h1 );
@ -2563,13 +2567,14 @@ BOOL WINAPI CopyFileA( LPCSTR source, LPCSTR dest, BOOL fail_if_exists )
CloseHandle( h1 ); CloseHandle( h1 );
return FALSE; return FALSE;
} }
while ((count = _lread( h1, buffer, sizeof(buffer) )) > 0)
while (ReadFile( h1, buffer, sizeof(buffer), &count, NULL ) && count > 0)
{ {
char *p = buffer; char *p = buffer;
while (count > 0) while (count > 0)
{ {
INT res = _lwrite( h2, p, count ); DWORD res;
if (res <= 0) goto done; if (!WriteFile( h2, p, count, &res, NULL ) || !res) goto done;
p += res; p += res;
count -= res; count -= res;
} }
@ -2753,7 +2758,7 @@ BOOL WINAPI UnlockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetH
* UnlockFileEx (KERNEL32.@) * UnlockFileEx (KERNEL32.@)
*/ */
BOOL WINAPI UnlockFileEx( BOOL WINAPI UnlockFileEx(
HFILE hFile, HANDLE hFile,
DWORD dwReserved, DWORD dwReserved,
DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockLow,
DWORD nNumberOfBytesToUnlockHigh, DWORD nNumberOfBytesToUnlockHigh,
@ -2881,7 +2886,7 @@ static BOOL DOS_RemoveLock(FILE_OBJECT *file, struct flock *f)
* LockFile (KERNEL32.@) * LockFile (KERNEL32.@)
*/ */
BOOL WINAPI LockFile( BOOL WINAPI LockFile(
HFILE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh, HANDLE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToLockLow,DWORD nNumberOfBytesToLockHigh ) DWORD nNumberOfBytesToLockLow,DWORD nNumberOfBytesToLockHigh )
{ {
struct flock f; struct flock f;
@ -2932,7 +2937,7 @@ BOOL WINAPI LockFile(
* UnlockFile (KERNEL32.@) * UnlockFile (KERNEL32.@)
*/ */
BOOL WINAPI UnlockFile( BOOL WINAPI UnlockFile(
HFILE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh, HANDLE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToUnlockLow,DWORD nNumberOfBytesToUnlockHigh ) DWORD nNumberOfBytesToUnlockLow,DWORD nNumberOfBytesToUnlockHigh )
{ {
FILE_OBJECT *file; FILE_OBJECT *file;

View File

@ -95,7 +95,7 @@ extern void DOSFS_UnixTimeToFileTime( time_t unixtime, LPFILETIME ft,
extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder ); extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder );
extern BOOL DOSFS_ToDosFCBFormat( LPCSTR name, LPSTR buffer ); extern BOOL DOSFS_ToDosFCBFormat( LPCSTR name, LPSTR buffer );
extern const DOS_DEVICE *DOSFS_GetDevice( const char *name ); 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 HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa);
extern BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf, extern BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf,
INT long_len, LPSTR short_buf, INT long_len, LPSTR short_buf,

View File

@ -207,7 +207,7 @@ extern BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
extern void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved ); extern void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved );
extern void MODULE_DllThreadAttach( LPVOID lpReserved ); extern void MODULE_DllThreadAttach( LPVOID lpReserved );
extern void MODULE_DllThreadDetach( 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 BOOL MODULE_FreeLibrary( WINE_MODREF *wm );
extern WINE_MODREF *MODULE_FindModule( LPCSTR path ); extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
extern HMODULE16 MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 ); extern HMODULE16 MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 );
@ -231,8 +231,8 @@ extern DWORD NE_StartTask(void);
/* loader/ne/resource.c */ /* loader/ne/resource.c */
extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16); extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
extern BOOL NE_InitResourceHandler( HMODULE16 hModule ); extern BOOL NE_InitResourceHandler( HMODULE16 hModule );
extern HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type ); extern HRSRC NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type );
extern DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc ); extern DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC hRsrc );
extern HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc ); extern HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc );
extern BOOL16 NE_FreeResource( NE_MODULE *pModule, HGLOBAL16 handle ); extern BOOL16 NE_FreeResource( NE_MODULE *pModule, HGLOBAL16 handle );
extern NE_TYPEINFO *NE_FindTypeSection( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR typeId ); extern NE_TYPEINFO *NE_FindTypeSection( LPBYTE pResTab, NE_TYPEINFO *pTypeInfo, LPCSTR typeId );

View File

@ -1487,6 +1487,7 @@ LPVOID WINAPI TlsGetValue(DWORD);
BOOL WINAPI TlsSetValue(DWORD,LPVOID); BOOL WINAPI TlsSetValue(DWORD,LPVOID);
BOOL WINAPI TransmitCommChar(HANDLE,CHAR); BOOL WINAPI TransmitCommChar(HANDLE,CHAR);
BOOL WINAPI UnlockFile(HANDLE,DWORD,DWORD,DWORD,DWORD); BOOL WINAPI UnlockFile(HANDLE,DWORD,DWORD,DWORD,DWORD);
BOOL WINAPI UnlockFileEx(HANDLE,DWORD,DWORD,DWORD,LPOVERLAPPED);
BOOL WINAPI UnmapViewOfFile(LPVOID); BOOL WINAPI UnmapViewOfFile(LPVOID);
BOOL WINAPI VerifyVersionInfoA(LPOSVERSIONINFOEXA,DWORD,DWORDLONG); BOOL WINAPI VerifyVersionInfoA(LPOSVERSIONINFOEXA,DWORD,DWORDLONG);
BOOL WINAPI VerifyVersionInfoW(LPOSVERSIONINFOEXW,DWORD,DWORDLONG); BOOL WINAPI VerifyVersionInfoW(LPOSVERSIONINFOEXW,DWORD,DWORDLONG);
@ -1703,7 +1704,6 @@ BOOL WINAPI SetVolumeLabelA(LPCSTR,LPCSTR);
BOOL WINAPI SetVolumeLabelW(LPCWSTR,LPCWSTR); BOOL WINAPI SetVolumeLabelW(LPCWSTR,LPCWSTR);
#define SetVolumeLabel WINELIB_NAME_AW(SetVolumeLabel) #define SetVolumeLabel WINELIB_NAME_AW(SetVolumeLabel)
DWORD WINAPI SizeofResource(HMODULE,HRSRC); DWORD WINAPI SizeofResource(HMODULE,HRSRC);
BOOL WINAPI UnlockFileEx(HFILE,DWORD,DWORD,DWORD,LPOVERLAPPED);
#define UnlockSegment(handle) GlobalUnfix((HANDLE)(handle)) #define UnlockSegment(handle) GlobalUnfix((HANDLE)(handle))
BOOL WINAPI WritePrivateProfileSectionA(LPCSTR,LPCSTR,LPCSTR); BOOL WINAPI WritePrivateProfileSectionA(LPCSTR,LPCSTR,LPCSTR);
BOOL WINAPI WritePrivateProfileSectionW(LPCWSTR,LPCWSTR,LPCWSTR); BOOL WINAPI WritePrivateProfileSectionW(LPCWSTR,LPCWSTR,LPCWSTR);

View File

@ -899,8 +899,8 @@ UINT WINAPI WinExec( LPCSTR lpCmdLine, UINT nCmdShow )
{ {
PROCESS_INFORMATION info; PROCESS_INFORMATION info;
STARTUPINFOA startup; STARTUPINFOA startup;
HINSTANCE hInstance;
char *cmdline; char *cmdline;
UINT ret;
memset( &startup, 0, sizeof(startup) ); memset( &startup, 0, sizeof(startup) );
startup.cb = 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 */ /* Give 30 seconds to the app to come up */
if (wait_input_idle( info.hProcess, 30000 ) == 0xFFFFFFFF) if (wait_input_idle( info.hProcess, 30000 ) == 0xFFFFFFFF)
WARN("WaitForInputIdle failed: Error %ld\n", GetLastError() ); WARN("WaitForInputIdle failed: Error %ld\n", GetLastError() );
hInstance = (HINSTANCE)33; ret = 33;
/* Close off the handles */ /* Close off the handles */
CloseHandle( info.hThread ); CloseHandle( info.hThread );
CloseHandle( info.hProcess ); CloseHandle( info.hProcess );
} }
else if ((hInstance = (HINSTANCE)GetLastError()) >= (HINSTANCE)32) else if ((ret = GetLastError()) >= 32)
{ {
FIXME("Strange error set by CreateProcess: %d\n", hInstance ); FIXME("Strange error set by CreateProcess: %d\n", ret );
hInstance = (HINSTANCE)11; ret = 11;
} }
HeapFree( GetProcessHeap(), 0, cmdline ); HeapFree( GetProcessHeap(), 0, cmdline );
return hInstance; return ret;
} }
/********************************************************************** /**********************************************************************
@ -1188,7 +1188,7 @@ static LPCSTR allocate_lib_dir(LPCSTR libname)
* init function into load_library). * init function into load_library).
* allocated_libdir is TRUE in the stack frame that allocated libdir * 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(); DWORD err = GetLastError();
WINE_MODREF *pwm; WINE_MODREF *pwm;

View File

@ -311,7 +311,7 @@ FARPROC16 WINAPI SetResourceHandler16( HMODULE16 hModule, LPCSTR typeId,
/********************************************************************** /**********************************************************************
* NE_FindResource * 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_TYPEINFO *pTypeInfo;
NE_NAMEINFO *pNameInfo; NE_NAMEINFO *pNameInfo;
@ -363,7 +363,7 @@ HRSRC16 NE_FindResource( NE_MODULE *pModule, LPCSTR name, LPCSTR type )
if ((pNameInfo = NE_FindResourceFromType( pResTab, pTypeInfo, name ))) if ((pNameInfo = NE_FindResourceFromType( pResTab, pTypeInfo, name )))
{ {
TRACE(" Found id %08lx\n", (DWORD)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" ); TRACE(" Not found, going on\n" );
pTypeInfo = NEXT_TYPEINFO(pTypeInfo); pTypeInfo = NEXT_TYPEINFO(pTypeInfo);
@ -443,7 +443,7 @@ INT16 WINAPI AccessResource16( HINSTANCE16 hModule, HRSRC16 hRsrc )
/********************************************************************** /**********************************************************************
* NE_SizeofResource * NE_SizeofResource
*/ */
DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc ) DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC hRsrc )
{ {
NE_NAMEINFO *pNameInfo=NULL; NE_NAMEINFO *pNameInfo=NULL;
WORD sizeShift; WORD sizeShift;
@ -453,7 +453,7 @@ DWORD NE_SizeofResource( NE_MODULE *pModule, HRSRC16 hRsrc )
TRACE("module=%04x res=%04x\n", pModule->self, hRsrc ); TRACE("module=%04x res=%04x\n", pModule->self, hRsrc );
sizeShift = *(WORD *)((char *)pModule + pModule->res_table); 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; return (DWORD)pNameInfo->length << sizeShift;
} }

View File

@ -111,7 +111,7 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
WORD count, i, offset, next_offset; WORD count, i, offset, next_offset;
HMODULE16 module; HMODULE16 module;
FARPROC16 address = 0; FARPROC16 address = 0;
HFILE hf; HANDLE hf;
DWORD res; DWORD res;
struct relocation_entry_s *rep, *reloc_entries; struct relocation_entry_s *rep, *reloc_entries;
BYTE *func_name; BYTE *func_name;
@ -152,7 +152,7 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
/* Implement self-loading segments */ /* Implement self-loading segments */
SELFLOADHEADER *selfloadheader; SELFLOADHEADER *selfloadheader;
DWORD oldstack; DWORD oldstack;
HFILE hFile32; HANDLE hFile32;
HFILE16 hFile16; HFILE16 hFile16;
selfloadheader = MapSL( MAKESEGPTR(SEL(pSegTable->hSeg),0) ); selfloadheader = MapSL( MAKESEGPTR(SEL(pSegTable->hSeg),0) );
@ -437,7 +437,7 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule )
if (pModule->flags & NE_FFLAGS_SELFLOAD) if (pModule->flags & NE_FFLAGS_SELFLOAD)
{ {
HFILE hf; HANDLE hf;
HFILE16 hFile16; HFILE16 hFile16;
HGLOBAL16 sel; HGLOBAL16 sel;
/* Handle self-loading modules */ /* Handle self-loading modules */

View File

@ -59,7 +59,7 @@ typedef struct _HRSRC_MAP
/********************************************************************** /**********************************************************************
* MapHRsrc32To16 * 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_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap;
HRSRC_ELEM *newElem; HRSRC_ELEM *newElem;
@ -80,7 +80,7 @@ static HRSRC16 MapHRsrc32To16( NE_MODULE *pModule, HANDLE hRsrc32, WORD type )
/* Check whether HRSRC32 already in map */ /* Check whether HRSRC32 already in map */
for ( i = 0; i < map->nUsed; i++ ) for ( i = 0; i < map->nUsed; i++ )
if ( map->elem[i].hRsrc == hRsrc32 ) if ( map->elem[i].hRsrc == hRsrc32 )
return (HRSRC16)(i + 1); return (HRSRC)(i + 1);
/* If no space left, grow table */ /* If no space left, grow table */
if ( map->nUsed == map->nAlloc ) 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->elem[map->nUsed].type = type;
map->nUsed++; map->nUsed++;
return (HRSRC16)map->nUsed; return (HRSRC)map->nUsed;
} }
/********************************************************************** /**********************************************************************
* MapHRsrc16To32 * MapHRsrc16To32
*/ */
static HANDLE MapHRsrc16To32( NE_MODULE *pModule, HRSRC16 hRsrc16 ) static HRSRC MapHRsrc16To32( NE_MODULE *pModule, HRSRC hRsrc16 )
{ {
HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap; HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap;
if ( !map || !hRsrc16 || (int)hRsrc16 > map->nUsed ) return 0; if ( !map || !hRsrc16 || (int)hRsrc16 > map->nUsed ) return 0;
@ -119,7 +119,7 @@ static HANDLE MapHRsrc16To32( NE_MODULE *pModule, HRSRC16 hRsrc16 )
/********************************************************************** /**********************************************************************
* MapHRsrc16ToType * MapHRsrc16ToType
*/ */
static WORD MapHRsrc16ToType( NE_MODULE *pModule, HRSRC16 hRsrc16 ) static WORD MapHRsrc16ToType( NE_MODULE *pModule, HRSRC hRsrc16 )
{ {
HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap; HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap;
if ( !map || !hRsrc16 || (int)hRsrc16 > map->nUsed ) return 0; 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 */ /* 16-bit NE module */
/* If we got a 32-bit hRsrc, we don't need to convert it */ /* 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 /* If we are to return a 32-bit resource, we should probably
convert it but we don't for now. FIXME !!! */ 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 ) HRSRC16 WINAPI FindResource16( HMODULE16 hModule, LPCSTR name, LPCSTR type )
{ {
return RES_FindResource( hModule, type, name, return LOWORD( RES_FindResource( hModule, type, name,
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), FALSE, TRUE ); MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), FALSE, TRUE ) );
} }
/********************************************************************** /**********************************************************************
@ -420,7 +420,7 @@ LPVOID WINAPI LockResource( HGLOBAL handle )
return (LPVOID)handle; return (LPVOID)handle;
/* 16-bit memory handle */ /* 16-bit memory handle */
return LockResource16( handle ); return LockResource16( LOWORD(handle) );
} }
typedef WORD (WINAPI *pDestroyIcon32Proc)( HGLOBAL16 handle, UINT16 flags ); 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 ) BOOL16 WINAPI FreeResource16( HGLOBAL16 handle )
{ {
HGLOBAL retv = handle; HGLOBAL16 retv = handle;
NE_MODULE *pModule = NE_GetPtr( FarGetOwner16( handle ) ); NE_MODULE *pModule = NE_GetPtr( FarGetOwner16( handle ) );
TRACE("(%04x)\n", 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 */ if (HIWORD(handle)) return 0; /* 32-bit memory handle: nothing to do */
return FreeResource16( handle ); return FreeResource16( LOWORD(handle) );
} }
/********************************************************************** /**********************************************************************

View File

@ -209,7 +209,7 @@ BOOL WINAPI DeleteMetaFile( HMETAFILE hmf )
* Returns a pointer to a memory based METAHEADER read in from file HFILE * 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; METAHEADER *mh;
DWORD BytesRead, size; DWORD BytesRead, size;

View File

@ -37,10 +37,10 @@ BOOL WINAPI CloseHandle( HANDLE handle )
NTSTATUS status; NTSTATUS status;
/* stdio handles need special treatment */ /* stdio handles need special treatment */
if ((handle == STD_INPUT_HANDLE) || if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
(handle == STD_OUTPUT_HANDLE) || (handle == (HANDLE)STD_OUTPUT_HANDLE) ||
(handle == STD_ERROR_HANDLE)) (handle == (HANDLE)STD_ERROR_HANDLE))
handle = GetStdHandle( handle ); handle = GetStdHandle( (DWORD)handle );
status = NtClose( handle ); status = NtClose( handle );
if (status) SetLastError( RtlNtStatusToDosError(status) ); if (status) SetLastError( RtlNtStatusToDosError(status) );

View File

@ -449,7 +449,7 @@ static void start_process(void)
int debugged, console_app; int debugged, console_app;
LPTHREAD_START_ROUTINE entry; LPTHREAD_START_ROUTINE entry;
WINE_MODREF *wm; 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 */ /* use original argv[0] as name for the main module */
if (!main_exe_name[0]) if (!main_exe_name[0])
@ -1332,7 +1332,7 @@ DWORD WINAPI GetProcessDword( DWORD dwProcessID, INT offset )
return GetAppCompatFlags16(0); return GetAppCompatFlags16(0);
case GPD_LOAD_DONE_EVENT: case GPD_LOAD_DONE_EVENT:
return current_process.load_done_evt; return (DWORD)current_process.load_done_evt;
case GPD_HINSTANCE16: case GPD_HINSTANCE16:
return GetTaskDS16(); return GetTaskDS16();
@ -1347,10 +1347,10 @@ DWORD WINAPI GetProcessDword( DWORD dwProcessID, INT offset )
return (DWORD)&current_process; return (DWORD)&current_process;
case GPD_STARTF_SHELLDATA: /* return stdoutput handle from startupinfo ??? */ 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 ??? */ case GPD_STARTF_HOTKEY: /* return stdinput handle from startupinfo ??? */
return current_startupinfo.hStdInput; return (DWORD)current_startupinfo.hStdInput;
case GPD_STARTF_SHOWWINDOW: case GPD_STARTF_SHOWWINDOW:
return current_startupinfo.wShowWindow; return current_startupinfo.wShowWindow;
@ -1920,5 +1920,5 @@ BOOL WINAPI TlsSetValue(
#undef GetCurrentProcess #undef GetCurrentProcess
HANDLE WINAPI GetCurrentProcess(void) HANDLE WINAPI GetCurrentProcess(void)
{ {
return 0xffffffff; return (HANDLE)0xffffffff;
} }