From c0bd29170fa3a71a9856e0a2cd75f4ad0b3854c2 Mon Sep 17 00:00:00 2001 From: midipix Date: Sep 26 2015 15:19:26 +0000 Subject: __ntapi_tt_sync_block_unlock(): construct the 64-bit comparison value by way of a union. --- diff --git a/src/sync/ntapi_tt_sync_block.c b/src/sync/ntapi_tt_sync_block.c index e52dd77..b28d56e 100644 --- a/src/sync/ntapi_tt_sync_block.c +++ b/src/sync/ntapi_tt_sync_block.c @@ -219,17 +219,20 @@ int32_t __stdcall __ntapi_tt_sync_block_server_lock( int32_t __stdcall __ntapi_tt_sync_block_unlock( __in nt_sync_block * sync_block) { - int64_t cmp; + union { + int64_t i64; + nt_large_integer nti64; + } cmp; if (sync_block->invalid) return NT_STATUS_INVALID_HANDLE; - cmp = (int64_t)(pe_get_current_process_id()) << 32; - cmp += pe_get_current_thread_id(); + cmp.nti64.ihigh = pe_get_current_process_id(); + cmp.nti64.ulow = pe_get_current_thread_id(); - if (cmp != at_locked_cas_64( + if (cmp.i64 != at_locked_cas_64( (int64_t *)&sync_block->tid, - cmp,0)) + cmp.i64,0)) return NT_STATUS_RESOURCE_NOT_OWNED; return NT_STATUS_SUCCESS;