xor esi, esi
xchg [hTimeOut], esi
VMMCall Cancel_Time_Out
If this code is executed twice by mistake, the second time will not cause any harm. Note, however, that there is still an opportunity for a race condition to occur between the xchg instruction and the call to the Cancel_Time_Out service. To be extra sure that you don't cancel the wrong timeout by mistake, put the routine in locked code. If the timeout being cancelled is an asynchronous timeout, you also need to disable interrupts.