<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: cj</title>
    <description>The latest articles on DEV Community by cj (@deadlyvalentine47).</description>
    <link>https://dev.to/deadlyvalentine47</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4256594%2F6292fc9f-b263-42c3-8614-332d30df9cb5.png</url>
      <title>DEV Community: cj</title>
      <link>https://dev.to/deadlyvalentine47</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/deadlyvalentine47"/>
    <language>en</language>
    <item>
      <title>The Truth Is in Memory: From Sekiro Hex Editing to Decompiling an Android App</title>
      <dc:creator>cj</dc:creator>
      <pubDate>Sat, 21 Nov 2026 05:49:33 +0000</pubDate>
      <link>https://dev.to/deadlyvalentine47/the-truth-is-in-memory-from-sekiro-hex-editing-to-decompiling-an-android-app-18ho</link>
      <guid>https://dev.to/deadlyvalentine47/the-truth-is-in-memory-from-sekiro-hex-editing-to-decompiling-an-android-app-18ho</guid>
      <description>&lt;h2&gt;
  
  
  Part 1: The farming problem 🎮
&lt;/h2&gt;

&lt;p&gt;I played Sekiro. And Dark Souls. And Elden Ring. You know the type.&lt;/p&gt;

&lt;p&gt;If you haven't played a Souls game, here's the loop: you die. You die again. Then you die to a boss you &lt;em&gt;know&lt;/em&gt; you could beat if you just had 20 more levels and a few more healing gourds. But you don't, because you spent them all on a boss you've now died to 37 times.&lt;/p&gt;

&lt;p&gt;And here's the thing — you &lt;em&gt;could&lt;/em&gt; go farm. Kill the same enemy two hundred times. Run in circles collecting upgrade materials for an hour. It works. It's also the most boring thing you can do with an evening, and I'm stubborn enough to try it for about fifteen minutes before I want to throw the controller at the wall.&lt;/p&gt;

&lt;p&gt;But who doesn't, right? After dying to a boss 100 times, at some point stubbornness loses and you go farm. So one night, mid-farm, I stopped and asked a much more interesting question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where does the game actually keep that number?&lt;/strong&gt; 🤔&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 2: The truth is in RAM
&lt;/h2&gt;

&lt;p&gt;The answer: RAM. All of it. Your xp, your healing gourds, your upgrade materials, the boss's health bar — all just numbers sitting in memory while the game runs.&lt;/p&gt;

&lt;p&gt;So I installed PINCE, a Linux memory scanner and debugger. Attached it to the running game. Found the address holding my xp. Changed the value. And then — this is the part that got me — I saved the game and quit.&lt;/p&gt;

&lt;p&gt;The save file had my edited number in it.&lt;/p&gt;

&lt;p&gt;Because that's how saving works. A game doesn't remember what you &lt;em&gt;earned&lt;/em&gt;. It writes down &lt;strong&gt;whatever is in memory at that exact moment&lt;/strong&gt;. And memory said 9,999.&lt;/p&gt;

&lt;p&gt;Next launch: 9,999 souls, no farming, boss dead first try. 😌&lt;/p&gt;

&lt;p&gt;I won't pretend I "discovered something profound" that night. I'd been told this in a systems class and it went in one ear and out the other. I just &lt;strong&gt;re-remembered&lt;/strong&gt; something I already knew, in a way that finally stuck:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The value on screen is not the truth of the system. It's a &lt;em&gt;rendering&lt;/em&gt; of it. The truth is in memory — everything that is actually real, all of it sitting there in ones and zeroes. Everything else is a picture of memory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That one idea sat in the back of my head for a while.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 3: Enter the annoying app 📱
&lt;/h2&gt;

&lt;p&gt;Sometime later, I was using a downloader app on my phone. I use it daily.&lt;/p&gt;

&lt;p&gt;And I want to be fair to it first, because it earned its place on my home screen: &lt;strong&gt;sharing was one tap.&lt;/strong&gt; You're watching a video, you hit share, you pick the app, and it offers MP4 or MP3, 1080p or 720p or 480p, video or audio-only, whatever you want. No desktop, no sketchy converter site, no "click here to continue" garbage. For pulling media off the internet on a phone, nothing else came close. Genuinely good software, and I used it constantly.&lt;/p&gt;

&lt;p&gt;But.&lt;/p&gt;

&lt;p&gt;Every download needed an ad first. 📺&lt;/p&gt;

