File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,6 +106,20 @@ DLLEXPORT void WINAPI GetCurrentVFSName(char *buffer, size_t size);
106106 */
107107DLLEXPORT BOOL WINAPI GetVFSProcessList (size_t * count , LPDWORD processIDs );
108108
109+ // retrieve a list of all processes connected to the vfs, stores an array
110+ // of `count` elements in `*buffer`
111+ //
112+ // if this returns TRUE and `count` is not 0, the caller must release the buffer
113+ // with `free(*buffer)`
114+ //
115+ // return values:
116+ // - ERROR_INVALID_PARAMETERS: either `count` or `buffer` is NULL
117+ // - ERROR_TOO_MANY_OPEN_FILES: there seems to be way too many usvfs processes
118+ // running, probably some internal error
119+ // - ERROR_NOT_ENOUGH_MEMORY: malloc() failed
120+ //
121+ DLLEXPORT BOOL WINAPI GetVFSProcessList2 (size_t * count , DWORD * * buffer );
122+
109123/**
110124 * spawn a new process that can see the virtual file system. The signature is identical to CreateProcess
111125 */
Original file line number Diff line number Diff line change @@ -532,6 +532,35 @@ BOOL WINAPI GetVFSProcessList(size_t *count, LPDWORD processIDs)
532532 return TRUE ;
533533}
534534
535+ BOOL WINAPI GetVFSProcessList2 (size_t * count, DWORD ** buffer)
536+ {
537+ if (!count || !buffer) {
538+ SetLastError (ERROR_INVALID_PARAMETER );
539+ return FALSE ;
540+ }
541+
542+ *count = 0 ;
543+ *buffer = nullptr ;
544+
545+ std::vector<DWORD > pids = context->registeredProcesses ();
546+ auto last = std::remove_if (pids.begin (), pids.end (), [](DWORD id) {
547+ return !processStillActive (id);
548+ });
549+
550+ pids.erase (last, pids.end ());
551+
552+ if (pids.empty ()) {
553+ return TRUE ;
554+ }
555+
556+ *count = pids.size ();
557+ *buffer = static_cast <DWORD *>(std::calloc (pids.size (), sizeof (DWORD )));
558+
559+ std::copy (pids.begin (), pids.end (), *buffer);
560+
561+ return TRUE ;
562+ }
563+
535564void WINAPI ClearVirtualMappings ()
536565{
537566 context->redirectionTable ()->clear ();
You can’t perform that action at this time.
0 commit comments