internal IntPtr FindFirst(string path, ref WIN32_FIND_DATA_ANSI findData) { try { // Find directory in virtual filesystem representing %path. var entryForPath = VirtualFilesystemUtils.TryFindFilesystemEntry(path, m_Plugin.GetRootDirectoryEntry()); if (entryForPath is DirectoryEntryBase directoryEntryForPath) { var enumeration = directoryEntryForPath.EnumerateChildFilesystemEntries(); if (enumeration != null) { var enumerator = enumeration.GetEnumerator(); if (enumerator != null && enumerator.MoveNext()) { findData = enumerator.Current.ToFindDataAnsi(); return(m_EnumerationsManager.Add(enumerator)); } } // Directory is empty Kernel32Functions.SetLastError(ErrorCodes.ERROR_NO_MORE_FILES); return(Handles.INVALID_HANDLE_VALUE); } // Path does not exists or is not directory Kernel32Functions.SetLastError(ErrorCodes.ERROR_PATH_NOT_FOUND); return(Handles.INVALID_HANDLE_VALUE); } catch { Kernel32Functions.SetLastError(ErrorCodes.ERROR_INVALID_FUNCTION); return(Handles.INVALID_HANDLE_VALUE); } }
public Applications(int processID) { IntPtr handle = Kernel32Functions.OpenProcess(0x400 | 0x010, false, Convert.ToUInt32(processID)); if (handle != IntPtr.Zero && handle != null) { this.process.Add(new Process(handle)); } else { throw new ProcessNotFoundException(ErrorMessages.CouldNotFindPid); } }