-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0166e7c
commit 8a74390
Showing
7 changed files
with
103 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use super::Protections; | ||
use std::ptr::null_mut; | ||
|
||
/// Contains information about the stack of the application main thread. | ||
#[derive(Debug)] | ||
pub struct AppStack { | ||
guard: *mut u8, | ||
stack: *mut u8, | ||
len: usize, | ||
prot: Protections, | ||
} | ||
|
||
impl AppStack { | ||
pub(super) fn new() -> Self { | ||
Self { | ||
guard: null_mut(), | ||
stack: null_mut(), | ||
len: 0x200000, | ||
prot: Protections::CPU_READ | Protections::CPU_WRITE, | ||
} | ||
} | ||
|
||
pub fn guard(&self) -> usize { | ||
self.guard as _ | ||
} | ||
|
||
pub fn start(&self) -> *mut u8 { | ||
self.stack | ||
} | ||
|
||
pub fn end(&self) -> *const u8 { | ||
unsafe { self.stack.add(self.len) } | ||
} | ||
|
||
pub fn len(&self) -> usize { | ||
self.len | ||
} | ||
|
||
pub fn prot(&self) -> Protections { | ||
self.prot | ||
} | ||
|
||
pub(super) fn set_guard(&mut self, v: *mut u8) { | ||
self.guard = v; | ||
} | ||
|
||
pub(super) fn set_stack(&mut self, v: *mut u8) { | ||
self.stack = v; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters