Beispiel #1
0
        private List <string> SniffFileHandles()
        {
            //Build a list of all song files being accessed
            List <string> songFiles = new List <string>();

            //Get all handles from the rocksmith process
            var handles = CustomAPI.GetHandles(rsProcess);

            //If there aren't any handles, return
            if (handles == null)
            {
                return(null);
            }

            var         strTemp = "";
            FileDetails fd      = null;

            //Go through all the handles
            for (int i = 0; i < handles.Count; i++)
            {
                //Read the filename from the file handle
                try
                {
                    fd = FileDetails.GetFileDetails(rsProcess.Handle, handles[i]);
                }
                catch (Exception e)
                {
                    continue;
                }

                //If getting file details failed for this handle, skip it
                if (fd == null)
                {
                    continue;
                }

                strTemp = fd.Name;

                //Add songs.psarc
                if (strTemp.EndsWith("songs.psarc"))
                {
                    songFiles.Add(strTemp);
                }

                //Check if it matches the dlc pattern
                if (dlcPSARCMatcher.IsMatch(strTemp))
                {
                    //Add dlc files
                    songFiles.Add(strTemp);
                }
            }

            return(songFiles);
        }
Beispiel #2
0
        private List <string> SniffFileHandles()
        {
            //Build a list of all song files being accessed
            List <string>      songFiles = new List <string>();
            List <FileDetails> fds       = new List <FileDetails>();

            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.MacOSX:
            case PlatformID.Unix:
                int    numPath      = 0;
                IntPtr pathPointers = MacOSAPI.proc_pidinfo_wrapper(memReader.PInfo.PID, out numPath);
                //Logger.Log("Num Paths: " + numPath);
                IntPtr[] pIntPtrArray       = new IntPtr[numPath];
                var      ManagedStringArray = new string[numPath];

                Marshal.Copy(pathPointers, pIntPtrArray, 0, numPath);

                for (int i = 0; i < numPath; i++)
                {
                    ManagedStringArray[i] = Marshal.PtrToStringAnsi(pIntPtrArray[i]);
                    fds.Add(new FileDetails()
                    {
                        Name = ManagedStringArray[i]
                    });
                }
                MacOSAPI.free_wrapper(pathPointers);
                break;

            default:
                //Get all handles from the rocksmith process
                var handles = CustomAPI.GetHandles(rsProcess);

                //If there aren't any handles, return
                if (handles == null)
                {
                    return(null);
                }
                for (int i = 0; i < handles.Count; i++)
                {
                    //Read the filename from the file handle
                    try
                    {
                        var fd = FileDetails.GetFileDetails(rsProcess.Handle, handles[i]);
                        fds.Add(fd);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }

                break;
            }

            var strTemp = "";

            //Go through all the handles
            for (int i = 0; i < fds.Count; i++)
            {
                FileDetails fd = fds[i];
                //If getting file details failed for this handle, skip it
                if (fd == null)
                {
                    continue;
                }

                strTemp = fd.Name;

                //Add songs.psarc
                if (strTemp.EndsWith("songs.psarc"))
                {
                    songFiles.Add(strTemp);
                }

                //Check if it matches the dlc pattern
                if (dlcPSARCMatcher.IsMatch(strTemp))
                {
                    //Add dlc files
                    songFiles.Add(strTemp);
                }
            }

            return(songFiles);
        }