Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// If I didn't select the entry or the time of the event was
// before the process was removed
//
if( ret == NULL ) {
//
// Only if time makes sense, else we will select a wrong old entry
// and the latest will be skipped
//
if( (current.removedTime.QuadPart == 0 || // If the current entry is still open
(ULONG64)time->QuadPart < (ULONG64)(current.removedTime.QuadPart + NT_500_MS)) && // Or it has now terminated but terminated after the process creation time
// the half second buffer is because we have seen network events appear marginally later than the process terminate event
(time->QuadPart >= current.data->m_CreateTime.QuadPart) ) { // #444. We validate the end of the time window but not the start..
ret = ¤t;
}
} elseif( current.removedTime.QuadPart != 0 && // The process has terminadumpted
(ULONG64)time->QuadPart < (ULONG64)current.removedTime.QuadPart && // The process terminated after our process creation time
time->QuadPart >= current.data->m_CreateTime.QuadPart && // #444 Validate the start of the time window too
(ret->removedTime.QuadPart == 0 || // we are either superseding a candidate that is still open
(ULONG64)ret->removedTime.QuadPart > ( ULONG64 )current.removedTime.QuadPart) ) { // or we are superseding a process with a wider windows than the current candidate