hexcore-unicorn 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +307 -0
- package/binding.gyp +91 -0
- package/deps/unicorn/include/unicorn/arm.h +235 -0
- package/deps/unicorn/include/unicorn/arm64.h +393 -0
- package/deps/unicorn/include/unicorn/m68k.h +81 -0
- package/deps/unicorn/include/unicorn/mips.h +283 -0
- package/deps/unicorn/include/unicorn/platform.h +263 -0
- package/deps/unicorn/include/unicorn/ppc.h +434 -0
- package/deps/unicorn/include/unicorn/riscv.h +316 -0
- package/deps/unicorn/include/unicorn/s390x.h +200 -0
- package/deps/unicorn/include/unicorn/sparc.h +173 -0
- package/deps/unicorn/include/unicorn/tricore.h +174 -0
- package/deps/unicorn/include/unicorn/unicorn.h +1456 -0
- package/deps/unicorn/include/unicorn/x86.h +1681 -0
- package/deps/unicorn/unicorn-import.lib +0 -0
- package/deps/unicorn/unicorn.dll +0 -0
- package/index.d.ts +792 -0
- package/index.js +167 -0
- package/index.mjs +40 -0
- package/package.json +87 -0
- package/src/emu_async_worker.h +179 -0
- package/src/main.cpp +717 -0
- package/src/unicorn_wrapper.cpp +1536 -0
- package/src/unicorn_wrapper.h +379 -0
package/README.md
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# HexCore Unicorn
|
|
2
|
+
|
|
3
|
+
Modern Node.js bindings for the [Unicorn Engine](https://www.unicorn-engine.org/) CPU emulator using N-API.
|
|
4
|
+
|
|
5
|
+
Part of the **HikariSystem HexCore** binary analysis IDE.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Full Unicorn Engine API support
|
|
10
|
+
- Modern N-API bindings (ABI stable)
|
|
11
|
+
- Async emulation with Promises
|
|
12
|
+
- TypeScript definitions included
|
|
13
|
+
- Hook system with ThreadSafeFunction
|
|
14
|
+
- Support for all architectures: x86, ARM, ARM64, MIPS, SPARC, PPC, M68K, RISC-V
|
|
15
|
+
- Context save/restore
|
|
16
|
+
- Memory mapping and protection
|
|
17
|
+
- **Native Breakpoints (O(1) lookup)**
|
|
18
|
+
- **Shared Memory Support (GC Safe)**
|
|
19
|
+
- **State Snapshotting (Save/Restore)**
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install hexcore-unicorn
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Note:** You need to have the Unicorn library installed on your system or place the library files in the `deps/unicorn/` directory.
|
|
28
|
+
|
|
29
|
+
### Building from source
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/LXrdKnowkill/hexcore-unicorn.git
|
|
33
|
+
cd hexcore-unicorn
|
|
34
|
+
npm install
|
|
35
|
+
npm run build
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
const { Unicorn, ARCH, MODE, PROT, X86_REG } = require('hexcore-unicorn');
|
|
42
|
+
|
|
43
|
+
// Create x86-64 emulator
|
|
44
|
+
const uc = new Unicorn(ARCH.X86, MODE.MODE_64);
|
|
45
|
+
|
|
46
|
+
// Map memory for code and stack
|
|
47
|
+
uc.memMap(0x1000n, 0x1000, PROT.ALL); // Code
|
|
48
|
+
uc.memMap(0x2000n, 0x1000, PROT.ALL); // Stack
|
|
49
|
+
|
|
50
|
+
// Write x86-64 code: mov rax, 0x1234; ret
|
|
51
|
+
const code = Buffer.from([
|
|
52
|
+
0x48, 0xC7, 0xC0, 0x34, 0x12, 0x00, 0x00, // mov rax, 0x1234
|
|
53
|
+
0xC3 // ret
|
|
54
|
+
]);
|
|
55
|
+
uc.memWrite(0x1000n, code);
|
|
56
|
+
|
|
57
|
+
// Set up stack pointer
|
|
58
|
+
uc.regWrite(X86_REG.RSP, 0x2800n);
|
|
59
|
+
|
|
60
|
+
// Run emulation
|
|
61
|
+
uc.emuStart(0x1000n, 0x1008n);
|
|
62
|
+
|
|
63
|
+
// Read result
|
|
64
|
+
const rax = uc.regRead(X86_REG.RAX);
|
|
65
|
+
console.log(`RAX = 0x${rax.toString(16)}`); // RAX = 0x1234
|
|
66
|
+
|
|
67
|
+
// Clean up
|
|
68
|
+
uc.close();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## API Reference
|
|
72
|
+
|
|
73
|
+
### Creating an Emulator
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
const uc = new Unicorn(arch, mode);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- `arch`: Architecture constant (e.g., `ARCH.X86`, `ARCH.ARM64`)
|
|
80
|
+
- `mode`: Mode constant (e.g., `MODE.MODE_64`, `MODE.UC_MODE_ARM`)
|
|
81
|
+
|
|
82
|
+
### Memory Operations
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
// Map memory
|
|
86
|
+
uc.memMap(address, size, permissions);
|
|
87
|
+
|
|
88
|
+
// Read memory
|
|
89
|
+
const buffer = uc.memRead(address, size);
|
|
90
|
+
|
|
91
|
+
// Write memory
|
|
92
|
+
uc.memWrite(address, buffer);
|
|
93
|
+
|
|
94
|
+
// Unmap memory
|
|
95
|
+
uc.memUnmap(address, size);
|
|
96
|
+
|
|
97
|
+
// Change permissions
|
|
98
|
+
uc.memProtect(address, size, permissions);
|
|
99
|
+
|
|
100
|
+
// Get mapped regions
|
|
101
|
+
const regions = uc.memRegions();
|
|
102
|
+
// Returns: [{ begin: bigint, end: bigint, perms: number }, ...]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Register Operations
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
// Read register
|
|
109
|
+
const value = uc.regRead(X86_REG.RAX);
|
|
110
|
+
|
|
111
|
+
// Write register
|
|
112
|
+
uc.regWrite(X86_REG.RAX, 0x1234n);
|
|
113
|
+
|
|
114
|
+
// Batch operations
|
|
115
|
+
const values = uc.regReadBatch([X86_REG.RAX, X86_REG.RBX]);
|
|
116
|
+
uc.regWriteBatch([X86_REG.RAX, X86_REG.RBX], [0x1111n, 0x2222n]);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Emulation Control
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
// Synchronous emulation
|
|
123
|
+
uc.emuStart(begin, until, timeout, count);
|
|
124
|
+
|
|
125
|
+
// Asynchronous emulation
|
|
126
|
+
await uc.emuStartAsync(begin, until, timeout, count);
|
|
127
|
+
|
|
128
|
+
// Stop emulation (from hook)
|
|
129
|
+
uc.emuStop();
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Hooks
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
// Code execution hook
|
|
136
|
+
const handle = uc.hookAdd(HOOK.CODE, (address, size) => {
|
|
137
|
+
console.log(`Executing: 0x${address.toString(16)}`);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Memory access hook
|
|
141
|
+
uc.hookAdd(HOOK.MEM_WRITE, (type, address, size, value) => {
|
|
142
|
+
console.log(`Memory write at 0x${address.toString(16)}`);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Interrupt hook
|
|
146
|
+
uc.hookAdd(HOOK.INTR, (intno) => {
|
|
147
|
+
console.log(`Interrupt: ${intno}`);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Remove hook
|
|
151
|
+
uc.hookDel(handle);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Context Management
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
// Save context
|
|
158
|
+
const ctx = uc.contextSave();
|
|
159
|
+
|
|
160
|
+
// Restore context
|
|
161
|
+
uc.contextRestore(ctx);
|
|
162
|
+
|
|
163
|
+
// Free context
|
|
164
|
+
ctx.free();
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Native Breakpoints (High Performance)
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
// Add a native breakpoint (Zero overhead until hit)
|
|
171
|
+
uc.breakpointAdd(0x1000n);
|
|
172
|
+
|
|
173
|
+
// Remove breakpoint
|
|
174
|
+
uc.breakpointDel(0x1000n);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Shared Memory (Zero-Copy & GC Safe)
|
|
178
|
+
|
|
179
|
+
```javascript
|
|
180
|
+
// Create shared buffer
|
|
181
|
+
const sab = new SharedArrayBuffer(4096);
|
|
182
|
+
const buffer = Buffer.from(sab);
|
|
183
|
+
|
|
184
|
+
// Map it (Unicorn keeps a reference to prevent GC)
|
|
185
|
+
uc.memMapPtr(0x10000n, buffer, PROT.ALL);
|
|
186
|
+
|
|
187
|
+
// usage: write to 'buffer' in JS, read instanly in Unicorn
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### State Snapshotting (Time Travel)
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
// Save full state (Context + RAM)
|
|
194
|
+
const snapshot = uc.stateSave();
|
|
195
|
+
|
|
196
|
+
// ... execute more code ...
|
|
197
|
+
|
|
198
|
+
// Restore state (Rewind)
|
|
199
|
+
uc.stateRestore(snapshot);
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Utility Functions
|
|
203
|
+
|
|
204
|
+
```javascript
|
|
205
|
+
// Get version
|
|
206
|
+
const ver = version();
|
|
207
|
+
console.log(`Unicorn ${ver.string}`);
|
|
208
|
+
|
|
209
|
+
// Check architecture support
|
|
210
|
+
if (archSupported(ARCH.ARM64)) {
|
|
211
|
+
console.log('ARM64 is supported');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Get error message
|
|
215
|
+
const msg = strerror(errorCode);
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Constants
|
|
219
|
+
|
|
220
|
+
### Architectures (ARCH)
|
|
221
|
+
|
|
222
|
+
- `ARCH.X86` - x86/x64
|
|
223
|
+
- `ARCH.ARM` - ARM
|
|
224
|
+
- `ARCH.ARM64` - ARM64 (AArch64)
|
|
225
|
+
- `ARCH.MIPS` - MIPS
|
|
226
|
+
- `ARCH.SPARC` - SPARC
|
|
227
|
+
- `ARCH.PPC` - PowerPC
|
|
228
|
+
- `ARCH.M68K` - Motorola 68K
|
|
229
|
+
- `ARCH.RISCV` - RISC-V
|
|
230
|
+
|
|
231
|
+
### Modes (MODE)
|
|
232
|
+
|
|
233
|
+
- `MODE.MODE_16` - 16-bit mode
|
|
234
|
+
- `MODE.MODE_32` - 32-bit mode
|
|
235
|
+
- `MODE.MODE_64` - 64-bit mode
|
|
236
|
+
- `MODE.LITTLE_ENDIAN` - Little-endian
|
|
237
|
+
- `MODE.BIG_ENDIAN` - Big-endian
|
|
238
|
+
|
|
239
|
+
### Memory Permissions (PROT)
|
|
240
|
+
|
|
241
|
+
- `PROT.NONE` - No permissions
|
|
242
|
+
- `PROT.READ` - Read permission
|
|
243
|
+
- `PROT.WRITE` - Write permission
|
|
244
|
+
- `PROT.EXEC` - Execute permission
|
|
245
|
+
- `PROT.ALL` - All permissions
|
|
246
|
+
|
|
247
|
+
### Hook Types (HOOK)
|
|
248
|
+
|
|
249
|
+
- `HOOK.CODE` - Code execution
|
|
250
|
+
- `HOOK.BLOCK` - Basic block
|
|
251
|
+
- `HOOK.INTR` - Interrupts
|
|
252
|
+
- `HOOK.MEM_READ` - Memory read
|
|
253
|
+
- `HOOK.MEM_WRITE` - Memory write
|
|
254
|
+
- `HOOK.MEM_FETCH` - Memory fetch
|
|
255
|
+
|
|
256
|
+
### Registers
|
|
257
|
+
|
|
258
|
+
- `X86_REG` - x86/x64 registers (RAX, RBX, RCX, etc.)
|
|
259
|
+
- `ARM_REG` - ARM registers (R0-R12, SP, LR, PC, etc.)
|
|
260
|
+
- `ARM64_REG` - ARM64 registers (X0-X30, SP, PC, etc.)
|
|
261
|
+
- `MIPS_REG` - MIPS registers (V0, A0-A3, T0-T9, etc.)
|
|
262
|
+
|
|
263
|
+
## TypeScript
|
|
264
|
+
|
|
265
|
+
Full TypeScript definitions are included:
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
import { Unicorn, ARCH, MODE, PROT, X86_REG, version } from 'hexcore-unicorn';
|
|
269
|
+
|
|
270
|
+
const uc = new Unicorn(ARCH.X86, MODE.MODE_64);
|
|
271
|
+
const rax: bigint | number = uc.regRead(X86_REG.RAX);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Requirements
|
|
275
|
+
|
|
276
|
+
- Node.js >= 18.0.0
|
|
277
|
+
- Unicorn Engine library
|
|
278
|
+
|
|
279
|
+
### Installing Unicorn
|
|
280
|
+
|
|
281
|
+
**Windows:**
|
|
282
|
+
Download from [Unicorn releases](https://github.com/unicorn-engine/unicorn/releases) and place `unicorn.dll` and `unicorn.lib` in `deps/unicorn/`.
|
|
283
|
+
|
|
284
|
+
**Linux:**
|
|
285
|
+
```bash
|
|
286
|
+
sudo apt install libunicorn-dev
|
|
287
|
+
# Or build from source
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**macOS:**
|
|
291
|
+
```bash
|
|
292
|
+
brew install unicorn
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
MIT License - See [LICENSE](LICENSE) for details.
|
|
298
|
+
|
|
299
|
+
## Contributing
|
|
300
|
+
|
|
301
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
302
|
+
|
|
303
|
+
## Related Projects
|
|
304
|
+
|
|
305
|
+
- [hexcore-capstone](https://www.npmjs.com/package/hexcore-capstone) - Capstone disassembler bindings
|
|
306
|
+
- [hexcore-keystone](https://www.npmjs.com/package/hexcore-keystone) - Keystone assembler bindings (Older version, No Working)
|
|
307
|
+
- [Unicorn Engine](https://www.unicorn-engine.org/) - The underlying emulation framework
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "hexcore_unicorn",
|
|
5
|
+
"sources": [
|
|
6
|
+
"src/main.cpp",
|
|
7
|
+
"src/unicorn_wrapper.cpp"
|
|
8
|
+
],
|
|
9
|
+
"include_dirs": [
|
|
10
|
+
"<!@(node -p \"require('node-addon-api').include\")",
|
|
11
|
+
"deps/unicorn/include"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": [
|
|
14
|
+
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
15
|
+
],
|
|
16
|
+
"defines": [
|
|
17
|
+
"NAPI_VERSION=8",
|
|
18
|
+
"NAPI_CPP_EXCEPTIONS",
|
|
19
|
+
"NODE_ADDON_API_DISABLE_DEPRECATED"
|
|
20
|
+
],
|
|
21
|
+
"cflags!": ["-fno-exceptions"],
|
|
22
|
+
"cflags_cc!": ["-fno-exceptions"],
|
|
23
|
+
"conditions": [
|
|
24
|
+
["OS=='win'", {
|
|
25
|
+
"libraries": [
|
|
26
|
+
"<(module_root_dir)/deps/unicorn/unicorn-import.lib"
|
|
27
|
+
],
|
|
28
|
+
"copies": [
|
|
29
|
+
{
|
|
30
|
+
"destination": "<(module_root_dir)/build/Release/",
|
|
31
|
+
"files": [
|
|
32
|
+
"<(module_root_dir)/deps/unicorn/unicorn.dll"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"msvs_settings": {
|
|
37
|
+
"VCCLCompilerTool": {
|
|
38
|
+
"ExceptionHandling": 1,
|
|
39
|
+
"AdditionalOptions": ["/std:c++17"]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"defines": [
|
|
43
|
+
"_HAS_EXCEPTIONS=1"
|
|
44
|
+
]
|
|
45
|
+
}],
|
|
46
|
+
["OS=='linux'", {
|
|
47
|
+
"libraries": [
|
|
48
|
+
"-L<(module_root_dir)/deps/unicorn",
|
|
49
|
+
"-lunicorn",
|
|
50
|
+
"-Wl,-rpath,'$$ORIGIN'"
|
|
51
|
+
],
|
|
52
|
+
"cflags_cc": [
|
|
53
|
+
"-std=c++17",
|
|
54
|
+
"-fexceptions"
|
|
55
|
+
],
|
|
56
|
+
"copies": [
|
|
57
|
+
{
|
|
58
|
+
"destination": "<(module_root_dir)/build/Release/",
|
|
59
|
+
"files": [
|
|
60
|
+
"<(module_root_dir)/deps/unicorn/libunicorn.so",
|
|
61
|
+
"<(module_root_dir)/deps/unicorn/libunicorn.so.2"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}],
|
|
66
|
+
["OS=='mac'", {
|
|
67
|
+
"libraries": [
|
|
68
|
+
"-L<(module_root_dir)/deps/unicorn",
|
|
69
|
+
"-lunicorn",
|
|
70
|
+
"-Wl,-rpath,@loader_path"
|
|
71
|
+
],
|
|
72
|
+
"xcode_settings": {
|
|
73
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
74
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
75
|
+
"CLANG_CXX_LANGUAGE_STANDARD": "c++17",
|
|
76
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.15"
|
|
77
|
+
},
|
|
78
|
+
"copies": [
|
|
79
|
+
{
|
|
80
|
+
"destination": "<(module_root_dir)/build/Release/",
|
|
81
|
+
"files": [
|
|
82
|
+
"<(module_root_dir)/deps/unicorn/libunicorn.dylib",
|
|
83
|
+
"<(module_root_dir)/deps/unicorn/libunicorn.2.dylib"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}]
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/* Unicorn Engine */
|
|
2
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2015-2017 */
|
|
3
|
+
/* This file is released under LGPL2.
|
|
4
|
+
See COPYING.LGPL2 in root directory for more details
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef UNICORN_ARM_H
|
|
8
|
+
#define UNICORN_ARM_H
|
|
9
|
+
|
|
10
|
+
#ifdef __cplusplus
|
|
11
|
+
extern "C" {
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#ifdef _MSC_VER
|
|
15
|
+
#pragma warning(disable : 4201)
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
//> ARM CPU
|
|
19
|
+
typedef enum uc_cpu_arm {
|
|
20
|
+
UC_CPU_ARM_926 = 0,
|
|
21
|
+
UC_CPU_ARM_946,
|
|
22
|
+
UC_CPU_ARM_1026,
|
|
23
|
+
UC_CPU_ARM_1136_R2,
|
|
24
|
+
UC_CPU_ARM_1136,
|
|
25
|
+
UC_CPU_ARM_1176,
|
|
26
|
+
UC_CPU_ARM_11MPCORE,
|
|
27
|
+
UC_CPU_ARM_CORTEX_M0,
|
|
28
|
+
UC_CPU_ARM_CORTEX_M3,
|
|
29
|
+
UC_CPU_ARM_CORTEX_M4,
|
|
30
|
+
UC_CPU_ARM_CORTEX_M7,
|
|
31
|
+
UC_CPU_ARM_CORTEX_M33,
|
|
32
|
+
UC_CPU_ARM_CORTEX_R5,
|
|
33
|
+
UC_CPU_ARM_CORTEX_R5F,
|
|
34
|
+
UC_CPU_ARM_CORTEX_A7,
|
|
35
|
+
UC_CPU_ARM_CORTEX_A8,
|
|
36
|
+
UC_CPU_ARM_CORTEX_A9,
|
|
37
|
+
UC_CPU_ARM_CORTEX_A15,
|
|
38
|
+
UC_CPU_ARM_TI925T,
|
|
39
|
+
UC_CPU_ARM_SA1100,
|
|
40
|
+
UC_CPU_ARM_SA1110,
|
|
41
|
+
UC_CPU_ARM_PXA250,
|
|
42
|
+
UC_CPU_ARM_PXA255,
|
|
43
|
+
UC_CPU_ARM_PXA260,
|
|
44
|
+
UC_CPU_ARM_PXA261,
|
|
45
|
+
UC_CPU_ARM_PXA262,
|
|
46
|
+
UC_CPU_ARM_PXA270,
|
|
47
|
+
UC_CPU_ARM_PXA270A0,
|
|
48
|
+
UC_CPU_ARM_PXA270A1,
|
|
49
|
+
UC_CPU_ARM_PXA270B0,
|
|
50
|
+
UC_CPU_ARM_PXA270B1,
|
|
51
|
+
UC_CPU_ARM_PXA270C0,
|
|
52
|
+
UC_CPU_ARM_PXA270C5,
|
|
53
|
+
UC_CPU_ARM_MAX,
|
|
54
|
+
|
|
55
|
+
UC_CPU_ARM_ENDING
|
|
56
|
+
} uc_cpu_arm;
|
|
57
|
+
|
|
58
|
+
// ARM coprocessor registers, use this with UC_ARM_REG_CP_REG to
|
|
59
|
+
// in call to uc_reg_write/read() to access the registers.
|
|
60
|
+
typedef struct uc_arm_cp_reg {
|
|
61
|
+
uint32_t cp; // The coprocessor identifier
|
|
62
|
+
uint32_t is64; // Is it a 64 bit control register
|
|
63
|
+
uint32_t sec; // Security state
|
|
64
|
+
uint32_t crn; // Coprocessor register number
|
|
65
|
+
uint32_t crm; // Coprocessor register number
|
|
66
|
+
uint32_t opc1; // Opcode1
|
|
67
|
+
uint32_t opc2; // Opcode2
|
|
68
|
+
uint64_t val; // The value to read/write
|
|
69
|
+
} uc_arm_cp_reg;
|
|
70
|
+
|
|
71
|
+
//> ARM registers
|
|
72
|
+
typedef enum uc_arm_reg {
|
|
73
|
+
UC_ARM_REG_INVALID = 0,
|
|
74
|
+
UC_ARM_REG_APSR,
|
|
75
|
+
UC_ARM_REG_APSR_NZCV,
|
|
76
|
+
UC_ARM_REG_CPSR,
|
|
77
|
+
UC_ARM_REG_FPEXC,
|
|
78
|
+
UC_ARM_REG_FPINST,
|
|
79
|
+
UC_ARM_REG_FPSCR,
|
|
80
|
+
UC_ARM_REG_FPSCR_NZCV,
|
|
81
|
+
UC_ARM_REG_FPSID,
|
|
82
|
+
UC_ARM_REG_ITSTATE,
|
|
83
|
+
UC_ARM_REG_LR,
|
|
84
|
+
UC_ARM_REG_PC,
|
|
85
|
+
UC_ARM_REG_SP,
|
|
86
|
+
UC_ARM_REG_SPSR,
|
|
87
|
+
UC_ARM_REG_D0,
|
|
88
|
+
UC_ARM_REG_D1,
|
|
89
|
+
UC_ARM_REG_D2,
|
|
90
|
+
UC_ARM_REG_D3,
|
|
91
|
+
UC_ARM_REG_D4,
|
|
92
|
+
UC_ARM_REG_D5,
|
|
93
|
+
UC_ARM_REG_D6,
|
|
94
|
+
UC_ARM_REG_D7,
|
|
95
|
+
UC_ARM_REG_D8,
|
|
96
|
+
UC_ARM_REG_D9,
|
|
97
|
+
UC_ARM_REG_D10,
|
|
98
|
+
UC_ARM_REG_D11,
|
|
99
|
+
UC_ARM_REG_D12,
|
|
100
|
+
UC_ARM_REG_D13,
|
|
101
|
+
UC_ARM_REG_D14,
|
|
102
|
+
UC_ARM_REG_D15,
|
|
103
|
+
UC_ARM_REG_D16,
|
|
104
|
+
UC_ARM_REG_D17,
|
|
105
|
+
UC_ARM_REG_D18,
|
|
106
|
+
UC_ARM_REG_D19,
|
|
107
|
+
UC_ARM_REG_D20,
|
|
108
|
+
UC_ARM_REG_D21,
|
|
109
|
+
UC_ARM_REG_D22,
|
|
110
|
+
UC_ARM_REG_D23,
|
|
111
|
+
UC_ARM_REG_D24,
|
|
112
|
+
UC_ARM_REG_D25,
|
|
113
|
+
UC_ARM_REG_D26,
|
|
114
|
+
UC_ARM_REG_D27,
|
|
115
|
+
UC_ARM_REG_D28,
|
|
116
|
+
UC_ARM_REG_D29,
|
|
117
|
+
UC_ARM_REG_D30,
|
|
118
|
+
UC_ARM_REG_D31,
|
|
119
|
+
UC_ARM_REG_FPINST2,
|
|
120
|
+
UC_ARM_REG_MVFR0,
|
|
121
|
+
UC_ARM_REG_MVFR1,
|
|
122
|
+
UC_ARM_REG_MVFR2,
|
|
123
|
+
UC_ARM_REG_Q0,
|
|
124
|
+
UC_ARM_REG_Q1,
|
|
125
|
+
UC_ARM_REG_Q2,
|
|
126
|
+
UC_ARM_REG_Q3,
|
|
127
|
+
UC_ARM_REG_Q4,
|
|
128
|
+
UC_ARM_REG_Q5,
|
|
129
|
+
UC_ARM_REG_Q6,
|
|
130
|
+
UC_ARM_REG_Q7,
|
|
131
|
+
UC_ARM_REG_Q8,
|
|
132
|
+
UC_ARM_REG_Q9,
|
|
133
|
+
UC_ARM_REG_Q10,
|
|
134
|
+
UC_ARM_REG_Q11,
|
|
135
|
+
UC_ARM_REG_Q12,
|
|
136
|
+
UC_ARM_REG_Q13,
|
|
137
|
+
UC_ARM_REG_Q14,
|
|
138
|
+
UC_ARM_REG_Q15,
|
|
139
|
+
UC_ARM_REG_R0,
|
|
140
|
+
UC_ARM_REG_R1,
|
|
141
|
+
UC_ARM_REG_R2,
|
|
142
|
+
UC_ARM_REG_R3,
|
|
143
|
+
UC_ARM_REG_R4,
|
|
144
|
+
UC_ARM_REG_R5,
|
|
145
|
+
UC_ARM_REG_R6,
|
|
146
|
+
UC_ARM_REG_R7,
|
|
147
|
+
UC_ARM_REG_R8,
|
|
148
|
+
UC_ARM_REG_R9,
|
|
149
|
+
UC_ARM_REG_R10,
|
|
150
|
+
UC_ARM_REG_R11,
|
|
151
|
+
UC_ARM_REG_R12,
|
|
152
|
+
UC_ARM_REG_S0,
|
|
153
|
+
UC_ARM_REG_S1,
|
|
154
|
+
UC_ARM_REG_S2,
|
|
155
|
+
UC_ARM_REG_S3,
|
|
156
|
+
UC_ARM_REG_S4,
|
|
157
|
+
UC_ARM_REG_S5,
|
|
158
|
+
UC_ARM_REG_S6,
|
|
159
|
+
UC_ARM_REG_S7,
|
|
160
|
+
UC_ARM_REG_S8,
|
|
161
|
+
UC_ARM_REG_S9,
|
|
162
|
+
UC_ARM_REG_S10,
|
|
163
|
+
UC_ARM_REG_S11,
|
|
164
|
+
UC_ARM_REG_S12,
|
|
165
|
+
UC_ARM_REG_S13,
|
|
166
|
+
UC_ARM_REG_S14,
|
|
167
|
+
UC_ARM_REG_S15,
|
|
168
|
+
UC_ARM_REG_S16,
|
|
169
|
+
UC_ARM_REG_S17,
|
|
170
|
+
UC_ARM_REG_S18,
|
|
171
|
+
UC_ARM_REG_S19,
|
|
172
|
+
UC_ARM_REG_S20,
|
|
173
|
+
UC_ARM_REG_S21,
|
|
174
|
+
UC_ARM_REG_S22,
|
|
175
|
+
UC_ARM_REG_S23,
|
|
176
|
+
UC_ARM_REG_S24,
|
|
177
|
+
UC_ARM_REG_S25,
|
|
178
|
+
UC_ARM_REG_S26,
|
|
179
|
+
UC_ARM_REG_S27,
|
|
180
|
+
UC_ARM_REG_S28,
|
|
181
|
+
UC_ARM_REG_S29,
|
|
182
|
+
UC_ARM_REG_S30,
|
|
183
|
+
UC_ARM_REG_S31,
|
|
184
|
+
|
|
185
|
+
UC_ARM_REG_C1_C0_2, // Depreciated, use UC_ARM_REG_CP_REG instead
|
|
186
|
+
UC_ARM_REG_C13_C0_2, // Depreciated, use UC_ARM_REG_CP_REG instead
|
|
187
|
+
UC_ARM_REG_C13_C0_3, // Depreciated, use UC_ARM_REG_CP_REG instead
|
|
188
|
+
|
|
189
|
+
UC_ARM_REG_IPSR,
|
|
190
|
+
UC_ARM_REG_MSP,
|
|
191
|
+
UC_ARM_REG_PSP,
|
|
192
|
+
UC_ARM_REG_CONTROL,
|
|
193
|
+
UC_ARM_REG_IAPSR,
|
|
194
|
+
UC_ARM_REG_EAPSR,
|
|
195
|
+
UC_ARM_REG_XPSR,
|
|
196
|
+
UC_ARM_REG_EPSR,
|
|
197
|
+
UC_ARM_REG_IEPSR,
|
|
198
|
+
UC_ARM_REG_PRIMASK,
|
|
199
|
+
UC_ARM_REG_BASEPRI,
|
|
200
|
+
UC_ARM_REG_BASEPRI_MAX,
|
|
201
|
+
UC_ARM_REG_FAULTMASK,
|
|
202
|
+
UC_ARM_REG_APSR_NZCVQ,
|
|
203
|
+
UC_ARM_REG_APSR_G,
|
|
204
|
+
UC_ARM_REG_APSR_NZCVQG,
|
|
205
|
+
UC_ARM_REG_IAPSR_NZCVQ,
|
|
206
|
+
UC_ARM_REG_IAPSR_G,
|
|
207
|
+
UC_ARM_REG_IAPSR_NZCVQG,
|
|
208
|
+
UC_ARM_REG_EAPSR_NZCVQ,
|
|
209
|
+
UC_ARM_REG_EAPSR_G,
|
|
210
|
+
UC_ARM_REG_EAPSR_NZCVQG,
|
|
211
|
+
UC_ARM_REG_XPSR_NZCVQ,
|
|
212
|
+
UC_ARM_REG_XPSR_G,
|
|
213
|
+
UC_ARM_REG_XPSR_NZCVQG,
|
|
214
|
+
UC_ARM_REG_CP_REG,
|
|
215
|
+
// A pseudo-register for fetching the exception syndrome
|
|
216
|
+
// from the CPU state. This is not a real register.
|
|
217
|
+
UC_ARM_REG_ESR,
|
|
218
|
+
UC_ARM_REG_ENDING, // <-- mark the end of the list or registers
|
|
219
|
+
|
|
220
|
+
//> alias registers
|
|
221
|
+
UC_ARM_REG_R13 = UC_ARM_REG_SP,
|
|
222
|
+
UC_ARM_REG_R14 = UC_ARM_REG_LR,
|
|
223
|
+
UC_ARM_REG_R15 = UC_ARM_REG_PC,
|
|
224
|
+
|
|
225
|
+
UC_ARM_REG_SB = UC_ARM_REG_R9,
|
|
226
|
+
UC_ARM_REG_SL = UC_ARM_REG_R10,
|
|
227
|
+
UC_ARM_REG_FP = UC_ARM_REG_R11,
|
|
228
|
+
UC_ARM_REG_IP = UC_ARM_REG_R12,
|
|
229
|
+
} uc_arm_reg;
|
|
230
|
+
|
|
231
|
+
#ifdef __cplusplus
|
|
232
|
+
}
|
|
233
|
+
#endif
|
|
234
|
+
|
|
235
|
+
#endif
|