&lt;p&gt;Every app launch needed an ad first.&lt;/p&gt;

&lt;p&gt;And if you tried to &lt;em&gt;play&lt;/em&gt; a file you'd already downloaded — inside the app — it didn't play it. It sent you to the Play Store to download a third-party media player. Every. Single. Time.&lt;/p&gt;

&lt;p&gt;Individually: small. Cumulatively: the kind of friction that makes you quietly stop using something you actually liked.&lt;/p&gt;

&lt;p&gt;So I'm sitting there, annoyed, and that old memory-editing thought surfaces:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The behaviour is code. Code is changeable.&lt;/strong&gt; 🛠️&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 4: Opening the box 📦
&lt;/h2&gt;

&lt;p&gt;Different layer this time. With the game I read memory at runtime. Here I pulled the APK off the phone and read the compiled artifact.&lt;/p&gt;

&lt;p&gt;First surprise: &lt;strong&gt;the scale.&lt;/strong&gt; Tens of thousands of classes. And nearly all of them named things like &lt;code&gt;o.z6a&lt;/code&gt;, &lt;code&gt;o.on7$a&lt;/code&gt;, &lt;code&gt;o.rt5&lt;/code&gt;. Obfuscation doesn't hide behaviour — it hides &lt;em&gt;names&lt;/em&gt;. There is no &lt;code&gt;AdManager.showInterstitial()&lt;/code&gt; to search for. There's a function called &lt;code&gt;m1()&lt;/code&gt; that returns a boolean, and the only way to learn what it means is to find who calls it.&lt;/p&gt;

&lt;p&gt;Second surprise, and the one that actually mattered: &lt;strong&gt;an APK is not one thing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's dex files, native libraries, resources — and, apparently, &lt;em&gt;other APKs that get downloaded after you install it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The media extraction logic for each site wasn't in the app at all. It arrived later, as a separate signed package, and got loaded at runtime with a &lt;code&gt;DexClassLoader&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I had spent my first day reading code that had nothing to do with the behaviour I was chasing. 😤&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 5: The patch — four hours, five edits ⚡
&lt;/h2&gt;

&lt;p&gt;Once I understood the architecture, the actual fix was fast. About four hours from "let's try this" to "it works."&lt;/p&gt;

&lt;p&gt;Five small edits, across a handful of methods:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The anti-tamper gate.&lt;/strong&gt; Resign an APK to modify it and you break its signature. The app checked its own certificate against an expected value and, on mismatch, showed a full-screen "pirated app" page. Not just refusing to work — it &lt;strong&gt;blocked every other feature.&lt;/strong&gt; Downloads, playback, sharing, all dead. One gate, deliberately placed upstream of everything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The ad funnel.&lt;/strong&gt; Dozens of places could show an ad. But there was one place that decided whether ads were &lt;em&gt;allowed at all&lt;/em&gt; — the splash activity, plus the reward gate that appeared before downloads. Patch the decision, not the twenty symptoms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The Play Store redirect.&lt;/strong&gt; The "install a third-party player" behaviour came from a whole subsystem around the player guide, spread across six methods in two files. That one was genuinely annoying to trace — I found the obvious gate first, patched it, and it changed nothing, because the code that actually ran was elsewhere.&lt;/p&gt;

&lt;p&gt;And then — it worked. 🎉&lt;/p&gt;

&lt;p&gt;No ads. Downloads fine. Playback in-app. Share-to-download from three different sites. I sat there feeling extremely pleased with myself.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 6: The app fought back 🥊
&lt;/h2&gt;

&lt;p&gt;The next morning, the "pirated app" screen was back.&lt;/p&gt;

&lt;p&gt;I hadn't installed anything. I hadn't updated the app. Same APK, same hash, same file on disk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And that's when the architecture bit me.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The app had pushed a &lt;strong&gt;plugin update&lt;/strong&gt; — a new version of that downloadable package — with no app update at all. From the user's side, nothing changed. From mine, the entire fix had been silently undone, because a copy of the same anti-tamper logic lived &lt;em&gt;inside the plugin&lt;/em&gt;, and the plugin had just replaced itself.&lt;/p&gt;

&lt;p&gt;This is the lesson I'd put on a poster:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;I patched a real thing. Just not the thing that runs.&lt;/strong&gt; 😑&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'd fixed the gate in the app. The gate that executed was in the plugin. Patching the host was necessary and completely insufficient — and the app had no reason to tell me it had replaced itself. It just did, quietly, overnight.&lt;/p&gt;

&lt;p&gt;That's when the project changed from "remove some ads" to "understand a piece of software that actively defends itself." And honestly? That's the part I enjoyed most.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 7: The war 🪓
&lt;/h2&gt;

&lt;p&gt;What followed, roughly in order of how much each one taught me:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The signature check isn't where you'd put it.&lt;/strong&gt; Every patch had to go in twice — once in the app, once in the plugin — and the plugin could update whenever it liked. The real fix wasn't another patch. It was &lt;strong&gt;stopping the app from downloading new plugins at all&lt;/strong&gt;. Two functions: one that checks for upgrades, one that builds the download task. Pin both, and the app can't quietly replace your work anymore.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The build started failing in new and creative ways.&lt;/strong&gt; &lt;code&gt;Invalid text&lt;/code&gt; on a smali file. Different file every run. 😵 So: concurrency. Java tooling compiling 17,000 files in parallel and occasionally tripping over itself. Fixed by building with &lt;code&gt;-j 1&lt;/code&gt; — slower, boring, reliable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Then it failed a second way.&lt;/strong&gt; Some decoded files came out with raw bytes and nulls where strings should be. Wrote a small sanitiser script to clean them before compiling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Then it failed a third way, and this one was the real one.&lt;/strong&gt; The same error, back again. The disk. My drive had &lt;strong&gt;remounted itself read-only&lt;/strong&gt; after a filesystem error, and reads were returning garbage. My retry logic had been hiding it for about an hour while I confidently fixed the wrong things.&lt;/p&gt;

&lt;p&gt;That's the debugging lesson that has nothing to do with Android:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When a failure keeps &lt;strong&gt;changing shape&lt;/strong&gt;, stop fixing the symptom and ask what could produce &lt;em&gt;any&lt;/em&gt; of these shapes. My first fix changed the failure — which is exactly why I nearly missed the second cause sitting underneath it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;And then one wall I couldn't break.&lt;/strong&gt; Instagram downloads started demanding a login. I assumed I'd broken something. I hadn't. Every version of the plugin I pulled had &lt;em&gt;identical&lt;/em&gt; handling for that error — Instagram had changed something on its end and stopped letting unattended requests scrape it.&lt;/p&gt;

&lt;p&gt;There was a way around it, in theory. On a desktop you can pull the session cookies and storage out of a logged-in browser and replay them in the request, and the server can't tell the difference. Except I was doing all of this from a phone, with no devtools and no easy way to extract a cookie jar. So that route was closed to me — and honestly, a dummy account did the job in the end.&lt;/p&gt;

&lt;p&gt;The takeaway is the part worth keeping:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You cannot patch a decision that was made on someone else's server. 🔒&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That one was almost a relief. Not everything is fixable, and knowing which problems are yours to solve is half of engineering.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 8: What I actually took away 🧠
&lt;/h2&gt;

&lt;p&gt;Not the ad-free app — although, not going to lie, that's nice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Values are runtime state.&lt;/strong&gt; The number on screen is a rendering. Whether it's xp in Sekiro or a feature flag in production, the truth lives somewhere else — memory, config, a server response — and knowing &lt;em&gt;which layer you're looking at&lt;/em&gt; is the entire skill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read the artifact, not the description.&lt;/strong&gt; Users describe symptoms. Systems name components. Get the actual activity, the actual class, the actual file — then read that. Two hours reading the wrong layer is the default outcome of skipping this step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Patch the highest funnel.&lt;/strong&gt; Dozens of places could show an ad. One decided whether ads existed. Three lines versus a week of whack-a-mole that would still have missed the next one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Obfuscation hides names, not behaviour.&lt;/strong&gt; A renamed function still returns a boolean for a reason. Follow the callers and the semantics surface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify the artifact, not the build output.&lt;/strong&gt; "It compiled" and "it's running" are different claims, and only one of them is testable. I hash the installed APK and compare it to what I built, every time.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 9: The honest boundary 🙏
&lt;/h2&gt;

&lt;p&gt;This was on a phone I own, for software I already used, and nothing was redistributed. That line matters, and it isn't a technical one — understanding a system and distributing a modified version of someone else's work are very different acts.&lt;/p&gt;

&lt;p&gt;The value was never in the modification. It was in the loop, which is exactly the loop I run at work every day:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;form a hypothesis → find the layer that actually executes → prove it with evidence → change one variable → verify the artifact.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I've run that loop on a game's memory, on a compiled Android app, on a coverage pipeline that was lying about its own results, and on a build system that failed differently every single time.&lt;/p&gt;

&lt;p&gt;The domain changes. The loop doesn't. 🔁&lt;/p&gt;




&lt;h2&gt;
  
  
  Appendix: the toolkit 🧰
&lt;/h2&gt;

&lt;p&gt;For anyone who wants to try something like this on their own device, here's everything I actually used. All of it is free, and none of it needs an Android SDK.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Talking to the phone&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;adb&lt;/strong&gt; (Android Debug Bridge) — the whole interface. &lt;code&gt;pull&lt;/code&gt; to get the APK off, &lt;code&gt;push&lt;/code&gt; to get files back, &lt;code&gt;shell&lt;/code&gt; for everything else. The one tool you cannot work without.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;USB debugging&lt;/strong&gt; — enabled in Developer Options. Note: on MIUI/Xiaomi, &lt;code&gt;adb install&lt;/code&gt; can still be blocked until you also enable &lt;em&gt;Install via USB&lt;/em&gt; and &lt;em&gt;USB debugging (Security settings)&lt;/em&gt;, which needs a reboot to take effect. That cost me an hour.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;logcat&lt;/strong&gt; — the app's own log buffer. This is where I first saw the plugin path being loaded.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;dumpsys&lt;/strong&gt; (&lt;code&gt;dumpsys window | grep mCurrentFocus&lt;/code&gt;) — tells you which activity is actually on screen, instead of guessing from what it looks like.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;uiautomator dump&lt;/strong&gt; — dumps the view hierarchy as XML. The fastest way to learn whether you're looking at native views or a WebView, which decides your entire toolchain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pm list packages&lt;/strong&gt; / &lt;strong&gt;pm path&lt;/strong&gt; — confirm what's installed and where the APK actually lives.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reading the code&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;apktool&lt;/strong&gt; — decodes the APK to smali (readable bytecode) and back. Version 3.x. Use &lt;code&gt;-j 1&lt;/code&gt;; the parallel compile corrupts files at this scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;jadx&lt;/strong&gt; — decompiles dex to Java for reading. Excellent for understanding flow; I used it to trace call graphs rather than to rebuild anything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;smali / dex&lt;/strong&gt; — the assembly-like layer apktool gives you. Obfuscated, verbose, and the only place the actual patch goes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Java (JRE)&lt;/strong&gt; — apktool needs it. A JDK is enough; no Android SDK, ever.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Building and verifying&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;uber-apk-signer&lt;/strong&gt; — zipalign + v1/v2/v3 signing in one Java jar. No &lt;code&gt;apksigner&lt;/code&gt; wrapper, no SDK, no build tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sha256sum&lt;/strong&gt; — hash the APK before and after. "It compiled" and "it's running" are different claims, and this is how you tell them apart.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A custom keystore&lt;/strong&gt; — you must sign with your own, which is why modifying an app means uninstalling the original first.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Watching the network&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PCAPdroid&lt;/strong&gt; — captures traffic from the phone without root. Proved to me that the login wall was a redirect, not something I'd broken.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;tshark&lt;/strong&gt; (Wireshark CLI) — reads the &lt;code&gt;.pcap&lt;/code&gt; on the laptop. Flow, DNS, and TLS handshake metadata without decrypting anything.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Memory-side (the game part)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PINCE&lt;/strong&gt; — Linux memory scanner and debugger. Attach to a running process, find an address, change a value. This is where the whole idea started.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Everything else&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bash&lt;/strong&gt; — the build, patch, and verify scripts. Boring and repeatable beats clever.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Python&lt;/strong&gt; — small utilities: one to sanitise smali files before compiling, one to verify that each patch actually applied.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Git&lt;/strong&gt; — patches as diffs, scripts as scripts, findings as markdown. If you can't reproduce it next month, you didn't learn it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;F-Droid&lt;/strong&gt; — a trustworthy source for the network-capture tools, no Play Store account needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The only paid thing in that list is the phone. Everything else is free, open source, and runs on a normal laptop with no Android Studio anywhere in sight.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you've ever gone down a rabbit hole like this — a game, an app, a build that broke for no reason — I'd love to hear what it taught you. Comments are open.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>gaming</category>
      <category>android</category>
      <category>debugging</category>
      <category>reverseengineering</category>
    </item>
  </channel>
</rss>
