Skip to content

Instantly share code, notes, and snippets.

@dalehamel
Created July 26, 2021 14:08
Show Gist options
  • Save dalehamel/7c501ad0d44079a5a267653e395a8b00 to your computer and use it in GitHub Desktop.
Save dalehamel/7c501ad0d44079a5a267653e395a8b00 to your computer and use it in GitHub Desktop.
Test rbspy patch
---
src/core/initialize.rs | 17 +++++++++++++++++
src/main.rs | 4 ++++
2 files changed, 21 insertions(+)
diff --git a/src/core/initialize.rs b/src/core/initialize.rs
index c6bed8b..2ea1b2e 100644
--- a/src/core/initialize.rs
+++ b/src/core/initialize.rs
@@ -92,10 +92,18 @@ impl StackTraceGetter {
Ok(remoteprocess::Error::IOError(e)) => {
match e.kind() {
std::io::ErrorKind::NotFound => {
+ match Process::new(self.process.pid) {
+ Ok(_) => debug!("FIRST BLOCK Process {} is alive", self.process.pid),
+ Err(e) => debug!("FIRST BLOCK Process {} is not alive: {:?}", self.process.pid, e),
+ }
return Err(MemoryCopyError::ProcessEnded)
}
#[cfg(target_os = "windows")]
std::io::ErrorKind::PermissionDenied => {
+ match Process::new(self.process.pid) {
+ Ok(_) => debug!("WINDOWS BLOCK Process {} is alive", self.process.pid),
+ Err(e) => debug!("WINDOWS BLOCK Process {} is not alive: {:?}", self.process.pid, e),
+ }
return Err(MemoryCopyError::ProcessEnded)
}
_ => {}
@@ -104,6 +112,10 @@ impl StackTraceGetter {
#[cfg(target_os = "linux")]
Ok(remoteprocess::Error::NixError(e)) => match e {
nix::Error::Sys(nix::errno::Errno::EPERM) => {
+ match Process::new(self.process.pid) {
+ Ok(_) => debug!("SECOND BLOCK Process {} is alive", self.process.pid),
+ Err(e) => debug!("SECOND BLOCK Process {} is not alive: {:?}", self.process.pid, e),
+ }
return Err(MemoryCopyError::ProcessEnded);
}
_ => {}
@@ -112,6 +124,11 @@ impl StackTraceGetter {
}
}
+ match Process::new(self.process.pid) {
+ Ok(_) => debug!("OUTER BLOCK Process {} is alive", self.process.pid),
+ Err(e) => debug!("OUTER BLOCK Process {} is not alive: {:?}", self.process.pid, e),
+ }
+
Err(e.into())
})?;
}
diff --git a/src/main.rs b/src/main.rs
index e4d5b5a..93b1831 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -701,6 +701,10 @@ fn record(
Err(x) => {
if let Some(MemoryCopyError::ProcessEnded) = x.downcast_ref() {
debug!("Process {} ended", pid);
+ match Process::new(pid) {
+ Ok(_) => debug!("Process {} is alive", pid),
+ Err(e) => debug!("Process {} is not alive: {:?}", pid, e),
+ }
return Ok(());
}
--
2.26.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment