Changeset 2332 for trunk/eraser


Ignore:
Timestamp:
10/30/2011 1:17:46 AM (3 years ago)
Author:
lowjoel
Message:

Behaviour change: DuplicateHandle? when not provided a handle pointer to clone the source handle to will leak handles from Windows 7 onwards. Prevent that (and restore locked file erasure functionality)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.Util.Native/OpenHandle.cpp

    r2149 r2332  
    9494    { 
    9595        //Open a handle to the owning process 
    96         HANDLE processHandle = OpenProcess(PROCESS_DUP_HANDLE, false, processId); 
     96        HANDLE processHandle = OpenProcess(PROCESS_DUP_HANDLE, false, ProcessId); 
    9797 
    9898        //Forcibly close the handle 
     99        HANDLE duplicateHandle = NULL; 
    99100        DuplicateHandle(processHandle, static_cast<void*>(Handle), GetCurrentProcess(), 
    100             NULL, 0, false, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); 
     101            &duplicateHandle, 0, false, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); 
     102        CloseHandle(duplicateHandle); 
    101103 
    102104        //Check if the handle is closed 
    103105        bool result = true; 
    104         HANDLE duplicateHandle = NULL; 
    105106        if (DuplicateHandle(processHandle, static_cast<void*>(Handle), GetCurrentProcess(), 
    106107            &duplicateHandle, 0, false, DUPLICATE_SAME_ACCESS)) 
Note: See TracChangeset for help on using the changeset viewer.