[5/5] kernel32: Fix compilation warnings in 64-bit mode
Dmitry Timoshkov
dmitry at codeweavers.com
Wed May 23 02:36:53 CDT 2007
Hello,
there should be a general way to disable 16-bit code/dlls on a not i386
platform, otherwise kernel32 would be completely 64-bit clean.
Changelog:
kernel32: Fix compilation warnings in 64-bit mode.
---
dlls/kernel32/file.c | 24 +++++++++++++++---------
dlls/kernel32/heap.c | 3 +++
dlls/kernel32/instr.c | 21 +++++++++++++++++++--
dlls/kernel32/kernel_main.c | 4 ++++
dlls/kernel32/kernel_private.h | 2 +-
dlls/kernel32/locale.c | 2 +-
dlls/kernel32/lzexpand.c | 6 +++---
dlls/kernel32/process.c | 16 ++++++++--------
dlls/kernel32/pthread.c | 6 +++---
dlls/kernel32/resource.c | 18 +++++++++---------
dlls/kernel32/sync.c | 4 ++--
dlls/kernel32/syslevel.c | 4 ++--
dlls/kernel32/thread.c | 8 ++++----
13 files changed, 74 insertions(+), 44 deletions(-)
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
index b3cf323..be8ca63 100644
--- a/dlls/kernel32/file.c
+++ b/dlls/kernel32/file.c
@@ -664,10 +664,10 @@ LONG WINAPI _hwrite( HFILE handle, LPCSTR buffer, LONG count )
if (!count)
{
/* Expand or truncate at current position */
- if (!SetEndOfFile( (HANDLE)handle )) return HFILE_ERROR;
+ if (!SetEndOfFile( LongToHandle(handle) )) return HFILE_ERROR;
return 0;
}
- if (!WriteFile( (HANDLE)handle, buffer, count, &result, NULL ))
+ if (!WriteFile( LongToHandle(handle), buffer, count, &result, NULL ))
return HFILE_ERROR;
return result;
}
@@ -679,7 +679,7 @@ LONG WINAPI _hwrite( HFILE handle, LPCSTR buffer, LONG count )
HFILE WINAPI _lclose( HFILE hFile )
{
TRACE("handle %d\n", hFile );
- return CloseHandle( (HANDLE)hFile ) ? 0 : HFILE_ERROR;
+ return CloseHandle( LongToHandle(hFile) ) ? 0 : HFILE_ERROR;
}
@@ -688,12 +688,15 @@ HFILE WINAPI _lclose( HFILE hFile )
*/
HFILE WINAPI _lcreat( LPCSTR path, INT attr )
{
+ HANDLE hfile;
+
/* 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 (HFILE)CreateFileA( path, GENERIC_READ | GENERIC_WRITE,
+ hfile = CreateFileA( path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, attr, 0 );
+ return HandleToLong(hfile);
}
@@ -702,8 +705,11 @@ HFILE WINAPI _lcreat( LPCSTR path, INT attr )
*/
HFILE WINAPI _lopen( LPCSTR path, INT mode )
{
+ HANDLE hfile;
+
TRACE("(%s,%04x)\n", debugstr_a(path), mode );
- return (HFILE)create_file_OF( path, mode & ~OF_CREATE );
+ hfile = create_file_OF( path, mode & ~OF_CREATE );
+ return HandleToLong(hfile);
}
/***********************************************************************
@@ -712,7 +718,7 @@ HFILE WINAPI _lopen( LPCSTR path, INT mode )
UINT WINAPI _lread( HFILE handle, LPVOID buffer, UINT count )
{
DWORD result;
- if (!ReadFile( (HANDLE)handle, buffer, count, &result, NULL ))
+ if (!ReadFile( LongToHandle(handle), buffer, count, &result, NULL ))
return HFILE_ERROR;
return result;
}
@@ -723,7 +729,7 @@ UINT WINAPI _lread( HFILE handle, LPVOID buffer, UINT count )
*/
LONG WINAPI _llseek( HFILE hFile, LONG lOffset, INT nOrigin )
{
- return SetFilePointer( (HANDLE)hFile, lOffset, NULL, nOrigin );
+ return SetFilePointer( LongToHandle(hFile), lOffset, NULL, nOrigin );
}
@@ -2254,7 +2260,7 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode )
return TRUE;
}
- handle = (HANDLE)_lopen( ofs->szPathName, mode );
+ handle = LongToHandle(_lopen( ofs->szPathName, mode ));
if (handle == INVALID_HANDLE_VALUE) goto error;
GetFileTime( handle, NULL, NULL, &filetime );
@@ -2279,7 +2285,7 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode )
CloseHandle( handle );
return TRUE;
}
- else return (HFILE)handle;
+ return HandleToLong(handle);
error: /* We get here if there was an error opening the file */
ofs->nErrCode = GetLastError();
diff --git a/dlls/kernel32/heap.c b/dlls/kernel32/heap.c
index 98552ca..76de0fa 100644
--- a/dlls/kernel32/heap.c
+++ b/dlls/kernel32/heap.c
@@ -1108,6 +1108,7 @@ BOOL WINAPI LocalUnlock(
return GlobalUnlock( (HGLOBAL)handle );
}
+#ifdef __i386__
/**********************************************************************
* AllocMappedBuffer (KERNEL32.38)
@@ -1182,6 +1183,8 @@ void WINAPI __regs_FreeMappedBuffer(
DEFINE_REGS_ENTRYPOINT( FreeMappedBuffer, 0, 0 )
#endif
+#endif /* __i386__ */
+
/***********************************************************************
* GlobalMemoryStatusEx (KERNEL32.@)
* A version of GlobalMemoryStatus that can deal with memory over 4GB
diff --git a/dlls/kernel32/instr.c b/dlls/kernel32/instr.c
index f9b99c8..b2cb8bd 100644
--- a/dlls/kernel32/instr.c
+++ b/dlls/kernel32/instr.c
@@ -38,6 +38,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(int);
WINE_DECLARE_DEBUG_CHANNEL(io);
+#ifdef __i386__
+
/* macros to set parts of a DWORD */
#define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
#define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
@@ -433,7 +435,7 @@ static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
* Emulate a privileged instruction.
* Returns exception continuation status.
*/
-DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT86 *context )
+DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context )
{
int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
BYTE *instr;
@@ -870,6 +872,21 @@ DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT86 *context )
return ExceptionContinueSearch; /* Unable to emulate it */
}
+#else /* __i386__ */
+
+/***********************************************************************
+ * __wine_emulate_instruction
+ *
+ * Emulate a privileged instruction.
+ * Returns exception continuation status.
+ */
+DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context )
+{
+ /* FIXME */
+ return ExceptionContinueSearch; /* Unable to emulate it */
+}
+
+#endif /* __i386__ */
/***********************************************************************
* INSTR_vectored_handler
@@ -880,7 +897,7 @@ DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT86 *context )
LONG CALLBACK INSTR_vectored_handler( EXCEPTION_POINTERS *ptrs )
{
EXCEPTION_RECORD *record = ptrs->ExceptionRecord;
- CONTEXT86 *context = ptrs->ContextRecord;
+ CONTEXT *context = ptrs->ContextRecord;
if (wine_ldt_is_system(context->SegCs) &&
(record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
diff --git a/dlls/kernel32/kernel_main.c b/dlls/kernel32/kernel_main.c
index 5e72cee..b01d075 100644
--- a/dlls/kernel32/kernel_main.c
+++ b/dlls/kernel32/kernel_main.c
@@ -51,11 +51,13 @@ extern int __wine_set_signal_handler(unsigned, int (*)(unsigned));
*/
static void thread_attach(void)
{
+#ifdef __i386__
/* allocate the 16-bit stack (FIXME: should be done lazily) */
HGLOBAL16 hstack = WOWGlobalAlloc16( GMEM_FIXED, 0x10000 );
kernel_get_thread_data()->stack_sel = GlobalHandleToSel16( hstack );
NtCurrentTeb()->WOW32Reserved = (void *)MAKESEGPTR( kernel_get_thread_data()->stack_sel,
0x10000 - sizeof(STACK16FRAME) );
+#endif /* __i386__ */
}
@@ -64,10 +66,12 @@ static void thread_attach(void)
*/
static void thread_detach(void)
{
+#ifdef __i386__
/* free the 16-bit stack */
WOWGlobalFree16( kernel_get_thread_data()->stack_sel );
NtCurrentTeb()->WOW32Reserved = 0;
if (NtCurrentTeb()->Tib.SubSystemTib) TASK_ExitTask();
+#endif /* __i386__ */
}
diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h
index dd7c916..30ebebd 100644
--- a/dlls/kernel32/kernel_private.h
+++ b/dlls/kernel32/kernel_private.h
@@ -79,7 +79,7 @@ extern void FILE_SetDosError(void);
extern WCHAR *FILE_name_AtoW( LPCSTR name, BOOL alloc );
extern DWORD FILE_name_WtoA( LPCWSTR src, INT srclen, LPSTR dest, INT destlen );
-extern DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT86 *context );
+extern DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context );
extern LONG CALLBACK INSTR_vectored_handler( EXCEPTION_POINTERS *ptrs );
extern void INSTR_CallBuiltinHandler( CONTEXT86 *context, BYTE intnum );
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 6e96eea..74593e5 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -1240,7 +1240,7 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len )
lang_id = MAKELANGID(PRIMARYLANGID(lang_id), SUBLANG_DEFAULT);
if (!(hrsrc = FindResourceExW( kernel32_handle, (LPWSTR)RT_STRING,
- (LPCWSTR)((lctype >> 4) + 1), lang_id )))
+ ULongToPtr((lctype >> 4) + 1), lang_id )))
{
SetLastError( ERROR_INVALID_FLAGS ); /* no such lctype */
return 0;
diff --git a/dlls/kernel32/lzexpand.c b/dlls/kernel32/lzexpand.c
index 904989b..b446736 100644
--- a/dlls/kernel32/lzexpand.c
+++ b/dlls/kernel32/lzexpand.c
@@ -499,8 +499,8 @@ LONG WINAPI LZCopy( HFILE src, HFILE dest )
/* Maintain the timestamp of source file to destination file */
srcfd = (!(lzs = GET_LZ_STATE(src))) ? src : lzs->realfd;
- GetFileTime((HANDLE)srcfd, NULL, NULL, &filetime);
- SetFileTime((HANDLE)dest, NULL, NULL, &filetime);
+ GetFileTime( LongToHandle(srcfd), NULL, NULL, &filetime );
+ SetFileTime( LongToHandle(dest), NULL, NULL, &filetime );
/* close handle */
if (usedlzinit)
@@ -583,7 +583,7 @@ void WINAPI LZClose( HFILE fd )
else
{
HeapFree( GetProcessHeap(), 0, lzs->get );
- CloseHandle((HANDLE)lzs->realfd);
+ CloseHandle( LongToHandle(lzs->realfd) );
lzstates[fd - LZ_MIN_HANDLE] = NULL;
HeapFree( GetProcessHeap(), 0, lzs );
}
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 036730f..1eaf195 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -1848,7 +1848,7 @@ HINSTANCE WINAPI LoadModule( LPCSTR name, LPVOID paramBlock )
if (!SearchPathA( NULL, name, ".exe", sizeof(filename), filename, NULL ) &&
!SearchPathA( NULL, name, NULL, sizeof(filename), filename, NULL ))
- return (HINSTANCE)GetLastError();
+ return ULongToHandle(GetLastError());
len = (BYTE)params->lpCmdLine[0];
if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, strlen(filename) + len + 2 )))
@@ -1879,7 +1879,7 @@ HINSTANCE WINAPI LoadModule( LPCSTR name, LPVOID paramBlock )
CloseHandle( info.hThread );
CloseHandle( info.hProcess );
}
- else if ((hInstance = (HINSTANCE)GetLastError()) >= (HINSTANCE)32)
+ else if ((hInstance = ULongToHandle(GetLastError())) >= (HINSTANCE)32)
{
FIXME("Strange error set by CreateProcess: %p\n", hInstance );
hInstance = (HINSTANCE)11;
@@ -2174,15 +2174,15 @@ DWORD WINAPI GetProcessDword( DWORD dwProcessID, INT offset )
case GPD_WINDOWS_VERSION:
return GetExeVersion16();
case GPD_THDB:
- return (DWORD)NtCurrentTeb() - 0x10 /* FIXME */;
+ return (DWORD_PTR)NtCurrentTeb() - 0x10 /* FIXME */;
case GPD_PDB:
- return (DWORD)NtCurrentTeb()->Peb;
+ return (DWORD_PTR)NtCurrentTeb()->Peb; /* FIXME: truncating a pointer */
case GPD_STARTF_SHELLDATA: /* return stdoutput handle from startupinfo ??? */
GetStartupInfoW(&siw);
- return (DWORD)siw.hStdOutput;
+ return HandleToULong(siw.hStdOutput);
case GPD_STARTF_HOTKEY: /* return stdinput handle from startupinfo ??? */
GetStartupInfoW(&siw);
- return (DWORD)siw.hStdInput;
+ return HandleToULong(siw.hStdInput);
case GPD_STARTF_SHOWWINDOW:
GetStartupInfoW(&siw);
return siw.wShowWindow;
@@ -2289,7 +2289,7 @@ HANDLE WINAPI OpenProcess( DWORD access, BOOL inherit, DWORD id )
OBJECT_ATTRIBUTES attr;
CLIENT_ID cid;
- cid.UniqueProcess = (HANDLE)id;
+ cid.UniqueProcess = ULongToHandle(id);
cid.UniqueThread = 0; /* FIXME ? */
attr.Length = sizeof(OBJECT_ATTRIBUTES);
@@ -2363,7 +2363,7 @@ BOOL WINAPI CloseHandle( HANDLE handle )
if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
(handle == (HANDLE)STD_OUTPUT_HANDLE) ||
(handle == (HANDLE)STD_ERROR_HANDLE))
- handle = GetStdHandle( (DWORD)handle );
+ handle = GetStdHandle( HandleToULong(handle) );
if (is_console_handle(handle))
return CloseConsoleHandle(handle);
diff --git a/dlls/kernel32/pthread.c b/dlls/kernel32/pthread.c
index 38d3f6d..dcb0863 100644
--- a/dlls/kernel32/pthread.c
+++ b/dlls/kernel32/pthread.c
@@ -82,7 +82,7 @@ static DWORD CALLBACK pthread_thread_start(LPVOID data)
{
struct pthread_thread_init init = *(struct pthread_thread_init*)data;
HeapFree(GetProcessHeap(),0,data);
- return (DWORD)init.start_routine(init.arg);
+ return (DWORD_PTR)init.start_routine(init.arg);
}
static int wine_pthread_create(pthread_t* thread, const pthread_attr_t* attr, void*
@@ -193,7 +193,7 @@ static int wine_pthread_mutex_unlock(pthread_mutex_t *mutex)
CRITICAL_SECTION *crit = ((wine_mutex)mutex)->critsect;
if (!crit) return 0;
- if (crit->OwningThread != (HANDLE)GetCurrentThreadId()) return EPERM;
+ if (crit->OwningThread != ULongToHandle(GetCurrentThreadId())) return EPERM;
RtlLeaveCriticalSection( crit );
return 0;
}
@@ -526,7 +526,7 @@ static int wine_pthread_equal(pthread_t thread1, pthread_t thread2)
static void wine_pthread_exit(void *retval, char *currentframe)
{
- ExitThread((DWORD)retval);
+ ExitThread((DWORD_PTR)retval);
}
static void *wine_get_thread_data(void)
diff --git a/dlls/kernel32/resource.c b/dlls/kernel32/resource.c
index 66e8adc..096a550 100644
--- a/dlls/kernel32/resource.c
+++ b/dlls/kernel32/resource.c
@@ -60,7 +60,7 @@ static NTSTATUS get_res_nameA( LPCSTR name, UNICODE_STRING *str )
ULONG value;
if (RtlCharToInteger( name + 1, 10, &value ) != STATUS_SUCCESS || HIWORD(value))
return STATUS_INVALID_PARAMETER;
- str->Buffer = (LPWSTR)value;
+ str->Buffer = ULongToPtr(value);
return STATUS_SUCCESS;
}
RtlCreateUnicodeStringFromAsciiz( str, name );
@@ -82,7 +82,7 @@ static NTSTATUS get_res_nameW( LPCWSTR name, UNICODE_STRING *str )
RtlInitUnicodeString( str, name + 1 );
if (RtlUnicodeStringToInteger( str, 10, &value ) != STATUS_SUCCESS || HIWORD(value))
return STATUS_INVALID_PARAMETER;
- str->Buffer = (LPWSTR)value;
+ str->Buffer = ULongToPtr(value);
return STATUS_SUCCESS;
}
RtlCreateUnicodeString( str, name );
@@ -288,7 +288,7 @@ BOOL WINAPI EnumResourceTypesA( HMODULE hmod, ENUMRESTYPEPROCA lpfun, LONG_PTR l
}
else
{
- ret = lpfun( hmod, (LPSTR)(int)et[i].u1.s2.Id, lparam );
+ ret = lpfun( hmod, UIntToPtr(et[i].u1.s2.Id), lparam );
}
if (!ret) break;
}
@@ -337,7 +337,7 @@ BOOL WINAPI EnumResourceTypesW( HMODULE hmod, ENUMRESTYPEPROCW lpfun, LONG_PTR l
}
else
{
- ret = lpfun( hmod, (LPWSTR)(int)et[i].u1.s2.Id, lparam );
+ ret = lpfun( hmod, UIntToPtr(et[i].u1.s2.Id), lparam );
}
if (!ret) break;
}
@@ -370,7 +370,7 @@ BOOL WINAPI EnumResourceNamesA( HMODULE hmod, LPCSTR type, ENUMRESNAMEPROCA lpfu
goto done;
if ((status = get_res_nameA( type, &typeW )) != STATUS_SUCCESS)
goto done;
- info.Type = (ULONG)typeW.Buffer;
+ info.Type = (ULONG_PTR)typeW.Buffer;
if ((status = LdrFindResourceDirectory_U( hmod, &info, 1, &resdir )) != STATUS_SUCCESS)
goto done;
@@ -397,7 +397,7 @@ BOOL WINAPI EnumResourceNamesA( HMODULE hmod, LPCSTR type, ENUMRESNAMEPROCA lpfu
}
else
{
- ret = lpfun( hmod, type, (LPSTR)(int)et[i].u1.s2.Id, lparam );
+ ret = lpfun( hmod, type, UIntToPtr(et[i].u1.s2.Id), lparam );
}
if (!ret) break;
}
@@ -432,7 +432,7 @@ BOOL WINAPI EnumResourceNamesW( HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpf
goto done;
if ((status = get_res_nameW( type, &typeW )) != STATUS_SUCCESS)
goto done;
- info.Type = (ULONG)typeW.Buffer;
+ info.Type = (ULONG_PTR)typeW.Buffer;
if ((status = LdrFindResourceDirectory_U( hmod, &info, 1, &resdir )) != STATUS_SUCCESS)
goto done;
@@ -458,7 +458,7 @@ BOOL WINAPI EnumResourceNamesW( HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpf
}
else
{
- ret = lpfun( hmod, type, (LPWSTR)(int)et[i].u1.s2.Id, lparam );
+ ret = lpfun( hmod, type, UIntToPtr(et[i].u1.s2.Id), lparam );
}
if (!ret) break;
}
@@ -979,7 +979,7 @@ static LPWSTR resource_dup_string( const IMAGE_RESOURCE_DIRECTORY *root, const I
LPWSTR s;
if (!entry->u1.s1.NameIsString)
- return (LPWSTR) (DWORD) entry->u1.s2.Id;
+ return UIntToPtr(entry->u1.s2.Id);
string = (const IMAGE_RESOURCE_DIR_STRING_U*) (((const char *)root) + entry->u1.s1.NameOffset);
s = HeapAlloc(GetProcessHeap(), 0, (string->Length + 1)*sizeof (WCHAR) );
diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index 2674764..ff987c3 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -170,7 +170,7 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
if ((handles[i] == (HANDLE)STD_INPUT_HANDLE) ||
(handles[i] == (HANDLE)STD_OUTPUT_HANDLE) ||
(handles[i] == (HANDLE)STD_ERROR_HANDLE))
- hloc[i] = GetStdHandle( (DWORD)handles[i] );
+ hloc[i] = GetStdHandle( HandleToULong(handles[i]) );
else
hloc[i] = handles[i];
@@ -1168,7 +1168,7 @@ HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
pipe_type = (dwPipeMode & PIPE_TYPE_MESSAGE) ? TRUE : FALSE;
read_mode = (dwPipeMode & PIPE_READMODE_MESSAGE) ? TRUE : FALSE;
non_block = (dwPipeMode & PIPE_NOWAIT) ? TRUE : FALSE;
- if (nMaxInstances >= PIPE_UNLIMITED_INSTANCES) nMaxInstances = ~0UL;
+ if (nMaxInstances >= PIPE_UNLIMITED_INSTANCES) nMaxInstances = ~0U;
timeout.QuadPart = (ULONGLONG)nDefaultTimeOut * -10000;
diff --git a/dlls/kernel32/syslevel.c b/dlls/kernel32/syslevel.c
index 8ffc3d2..46fdf9a 100644
--- a/dlls/kernel32/syslevel.c
+++ b/dlls/kernel32/syslevel.c
@@ -157,7 +157,7 @@ VOID WINAPI _KERNEL32_86(SYSLEVEL *lock)
*/
DWORD WINAPI _ConfirmSysLevel(SYSLEVEL *lock)
{
- if ( lock && lock->crst.OwningThread == (HANDLE)GetCurrentThreadId() )
+ if ( lock && lock->crst.OwningThread == ULongToHandle(GetCurrentThreadId()) )
return lock->crst.RecursionCount;
else
return 0L;
@@ -169,7 +169,7 @@ DWORD WINAPI _ConfirmSysLevel(SYSLEVEL *lock)
*/
VOID WINAPI _CheckNotSysLevel(SYSLEVEL *lock)
{
- if (lock && lock->crst.OwningThread == (HANDLE)GetCurrentThreadId() &&
+ if (lock && lock->crst.OwningThread == ULongToHandle(GetCurrentThreadId()) &&
lock->crst.RecursionCount)
{
ERR( "Holding lock %p level %d\n", lock, lock->level );
diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c
index b91810f..27fe5e2 100644
--- a/dlls/kernel32/thread.c
+++ b/dlls/kernel32/thread.c
@@ -92,7 +92,7 @@ HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE
(PRTL_THREAD_START_ROUTINE)start, param, &handle, &client_id );
if (status == STATUS_SUCCESS)
{
- if (id) *id = (DWORD)client_id.UniqueThread;
+ if (id) *id = HandleToULong(client_id.UniqueThread);
if (sa && (sa->nLength >= sizeof(*sa)) && sa->bInheritHandle)
SetHandleInformation( handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT );
if (!(flags & CREATE_SUSPENDED))
@@ -133,7 +133,7 @@ HANDLE WINAPI OpenThread( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwTh
attr.SecurityQualityOfService = NULL;
cid.UniqueProcess = 0; /* FIXME */
- cid.UniqueThread = (HANDLE)dwThreadId;
+ cid.UniqueThread = ULongToHandle(dwThreadId);
status = NtOpenThread( &handle, dwDesiredAccess, &attr, &cid );
if (status)
{
@@ -621,7 +621,7 @@ DWORD WINAPI GetLastError(void)
*/
DWORD WINAPI GetCurrentProcessId(void)
{
- return (DWORD)NtCurrentTeb()->ClientId.UniqueProcess;
+ return HandleToULong(NtCurrentTeb()->ClientId.UniqueProcess);
}
/***********************************************************************
@@ -635,7 +635,7 @@ DWORD WINAPI GetCurrentProcessId(void)
*/
DWORD WINAPI GetCurrentThreadId(void)
{
- return (DWORD)NtCurrentTeb()->ClientId.UniqueThread;
+ return HandleToULong(NtCurrentTeb()->ClientId.UniqueThread);
}
#endif /* __i386__ */
--
1.5.1.6
More information about the wine-patches
mailing list