https://github.com/henryquan/memorysafe
A naive approach to provide some protections to memory values
https://github.com/henryquan/memorysafe
cpp memory safety
Last synced: about 1 month ago
JSON representation
A naive approach to provide some protections to memory values
- Host: GitHub
- URL: https://github.com/henryquan/memorysafe
- Owner: HenryQuan
- License: mit
- Created: 2022-12-18T12:18:32.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-25T11:41:55.000Z (over 3 years ago)
- Last Synced: 2025-12-26T19:36:11.130Z (6 months ago)
- Topics: cpp, memory, safety
- Language: C++
- Homepage:
- Size: 70.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Memory Safe
A naive approach to provide some protections to memory values.
## Introduction
Back in 2012, the golden age of iOS games, many games appeared on AppStore. Many games are offline and local. It took only 20 minutes to mod one to have unlimited in-game currencies. There was zero protection for critical values, and they were a quick memory search away. The way how it worked was by changing the value to locate the memory address.
A year or so later, games were more protected because memory search wouldn't work anymore. I couldn't understand the reason beyond.
## The Solution
My guess is that games did a simple trick to swap values between two different addresses, effectively make the memory search useless.
## Demo

The demo showcases how `MemorySafe` could protect critical values. Both `safe_value` and `unsafe_value` are 10 by default. They will update to 20 and 120 after user input. However, `unsafe_value` could be modified by Cheat Engine half way to 2000 in the demo. On the other hand, `safe_value` could not be found easily.

## Afterword
This solution is not perfect. `safe_value` can still be found with more advanced techniques. However, it could at least block out many naive attackers like myself. iOS is getting more secure, but storing critical unprotected values in memory is not a good idea. I will cover more in my future blog posts.
Also check my post on [Linkedin](https://www.linkedin.com/posts/yihengquan_memorysafe-is-my-naive-approach-providing-activity-7023976841812037632-BS9O?utm_source=share).