Skip to content

Commit 5a99960

Browse files
committed
Actually fixed Android
It didnt work for all UE4 games, now it should
1 parent 119476e commit 5a99960

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

ReadMe.md

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ It can be really difficult to get the AES Key of a game if you do not know what
33
#### If this doesn't work for you just a open a new issue, but provide the game name and a memory dump of it, if you already have the AES Key or find it later please provide that too :)
44
You can use https://github.com/NtQuery/Scylla to get a memory dump of your game
55

6+
## Android (arm64-v8 only)
7+
For android games you will get two AES Keys, that is because I do not know when the key is + 0x1000 after the offset it should be at. Just try both :)
8+
(If you know why the location is 0x1000 bytes forward please make a pr)
9+
10+
## Android (armeabi-v7a)
11+
If you send me a library + AES Key I can add support for that too
12+
613
### Example outputs:
714
```
815
Please select from where you want to get the AES Key

UEAESKeyFinder/Searcher.cs

+21-23
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,7 @@ public int FollowJMP(int addr)
116116

117117
return addr;
118118
}
119-
public int GetPageAddress(int Addr, int PageSize)
120-
{
121-
// log2
122-
PageSize |= PageSize >> 1;
123-
PageSize |= PageSize >> 2;
124-
PageSize |= PageSize >> 4;
125-
PageSize |= PageSize >> 8;
126-
PageSize |= PageSize >> 16;
127-
int bits_page_offset = new List<int>() { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 }[(PageSize * 0x07C4ACDD) >> 27];
128-
129-
return (Addr >> (bits_page_offset - 1)) << (bits_page_offset - 1);
130-
}
131-
public int DecodeADRP(int adrp) // https://chromium.googlesource.com/chromiumos/third_party/binutils/+/refs/heads/stabilize-7374.B/gold/aarch64.cc#150
119+
public UInt64 DecodeADRP(int adrp) // https://chromium.googlesource.com/chromiumos/third_party/binutils/+/refs/heads/stabilize-7374.B/gold/aarch64.cc#150
132120
{
133121
const int mask19 = (1 << 19) - 1;
134122
const int mask2 = 3;
@@ -141,17 +129,20 @@ public int DecodeADRP(int adrp) // https://chromium.googlesource.com/chromiumos/
141129
int value = imm << 12;
142130
// Sign extend to 64-bit by repeating msbt 31 (64-33) times and merge it
143131
// with value.
144-
return ((((int)(1) << 32) - msbt) << 33) | value;
132+
return (UInt64)(((((int)(1) << 32) - msbt) << 33) | value);
145133
}
146-
public int GetADRPAddress(int ADRPLoc)
134+
public UInt64 DecodeADD(int add)
147135
{
148-
int ADRP = DecodeADRP(BitConverter.ToInt32(this.ProcessMemory, ADRPLoc));
149-
int ADD = BitConverter.ToInt32(this.ProcessMemory, ADRPLoc + 4);
150-
151-
int imm12 = (ADD & 0x3ffc00) >> 10;
152-
if ((ADD & 0xc00000) != 0) imm12 <<= 12;
136+
var imm12 = (add & 0x3ffc00) >> 10;
137+
if ((imm12 & 0xc00000) != 0) imm12 <<= 12;
138+
return (UInt64)imm12;
139+
}
140+
public int GetADRLAddress(int ADRPLoc)
141+
{
142+
UInt64 ADRP = DecodeADRP(BitConverter.ToInt32(this.ProcessMemory, ADRPLoc));
143+
UInt64 ADD = DecodeADD(BitConverter.ToInt32(this.ProcessMemory, ADRPLoc + 4));
153144

154-
return GetPageAddress(ADRPLoc, PAGE_SIZE) + ADRP + imm12;
145+
return (int)((((UInt64)ADRPLoc & 0xFFFFF000) + ADRP + ADD) & 0xFFFFFFFF);
155146
}
156147
public Dictionary<ulong, string> FindAllPattern(out long t)
157148
{
@@ -167,6 +158,8 @@ public Dictionary<ulong, string> FindAllPattern(out long t)
167158
{
168159
// if this gets no results (or too many) for some reason we could also get the addr that calls this...
169160

161+
// 01 01 40 AD 01 00 00 AD C0 03 5F D6
162+
170163
// First instruction is the adrp, then add...
171164

172165
// Second instruction
@@ -186,11 +179,16 @@ public Dictionary<ulong, string> FindAllPattern(out long t)
186179
if (this.ProcessMemory[i + 9] != 0x03) continue;
187180
if (this.ProcessMemory[i + 10] != 0x5F) continue;
188181
if (this.ProcessMemory[i + 11] != 0xD6) continue;
189-
182+
190183
aesKey = "";
191-
int aesKeyAddr = GetADRPAddress(i - 8);
184+
int aesKeyAddr = GetADRLAddress(i - 8);
185+
192186
aesKey += BitConverter.ToString(this.ProcessMemory[aesKeyAddr..(aesKeyAddr + 32)]).ToString().Replace("-", "");
193187
offsets.Add(AllocationBase + (ulong)aesKeyAddr, $"0x{aesKey}");
188+
189+
aesKeyAddr += 0x1000; // Please fix this, idk when its + 0x1000 and when not....
190+
aesKey = BitConverter.ToString(this.ProcessMemory[aesKeyAddr..(aesKeyAddr + 32)]).ToString().Replace("-", "");
191+
offsets.Add(AllocationBase + (ulong)aesKeyAddr, $"0x{aesKey}");
194192
}
195193
}
196194
else

0 commit comments

Comments
 (0)