public RSMemoryReader(Process rsProcess) { this.PInfo.rsProcess = rsProcess; this.PInfo.rsProcessHandle = rsProcess.Handle; this.PInfo.PID = (ulong)rsProcess.Id; switch (Environment.OSVersion.Platform) { case PlatformID.Unix: case PlatformID.MacOSX: MacOSAPI.task_for_pid_wrapper(this.PInfo.PID, out this.PInfo.Task); break; } }
private IntPtr FollowPointers(int entryAddress, int[] offsets) { //Get base address IntPtr baseAddress = IntPtr.Zero; switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: case PlatformID.Unix: if (Offset == 0) { int ret = MacOSAPI.find_main_binary_wrapper(PInfo.PID, out Offset); if (ret != 0) { Logger.Log("Unable to find address of Rocksmith2014, try running with sudo"); System.Environment.Exit(ret); } } baseAddress = (IntPtr)Offset; break; default: baseAddress = PInfo.rsProcess.MainModule.BaseAddress; break; } //Add entry address IntPtr finalAddress = IntPtr.Add(baseAddress, entryAddress); //Add offsets foreach (int offset in offsets) { finalAddress = MemoryHelper.FollowPointer(PInfo, finalAddress, offset); //If any of the offsets points to 0, return zero if (finalAddress.ToInt32() == offset) { return IntPtr.Zero; } } //Return the final address return finalAddress; }
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); }