Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Noitidart/adc89a92713c9c635dad to your computer and use it in GitHub Desktop.
Save Noitidart/adc89a92713c9c635dad to your computer and use it in GitHub Desktop.
pre-/paralell-cursor to _ff-addon-snippet-WINAPI_EnumHandlesAndReadFilePaths
//See the code at here: https://gist.github.com/Noitidart/d752e2c59793fa2cab3c
@Noitidart
Copy link
Author

README

Learned that must feed duplicated handle to GetFinalPathByHandles as well, not just for NtQueryInformationFile. Learned this by passing duped handle to Nt and non-duped to GetFinal and GetFinal returned wrong path while Nt returend right one. When passed duped to both, then both correct.

GetFinalPathByHandles makes it take on average of 580ms. NtQueryInformationFile makes it take average of 280ms.

Rev1

  • Duplicate handle is failing if use GetCurrentProcess() but that's the way it should be done
    • If use OpenProcess on currentProcessId instead of GetCurrentProcess() the handle duplicates but the NtQueryInformationFile and GetFinalPathByHandles returns wrong path names

Rev2

  • Duplicate handle now works with GetCurrentProcess(), i changed from using unsigned_short everywhere to using voidptr_t. Except output of handle_entry_info, but i wrap that output ushort with voidptr_t.

Rev3

  • Succesfully reads paths from other PIDs now, the problem was my stupid logic I was testing if rez was not 0 for handles of the current pid, duhhhhhhhhh

Rev4

  • Updated file and gist name to include WINAPI_

Rev5

  • Renamed this to be precusor/parallelCursor to final work over HERE
  • But not deleting this Gist as it has some extensive readme notes which indicates there was learning through the revisions

Rev6

  • Because the code was the same as the code over at the TryingToFigureOut which I renamed to EnumHandlesAndGetPaths MINUS the work where I tested on the Win8.1 with low privelages and the uintptr_t fix I just edited out this code. The only reason I'm leaving this is for me to look through the revisions and notes with them for learning which it looks like I did through it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment