AndroCorn Documentation
AndroCorn is an advanced, kernel-free user-space emulation framework for Android native ARM/ARM64 libraries built on top of the Unicorn Engine.
It provides a fully simulated Android OS user-space environment, allowing you to load and execute heavily obfuscated .so files, anti-tamper protectors, and cryptors seamlessly on Windows, macOS, and Linux.
Key Highlights of Version 2.0
- Zero God-Objects: Modular, context-driven design where interrupts and syscalls operate on pure stateless abstractions.
- Deterministic Memory Mapping: Strict segmentation between emulator-internal storage (
0x60...), process[heap](0x70...), dynamicmmap(0x80...), and the stack (0x10...). - POSIX VFS with In-Memory IPC: Full object-oriented filesystem node architecture with support for character devices (
/dev/null,/dev/urandom,/dev/binder,/dev/ptmx), dynamic procfs (/proc/self/maps), and non-blockingVirtualPipe. - Auto-Arity JNI Dispatcher: Dynamic argument extraction supporting methods with arbitrary parameter counts without hardcoded limits.
- Modern Hooking & Forensics: Integrated
InlineHook, caller-contextMemoryWatchpoint, and block-levelCrossModuleTracer. - State Rollback: Instant zero-copy memory snapshots for fuzzing and repetitive native function evaluation.
Module Index
androidemu.core.emulator.Emulator
Main class of Emulator. Store everything you need.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vfs_root
|
str
|
The root of the virtual file system |
'vfs'
|
environment
|
Dict
|
The configuration package |
DEFAULT_PACKAGE
|
vfp_inst_set
|
bool
|
Enable VFP instructions |
True
|
arch
|
int
|
Current architecture (32 or 64 bit). 1 (ARM32) or 2 (ARM64) (default: 1) |
ARCH_ARM32
|
init_sys_libs
|
bool
|
Initialize system libraries |
True
|
Source code in androidemu/core/emulator.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
call_function(module, function_name, *argv)
Use it for non-export functions, like in libc
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The module containing the function |
required |
function_name
|
str
|
The name of the function |
required |
*argv
|
Any
|
The arguments to pass to the function |
()
|
Returns:
| Type | Description |
|---|---|
Optional[int]
|
The return value of the function |
Source code in androidemu/core/emulator.py
call_native(addr, *argv)
Call a native function with the given address and arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
int
|
The address of the native function |
required |
*argv
|
Any
|
The arguments to pass to the native function |
()
|
Returns:
| Type | Description |
|---|---|
Optional[int]
|
The return value of the native function |
Source code in androidemu/core/emulator.py
call_native_return_2reg(addr, *argv)
The 8 (or 16) byte return value is split across two registers. The high (4 or 8) bytes are stored in R1 (X1) and the low (4 or 8) bytes are stored in the return value. This function combines the two parts of the return value into a single 8 (or 16) byte value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
int
|
The address of the native function |
required |
*argv
|
Any
|
The arguments to pass to the native function |
()
|
Returns:
| Type | Description |
|---|---|
Optional[int]
|
The return value of the native function |
Source code in androidemu/core/emulator.py
call_symbol(module, symbol_name, *argv)
Call a symbol in a module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The module containing the symbol |
required |
symbol_name
|
str
|
The name of the symbol |
required |
*argv
|
Any
|
The arguments to pass to the symbol |
()
|
Returns:
| Type | Description |
|---|---|
Optional[int]
|
The return value of the symbol |
Source code in androidemu/core/emulator.py
get_library(filename)
Get a loaded library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the library |
required |
Returns:
| Type | Description |
|---|---|
Optional[Module]
|
The loaded module, or None if the library is not loaded. |
Source code in androidemu/core/emulator.py
load_library(filename, do_init=True, main_lib=False)
Load a dynamic library from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the library (e.g. libfoo.so) |
required |
do_init
|
bool
|
Whether to initialize the library with init_array |
True
|
main_lib
|
bool
|
Whether this is the main executable |
False
|
Returns:
| Type | Description |
|---|---|
Module
|
The loaded module |
Source code in androidemu/core/emulator.py
sys_reg_read(reg)
Read Non-Implement System Registers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reg
|
int
|
The register to read |
required |
Returns:
| Type | Description |
|---|---|
int
|
The value of the register |
sys_reg_write(reg, val)
Write Non-Implement System Registers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reg
|
int
|
The register to write |
required |
val
|
int
|
The value to write |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in androidemu/core/emulator.py
androidemu.core.registers.RegistersMapping
Source code in androidemu/core/registers.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
read_args(count)
Reads function call arguments according to the architecture's calling convention: first from registers (arguments), then falls back to reading the stack.
Source code in androidemu/core/registers.py
read_syscall_args(count)
Reads arguments for system calls directly from registers.
set_return_val(val, high_val=None)
Sets return value in v_ret (and v_reg_1 if 64-bit pair on 32-bit).
write_args(java_vm, *argv)
Writes function call arguments according to the architecture's calling convention: first into argument registers, then remaining onto the stack (aligned to 16 bytes).
Source code in androidemu/core/registers.py
androidemu.kernel.fs.manager.VFSManager
Source code in androidemu/kernel/fs/manager.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | |
androidemu.native.hook.manager.HookManager
Source code in androidemu/native/hook/manager.py
inline(addr, num_args, cb_before=None, cb_after=None)
Hooks execution at a specific address (function prologue/epilogue).
Source code in androidemu/native/hook/manager.py
inline_symbol(module_name, symbol_name, num_args, cb_before=None, cb_after=None)
Finds symbol in module and inline-hooks it.
Source code in androidemu/native/hook/manager.py
stub(symname, callback)
Replaces an exported or imported function with a Python callback.
Source code in androidemu/native/hook/manager.py
watch(addr, size, tag='WATCH', on_read=None, on_write=None)
Watches memory reads/writes in a given range.
Source code in androidemu/native/hook/manager.py
androidemu.internal.linker.AndroidLinker
Bionic Dynamic Linker Orchestrator Lifecycle: Load Segments -> TLS Setup -> 3-Pass Relocations -> Init Constructors -> Memory Protect.
Source code in androidemu/internal/linker.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
androidemu.utils.memory.map.MemoryMap
Source code in androidemu/utils/memory/map.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
current_brk
property
Get the current counter-allocation pointer.
create_snapshot()
Takes a full snapshot of CPU registers and writable (RW) memory regions. Ignores Read-Only/Execute code segments to save memory and time.
Source code in androidemu/utils/memory/map.py
dump_maps(stream)
Write current memory map to a stream.
Source code in androidemu/utils/memory/map.py
dynamic_alloc(n_units, is_ptr_array=False)
Fast allocation for dynamic data or arrays of pointers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_units
|
int
|
Number of bytes or number of pointers. |
required |
is_ptr_array
|
bool
|
If True, n_units is treated as count of pointers (size * ptr_sz). |
False
|
Returns:
| Type | Description |
|---|---|
int
|
Allocated address. |
Source code in androidemu/utils/memory/map.py
find_free_region(size, start_search=0)
Finds a continuous unmapped memory region.
Source code in androidemu/utils/memory/map.py
get_regions()
map(address, size, prot=UC_PROT_READ | UC_PROT_WRITE, node=None, offset=0)
Standard memory mapping (page-aligned). If address is 0, finds a free region automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address
|
int
|
Target address (must be page aligned if not 0). |
required |
size
|
int
|
Size in bytes. |
required |
prot
|
int
|
Protection flags (UC_PROT_...). |
UC_PROT_READ | UC_PROT_WRITE
|
node
|
Optional[VfsNode]
|
Optional VfsNode to load data from. |
None
|
offset
|
int
|
File offset. |
0
|
Returns:
| Type | Description |
|---|---|
int
|
Base address of the mapped region. |
Source code in androidemu/utils/memory/map.py
protect(addr, size, prot)
restore_snapshot(snapshot)
Restores CPU state and rolls back all writable memory pages to the snapshot.
Source code in androidemu/utils/memory/map.py
static_alloc(size, addr=None, align=16)
Allocate memory. If addr is provided, it acts as a fixed-base mapping (for TLS/Soinfo zones). If addr is None, it acts as a linear allocator (for general heap).
Source code in androidemu/utils/memory/map.py
unmap(addr, size)
Unmap a memory region and clean up tracking.