Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Android, macOS M1 & FreeBSD #6

Merged
merged 23 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1a21196
Cleanup use/import statements for different OSes, change 'mac+linux' …
Sewer56 Sep 8, 2023
f74dbee
Added: mmap-rs based implementation of memory allocation
Sewer56 Sep 9, 2023
01dda59
Added: Attempt at Android
Sewer56 Sep 9, 2023
00712bd
Added: Extra Platform Support Note for Rust
Sewer56 Sep 9, 2023
0435a61
Added: Ability to clear instruction cache
Sewer56 Sep 9, 2023
8a6b179
Added: Execute test for Aarch64
Sewer56 Sep 9, 2023
a1c3e4e
Omit open_unix for macOS
Sewer56 Sep 9, 2023
b715d83
Added: Enable CI for current branch
Sewer56 Sep 9, 2023
9bbdc8c
Fixed: Broken Windows Build
Sewer56 Sep 9, 2023
fbe9034
Changed: LocatorHeader doesn't need to have execute permission
Sewer56 Sep 9, 2023
f9ad8b5
Use package that exports GCC/Clang Cache Clear & Disable for X86, Bum…
Sewer56 Sep 10, 2023
c84bb14
Apple lies about page size on macOS M1, don't let them get away with it.
Sewer56 Sep 10, 2023
10a214f
Added: Initialize Remaining Space as Extra Headers in W^X environments.
Sewer56 Sep 10, 2023
916090f
Added: Functionality to dynamically toggle W^X as well as APIs to saf…
Sewer56 Sep 10, 2023
3f76b7d
Don't Build clf on Windows
Sewer56 Sep 10, 2023
061f415
Updated: Documentation for new features
Sewer56 Sep 10, 2023
30cf711
Fixed: Off by one error
Sewer56 Sep 11, 2023
596e88e
Added: Remaining W^X fixes for M1 macOS
Sewer56 Sep 11, 2023
6bd39f8
Changed: Don't check for Null when Not Needed
Sewer56 Nov 24, 2023
aea5052
Changed: To mmap-rs fork
Sewer56 Nov 25, 2023
67267f9
Changed: icache should only be cleared once code becomes executable a…
Sewer56 Nov 25, 2023
f390414
I will assume I screwed this before committing, and will promptly (ju…
Sewer56 Nov 25, 2023
852e26d
Added: mmap_rs fork integration for Android, freebsd
Sewer56 Nov 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: C# Build, Test and Publish
on:
push:
branches: [ master, refactor-reloaded3-compliance ]
branches: [ master, refactor-reloaded3-compliance, support-android-and-bsd ]
tags:
- '*'
pull_request:
branches: [ master, refactor-reloaded3-compliance ]
branches: [ master, refactor-reloaded3-compliance, support-android-and-bsd ]
workflow_dispatch:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Rust Build, Test & Publish

on:
push:
branches: [ main, master, crab ]
branches: [ main, master, crab, support-android-and-bsd ]
tags:
- '*'
pull_request:
branches: [ main, master, crab ]
branches: [ main, master, crab, support-android-and-bsd ]
workflow_dispatch:

jobs:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ With the following properties:
- ***Large Address Aware:*** On Windows, the library can correctly leverage all 4GB in 32-bit processes.
- ***Cross Platform***: Supports Windows, OSX and Linux.

Note: Rust/C port also work with FreeBSD (untested), and has partial [(limited) Android support](https://github.com/Reloaded-Project/Reloaded.Memory.Buffers/issues/3).

## Wiki & Documentation

[For full documentation, please see the Wiki](https://reloaded-project.github.io/Reloaded.Memory.Buffers/).
Expand Down
31 changes: 30 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ With the following properties:
- ***Large Address Aware:*** On Windows, the library can correctly leverage all 4GB in 32-bit processes.
- ***Cross Platform***: Supports Windows, OSX and Linux.

Note: Rust/C port also works with FreeBSD (untested), and has partial [(limited) Android support](https://github.com/Reloaded-Project/Reloaded.Memory.Buffers/issues/3).

## Example Use Cases

!!! tip "These are just examples."
Expand Down Expand Up @@ -161,11 +163,12 @@ With the following properties:
free_get_buffer_result(result);
```

!!! note "Use `append_code` instead of `append_bytes` if you need to add executable code. (Currently unavailable in C# port)"

### Allocate Memory

!!! info "Allows you to temporarily allocate memory within a specific address range and size constraints."


=== "C#"

```csharp
Expand Down Expand Up @@ -215,6 +218,32 @@ With the following properties:

!!! note "You can specify another process with `TargetProcess = someProcess` in `BufferAllocatorSettings`, but this is only supported on Windows."

### Overwriting Allocated Instructions

!!! info "On non-x86 architectures, some extra actions may be needed when overwriting executable code allocated with `append_code`."

!!! note "This involves clearing instruction cache, and abiding by Write XOR Execute restrictions."

=== "Rust"

```rust
Self::overwrite_allocated_code(address, size, |addr, size| {
// Do stuff with executable code
});
```

=== "C/C++"

```cpp
void do_stuff_with_executable_code(char* addr, size_t size) {
// Modify executable code in buffer
}

overwrite_allocated_code(address, size, do_stuff_with_executable_code);
```

!!! warning "Not currently available in C# version. Submit an issue request or PR if you need this."

## Community Feedback

If you have questions/bug reports/etc. feel free to [Open an Issue](https://github.com/Reloaded-Project/Reloaded.Memory.Buffers/issues/new).
Expand Down
145 changes: 132 additions & 13 deletions src-rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading