├── .gitattributes
├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── examples
├── x86.lpi
├── x86.lpr
└── x86.lps
└── unicorn
├── Arm64Const.pas
├── ArmConst.pas
├── GenerateConsts.py
├── M68kConst.pas
├── MipsConst.pas
├── SparcConst.pas
├── UnicornConst.pas
├── Unicorn_dyn.pas
├── X86Const.pas
└── include
└── unicorn
├── arm.h
├── arm64.h
├── m68k.h
├── mips.h
├── platform.h
├── sparc.h
├── unicorn.h
└── x86.h
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [Coldzer0]
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | *.bak
3 | *.o
4 | *.ppu
5 | *.compiled
6 | *.dSYM
7 | examples/x86
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C) 2018 Coldzer0
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # unicorn-engine-pascal
2 |
3 | Pascal/Delphi language binding for the [Unicorn emulator](http://www.unicorn-engine.org/)
4 | ([GitHub](https://github.com/unicorn-engine/unicorn)).
5 |
6 | *Unicorn* is a lightweight multi-platform, multi-architecture CPU emulator framework
7 | based on [QEMU](http://www.qemu.org/).
8 |
9 | ## License
10 |
11 | `GPLv2`
12 |
13 | ## Compilers Compatibility
14 |
15 | #### Free Pascal >= v3
16 | - `Mac OS`
17 | - `Windows`
18 | - `Linux`
19 | #### Delphi
20 | - `Windows`
21 | ## Features
22 |
23 | * Same API as the C core
24 | - with some workarounds for Pascals case insensitivity:
25 |
26 |
27 | `uc_mem_write()` -> `uc_mem_write_()`, `uc_mem_read()` -> `uc_mem_read_()`
28 | - and the missing feature passing variable number of arguments to functions (`...`):
29 |
30 | i solve it by using -> `args : Array of Const;`
31 | you can pass args inside [] like :
32 | ```pascal
33 | uc_hook_add(uc, trace, UC_HOOK_INSN, @HookIn, nil, 1,0,[UC_X86_INS_IN];
34 | ```
35 | check X86 example for more info .
36 |
37 | * Multiplatform (Mac OS , Windows and Linux are tested)
38 |
39 | ## Examples
40 | * `X86` Emulate 16, 32, 64 Bit x86
41 |
42 |
43 | ## Version History
44 | * `1.1`
45 | * Add Delphi Compatibility [ Windows ]
46 | * `1.0`
47 | * this is the first version it has all APIs of UNICORN v1.0.1
48 |
49 | ## TODO
50 | - Add more Examples
51 | - Add Mac , Linux Support for Delphi
--------------------------------------------------------------------------------
/examples/x86.lpi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
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 |
--------------------------------------------------------------------------------
/examples/x86.lpr:
--------------------------------------------------------------------------------
1 | {
2 | FreePascal/Delphi bindings for the UnicornEngine Emulator Engine .
3 |
4 | Copyright(c) 2018 Coldzer0 .
5 |
6 | License : GPLv2 .
7 | }
8 |
9 | program x86;
10 |
11 | {$IFDEF FPC}
12 | {$MODE Delphi}
13 | {$ENDIF}
14 |
15 | {$ifdef MSWINDOWS}
16 | {$apptype CONSOLE}
17 | {$endif}
18 |
19 | uses
20 | SysUtils,
21 | Unicorn_dyn,
22 | UnicornConst,
23 | X86Const;
24 |
25 | const
26 | // code to be emulated .
27 | X86_CODE32: array[0..6] of Byte = ($41, $4a,$66,$0f,$ef,$c1, $00); // INC ecx; DEC edx ; PXOR xmm0, xmm1 ;
28 | X86_CODE32_JUMP: array[0..8] of Byte = ($eb, $02, $90, $90, $90, $90, $90, $90, $00); // jmp 4; nop; nop; nop; nop; nop; nop ;
29 | X86_CODE32_LOOP: array[0..4] of Byte = ($41, $4a, $eb, $fe, $00); // INC ecx; DEC edx; JMP self-loop
30 | X86_CODE32_MEM_WRITE: array[0..8] of Byte = ($89, $0d, $aa, $aa, $aa, $aa, $41, $4a, $00); // mov [0xaaaaaaaa], ecx; INC ecx; DEC edx ;
31 | X86_CODE32_MEM_READ: array[0..8] of Byte = ($8b, $0d, $aa, $aa, $aa, $aa, $41, $4a, $00); // mov ecx,[0xaaaaaaaa]; INC ecx; DEC edx ;
32 |
33 | X86_CODE32_JMP_INVALID: array[0..6] of Byte = ($e9, $e9, $ee, $ee, $41, $4a, $00); // JMP outside; INC ecx; DEC edx ;
34 | X86_CODE32_INOUT: array[0..7] of Byte = ($41, $E4, $3F, $4a, $E6, $46, $43, $00); // INC ecx; IN AL, 0x3f; DEC edx; OUT 0x46, AL; INC ebx ;
35 | X86_CODE32_INC : array[0..1] of byte = ($40,$00); // INC eax .
36 |
37 | X86_CODE64: array[0..75] of Byte = (
38 | $41, $BC, $3B, $B0, $28, $2A, $49, $0F, $C9, $90, $4D, $0F, $AD, $CF, $49, $87, $FD, $90, $48, $81,
39 | $D2, $8A, $CE, $77, $35, $48, $F7, $D9, $4D, $29, $F4, $49, $81, $C9, $F6, $8A, $C6, $53, $4D, $87,
40 | $ED, $48, $0F, $AD, $D2, $49, $F7, $D4, $48, $F7, $E1, $4D, $19, $C5, $4D, $89, $C5, $48, $F7, $D6,
41 | $41, $B8, $4F, $8D, $6B, $59, $4D, $87, $D0, $68, $6A, $1E, $09, $3C, $59, $00);
42 | X86_CODE16: array[0..2] of Byte = ($00, $00, $00); // add byte ptr [bx + si], al
43 | X86_CODE64_SYSCALL: array[0..2] of Byte = ($0f, $05, $00); // SYSCALL
44 |
45 | // memory address where emulation starts
46 | ADDRESS = $1000000;
47 |
48 | // callback for tracing basic blocks
49 | procedure HookBlock(uc: uc_engine; address: UInt64; size: Cardinal; user_data: Pointer); cdecl;
50 | begin
51 | WriteLn(Format('>>> Tracing basic block at 0x%x, block size = 0x%x', [address, size]));
52 | end;
53 |
54 | // callback for tracing instruction
55 | procedure HookCode(uc: uc_engine; address: UInt64; size: Cardinal; user_data: Pointer); cdecl;
56 | var
57 | eflags: integer;
58 | begin
59 | WriteLn(Format('>>> Tracing instruction at 0x%x, instruction size = 0x%x', [address, size]));
60 | uc_reg_read(uc, UC_X86_REG_EFLAGS, @eflags);
61 | WriteLn(Format('>>> --- EFLAGS is 0x%x', [eflags]));
62 | end;
63 |
64 | // callback for tracing instruction
65 | procedure HookCode64(uc: uc_engine; address: UInt64; size: Cardinal; user_data: Pointer); cdecl;
66 | var
67 | rip: UInt64;
68 | begin
69 | WriteLn(Format('>>> Tracing instruction at 0x%x, instruction size = 0x%x', [address, size]));
70 | uc_reg_read(uc, UC_X86_REG_RIP, @rip);
71 | WriteLn(Format('>>> --- RIP is 0x%x', [rip]));
72 | end;
73 |
74 | function HookMemInvalid(uc: uc_engine; _type: uc_mem_type; address: UInt64; size: Cardinal; value: Int64; user_data: Pointer): LongBool; cdecl;
75 | begin
76 | case _type of
77 | UC_MEM_WRITE_UNMAPPED:
78 | begin
79 | WriteLn(Format('>>> Missing memory is being WRITE at 0x%x, data size = %u, data value = 0x%x', [address, size, value]));
80 | // map this memory in with 2MB in size
81 | uc_mem_map(uc, $aaaa0000, 2 * 1024*1024, UC_PROT_ALL);
82 | // return true to indicate we want to continue
83 | Result := true;
84 | end
85 | else
86 | begin
87 | // return false to indicate we want to stop emulation
88 | Result := false;
89 | end;
90 | end;
91 | end;
92 |
93 | procedure HookMem64(uc: uc_engine; _type: uc_mem_type; address: UInt64; size: Cardinal; value: Int64; user_data: Pointer); cdecl;
94 | begin
95 | case _type of
96 | UC_MEM_READ:
97 | begin
98 | WriteLn(Format('>>> Memory is being READ at 0x%x, data size = %u', [address, size]));
99 | end;
100 | UC_MEM_WRITE:
101 | begin
102 | WriteLn(Format('>>> Memory is being WRITE at 0x%x, data size = %u, data value = 0x%x', [address, size, value]));
103 | end;
104 | end;
105 | end;
106 |
107 | // callback for IN instruction (X86).
108 | // this returns the data read from the port
109 | function HookIn(uc: uc_engine; port: UInt32; size: integer; user_data: Pointer): Uint32; cdecl;
110 | var
111 | eip: UInt32;
112 | begin
113 | uc_reg_read(uc, UC_X86_REG_EIP, @eip);
114 | WriteLn(Format('--- reading from port 0x%x, size: %u, address: 0x%x', [port, size, eip]));
115 | case size of
116 | 1:
117 | begin
118 | // read 1 byte to AL
119 | Result := $f1;
120 | end;
121 | 2:
122 | begin
123 | // read 2 byte to AX
124 | Result := $f2;
125 | end;
126 | 4:
127 | begin
128 | // read 4 byte to EAX
129 | Result := $f4;
130 | end;
131 | else
132 | begin
133 | // should never reach this
134 | Result := 0;
135 | end;
136 | end;
137 | end;
138 |
139 | // callback for OUT instruction (X86).
140 | procedure HookOut(uc: uc_engine; port: UInt32; size: integer; value: UInt32; user_data: Pointer); cdecl;
141 | var
142 | tmp, eip: UInt32;
143 | begin
144 | uc_reg_read(uc, UC_X86_REG_EIP, @eip);
145 | WriteLn(Format('--- writing to port 0x%x, size: %u, value: 0x%x, address: 0x%x', [port, size, value, eip]));
146 |
147 | // confirm that value is indeed the value of AL/AX/EAX
148 | case size of
149 | 1:
150 | begin
151 | uc_reg_read(uc, UC_X86_REG_AL, @tmp);
152 | end;
153 | 2:
154 | begin
155 | uc_reg_read(uc, UC_X86_REG_AX, @tmp);
156 | end;
157 | 4:
158 | begin
159 | uc_reg_read(uc, UC_X86_REG_EAX, @tmp);
160 | end;
161 | else
162 | begin
163 | // should never reach this
164 | Exit;
165 | end;
166 | end;
167 | WriteLn(Format('--- register value = 0x%x', [tmp]));
168 | end;
169 |
170 | // callback for SYSCALL instruction (X86).
171 | procedure HookSyscall(uc: uc_engine; user_data: Pointer); cdecl;
172 | var
173 | rax: UInt64;
174 | begin
175 | uc_reg_read(uc, UC_X86_REG_RAX, @rax);
176 | if (rax = $100) then begin
177 | rax := $200;
178 | uc_reg_write(uc, UC_X86_REG_RAX, @rax);
179 | end else
180 | WriteLn(Format('ERROR: was not expecting rax=0x%x in syscall', [rax]));
181 | end;
182 |
183 | procedure TestI386;
184 | var
185 | uc: uc_engine;
186 | err: uc_err;
187 | tmp: UInt32;
188 | trace1, trace2: uc_hook;
189 | r_ecx, r_edx: integer;
190 | r_xmm0,r_xmm1 : array [0..1] of UInt64;
191 | begin
192 | r_ecx := $1234; // ECX register
193 | r_edx := $7890; // EDX register
194 | r_xmm0[0] := $08090a0b0c0d0e0f; r_xmm0[1] := $0001020304050607;
195 | r_xmm1[0] := {%H-}$8090a0b0c0d0e0f0; r_xmm1[1] := $0010203040506070;
196 |
197 |
198 | WriteLn('Emulate i386 code');
199 |
200 | // Initialize emulator in X86-32bit mode
201 | err := uc_open(UC_ARCH_X86, UC_MODE_32, uc);
202 | if (err <> UC_ERR_OK) then begin
203 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
204 | Exit;
205 | end;
206 |
207 | // map 2MB memory for this emulation
208 | uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL);
209 |
210 | // write machine code to be emulated to memory
211 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE32, SizeOf(X86_CODE32) - 1) <> UC_ERR_OK) then begin
212 | WriteLn('Failed to write emulation code to memory, quit!');
213 | Exit;
214 | end;
215 |
216 | // initialize machine registers
217 | uc_reg_write(uc, UC_X86_REG_ECX, @r_ecx);
218 | uc_reg_write(uc, UC_X86_REG_EDX, @r_edx);
219 | uc_reg_write(uc, UC_X86_REG_XMM0, @r_xmm0);
220 | uc_reg_write(uc, UC_X86_REG_XMM1, @r_xmm1);
221 |
222 | // tracing all basic blocks with customized callback
223 | uc_hook_add(uc, trace1, UC_HOOK_BLOCK, @HookBlock, nil, 1, 0,[]);
224 |
225 | // tracing all instruction by having @begin > @end
226 | uc_hook_add(uc, trace2, UC_HOOK_CODE, @HookCode, nil, 1, 0,[]);
227 |
228 | // emulate machine code in infinite time
229 | err := uc_emu_start(uc, ADDRESS, ADDRESS + SizeOf(X86_CODE32) - 1, 0, 0);
230 | if (err <> UC_ERR_OK) then begin
231 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
232 | end;
233 |
234 | // now print out some registers
235 | WriteLn('>>> Emulation done. Below is the CPU context');
236 |
237 | uc_reg_read(uc, UC_X86_REG_ECX, @r_ecx);
238 | uc_reg_read(uc, UC_X86_REG_EDX, @r_edx);
239 | uc_reg_read(uc, UC_X86_REG_XMM0, @r_xmm0);
240 |
241 | WriteLn(Format('>>> ECX = 0x%x', [r_ecx]));
242 | WriteLn(Format('>>> EDX = 0x%x', [r_edx]));
243 | WriteLn(Format('>>> XMM0 = 0x%s%s', [IntToHex(r_xmm0[1],16),IntToHex(r_xmm0[0],16)]));
244 |
245 | // read from memory
246 | err := uc_mem_read_(uc, ADDRESS, @tmp, SizeOf(tmp));
247 | if (err = UC_ERR_OK) then begin
248 | WriteLn(Format('>>> Read 4 bytes from [0x%x] = 0x%x', [ADDRESS, tmp]));
249 | end else begin
250 | WriteLn(Format('>>> Failed to read 4 bytes from [0x%x], err = %u: %s', [ADDRESS, err, uc_strerror(err)]));
251 | end;
252 |
253 | uc_close(uc);
254 | end;
255 |
256 | procedure test_i386_map_ptr();
257 | var
258 | uc: uc_engine;
259 | err: uc_err;
260 | tmp: UInt32;
261 | trace1, trace2: uc_hook;
262 | mem : Pointer;
263 | r_ecx, r_edx: integer;
264 | r_xmm0,r_xmm1 : array [0..1] of UInt64;
265 | begin
266 | r_ecx := $1234; // ECX register
267 | r_edx := $7890; // EDX register
268 | r_xmm0[0] := $08090a0b0c0d0e0f; r_xmm0[1] := $0001020304050607;
269 | r_xmm1[0] := {%H-}$8090a0b0c0d0e0f0; r_xmm1[1] := $0010203040506070;
270 |
271 |
272 | WriteLn('===================================');
273 | WriteLn('Emulate i386 code - use uc_mem_map_ptr()');
274 |
275 | // Initialize emulator in X86-32bit mode
276 | err := uc_open(UC_ARCH_X86, UC_MODE_32, uc);
277 | if (err <> UC_ERR_OK) then begin
278 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
279 | Exit;
280 | end;
281 |
282 | mem := AllocMem(2 * 1024 * 1024);
283 | if mem = nil then
284 | begin
285 | Writeln('Failed to Allocmem');
286 | uc_close(uc);
287 | exit;
288 | end;
289 |
290 | err := uc_mem_map_ptr(uc,ADDRESS,2 * 1024 * 1024,UC_PROT_ALL,mem);
291 | if err <> UC_ERR_OK then
292 | begin
293 | WriteLn(Format('Failed on uc_mem_map_ptr() with error returned: %u - %s', [err,uc_strerror(err)]));
294 | FreeMem(mem,2 * 1024 * 1024);
295 | uc_close(uc);
296 | Exit;
297 | end;
298 |
299 | Move(X86_CODE32,mem^,SizeOf(X86_CODE32)-1);
300 | if CompareMem(mem,@X86_CODE32,SizeOf(X86_CODE32)-1) <> true then
301 | begin
302 | Writeln('Failed to write emulation code to memory, quit!');
303 | Freemem(mem,2 * 1024 * 1024);
304 | uc_close(uc);
305 | exit;
306 | end;
307 | uc_reg_write(uc, UC_X86_REG_ECX, @r_ecx);
308 | uc_reg_write(uc, UC_X86_REG_EDX, @r_edx);
309 | uc_reg_write(uc, UC_X86_REG_XMM0, @r_xmm0);
310 | uc_reg_write(uc, UC_X86_REG_XMM1, @r_xmm1);
311 |
312 | // tracing all basic blocks with customized callback
313 | uc_hook_add(uc, trace1, UC_HOOK_BLOCK, @HookBlock, nil, 1, 0,[]);
314 |
315 | // tracing all instruction by having @begin > @end .
316 | uc_hook_add(uc, trace2, UC_HOOK_CODE, @HookCode, nil, 1, 0,[]);
317 |
318 | // emulate machine code in infinite time
319 | err := uc_emu_start(uc, ADDRESS, ADDRESS + sizeof(X86_CODE32) - 1, 0, 0);
320 | if err <> UC_ERR_OK then
321 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
322 |
323 | Writeln('>>> Emulation done. Below is the CPU context');
324 |
325 | uc_reg_read(uc, UC_X86_REG_ECX, @r_ecx);
326 | uc_reg_read(uc, UC_X86_REG_EDX, @r_edx);
327 | uc_reg_read(uc, UC_X86_REG_XMM0, @r_xmm0);
328 |
329 | WriteLn(Format('>>> ECX = 0x%x', [r_ecx]));
330 | WriteLn(Format('>>> EDX = 0x%x', [r_edx]));
331 | WriteLn(Format('>>> XMM0 = 0x%s%s', [IntToHex(r_xmm0[1],16),IntToHex(r_xmm0[0],16)]));
332 |
333 | // read from memory
334 | err := uc_mem_read_(uc, ADDRESS, @tmp, SizeOf(tmp));
335 | if (err = UC_ERR_OK) then begin
336 | WriteLn(Format('>>> Read 4 bytes from [0x%x] = 0x%x', [ADDRESS, tmp]));
337 | end else begin
338 | WriteLn(Format('>>> Failed to read 4 bytes from [0x%x], err = %u: %s', [ADDRESS, err, uc_strerror(err)]));
339 | end;
340 |
341 | Freemem(mem,2 * 1024 * 1024);
342 | uc_close(uc);
343 | end;
344 |
345 | procedure TestI386Jump;
346 | var
347 | uc: uc_engine;
348 | err: uc_err;
349 | trace1, trace2: uc_hook;
350 | begin
351 | WriteLn('===================================');
352 | WriteLn('Emulate i386 code with jump');
353 |
354 | // Initialize emulator in X86-32bit mode
355 | err := uc_open(UC_ARCH_X86, UC_MODE_32, uc);
356 | if (err <> UC_ERR_OK) then begin
357 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
358 | Exit;
359 | end;
360 |
361 | // map 2MB memory for this emulation
362 | uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL);
363 |
364 | // write machine code to be emulated to memory
365 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE32_JUMP, SizeOf(X86_CODE32_JUMP) - 1) <> UC_ERR_OK) then begin
366 | WriteLn('Failed to write emulation code to memory, quit!');
367 | Exit;
368 | end;
369 |
370 | // tracing 1 basic block with customized callback
371 | uc_hook_add(uc, trace1, UC_HOOK_BLOCK, @HookBlock, nil, ADDRESS, ADDRESS,[]);
372 |
373 | // tracing 1 instruction at ADDRESS
374 | uc_hook_add(uc, trace2, UC_HOOK_CODE, @HookCode, nil, ADDRESS, ADDRESS,[]);
375 |
376 | // emulate machine code in infinite time
377 | err := uc_emu_start(uc, ADDRESS, ADDRESS + SizeOf(X86_CODE32_JUMP) - 1, 0, 0);
378 | if (err <> UC_ERR_OK) then begin
379 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
380 | end;
381 |
382 | WriteLn('>>> Emulation done.');
383 | uc_close(uc);
384 | end;
385 |
386 | procedure TestI386Loop;
387 | var
388 | uc: uc_engine;
389 | err: uc_err;
390 | r_ecx, r_edx: integer;
391 | begin
392 | r_ecx := $1234; // ECX register
393 | r_edx := $7890; // EDX register
394 | WriteLn('===================================');
395 | WriteLn('Emulate i386 code that loop forever');
396 |
397 | // Initialize emulator in X86-32bit mode
398 | err := uc_open(UC_ARCH_X86, UC_MODE_32, uc);
399 | if (err <> UC_ERR_OK) then begin
400 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
401 | Exit;
402 | end;
403 |
404 | // map 2MB memory for this emulation
405 | uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL);
406 |
407 | // write machine code to be emulated to memory
408 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE32_LOOP, SizeOf(X86_CODE32_LOOP) - 1) <> UC_ERR_OK) then begin
409 | WriteLn('Failed to write emulation code to memory, quit!');
410 | Exit;
411 | end;
412 |
413 | // initialize machine registers
414 | uc_reg_write(uc, UC_X86_REG_ECX, @r_ecx);
415 | uc_reg_write(uc, UC_X86_REG_EDX, @r_edx);
416 |
417 | // emulate machine code in 2 seconds, so we can quit even
418 | // if the code loops
419 | err := uc_emu_start(uc, ADDRESS, ADDRESS + SizeOf(X86_CODE32_LOOP) - 1, 2 * UC_SECOND_SCALE, 0);
420 | if (err <> UC_ERR_OK) then begin
421 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
422 | end;
423 |
424 | // now print out some registers
425 | WriteLn('>>> Emulation done. Below is the CPU context');
426 |
427 | uc_reg_read(uc, UC_X86_REG_ECX, @r_ecx);
428 | uc_reg_read(uc, UC_X86_REG_EDX, @r_edx);
429 | WriteLn(Format('>>> ECX = 0x%x', [r_ecx]));
430 | WriteLn(Format('>>> EDX = 0x%x', [r_edx]));
431 |
432 | uc_close(uc);
433 | end;
434 |
435 | procedure TestI386InvalidMemRead;
436 | var
437 | uc: uc_engine;
438 | err: uc_err;
439 | trace1, trace2: uc_hook;
440 | r_ecx, r_edx: integer;
441 | begin
442 | r_ecx := $1234; // ECX register
443 | r_edx := $7890; // EDX register
444 | WriteLn('===================================');
445 | WriteLn('Emulate i386 code that read from invalid memory');
446 |
447 | // Initialize emulator in X86-32bit mode
448 | err := uc_open(UC_ARCH_X86, UC_MODE_32, uc);
449 | if (err <> UC_ERR_OK) then begin
450 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
451 | Exit;
452 | end;
453 |
454 | // map 2MB memory for this emulation
455 | uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL);
456 |
457 | // write machine code to be emulated to memory
458 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE32_MEM_READ, SizeOf(X86_CODE32_MEM_READ) - 1) <> UC_ERR_OK) then begin
459 | WriteLn('Failed to write emulation code to memory, quit!');
460 | uc_close(uc);
461 | Exit;
462 | end;
463 |
464 | // initialize machine registers
465 | uc_reg_write(uc, UC_X86_REG_ECX, @r_ecx);
466 | uc_reg_write(uc, UC_X86_REG_EDX, @r_edx);
467 |
468 | // tracing all basic blocks with customized callback
469 | uc_hook_add(uc, trace1, UC_HOOK_BLOCK, @HookBlock, nil, 1, 0,[]);
470 |
471 | // tracing all instruction by having @begin > @end
472 | uc_hook_add(uc, trace2, UC_HOOK_CODE, @HookCode, nil, 1, 0,[]);
473 |
474 | err := uc_emu_start(uc, ADDRESS, ADDRESS + SizeOf(X86_CODE32_MEM_READ) - 1, 0, 0);
475 | if (err <> UC_ERR_OK) then begin
476 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
477 | end;
478 |
479 | // now print out some registers
480 | WriteLn('>>> Emulation done. Below is the CPU context');
481 |
482 | uc_reg_read(uc, UC_X86_REG_ECX, @r_ecx);
483 | uc_reg_read(uc, UC_X86_REG_EDX, @r_edx);
484 | WriteLn(Format('>>> ECX = 0x%x', [r_ecx]));
485 | WriteLn(Format('>>> EDX = 0x%x', [r_edx]));
486 |
487 | uc_close(uc);
488 | end;
489 |
490 | procedure TestI386InvalidMemWrite;
491 | var
492 | uc: uc_engine;
493 | err: uc_err;
494 | trace1, trace2, trace3: uc_hook;
495 | r_ecx, r_edx: integer;
496 | tmp: UInt32;
497 | begin
498 | r_ecx := $1234; // ECX register
499 | r_edx := $7890; // EDX register
500 | WriteLn('===================================');
501 | WriteLn('Emulate i386 code that write to invalid memory');
502 |
503 | // Initialize emulator in X86-32bit mode
504 | err := uc_open(UC_ARCH_X86, UC_MODE_32, uc);
505 | if (err <> UC_ERR_OK) then begin
506 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
507 | Exit;
508 | end;
509 |
510 | // map 2MB memory for this emulation
511 | uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL);
512 |
513 | // write machine code to be emulated to memory
514 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE32_MEM_WRITE, SizeOf(X86_CODE32_MEM_WRITE) - 1) <> UC_ERR_OK) then begin
515 | WriteLn('Failed to write emulation code to memory, quit!');
516 | Exit;
517 | end;
518 |
519 | // initialize machine registers
520 | uc_reg_write(uc, UC_X86_REG_ECX, @r_ecx);
521 | uc_reg_write(uc, UC_X86_REG_EDX, @r_edx);
522 |
523 | // tracing all basic blocks with customized callback
524 | uc_hook_add(uc, trace1, UC_HOOK_BLOCK, @HookBlock, nil, 1, 0,[]);
525 |
526 | // tracing all instruction by having @begin > @end
527 | uc_hook_add(uc, trace2, UC_HOOK_CODE, @HookCode, nil, 1, 0,[]);
528 |
529 | // intercept invalid memory events
530 | uc_hook_add(uc, trace3, UC_HOOK_MEM_READ_UNMAPPED or UC_HOOK_MEM_WRITE_UNMAPPED, @HookMemInvalid, nil,1,0,[]);
531 |
532 | err := uc_emu_start(uc, ADDRESS, ADDRESS + SizeOf(X86_CODE32_MEM_WRITE) - 1, 0, 0);
533 | if (err <> UC_ERR_OK) then begin
534 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
535 | end;
536 |
537 | // now print out some registers
538 | WriteLn('>>> Emulation done. Below is the CPU context');
539 |
540 | uc_reg_read(uc, UC_X86_REG_ECX, @r_ecx);
541 | uc_reg_read(uc, UC_X86_REG_EDX, @r_edx);
542 | WriteLn(Format('>>> ECX = 0x%x', [r_ecx]));
543 | WriteLn(Format('>>> EDX = 0x%x', [r_edx]));
544 |
545 | // read from memory
546 | err := uc_mem_read_(uc, $aaaaaaaa, @tmp, SizeOf(tmp));
547 | if (err = UC_ERR_OK) then
548 | WriteLn(Format('>>> Read 4 bytes from [0x%x] = 0x%x', [$aaaaaaaa, tmp]))
549 | else
550 | WriteLn(Format('>>> Failed to read 4 bytes from [0x%x]', [$aaaaaaaa]));
551 |
552 | err := uc_mem_read_(uc, $ffffffaa, @tmp, SizeOf(tmp));
553 | if (err = UC_ERR_OK) then
554 | WriteLn(Format('>>> Read 4 bytes from [0x%x] = 0x%x', [$ffffffaa, tmp]))
555 | else
556 | WriteLn(Format('>>> Failed to read 4 bytes from [0x%x]', [$ffffffaa]));
557 |
558 | uc_close(uc);
559 | end;
560 |
561 | procedure TestI386JumpInvalid;
562 | var
563 | uc: uc_engine;
564 | err: uc_err;
565 | trace1, trace2: uc_hook;
566 | r_ecx, r_edx: integer;
567 | begin
568 | r_ecx := $1234; // ECX register
569 | r_edx := $7890; // EDX register
570 | WriteLn('===================================');
571 | WriteLn('Emulate i386 code that jumps to invalid memory');
572 |
573 | // Initialize emulator in X86-32bit mode
574 | err := uc_open(UC_ARCH_X86, UC_MODE_32, uc);
575 | if (err <> UC_ERR_OK) then begin
576 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
577 | Exit;
578 | end;
579 |
580 | // map 2MB memory for this emulation
581 | uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL);
582 |
583 | // write machine code to be emulated to memory
584 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE32_JMP_INVALID, SizeOf(X86_CODE32_JMP_INVALID) - 1) <> UC_ERR_OK) then begin
585 | WriteLn('Failed to write emulation code to memory, quit!');
586 | uc_close(uc);
587 | Exit;
588 | end;
589 |
590 | // initialize machine registers
591 | uc_reg_write(uc, UC_X86_REG_ECX, @r_ecx);
592 | uc_reg_write(uc, UC_X86_REG_EDX, @r_edx);
593 |
594 | // tracing all basic blocks with customized callback
595 | uc_hook_add(uc, trace1, UC_HOOK_BLOCK, @HookBlock, nil, 1, 0,[]);
596 |
597 | // tracing all instruction by having @begin > @end
598 | uc_hook_add(uc, trace2, UC_HOOK_CODE, @HookCode, nil, 1, 0,[]);
599 |
600 | err := uc_emu_start(uc, ADDRESS, ADDRESS + SizeOf(X86_CODE32_JMP_INVALID) - 1, 0, 0);
601 | if (err <> UC_ERR_OK) then begin
602 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
603 | end;
604 |
605 | // now print out some registers
606 | WriteLn('>>> Emulation done. Below is the CPU context');
607 |
608 | uc_reg_read(uc, UC_X86_REG_ECX, @r_ecx);
609 | uc_reg_read(uc, UC_X86_REG_EDX, @r_edx);
610 | WriteLn(Format('>>> ECX = 0x%x', [r_ecx]));
611 | WriteLn(Format('>>> EDX = 0x%x', [r_edx]));
612 |
613 | uc_close(uc);
614 | end;
615 |
616 | procedure TestI386Inout;
617 | var
618 | uc: uc_engine;
619 | err: uc_err;
620 | trace1, trace2, trace3, trace4: uc_hook;
621 | r_ecx, r_edx: integer;
622 | begin
623 | r_ecx := $1234; // ECX register
624 | r_edx := $7890; // EDX register
625 | WriteLn('===================================');
626 | WriteLn('Emulate i386 code with IN/OUT instructions');
627 |
628 | // Initialize emulator in X86-32bit mode
629 | err := uc_open(UC_ARCH_X86, UC_MODE_32, uc);
630 | if (err <> UC_ERR_OK) then begin
631 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
632 | Exit;
633 | end;
634 |
635 | // map 2MB memory for this emulation
636 | uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL);
637 |
638 | // write machine code to be emulated to memory
639 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE32_INOUT, SizeOf(X86_CODE32_INOUT) - 1) <> UC_ERR_OK) then begin
640 | WriteLn('Failed to write emulation code to memory, quit!');
641 | Exit;
642 | end;
643 |
644 | // initialize machine registers
645 | uc_reg_write(uc, UC_X86_REG_ECX, @r_ecx);
646 | uc_reg_write(uc, UC_X86_REG_EDX, @r_edx);
647 |
648 | // tracing all basic blocks with customized callback
649 | uc_hook_add(uc, trace1, UC_HOOK_BLOCK, @HookBlock, nil, 1, 0,[]);
650 |
651 | // tracing all instruction by having @begin > @end
652 | uc_hook_add(uc, trace2, UC_HOOK_CODE, @HookCode, nil, 1, 0,[]);
653 |
654 | // uc IN instruction
655 | uc_hook_add(uc, trace3, UC_HOOK_INSN, @HookIn, nil, 1,0,[UC_X86_INS_IN]);
656 | // uc OUT instruction
657 | uc_hook_add(uc, trace4, UC_HOOK_INSN, @HookOut, nil, 1,0,[UC_X86_INS_OUT]);
658 |
659 | err := uc_emu_start(uc, ADDRESS, ADDRESS + SizeOf(X86_CODE32_INOUT) - 1, 0, 0);
660 | if (err <> UC_ERR_OK) then begin
661 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
662 | end;
663 |
664 | // now print out some registers
665 | WriteLn('>>> Emulation done. Below is the CPU context');
666 |
667 | uc_reg_read(uc, UC_X86_REG_ECX, @r_ecx);
668 | uc_reg_read(uc, UC_X86_REG_EDX, @r_edx);
669 | WriteLn(Format('>>> ECX = 0x%x', [r_ecx]));
670 | WriteLn(Format('>>> EDX = 0x%x', [r_edx]));
671 |
672 | uc_close(uc);
673 | end;
674 |
675 | procedure test_i386_context_save();
676 | var
677 | uc: uc_engine;
678 | context : uc_context;
679 | err: uc_err;
680 | r_eax : integer;
681 | begin
682 | r_eax := 1; // EAX register
683 | WriteLn('===================================');
684 | WriteLn('Emulate i386 code - Save/restore CPU context in opaque blob');
685 |
686 | // Initialize emulator in X86-32bit mode
687 | err := uc_open(UC_ARCH_X86, UC_MODE_32, uc);
688 | if (err <> UC_ERR_OK) then begin
689 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
690 | Exit;
691 | end;
692 |
693 | uc_mem_map(uc,ADDRESS,8 * 1024 , UC_PROT_ALL);
694 |
695 | // write machine code to be emulated to memory
696 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE32_INC, SizeOf(X86_CODE32_INC) - 1) <> UC_ERR_OK) then begin
697 | WriteLn('Failed to write emulation code to memory, quit!');
698 | uc_close(uc);
699 | Exit;
700 | end;
701 | // initialize machine registers
702 | uc_reg_write(uc, UC_X86_REG_EAX, @r_eax);
703 |
704 | // emulate machine code in infinite time
705 | writeln('>>> Running emulation for the first time');
706 | err := uc_emu_start(uc, ADDRESS, ADDRESS + sizeof(X86_CODE32_INC) - 1, 0, 0);
707 | if (err <> UC_ERR_OK) then begin
708 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
709 | end;
710 |
711 | Writeln('>>> Emulation done. Below is the CPU context');
712 |
713 | uc_reg_read(uc, UC_X86_REG_EAX, @r_eax);
714 | WriteLn(Format('>>> EAX = 0x%x', [r_eax]));
715 |
716 | Writeln('>>> Saving CPU context');
717 |
718 | err := uc_context_alloc(uc,context);
719 | if (err <> UC_ERR_OK) then begin
720 | WriteLn(Format('Failed on uc_context_alloc() with error returned %u : %s', [err, uc_strerror(err)]));
721 | exit;
722 | end;
723 |
724 | err := uc_context_save(uc, context);
725 | if (err <> UC_ERR_OK) then begin
726 | WriteLn(Format('Failed on uc_context_save() with error returned %u : %s', [err, uc_strerror(err)]));
727 | exit;
728 | end;
729 |
730 | Writeln('>>> Running emulation for the second time');
731 |
732 | err := uc_emu_start(uc, ADDRESS, ADDRESS + sizeof(X86_CODE32_INC) - 1, 0, 0);
733 | if (err <> UC_ERR_OK) then begin
734 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
735 | end;
736 |
737 | Writeln('>>> Emulation done. Below is the CPU context');
738 |
739 | uc_reg_read(uc, UC_X86_REG_EAX, @r_eax);
740 | WriteLn(Format('>>> EAX = 0x%x', [r_eax]));
741 |
742 | err := uc_context_restore(uc, context);
743 | if (err <> UC_ERR_OK) then begin
744 | WriteLn(Format('Failed on uc_context_restore() with error returned %u: %s', [err, uc_strerror(err)]));
745 | exit;
746 | end;
747 |
748 | Writeln('>>> CPU context restored. Below is the CPU context');
749 |
750 | uc_reg_read(uc, UC_X86_REG_EAX, @r_eax);
751 | WriteLn(Format('>>> EAX = 0x%x', [r_eax]));
752 |
753 | err := uc_free(context);
754 | if (err <> UC_ERR_OK) then begin
755 | WriteLn(Format('Failed on uc_free() with error returned %u: %s', [err, uc_strerror(err)]));
756 | exit;
757 | end;
758 |
759 | uc_close(uc);
760 | end;
761 |
762 | procedure TestX86_64;
763 | var
764 | uc: uc_engine;
765 | err: uc_err;
766 | trace1, trace2, trace3, trace4: uc_hook;
767 | rax, rbx, rcx, rdx, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15, rsp: UInt64;
768 | begin
769 | rax := $71f3029efd49d41d;
770 | rbx := $d87b45277f133ddb;
771 | rcx := $ab40d1ffd8afc461;
772 | rdx := $919317b4a733f01;
773 | rsi := $4c24e753a17ea358;
774 | rdi := $e509a57d2571ce96;
775 | r8 := $ea5b108cc2b9ab1f;
776 | r9 := $19ec097c8eb618c1;
777 | r10 := $ec45774f00c5f682;
778 | r11 := $e17e9dbec8c074aa;
779 | r12 := $80f86a8dc0f6d457;
780 | r13 := $48288ca5671c5492;
781 | r14 := $595f72f6e4017f6e;
782 | r15 := $1efd97aea331cccc;
783 |
784 | rsp := ADDRESS + $200000;
785 |
786 | WriteLn('Emulate x86_64 code');
787 |
788 | // Initialize emulator in X86-64bit mode
789 | err := uc_open(UC_ARCH_X86, UC_MODE_64, uc);
790 | if (err <> UC_ERR_OK) then begin
791 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
792 | Exit;
793 | end;
794 |
795 | // map 2MB memory for this emulation
796 | uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL);
797 |
798 | // write machine code to be emulated to memory
799 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE64, SizeOf(X86_CODE64) - 1) <> UC_ERR_OK) then begin
800 | WriteLn('Failed to write emulation code to memory, quit!');
801 | Exit;
802 | end;
803 |
804 | // initialize machine registers
805 | uc_reg_write(uc, UC_X86_REG_RSP, @rsp);
806 |
807 | uc_reg_write(uc, UC_X86_REG_RAX, @rax);
808 | uc_reg_write(uc, UC_X86_REG_RBX, @rbx);
809 | uc_reg_write(uc, UC_X86_REG_RCX, @rcx);
810 | uc_reg_write(uc, UC_X86_REG_RDX, @rdx);
811 | uc_reg_write(uc, UC_X86_REG_RSI, @rsi);
812 | uc_reg_write(uc, UC_X86_REG_RDI, @rdi);
813 | uc_reg_write(uc, UC_X86_REG_R8, @r8);
814 | uc_reg_write(uc, UC_X86_REG_R9, @r9);
815 | uc_reg_write(uc, UC_X86_REG_R10, @r10);
816 | uc_reg_write(uc, UC_X86_REG_R11, @r11);
817 | uc_reg_write(uc, UC_X86_REG_R12, @r12);
818 | uc_reg_write(uc, UC_X86_REG_R13, @r13);
819 | uc_reg_write(uc, UC_X86_REG_R14, @r14);
820 | uc_reg_write(uc, UC_X86_REG_R15, @r15);
821 |
822 | // tracing all basic blocks with customized callback
823 | uc_hook_add(uc, trace1, UC_HOOK_BLOCK, @HookBlock, nil, 1, 0,[]);
824 |
825 | // tracing all instruction by having @begin > @end
826 | uc_hook_add(uc, trace2, UC_HOOK_CODE, @HookCode64, nil, ADDRESS, ADDRESS + 20,[]);
827 |
828 | // tracing all memory WRITE access (with @begin > @end)
829 | uc_hook_add(uc, trace3, UC_HOOK_MEM_WRITE, @HookMem64, nil, 1, 0,[]);
830 | // tracing all memory READ access (with @begin > @end)
831 | uc_hook_add(uc, trace4, UC_HOOK_MEM_READ, @HookMem64, nil, 1, 0,[]);
832 |
833 | err := uc_emu_start(uc, ADDRESS, ADDRESS + SizeOf(X86_CODE64) - 1, 0, 0);
834 | if (err <> UC_ERR_OK) then begin
835 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
836 | end;
837 |
838 | // now print out some registers
839 | WriteLn('>>> Emulation done. Below is the CPU context');
840 |
841 | uc_reg_read(uc, UC_X86_REG_RAX, @rax);
842 | uc_reg_read(uc, UC_X86_REG_RBX, @rbx);
843 | uc_reg_read(uc, UC_X86_REG_RCX, @rcx);
844 | uc_reg_read(uc, UC_X86_REG_RDX, @rdx);
845 | uc_reg_read(uc, UC_X86_REG_RSI, @rsi);
846 | uc_reg_read(uc, UC_X86_REG_RDI, @rdi);
847 | uc_reg_read(uc, UC_X86_REG_R8, @r8);
848 | uc_reg_read(uc, UC_X86_REG_R9, @r9);
849 | uc_reg_read(uc, UC_X86_REG_R10, @r10);
850 | uc_reg_read(uc, UC_X86_REG_R11, @r11);
851 | uc_reg_read(uc, UC_X86_REG_R12, @r12);
852 | uc_reg_read(uc, UC_X86_REG_R13, @r13);
853 | uc_reg_read(uc, UC_X86_REG_R14, @r14);
854 | uc_reg_read(uc, UC_X86_REG_R15, @r15);
855 |
856 | WriteLn(Format('>>> RAX = 0x%.16x', [rax]));
857 | WriteLn(Format('>>> RBX = 0x%.16x', [rbx]));
858 | WriteLn(Format('>>> RCX = 0x%.16x', [rcx]));
859 | WriteLn(Format('>>> RDX = 0x%.16x', [rdx]));
860 | WriteLn(Format('>>> RSI = 0x%.16x', [rsi]));
861 | WriteLn(Format('>>> RDI = 0x%.16x', [rdi]));
862 | WriteLn(Format('>>> R8 = 0x%.16x', [r8]));
863 | WriteLn(Format('>>> R9 = 0x%.16x', [r9]));
864 | WriteLn(Format('>>> R10 = 0x%.16x', [r10]));
865 | WriteLn(Format('>>> R11 = 0x%.16x', [r11]));
866 | WriteLn(Format('>>> R12 = 0x%.16x', [r12]));
867 | WriteLn(Format('>>> R13 = 0x%.16x', [r13]));
868 | WriteLn(Format('>>> R14 = 0x%.16x', [r14]));
869 | WriteLn(Format('>>> R15 = 0x%.16x', [r15]));
870 |
871 | uc_close(uc);
872 | end;
873 |
874 | procedure TestX86_64Syscall;
875 | var
876 | uc: uc_engine;
877 | err: uc_err;
878 | trace1: uc_hook;
879 | rax: UInt64;
880 | begin
881 | rax := $100;
882 | WriteLn('===================================');
883 | WriteLn('Emulate x86_64 code with "syscall" instruction');
884 |
885 | // Initialize emulator in X86-64bit mode
886 | err := uc_open(UC_ARCH_X86, UC_MODE_64, uc);
887 | if (err <> UC_ERR_OK) then begin
888 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
889 | Exit;
890 | end;
891 |
892 | // map 2MB memory for this emulation
893 | uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL);
894 |
895 | // write machine code to be emulated to memory
896 | if (uc_mem_write_(uc, ADDRESS, @X86_CODE64_SYSCALL, SizeOf(X86_CODE64_SYSCALL) - 1) <> UC_ERR_OK) then begin
897 | WriteLn('Failed to write emulation code to memory, quit!');
898 | Exit;
899 | end;
900 |
901 | // hook interrupts for syscall
902 | uc_hook_add(uc, trace1, UC_HOOK_INSN, @HookSyscall, nil, 1 , 0 , [UC_X86_INS_SYSCALL]);
903 |
904 | // initialize machine registers
905 | uc_reg_write(uc, UC_X86_REG_RAX, @rax);
906 |
907 | // emulate machine code in infinite time (last param = 0), or when
908 | // finishing all the code.
909 | err := uc_emu_start(uc, ADDRESS, ADDRESS + SizeOf(X86_CODE64_SYSCALL) - 1, 0, 0);
910 | if (err <> UC_ERR_OK) then begin
911 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
912 | end;
913 |
914 | // now print out some registers
915 | WriteLn('>>> Emulation done. Below is the CPU context');
916 |
917 | uc_reg_read(uc, UC_X86_REG_RAX, @rax);
918 | WriteLn(Format('>>> RAX = 0x%x', [rax]));
919 |
920 | uc_close(uc);
921 | end;
922 |
923 | procedure TestX86_16;
924 | var
925 | uc: uc_engine;
926 | err: uc_err;
927 | tmp: Word;
928 | eax, ebx, esi: UInt32;
929 | begin
930 | eax := 7;
931 | ebx := 5;
932 | esi := 6;
933 |
934 | WriteLn('Emulate x86 16-bit code');
935 |
936 | // Initialize emulator in X86-16bit mode
937 | err := uc_open(UC_ARCH_X86, UC_MODE_16, uc);
938 | if (err <> UC_ERR_OK) then begin
939 | WriteLn(Format('Failed on uc_open() with error returned: %u', [err]));
940 | Exit;
941 | end;
942 |
943 | // map 8KB memory for this emulation
944 | uc_mem_map(uc, 0, 8 * 1024, UC_PROT_ALL);
945 |
946 | // write machine code to be emulated to memory
947 | if (uc_mem_write_(uc, 0, @X86_CODE16, SizeOf(X86_CODE16) - 1) <> UC_ERR_OK) then begin
948 | WriteLn('Failed to write emulation code to memory, quit!');
949 | Exit;
950 | end;
951 |
952 | // initialize machine registers
953 | uc_reg_write(uc, UC_X86_REG_EAX, @eax);
954 | uc_reg_write(uc, UC_X86_REG_EBX, @ebx);
955 | uc_reg_write(uc, UC_X86_REG_ESI, @esi);
956 |
957 | // emulate machine code in infinite time (last param = 0), or when
958 | // finishing all the code.
959 | err := uc_emu_start(uc, 0, SizeOf(X86_CODE16) - 1, 0, 0);
960 | if (err <> UC_ERR_OK) then begin
961 | WriteLn(Format('Failed on uc_emu_start() with error returned %u: %s', [err, uc_strerror(err)]));
962 | end;
963 |
964 | // now print out some registers
965 | WriteLn('>>> Emulation done. Below is the CPU context');
966 |
967 | err := uc_mem_read_(uc, 11, @tmp, 1);
968 | if (err = UC_ERR_OK) then
969 | WriteLn(Format('>>> Read 1 bytes from [0x%x] = 0x%x', [11, tmp]))
970 | else
971 | WriteLn(Format('>>> Failed to read 1 bytes from [0x%x]', [11]));
972 |
973 | uc_close(uc);
974 | end;
975 |
976 | begin
977 | if ParamCount > 0 then begin
978 | if (ParamStr(1) = '-32') then begin
979 | TestI386;
980 | test_i386_map_ptr;
981 | test_i386_context_save;
982 | TestI386Inout;
983 | TestI386Jump;
984 | TestI386Loop;
985 | TestI386InvalidMemRead;
986 | TestI386InvalidMemWrite;
987 | TestI386JumpInvalid;
988 | end;
989 |
990 | if (ParamStr(1) = '-64') then begin
991 | TestX86_64;
992 | TestX86_64Syscall;
993 | end;
994 |
995 | if (ParamStr(1) = '-16') then begin
996 | TestX86_16;
997 | end;
998 |
999 | end else
1000 | WriteLn(#10'Syntax: SampleX86 <-16|-32|-64>'#10);
1001 | end.
1002 |
--------------------------------------------------------------------------------
/examples/x86.lps:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
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 |
--------------------------------------------------------------------------------
/unicorn/Arm64Const.pas:
--------------------------------------------------------------------------------
1 | // For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
2 |
3 | unit Arm64Const;
4 |
5 | interface
6 |
7 | const
8 | // ARM64 registers
9 |
10 | UC_ARM64_REG_INVALID = 0;
11 | UC_ARM64_REG_X29 = 1;
12 | UC_ARM64_REG_X30 = 2;
13 | UC_ARM64_REG_NZCV = 3;
14 | UC_ARM64_REG_SP = 4;
15 | UC_ARM64_REG_WSP = 5;
16 | UC_ARM64_REG_WZR = 6;
17 | UC_ARM64_REG_XZR = 7;
18 | UC_ARM64_REG_B0 = 8;
19 | UC_ARM64_REG_B1 = 9;
20 | UC_ARM64_REG_B2 = 10;
21 | UC_ARM64_REG_B3 = 11;
22 | UC_ARM64_REG_B4 = 12;
23 | UC_ARM64_REG_B5 = 13;
24 | UC_ARM64_REG_B6 = 14;
25 | UC_ARM64_REG_B7 = 15;
26 | UC_ARM64_REG_B8 = 16;
27 | UC_ARM64_REG_B9 = 17;
28 | UC_ARM64_REG_B10 = 18;
29 | UC_ARM64_REG_B11 = 19;
30 | UC_ARM64_REG_B12 = 20;
31 | UC_ARM64_REG_B13 = 21;
32 | UC_ARM64_REG_B14 = 22;
33 | UC_ARM64_REG_B15 = 23;
34 | UC_ARM64_REG_B16 = 24;
35 | UC_ARM64_REG_B17 = 25;
36 | UC_ARM64_REG_B18 = 26;
37 | UC_ARM64_REG_B19 = 27;
38 | UC_ARM64_REG_B20 = 28;
39 | UC_ARM64_REG_B21 = 29;
40 | UC_ARM64_REG_B22 = 30;
41 | UC_ARM64_REG_B23 = 31;
42 | UC_ARM64_REG_B24 = 32;
43 | UC_ARM64_REG_B25 = 33;
44 | UC_ARM64_REG_B26 = 34;
45 | UC_ARM64_REG_B27 = 35;
46 | UC_ARM64_REG_B28 = 36;
47 | UC_ARM64_REG_B29 = 37;
48 | UC_ARM64_REG_B30 = 38;
49 | UC_ARM64_REG_B31 = 39;
50 | UC_ARM64_REG_D0 = 40;
51 | UC_ARM64_REG_D1 = 41;
52 | UC_ARM64_REG_D2 = 42;
53 | UC_ARM64_REG_D3 = 43;
54 | UC_ARM64_REG_D4 = 44;
55 | UC_ARM64_REG_D5 = 45;
56 | UC_ARM64_REG_D6 = 46;
57 | UC_ARM64_REG_D7 = 47;
58 | UC_ARM64_REG_D8 = 48;
59 | UC_ARM64_REG_D9 = 49;
60 | UC_ARM64_REG_D10 = 50;
61 | UC_ARM64_REG_D11 = 51;
62 | UC_ARM64_REG_D12 = 52;
63 | UC_ARM64_REG_D13 = 53;
64 | UC_ARM64_REG_D14 = 54;
65 | UC_ARM64_REG_D15 = 55;
66 | UC_ARM64_REG_D16 = 56;
67 | UC_ARM64_REG_D17 = 57;
68 | UC_ARM64_REG_D18 = 58;
69 | UC_ARM64_REG_D19 = 59;
70 | UC_ARM64_REG_D20 = 60;
71 | UC_ARM64_REG_D21 = 61;
72 | UC_ARM64_REG_D22 = 62;
73 | UC_ARM64_REG_D23 = 63;
74 | UC_ARM64_REG_D24 = 64;
75 | UC_ARM64_REG_D25 = 65;
76 | UC_ARM64_REG_D26 = 66;
77 | UC_ARM64_REG_D27 = 67;
78 | UC_ARM64_REG_D28 = 68;
79 | UC_ARM64_REG_D29 = 69;
80 | UC_ARM64_REG_D30 = 70;
81 | UC_ARM64_REG_D31 = 71;
82 | UC_ARM64_REG_H0 = 72;
83 | UC_ARM64_REG_H1 = 73;
84 | UC_ARM64_REG_H2 = 74;
85 | UC_ARM64_REG_H3 = 75;
86 | UC_ARM64_REG_H4 = 76;
87 | UC_ARM64_REG_H5 = 77;
88 | UC_ARM64_REG_H6 = 78;
89 | UC_ARM64_REG_H7 = 79;
90 | UC_ARM64_REG_H8 = 80;
91 | UC_ARM64_REG_H9 = 81;
92 | UC_ARM64_REG_H10 = 82;
93 | UC_ARM64_REG_H11 = 83;
94 | UC_ARM64_REG_H12 = 84;
95 | UC_ARM64_REG_H13 = 85;
96 | UC_ARM64_REG_H14 = 86;
97 | UC_ARM64_REG_H15 = 87;
98 | UC_ARM64_REG_H16 = 88;
99 | UC_ARM64_REG_H17 = 89;
100 | UC_ARM64_REG_H18 = 90;
101 | UC_ARM64_REG_H19 = 91;
102 | UC_ARM64_REG_H20 = 92;
103 | UC_ARM64_REG_H21 = 93;
104 | UC_ARM64_REG_H22 = 94;
105 | UC_ARM64_REG_H23 = 95;
106 | UC_ARM64_REG_H24 = 96;
107 | UC_ARM64_REG_H25 = 97;
108 | UC_ARM64_REG_H26 = 98;
109 | UC_ARM64_REG_H27 = 99;
110 | UC_ARM64_REG_H28 = 100;
111 | UC_ARM64_REG_H29 = 101;
112 | UC_ARM64_REG_H30 = 102;
113 | UC_ARM64_REG_H31 = 103;
114 | UC_ARM64_REG_Q0 = 104;
115 | UC_ARM64_REG_Q1 = 105;
116 | UC_ARM64_REG_Q2 = 106;
117 | UC_ARM64_REG_Q3 = 107;
118 | UC_ARM64_REG_Q4 = 108;
119 | UC_ARM64_REG_Q5 = 109;
120 | UC_ARM64_REG_Q6 = 110;
121 | UC_ARM64_REG_Q7 = 111;
122 | UC_ARM64_REG_Q8 = 112;
123 | UC_ARM64_REG_Q9 = 113;
124 | UC_ARM64_REG_Q10 = 114;
125 | UC_ARM64_REG_Q11 = 115;
126 | UC_ARM64_REG_Q12 = 116;
127 | UC_ARM64_REG_Q13 = 117;
128 | UC_ARM64_REG_Q14 = 118;
129 | UC_ARM64_REG_Q15 = 119;
130 | UC_ARM64_REG_Q16 = 120;
131 | UC_ARM64_REG_Q17 = 121;
132 | UC_ARM64_REG_Q18 = 122;
133 | UC_ARM64_REG_Q19 = 123;
134 | UC_ARM64_REG_Q20 = 124;
135 | UC_ARM64_REG_Q21 = 125;
136 | UC_ARM64_REG_Q22 = 126;
137 | UC_ARM64_REG_Q23 = 127;
138 | UC_ARM64_REG_Q24 = 128;
139 | UC_ARM64_REG_Q25 = 129;
140 | UC_ARM64_REG_Q26 = 130;
141 | UC_ARM64_REG_Q27 = 131;
142 | UC_ARM64_REG_Q28 = 132;
143 | UC_ARM64_REG_Q29 = 133;
144 | UC_ARM64_REG_Q30 = 134;
145 | UC_ARM64_REG_Q31 = 135;
146 | UC_ARM64_REG_S0 = 136;
147 | UC_ARM64_REG_S1 = 137;
148 | UC_ARM64_REG_S2 = 138;
149 | UC_ARM64_REG_S3 = 139;
150 | UC_ARM64_REG_S4 = 140;
151 | UC_ARM64_REG_S5 = 141;
152 | UC_ARM64_REG_S6 = 142;
153 | UC_ARM64_REG_S7 = 143;
154 | UC_ARM64_REG_S8 = 144;
155 | UC_ARM64_REG_S9 = 145;
156 | UC_ARM64_REG_S10 = 146;
157 | UC_ARM64_REG_S11 = 147;
158 | UC_ARM64_REG_S12 = 148;
159 | UC_ARM64_REG_S13 = 149;
160 | UC_ARM64_REG_S14 = 150;
161 | UC_ARM64_REG_S15 = 151;
162 | UC_ARM64_REG_S16 = 152;
163 | UC_ARM64_REG_S17 = 153;
164 | UC_ARM64_REG_S18 = 154;
165 | UC_ARM64_REG_S19 = 155;
166 | UC_ARM64_REG_S20 = 156;
167 | UC_ARM64_REG_S21 = 157;
168 | UC_ARM64_REG_S22 = 158;
169 | UC_ARM64_REG_S23 = 159;
170 | UC_ARM64_REG_S24 = 160;
171 | UC_ARM64_REG_S25 = 161;
172 | UC_ARM64_REG_S26 = 162;
173 | UC_ARM64_REG_S27 = 163;
174 | UC_ARM64_REG_S28 = 164;
175 | UC_ARM64_REG_S29 = 165;
176 | UC_ARM64_REG_S30 = 166;
177 | UC_ARM64_REG_S31 = 167;
178 | UC_ARM64_REG_W0 = 168;
179 | UC_ARM64_REG_W1 = 169;
180 | UC_ARM64_REG_W2 = 170;
181 | UC_ARM64_REG_W3 = 171;
182 | UC_ARM64_REG_W4 = 172;
183 | UC_ARM64_REG_W5 = 173;
184 | UC_ARM64_REG_W6 = 174;
185 | UC_ARM64_REG_W7 = 175;
186 | UC_ARM64_REG_W8 = 176;
187 | UC_ARM64_REG_W9 = 177;
188 | UC_ARM64_REG_W10 = 178;
189 | UC_ARM64_REG_W11 = 179;
190 | UC_ARM64_REG_W12 = 180;
191 | UC_ARM64_REG_W13 = 181;
192 | UC_ARM64_REG_W14 = 182;
193 | UC_ARM64_REG_W15 = 183;
194 | UC_ARM64_REG_W16 = 184;
195 | UC_ARM64_REG_W17 = 185;
196 | UC_ARM64_REG_W18 = 186;
197 | UC_ARM64_REG_W19 = 187;
198 | UC_ARM64_REG_W20 = 188;
199 | UC_ARM64_REG_W21 = 189;
200 | UC_ARM64_REG_W22 = 190;
201 | UC_ARM64_REG_W23 = 191;
202 | UC_ARM64_REG_W24 = 192;
203 | UC_ARM64_REG_W25 = 193;
204 | UC_ARM64_REG_W26 = 194;
205 | UC_ARM64_REG_W27 = 195;
206 | UC_ARM64_REG_W28 = 196;
207 | UC_ARM64_REG_W29 = 197;
208 | UC_ARM64_REG_W30 = 198;
209 | UC_ARM64_REG_X0 = 199;
210 | UC_ARM64_REG_X1 = 200;
211 | UC_ARM64_REG_X2 = 201;
212 | UC_ARM64_REG_X3 = 202;
213 | UC_ARM64_REG_X4 = 203;
214 | UC_ARM64_REG_X5 = 204;
215 | UC_ARM64_REG_X6 = 205;
216 | UC_ARM64_REG_X7 = 206;
217 | UC_ARM64_REG_X8 = 207;
218 | UC_ARM64_REG_X9 = 208;
219 | UC_ARM64_REG_X10 = 209;
220 | UC_ARM64_REG_X11 = 210;
221 | UC_ARM64_REG_X12 = 211;
222 | UC_ARM64_REG_X13 = 212;
223 | UC_ARM64_REG_X14 = 213;
224 | UC_ARM64_REG_X15 = 214;
225 | UC_ARM64_REG_X16 = 215;
226 | UC_ARM64_REG_X17 = 216;
227 | UC_ARM64_REG_X18 = 217;
228 | UC_ARM64_REG_X19 = 218;
229 | UC_ARM64_REG_X20 = 219;
230 | UC_ARM64_REG_X21 = 220;
231 | UC_ARM64_REG_X22 = 221;
232 | UC_ARM64_REG_X23 = 222;
233 | UC_ARM64_REG_X24 = 223;
234 | UC_ARM64_REG_X25 = 224;
235 | UC_ARM64_REG_X26 = 225;
236 | UC_ARM64_REG_X27 = 226;
237 | UC_ARM64_REG_X28 = 227;
238 | UC_ARM64_REG_V0 = 228;
239 | UC_ARM64_REG_V1 = 229;
240 | UC_ARM64_REG_V2 = 230;
241 | UC_ARM64_REG_V3 = 231;
242 | UC_ARM64_REG_V4 = 232;
243 | UC_ARM64_REG_V5 = 233;
244 | UC_ARM64_REG_V6 = 234;
245 | UC_ARM64_REG_V7 = 235;
246 | UC_ARM64_REG_V8 = 236;
247 | UC_ARM64_REG_V9 = 237;
248 | UC_ARM64_REG_V10 = 238;
249 | UC_ARM64_REG_V11 = 239;
250 | UC_ARM64_REG_V12 = 240;
251 | UC_ARM64_REG_V13 = 241;
252 | UC_ARM64_REG_V14 = 242;
253 | UC_ARM64_REG_V15 = 243;
254 | UC_ARM64_REG_V16 = 244;
255 | UC_ARM64_REG_V17 = 245;
256 | UC_ARM64_REG_V18 = 246;
257 | UC_ARM64_REG_V19 = 247;
258 | UC_ARM64_REG_V20 = 248;
259 | UC_ARM64_REG_V21 = 249;
260 | UC_ARM64_REG_V22 = 250;
261 | UC_ARM64_REG_V23 = 251;
262 | UC_ARM64_REG_V24 = 252;
263 | UC_ARM64_REG_V25 = 253;
264 | UC_ARM64_REG_V26 = 254;
265 | UC_ARM64_REG_V27 = 255;
266 | UC_ARM64_REG_V28 = 256;
267 | UC_ARM64_REG_V29 = 257;
268 | UC_ARM64_REG_V30 = 258;
269 | UC_ARM64_REG_V31 = 259;
270 |
271 | // pseudo registers
272 | UC_ARM64_REG_PC = 260;
273 | UC_ARM64_REG_CPACR_EL1 = 261;
274 |
275 | // thread registers
276 | UC_ARM64_REG_TPIDR_EL0 = 262;
277 | UC_ARM64_REG_TPIDRRO_EL0 = 263;
278 | UC_ARM64_REG_TPIDR_EL1 = 264;
279 | UC_ARM64_REG_ENDING = 265;
280 |
281 | // alias registers
282 | UC_ARM64_REG_IP0 = 215;
283 | UC_ARM64_REG_IP1 = 216;
284 | UC_ARM64_REG_FP = 1;
285 | UC_ARM64_REG_LR = 2;
286 |
287 | implementation
288 | end.
--------------------------------------------------------------------------------
/unicorn/ArmConst.pas:
--------------------------------------------------------------------------------
1 | // For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
2 |
3 | unit ArmConst;
4 |
5 | interface
6 |
7 | const
8 | // ARM registers
9 |
10 | UC_ARM_REG_INVALID = 0;
11 | UC_ARM_REG_APSR = 1;
12 | UC_ARM_REG_APSR_NZCV = 2;
13 | UC_ARM_REG_CPSR = 3;
14 | UC_ARM_REG_FPEXC = 4;
15 | UC_ARM_REG_FPINST = 5;
16 | UC_ARM_REG_FPSCR = 6;
17 | UC_ARM_REG_FPSCR_NZCV = 7;
18 | UC_ARM_REG_FPSID = 8;
19 | UC_ARM_REG_ITSTATE = 9;
20 | UC_ARM_REG_LR = 10;
21 | UC_ARM_REG_PC = 11;
22 | UC_ARM_REG_SP = 12;
23 | UC_ARM_REG_SPSR = 13;
24 | UC_ARM_REG_D0 = 14;
25 | UC_ARM_REG_D1 = 15;
26 | UC_ARM_REG_D2 = 16;
27 | UC_ARM_REG_D3 = 17;
28 | UC_ARM_REG_D4 = 18;
29 | UC_ARM_REG_D5 = 19;
30 | UC_ARM_REG_D6 = 20;
31 | UC_ARM_REG_D7 = 21;
32 | UC_ARM_REG_D8 = 22;
33 | UC_ARM_REG_D9 = 23;
34 | UC_ARM_REG_D10 = 24;
35 | UC_ARM_REG_D11 = 25;
36 | UC_ARM_REG_D12 = 26;
37 | UC_ARM_REG_D13 = 27;
38 | UC_ARM_REG_D14 = 28;
39 | UC_ARM_REG_D15 = 29;
40 | UC_ARM_REG_D16 = 30;
41 | UC_ARM_REG_D17 = 31;
42 | UC_ARM_REG_D18 = 32;
43 | UC_ARM_REG_D19 = 33;
44 | UC_ARM_REG_D20 = 34;
45 | UC_ARM_REG_D21 = 35;
46 | UC_ARM_REG_D22 = 36;
47 | UC_ARM_REG_D23 = 37;
48 | UC_ARM_REG_D24 = 38;
49 | UC_ARM_REG_D25 = 39;
50 | UC_ARM_REG_D26 = 40;
51 | UC_ARM_REG_D27 = 41;
52 | UC_ARM_REG_D28 = 42;
53 | UC_ARM_REG_D29 = 43;
54 | UC_ARM_REG_D30 = 44;
55 | UC_ARM_REG_D31 = 45;
56 | UC_ARM_REG_FPINST2 = 46;
57 | UC_ARM_REG_MVFR0 = 47;
58 | UC_ARM_REG_MVFR1 = 48;
59 | UC_ARM_REG_MVFR2 = 49;
60 | UC_ARM_REG_Q0 = 50;
61 | UC_ARM_REG_Q1 = 51;
62 | UC_ARM_REG_Q2 = 52;
63 | UC_ARM_REG_Q3 = 53;
64 | UC_ARM_REG_Q4 = 54;
65 | UC_ARM_REG_Q5 = 55;
66 | UC_ARM_REG_Q6 = 56;
67 | UC_ARM_REG_Q7 = 57;
68 | UC_ARM_REG_Q8 = 58;
69 | UC_ARM_REG_Q9 = 59;
70 | UC_ARM_REG_Q10 = 60;
71 | UC_ARM_REG_Q11 = 61;
72 | UC_ARM_REG_Q12 = 62;
73 | UC_ARM_REG_Q13 = 63;
74 | UC_ARM_REG_Q14 = 64;
75 | UC_ARM_REG_Q15 = 65;
76 | UC_ARM_REG_R0 = 66;
77 | UC_ARM_REG_R1 = 67;
78 | UC_ARM_REG_R2 = 68;
79 | UC_ARM_REG_R3 = 69;
80 | UC_ARM_REG_R4 = 70;
81 | UC_ARM_REG_R5 = 71;
82 | UC_ARM_REG_R6 = 72;
83 | UC_ARM_REG_R7 = 73;
84 | UC_ARM_REG_R8 = 74;
85 | UC_ARM_REG_R9 = 75;
86 | UC_ARM_REG_R10 = 76;
87 | UC_ARM_REG_R11 = 77;
88 | UC_ARM_REG_R12 = 78;
89 | UC_ARM_REG_S0 = 79;
90 | UC_ARM_REG_S1 = 80;
91 | UC_ARM_REG_S2 = 81;
92 | UC_ARM_REG_S3 = 82;
93 | UC_ARM_REG_S4 = 83;
94 | UC_ARM_REG_S5 = 84;
95 | UC_ARM_REG_S6 = 85;
96 | UC_ARM_REG_S7 = 86;
97 | UC_ARM_REG_S8 = 87;
98 | UC_ARM_REG_S9 = 88;
99 | UC_ARM_REG_S10 = 89;
100 | UC_ARM_REG_S11 = 90;
101 | UC_ARM_REG_S12 = 91;
102 | UC_ARM_REG_S13 = 92;
103 | UC_ARM_REG_S14 = 93;
104 | UC_ARM_REG_S15 = 94;
105 | UC_ARM_REG_S16 = 95;
106 | UC_ARM_REG_S17 = 96;
107 | UC_ARM_REG_S18 = 97;
108 | UC_ARM_REG_S19 = 98;
109 | UC_ARM_REG_S20 = 99;
110 | UC_ARM_REG_S21 = 100;
111 | UC_ARM_REG_S22 = 101;
112 | UC_ARM_REG_S23 = 102;
113 | UC_ARM_REG_S24 = 103;
114 | UC_ARM_REG_S25 = 104;
115 | UC_ARM_REG_S26 = 105;
116 | UC_ARM_REG_S27 = 106;
117 | UC_ARM_REG_S28 = 107;
118 | UC_ARM_REG_S29 = 108;
119 | UC_ARM_REG_S30 = 109;
120 | UC_ARM_REG_S31 = 110;
121 | UC_ARM_REG_C1_C0_2 = 111;
122 | UC_ARM_REG_C13_C0_2 = 112;
123 | UC_ARM_REG_C13_C0_3 = 113;
124 | UC_ARM_REG_ENDING = 114;
125 |
126 | // alias registers
127 | UC_ARM_REG_R13 = 12;
128 | UC_ARM_REG_R14 = 10;
129 | UC_ARM_REG_R15 = 11;
130 | UC_ARM_REG_SB = 75;
131 | UC_ARM_REG_SL = 76;
132 | UC_ARM_REG_FP = 77;
133 | UC_ARM_REG_IP = 78;
134 |
135 | implementation
136 | end.
--------------------------------------------------------------------------------
/unicorn/GenerateConsts.py:
--------------------------------------------------------------------------------
1 | # Unicorn Engine
2 | # By Dang Hoang Vu, 2013
3 | from __future__ import print_function
4 | import sys, re, os
5 |
6 | INCL_DIR = os.path.join('include', 'unicorn')
7 |
8 | include = [ 'arm.h', 'arm64.h', 'mips.h', 'x86.h', 'sparc.h', 'm68k.h', 'unicorn.h' ]
9 |
10 | template = {
11 | 'python': {
12 | 'header': "# For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.py]\n",
13 | 'footer': "",
14 | 'line_format': 'UC_%s = %s\n',
15 | 'out_file': './python/unicorn/%s_const.py',
16 | # prefixes for constant filenames of all archs - case sensitive
17 | 'arm.h': 'arm',
18 | 'arm64.h': 'arm64',
19 | 'mips.h': 'mips',
20 | 'x86.h': 'x86',
21 | 'sparc.h': 'sparc',
22 | 'm68k.h': 'm68k',
23 | 'unicorn.h': 'unicorn',
24 | 'comment_open': '#',
25 | 'comment_close': '',
26 | },
27 | 'ruby': {
28 | 'header': "# For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.rb]\n\nmodule UnicornEngine\n",
29 | 'footer': "end",
30 | 'line_format': '\tUC_%s = %s\n',
31 | 'out_file': './ruby/unicorn_gem/lib/unicorn_engine/%s_const.rb',
32 | # prefixes for constant filenames of all archs - case sensitive
33 | 'arm.h': 'arm',
34 | 'arm64.h': 'arm64',
35 | 'mips.h': 'mips',
36 | 'x86.h': 'x86',
37 | 'sparc.h': 'sparc',
38 | 'm68k.h': 'm68k',
39 | 'unicorn.h': 'unicorn',
40 | 'comment_open': '#',
41 | 'comment_close': '',
42 | },
43 | 'go': {
44 | 'header': "package unicorn\n// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [%s_const.go]\nconst (\n",
45 | 'footer': ")",
46 | 'line_format': '\t%s = %s\n',
47 | 'out_file': './go/unicorn/%s_const.go',
48 | # prefixes for constant filenames of all archs - case sensitive
49 | 'arm.h': 'arm',
50 | 'arm64.h': 'arm64',
51 | 'mips.h': 'mips',
52 | 'x86.h': 'x86',
53 | 'sparc.h': 'sparc',
54 | 'm68k.h': 'm68k',
55 | 'unicorn.h': 'unicorn',
56 | 'comment_open': '//',
57 | 'comment_close': '',
58 | },
59 | 'java': {
60 | 'header': "// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT\n\npackage unicorn;\n\npublic interface %sConst {\n",
61 | 'footer': "\n}\n",
62 | 'line_format': ' public static final int UC_%s = %s;\n',
63 | 'out_file': './java/unicorn/%sConst.java',
64 | # prefixes for constant filenames of all archs - case sensitive
65 | 'arm.h': 'Arm',
66 | 'arm64.h': 'Arm64',
67 | 'mips.h': 'Mips',
68 | 'x86.h': 'X86',
69 | 'sparc.h': 'Sparc',
70 | 'm68k.h': 'M68k',
71 | 'unicorn.h': 'Unicorn',
72 | 'comment_open': '//',
73 | 'comment_close': '',
74 | },
75 | 'dotnet': {
76 | 'header': "// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT\n\nnamespace UnicornManaged.Const\n\nopen System\n\n[]\nmodule %s =\n",
77 | 'footer': "\n",
78 | 'line_format': ' let UC_%s = %s\n',
79 | 'out_file': os.path.join('dotnet', 'UnicornManaged', 'Const', '%s.fs'),
80 | # prefixes for constant filenames of all archs - case sensitive
81 | 'arm.h': 'Arm',
82 | 'arm64.h': 'Arm64',
83 | 'mips.h': 'Mips',
84 | 'x86.h': 'X86',
85 | 'sparc.h': 'Sparc',
86 | 'm68k.h': 'M68k',
87 | 'unicorn.h': 'Common',
88 | 'comment_open': '//',
89 | 'comment_close': '',
90 | },
91 | 'pascal': {
92 | 'header': "// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT\n\nunit %sConst;\n\ninterface\n\nconst",
93 | 'footer': "\nimplementation\nend.",
94 | 'line_format': ' UC_%s = %s;\n',
95 | 'out_file': './%sConst.pas',
96 | # prefixes for constant filenames of all archs - case sensitive
97 | 'arm.h': 'Arm',
98 | 'arm64.h': 'Arm64',
99 | 'mips.h': 'Mips',
100 | 'x86.h': 'X86',
101 | 'sparc.h': 'Sparc',
102 | 'm68k.h': 'M68k',
103 | 'unicorn.h': 'Unicorn',
104 | 'comment_open': '//',
105 | 'comment_close': '',
106 | },
107 | }
108 |
109 | # markup for comments to be added to autogen files
110 | MARKUP = '//>'
111 |
112 | def gen(lang):
113 | global include, INCL_DIR
114 | templ = template[lang]
115 | for target in include:
116 | prefix = templ[target]
117 | outfile = open(templ['out_file'] %(prefix), 'wb') # open as binary prevents windows newlines
118 | outfile.write((templ['header'] % (prefix)).encode("utf-8"))
119 | if target == 'unicorn.h':
120 | prefix = ''
121 | lines = open(os.path.join(INCL_DIR, target)).readlines()
122 |
123 | previous = {}
124 | count = 0
125 | for line in lines:
126 | line = line.strip()
127 |
128 | if line.startswith(MARKUP): # markup for comments
129 | outfile.write(("\n%s%s%s\n" %(templ['comment_open'], \
130 | line.replace(MARKUP, ''), templ['comment_close'])).encode("utf-8"))
131 | continue
132 |
133 | if line == '' or line.startswith('//'):
134 | continue
135 |
136 | tmp = line.strip().split(',')
137 | for t in tmp:
138 | t = t.strip()
139 | if not t or t.startswith('//'): continue
140 | f = re.split('\s+', t)
141 |
142 | # parse #define UC_TARGET (num)
143 | define = False
144 | if f[0] == '#define' and len(f) >= 3:
145 | define = True
146 | f.pop(0)
147 | f.insert(1, '=')
148 |
149 | if f[0].startswith("UC_" + prefix.upper()):
150 | if len(f) > 1 and f[1] not in ('//', '='):
151 | print("WARNING: Unable to convert %s" % f)
152 | print(" Line =", line)
153 | continue
154 | elif len(f) > 1 and f[1] == '=':
155 | rhs = ''.join(f[2:])
156 | else:
157 | rhs = str(count)
158 |
159 | lhs = f[0].strip()
160 | # evaluate bitshifts in constants e.g. "UC_X86 = 1 << 1"
161 | match = re.match(r'(?P\s*\d+\s*<<\s*\d+\s*)', rhs)
162 | if match:
163 | rhs = str(eval(match.group(1)))
164 | else:
165 | # evaluate references to other constants e.g. "UC_ARM_REG_X = UC_ARM_REG_SP"
166 | match = re.match(r'^([^\d]\w+)$', rhs)
167 | if match:
168 | rhs = previous[match.group(1)]
169 |
170 | if not rhs.isdigit():
171 | for k, v in previous.items():
172 | rhs = re.sub(r'\b%s\b' % k, v, rhs)
173 | rhs = str(eval(rhs))
174 |
175 | lhs_strip = re.sub(r'^UC_', '', lhs)
176 | count = int(rhs) + 1
177 | if (count == 1):
178 | outfile.write(("\n").encode("utf-8"))
179 |
180 | outfile.write((templ['line_format'] % (lhs_strip, rhs)).encode("utf-8"))
181 | previous[lhs] = str(rhs)
182 |
183 | outfile.write((templ['footer']).encode("utf-8"))
184 | outfile.close()
185 |
186 | def main():
187 | lang = sys.argv[1]
188 | if not lang in template:
189 | raise RuntimeError("Unsupported binding %s" % lang)
190 | gen(sys.argv[1])
191 |
192 | if __name__ == "__main__":
193 | if len(sys.argv) < 2:
194 | print("Usage:", sys.argv[0], " ")
195 | sys.exit(1)
196 | main()
--------------------------------------------------------------------------------
/unicorn/M68kConst.pas:
--------------------------------------------------------------------------------
1 | // For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
2 |
3 | unit M68kConst;
4 |
5 | interface
6 |
7 | const
8 | // M68K registers
9 |
10 | UC_M68K_REG_INVALID = 0;
11 | UC_M68K_REG_A0 = 1;
12 | UC_M68K_REG_A1 = 2;
13 | UC_M68K_REG_A2 = 3;
14 | UC_M68K_REG_A3 = 4;
15 | UC_M68K_REG_A4 = 5;
16 | UC_M68K_REG_A5 = 6;
17 | UC_M68K_REG_A6 = 7;
18 | UC_M68K_REG_A7 = 8;
19 | UC_M68K_REG_D0 = 9;
20 | UC_M68K_REG_D1 = 10;
21 | UC_M68K_REG_D2 = 11;
22 | UC_M68K_REG_D3 = 12;
23 | UC_M68K_REG_D4 = 13;
24 | UC_M68K_REG_D5 = 14;
25 | UC_M68K_REG_D6 = 15;
26 | UC_M68K_REG_D7 = 16;
27 | UC_M68K_REG_SR = 17;
28 | UC_M68K_REG_PC = 18;
29 | UC_M68K_REG_ENDING = 19;
30 |
31 | implementation
32 | end.
--------------------------------------------------------------------------------
/unicorn/MipsConst.pas:
--------------------------------------------------------------------------------
1 | // For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
2 |
3 | unit MipsConst;
4 |
5 | interface
6 |
7 | const
8 | // MIPS registers
9 |
10 | UC_MIPS_REG_INVALID = 0;
11 |
12 | // General purpose registers
13 | UC_MIPS_REG_PC = 1;
14 | UC_MIPS_REG_0 = 2;
15 | UC_MIPS_REG_1 = 3;
16 | UC_MIPS_REG_2 = 4;
17 | UC_MIPS_REG_3 = 5;
18 | UC_MIPS_REG_4 = 6;
19 | UC_MIPS_REG_5 = 7;
20 | UC_MIPS_REG_6 = 8;
21 | UC_MIPS_REG_7 = 9;
22 | UC_MIPS_REG_8 = 10;
23 | UC_MIPS_REG_9 = 11;
24 | UC_MIPS_REG_10 = 12;
25 | UC_MIPS_REG_11 = 13;
26 | UC_MIPS_REG_12 = 14;
27 | UC_MIPS_REG_13 = 15;
28 | UC_MIPS_REG_14 = 16;
29 | UC_MIPS_REG_15 = 17;
30 | UC_MIPS_REG_16 = 18;
31 | UC_MIPS_REG_17 = 19;
32 | UC_MIPS_REG_18 = 20;
33 | UC_MIPS_REG_19 = 21;
34 | UC_MIPS_REG_20 = 22;
35 | UC_MIPS_REG_21 = 23;
36 | UC_MIPS_REG_22 = 24;
37 | UC_MIPS_REG_23 = 25;
38 | UC_MIPS_REG_24 = 26;
39 | UC_MIPS_REG_25 = 27;
40 | UC_MIPS_REG_26 = 28;
41 | UC_MIPS_REG_27 = 29;
42 | UC_MIPS_REG_28 = 30;
43 | UC_MIPS_REG_29 = 31;
44 | UC_MIPS_REG_30 = 32;
45 | UC_MIPS_REG_31 = 33;
46 |
47 | // DSP registers
48 | UC_MIPS_REG_DSPCCOND = 34;
49 | UC_MIPS_REG_DSPCARRY = 35;
50 | UC_MIPS_REG_DSPEFI = 36;
51 | UC_MIPS_REG_DSPOUTFLAG = 37;
52 | UC_MIPS_REG_DSPOUTFLAG16_19 = 38;
53 | UC_MIPS_REG_DSPOUTFLAG20 = 39;
54 | UC_MIPS_REG_DSPOUTFLAG21 = 40;
55 | UC_MIPS_REG_DSPOUTFLAG22 = 41;
56 | UC_MIPS_REG_DSPOUTFLAG23 = 42;
57 | UC_MIPS_REG_DSPPOS = 43;
58 | UC_MIPS_REG_DSPSCOUNT = 44;
59 |
60 | // ACC registers
61 | UC_MIPS_REG_AC0 = 45;
62 | UC_MIPS_REG_AC1 = 46;
63 | UC_MIPS_REG_AC2 = 47;
64 | UC_MIPS_REG_AC3 = 48;
65 |
66 | // COP registers
67 | UC_MIPS_REG_CC0 = 49;
68 | UC_MIPS_REG_CC1 = 50;
69 | UC_MIPS_REG_CC2 = 51;
70 | UC_MIPS_REG_CC3 = 52;
71 | UC_MIPS_REG_CC4 = 53;
72 | UC_MIPS_REG_CC5 = 54;
73 | UC_MIPS_REG_CC6 = 55;
74 | UC_MIPS_REG_CC7 = 56;
75 |
76 | // FPU registers
77 | UC_MIPS_REG_F0 = 57;
78 | UC_MIPS_REG_F1 = 58;
79 | UC_MIPS_REG_F2 = 59;
80 | UC_MIPS_REG_F3 = 60;
81 | UC_MIPS_REG_F4 = 61;
82 | UC_MIPS_REG_F5 = 62;
83 | UC_MIPS_REG_F6 = 63;
84 | UC_MIPS_REG_F7 = 64;
85 | UC_MIPS_REG_F8 = 65;
86 | UC_MIPS_REG_F9 = 66;
87 | UC_MIPS_REG_F10 = 67;
88 | UC_MIPS_REG_F11 = 68;
89 | UC_MIPS_REG_F12 = 69;
90 | UC_MIPS_REG_F13 = 70;
91 | UC_MIPS_REG_F14 = 71;
92 | UC_MIPS_REG_F15 = 72;
93 | UC_MIPS_REG_F16 = 73;
94 | UC_MIPS_REG_F17 = 74;
95 | UC_MIPS_REG_F18 = 75;
96 | UC_MIPS_REG_F19 = 76;
97 | UC_MIPS_REG_F20 = 77;
98 | UC_MIPS_REG_F21 = 78;
99 | UC_MIPS_REG_F22 = 79;
100 | UC_MIPS_REG_F23 = 80;
101 | UC_MIPS_REG_F24 = 81;
102 | UC_MIPS_REG_F25 = 82;
103 | UC_MIPS_REG_F26 = 83;
104 | UC_MIPS_REG_F27 = 84;
105 | UC_MIPS_REG_F28 = 85;
106 | UC_MIPS_REG_F29 = 86;
107 | UC_MIPS_REG_F30 = 87;
108 | UC_MIPS_REG_F31 = 88;
109 | UC_MIPS_REG_FCC0 = 89;
110 | UC_MIPS_REG_FCC1 = 90;
111 | UC_MIPS_REG_FCC2 = 91;
112 | UC_MIPS_REG_FCC3 = 92;
113 | UC_MIPS_REG_FCC4 = 93;
114 | UC_MIPS_REG_FCC5 = 94;
115 | UC_MIPS_REG_FCC6 = 95;
116 | UC_MIPS_REG_FCC7 = 96;
117 |
118 | // AFPR128
119 | UC_MIPS_REG_W0 = 97;
120 | UC_MIPS_REG_W1 = 98;
121 | UC_MIPS_REG_W2 = 99;
122 | UC_MIPS_REG_W3 = 100;
123 | UC_MIPS_REG_W4 = 101;
124 | UC_MIPS_REG_W5 = 102;
125 | UC_MIPS_REG_W6 = 103;
126 | UC_MIPS_REG_W7 = 104;
127 | UC_MIPS_REG_W8 = 105;
128 | UC_MIPS_REG_W9 = 106;
129 | UC_MIPS_REG_W10 = 107;
130 | UC_MIPS_REG_W11 = 108;
131 | UC_MIPS_REG_W12 = 109;
132 | UC_MIPS_REG_W13 = 110;
133 | UC_MIPS_REG_W14 = 111;
134 | UC_MIPS_REG_W15 = 112;
135 | UC_MIPS_REG_W16 = 113;
136 | UC_MIPS_REG_W17 = 114;
137 | UC_MIPS_REG_W18 = 115;
138 | UC_MIPS_REG_W19 = 116;
139 | UC_MIPS_REG_W20 = 117;
140 | UC_MIPS_REG_W21 = 118;
141 | UC_MIPS_REG_W22 = 119;
142 | UC_MIPS_REG_W23 = 120;
143 | UC_MIPS_REG_W24 = 121;
144 | UC_MIPS_REG_W25 = 122;
145 | UC_MIPS_REG_W26 = 123;
146 | UC_MIPS_REG_W27 = 124;
147 | UC_MIPS_REG_W28 = 125;
148 | UC_MIPS_REG_W29 = 126;
149 | UC_MIPS_REG_W30 = 127;
150 | UC_MIPS_REG_W31 = 128;
151 | UC_MIPS_REG_HI = 129;
152 | UC_MIPS_REG_LO = 130;
153 | UC_MIPS_REG_P0 = 131;
154 | UC_MIPS_REG_P1 = 132;
155 | UC_MIPS_REG_P2 = 133;
156 | UC_MIPS_REG_MPL0 = 134;
157 | UC_MIPS_REG_MPL1 = 135;
158 | UC_MIPS_REG_MPL2 = 136;
159 | UC_MIPS_REG_ENDING = 137;
160 | UC_MIPS_REG_ZERO = 2;
161 | UC_MIPS_REG_AT = 3;
162 | UC_MIPS_REG_V0 = 4;
163 | UC_MIPS_REG_V1 = 5;
164 | UC_MIPS_REG_A0 = 6;
165 | UC_MIPS_REG_A1 = 7;
166 | UC_MIPS_REG_A2 = 8;
167 | UC_MIPS_REG_A3 = 9;
168 | UC_MIPS_REG_T0 = 10;
169 | UC_MIPS_REG_T1 = 11;
170 | UC_MIPS_REG_T2 = 12;
171 | UC_MIPS_REG_T3 = 13;
172 | UC_MIPS_REG_T4 = 14;
173 | UC_MIPS_REG_T5 = 15;
174 | UC_MIPS_REG_T6 = 16;
175 | UC_MIPS_REG_T7 = 17;
176 | UC_MIPS_REG_S0 = 18;
177 | UC_MIPS_REG_S1 = 19;
178 | UC_MIPS_REG_S2 = 20;
179 | UC_MIPS_REG_S3 = 21;
180 | UC_MIPS_REG_S4 = 22;
181 | UC_MIPS_REG_S5 = 23;
182 | UC_MIPS_REG_S6 = 24;
183 | UC_MIPS_REG_S7 = 25;
184 | UC_MIPS_REG_T8 = 26;
185 | UC_MIPS_REG_T9 = 27;
186 | UC_MIPS_REG_K0 = 28;
187 | UC_MIPS_REG_K1 = 29;
188 | UC_MIPS_REG_GP = 30;
189 | UC_MIPS_REG_SP = 31;
190 | UC_MIPS_REG_FP = 32;
191 | UC_MIPS_REG_S8 = 32;
192 | UC_MIPS_REG_RA = 33;
193 | UC_MIPS_REG_HI0 = 45;
194 | UC_MIPS_REG_HI1 = 46;
195 | UC_MIPS_REG_HI2 = 47;
196 | UC_MIPS_REG_HI3 = 48;
197 | UC_MIPS_REG_LO0 = 45;
198 | UC_MIPS_REG_LO1 = 46;
199 | UC_MIPS_REG_LO2 = 47;
200 | UC_MIPS_REG_LO3 = 48;
201 |
202 | implementation
203 | end.
--------------------------------------------------------------------------------
/unicorn/SparcConst.pas:
--------------------------------------------------------------------------------
1 | // For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
2 |
3 | unit SparcConst;
4 |
5 | interface
6 |
7 | const
8 | // SPARC registers
9 |
10 | UC_SPARC_REG_INVALID = 0;
11 | UC_SPARC_REG_F0 = 1;
12 | UC_SPARC_REG_F1 = 2;
13 | UC_SPARC_REG_F2 = 3;
14 | UC_SPARC_REG_F3 = 4;
15 | UC_SPARC_REG_F4 = 5;
16 | UC_SPARC_REG_F5 = 6;
17 | UC_SPARC_REG_F6 = 7;
18 | UC_SPARC_REG_F7 = 8;
19 | UC_SPARC_REG_F8 = 9;
20 | UC_SPARC_REG_F9 = 10;
21 | UC_SPARC_REG_F10 = 11;
22 | UC_SPARC_REG_F11 = 12;
23 | UC_SPARC_REG_F12 = 13;
24 | UC_SPARC_REG_F13 = 14;
25 | UC_SPARC_REG_F14 = 15;
26 | UC_SPARC_REG_F15 = 16;
27 | UC_SPARC_REG_F16 = 17;
28 | UC_SPARC_REG_F17 = 18;
29 | UC_SPARC_REG_F18 = 19;
30 | UC_SPARC_REG_F19 = 20;
31 | UC_SPARC_REG_F20 = 21;
32 | UC_SPARC_REG_F21 = 22;
33 | UC_SPARC_REG_F22 = 23;
34 | UC_SPARC_REG_F23 = 24;
35 | UC_SPARC_REG_F24 = 25;
36 | UC_SPARC_REG_F25 = 26;
37 | UC_SPARC_REG_F26 = 27;
38 | UC_SPARC_REG_F27 = 28;
39 | UC_SPARC_REG_F28 = 29;
40 | UC_SPARC_REG_F29 = 30;
41 | UC_SPARC_REG_F30 = 31;
42 | UC_SPARC_REG_F31 = 32;
43 | UC_SPARC_REG_F32 = 33;
44 | UC_SPARC_REG_F34 = 34;
45 | UC_SPARC_REG_F36 = 35;
46 | UC_SPARC_REG_F38 = 36;
47 | UC_SPARC_REG_F40 = 37;
48 | UC_SPARC_REG_F42 = 38;
49 | UC_SPARC_REG_F44 = 39;
50 | UC_SPARC_REG_F46 = 40;
51 | UC_SPARC_REG_F48 = 41;
52 | UC_SPARC_REG_F50 = 42;
53 | UC_SPARC_REG_F52 = 43;
54 | UC_SPARC_REG_F54 = 44;
55 | UC_SPARC_REG_F56 = 45;
56 | UC_SPARC_REG_F58 = 46;
57 | UC_SPARC_REG_F60 = 47;
58 | UC_SPARC_REG_F62 = 48;
59 | UC_SPARC_REG_FCC0 = 49;
60 | UC_SPARC_REG_FCC1 = 50;
61 | UC_SPARC_REG_FCC2 = 51;
62 | UC_SPARC_REG_FCC3 = 52;
63 | UC_SPARC_REG_G0 = 53;
64 | UC_SPARC_REG_G1 = 54;
65 | UC_SPARC_REG_G2 = 55;
66 | UC_SPARC_REG_G3 = 56;
67 | UC_SPARC_REG_G4 = 57;
68 | UC_SPARC_REG_G5 = 58;
69 | UC_SPARC_REG_G6 = 59;
70 | UC_SPARC_REG_G7 = 60;
71 | UC_SPARC_REG_I0 = 61;
72 | UC_SPARC_REG_I1 = 62;
73 | UC_SPARC_REG_I2 = 63;
74 | UC_SPARC_REG_I3 = 64;
75 | UC_SPARC_REG_I4 = 65;
76 | UC_SPARC_REG_I5 = 66;
77 | UC_SPARC_REG_FP = 67;
78 | UC_SPARC_REG_I7 = 68;
79 | UC_SPARC_REG_ICC = 69;
80 | UC_SPARC_REG_L0 = 70;
81 | UC_SPARC_REG_L1 = 71;
82 | UC_SPARC_REG_L2 = 72;
83 | UC_SPARC_REG_L3 = 73;
84 | UC_SPARC_REG_L4 = 74;
85 | UC_SPARC_REG_L5 = 75;
86 | UC_SPARC_REG_L6 = 76;
87 | UC_SPARC_REG_L7 = 77;
88 | UC_SPARC_REG_O0 = 78;
89 | UC_SPARC_REG_O1 = 79;
90 | UC_SPARC_REG_O2 = 80;
91 | UC_SPARC_REG_O3 = 81;
92 | UC_SPARC_REG_O4 = 82;
93 | UC_SPARC_REG_O5 = 83;
94 | UC_SPARC_REG_SP = 84;
95 | UC_SPARC_REG_O7 = 85;
96 | UC_SPARC_REG_Y = 86;
97 | UC_SPARC_REG_XCC = 87;
98 | UC_SPARC_REG_PC = 88;
99 | UC_SPARC_REG_ENDING = 89;
100 | UC_SPARC_REG_O6 = 84;
101 | UC_SPARC_REG_I6 = 67;
102 |
103 | implementation
104 | end.
--------------------------------------------------------------------------------
/unicorn/UnicornConst.pas:
--------------------------------------------------------------------------------
1 | // For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
2 |
3 | unit UnicornConst;
4 |
5 | interface
6 |
7 | const UC_API_MAJOR = 1;
8 |
9 | UC_API_MINOR = 0;
10 | UC_VERSION_MAJOR = 1;
11 |
12 | UC_VERSION_MINOR = 0;
13 | UC_VERSION_EXTRA = 2;
14 | UC_SECOND_SCALE = 1000000;
15 | UC_MILISECOND_SCALE = 1000;
16 | UC_ARCH_ARM = 1;
17 | UC_ARCH_ARM64 = 2;
18 | UC_ARCH_MIPS = 3;
19 | UC_ARCH_X86 = 4;
20 | UC_ARCH_PPC = 5;
21 | UC_ARCH_SPARC = 6;
22 | UC_ARCH_M68K = 7;
23 | UC_ARCH_MAX = 8;
24 |
25 | UC_MODE_LITTLE_ENDIAN = 0;
26 | UC_MODE_BIG_ENDIAN = 1073741824;
27 |
28 | UC_MODE_ARM = 0;
29 | UC_MODE_THUMB = 16;
30 | UC_MODE_MCLASS = 32;
31 | UC_MODE_V8 = 64;
32 | UC_MODE_MICRO = 16;
33 | UC_MODE_MIPS3 = 32;
34 | UC_MODE_MIPS32R6 = 64;
35 | UC_MODE_MIPS32 = 4;
36 | UC_MODE_MIPS64 = 8;
37 | UC_MODE_16 = 2;
38 | UC_MODE_32 = 4;
39 | UC_MODE_64 = 8;
40 | UC_MODE_PPC32 = 4;
41 | UC_MODE_PPC64 = 8;
42 | UC_MODE_QPX = 16;
43 | UC_MODE_SPARC32 = 4;
44 | UC_MODE_SPARC64 = 8;
45 | UC_MODE_V9 = 16;
46 |
47 | UC_ERR_OK = 0;
48 | UC_ERR_NOMEM = 1;
49 | UC_ERR_ARCH = 2;
50 | UC_ERR_HANDLE = 3;
51 | UC_ERR_MODE = 4;
52 | UC_ERR_VERSION = 5;
53 | UC_ERR_READ_UNMAPPED = 6;
54 | UC_ERR_WRITE_UNMAPPED = 7;
55 | UC_ERR_FETCH_UNMAPPED = 8;
56 | UC_ERR_HOOK = 9;
57 | UC_ERR_INSN_INVALID = 10;
58 | UC_ERR_MAP = 11;
59 | UC_ERR_WRITE_PROT = 12;
60 | UC_ERR_READ_PROT = 13;
61 | UC_ERR_FETCH_PROT = 14;
62 | UC_ERR_ARG = 15;
63 | UC_ERR_READ_UNALIGNED = 16;
64 | UC_ERR_WRITE_UNALIGNED = 17;
65 | UC_ERR_FETCH_UNALIGNED = 18;
66 | UC_ERR_HOOK_EXIST = 19;
67 | UC_ERR_RESOURCE = 20;
68 | UC_ERR_EXCEPTION = 21;
69 | UC_MEM_READ = 16;
70 | UC_MEM_WRITE = 17;
71 | UC_MEM_FETCH = 18;
72 | UC_MEM_READ_UNMAPPED = 19;
73 | UC_MEM_WRITE_UNMAPPED = 20;
74 | UC_MEM_FETCH_UNMAPPED = 21;
75 | UC_MEM_WRITE_PROT = 22;
76 | UC_MEM_READ_PROT = 23;
77 | UC_MEM_FETCH_PROT = 24;
78 | UC_MEM_READ_AFTER = 25;
79 | UC_HOOK_INTR = 1;
80 | UC_HOOK_INSN = 2;
81 | UC_HOOK_CODE = 4;
82 | UC_HOOK_BLOCK = 8;
83 | UC_HOOK_MEM_READ_UNMAPPED = 16;
84 | UC_HOOK_MEM_WRITE_UNMAPPED = 32;
85 | UC_HOOK_MEM_FETCH_UNMAPPED = 64;
86 | UC_HOOK_MEM_READ_PROT = 128;
87 | UC_HOOK_MEM_WRITE_PROT = 256;
88 | UC_HOOK_MEM_FETCH_PROT = 512;
89 | UC_HOOK_MEM_READ = 1024;
90 | UC_HOOK_MEM_WRITE = 2048;
91 | UC_HOOK_MEM_FETCH = 4096;
92 | UC_HOOK_MEM_READ_AFTER = 8192;
93 | UC_HOOK_MEM_UNMAPPED = 112;
94 | UC_HOOK_MEM_PROT = 896;
95 | UC_HOOK_MEM_READ_INVALID = 144;
96 | UC_HOOK_MEM_WRITE_INVALID = 288;
97 | UC_HOOK_MEM_FETCH_INVALID = 576;
98 | UC_HOOK_MEM_INVALID = 1008;
99 | UC_HOOK_MEM_VALID = 7168;
100 | UC_QUERY_MODE = 1;
101 | UC_QUERY_PAGE_SIZE = 2;
102 | UC_QUERY_ARCH = 3;
103 |
104 | UC_PROT_NONE = 0;
105 | UC_PROT_READ = 1;
106 | UC_PROT_WRITE = 2;
107 | UC_PROT_EXEC = 4;
108 | UC_PROT_ALL = 7;
109 |
110 | implementation
111 | end.
--------------------------------------------------------------------------------
/unicorn/Unicorn_dyn.pas:
--------------------------------------------------------------------------------
1 | {
2 | FreePascal/Delphi bindings for the UnicornEngine Emulator Engine \
3 | Tested On Mac - Win - Linux >> with FreePascal v3.0.4 & Delphi Berlin 10.2 .
4 |
5 | Copyright(c) 2018 Coldzer0 .
6 |
7 | License: GPLv2 .
8 | }
9 |
10 | unit Unicorn_dyn;
11 |
12 | {$IFDEF FPC}
13 | {$MODE Delphi}
14 | {$PackRecords C}
15 | {$ENDIF}
16 |
17 | interface
18 |
19 | uses
20 | {$IFDEF FPC}dynlibs,Crt{$ELSE}
21 | {$ifdef mswindows}
22 | windows,sysutils
23 | {$ENDIF}
24 | {$ENDIF};
25 |
26 |
27 | const
28 | {$IFDEF Darwin}
29 | UNICORN_LIB = './libunicorn.dylib';
30 | {$ENDIF}
31 | {$ifdef Linux}
32 | UNICORN_LIB = './libunicorn.so';
33 | {$endif}
34 | {$ifdef mswindows}
35 | UNICORN_LIB = './unicorn.dll';
36 | {$endif}
37 |
38 | type
39 | uc_engine = Pointer;
40 | uc_context = Pointer; // Opaque storage for CPU context, used with uc_context_*()
41 | uc_hook = UIntPtr;
42 | uc_arch = Cardinal;
43 | uc_mode = Cardinal;
44 | uc_err = Cardinal;
45 | uc_query_type = Cardinal;
46 |
47 | {$IFNDEF FPC} // Delphi Support .
48 | PUInt32 = ^UInt32;
49 | {$ENDIF}
50 |
51 | type
52 | {
53 | Callback functions
54 | Callback function for tracing code (UC_HOOK_CODE & UC_HOOK_BLOCK)
55 | @address: address where the code is being executed
56 | @size: size of machine instruction(s) being executed, or 0 when size is unknown
57 | @user_data: user data passed to tracing APIs.
58 | }
59 | uc_cb_hookcode_t = procedure(uc : uc_engine; address : UInt64; size : UInt32; user_data : Pointer); cdecl;
60 |
61 | {
62 | Callback function for tracing interrupts (for uc_hook_intr())
63 | @intno: interrupt number
64 | @user_data: user data passed to tracing APIs.
65 | }
66 | uc_cb_hookintr_t = procedure(uc : uc_engine; intno : UInt32; user_data : Pointer); cdecl;
67 |
68 | {
69 | Callback function for tracing IN instruction of X86
70 | @port: port number
71 | @size: data size (1/2/4) to be read from this port
72 | @user_data: user data passed to tracing APIs.
73 | }
74 | uc_cb_insn_in_t = function(uc : uc_engine; port : UInt32; siz : integer; user_data : Pointer) : UInt32; cdecl;
75 |
76 | {
77 | Callback function for OUT instruction of X86 .
78 | @port: port number
79 | @size: data size (1/2/4) to be written to this port
80 | @value: data value to be written to this port
81 | }
82 | uc_cb_insn_out_t = procedure(uc : uc_engine; port : UInt32; size : integer; value : UInt32; user_data : Pointer); cdecl;
83 |
84 | // All type of memory accesses for UC_HOOK_MEM_*
85 | uc_mem_type = integer;
86 |
87 | // All type of hooks for uc_hook_add() API.
88 | uc_hook_type = integer;
89 |
90 | {
91 | Callback function for hooking memory (UC_MEM_READ, UC_MEM_WRITE & UC_MEM_FETCH)
92 | @type: this memory is being READ, or WRITE
93 | @address: address where the code is being executed
94 | @size: size of data being read or written
95 | @value: value of data being written to memory, or irrelevant if type = READ.
96 | @user_data: user data passed to tracing APIs
97 | }
98 | uc_cb_hookmem_t = procedure(uc : uc_engine; _type : uc_mem_type; address : UInt64; size : integer; value : Int64; user_data : Pointer); cdecl;
99 |
100 | {
101 | Callback function for handling invalid memory access events (UNMAPPED and
102 | PROT events)
103 |
104 | @type: this memory is being READ, or WRITE
105 | @address: address where the code is being executed
106 | @size: size of data being read or written
107 | @value: value of data being written to memory, or irrelevant if type = READ.
108 | @user_data: user data passed to tracing APIs
109 |
110 | @return: return true to continue, or false to stop program (due to invalid memory).
111 | NOTE: returning true to continue execution will only work if if the accessed
112 | memory is made accessible with the correct permissions during the hook.
113 |
114 | In the event of a UC_MEM_READ_UNMAPPED or UC_MEM_WRITE_UNMAPPED callback,
115 | the memory should be uc_mem_map()-ed with the correct permissions, and the
116 | instruction will then read or write to the address as it was supposed to.
117 |
118 | In the event of a UC_MEM_FETCH_UNMAPPED callback, the memory can be mapped
119 | in as executable, in which case execution will resume from the fetched address.
120 | The instruction pointer may be written to in order to change where execution resumes,
121 | but the fetch must succeed if execution is to resume.
122 | }
123 | uc_cb_eventmem_t = function(uc : uc_engine; _type : uc_mem_type; address : UInt64; size : integer; value : Int64; user_data : Pointer) : LongBool; cdecl;
124 |
125 |
126 | type
127 | {
128 | Memory region mapped by uc_mem_map() and uc_mem_map_ptr()
129 | Retrieve the list of memory regions with uc_mem_regions()
130 | }
131 | uc_mem_region = record
132 | rBegin : UInt64; // begin address of the region (inclusive)
133 | rEnd : UInt64; // end address of the region (inclusive)
134 | rPerms : UInt32; // memory permissions of the region
135 | end;
136 | uc_mem_regionArray = array[0..(MaxInt div SizeOf(uc_mem_region))-1] of uc_mem_region;
137 | Puc_mem_regionArray = ^uc_mem_regionArray;
138 |
139 |
140 | // Exports
141 | var
142 | (*
143 | Return combined API version & major and minor version numbers.
144 |
145 | @major: major number of API version
146 | @minor: minor number of API version
147 |
148 | @return hexical number as (major << 8 | minor), which encodes both
149 | major & minor versions.
150 | NOTE: This returned value can be compared with version number made
151 | with macro UC_MAKE_VERSION .
152 |
153 | For example, second API version would return 1 in @major, and 1 in @minor
154 | The return value would be 0x0101
155 |
156 | NOTE: if you only care about returned value, but not major and minor values,
157 | set both @major & @minor arguments to NULL.
158 | *)
159 | uc_version : function (var major, minor : Cardinal) : Cardinal; cdecl;
160 |
161 | (*
162 | Determine if the given architecture is supported by this library.
163 |
164 | @arch: architecture type (UC_ARCH_* )
165 |
166 | @return True if this library supports the given arch.
167 | *)
168 | uc_arch_supported : function (arch : uc_arch) : LongBool; cdecl;
169 |
170 | (*
171 | Create new instance of unicorn engine.
172 |
173 | @arch: architecture type (UC_ARCH_* )
174 | @mode: hardware mode. This is combined of UC_MODE_*
175 | @uc: pointer to uc_engine, which will be updated at return time
176 |
177 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
178 | for detailed error).
179 | *)
180 | uc_open : function (arch : uc_arch; mode : uc_mode; var uc : uc_engine) : uc_err; cdecl;
181 |
182 | (*
183 | Close UC instance: MUST do to release the handle when it is not used anymore.
184 | NOTE: this must be called only when there is no longer usage of Unicorn.
185 | The reason is the this API releases some cached memory, thus access to any
186 | Unicorn API after uc_close() might crash your application.
187 | After this, @uc is invalid, and nolonger usable.
188 |
189 | @uc: pointer to a handle returned by uc_open()
190 |
191 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
192 | for detailed error).
193 | *)
194 | uc_close : function (uc : uc_engine) : uc_err; cdecl;
195 |
196 | (*
197 | Query internal status of engine.
198 |
199 | @uc: handle returned by uc_open()
200 | @type: query type. See uc_query_type
201 |
202 | @result: save the internal status queried .
203 |
204 | @return: error code of uc_err enum type (UC_ERR_*, see above)
205 | *)
206 | uc_query : function (uc : uc_engine; qtype : uc_query_type; result : PCardinal) : uc_err ; cdecl;
207 |
208 |
209 | (*
210 | Report the last error number when some API function fail.
211 | Like glibc's errno, uc_errno might not retain its old value once accessed.
212 |
213 | @uc: handle returned by uc_open()
214 |
215 | @return: error code of uc_err enum type (UC_ERR_*, see above)
216 | *)
217 | uc_errno : function (uc : uc_engine) : uc_err; cdecl;
218 |
219 | (*
220 | Return a string describing given error code.
221 |
222 | @code: error code (see UC_ERR_* )
223 |
224 | @return: returns a pointer to a string that describes the error code
225 | passed in the argument @code
226 | *)
227 | uc_strerror : function (code : uc_err) : PAnsiChar; cdecl;
228 |
229 | (*
230 | Write to register.
231 |
232 | @uc: handle returned by uc_open()
233 | @regid: register ID that is to be modified.
234 | @value: pointer to the value that will set to register @regid .
235 |
236 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
237 | for detailed error).
238 | *)
239 | uc_reg_write : function (uc : uc_engine; regid : Integer; const value : Pointer) : uc_err; cdecl;
240 |
241 | (*
242 | Read register value.
243 |
244 | @uc: handle returned by uc_open()
245 | @regid: register ID that is to be retrieved.
246 | @value: pointer to a variable storing the register value.
247 |
248 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
249 | for detailed error).
250 | *)
251 | uc_reg_read: function (uc : uc_engine; regid : Integer; value : Pointer) : uc_err; cdecl ;
252 |
253 |
254 | (*
255 | Write multiple register values.
256 |
257 | @uc: handle returned by uc_open()
258 | @rges: array of register IDs to store
259 | @value: pointer to array of register values
260 | @count: length of both *regs and *vals
261 |
262 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
263 | for detailed error).
264 | *)
265 | uc_reg_write_batch : function(uc : uc_engine; regs : PIntegerArray; const values : Pointer; count : Integer) : uc_err; cdecl;
266 |
267 | (*
268 | Read multiple register values.
269 |
270 | @uc: handle returned by uc_open()
271 | @rges: array of register IDs to retrieve
272 | @value: pointer to array of values to hold registers
273 | @count: length of both *regs and *vals
274 |
275 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
276 | for detailed error).
277 | *)
278 | uc_reg_read_batch : function(uc : uc_engine; regs : PIntegerArray; var values : Pointer; count : integer) : uc_err; cdecl;
279 |
280 | (*
281 | Write to a range of bytes in memory.
282 |
283 | @uc: handle returned by uc_open()
284 | @address: starting memory address of bytes to set.
285 | @bytes: pointer to a variable containing data to be written to memory.
286 | @size: size of memory to write to.
287 |
288 | NOTE: @bytes must be big enough to contain @size bytes.
289 |
290 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
291 | for detailed error).
292 | *)
293 | uc_mem_write_ : function (uc : uc_engine; address : UInt64; const bytes : Pointer;
294 | size : Cardinal) : uc_err; cdecl;
295 |
296 | (*
297 | Read a range of bytes in memory.
298 |
299 | @uc: handle returned by uc_open()
300 | @address: starting memory address of bytes to get.
301 | @bytes: pointer to a variable containing data copied from memory.
302 | @size: size of memory to read.
303 |
304 | NOTE: @bytes must be big enough to contain @size bytes.
305 |
306 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
307 | for detailed error).
308 | *)
309 | uc_mem_read_ : function (uc : uc_engine; address : UInt64; bytes : Pointer;
310 | size : Cardinal) : uc_err; cdecl;
311 |
312 | (*
313 | Emulate machine code in a specific duration of time.
314 |
315 | @uc: handle returned by uc_open()
316 | @begin: address where emulation starts
317 | @until: address where emulation stops (i.e when this address is hit)
318 | @timeout: duration to emulate the code (in microseconds). When this value is 0,
319 | we will emulate the code in infinite time, until the code is finished.
320 | @count: the number of instructions to be emulated. When this value is 0,
321 | we will emulate all the code available, until the code is finished.
322 |
323 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
324 | for detailed error).
325 | *)
326 | uc_emu_start : function (uc : uc_engine; _begin, _until , timeout : UInt64;
327 | count : Cardinal) : uc_err; cdecl;
328 |
329 | (*
330 | Stop emulation (which was started by uc_emu_start() API.
331 | This is typically called from callback functions registered via tracing APIs.
332 | NOTE: for now, this will stop the execution only after the current block.
333 |
334 | @uc: handle returned by uc_open()
335 |
336 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
337 | for detailed error).
338 | *)
339 | uc_emu_stop : function (uc : uc_engine) : uc_err; cdecl;
340 |
341 | (*
342 | function (uc : uc_engine; var hh : uc_hook; _type : integer;
343 | callback : Pointer; user_data : Pointer; _Begin, _End : UInt64; args : Array Of Const) : uc_err; cdecl;
344 |
345 | Register callback for a hook event.
346 | The callback will be run when the hook event is hit.
347 |
348 | @uc: handle returned by uc_open()
349 | @hh: hook handle returned from this registration. To be used in uc_hook_del() API
350 | @type: hook type
351 | @callback: callback to be run when instruction is hit
352 | @user_data: user-defined data. This will be passed to callback function in its
353 | last argument @user_data
354 | @begin: start address of the area where the callback is effect (inclusive)
355 | @end: end address of the area where the callback is effect (inclusive)
356 | NOTE 1: the callback is called only if related address is in range [@begin, @end]
357 | NOTE 2: if @begin > @end, callback is called whenever this hook type is triggered
358 | @...: variable arguments (depending on @type)
359 | NOTE: if @type = UC_HOOK_INSN, this is the instruction ID (ex: UC_X86_INS_OUT)
360 |
361 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
362 | for detailed error).
363 | *)
364 | uc_hook_add : function (uc : uc_engine; var hh : uc_hook; _type : integer;
365 | callback : Pointer; user_data : Pointer; _Begin, _End : UInt64; args : Array Of Const) : uc_err; cdecl;
366 |
367 | //uc_hook_add_1 : function (uc : uc_engine; var hh : uc_hook; _type : integer;
368 | // callback : Pointer; user_data : Pointer; _Begin, _End : UInt64; arg1 : integer) : uc_err; cdecl;
369 | //
370 | //uc_hook_add_2 : function (uc : uc_engine; var hh : uc_hook; _type : integer;
371 | // callback : Pointer; user_data : Pointer; _Begin, _End : UInt64; arg1, arg2 : UInt64) : uc_err; cdecl;
372 | //
373 | (*
374 | Unregister (remove) a hook callback.
375 | This API removes the hook callback registered by uc_hook_add().
376 | NOTE: this should be called only when you no longer want to trace.
377 | After this, @hh is invalid, and nolonger usable.
378 |
379 | @uc: handle returned by uc_open()
380 | @hh: handle returned by uc_hook_add()
381 |
382 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
383 | for detailed error).
384 | *)
385 | uc_hook_del : function (uc : uc_engine; hh : uc_hook) : uc_err; cdecl ;
386 |
387 | (*
388 | Map memory in for emulation.
389 | This API adds a memory region that can be used by emulation.
390 |
391 | @uc: handle returned by uc_open()
392 | @address: starting address of the new memory region to be mapped in.
393 | This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
394 | @size: size of the new memory region to be mapped in.
395 | This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
396 | @perms: Permissions for the newly mapped region.
397 | This must be some combination of UC_PROT_READ | UC_PROT_WRITE | UC_PROT_EXEC,
398 | or this will return with UC_ERR_ARG error.
399 |
400 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
401 | for detailed error).
402 | *)
403 | uc_mem_map : function (uc : uc_engine; address : UInt64; size : Cardinal; perms : UInt32) : uc_err; cdecl;
404 |
405 |
406 | (*
407 | Map existing host memory in for emulation.
408 | This API adds a memory region that can be used by emulation.
409 |
410 | @uc: handle returned by uc_open()
411 | @address: starting address of the new memory region to be mapped in.
412 | This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
413 | @size: size of the new memory region to be mapped in.
414 | This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
415 | @perms: Permissions for the newly mapped region.
416 | This must be some combination of UC_PROT_READ | UC_PROT_WRITE | UC_PROT_EXEC,
417 | or this will return with UC_ERR_ARG error.
418 | @ptr: pointer to host memory backing the newly mapped memory. This host memory is
419 | expected to be an equal or larger size than provided, and be mapped with at
420 | least PROT_READ | PROT_WRITE. If it is not, the resulting behavior is undefined.
421 |
422 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
423 | for detailed error).
424 | *)
425 | uc_mem_map_ptr : function(uc : uc_engine; address : UInt64; size : Cardinal; perms : UInt32; ptr : Pointer) : uc_err; cdecl;
426 |
427 |
428 | (*
429 | Unmap a region of emulation memory.
430 | This API deletes a memory mapping from the emulation memory space.
431 |
432 | @handle: handle returned by uc_open()
433 | @address: starting address of the memory region to be unmapped.
434 | This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
435 | @size: size of the memory region to be modified.
436 | This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
437 |
438 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
439 | for detailed error).
440 | *)
441 | uc_mem_unmap : function (uc : uc_engine; address : UInt64; size : Cardinal) : uc_err; cdecl ;
442 |
443 | (*
444 | Set memory permissions for emulation memory.
445 | This API changes permissions on an existing memory region.
446 |
447 | @handle: handle returned by uc_open()
448 | @address: starting address of the memory region to be modified.
449 | This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
450 | @size: size of the memory region to be modified.
451 | This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
452 | @perms: New permissions for the mapped region.
453 | This must be some combination of UC_PROT_READ | UC_PROT_WRITE | UC_PROT_EXEC,
454 | or this will return with UC_ERR_ARG error.
455 |
456 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
457 | for detailed error).
458 | *)
459 | uc_mem_protect : function (uc : uc_engine; address : UInt64; size : Cardinal; perms : UInt32) : uc_err; cdecl ;
460 |
461 | (*
462 | Retrieve all memory regions mapped by uc_mem_map() and uc_mem_map_ptr()
463 | This API allocates memory for @regions, and user must free this memory later
464 | by free() to avoid leaking memory.
465 | NOTE: memory regions may be splitted by uc_mem_unmap()
466 |
467 | @uc: handle returned by uc_open()
468 | @regions: pointer to an array of uc_mem_region struct. >> Check "Puc_mem_regionArray"
469 | This is allocated by Unicorn, and must be freed by user later.
470 | @count: pointer to number of struct uc_mem_region contained in @regions
471 |
472 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
473 | for detailed error).
474 | *)
475 | uc_mem_regions : function(uc : uc_engine; var regions : Puc_mem_regionArray; count : PUInt32) : uc_err; cdecl ;
476 |
477 | (*
478 | Allocate a region that can be used with uc_context_{save,restore} to perform
479 | quick save/rollback of the CPU context, which includes registers and some
480 | internal metadata. Contexts may not be shared across engine instances with
481 | differing arches or modes.
482 |
483 | @uc: handle returned by uc_open()
484 | @context: pointer to a uc_engine*. This will be updated with the pointer to
485 | the new context on successful return of this function.
486 | Later, this allocated memory must be freed with uc_free().
487 |
488 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
489 | for detailed error).
490 | *)
491 | uc_context_alloc : function ( uc : uc_engine; var context : uc_context) : uc_err; cdecl ;
492 |
493 | (*
494 | Free the memory allocated by uc_context_alloc & uc_mem_regions.
495 |
496 | @mem: memory allocated by uc_context_alloc (returned in *context), or
497 | by uc_mem_regions (returned in *regions)
498 |
499 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
500 | for detailed error).
501 | *)
502 | uc_free : function (context : Pointer) : uc_err; cdecl ;
503 |
504 |
505 | (*
506 | Save a copy of the internal CPU context.
507 | This API should be used to efficiently make or update a saved copy of the
508 | internal CPU state.
509 |
510 | @uc: handle returned by uc_open()
511 | @context: handle returned by uc_context_alloc()
512 |
513 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
514 | for detailed error).
515 | *)
516 | uc_context_save : function ( uc : uc_engine; context : uc_context) : uc_err; cdecl;
517 |
518 | (*
519 | Restore the current CPU context from a saved copy.
520 | This API should be used to roll the CPU context back to a previous
521 | state saved by uc_context_save().
522 |
523 | @uc: handle returned by uc_open()
524 | @context: handle returned by uc_context_alloc that has been used with uc_context_save
525 |
526 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
527 | for detailed error).
528 | *)
529 | uc_context_restore : function(uc : uc_engine; context : uc_context) : uc_err; cdecl;
530 |
531 |
532 | {============================= Global Functions ================================}
533 |
534 | // function uc_hook_add(uc : uc_engine; var hh : uc_hook; _type : integer;
535 | // callback : Pointer; user_data : Pointer; mBegin, mEnd : UInt64) : uc_err; overload;
536 | //function uc_hook_add(uc : uc_engine; var hh : uc_hook; _type : integer;
537 | // callback : Pointer; user_data : Pointer; mBegin, mEnd , arg1 : UInt64) : uc_err; overload;
538 | //function uc_hook_add(uc : uc_engine; var hh : uc_hook; _type : integer;
539 | // callback : Pointer; user_data : Pointer; mBegin, mEnd , arg1, arg2 : UInt64) : uc_err; overload;
540 | //
541 |
542 | function UC_MAKE_VERSION(major,minor : Cardinal): Cardinal;
543 |
544 | implementation
545 |
546 | function UC_MAKE_VERSION(major,minor : Cardinal): Cardinal;
547 | begin
548 | Result := ((major shl 8) + minor);
549 | end;
550 |
551 | var
552 | UC_Handle : {$IFDEF FPC}dynlibs.{$ENDIF}HModule;
553 |
554 | function dyn_loadfunc(name : {$IFDEF FPC}string{$ELSE}PChar{$ENDIF}) : Pointer;
555 | begin
556 | Result := {$IFDEF FPC}dynlibs.{$ENDIF}GetProcAddress(UC_Handle,name);
557 | end;
558 |
559 | function loadUC(): Boolean;
560 | var
561 | LastError : String;
562 | begin
563 | Result := false;
564 | UC_Handle := {$IFDEF FPC}dynlibs.{$ENDIF}LoadLibrary(UNICORN_LIB);
565 | if UC_Handle <> 0 then
566 | begin
567 | @uc_version := dyn_loadfunc('uc_version');
568 | if (@uc_version = nil) then exit(false);
569 |
570 | @uc_arch_supported := dyn_loadfunc('uc_arch_supported');
571 | if (@uc_arch_supported = nil) then exit(false);
572 |
573 | @uc_open := dyn_loadfunc('uc_open');
574 | if (@uc_open = nil) then exit(false);
575 |
576 | @uc_close := dyn_loadfunc('uc_close');
577 | if (@uc_close = nil) then exit(false);
578 |
579 | @uc_query := dyn_loadfunc('uc_query');
580 | if (@uc_query = nil) then exit(false);
581 |
582 | @uc_errno := dyn_loadfunc('uc_errno');
583 | if (@uc_errno = nil) then exit(false);
584 |
585 | @uc_strerror := dyn_loadfunc('uc_strerror');
586 | if (@uc_strerror = nil) then exit(false);
587 |
588 | @uc_reg_write := dyn_loadfunc('uc_reg_write');
589 | if (@uc_reg_write = nil) then exit(false);
590 |
591 | @uc_reg_read := dyn_loadfunc('uc_reg_read');
592 | if (@uc_reg_read = nil) then exit(false);
593 |
594 | @uc_reg_write_batch := dyn_loadfunc('uc_reg_write_batch');
595 | if (@uc_reg_write_batch = nil) then exit(false);
596 |
597 | @uc_reg_read_batch := dyn_loadfunc('uc_reg_read_batch');
598 | if (@uc_reg_read_batch = nil) then exit(false);
599 |
600 | @uc_mem_write_ := dyn_loadfunc('uc_mem_write');
601 | if (@uc_mem_write_ = nil) then exit(false);
602 |
603 | @uc_mem_read_ := dyn_loadfunc('uc_mem_read');
604 | if (@uc_mem_read_ = nil) then exit(false);
605 |
606 | @uc_emu_start := dyn_loadfunc('uc_emu_start');
607 | if (@uc_emu_start = nil) then exit(false);
608 |
609 | @uc_emu_stop := dyn_loadfunc('uc_emu_stop');
610 | if (@uc_emu_stop = nil) then exit(false);
611 |
612 | @uc_hook_add := dyn_loadfunc('uc_hook_add');
613 | if (@uc_hook_add = nil) then exit(false);
614 |
615 | @uc_hook_del := dyn_loadfunc('uc_hook_del');
616 | if (@uc_hook_del = nil) then exit(false);
617 |
618 | @uc_mem_map := dyn_loadfunc('uc_mem_map');
619 | if (@uc_mem_map = nil) then exit(false);
620 |
621 | @uc_mem_map_ptr := dyn_loadfunc('uc_mem_map_ptr');
622 | if (@uc_mem_map_ptr = nil) then exit(false);
623 |
624 | @uc_mem_unmap := dyn_loadfunc('uc_mem_unmap');
625 | if (@uc_mem_unmap = nil) then exit(false);
626 |
627 | @uc_mem_protect := dyn_loadfunc('uc_mem_protect');
628 | if (@uc_mem_protect = nil) then exit(false);
629 |
630 | @uc_mem_regions := dyn_loadfunc('uc_mem_regions');
631 | if (@uc_mem_regions = nil) then exit(false);
632 |
633 | @uc_context_alloc := dyn_loadfunc('uc_context_alloc');
634 | if (@uc_context_alloc = nil) then exit(false);
635 |
636 | @uc_context_save := dyn_loadfunc('uc_context_save');
637 | if (@uc_context_save = nil) then exit(false);
638 |
639 | @uc_context_restore := dyn_loadfunc('uc_context_restore');
640 | if (@uc_context_restore = nil) then exit(false);
641 |
642 | @uc_free := dyn_loadfunc('uc_free');
643 | if (@uc_free = nil) then exit(false);
644 |
645 | Result := true;
646 | end
647 | else
648 | begin
649 | {$IFDEF FPC}TextColor(LightRed);{$ENDIF}
650 | LastError := {$IFDEF FPC}GetLoadErrorStr;{$ELSE}
651 | {$ifdef mswindows}
652 | SysErrorMessage(GetLastError,UC_Handle);
653 | SetLastError(0);
654 | {$ENDIF}
655 | {$ENDIF}
656 | WriteLn('error while loading unicorn library : ',LastError,#10);
657 | {$IFDEF FPC}NormVideo;{$ENDIF}
658 | end;
659 | end;
660 |
661 | procedure FreeUC();
662 | begin
663 | if UC_Handle <> 0 then
664 | {$IFDEF FPC}dynlibs.{$ENDIF}FreeLibrary(UC_Handle);
665 | end;
666 |
667 | initialization
668 | UC_Handle := 0;
669 | if not loadUC then halt(0);
670 |
671 | finalization
672 | FreeUC();
673 | end.
674 |
--------------------------------------------------------------------------------
/unicorn/include/unicorn/arm.h:
--------------------------------------------------------------------------------
1 | /* Unicorn Engine */
2 | /* By Nguyen Anh Quynh , 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 registers
19 | typedef enum uc_arm_reg {
20 | UC_ARM_REG_INVALID = 0,
21 | UC_ARM_REG_APSR,
22 | UC_ARM_REG_APSR_NZCV,
23 | UC_ARM_REG_CPSR,
24 | UC_ARM_REG_FPEXC,
25 | UC_ARM_REG_FPINST,
26 | UC_ARM_REG_FPSCR,
27 | UC_ARM_REG_FPSCR_NZCV,
28 | UC_ARM_REG_FPSID,
29 | UC_ARM_REG_ITSTATE,
30 | UC_ARM_REG_LR,
31 | UC_ARM_REG_PC,
32 | UC_ARM_REG_SP,
33 | UC_ARM_REG_SPSR,
34 | UC_ARM_REG_D0,
35 | UC_ARM_REG_D1,
36 | UC_ARM_REG_D2,
37 | UC_ARM_REG_D3,
38 | UC_ARM_REG_D4,
39 | UC_ARM_REG_D5,
40 | UC_ARM_REG_D6,
41 | UC_ARM_REG_D7,
42 | UC_ARM_REG_D8,
43 | UC_ARM_REG_D9,
44 | UC_ARM_REG_D10,
45 | UC_ARM_REG_D11,
46 | UC_ARM_REG_D12,
47 | UC_ARM_REG_D13,
48 | UC_ARM_REG_D14,
49 | UC_ARM_REG_D15,
50 | UC_ARM_REG_D16,
51 | UC_ARM_REG_D17,
52 | UC_ARM_REG_D18,
53 | UC_ARM_REG_D19,
54 | UC_ARM_REG_D20,
55 | UC_ARM_REG_D21,
56 | UC_ARM_REG_D22,
57 | UC_ARM_REG_D23,
58 | UC_ARM_REG_D24,
59 | UC_ARM_REG_D25,
60 | UC_ARM_REG_D26,
61 | UC_ARM_REG_D27,
62 | UC_ARM_REG_D28,
63 | UC_ARM_REG_D29,
64 | UC_ARM_REG_D30,
65 | UC_ARM_REG_D31,
66 | UC_ARM_REG_FPINST2,
67 | UC_ARM_REG_MVFR0,
68 | UC_ARM_REG_MVFR1,
69 | UC_ARM_REG_MVFR2,
70 | UC_ARM_REG_Q0,
71 | UC_ARM_REG_Q1,
72 | UC_ARM_REG_Q2,
73 | UC_ARM_REG_Q3,
74 | UC_ARM_REG_Q4,
75 | UC_ARM_REG_Q5,
76 | UC_ARM_REG_Q6,
77 | UC_ARM_REG_Q7,
78 | UC_ARM_REG_Q8,
79 | UC_ARM_REG_Q9,
80 | UC_ARM_REG_Q10,
81 | UC_ARM_REG_Q11,
82 | UC_ARM_REG_Q12,
83 | UC_ARM_REG_Q13,
84 | UC_ARM_REG_Q14,
85 | UC_ARM_REG_Q15,
86 | UC_ARM_REG_R0,
87 | UC_ARM_REG_R1,
88 | UC_ARM_REG_R2,
89 | UC_ARM_REG_R3,
90 | UC_ARM_REG_R4,
91 | UC_ARM_REG_R5,
92 | UC_ARM_REG_R6,
93 | UC_ARM_REG_R7,
94 | UC_ARM_REG_R8,
95 | UC_ARM_REG_R9,
96 | UC_ARM_REG_R10,
97 | UC_ARM_REG_R11,
98 | UC_ARM_REG_R12,
99 | UC_ARM_REG_S0,
100 | UC_ARM_REG_S1,
101 | UC_ARM_REG_S2,
102 | UC_ARM_REG_S3,
103 | UC_ARM_REG_S4,
104 | UC_ARM_REG_S5,
105 | UC_ARM_REG_S6,
106 | UC_ARM_REG_S7,
107 | UC_ARM_REG_S8,
108 | UC_ARM_REG_S9,
109 | UC_ARM_REG_S10,
110 | UC_ARM_REG_S11,
111 | UC_ARM_REG_S12,
112 | UC_ARM_REG_S13,
113 | UC_ARM_REG_S14,
114 | UC_ARM_REG_S15,
115 | UC_ARM_REG_S16,
116 | UC_ARM_REG_S17,
117 | UC_ARM_REG_S18,
118 | UC_ARM_REG_S19,
119 | UC_ARM_REG_S20,
120 | UC_ARM_REG_S21,
121 | UC_ARM_REG_S22,
122 | UC_ARM_REG_S23,
123 | UC_ARM_REG_S24,
124 | UC_ARM_REG_S25,
125 | UC_ARM_REG_S26,
126 | UC_ARM_REG_S27,
127 | UC_ARM_REG_S28,
128 | UC_ARM_REG_S29,
129 | UC_ARM_REG_S30,
130 | UC_ARM_REG_S31,
131 |
132 | UC_ARM_REG_C1_C0_2,
133 | UC_ARM_REG_C13_C0_2,
134 | UC_ARM_REG_C13_C0_3,
135 |
136 | UC_ARM_REG_ENDING, // <-- mark the end of the list or registers
137 |
138 | //> alias registers
139 | UC_ARM_REG_R13 = UC_ARM_REG_SP,
140 | UC_ARM_REG_R14 = UC_ARM_REG_LR,
141 | UC_ARM_REG_R15 = UC_ARM_REG_PC,
142 |
143 | UC_ARM_REG_SB = UC_ARM_REG_R9,
144 | UC_ARM_REG_SL = UC_ARM_REG_R10,
145 | UC_ARM_REG_FP = UC_ARM_REG_R11,
146 | UC_ARM_REG_IP = UC_ARM_REG_R12,
147 | } uc_arm_reg;
148 |
149 | #ifdef __cplusplus
150 | }
151 | #endif
152 |
153 | #endif
154 |
--------------------------------------------------------------------------------
/unicorn/include/unicorn/arm64.h:
--------------------------------------------------------------------------------
1 | /* Unicorn Emulator Engine */
2 | /* By Nguyen Anh Quynh , 2015-2017 */
3 | /* This file is released under LGPL2.
4 | See COPYING.LGPL2 in root directory for more details
5 | */
6 |
7 | #ifndef UNICORN_ARM64_H
8 | #define UNICORN_ARM64_H
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | #ifdef _MSC_VER
15 | #pragma warning(disable:4201)
16 | #endif
17 |
18 | //> ARM64 registers
19 | typedef enum uc_arm64_reg {
20 | UC_ARM64_REG_INVALID = 0,
21 |
22 | UC_ARM64_REG_X29,
23 | UC_ARM64_REG_X30,
24 | UC_ARM64_REG_NZCV,
25 | UC_ARM64_REG_SP,
26 | UC_ARM64_REG_WSP,
27 | UC_ARM64_REG_WZR,
28 | UC_ARM64_REG_XZR,
29 | UC_ARM64_REG_B0,
30 | UC_ARM64_REG_B1,
31 | UC_ARM64_REG_B2,
32 | UC_ARM64_REG_B3,
33 | UC_ARM64_REG_B4,
34 | UC_ARM64_REG_B5,
35 | UC_ARM64_REG_B6,
36 | UC_ARM64_REG_B7,
37 | UC_ARM64_REG_B8,
38 | UC_ARM64_REG_B9,
39 | UC_ARM64_REG_B10,
40 | UC_ARM64_REG_B11,
41 | UC_ARM64_REG_B12,
42 | UC_ARM64_REG_B13,
43 | UC_ARM64_REG_B14,
44 | UC_ARM64_REG_B15,
45 | UC_ARM64_REG_B16,
46 | UC_ARM64_REG_B17,
47 | UC_ARM64_REG_B18,
48 | UC_ARM64_REG_B19,
49 | UC_ARM64_REG_B20,
50 | UC_ARM64_REG_B21,
51 | UC_ARM64_REG_B22,
52 | UC_ARM64_REG_B23,
53 | UC_ARM64_REG_B24,
54 | UC_ARM64_REG_B25,
55 | UC_ARM64_REG_B26,
56 | UC_ARM64_REG_B27,
57 | UC_ARM64_REG_B28,
58 | UC_ARM64_REG_B29,
59 | UC_ARM64_REG_B30,
60 | UC_ARM64_REG_B31,
61 | UC_ARM64_REG_D0,
62 | UC_ARM64_REG_D1,
63 | UC_ARM64_REG_D2,
64 | UC_ARM64_REG_D3,
65 | UC_ARM64_REG_D4,
66 | UC_ARM64_REG_D5,
67 | UC_ARM64_REG_D6,
68 | UC_ARM64_REG_D7,
69 | UC_ARM64_REG_D8,
70 | UC_ARM64_REG_D9,
71 | UC_ARM64_REG_D10,
72 | UC_ARM64_REG_D11,
73 | UC_ARM64_REG_D12,
74 | UC_ARM64_REG_D13,
75 | UC_ARM64_REG_D14,
76 | UC_ARM64_REG_D15,
77 | UC_ARM64_REG_D16,
78 | UC_ARM64_REG_D17,
79 | UC_ARM64_REG_D18,
80 | UC_ARM64_REG_D19,
81 | UC_ARM64_REG_D20,
82 | UC_ARM64_REG_D21,
83 | UC_ARM64_REG_D22,
84 | UC_ARM64_REG_D23,
85 | UC_ARM64_REG_D24,
86 | UC_ARM64_REG_D25,
87 | UC_ARM64_REG_D26,
88 | UC_ARM64_REG_D27,
89 | UC_ARM64_REG_D28,
90 | UC_ARM64_REG_D29,
91 | UC_ARM64_REG_D30,
92 | UC_ARM64_REG_D31,
93 | UC_ARM64_REG_H0,
94 | UC_ARM64_REG_H1,
95 | UC_ARM64_REG_H2,
96 | UC_ARM64_REG_H3,
97 | UC_ARM64_REG_H4,
98 | UC_ARM64_REG_H5,
99 | UC_ARM64_REG_H6,
100 | UC_ARM64_REG_H7,
101 | UC_ARM64_REG_H8,
102 | UC_ARM64_REG_H9,
103 | UC_ARM64_REG_H10,
104 | UC_ARM64_REG_H11,
105 | UC_ARM64_REG_H12,
106 | UC_ARM64_REG_H13,
107 | UC_ARM64_REG_H14,
108 | UC_ARM64_REG_H15,
109 | UC_ARM64_REG_H16,
110 | UC_ARM64_REG_H17,
111 | UC_ARM64_REG_H18,
112 | UC_ARM64_REG_H19,
113 | UC_ARM64_REG_H20,
114 | UC_ARM64_REG_H21,
115 | UC_ARM64_REG_H22,
116 | UC_ARM64_REG_H23,
117 | UC_ARM64_REG_H24,
118 | UC_ARM64_REG_H25,
119 | UC_ARM64_REG_H26,
120 | UC_ARM64_REG_H27,
121 | UC_ARM64_REG_H28,
122 | UC_ARM64_REG_H29,
123 | UC_ARM64_REG_H30,
124 | UC_ARM64_REG_H31,
125 | UC_ARM64_REG_Q0,
126 | UC_ARM64_REG_Q1,
127 | UC_ARM64_REG_Q2,
128 | UC_ARM64_REG_Q3,
129 | UC_ARM64_REG_Q4,
130 | UC_ARM64_REG_Q5,
131 | UC_ARM64_REG_Q6,
132 | UC_ARM64_REG_Q7,
133 | UC_ARM64_REG_Q8,
134 | UC_ARM64_REG_Q9,
135 | UC_ARM64_REG_Q10,
136 | UC_ARM64_REG_Q11,
137 | UC_ARM64_REG_Q12,
138 | UC_ARM64_REG_Q13,
139 | UC_ARM64_REG_Q14,
140 | UC_ARM64_REG_Q15,
141 | UC_ARM64_REG_Q16,
142 | UC_ARM64_REG_Q17,
143 | UC_ARM64_REG_Q18,
144 | UC_ARM64_REG_Q19,
145 | UC_ARM64_REG_Q20,
146 | UC_ARM64_REG_Q21,
147 | UC_ARM64_REG_Q22,
148 | UC_ARM64_REG_Q23,
149 | UC_ARM64_REG_Q24,
150 | UC_ARM64_REG_Q25,
151 | UC_ARM64_REG_Q26,
152 | UC_ARM64_REG_Q27,
153 | UC_ARM64_REG_Q28,
154 | UC_ARM64_REG_Q29,
155 | UC_ARM64_REG_Q30,
156 | UC_ARM64_REG_Q31,
157 | UC_ARM64_REG_S0,
158 | UC_ARM64_REG_S1,
159 | UC_ARM64_REG_S2,
160 | UC_ARM64_REG_S3,
161 | UC_ARM64_REG_S4,
162 | UC_ARM64_REG_S5,
163 | UC_ARM64_REG_S6,
164 | UC_ARM64_REG_S7,
165 | UC_ARM64_REG_S8,
166 | UC_ARM64_REG_S9,
167 | UC_ARM64_REG_S10,
168 | UC_ARM64_REG_S11,
169 | UC_ARM64_REG_S12,
170 | UC_ARM64_REG_S13,
171 | UC_ARM64_REG_S14,
172 | UC_ARM64_REG_S15,
173 | UC_ARM64_REG_S16,
174 | UC_ARM64_REG_S17,
175 | UC_ARM64_REG_S18,
176 | UC_ARM64_REG_S19,
177 | UC_ARM64_REG_S20,
178 | UC_ARM64_REG_S21,
179 | UC_ARM64_REG_S22,
180 | UC_ARM64_REG_S23,
181 | UC_ARM64_REG_S24,
182 | UC_ARM64_REG_S25,
183 | UC_ARM64_REG_S26,
184 | UC_ARM64_REG_S27,
185 | UC_ARM64_REG_S28,
186 | UC_ARM64_REG_S29,
187 | UC_ARM64_REG_S30,
188 | UC_ARM64_REG_S31,
189 | UC_ARM64_REG_W0,
190 | UC_ARM64_REG_W1,
191 | UC_ARM64_REG_W2,
192 | UC_ARM64_REG_W3,
193 | UC_ARM64_REG_W4,
194 | UC_ARM64_REG_W5,
195 | UC_ARM64_REG_W6,
196 | UC_ARM64_REG_W7,
197 | UC_ARM64_REG_W8,
198 | UC_ARM64_REG_W9,
199 | UC_ARM64_REG_W10,
200 | UC_ARM64_REG_W11,
201 | UC_ARM64_REG_W12,
202 | UC_ARM64_REG_W13,
203 | UC_ARM64_REG_W14,
204 | UC_ARM64_REG_W15,
205 | UC_ARM64_REG_W16,
206 | UC_ARM64_REG_W17,
207 | UC_ARM64_REG_W18,
208 | UC_ARM64_REG_W19,
209 | UC_ARM64_REG_W20,
210 | UC_ARM64_REG_W21,
211 | UC_ARM64_REG_W22,
212 | UC_ARM64_REG_W23,
213 | UC_ARM64_REG_W24,
214 | UC_ARM64_REG_W25,
215 | UC_ARM64_REG_W26,
216 | UC_ARM64_REG_W27,
217 | UC_ARM64_REG_W28,
218 | UC_ARM64_REG_W29,
219 | UC_ARM64_REG_W30,
220 | UC_ARM64_REG_X0,
221 | UC_ARM64_REG_X1,
222 | UC_ARM64_REG_X2,
223 | UC_ARM64_REG_X3,
224 | UC_ARM64_REG_X4,
225 | UC_ARM64_REG_X5,
226 | UC_ARM64_REG_X6,
227 | UC_ARM64_REG_X7,
228 | UC_ARM64_REG_X8,
229 | UC_ARM64_REG_X9,
230 | UC_ARM64_REG_X10,
231 | UC_ARM64_REG_X11,
232 | UC_ARM64_REG_X12,
233 | UC_ARM64_REG_X13,
234 | UC_ARM64_REG_X14,
235 | UC_ARM64_REG_X15,
236 | UC_ARM64_REG_X16,
237 | UC_ARM64_REG_X17,
238 | UC_ARM64_REG_X18,
239 | UC_ARM64_REG_X19,
240 | UC_ARM64_REG_X20,
241 | UC_ARM64_REG_X21,
242 | UC_ARM64_REG_X22,
243 | UC_ARM64_REG_X23,
244 | UC_ARM64_REG_X24,
245 | UC_ARM64_REG_X25,
246 | UC_ARM64_REG_X26,
247 | UC_ARM64_REG_X27,
248 | UC_ARM64_REG_X28,
249 |
250 | UC_ARM64_REG_V0,
251 | UC_ARM64_REG_V1,
252 | UC_ARM64_REG_V2,
253 | UC_ARM64_REG_V3,
254 | UC_ARM64_REG_V4,
255 | UC_ARM64_REG_V5,
256 | UC_ARM64_REG_V6,
257 | UC_ARM64_REG_V7,
258 | UC_ARM64_REG_V8,
259 | UC_ARM64_REG_V9,
260 | UC_ARM64_REG_V10,
261 | UC_ARM64_REG_V11,
262 | UC_ARM64_REG_V12,
263 | UC_ARM64_REG_V13,
264 | UC_ARM64_REG_V14,
265 | UC_ARM64_REG_V15,
266 | UC_ARM64_REG_V16,
267 | UC_ARM64_REG_V17,
268 | UC_ARM64_REG_V18,
269 | UC_ARM64_REG_V19,
270 | UC_ARM64_REG_V20,
271 | UC_ARM64_REG_V21,
272 | UC_ARM64_REG_V22,
273 | UC_ARM64_REG_V23,
274 | UC_ARM64_REG_V24,
275 | UC_ARM64_REG_V25,
276 | UC_ARM64_REG_V26,
277 | UC_ARM64_REG_V27,
278 | UC_ARM64_REG_V28,
279 | UC_ARM64_REG_V29,
280 | UC_ARM64_REG_V30,
281 | UC_ARM64_REG_V31,
282 |
283 | //> pseudo registers
284 | UC_ARM64_REG_PC, // program counter register
285 |
286 | UC_ARM64_REG_CPACR_EL1,
287 |
288 | //> thread registers
289 | UC_ARM64_REG_TPIDR_EL0,
290 | UC_ARM64_REG_TPIDRRO_EL0,
291 | UC_ARM64_REG_TPIDR_EL1,
292 |
293 | UC_ARM64_REG_ENDING, // <-- mark the end of the list of registers
294 |
295 | //> alias registers
296 |
297 | UC_ARM64_REG_IP0 = UC_ARM64_REG_X16,
298 | UC_ARM64_REG_IP1 = UC_ARM64_REG_X17,
299 | UC_ARM64_REG_FP = UC_ARM64_REG_X29,
300 | UC_ARM64_REG_LR = UC_ARM64_REG_X30,
301 | } uc_arm64_reg;
302 |
303 | #ifdef __cplusplus
304 | }
305 | #endif
306 |
307 | #endif
308 |
--------------------------------------------------------------------------------
/unicorn/include/unicorn/m68k.h:
--------------------------------------------------------------------------------
1 | /* Unicorn Emulator Engine */
2 | /* By Nguyen Anh Quynh , 2014-2017 */
3 | /* This file is released under LGPL2.
4 | See COPYING.LGPL2 in root directory for more details
5 | */
6 |
7 | #ifndef UNICORN_M68K_H
8 | #define UNICORN_M68K_H
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | #ifdef _MSC_VER
15 | #pragma warning(disable:4201)
16 | #endif
17 |
18 | //> M68K registers
19 | typedef enum uc_m68k_reg {
20 | UC_M68K_REG_INVALID = 0,
21 |
22 | UC_M68K_REG_A0,
23 | UC_M68K_REG_A1,
24 | UC_M68K_REG_A2,
25 | UC_M68K_REG_A3,
26 | UC_M68K_REG_A4,
27 | UC_M68K_REG_A5,
28 | UC_M68K_REG_A6,
29 | UC_M68K_REG_A7,
30 |
31 | UC_M68K_REG_D0,
32 | UC_M68K_REG_D1,
33 | UC_M68K_REG_D2,
34 | UC_M68K_REG_D3,
35 | UC_M68K_REG_D4,
36 | UC_M68K_REG_D5,
37 | UC_M68K_REG_D6,
38 | UC_M68K_REG_D7,
39 |
40 | UC_M68K_REG_SR,
41 | UC_M68K_REG_PC,
42 |
43 | UC_M68K_REG_ENDING, // <-- mark the end of the list of registers
44 | } uc_m68k_reg;
45 |
46 | #ifdef __cplusplus
47 | }
48 | #endif
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/unicorn/include/unicorn/mips.h:
--------------------------------------------------------------------------------
1 | /* Unicorn Emulator Engine */
2 | /* By Nguyen Anh Quynh , 2015-2017 */
3 | /* This file is released under LGPL2.
4 | See COPYING.LGPL2 in root directory for more details
5 | */
6 |
7 | #ifndef UNICORN_MIPS_H
8 | #define UNICORN_MIPS_H
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | // GCC MIPS toolchain has a default macro called "mips" which breaks
15 | // compilation
16 | #undef mips
17 |
18 | #ifdef _MSC_VER
19 | #pragma warning(disable:4201)
20 | #endif
21 |
22 | //> MIPS registers
23 | typedef enum UC_MIPS_REG {
24 | UC_MIPS_REG_INVALID = 0,
25 | //> General purpose registers
26 | UC_MIPS_REG_PC,
27 |
28 | UC_MIPS_REG_0,
29 | UC_MIPS_REG_1,
30 | UC_MIPS_REG_2,
31 | UC_MIPS_REG_3,
32 | UC_MIPS_REG_4,
33 | UC_MIPS_REG_5,
34 | UC_MIPS_REG_6,
35 | UC_MIPS_REG_7,
36 | UC_MIPS_REG_8,
37 | UC_MIPS_REG_9,
38 | UC_MIPS_REG_10,
39 | UC_MIPS_REG_11,
40 | UC_MIPS_REG_12,
41 | UC_MIPS_REG_13,
42 | UC_MIPS_REG_14,
43 | UC_MIPS_REG_15,
44 | UC_MIPS_REG_16,
45 | UC_MIPS_REG_17,
46 | UC_MIPS_REG_18,
47 | UC_MIPS_REG_19,
48 | UC_MIPS_REG_20,
49 | UC_MIPS_REG_21,
50 | UC_MIPS_REG_22,
51 | UC_MIPS_REG_23,
52 | UC_MIPS_REG_24,
53 | UC_MIPS_REG_25,
54 | UC_MIPS_REG_26,
55 | UC_MIPS_REG_27,
56 | UC_MIPS_REG_28,
57 | UC_MIPS_REG_29,
58 | UC_MIPS_REG_30,
59 | UC_MIPS_REG_31,
60 |
61 | //> DSP registers
62 | UC_MIPS_REG_DSPCCOND,
63 | UC_MIPS_REG_DSPCARRY,
64 | UC_MIPS_REG_DSPEFI,
65 | UC_MIPS_REG_DSPOUTFLAG,
66 | UC_MIPS_REG_DSPOUTFLAG16_19,
67 | UC_MIPS_REG_DSPOUTFLAG20,
68 | UC_MIPS_REG_DSPOUTFLAG21,
69 | UC_MIPS_REG_DSPOUTFLAG22,
70 | UC_MIPS_REG_DSPOUTFLAG23,
71 | UC_MIPS_REG_DSPPOS,
72 | UC_MIPS_REG_DSPSCOUNT,
73 |
74 | //> ACC registers
75 | UC_MIPS_REG_AC0,
76 | UC_MIPS_REG_AC1,
77 | UC_MIPS_REG_AC2,
78 | UC_MIPS_REG_AC3,
79 |
80 | //> COP registers
81 | UC_MIPS_REG_CC0,
82 | UC_MIPS_REG_CC1,
83 | UC_MIPS_REG_CC2,
84 | UC_MIPS_REG_CC3,
85 | UC_MIPS_REG_CC4,
86 | UC_MIPS_REG_CC5,
87 | UC_MIPS_REG_CC6,
88 | UC_MIPS_REG_CC7,
89 |
90 | //> FPU registers
91 | UC_MIPS_REG_F0,
92 | UC_MIPS_REG_F1,
93 | UC_MIPS_REG_F2,
94 | UC_MIPS_REG_F3,
95 | UC_MIPS_REG_F4,
96 | UC_MIPS_REG_F5,
97 | UC_MIPS_REG_F6,
98 | UC_MIPS_REG_F7,
99 | UC_MIPS_REG_F8,
100 | UC_MIPS_REG_F9,
101 | UC_MIPS_REG_F10,
102 | UC_MIPS_REG_F11,
103 | UC_MIPS_REG_F12,
104 | UC_MIPS_REG_F13,
105 | UC_MIPS_REG_F14,
106 | UC_MIPS_REG_F15,
107 | UC_MIPS_REG_F16,
108 | UC_MIPS_REG_F17,
109 | UC_MIPS_REG_F18,
110 | UC_MIPS_REG_F19,
111 | UC_MIPS_REG_F20,
112 | UC_MIPS_REG_F21,
113 | UC_MIPS_REG_F22,
114 | UC_MIPS_REG_F23,
115 | UC_MIPS_REG_F24,
116 | UC_MIPS_REG_F25,
117 | UC_MIPS_REG_F26,
118 | UC_MIPS_REG_F27,
119 | UC_MIPS_REG_F28,
120 | UC_MIPS_REG_F29,
121 | UC_MIPS_REG_F30,
122 | UC_MIPS_REG_F31,
123 |
124 | UC_MIPS_REG_FCC0,
125 | UC_MIPS_REG_FCC1,
126 | UC_MIPS_REG_FCC2,
127 | UC_MIPS_REG_FCC3,
128 | UC_MIPS_REG_FCC4,
129 | UC_MIPS_REG_FCC5,
130 | UC_MIPS_REG_FCC6,
131 | UC_MIPS_REG_FCC7,
132 |
133 | //> AFPR128
134 | UC_MIPS_REG_W0,
135 | UC_MIPS_REG_W1,
136 | UC_MIPS_REG_W2,
137 | UC_MIPS_REG_W3,
138 | UC_MIPS_REG_W4,
139 | UC_MIPS_REG_W5,
140 | UC_MIPS_REG_W6,
141 | UC_MIPS_REG_W7,
142 | UC_MIPS_REG_W8,
143 | UC_MIPS_REG_W9,
144 | UC_MIPS_REG_W10,
145 | UC_MIPS_REG_W11,
146 | UC_MIPS_REG_W12,
147 | UC_MIPS_REG_W13,
148 | UC_MIPS_REG_W14,
149 | UC_MIPS_REG_W15,
150 | UC_MIPS_REG_W16,
151 | UC_MIPS_REG_W17,
152 | UC_MIPS_REG_W18,
153 | UC_MIPS_REG_W19,
154 | UC_MIPS_REG_W20,
155 | UC_MIPS_REG_W21,
156 | UC_MIPS_REG_W22,
157 | UC_MIPS_REG_W23,
158 | UC_MIPS_REG_W24,
159 | UC_MIPS_REG_W25,
160 | UC_MIPS_REG_W26,
161 | UC_MIPS_REG_W27,
162 | UC_MIPS_REG_W28,
163 | UC_MIPS_REG_W29,
164 | UC_MIPS_REG_W30,
165 | UC_MIPS_REG_W31,
166 |
167 | UC_MIPS_REG_HI,
168 | UC_MIPS_REG_LO,
169 |
170 | UC_MIPS_REG_P0,
171 | UC_MIPS_REG_P1,
172 | UC_MIPS_REG_P2,
173 |
174 | UC_MIPS_REG_MPL0,
175 | UC_MIPS_REG_MPL1,
176 | UC_MIPS_REG_MPL2,
177 |
178 | UC_MIPS_REG_ENDING, // <-- mark the end of the list or registers
179 |
180 | // alias registers
181 | UC_MIPS_REG_ZERO = UC_MIPS_REG_0,
182 | UC_MIPS_REG_AT = UC_MIPS_REG_1,
183 | UC_MIPS_REG_V0 = UC_MIPS_REG_2,
184 | UC_MIPS_REG_V1 = UC_MIPS_REG_3,
185 | UC_MIPS_REG_A0 = UC_MIPS_REG_4,
186 | UC_MIPS_REG_A1 = UC_MIPS_REG_5,
187 | UC_MIPS_REG_A2 = UC_MIPS_REG_6,
188 | UC_MIPS_REG_A3 = UC_MIPS_REG_7,
189 | UC_MIPS_REG_T0 = UC_MIPS_REG_8,
190 | UC_MIPS_REG_T1 = UC_MIPS_REG_9,
191 | UC_MIPS_REG_T2 = UC_MIPS_REG_10,
192 | UC_MIPS_REG_T3 = UC_MIPS_REG_11,
193 | UC_MIPS_REG_T4 = UC_MIPS_REG_12,
194 | UC_MIPS_REG_T5 = UC_MIPS_REG_13,
195 | UC_MIPS_REG_T6 = UC_MIPS_REG_14,
196 | UC_MIPS_REG_T7 = UC_MIPS_REG_15,
197 | UC_MIPS_REG_S0 = UC_MIPS_REG_16,
198 | UC_MIPS_REG_S1 = UC_MIPS_REG_17,
199 | UC_MIPS_REG_S2 = UC_MIPS_REG_18,
200 | UC_MIPS_REG_S3 = UC_MIPS_REG_19,
201 | UC_MIPS_REG_S4 = UC_MIPS_REG_20,
202 | UC_MIPS_REG_S5 = UC_MIPS_REG_21,
203 | UC_MIPS_REG_S6 = UC_MIPS_REG_22,
204 | UC_MIPS_REG_S7 = UC_MIPS_REG_23,
205 | UC_MIPS_REG_T8 = UC_MIPS_REG_24,
206 | UC_MIPS_REG_T9 = UC_MIPS_REG_25,
207 | UC_MIPS_REG_K0 = UC_MIPS_REG_26,
208 | UC_MIPS_REG_K1 = UC_MIPS_REG_27,
209 | UC_MIPS_REG_GP = UC_MIPS_REG_28,
210 | UC_MIPS_REG_SP = UC_MIPS_REG_29,
211 | UC_MIPS_REG_FP = UC_MIPS_REG_30, UC_MIPS_REG_S8 = UC_MIPS_REG_30,
212 | UC_MIPS_REG_RA = UC_MIPS_REG_31,
213 |
214 | UC_MIPS_REG_HI0 = UC_MIPS_REG_AC0,
215 | UC_MIPS_REG_HI1 = UC_MIPS_REG_AC1,
216 | UC_MIPS_REG_HI2 = UC_MIPS_REG_AC2,
217 | UC_MIPS_REG_HI3 = UC_MIPS_REG_AC3,
218 |
219 | UC_MIPS_REG_LO0 = UC_MIPS_REG_HI0,
220 | UC_MIPS_REG_LO1 = UC_MIPS_REG_HI1,
221 | UC_MIPS_REG_LO2 = UC_MIPS_REG_HI2,
222 | UC_MIPS_REG_LO3 = UC_MIPS_REG_HI3,
223 | } UC_MIPS_REG;
224 |
225 | #ifdef __cplusplus
226 | }
227 | #endif
228 |
229 | #endif
230 |
--------------------------------------------------------------------------------
/unicorn/include/unicorn/platform.h:
--------------------------------------------------------------------------------
1 | /* This file is released under LGPL2.
2 | See COPYING.LGPL2 in root directory for more details
3 | */
4 |
5 | /*
6 | This file is to support header files that are missing in MSVC and
7 | other non-standard compilers.
8 | */
9 | #ifndef UNICORN_PLATFORM_H
10 | #define UNICORN_PLATFORM_H
11 |
12 | /*
13 | These are the various MSVC versions as given by _MSC_VER:
14 | MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
15 | MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
16 | MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
17 | MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
18 | MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
19 | MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
20 | MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio 2003)
21 | MSVC++ 7.0 _MSC_VER == 1300
22 | MSVC++ 6.0 _MSC_VER == 1200
23 | MSVC++ 5.0 _MSC_VER == 1100
24 | */
25 | #define MSC_VER_VS2003 1310
26 | #define MSC_VER_VS2005 1400
27 | #define MSC_VER_VS2008 1500
28 | #define MSC_VER_VS2010 1600
29 | #define MSC_VER_VS2012 1700
30 | #define MSC_VER_VS2013 1800
31 | #define MSC_VER_VS2015 1900
32 |
33 | // handle stdbool.h compatibility
34 | #if !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64))
35 | // MSVC
36 |
37 | // stdbool.h
38 | #if (_MSC_VER < MSC_VER_VS2013) || defined(_KERNEL_MODE)
39 | // this system does not have stdbool.h
40 | #ifndef __cplusplus
41 | typedef unsigned char bool;
42 | #define false 0
43 | #define true 1
44 | #endif // __cplusplus
45 |
46 | #else
47 | // VisualStudio 2013+ -> C99 is supported
48 | #include
49 | #endif // (_MSC_VER < MSC_VER_VS2013) || defined(_KERNEL_MODE)
50 |
51 | #else
52 | // not MSVC -> C99 is supported
53 | #include
54 | #endif // !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64))
55 |
56 | #if (defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2010)) || defined(_KERNEL_MODE)
57 | // this system does not have stdint.h
58 | typedef signed char int8_t;
59 | typedef signed short int16_t;
60 | typedef signed int int32_t;
61 | typedef unsigned char uint8_t;
62 | typedef unsigned short uint16_t;
63 | typedef unsigned int uint32_t;
64 | typedef signed long long int64_t;
65 | typedef unsigned long long uint64_t;
66 |
67 | #ifndef _INTPTR_T_DEFINED
68 | #define _INTPTR_T_DEFINED
69 | #ifdef _WIN64
70 | typedef long long intptr_t;
71 | #else /* _WIN64 */
72 | typedef _W64 int intptr_t;
73 | #endif /* _WIN64 */
74 | #endif /* _INTPTR_T_DEFINED */
75 |
76 | #ifndef _UINTPTR_T_DEFINED
77 | #define _UINTPTR_T_DEFINED
78 | #ifdef _WIN64
79 | typedef unsigned long long uintptr_t;
80 | #else /* _WIN64 */
81 | typedef _W64 unsigned int uintptr_t;
82 | #endif /* _WIN64 */
83 | #endif /* _UINTPTR_T_DEFINED */
84 |
85 | #define INT8_MIN (-127i8 - 1)
86 | #define INT16_MIN (-32767i16 - 1)
87 | #define INT32_MIN (-2147483647i32 - 1)
88 | #define INT64_MIN (-9223372036854775807i64 - 1)
89 | #define INT8_MAX 127i8
90 | #define INT16_MAX 32767i16
91 | #define INT32_MAX 2147483647i32
92 | #define INT64_MAX 9223372036854775807i64
93 | #define UINT8_MAX 0xffui8
94 | #define UINT16_MAX 0xffffui16
95 | #define UINT32_MAX 0xffffffffui32
96 | #define UINT64_MAX 0xffffffffffffffffui64
97 | #else // this system has stdint.h
98 | #include
99 | #endif // (defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2010)) || defined(_KERNEL_MODE)
100 |
101 | // handle inttypes.h compatibility
102 | #if (defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2013)) || defined(_KERNEL_MODE)
103 | // this system does not have inttypes.h
104 |
105 | #define __PRI_8_LENGTH_MODIFIER__ "hh"
106 | #define __PRI_64_LENGTH_MODIFIER__ "ll"
107 |
108 | #define PRId8 __PRI_8_LENGTH_MODIFIER__ "d"
109 | #define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i"
110 | #define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o"
111 | #define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u"
112 | #define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x"
113 | #define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X"
114 |
115 | #define PRId16 "hd"
116 | #define PRIi16 "hi"
117 | #define PRIo16 "ho"
118 | #define PRIu16 "hu"
119 | #define PRIx16 "hx"
120 | #define PRIX16 "hX"
121 |
122 | #if defined(_MSC_VER) && (_MSC_VER <= MSC_VER_VS2012)
123 | #define PRId32 "ld"
124 | #define PRIi32 "li"
125 | #define PRIo32 "lo"
126 | #define PRIu32 "lu"
127 | #define PRIx32 "lx"
128 | #define PRIX32 "lX"
129 | #else // OSX
130 | #define PRId32 "d"
131 | #define PRIi32 "i"
132 | #define PRIo32 "o"
133 | #define PRIu32 "u"
134 | #define PRIx32 "x"
135 | #define PRIX32 "X"
136 | #endif // defined(_MSC_VER) && (_MSC_VER <= MSC_VER_VS2012)
137 |
138 | #if defined(_MSC_VER) && (_MSC_VER <= MSC_VER_VS2012)
139 | // redefine functions from inttypes.h used in cstool
140 | #define strtoull _strtoui64
141 | #endif
142 |
143 | #define PRId64 __PRI_64_LENGTH_MODIFIER__ "d"
144 | #define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i"
145 | #define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o"
146 | #define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u"
147 | #define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x"
148 | #define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X"
149 |
150 | #else
151 | // this system has inttypes.h by default
152 | #include
153 | #endif // #if defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2013) || defined(_KERNEL_MODE)
154 |
155 | // sys/time.h compatibility
156 | #if defined(_MSC_VER)
157 | #include
158 | #include
159 | #include
160 |
161 | static int gettimeofday(struct timeval* t, void* timezone)
162 | {
163 | struct _timeb timebuffer;
164 | _ftime( &timebuffer );
165 | t->tv_sec = (long)timebuffer.time;
166 | t->tv_usec = 1000*timebuffer.millitm;
167 | return 0;
168 | }
169 | #else
170 | #include
171 | #endif
172 |
173 | // unistd.h compatibility
174 | #if defined(_MSC_VER)
175 |
176 | static int usleep(uint32_t usec)
177 | {
178 | HANDLE timer;
179 | LARGE_INTEGER due;
180 |
181 | timer = CreateWaitableTimer(NULL, TRUE, NULL);
182 | if (!timer)
183 | return -1;
184 |
185 | due.QuadPart = (-((int64_t) usec)) * 10LL;
186 | if (!SetWaitableTimer(timer, &due, 0, NULL, NULL, 0)) {
187 | CloseHandle(timer);
188 | return -1;
189 | }
190 | WaitForSingleObject(timer, INFINITE);
191 | CloseHandle(timer);
192 |
193 | return 0;
194 | }
195 |
196 | #else
197 | #include
198 | #endif
199 |
200 | // misc support
201 | #if defined(_MSC_VER)
202 | #ifdef _WIN64
203 | typedef signed __int64 ssize_t;
204 | #else
205 | typedef _W64 signed int ssize_t;
206 | #endif
207 |
208 | #define va_copy(d,s) ((d) = (s))
209 | #define strcasecmp _stricmp
210 | #if (_MSC_VER < MSC_VER_VS2015)
211 | #define snprintf _snprintf
212 | #endif
213 | #if (_MSC_VER <= MSC_VER_VS2013)
214 | #define strtoll _strtoi64
215 | #endif
216 | #endif
217 |
218 |
219 | #endif // UNICORN_PLATFORM_H
220 |
--------------------------------------------------------------------------------
/unicorn/include/unicorn/sparc.h:
--------------------------------------------------------------------------------
1 | /* Unicorn Emulator Engine */
2 | /* By Nguyen Anh Quynh , 2014-2017 */
3 | /* This file is released under LGPL2.
4 | See COPYING.LGPL2 in root directory for more details
5 | */
6 |
7 | #ifndef UNICORN_SPARC_H
8 | #define UNICORN_SPARC_H
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | // GCC SPARC toolchain has a default macro called "sparc" which breaks
15 | // compilation
16 | #undef sparc
17 |
18 | #ifdef _MSC_VER
19 | #pragma warning(disable:4201)
20 | #endif
21 |
22 | //> SPARC registers
23 | typedef enum uc_sparc_reg {
24 | UC_SPARC_REG_INVALID = 0,
25 |
26 | UC_SPARC_REG_F0,
27 | UC_SPARC_REG_F1,
28 | UC_SPARC_REG_F2,
29 | UC_SPARC_REG_F3,
30 | UC_SPARC_REG_F4,
31 | UC_SPARC_REG_F5,
32 | UC_SPARC_REG_F6,
33 | UC_SPARC_REG_F7,
34 | UC_SPARC_REG_F8,
35 | UC_SPARC_REG_F9,
36 | UC_SPARC_REG_F10,
37 | UC_SPARC_REG_F11,
38 | UC_SPARC_REG_F12,
39 | UC_SPARC_REG_F13,
40 | UC_SPARC_REG_F14,
41 | UC_SPARC_REG_F15,
42 | UC_SPARC_REG_F16,
43 | UC_SPARC_REG_F17,
44 | UC_SPARC_REG_F18,
45 | UC_SPARC_REG_F19,
46 | UC_SPARC_REG_F20,
47 | UC_SPARC_REG_F21,
48 | UC_SPARC_REG_F22,
49 | UC_SPARC_REG_F23,
50 | UC_SPARC_REG_F24,
51 | UC_SPARC_REG_F25,
52 | UC_SPARC_REG_F26,
53 | UC_SPARC_REG_F27,
54 | UC_SPARC_REG_F28,
55 | UC_SPARC_REG_F29,
56 | UC_SPARC_REG_F30,
57 | UC_SPARC_REG_F31,
58 | UC_SPARC_REG_F32,
59 | UC_SPARC_REG_F34,
60 | UC_SPARC_REG_F36,
61 | UC_SPARC_REG_F38,
62 | UC_SPARC_REG_F40,
63 | UC_SPARC_REG_F42,
64 | UC_SPARC_REG_F44,
65 | UC_SPARC_REG_F46,
66 | UC_SPARC_REG_F48,
67 | UC_SPARC_REG_F50,
68 | UC_SPARC_REG_F52,
69 | UC_SPARC_REG_F54,
70 | UC_SPARC_REG_F56,
71 | UC_SPARC_REG_F58,
72 | UC_SPARC_REG_F60,
73 | UC_SPARC_REG_F62,
74 | UC_SPARC_REG_FCC0, // Floating condition codes
75 | UC_SPARC_REG_FCC1,
76 | UC_SPARC_REG_FCC2,
77 | UC_SPARC_REG_FCC3,
78 | UC_SPARC_REG_G0,
79 | UC_SPARC_REG_G1,
80 | UC_SPARC_REG_G2,
81 | UC_SPARC_REG_G3,
82 | UC_SPARC_REG_G4,
83 | UC_SPARC_REG_G5,
84 | UC_SPARC_REG_G6,
85 | UC_SPARC_REG_G7,
86 | UC_SPARC_REG_I0,
87 | UC_SPARC_REG_I1,
88 | UC_SPARC_REG_I2,
89 | UC_SPARC_REG_I3,
90 | UC_SPARC_REG_I4,
91 | UC_SPARC_REG_I5,
92 | UC_SPARC_REG_FP,
93 | UC_SPARC_REG_I7,
94 | UC_SPARC_REG_ICC, // Integer condition codes
95 | UC_SPARC_REG_L0,
96 | UC_SPARC_REG_L1,
97 | UC_SPARC_REG_L2,
98 | UC_SPARC_REG_L3,
99 | UC_SPARC_REG_L4,
100 | UC_SPARC_REG_L5,
101 | UC_SPARC_REG_L6,
102 | UC_SPARC_REG_L7,
103 | UC_SPARC_REG_O0,
104 | UC_SPARC_REG_O1,
105 | UC_SPARC_REG_O2,
106 | UC_SPARC_REG_O3,
107 | UC_SPARC_REG_O4,
108 | UC_SPARC_REG_O5,
109 | UC_SPARC_REG_SP,
110 | UC_SPARC_REG_O7,
111 | UC_SPARC_REG_Y,
112 |
113 | // special register
114 | UC_SPARC_REG_XCC,
115 |
116 | // pseudo register
117 | UC_SPARC_REG_PC, // program counter register
118 |
119 | UC_SPARC_REG_ENDING, // <-- mark the end of the list of registers
120 |
121 | // extras
122 | UC_SPARC_REG_O6 = UC_SPARC_REG_SP,
123 | UC_SPARC_REG_I6 = UC_SPARC_REG_FP,
124 | } uc_sparc_reg;
125 |
126 | #ifdef __cplusplus
127 | }
128 | #endif
129 |
130 | #endif
131 |
--------------------------------------------------------------------------------
/unicorn/include/unicorn/unicorn.h:
--------------------------------------------------------------------------------
1 | /* Unicorn Emulator Engine */
2 | /* By Nguyen Anh Quynh , 2015-2017 */
3 | /* This file is released under LGPL2.
4 | See COPYING.LGPL2 in root directory for more details
5 | */
6 |
7 | #ifndef UNICORN_ENGINE_H
8 | #define UNICORN_ENGINE_H
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | #include "platform.h"
15 | #include
16 |
17 | #if defined(UNICORN_HAS_OSXKERNEL)
18 | #include
19 | #else
20 | #include
21 | #include
22 | #endif
23 |
24 | struct uc_struct;
25 | typedef struct uc_struct uc_engine;
26 |
27 | typedef size_t uc_hook;
28 |
29 | #include "m68k.h"
30 | #include "x86.h"
31 | #include "arm.h"
32 | #include "arm64.h"
33 | #include "mips.h"
34 | #include "sparc.h"
35 |
36 | #ifdef __GNUC__
37 | #define DEFAULT_VISIBILITY __attribute__((visibility("default")))
38 | #else
39 | #define DEFAULT_VISIBILITY
40 | #endif
41 |
42 | #ifdef _MSC_VER
43 | #pragma warning(disable:4201)
44 | #pragma warning(disable:4100)
45 | #ifdef UNICORN_SHARED
46 | #define UNICORN_EXPORT __declspec(dllexport)
47 | #else // defined(UNICORN_STATIC)
48 | #define UNICORN_EXPORT
49 | #endif
50 | #else
51 | #ifdef __GNUC__
52 | #define UNICORN_EXPORT __attribute__((visibility("default")))
53 | #else
54 | #define UNICORN_EXPORT
55 | #endif
56 | #endif
57 |
58 | #ifdef __GNUC__
59 | #define UNICORN_DEPRECATED __attribute__((deprecated))
60 | #elif defined(_MSC_VER)
61 | #define UNICORN_DEPRECATED __declspec(deprecated)
62 | #else
63 | #pragma message("WARNING: You need to implement UNICORN_DEPRECATED for this compiler")
64 | #define UNICORN_DEPRECATED
65 | #endif
66 |
67 | // Unicorn API version
68 | #define UC_API_MAJOR 1
69 | #define UC_API_MINOR 0
70 |
71 | // Unicorn package version
72 | #define UC_VERSION_MAJOR UC_API_MAJOR
73 | #define UC_VERSION_MINOR UC_API_MINOR
74 | #define UC_VERSION_EXTRA 2
75 |
76 |
77 | /*
78 | Macro to create combined version which can be compared to
79 | result of uc_version() API.
80 | */
81 | #define UC_MAKE_VERSION(major, minor) ((major << 8) + minor)
82 |
83 | // Scales to calculate timeout on microsecond unit
84 | // 1 second = 1000,000 microseconds
85 | #define UC_SECOND_SCALE 1000000
86 | // 1 milisecond = 1000 nanoseconds
87 | #define UC_MILISECOND_SCALE 1000
88 |
89 | // Architecture type
90 | typedef enum uc_arch {
91 | UC_ARCH_ARM = 1, // ARM architecture (including Thumb, Thumb-2)
92 | UC_ARCH_ARM64, // ARM-64, also called AArch64
93 | UC_ARCH_MIPS, // Mips architecture
94 | UC_ARCH_X86, // X86 architecture (including x86 & x86-64)
95 | UC_ARCH_PPC, // PowerPC architecture (currently unsupported)
96 | UC_ARCH_SPARC, // Sparc architecture
97 | UC_ARCH_M68K, // M68K architecture
98 | UC_ARCH_MAX,
99 | } uc_arch;
100 |
101 | // Mode type
102 | typedef enum uc_mode {
103 | UC_MODE_LITTLE_ENDIAN = 0, // little-endian mode (default mode)
104 | UC_MODE_BIG_ENDIAN = 1 << 30, // big-endian mode
105 | // arm / arm64
106 | UC_MODE_ARM = 0, // ARM mode
107 | UC_MODE_THUMB = 1 << 4, // THUMB mode (including Thumb-2)
108 | UC_MODE_MCLASS = 1 << 5, // ARM's Cortex-M series (currently unsupported)
109 | UC_MODE_V8 = 1 << 6, // ARMv8 A32 encodings for ARM (currently unsupported)
110 | // mips
111 | UC_MODE_MICRO = 1 << 4, // MicroMips mode (currently unsupported)
112 | UC_MODE_MIPS3 = 1 << 5, // Mips III ISA (currently unsupported)
113 | UC_MODE_MIPS32R6 = 1 << 6, // Mips32r6 ISA (currently unsupported)
114 | UC_MODE_MIPS32 = 1 << 2, // Mips32 ISA
115 | UC_MODE_MIPS64 = 1 << 3, // Mips64 ISA
116 | // x86 / x64
117 | UC_MODE_16 = 1 << 1, // 16-bit mode
118 | UC_MODE_32 = 1 << 2, // 32-bit mode
119 | UC_MODE_64 = 1 << 3, // 64-bit mode
120 | // ppc
121 | UC_MODE_PPC32 = 1 << 2, // 32-bit mode (currently unsupported)
122 | UC_MODE_PPC64 = 1 << 3, // 64-bit mode (currently unsupported)
123 | UC_MODE_QPX = 1 << 4, // Quad Processing eXtensions mode (currently unsupported)
124 | // sparc
125 | UC_MODE_SPARC32 = 1 << 2, // 32-bit mode
126 | UC_MODE_SPARC64 = 1 << 3, // 64-bit mode
127 | UC_MODE_V9 = 1 << 4, // SparcV9 mode (currently unsupported)
128 | // m68k
129 | } uc_mode;
130 |
131 | // All type of errors encountered by Unicorn API.
132 | // These are values returned by uc_errno()
133 | typedef enum uc_err {
134 | UC_ERR_OK = 0, // No error: everything was fine
135 | UC_ERR_NOMEM, // Out-Of-Memory error: uc_open(), uc_emulate()
136 | UC_ERR_ARCH, // Unsupported architecture: uc_open()
137 | UC_ERR_HANDLE, // Invalid handle
138 | UC_ERR_MODE, // Invalid/unsupported mode: uc_open()
139 | UC_ERR_VERSION, // Unsupported version (bindings)
140 | UC_ERR_READ_UNMAPPED, // Quit emulation due to READ on unmapped memory: uc_emu_start()
141 | UC_ERR_WRITE_UNMAPPED, // Quit emulation due to WRITE on unmapped memory: uc_emu_start()
142 | UC_ERR_FETCH_UNMAPPED, // Quit emulation due to FETCH on unmapped memory: uc_emu_start()
143 | UC_ERR_HOOK, // Invalid hook type: uc_hook_add()
144 | UC_ERR_INSN_INVALID, // Quit emulation due to invalid instruction: uc_emu_start()
145 | UC_ERR_MAP, // Invalid memory mapping: uc_mem_map()
146 | UC_ERR_WRITE_PROT, // Quit emulation due to UC_MEM_WRITE_PROT violation: uc_emu_start()
147 | UC_ERR_READ_PROT, // Quit emulation due to UC_MEM_READ_PROT violation: uc_emu_start()
148 | UC_ERR_FETCH_PROT, // Quit emulation due to UC_MEM_FETCH_PROT violation: uc_emu_start()
149 | UC_ERR_ARG, // Inavalid argument provided to uc_xxx function (See specific function API)
150 | UC_ERR_READ_UNALIGNED, // Unaligned read
151 | UC_ERR_WRITE_UNALIGNED, // Unaligned write
152 | UC_ERR_FETCH_UNALIGNED, // Unaligned fetch
153 | UC_ERR_HOOK_EXIST, // hook for this event already existed
154 | UC_ERR_RESOURCE, // Insufficient resource: uc_emu_start()
155 | UC_ERR_EXCEPTION // Unhandled CPU exception
156 | } uc_err;
157 |
158 |
159 | /*
160 | Callback function for tracing code (UC_HOOK_CODE & UC_HOOK_BLOCK)
161 |
162 | @address: address where the code is being executed
163 | @size: size of machine instruction(s) being executed, or 0 when size is unknown
164 | @user_data: user data passed to tracing APIs.
165 | */
166 | typedef void (*uc_cb_hookcode_t)(uc_engine *uc, uint64_t address, uint32_t size, void *user_data);
167 |
168 | /*
169 | Callback function for tracing interrupts (for uc_hook_intr())
170 |
171 | @intno: interrupt number
172 | @user_data: user data passed to tracing APIs.
173 | */
174 | typedef void (*uc_cb_hookintr_t)(uc_engine *uc, uint32_t intno, void *user_data);
175 |
176 | /*
177 | Callback function for tracing IN instruction of X86
178 |
179 | @port: port number
180 | @size: data size (1/2/4) to be read from this port
181 | @user_data: user data passed to tracing APIs.
182 | */
183 | typedef uint32_t (*uc_cb_insn_in_t)(uc_engine *uc, uint32_t port, int size, void *user_data);
184 |
185 | /*
186 | Callback function for OUT instruction of X86
187 |
188 | @port: port number
189 | @size: data size (1/2/4) to be written to this port
190 | @value: data value to be written to this port
191 | */
192 | typedef void (*uc_cb_insn_out_t)(uc_engine *uc, uint32_t port, int size, uint32_t value, void *user_data);
193 |
194 | // All type of memory accesses for UC_HOOK_MEM_*
195 | typedef enum uc_mem_type {
196 | UC_MEM_READ = 16, // Memory is read from
197 | UC_MEM_WRITE, // Memory is written to
198 | UC_MEM_FETCH, // Memory is fetched
199 | UC_MEM_READ_UNMAPPED, // Unmapped memory is read from
200 | UC_MEM_WRITE_UNMAPPED, // Unmapped memory is written to
201 | UC_MEM_FETCH_UNMAPPED, // Unmapped memory is fetched
202 | UC_MEM_WRITE_PROT, // Write to write protected, but mapped, memory
203 | UC_MEM_READ_PROT, // Read from read protected, but mapped, memory
204 | UC_MEM_FETCH_PROT, // Fetch from non-executable, but mapped, memory
205 | UC_MEM_READ_AFTER, // Memory is read from (successful access)
206 | } uc_mem_type;
207 |
208 | // All type of hooks for uc_hook_add() API.
209 | typedef enum uc_hook_type {
210 | // Hook all interrupt/syscall events
211 | UC_HOOK_INTR = 1 << 0,
212 | // Hook a particular instruction - only a very small subset of instructions supported here
213 | UC_HOOK_INSN = 1 << 1,
214 | // Hook a range of code
215 | UC_HOOK_CODE = 1 << 2,
216 | // Hook basic blocks
217 | UC_HOOK_BLOCK = 1 << 3,
218 | // Hook for memory read on unmapped memory
219 | UC_HOOK_MEM_READ_UNMAPPED = 1 << 4,
220 | // Hook for invalid memory write events
221 | UC_HOOK_MEM_WRITE_UNMAPPED = 1 << 5,
222 | // Hook for invalid memory fetch for execution events
223 | UC_HOOK_MEM_FETCH_UNMAPPED = 1 << 6,
224 | // Hook for memory read on read-protected memory
225 | UC_HOOK_MEM_READ_PROT = 1 << 7,
226 | // Hook for memory write on write-protected memory
227 | UC_HOOK_MEM_WRITE_PROT = 1 << 8,
228 | // Hook for memory fetch on non-executable memory
229 | UC_HOOK_MEM_FETCH_PROT = 1 << 9,
230 | // Hook memory read events.
231 | UC_HOOK_MEM_READ = 1 << 10,
232 | // Hook memory write events.
233 | UC_HOOK_MEM_WRITE = 1 << 11,
234 | // Hook memory fetch for execution events
235 | UC_HOOK_MEM_FETCH = 1 << 12,
236 | // Hook memory read events, but only successful access.
237 | // The callback will be triggered after successful read.
238 | UC_HOOK_MEM_READ_AFTER = 1 << 13,
239 | } uc_hook_type;
240 |
241 | // Hook type for all events of unmapped memory access
242 | #define UC_HOOK_MEM_UNMAPPED (UC_HOOK_MEM_READ_UNMAPPED + UC_HOOK_MEM_WRITE_UNMAPPED + UC_HOOK_MEM_FETCH_UNMAPPED)
243 | // Hook type for all events of illegal protected memory access
244 | #define UC_HOOK_MEM_PROT (UC_HOOK_MEM_READ_PROT + UC_HOOK_MEM_WRITE_PROT + UC_HOOK_MEM_FETCH_PROT)
245 | // Hook type for all events of illegal read memory access
246 | #define UC_HOOK_MEM_READ_INVALID (UC_HOOK_MEM_READ_PROT + UC_HOOK_MEM_READ_UNMAPPED)
247 | // Hook type for all events of illegal write memory access
248 | #define UC_HOOK_MEM_WRITE_INVALID (UC_HOOK_MEM_WRITE_PROT + UC_HOOK_MEM_WRITE_UNMAPPED)
249 | // Hook type for all events of illegal fetch memory access
250 | #define UC_HOOK_MEM_FETCH_INVALID (UC_HOOK_MEM_FETCH_PROT + UC_HOOK_MEM_FETCH_UNMAPPED)
251 | // Hook type for all events of illegal memory access
252 | #define UC_HOOK_MEM_INVALID (UC_HOOK_MEM_UNMAPPED + UC_HOOK_MEM_PROT)
253 | // Hook type for all events of valid memory access
254 | // NOTE: UC_HOOK_MEM_READ is triggered before UC_HOOK_MEM_READ_PROT and UC_HOOK_MEM_READ_UNMAPPED, so
255 | // this hook may technically trigger on some invalid reads.
256 | #define UC_HOOK_MEM_VALID (UC_HOOK_MEM_READ + UC_HOOK_MEM_WRITE + UC_HOOK_MEM_FETCH)
257 |
258 | /*
259 | Callback function for hooking memory (READ, WRITE & FETCH)
260 |
261 | @type: this memory is being READ, or WRITE
262 | @address: address where the code is being executed
263 | @size: size of data being read or written
264 | @value: value of data being written to memory, or irrelevant if type = READ.
265 | @user_data: user data passed to tracing APIs
266 | */
267 | typedef void (*uc_cb_hookmem_t)(uc_engine *uc, uc_mem_type type,
268 | uint64_t address, int size, int64_t value, void *user_data);
269 |
270 | /*
271 | Callback function for handling invalid memory access events (UNMAPPED and
272 | PROT events)
273 |
274 | @type: this memory is being READ, or WRITE
275 | @address: address where the code is being executed
276 | @size: size of data being read or written
277 | @value: value of data being written to memory, or irrelevant if type = READ.
278 | @user_data: user data passed to tracing APIs
279 |
280 | @return: return true to continue, or false to stop program (due to invalid memory).
281 | NOTE: returning true to continue execution will only work if if the accessed
282 | memory is made accessible with the correct permissions during the hook.
283 |
284 | In the event of a UC_MEM_READ_UNMAPPED or UC_MEM_WRITE_UNMAPPED callback,
285 | the memory should be uc_mem_map()-ed with the correct permissions, and the
286 | instruction will then read or write to the address as it was supposed to.
287 |
288 | In the event of a UC_MEM_FETCH_UNMAPPED callback, the memory can be mapped
289 | in as executable, in which case execution will resume from the fetched address.
290 | The instruction pointer may be written to in order to change where execution resumes,
291 | but the fetch must succeed if execution is to resume.
292 | */
293 | typedef bool (*uc_cb_eventmem_t)(uc_engine *uc, uc_mem_type type,
294 | uint64_t address, int size, int64_t value, void *user_data);
295 |
296 | /*
297 | Memory region mapped by uc_mem_map() and uc_mem_map_ptr()
298 | Retrieve the list of memory regions with uc_mem_regions()
299 | */
300 | typedef struct uc_mem_region {
301 | uint64_t begin; // begin address of the region (inclusive)
302 | uint64_t end; // end address of the region (inclusive)
303 | uint32_t perms; // memory permissions of the region
304 | } uc_mem_region;
305 |
306 | // All type of queries for uc_query() API.
307 | typedef enum uc_query_type {
308 | // Dynamically query current hardware mode.
309 | UC_QUERY_MODE = 1,
310 | UC_QUERY_PAGE_SIZE,
311 | UC_QUERY_ARCH,
312 | } uc_query_type;
313 |
314 | // Opaque storage for CPU context, used with uc_context_*()
315 | struct uc_context;
316 | typedef struct uc_context uc_context;
317 |
318 | /*
319 | Return combined API version & major and minor version numbers.
320 |
321 | @major: major number of API version
322 | @minor: minor number of API version
323 |
324 | @return hexical number as (major << 8 | minor), which encodes both
325 | major & minor versions.
326 | NOTE: This returned value can be compared with version number made
327 | with macro UC_MAKE_VERSION
328 |
329 | For example, second API version would return 1 in @major, and 1 in @minor
330 | The return value would be 0x0101
331 |
332 | NOTE: if you only care about returned value, but not major and minor values,
333 | set both @major & @minor arguments to NULL.
334 | */
335 | UNICORN_EXPORT
336 | unsigned int uc_version(unsigned int *major, unsigned int *minor);
337 |
338 |
339 | /*
340 | Determine if the given architecture is supported by this library.
341 |
342 | @arch: architecture type (UC_ARCH_*)
343 |
344 | @return True if this library supports the given arch.
345 | */
346 | UNICORN_EXPORT
347 | bool uc_arch_supported(uc_arch arch);
348 |
349 |
350 | /*
351 | Create new instance of unicorn engine.
352 |
353 | @arch: architecture type (UC_ARCH_*)
354 | @mode: hardware mode. This is combined of UC_MODE_*
355 | @uc: pointer to uc_engine, which will be updated at return time
356 |
357 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
358 | for detailed error).
359 | */
360 | UNICORN_EXPORT
361 | uc_err uc_open(uc_arch arch, uc_mode mode, uc_engine **uc);
362 |
363 | /*
364 | Close a Unicorn engine instance.
365 | NOTE: this must be called only when there is no longer any
366 | usage of @uc. This API releases some of @uc's cached memory, thus
367 | any use of the Unicorn API with @uc after it has been closed may
368 | crash your application. After this, @uc is invalid, and is no
369 | longer usable.
370 |
371 | @uc: pointer to a handle returned by uc_open()
372 |
373 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
374 | for detailed error).
375 | */
376 | UNICORN_EXPORT
377 | uc_err uc_close(uc_engine *uc);
378 |
379 | /*
380 | Query internal status of engine.
381 |
382 | @uc: handle returned by uc_open()
383 | @type: query type. See uc_query_type
384 |
385 | @result: save the internal status queried
386 |
387 | @return: error code of uc_err enum type (UC_ERR_*, see above)
388 | */
389 | UNICORN_EXPORT
390 | uc_err uc_query(uc_engine *uc, uc_query_type type, size_t *result);
391 |
392 | /*
393 | Report the last error number when some API function fail.
394 | Like glibc's errno, uc_errno might not retain its old value once accessed.
395 |
396 | @uc: handle returned by uc_open()
397 |
398 | @return: error code of uc_err enum type (UC_ERR_*, see above)
399 | */
400 | UNICORN_EXPORT
401 | uc_err uc_errno(uc_engine *uc);
402 |
403 | /*
404 | Return a string describing given error code.
405 |
406 | @code: error code (see UC_ERR_* above)
407 |
408 | @return: returns a pointer to a string that describes the error code
409 | passed in the argument @code
410 | */
411 | UNICORN_EXPORT
412 | const char *uc_strerror(uc_err code);
413 |
414 | /*
415 | Write to register.
416 |
417 | @uc: handle returned by uc_open()
418 | @regid: register ID that is to be modified.
419 | @value: pointer to the value that will set to register @regid
420 |
421 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
422 | for detailed error).
423 | */
424 | UNICORN_EXPORT
425 | uc_err uc_reg_write(uc_engine *uc, int regid, const void *value);
426 |
427 | /*
428 | Read register value.
429 |
430 | @uc: handle returned by uc_open()
431 | @regid: register ID that is to be retrieved.
432 | @value: pointer to a variable storing the register value.
433 |
434 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
435 | for detailed error).
436 | */
437 | UNICORN_EXPORT
438 | uc_err uc_reg_read(uc_engine *uc, int regid, void *value);
439 |
440 | /*
441 | Write multiple register values.
442 |
443 | @uc: handle returned by uc_open()
444 | @rges: array of register IDs to store
445 | @value: pointer to array of register values
446 | @count: length of both *regs and *vals
447 |
448 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
449 | for detailed error).
450 | */
451 | UNICORN_EXPORT
452 | uc_err uc_reg_write_batch(uc_engine *uc, int *regs, void *const *vals, int count);
453 |
454 | /*
455 | Read multiple register values.
456 |
457 | @uc: handle returned by uc_open()
458 | @rges: array of register IDs to retrieve
459 | @value: pointer to array of values to hold registers
460 | @count: length of both *regs and *vals
461 |
462 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
463 | for detailed error).
464 | */
465 | UNICORN_EXPORT
466 | uc_err uc_reg_read_batch(uc_engine *uc, int *regs, void **vals, int count);
467 |
468 | /*
469 | Write to a range of bytes in memory.
470 |
471 | @uc: handle returned by uc_open()
472 | @address: starting memory address of bytes to set.
473 | @bytes: pointer to a variable containing data to be written to memory.
474 | @size: size of memory to write to.
475 |
476 | NOTE: @bytes must be big enough to contain @size bytes.
477 |
478 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
479 | for detailed error).
480 | */
481 | UNICORN_EXPORT
482 | uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *bytes, size_t size);
483 |
484 | /*
485 | Read a range of bytes in memory.
486 |
487 | @uc: handle returned by uc_open()
488 | @address: starting memory address of bytes to get.
489 | @bytes: pointer to a variable containing data copied from memory.
490 | @size: size of memory to read.
491 |
492 | NOTE: @bytes must be big enough to contain @size bytes.
493 |
494 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
495 | for detailed error).
496 | */
497 | UNICORN_EXPORT
498 | uc_err uc_mem_read(uc_engine *uc, uint64_t address, void *bytes, size_t size);
499 |
500 | /*
501 | Emulate machine code in a specific duration of time.
502 |
503 | @uc: handle returned by uc_open()
504 | @begin: address where emulation starts
505 | @until: address where emulation stops (i.e when this address is hit)
506 | @timeout: duration to emulate the code (in microseconds). When this value is 0,
507 | we will emulate the code in infinite time, until the code is finished.
508 | @count: the number of instructions to be emulated. When this value is 0,
509 | we will emulate all the code available, until the code is finished.
510 |
511 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
512 | for detailed error).
513 | */
514 | UNICORN_EXPORT
515 | uc_err uc_emu_start(uc_engine *uc, uint64_t begin, uint64_t until, uint64_t timeout, size_t count);
516 |
517 | /*
518 | Stop emulation (which was started by uc_emu_start() API.
519 | This is typically called from callback functions registered via tracing APIs.
520 |
521 | @uc: handle returned by uc_open()
522 |
523 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
524 | for detailed error).
525 | */
526 | UNICORN_EXPORT
527 | uc_err uc_emu_stop(uc_engine *uc);
528 |
529 | /*
530 | Register callback for a hook event.
531 | The callback will be run when the hook event is hit.
532 |
533 | @uc: handle returned by uc_open()
534 | @hh: hook handle returned from this registration. To be used in uc_hook_del() API
535 | @type: hook type
536 | @callback: callback to be run when instruction is hit
537 | @user_data: user-defined data. This will be passed to callback function in its
538 | last argument @user_data
539 | @begin: start address of the area where the callback is effect (inclusive)
540 | @end: end address of the area where the callback is effect (inclusive)
541 | NOTE 1: the callback is called only if related address is in range [@begin, @end]
542 | NOTE 2: if @begin > @end, callback is called whenever this hook type is triggered
543 | @...: variable arguments (depending on @type)
544 | NOTE: if @type = UC_HOOK_INSN, this is the instruction ID (ex: UC_X86_INS_OUT)
545 |
546 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
547 | for detailed error).
548 | */
549 | UNICORN_EXPORT
550 | uc_err uc_hook_add(uc_engine *uc, uc_hook *hh, int type, void *callback,
551 | void *user_data, uint64_t begin, uint64_t end, ...);
552 |
553 | /*
554 | Unregister (remove) a hook callback.
555 | This API removes the hook callback registered by uc_hook_add().
556 | NOTE: this should be called only when you no longer want to trace.
557 | After this, @hh is invalid, and nolonger usable.
558 |
559 | @uc: handle returned by uc_open()
560 | @hh: handle returned by uc_hook_add()
561 |
562 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
563 | for detailed error).
564 | */
565 | UNICORN_EXPORT
566 | uc_err uc_hook_del(uc_engine *uc, uc_hook hh);
567 |
568 | typedef enum uc_prot {
569 | UC_PROT_NONE = 0,
570 | UC_PROT_READ = 1,
571 | UC_PROT_WRITE = 2,
572 | UC_PROT_EXEC = 4,
573 | UC_PROT_ALL = 7,
574 | } uc_prot;
575 |
576 | /*
577 | Map memory in for emulation.
578 | This API adds a memory region that can be used by emulation.
579 |
580 | @uc: handle returned by uc_open()
581 | @address: starting address of the new memory region to be mapped in.
582 | This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
583 | @size: size of the new memory region to be mapped in.
584 | This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
585 | @perms: Permissions for the newly mapped region.
586 | This must be some combination of UC_PROT_READ | UC_PROT_WRITE | UC_PROT_EXEC,
587 | or this will return with UC_ERR_ARG error.
588 |
589 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
590 | for detailed error).
591 | */
592 | UNICORN_EXPORT
593 | uc_err uc_mem_map(uc_engine *uc, uint64_t address, size_t size, uint32_t perms);
594 |
595 | /*
596 | Map existing host memory in for emulation.
597 | This API adds a memory region that can be used by emulation.
598 |
599 | @uc: handle returned by uc_open()
600 | @address: starting address of the new memory region to be mapped in.
601 | This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
602 | @size: size of the new memory region to be mapped in.
603 | This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
604 | @perms: Permissions for the newly mapped region.
605 | This must be some combination of UC_PROT_READ | UC_PROT_WRITE | UC_PROT_EXEC,
606 | or this will return with UC_ERR_ARG error.
607 | @ptr: pointer to host memory backing the newly mapped memory. This host memory is
608 | expected to be an equal or larger size than provided, and be mapped with at
609 | least PROT_READ | PROT_WRITE. If it is not, the resulting behavior is undefined.
610 |
611 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
612 | for detailed error).
613 | */
614 | UNICORN_EXPORT
615 | uc_err uc_mem_map_ptr(uc_engine *uc, uint64_t address, size_t size, uint32_t perms, void *ptr);
616 |
617 | /*
618 | Unmap a region of emulation memory.
619 | This API deletes a memory mapping from the emulation memory space.
620 |
621 | @uc: handle returned by uc_open()
622 | @address: starting address of the memory region to be unmapped.
623 | This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
624 | @size: size of the memory region to be modified.
625 | This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
626 |
627 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
628 | for detailed error).
629 | */
630 | UNICORN_EXPORT
631 | uc_err uc_mem_unmap(uc_engine *uc, uint64_t address, size_t size);
632 |
633 | /*
634 | Set memory permissions for emulation memory.
635 | This API changes permissions on an existing memory region.
636 |
637 | @uc: handle returned by uc_open()
638 | @address: starting address of the memory region to be modified.
639 | This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
640 | @size: size of the memory region to be modified.
641 | This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
642 | @perms: New permissions for the mapped region.
643 | This must be some combination of UC_PROT_READ | UC_PROT_WRITE | UC_PROT_EXEC,
644 | or this will return with UC_ERR_ARG error.
645 |
646 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
647 | for detailed error).
648 | */
649 | UNICORN_EXPORT
650 | uc_err uc_mem_protect(uc_engine *uc, uint64_t address, size_t size, uint32_t perms);
651 |
652 | /*
653 | Retrieve all memory regions mapped by uc_mem_map() and uc_mem_map_ptr()
654 | This API allocates memory for @regions, and user must free this memory later
655 | by free() to avoid leaking memory.
656 | NOTE: memory regions may be splitted by uc_mem_unmap()
657 |
658 | @uc: handle returned by uc_open()
659 | @regions: pointer to an array of uc_mem_region struct. This is allocated by
660 | Unicorn, and must be freed by user later with uc_free()
661 | @count: pointer to number of struct uc_mem_region contained in @regions
662 |
663 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
664 | for detailed error).
665 | */
666 | UNICORN_EXPORT
667 | uc_err uc_mem_regions(uc_engine *uc, uc_mem_region **regions, uint32_t *count);
668 |
669 | /*
670 | Allocate a region that can be used with uc_context_{save,restore} to perform
671 | quick save/rollback of the CPU context, which includes registers and some
672 | internal metadata. Contexts may not be shared across engine instances with
673 | differing arches or modes.
674 |
675 | @uc: handle returned by uc_open()
676 | @context: pointer to a uc_engine*. This will be updated with the pointer to
677 | the new context on successful return of this function.
678 | Later, this allocated memory must be freed with uc_free().
679 |
680 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
681 | for detailed error).
682 | */
683 | UNICORN_EXPORT
684 | uc_err uc_context_alloc(uc_engine *uc, uc_context **context);
685 |
686 | /*
687 | Free the memory allocated by uc_context_alloc & uc_mem_regions.
688 |
689 | @mem: memory allocated by uc_context_alloc (returned in *context), or
690 | by uc_mem_regions (returned in *regions)
691 |
692 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
693 | for detailed error).
694 | */
695 | UNICORN_EXPORT
696 | uc_err uc_free(void *mem);
697 |
698 | /*
699 | Save a copy of the internal CPU context.
700 | This API should be used to efficiently make or update a saved copy of the
701 | internal CPU state.
702 |
703 | @uc: handle returned by uc_open()
704 | @context: handle returned by uc_context_alloc()
705 |
706 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
707 | for detailed error).
708 | */
709 | UNICORN_EXPORT
710 | uc_err uc_context_save(uc_engine *uc, uc_context *context);
711 |
712 | /*
713 | Restore the current CPU context from a saved copy.
714 | This API should be used to roll the CPU context back to a previous
715 | state saved by uc_context_save().
716 |
717 | @uc: handle returned by uc_open()
718 | @buffer: handle returned by uc_context_alloc that has been used with uc_context_save
719 |
720 | @return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
721 | for detailed error).
722 | */
723 | UNICORN_EXPORT
724 | uc_err uc_context_restore(uc_engine *uc, uc_context *context);
725 |
726 | #ifdef __cplusplus
727 | }
728 | #endif
729 |
730 | #endif
731 |
--------------------------------------------------------------------------------
/unicorn/include/unicorn/x86.h:
--------------------------------------------------------------------------------
1 | /* Unicorn Emulator Engine */
2 | /* By Nguyen Anh Quynh , 2015-2017 */
3 | /* This file is released under LGPL2.
4 | See COPYING.LGPL2 in root directory for more details
5 | */
6 |
7 | #ifndef UNICORN_X86_H
8 | #define UNICORN_X86_H
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | #include "platform.h"
15 |
16 | // Memory-Management Register for instructions IDTR, GDTR, LDTR, TR.
17 | // Borrow from SegmentCache in qemu/target-i386/cpu.h
18 | typedef struct uc_x86_mmr {
19 | uint16_t selector; /* not used by GDTR and IDTR */
20 | uint64_t base; /* handle 32 or 64 bit CPUs */
21 | uint32_t limit;
22 | uint32_t flags; /* not used by GDTR and IDTR */
23 | } uc_x86_mmr;
24 |
25 | // Model-Specific Register structure, use this with UC_X86_REG_MSR (as the register ID) in
26 | // call to uc_reg_write/uc_reg_read() to manipulate MSRs.
27 | typedef struct uc_x86_msr {
28 | uint32_t rid; // MSR id
29 | uint64_t value; // MSR value
30 | } uc_x86_msr;
31 |
32 | // Callback function for tracing SYSCALL/SYSENTER (for uc_hook_intr())
33 | // @user_data: user data passed to tracing APIs.
34 | typedef void (*uc_cb_insn_syscall_t)(struct uc_struct *uc, void *user_data);
35 |
36 | //> X86 registers
37 | typedef enum uc_x86_reg {
38 | UC_X86_REG_INVALID = 0,
39 | UC_X86_REG_AH, UC_X86_REG_AL, UC_X86_REG_AX, UC_X86_REG_BH, UC_X86_REG_BL,
40 | UC_X86_REG_BP, UC_X86_REG_BPL, UC_X86_REG_BX, UC_X86_REG_CH, UC_X86_REG_CL,
41 | UC_X86_REG_CS, UC_X86_REG_CX, UC_X86_REG_DH, UC_X86_REG_DI, UC_X86_REG_DIL,
42 | UC_X86_REG_DL, UC_X86_REG_DS, UC_X86_REG_DX, UC_X86_REG_EAX, UC_X86_REG_EBP,
43 | UC_X86_REG_EBX, UC_X86_REG_ECX, UC_X86_REG_EDI, UC_X86_REG_EDX, UC_X86_REG_EFLAGS,
44 | UC_X86_REG_EIP, UC_X86_REG_EIZ, UC_X86_REG_ES, UC_X86_REG_ESI, UC_X86_REG_ESP,
45 | UC_X86_REG_FPSW, UC_X86_REG_FS, UC_X86_REG_GS, UC_X86_REG_IP, UC_X86_REG_RAX,
46 | UC_X86_REG_RBP, UC_X86_REG_RBX, UC_X86_REG_RCX, UC_X86_REG_RDI, UC_X86_REG_RDX,
47 | UC_X86_REG_RIP, UC_X86_REG_RIZ, UC_X86_REG_RSI, UC_X86_REG_RSP, UC_X86_REG_SI,
48 | UC_X86_REG_SIL, UC_X86_REG_SP, UC_X86_REG_SPL, UC_X86_REG_SS, UC_X86_REG_CR0,
49 | UC_X86_REG_CR1, UC_X86_REG_CR2, UC_X86_REG_CR3, UC_X86_REG_CR4, UC_X86_REG_CR5,
50 | UC_X86_REG_CR6, UC_X86_REG_CR7, UC_X86_REG_CR8, UC_X86_REG_CR9, UC_X86_REG_CR10,
51 | UC_X86_REG_CR11, UC_X86_REG_CR12, UC_X86_REG_CR13, UC_X86_REG_CR14, UC_X86_REG_CR15,
52 | UC_X86_REG_DR0, UC_X86_REG_DR1, UC_X86_REG_DR2, UC_X86_REG_DR3, UC_X86_REG_DR4,
53 | UC_X86_REG_DR5, UC_X86_REG_DR6, UC_X86_REG_DR7, UC_X86_REG_DR8, UC_X86_REG_DR9,
54 | UC_X86_REG_DR10, UC_X86_REG_DR11, UC_X86_REG_DR12, UC_X86_REG_DR13, UC_X86_REG_DR14,
55 | UC_X86_REG_DR15, UC_X86_REG_FP0, UC_X86_REG_FP1, UC_X86_REG_FP2, UC_X86_REG_FP3,
56 | UC_X86_REG_FP4, UC_X86_REG_FP5, UC_X86_REG_FP6, UC_X86_REG_FP7,
57 | UC_X86_REG_K0, UC_X86_REG_K1, UC_X86_REG_K2, UC_X86_REG_K3, UC_X86_REG_K4,
58 | UC_X86_REG_K5, UC_X86_REG_K6, UC_X86_REG_K7, UC_X86_REG_MM0, UC_X86_REG_MM1,
59 | UC_X86_REG_MM2, UC_X86_REG_MM3, UC_X86_REG_MM4, UC_X86_REG_MM5, UC_X86_REG_MM6,
60 | UC_X86_REG_MM7, UC_X86_REG_R8, UC_X86_REG_R9, UC_X86_REG_R10, UC_X86_REG_R11,
61 | UC_X86_REG_R12, UC_X86_REG_R13, UC_X86_REG_R14, UC_X86_REG_R15,
62 | UC_X86_REG_ST0, UC_X86_REG_ST1, UC_X86_REG_ST2, UC_X86_REG_ST3,
63 | UC_X86_REG_ST4, UC_X86_REG_ST5, UC_X86_REG_ST6, UC_X86_REG_ST7,
64 | UC_X86_REG_XMM0, UC_X86_REG_XMM1, UC_X86_REG_XMM2, UC_X86_REG_XMM3, UC_X86_REG_XMM4,
65 | UC_X86_REG_XMM5, UC_X86_REG_XMM6, UC_X86_REG_XMM7, UC_X86_REG_XMM8, UC_X86_REG_XMM9,
66 | UC_X86_REG_XMM10, UC_X86_REG_XMM11, UC_X86_REG_XMM12, UC_X86_REG_XMM13, UC_X86_REG_XMM14,
67 | UC_X86_REG_XMM15, UC_X86_REG_XMM16, UC_X86_REG_XMM17, UC_X86_REG_XMM18, UC_X86_REG_XMM19,
68 | UC_X86_REG_XMM20, UC_X86_REG_XMM21, UC_X86_REG_XMM22, UC_X86_REG_XMM23, UC_X86_REG_XMM24,
69 | UC_X86_REG_XMM25, UC_X86_REG_XMM26, UC_X86_REG_XMM27, UC_X86_REG_XMM28, UC_X86_REG_XMM29,
70 | UC_X86_REG_XMM30, UC_X86_REG_XMM31, UC_X86_REG_YMM0, UC_X86_REG_YMM1, UC_X86_REG_YMM2,
71 | UC_X86_REG_YMM3, UC_X86_REG_YMM4, UC_X86_REG_YMM5, UC_X86_REG_YMM6, UC_X86_REG_YMM7,
72 | UC_X86_REG_YMM8, UC_X86_REG_YMM9, UC_X86_REG_YMM10, UC_X86_REG_YMM11, UC_X86_REG_YMM12,
73 | UC_X86_REG_YMM13, UC_X86_REG_YMM14, UC_X86_REG_YMM15, UC_X86_REG_YMM16, UC_X86_REG_YMM17,
74 | UC_X86_REG_YMM18, UC_X86_REG_YMM19, UC_X86_REG_YMM20, UC_X86_REG_YMM21, UC_X86_REG_YMM22,
75 | UC_X86_REG_YMM23, UC_X86_REG_YMM24, UC_X86_REG_YMM25, UC_X86_REG_YMM26, UC_X86_REG_YMM27,
76 | UC_X86_REG_YMM28, UC_X86_REG_YMM29, UC_X86_REG_YMM30, UC_X86_REG_YMM31, UC_X86_REG_ZMM0,
77 | UC_X86_REG_ZMM1, UC_X86_REG_ZMM2, UC_X86_REG_ZMM3, UC_X86_REG_ZMM4, UC_X86_REG_ZMM5,
78 | UC_X86_REG_ZMM6, UC_X86_REG_ZMM7, UC_X86_REG_ZMM8, UC_X86_REG_ZMM9, UC_X86_REG_ZMM10,
79 | UC_X86_REG_ZMM11, UC_X86_REG_ZMM12, UC_X86_REG_ZMM13, UC_X86_REG_ZMM14, UC_X86_REG_ZMM15,
80 | UC_X86_REG_ZMM16, UC_X86_REG_ZMM17, UC_X86_REG_ZMM18, UC_X86_REG_ZMM19, UC_X86_REG_ZMM20,
81 | UC_X86_REG_ZMM21, UC_X86_REG_ZMM22, UC_X86_REG_ZMM23, UC_X86_REG_ZMM24, UC_X86_REG_ZMM25,
82 | UC_X86_REG_ZMM26, UC_X86_REG_ZMM27, UC_X86_REG_ZMM28, UC_X86_REG_ZMM29, UC_X86_REG_ZMM30,
83 | UC_X86_REG_ZMM31, UC_X86_REG_R8B, UC_X86_REG_R9B, UC_X86_REG_R10B, UC_X86_REG_R11B,
84 | UC_X86_REG_R12B, UC_X86_REG_R13B, UC_X86_REG_R14B, UC_X86_REG_R15B, UC_X86_REG_R8D,
85 | UC_X86_REG_R9D, UC_X86_REG_R10D, UC_X86_REG_R11D, UC_X86_REG_R12D, UC_X86_REG_R13D,
86 | UC_X86_REG_R14D, UC_X86_REG_R15D, UC_X86_REG_R8W, UC_X86_REG_R9W, UC_X86_REG_R10W,
87 | UC_X86_REG_R11W, UC_X86_REG_R12W, UC_X86_REG_R13W, UC_X86_REG_R14W, UC_X86_REG_R15W,
88 | UC_X86_REG_IDTR, UC_X86_REG_GDTR, UC_X86_REG_LDTR, UC_X86_REG_TR, UC_X86_REG_FPCW,
89 | UC_X86_REG_FPTAG,
90 | UC_X86_REG_MSR, // Model-Specific Register
91 |
92 | UC_X86_REG_ENDING // <-- mark the end of the list of registers
93 | } uc_x86_reg;
94 |
95 | //> X86 instructions
96 | typedef enum uc_x86_insn {
97 | UC_X86_INS_INVALID = 0,
98 |
99 | UC_X86_INS_AAA,
100 | UC_X86_INS_AAD,
101 | UC_X86_INS_AAM,
102 | UC_X86_INS_AAS,
103 | UC_X86_INS_FABS,
104 | UC_X86_INS_ADC,
105 | UC_X86_INS_ADCX,
106 | UC_X86_INS_ADD,
107 | UC_X86_INS_ADDPD,
108 | UC_X86_INS_ADDPS,
109 | UC_X86_INS_ADDSD,
110 | UC_X86_INS_ADDSS,
111 | UC_X86_INS_ADDSUBPD,
112 | UC_X86_INS_ADDSUBPS,
113 | UC_X86_INS_FADD,
114 | UC_X86_INS_FIADD,
115 | UC_X86_INS_FADDP,
116 | UC_X86_INS_ADOX,
117 | UC_X86_INS_AESDECLAST,
118 | UC_X86_INS_AESDEC,
119 | UC_X86_INS_AESENCLAST,
120 | UC_X86_INS_AESENC,
121 | UC_X86_INS_AESIMC,
122 | UC_X86_INS_AESKEYGENASSIST,
123 | UC_X86_INS_AND,
124 | UC_X86_INS_ANDN,
125 | UC_X86_INS_ANDNPD,
126 | UC_X86_INS_ANDNPS,
127 | UC_X86_INS_ANDPD,
128 | UC_X86_INS_ANDPS,
129 | UC_X86_INS_ARPL,
130 | UC_X86_INS_BEXTR,
131 | UC_X86_INS_BLCFILL,
132 | UC_X86_INS_BLCI,
133 | UC_X86_INS_BLCIC,
134 | UC_X86_INS_BLCMSK,
135 | UC_X86_INS_BLCS,
136 | UC_X86_INS_BLENDPD,
137 | UC_X86_INS_BLENDPS,
138 | UC_X86_INS_BLENDVPD,
139 | UC_X86_INS_BLENDVPS,
140 | UC_X86_INS_BLSFILL,
141 | UC_X86_INS_BLSI,
142 | UC_X86_INS_BLSIC,
143 | UC_X86_INS_BLSMSK,
144 | UC_X86_INS_BLSR,
145 | UC_X86_INS_BOUND,
146 | UC_X86_INS_BSF,
147 | UC_X86_INS_BSR,
148 | UC_X86_INS_BSWAP,
149 | UC_X86_INS_BT,
150 | UC_X86_INS_BTC,
151 | UC_X86_INS_BTR,
152 | UC_X86_INS_BTS,
153 | UC_X86_INS_BZHI,
154 | UC_X86_INS_CALL,
155 | UC_X86_INS_CBW,
156 | UC_X86_INS_CDQ,
157 | UC_X86_INS_CDQE,
158 | UC_X86_INS_FCHS,
159 | UC_X86_INS_CLAC,
160 | UC_X86_INS_CLC,
161 | UC_X86_INS_CLD,
162 | UC_X86_INS_CLFLUSH,
163 | UC_X86_INS_CLFLUSHOPT,
164 | UC_X86_INS_CLGI,
165 | UC_X86_INS_CLI,
166 | UC_X86_INS_CLTS,
167 | UC_X86_INS_CLWB,
168 | UC_X86_INS_CMC,
169 | UC_X86_INS_CMOVA,
170 | UC_X86_INS_CMOVAE,
171 | UC_X86_INS_CMOVB,
172 | UC_X86_INS_CMOVBE,
173 | UC_X86_INS_FCMOVBE,
174 | UC_X86_INS_FCMOVB,
175 | UC_X86_INS_CMOVE,
176 | UC_X86_INS_FCMOVE,
177 | UC_X86_INS_CMOVG,
178 | UC_X86_INS_CMOVGE,
179 | UC_X86_INS_CMOVL,
180 | UC_X86_INS_CMOVLE,
181 | UC_X86_INS_FCMOVNBE,
182 | UC_X86_INS_FCMOVNB,
183 | UC_X86_INS_CMOVNE,
184 | UC_X86_INS_FCMOVNE,
185 | UC_X86_INS_CMOVNO,
186 | UC_X86_INS_CMOVNP,
187 | UC_X86_INS_FCMOVNU,
188 | UC_X86_INS_CMOVNS,
189 | UC_X86_INS_CMOVO,
190 | UC_X86_INS_CMOVP,
191 | UC_X86_INS_FCMOVU,
192 | UC_X86_INS_CMOVS,
193 | UC_X86_INS_CMP,
194 | UC_X86_INS_CMPPD,
195 | UC_X86_INS_CMPPS,
196 | UC_X86_INS_CMPSB,
197 | UC_X86_INS_CMPSD,
198 | UC_X86_INS_CMPSQ,
199 | UC_X86_INS_CMPSS,
200 | UC_X86_INS_CMPSW,
201 | UC_X86_INS_CMPXCHG16B,
202 | UC_X86_INS_CMPXCHG,
203 | UC_X86_INS_CMPXCHG8B,
204 | UC_X86_INS_COMISD,
205 | UC_X86_INS_COMISS,
206 | UC_X86_INS_FCOMP,
207 | UC_X86_INS_FCOMPI,
208 | UC_X86_INS_FCOMI,
209 | UC_X86_INS_FCOM,
210 | UC_X86_INS_FCOS,
211 | UC_X86_INS_CPUID,
212 | UC_X86_INS_CQO,
213 | UC_X86_INS_CRC32,
214 | UC_X86_INS_CVTDQ2PD,
215 | UC_X86_INS_CVTDQ2PS,
216 | UC_X86_INS_CVTPD2DQ,
217 | UC_X86_INS_CVTPD2PS,
218 | UC_X86_INS_CVTPS2DQ,
219 | UC_X86_INS_CVTPS2PD,
220 | UC_X86_INS_CVTSD2SI,
221 | UC_X86_INS_CVTSD2SS,
222 | UC_X86_INS_CVTSI2SD,
223 | UC_X86_INS_CVTSI2SS,
224 | UC_X86_INS_CVTSS2SD,
225 | UC_X86_INS_CVTSS2SI,
226 | UC_X86_INS_CVTTPD2DQ,
227 | UC_X86_INS_CVTTPS2DQ,
228 | UC_X86_INS_CVTTSD2SI,
229 | UC_X86_INS_CVTTSS2SI,
230 | UC_X86_INS_CWD,
231 | UC_X86_INS_CWDE,
232 | UC_X86_INS_DAA,
233 | UC_X86_INS_DAS,
234 | UC_X86_INS_DATA16,
235 | UC_X86_INS_DEC,
236 | UC_X86_INS_DIV,
237 | UC_X86_INS_DIVPD,
238 | UC_X86_INS_DIVPS,
239 | UC_X86_INS_FDIVR,
240 | UC_X86_INS_FIDIVR,
241 | UC_X86_INS_FDIVRP,
242 | UC_X86_INS_DIVSD,
243 | UC_X86_INS_DIVSS,
244 | UC_X86_INS_FDIV,
245 | UC_X86_INS_FIDIV,
246 | UC_X86_INS_FDIVP,
247 | UC_X86_INS_DPPD,
248 | UC_X86_INS_DPPS,
249 | UC_X86_INS_RET,
250 | UC_X86_INS_ENCLS,
251 | UC_X86_INS_ENCLU,
252 | UC_X86_INS_ENTER,
253 | UC_X86_INS_EXTRACTPS,
254 | UC_X86_INS_EXTRQ,
255 | UC_X86_INS_F2XM1,
256 | UC_X86_INS_LCALL,
257 | UC_X86_INS_LJMP,
258 | UC_X86_INS_FBLD,
259 | UC_X86_INS_FBSTP,
260 | UC_X86_INS_FCOMPP,
261 | UC_X86_INS_FDECSTP,
262 | UC_X86_INS_FEMMS,
263 | UC_X86_INS_FFREE,
264 | UC_X86_INS_FICOM,
265 | UC_X86_INS_FICOMP,
266 | UC_X86_INS_FINCSTP,
267 | UC_X86_INS_FLDCW,
268 | UC_X86_INS_FLDENV,
269 | UC_X86_INS_FLDL2E,
270 | UC_X86_INS_FLDL2T,
271 | UC_X86_INS_FLDLG2,
272 | UC_X86_INS_FLDLN2,
273 | UC_X86_INS_FLDPI,
274 | UC_X86_INS_FNCLEX,
275 | UC_X86_INS_FNINIT,
276 | UC_X86_INS_FNOP,
277 | UC_X86_INS_FNSTCW,
278 | UC_X86_INS_FNSTSW,
279 | UC_X86_INS_FPATAN,
280 | UC_X86_INS_FPREM,
281 | UC_X86_INS_FPREM1,
282 | UC_X86_INS_FPTAN,
283 | UC_X86_INS_FFREEP,
284 | UC_X86_INS_FRNDINT,
285 | UC_X86_INS_FRSTOR,
286 | UC_X86_INS_FNSAVE,
287 | UC_X86_INS_FSCALE,
288 | UC_X86_INS_FSETPM,
289 | UC_X86_INS_FSINCOS,
290 | UC_X86_INS_FNSTENV,
291 | UC_X86_INS_FXAM,
292 | UC_X86_INS_FXRSTOR,
293 | UC_X86_INS_FXRSTOR64,
294 | UC_X86_INS_FXSAVE,
295 | UC_X86_INS_FXSAVE64,
296 | UC_X86_INS_FXTRACT,
297 | UC_X86_INS_FYL2X,
298 | UC_X86_INS_FYL2XP1,
299 | UC_X86_INS_MOVAPD,
300 | UC_X86_INS_MOVAPS,
301 | UC_X86_INS_ORPD,
302 | UC_X86_INS_ORPS,
303 | UC_X86_INS_VMOVAPD,
304 | UC_X86_INS_VMOVAPS,
305 | UC_X86_INS_XORPD,
306 | UC_X86_INS_XORPS,
307 | UC_X86_INS_GETSEC,
308 | UC_X86_INS_HADDPD,
309 | UC_X86_INS_HADDPS,
310 | UC_X86_INS_HLT,
311 | UC_X86_INS_HSUBPD,
312 | UC_X86_INS_HSUBPS,
313 | UC_X86_INS_IDIV,
314 | UC_X86_INS_FILD,
315 | UC_X86_INS_IMUL,
316 | UC_X86_INS_IN,
317 | UC_X86_INS_INC,
318 | UC_X86_INS_INSB,
319 | UC_X86_INS_INSERTPS,
320 | UC_X86_INS_INSERTQ,
321 | UC_X86_INS_INSD,
322 | UC_X86_INS_INSW,
323 | UC_X86_INS_INT,
324 | UC_X86_INS_INT1,
325 | UC_X86_INS_INT3,
326 | UC_X86_INS_INTO,
327 | UC_X86_INS_INVD,
328 | UC_X86_INS_INVEPT,
329 | UC_X86_INS_INVLPG,
330 | UC_X86_INS_INVLPGA,
331 | UC_X86_INS_INVPCID,
332 | UC_X86_INS_INVVPID,
333 | UC_X86_INS_IRET,
334 | UC_X86_INS_IRETD,
335 | UC_X86_INS_IRETQ,
336 | UC_X86_INS_FISTTP,
337 | UC_X86_INS_FIST,
338 | UC_X86_INS_FISTP,
339 | UC_X86_INS_UCOMISD,
340 | UC_X86_INS_UCOMISS,
341 | UC_X86_INS_VCOMISD,
342 | UC_X86_INS_VCOMISS,
343 | UC_X86_INS_VCVTSD2SS,
344 | UC_X86_INS_VCVTSI2SD,
345 | UC_X86_INS_VCVTSI2SS,
346 | UC_X86_INS_VCVTSS2SD,
347 | UC_X86_INS_VCVTTSD2SI,
348 | UC_X86_INS_VCVTTSD2USI,
349 | UC_X86_INS_VCVTTSS2SI,
350 | UC_X86_INS_VCVTTSS2USI,
351 | UC_X86_INS_VCVTUSI2SD,
352 | UC_X86_INS_VCVTUSI2SS,
353 | UC_X86_INS_VUCOMISD,
354 | UC_X86_INS_VUCOMISS,
355 | UC_X86_INS_JAE,
356 | UC_X86_INS_JA,
357 | UC_X86_INS_JBE,
358 | UC_X86_INS_JB,
359 | UC_X86_INS_JCXZ,
360 | UC_X86_INS_JECXZ,
361 | UC_X86_INS_JE,
362 | UC_X86_INS_JGE,
363 | UC_X86_INS_JG,
364 | UC_X86_INS_JLE,
365 | UC_X86_INS_JL,
366 | UC_X86_INS_JMP,
367 | UC_X86_INS_JNE,
368 | UC_X86_INS_JNO,
369 | UC_X86_INS_JNP,
370 | UC_X86_INS_JNS,
371 | UC_X86_INS_JO,
372 | UC_X86_INS_JP,
373 | UC_X86_INS_JRCXZ,
374 | UC_X86_INS_JS,
375 | UC_X86_INS_KANDB,
376 | UC_X86_INS_KANDD,
377 | UC_X86_INS_KANDNB,
378 | UC_X86_INS_KANDND,
379 | UC_X86_INS_KANDNQ,
380 | UC_X86_INS_KANDNW,
381 | UC_X86_INS_KANDQ,
382 | UC_X86_INS_KANDW,
383 | UC_X86_INS_KMOVB,
384 | UC_X86_INS_KMOVD,
385 | UC_X86_INS_KMOVQ,
386 | UC_X86_INS_KMOVW,
387 | UC_X86_INS_KNOTB,
388 | UC_X86_INS_KNOTD,
389 | UC_X86_INS_KNOTQ,
390 | UC_X86_INS_KNOTW,
391 | UC_X86_INS_KORB,
392 | UC_X86_INS_KORD,
393 | UC_X86_INS_KORQ,
394 | UC_X86_INS_KORTESTB,
395 | UC_X86_INS_KORTESTD,
396 | UC_X86_INS_KORTESTQ,
397 | UC_X86_INS_KORTESTW,
398 | UC_X86_INS_KORW,
399 | UC_X86_INS_KSHIFTLB,
400 | UC_X86_INS_KSHIFTLD,
401 | UC_X86_INS_KSHIFTLQ,
402 | UC_X86_INS_KSHIFTLW,
403 | UC_X86_INS_KSHIFTRB,
404 | UC_X86_INS_KSHIFTRD,
405 | UC_X86_INS_KSHIFTRQ,
406 | UC_X86_INS_KSHIFTRW,
407 | UC_X86_INS_KUNPCKBW,
408 | UC_X86_INS_KXNORB,
409 | UC_X86_INS_KXNORD,
410 | UC_X86_INS_KXNORQ,
411 | UC_X86_INS_KXNORW,
412 | UC_X86_INS_KXORB,
413 | UC_X86_INS_KXORD,
414 | UC_X86_INS_KXORQ,
415 | UC_X86_INS_KXORW,
416 | UC_X86_INS_LAHF,
417 | UC_X86_INS_LAR,
418 | UC_X86_INS_LDDQU,
419 | UC_X86_INS_LDMXCSR,
420 | UC_X86_INS_LDS,
421 | UC_X86_INS_FLDZ,
422 | UC_X86_INS_FLD1,
423 | UC_X86_INS_FLD,
424 | UC_X86_INS_LEA,
425 | UC_X86_INS_LEAVE,
426 | UC_X86_INS_LES,
427 | UC_X86_INS_LFENCE,
428 | UC_X86_INS_LFS,
429 | UC_X86_INS_LGDT,
430 | UC_X86_INS_LGS,
431 | UC_X86_INS_LIDT,
432 | UC_X86_INS_LLDT,
433 | UC_X86_INS_LMSW,
434 | UC_X86_INS_OR,
435 | UC_X86_INS_SUB,
436 | UC_X86_INS_XOR,
437 | UC_X86_INS_LODSB,
438 | UC_X86_INS_LODSD,
439 | UC_X86_INS_LODSQ,
440 | UC_X86_INS_LODSW,
441 | UC_X86_INS_LOOP,
442 | UC_X86_INS_LOOPE,
443 | UC_X86_INS_LOOPNE,
444 | UC_X86_INS_RETF,
445 | UC_X86_INS_RETFQ,
446 | UC_X86_INS_LSL,
447 | UC_X86_INS_LSS,
448 | UC_X86_INS_LTR,
449 | UC_X86_INS_XADD,
450 | UC_X86_INS_LZCNT,
451 | UC_X86_INS_MASKMOVDQU,
452 | UC_X86_INS_MAXPD,
453 | UC_X86_INS_MAXPS,
454 | UC_X86_INS_MAXSD,
455 | UC_X86_INS_MAXSS,
456 | UC_X86_INS_MFENCE,
457 | UC_X86_INS_MINPD,
458 | UC_X86_INS_MINPS,
459 | UC_X86_INS_MINSD,
460 | UC_X86_INS_MINSS,
461 | UC_X86_INS_CVTPD2PI,
462 | UC_X86_INS_CVTPI2PD,
463 | UC_X86_INS_CVTPI2PS,
464 | UC_X86_INS_CVTPS2PI,
465 | UC_X86_INS_CVTTPD2PI,
466 | UC_X86_INS_CVTTPS2PI,
467 | UC_X86_INS_EMMS,
468 | UC_X86_INS_MASKMOVQ,
469 | UC_X86_INS_MOVD,
470 | UC_X86_INS_MOVDQ2Q,
471 | UC_X86_INS_MOVNTQ,
472 | UC_X86_INS_MOVQ2DQ,
473 | UC_X86_INS_MOVQ,
474 | UC_X86_INS_PABSB,
475 | UC_X86_INS_PABSD,
476 | UC_X86_INS_PABSW,
477 | UC_X86_INS_PACKSSDW,
478 | UC_X86_INS_PACKSSWB,
479 | UC_X86_INS_PACKUSWB,
480 | UC_X86_INS_PADDB,
481 | UC_X86_INS_PADDD,
482 | UC_X86_INS_PADDQ,
483 | UC_X86_INS_PADDSB,
484 | UC_X86_INS_PADDSW,
485 | UC_X86_INS_PADDUSB,
486 | UC_X86_INS_PADDUSW,
487 | UC_X86_INS_PADDW,
488 | UC_X86_INS_PALIGNR,
489 | UC_X86_INS_PANDN,
490 | UC_X86_INS_PAND,
491 | UC_X86_INS_PAVGB,
492 | UC_X86_INS_PAVGW,
493 | UC_X86_INS_PCMPEQB,
494 | UC_X86_INS_PCMPEQD,
495 | UC_X86_INS_PCMPEQW,
496 | UC_X86_INS_PCMPGTB,
497 | UC_X86_INS_PCMPGTD,
498 | UC_X86_INS_PCMPGTW,
499 | UC_X86_INS_PEXTRW,
500 | UC_X86_INS_PHADDSW,
501 | UC_X86_INS_PHADDW,
502 | UC_X86_INS_PHADDD,
503 | UC_X86_INS_PHSUBD,
504 | UC_X86_INS_PHSUBSW,
505 | UC_X86_INS_PHSUBW,
506 | UC_X86_INS_PINSRW,
507 | UC_X86_INS_PMADDUBSW,
508 | UC_X86_INS_PMADDWD,
509 | UC_X86_INS_PMAXSW,
510 | UC_X86_INS_PMAXUB,
511 | UC_X86_INS_PMINSW,
512 | UC_X86_INS_PMINUB,
513 | UC_X86_INS_PMOVMSKB,
514 | UC_X86_INS_PMULHRSW,
515 | UC_X86_INS_PMULHUW,
516 | UC_X86_INS_PMULHW,
517 | UC_X86_INS_PMULLW,
518 | UC_X86_INS_PMULUDQ,
519 | UC_X86_INS_POR,
520 | UC_X86_INS_PSADBW,
521 | UC_X86_INS_PSHUFB,
522 | UC_X86_INS_PSHUFW,
523 | UC_X86_INS_PSIGNB,
524 | UC_X86_INS_PSIGND,
525 | UC_X86_INS_PSIGNW,
526 | UC_X86_INS_PSLLD,
527 | UC_X86_INS_PSLLQ,
528 | UC_X86_INS_PSLLW,
529 | UC_X86_INS_PSRAD,
530 | UC_X86_INS_PSRAW,
531 | UC_X86_INS_PSRLD,
532 | UC_X86_INS_PSRLQ,
533 | UC_X86_INS_PSRLW,
534 | UC_X86_INS_PSUBB,
535 | UC_X86_INS_PSUBD,
536 | UC_X86_INS_PSUBQ,
537 | UC_X86_INS_PSUBSB,
538 | UC_X86_INS_PSUBSW,
539 | UC_X86_INS_PSUBUSB,
540 | UC_X86_INS_PSUBUSW,
541 | UC_X86_INS_PSUBW,
542 | UC_X86_INS_PUNPCKHBW,
543 | UC_X86_INS_PUNPCKHDQ,
544 | UC_X86_INS_PUNPCKHWD,
545 | UC_X86_INS_PUNPCKLBW,
546 | UC_X86_INS_PUNPCKLDQ,
547 | UC_X86_INS_PUNPCKLWD,
548 | UC_X86_INS_PXOR,
549 | UC_X86_INS_MONITOR,
550 | UC_X86_INS_MONTMUL,
551 | UC_X86_INS_MOV,
552 | UC_X86_INS_MOVABS,
553 | UC_X86_INS_MOVBE,
554 | UC_X86_INS_MOVDDUP,
555 | UC_X86_INS_MOVDQA,
556 | UC_X86_INS_MOVDQU,
557 | UC_X86_INS_MOVHLPS,
558 | UC_X86_INS_MOVHPD,
559 | UC_X86_INS_MOVHPS,
560 | UC_X86_INS_MOVLHPS,
561 | UC_X86_INS_MOVLPD,
562 | UC_X86_INS_MOVLPS,
563 | UC_X86_INS_MOVMSKPD,
564 | UC_X86_INS_MOVMSKPS,
565 | UC_X86_INS_MOVNTDQA,
566 | UC_X86_INS_MOVNTDQ,
567 | UC_X86_INS_MOVNTI,
568 | UC_X86_INS_MOVNTPD,
569 | UC_X86_INS_MOVNTPS,
570 | UC_X86_INS_MOVNTSD,
571 | UC_X86_INS_MOVNTSS,
572 | UC_X86_INS_MOVSB,
573 | UC_X86_INS_MOVSD,
574 | UC_X86_INS_MOVSHDUP,
575 | UC_X86_INS_MOVSLDUP,
576 | UC_X86_INS_MOVSQ,
577 | UC_X86_INS_MOVSS,
578 | UC_X86_INS_MOVSW,
579 | UC_X86_INS_MOVSX,
580 | UC_X86_INS_MOVSXD,
581 | UC_X86_INS_MOVUPD,
582 | UC_X86_INS_MOVUPS,
583 | UC_X86_INS_MOVZX,
584 | UC_X86_INS_MPSADBW,
585 | UC_X86_INS_MUL,
586 | UC_X86_INS_MULPD,
587 | UC_X86_INS_MULPS,
588 | UC_X86_INS_MULSD,
589 | UC_X86_INS_MULSS,
590 | UC_X86_INS_MULX,
591 | UC_X86_INS_FMUL,
592 | UC_X86_INS_FIMUL,
593 | UC_X86_INS_FMULP,
594 | UC_X86_INS_MWAIT,
595 | UC_X86_INS_NEG,
596 | UC_X86_INS_NOP,
597 | UC_X86_INS_NOT,
598 | UC_X86_INS_OUT,
599 | UC_X86_INS_OUTSB,
600 | UC_X86_INS_OUTSD,
601 | UC_X86_INS_OUTSW,
602 | UC_X86_INS_PACKUSDW,
603 | UC_X86_INS_PAUSE,
604 | UC_X86_INS_PAVGUSB,
605 | UC_X86_INS_PBLENDVB,
606 | UC_X86_INS_PBLENDW,
607 | UC_X86_INS_PCLMULQDQ,
608 | UC_X86_INS_PCMPEQQ,
609 | UC_X86_INS_PCMPESTRI,
610 | UC_X86_INS_PCMPESTRM,
611 | UC_X86_INS_PCMPGTQ,
612 | UC_X86_INS_PCMPISTRI,
613 | UC_X86_INS_PCMPISTRM,
614 | UC_X86_INS_PCOMMIT,
615 | UC_X86_INS_PDEP,
616 | UC_X86_INS_PEXT,
617 | UC_X86_INS_PEXTRB,
618 | UC_X86_INS_PEXTRD,
619 | UC_X86_INS_PEXTRQ,
620 | UC_X86_INS_PF2ID,
621 | UC_X86_INS_PF2IW,
622 | UC_X86_INS_PFACC,
623 | UC_X86_INS_PFADD,
624 | UC_X86_INS_PFCMPEQ,
625 | UC_X86_INS_PFCMPGE,
626 | UC_X86_INS_PFCMPGT,
627 | UC_X86_INS_PFMAX,
628 | UC_X86_INS_PFMIN,
629 | UC_X86_INS_PFMUL,
630 | UC_X86_INS_PFNACC,
631 | UC_X86_INS_PFPNACC,
632 | UC_X86_INS_PFRCPIT1,
633 | UC_X86_INS_PFRCPIT2,
634 | UC_X86_INS_PFRCP,
635 | UC_X86_INS_PFRSQIT1,
636 | UC_X86_INS_PFRSQRT,
637 | UC_X86_INS_PFSUBR,
638 | UC_X86_INS_PFSUB,
639 | UC_X86_INS_PHMINPOSUW,
640 | UC_X86_INS_PI2FD,
641 | UC_X86_INS_PI2FW,
642 | UC_X86_INS_PINSRB,
643 | UC_X86_INS_PINSRD,
644 | UC_X86_INS_PINSRQ,
645 | UC_X86_INS_PMAXSB,
646 | UC_X86_INS_PMAXSD,
647 | UC_X86_INS_PMAXUD,
648 | UC_X86_INS_PMAXUW,
649 | UC_X86_INS_PMINSB,
650 | UC_X86_INS_PMINSD,
651 | UC_X86_INS_PMINUD,
652 | UC_X86_INS_PMINUW,
653 | UC_X86_INS_PMOVSXBD,
654 | UC_X86_INS_PMOVSXBQ,
655 | UC_X86_INS_PMOVSXBW,
656 | UC_X86_INS_PMOVSXDQ,
657 | UC_X86_INS_PMOVSXWD,
658 | UC_X86_INS_PMOVSXWQ,
659 | UC_X86_INS_PMOVZXBD,
660 | UC_X86_INS_PMOVZXBQ,
661 | UC_X86_INS_PMOVZXBW,
662 | UC_X86_INS_PMOVZXDQ,
663 | UC_X86_INS_PMOVZXWD,
664 | UC_X86_INS_PMOVZXWQ,
665 | UC_X86_INS_PMULDQ,
666 | UC_X86_INS_PMULHRW,
667 | UC_X86_INS_PMULLD,
668 | UC_X86_INS_POP,
669 | UC_X86_INS_POPAW,
670 | UC_X86_INS_POPAL,
671 | UC_X86_INS_POPCNT,
672 | UC_X86_INS_POPF,
673 | UC_X86_INS_POPFD,
674 | UC_X86_INS_POPFQ,
675 | UC_X86_INS_PREFETCH,
676 | UC_X86_INS_PREFETCHNTA,
677 | UC_X86_INS_PREFETCHT0,
678 | UC_X86_INS_PREFETCHT1,
679 | UC_X86_INS_PREFETCHT2,
680 | UC_X86_INS_PREFETCHW,
681 | UC_X86_INS_PSHUFD,
682 | UC_X86_INS_PSHUFHW,
683 | UC_X86_INS_PSHUFLW,
684 | UC_X86_INS_PSLLDQ,
685 | UC_X86_INS_PSRLDQ,
686 | UC_X86_INS_PSWAPD,
687 | UC_X86_INS_PTEST,
688 | UC_X86_INS_PUNPCKHQDQ,
689 | UC_X86_INS_PUNPCKLQDQ,
690 | UC_X86_INS_PUSH,
691 | UC_X86_INS_PUSHAW,
692 | UC_X86_INS_PUSHAL,
693 | UC_X86_INS_PUSHF,
694 | UC_X86_INS_PUSHFD,
695 | UC_X86_INS_PUSHFQ,
696 | UC_X86_INS_RCL,
697 | UC_X86_INS_RCPPS,
698 | UC_X86_INS_RCPSS,
699 | UC_X86_INS_RCR,
700 | UC_X86_INS_RDFSBASE,
701 | UC_X86_INS_RDGSBASE,
702 | UC_X86_INS_RDMSR,
703 | UC_X86_INS_RDPMC,
704 | UC_X86_INS_RDRAND,
705 | UC_X86_INS_RDSEED,
706 | UC_X86_INS_RDTSC,
707 | UC_X86_INS_RDTSCP,
708 | UC_X86_INS_ROL,
709 | UC_X86_INS_ROR,
710 | UC_X86_INS_RORX,
711 | UC_X86_INS_ROUNDPD,
712 | UC_X86_INS_ROUNDPS,
713 | UC_X86_INS_ROUNDSD,
714 | UC_X86_INS_ROUNDSS,
715 | UC_X86_INS_RSM,
716 | UC_X86_INS_RSQRTPS,
717 | UC_X86_INS_RSQRTSS,
718 | UC_X86_INS_SAHF,
719 | UC_X86_INS_SAL,
720 | UC_X86_INS_SALC,
721 | UC_X86_INS_SAR,
722 | UC_X86_INS_SARX,
723 | UC_X86_INS_SBB,
724 | UC_X86_INS_SCASB,
725 | UC_X86_INS_SCASD,
726 | UC_X86_INS_SCASQ,
727 | UC_X86_INS_SCASW,
728 | UC_X86_INS_SETAE,
729 | UC_X86_INS_SETA,
730 | UC_X86_INS_SETBE,
731 | UC_X86_INS_SETB,
732 | UC_X86_INS_SETE,
733 | UC_X86_INS_SETGE,
734 | UC_X86_INS_SETG,
735 | UC_X86_INS_SETLE,
736 | UC_X86_INS_SETL,
737 | UC_X86_INS_SETNE,
738 | UC_X86_INS_SETNO,
739 | UC_X86_INS_SETNP,
740 | UC_X86_INS_SETNS,
741 | UC_X86_INS_SETO,
742 | UC_X86_INS_SETP,
743 | UC_X86_INS_SETS,
744 | UC_X86_INS_SFENCE,
745 | UC_X86_INS_SGDT,
746 | UC_X86_INS_SHA1MSG1,
747 | UC_X86_INS_SHA1MSG2,
748 | UC_X86_INS_SHA1NEXTE,
749 | UC_X86_INS_SHA1RNDS4,
750 | UC_X86_INS_SHA256MSG1,
751 | UC_X86_INS_SHA256MSG2,
752 | UC_X86_INS_SHA256RNDS2,
753 | UC_X86_INS_SHL,
754 | UC_X86_INS_SHLD,
755 | UC_X86_INS_SHLX,
756 | UC_X86_INS_SHR,
757 | UC_X86_INS_SHRD,
758 | UC_X86_INS_SHRX,
759 | UC_X86_INS_SHUFPD,
760 | UC_X86_INS_SHUFPS,
761 | UC_X86_INS_SIDT,
762 | UC_X86_INS_FSIN,
763 | UC_X86_INS_SKINIT,
764 | UC_X86_INS_SLDT,
765 | UC_X86_INS_SMSW,
766 | UC_X86_INS_SQRTPD,
767 | UC_X86_INS_SQRTPS,
768 | UC_X86_INS_SQRTSD,
769 | UC_X86_INS_SQRTSS,
770 | UC_X86_INS_FSQRT,
771 | UC_X86_INS_STAC,
772 | UC_X86_INS_STC,
773 | UC_X86_INS_STD,
774 | UC_X86_INS_STGI,
775 | UC_X86_INS_STI,
776 | UC_X86_INS_STMXCSR,
777 | UC_X86_INS_STOSB,
778 | UC_X86_INS_STOSD,
779 | UC_X86_INS_STOSQ,
780 | UC_X86_INS_STOSW,
781 | UC_X86_INS_STR,
782 | UC_X86_INS_FST,
783 | UC_X86_INS_FSTP,
784 | UC_X86_INS_FSTPNCE,
785 | UC_X86_INS_FXCH,
786 | UC_X86_INS_SUBPD,
787 | UC_X86_INS_SUBPS,
788 | UC_X86_INS_FSUBR,
789 | UC_X86_INS_FISUBR,
790 | UC_X86_INS_FSUBRP,
791 | UC_X86_INS_SUBSD,
792 | UC_X86_INS_SUBSS,
793 | UC_X86_INS_FSUB,
794 | UC_X86_INS_FISUB,
795 | UC_X86_INS_FSUBP,
796 | UC_X86_INS_SWAPGS,
797 | UC_X86_INS_SYSCALL,
798 | UC_X86_INS_SYSENTER,
799 | UC_X86_INS_SYSEXIT,
800 | UC_X86_INS_SYSRET,
801 | UC_X86_INS_T1MSKC,
802 | UC_X86_INS_TEST,
803 | UC_X86_INS_UD2,
804 | UC_X86_INS_FTST,
805 | UC_X86_INS_TZCNT,
806 | UC_X86_INS_TZMSK,
807 | UC_X86_INS_FUCOMPI,
808 | UC_X86_INS_FUCOMI,
809 | UC_X86_INS_FUCOMPP,
810 | UC_X86_INS_FUCOMP,
811 | UC_X86_INS_FUCOM,
812 | UC_X86_INS_UD2B,
813 | UC_X86_INS_UNPCKHPD,
814 | UC_X86_INS_UNPCKHPS,
815 | UC_X86_INS_UNPCKLPD,
816 | UC_X86_INS_UNPCKLPS,
817 | UC_X86_INS_VADDPD,
818 | UC_X86_INS_VADDPS,
819 | UC_X86_INS_VADDSD,
820 | UC_X86_INS_VADDSS,
821 | UC_X86_INS_VADDSUBPD,
822 | UC_X86_INS_VADDSUBPS,
823 | UC_X86_INS_VAESDECLAST,
824 | UC_X86_INS_VAESDEC,
825 | UC_X86_INS_VAESENCLAST,
826 | UC_X86_INS_VAESENC,
827 | UC_X86_INS_VAESIMC,
828 | UC_X86_INS_VAESKEYGENASSIST,
829 | UC_X86_INS_VALIGND,
830 | UC_X86_INS_VALIGNQ,
831 | UC_X86_INS_VANDNPD,
832 | UC_X86_INS_VANDNPS,
833 | UC_X86_INS_VANDPD,
834 | UC_X86_INS_VANDPS,
835 | UC_X86_INS_VBLENDMPD,
836 | UC_X86_INS_VBLENDMPS,
837 | UC_X86_INS_VBLENDPD,
838 | UC_X86_INS_VBLENDPS,
839 | UC_X86_INS_VBLENDVPD,
840 | UC_X86_INS_VBLENDVPS,
841 | UC_X86_INS_VBROADCASTF128,
842 | UC_X86_INS_VBROADCASTI32X4,
843 | UC_X86_INS_VBROADCASTI64X4,
844 | UC_X86_INS_VBROADCASTSD,
845 | UC_X86_INS_VBROADCASTSS,
846 | UC_X86_INS_VCMPPD,
847 | UC_X86_INS_VCMPPS,
848 | UC_X86_INS_VCMPSD,
849 | UC_X86_INS_VCMPSS,
850 | UC_X86_INS_VCOMPRESSPD,
851 | UC_X86_INS_VCOMPRESSPS,
852 | UC_X86_INS_VCVTDQ2PD,
853 | UC_X86_INS_VCVTDQ2PS,
854 | UC_X86_INS_VCVTPD2DQX,
855 | UC_X86_INS_VCVTPD2DQ,
856 | UC_X86_INS_VCVTPD2PSX,
857 | UC_X86_INS_VCVTPD2PS,
858 | UC_X86_INS_VCVTPD2UDQ,
859 | UC_X86_INS_VCVTPH2PS,
860 | UC_X86_INS_VCVTPS2DQ,
861 | UC_X86_INS_VCVTPS2PD,
862 | UC_X86_INS_VCVTPS2PH,
863 | UC_X86_INS_VCVTPS2UDQ,
864 | UC_X86_INS_VCVTSD2SI,
865 | UC_X86_INS_VCVTSD2USI,
866 | UC_X86_INS_VCVTSS2SI,
867 | UC_X86_INS_VCVTSS2USI,
868 | UC_X86_INS_VCVTTPD2DQX,
869 | UC_X86_INS_VCVTTPD2DQ,
870 | UC_X86_INS_VCVTTPD2UDQ,
871 | UC_X86_INS_VCVTTPS2DQ,
872 | UC_X86_INS_VCVTTPS2UDQ,
873 | UC_X86_INS_VCVTUDQ2PD,
874 | UC_X86_INS_VCVTUDQ2PS,
875 | UC_X86_INS_VDIVPD,
876 | UC_X86_INS_VDIVPS,
877 | UC_X86_INS_VDIVSD,
878 | UC_X86_INS_VDIVSS,
879 | UC_X86_INS_VDPPD,
880 | UC_X86_INS_VDPPS,
881 | UC_X86_INS_VERR,
882 | UC_X86_INS_VERW,
883 | UC_X86_INS_VEXP2PD,
884 | UC_X86_INS_VEXP2PS,
885 | UC_X86_INS_VEXPANDPD,
886 | UC_X86_INS_VEXPANDPS,
887 | UC_X86_INS_VEXTRACTF128,
888 | UC_X86_INS_VEXTRACTF32X4,
889 | UC_X86_INS_VEXTRACTF64X4,
890 | UC_X86_INS_VEXTRACTI128,
891 | UC_X86_INS_VEXTRACTI32X4,
892 | UC_X86_INS_VEXTRACTI64X4,
893 | UC_X86_INS_VEXTRACTPS,
894 | UC_X86_INS_VFMADD132PD,
895 | UC_X86_INS_VFMADD132PS,
896 | UC_X86_INS_VFMADDPD,
897 | UC_X86_INS_VFMADD213PD,
898 | UC_X86_INS_VFMADD231PD,
899 | UC_X86_INS_VFMADDPS,
900 | UC_X86_INS_VFMADD213PS,
901 | UC_X86_INS_VFMADD231PS,
902 | UC_X86_INS_VFMADDSD,
903 | UC_X86_INS_VFMADD213SD,
904 | UC_X86_INS_VFMADD132SD,
905 | UC_X86_INS_VFMADD231SD,
906 | UC_X86_INS_VFMADDSS,
907 | UC_X86_INS_VFMADD213SS,
908 | UC_X86_INS_VFMADD132SS,
909 | UC_X86_INS_VFMADD231SS,
910 | UC_X86_INS_VFMADDSUB132PD,
911 | UC_X86_INS_VFMADDSUB132PS,
912 | UC_X86_INS_VFMADDSUBPD,
913 | UC_X86_INS_VFMADDSUB213PD,
914 | UC_X86_INS_VFMADDSUB231PD,
915 | UC_X86_INS_VFMADDSUBPS,
916 | UC_X86_INS_VFMADDSUB213PS,
917 | UC_X86_INS_VFMADDSUB231PS,
918 | UC_X86_INS_VFMSUB132PD,
919 | UC_X86_INS_VFMSUB132PS,
920 | UC_X86_INS_VFMSUBADD132PD,
921 | UC_X86_INS_VFMSUBADD132PS,
922 | UC_X86_INS_VFMSUBADDPD,
923 | UC_X86_INS_VFMSUBADD213PD,
924 | UC_X86_INS_VFMSUBADD231PD,
925 | UC_X86_INS_VFMSUBADDPS,
926 | UC_X86_INS_VFMSUBADD213PS,
927 | UC_X86_INS_VFMSUBADD231PS,
928 | UC_X86_INS_VFMSUBPD,
929 | UC_X86_INS_VFMSUB213PD,
930 | UC_X86_INS_VFMSUB231PD,
931 | UC_X86_INS_VFMSUBPS,
932 | UC_X86_INS_VFMSUB213PS,
933 | UC_X86_INS_VFMSUB231PS,
934 | UC_X86_INS_VFMSUBSD,
935 | UC_X86_INS_VFMSUB213SD,
936 | UC_X86_INS_VFMSUB132SD,
937 | UC_X86_INS_VFMSUB231SD,
938 | UC_X86_INS_VFMSUBSS,
939 | UC_X86_INS_VFMSUB213SS,
940 | UC_X86_INS_VFMSUB132SS,
941 | UC_X86_INS_VFMSUB231SS,
942 | UC_X86_INS_VFNMADD132PD,
943 | UC_X86_INS_VFNMADD132PS,
944 | UC_X86_INS_VFNMADDPD,
945 | UC_X86_INS_VFNMADD213PD,
946 | UC_X86_INS_VFNMADD231PD,
947 | UC_X86_INS_VFNMADDPS,
948 | UC_X86_INS_VFNMADD213PS,
949 | UC_X86_INS_VFNMADD231PS,
950 | UC_X86_INS_VFNMADDSD,
951 | UC_X86_INS_VFNMADD213SD,
952 | UC_X86_INS_VFNMADD132SD,
953 | UC_X86_INS_VFNMADD231SD,
954 | UC_X86_INS_VFNMADDSS,
955 | UC_X86_INS_VFNMADD213SS,
956 | UC_X86_INS_VFNMADD132SS,
957 | UC_X86_INS_VFNMADD231SS,
958 | UC_X86_INS_VFNMSUB132PD,
959 | UC_X86_INS_VFNMSUB132PS,
960 | UC_X86_INS_VFNMSUBPD,
961 | UC_X86_INS_VFNMSUB213PD,
962 | UC_X86_INS_VFNMSUB231PD,
963 | UC_X86_INS_VFNMSUBPS,
964 | UC_X86_INS_VFNMSUB213PS,
965 | UC_X86_INS_VFNMSUB231PS,
966 | UC_X86_INS_VFNMSUBSD,
967 | UC_X86_INS_VFNMSUB213SD,
968 | UC_X86_INS_VFNMSUB132SD,
969 | UC_X86_INS_VFNMSUB231SD,
970 | UC_X86_INS_VFNMSUBSS,
971 | UC_X86_INS_VFNMSUB213SS,
972 | UC_X86_INS_VFNMSUB132SS,
973 | UC_X86_INS_VFNMSUB231SS,
974 | UC_X86_INS_VFRCZPD,
975 | UC_X86_INS_VFRCZPS,
976 | UC_X86_INS_VFRCZSD,
977 | UC_X86_INS_VFRCZSS,
978 | UC_X86_INS_VORPD,
979 | UC_X86_INS_VORPS,
980 | UC_X86_INS_VXORPD,
981 | UC_X86_INS_VXORPS,
982 | UC_X86_INS_VGATHERDPD,
983 | UC_X86_INS_VGATHERDPS,
984 | UC_X86_INS_VGATHERPF0DPD,
985 | UC_X86_INS_VGATHERPF0DPS,
986 | UC_X86_INS_VGATHERPF0QPD,
987 | UC_X86_INS_VGATHERPF0QPS,
988 | UC_X86_INS_VGATHERPF1DPD,
989 | UC_X86_INS_VGATHERPF1DPS,
990 | UC_X86_INS_VGATHERPF1QPD,
991 | UC_X86_INS_VGATHERPF1QPS,
992 | UC_X86_INS_VGATHERQPD,
993 | UC_X86_INS_VGATHERQPS,
994 | UC_X86_INS_VHADDPD,
995 | UC_X86_INS_VHADDPS,
996 | UC_X86_INS_VHSUBPD,
997 | UC_X86_INS_VHSUBPS,
998 | UC_X86_INS_VINSERTF128,
999 | UC_X86_INS_VINSERTF32X4,
1000 | UC_X86_INS_VINSERTF32X8,
1001 | UC_X86_INS_VINSERTF64X2,
1002 | UC_X86_INS_VINSERTF64X4,
1003 | UC_X86_INS_VINSERTI128,
1004 | UC_X86_INS_VINSERTI32X4,
1005 | UC_X86_INS_VINSERTI32X8,
1006 | UC_X86_INS_VINSERTI64X2,
1007 | UC_X86_INS_VINSERTI64X4,
1008 | UC_X86_INS_VINSERTPS,
1009 | UC_X86_INS_VLDDQU,
1010 | UC_X86_INS_VLDMXCSR,
1011 | UC_X86_INS_VMASKMOVDQU,
1012 | UC_X86_INS_VMASKMOVPD,
1013 | UC_X86_INS_VMASKMOVPS,
1014 | UC_X86_INS_VMAXPD,
1015 | UC_X86_INS_VMAXPS,
1016 | UC_X86_INS_VMAXSD,
1017 | UC_X86_INS_VMAXSS,
1018 | UC_X86_INS_VMCALL,
1019 | UC_X86_INS_VMCLEAR,
1020 | UC_X86_INS_VMFUNC,
1021 | UC_X86_INS_VMINPD,
1022 | UC_X86_INS_VMINPS,
1023 | UC_X86_INS_VMINSD,
1024 | UC_X86_INS_VMINSS,
1025 | UC_X86_INS_VMLAUNCH,
1026 | UC_X86_INS_VMLOAD,
1027 | UC_X86_INS_VMMCALL,
1028 | UC_X86_INS_VMOVQ,
1029 | UC_X86_INS_VMOVDDUP,
1030 | UC_X86_INS_VMOVD,
1031 | UC_X86_INS_VMOVDQA32,
1032 | UC_X86_INS_VMOVDQA64,
1033 | UC_X86_INS_VMOVDQA,
1034 | UC_X86_INS_VMOVDQU16,
1035 | UC_X86_INS_VMOVDQU32,
1036 | UC_X86_INS_VMOVDQU64,
1037 | UC_X86_INS_VMOVDQU8,
1038 | UC_X86_INS_VMOVDQU,
1039 | UC_X86_INS_VMOVHLPS,
1040 | UC_X86_INS_VMOVHPD,
1041 | UC_X86_INS_VMOVHPS,
1042 | UC_X86_INS_VMOVLHPS,
1043 | UC_X86_INS_VMOVLPD,
1044 | UC_X86_INS_VMOVLPS,
1045 | UC_X86_INS_VMOVMSKPD,
1046 | UC_X86_INS_VMOVMSKPS,
1047 | UC_X86_INS_VMOVNTDQA,
1048 | UC_X86_INS_VMOVNTDQ,
1049 | UC_X86_INS_VMOVNTPD,
1050 | UC_X86_INS_VMOVNTPS,
1051 | UC_X86_INS_VMOVSD,
1052 | UC_X86_INS_VMOVSHDUP,
1053 | UC_X86_INS_VMOVSLDUP,
1054 | UC_X86_INS_VMOVSS,
1055 | UC_X86_INS_VMOVUPD,
1056 | UC_X86_INS_VMOVUPS,
1057 | UC_X86_INS_VMPSADBW,
1058 | UC_X86_INS_VMPTRLD,
1059 | UC_X86_INS_VMPTRST,
1060 | UC_X86_INS_VMREAD,
1061 | UC_X86_INS_VMRESUME,
1062 | UC_X86_INS_VMRUN,
1063 | UC_X86_INS_VMSAVE,
1064 | UC_X86_INS_VMULPD,
1065 | UC_X86_INS_VMULPS,
1066 | UC_X86_INS_VMULSD,
1067 | UC_X86_INS_VMULSS,
1068 | UC_X86_INS_VMWRITE,
1069 | UC_X86_INS_VMXOFF,
1070 | UC_X86_INS_VMXON,
1071 | UC_X86_INS_VPABSB,
1072 | UC_X86_INS_VPABSD,
1073 | UC_X86_INS_VPABSQ,
1074 | UC_X86_INS_VPABSW,
1075 | UC_X86_INS_VPACKSSDW,
1076 | UC_X86_INS_VPACKSSWB,
1077 | UC_X86_INS_VPACKUSDW,
1078 | UC_X86_INS_VPACKUSWB,
1079 | UC_X86_INS_VPADDB,
1080 | UC_X86_INS_VPADDD,
1081 | UC_X86_INS_VPADDQ,
1082 | UC_X86_INS_VPADDSB,
1083 | UC_X86_INS_VPADDSW,
1084 | UC_X86_INS_VPADDUSB,
1085 | UC_X86_INS_VPADDUSW,
1086 | UC_X86_INS_VPADDW,
1087 | UC_X86_INS_VPALIGNR,
1088 | UC_X86_INS_VPANDD,
1089 | UC_X86_INS_VPANDND,
1090 | UC_X86_INS_VPANDNQ,
1091 | UC_X86_INS_VPANDN,
1092 | UC_X86_INS_VPANDQ,
1093 | UC_X86_INS_VPAND,
1094 | UC_X86_INS_VPAVGB,
1095 | UC_X86_INS_VPAVGW,
1096 | UC_X86_INS_VPBLENDD,
1097 | UC_X86_INS_VPBLENDMB,
1098 | UC_X86_INS_VPBLENDMD,
1099 | UC_X86_INS_VPBLENDMQ,
1100 | UC_X86_INS_VPBLENDMW,
1101 | UC_X86_INS_VPBLENDVB,
1102 | UC_X86_INS_VPBLENDW,
1103 | UC_X86_INS_VPBROADCASTB,
1104 | UC_X86_INS_VPBROADCASTD,
1105 | UC_X86_INS_VPBROADCASTMB2Q,
1106 | UC_X86_INS_VPBROADCASTMW2D,
1107 | UC_X86_INS_VPBROADCASTQ,
1108 | UC_X86_INS_VPBROADCASTW,
1109 | UC_X86_INS_VPCLMULQDQ,
1110 | UC_X86_INS_VPCMOV,
1111 | UC_X86_INS_VPCMPB,
1112 | UC_X86_INS_VPCMPD,
1113 | UC_X86_INS_VPCMPEQB,
1114 | UC_X86_INS_VPCMPEQD,
1115 | UC_X86_INS_VPCMPEQQ,
1116 | UC_X86_INS_VPCMPEQW,
1117 | UC_X86_INS_VPCMPESTRI,
1118 | UC_X86_INS_VPCMPESTRM,
1119 | UC_X86_INS_VPCMPGTB,
1120 | UC_X86_INS_VPCMPGTD,
1121 | UC_X86_INS_VPCMPGTQ,
1122 | UC_X86_INS_VPCMPGTW,
1123 | UC_X86_INS_VPCMPISTRI,
1124 | UC_X86_INS_VPCMPISTRM,
1125 | UC_X86_INS_VPCMPQ,
1126 | UC_X86_INS_VPCMPUB,
1127 | UC_X86_INS_VPCMPUD,
1128 | UC_X86_INS_VPCMPUQ,
1129 | UC_X86_INS_VPCMPUW,
1130 | UC_X86_INS_VPCMPW,
1131 | UC_X86_INS_VPCOMB,
1132 | UC_X86_INS_VPCOMD,
1133 | UC_X86_INS_VPCOMPRESSD,
1134 | UC_X86_INS_VPCOMPRESSQ,
1135 | UC_X86_INS_VPCOMQ,
1136 | UC_X86_INS_VPCOMUB,
1137 | UC_X86_INS_VPCOMUD,
1138 | UC_X86_INS_VPCOMUQ,
1139 | UC_X86_INS_VPCOMUW,
1140 | UC_X86_INS_VPCOMW,
1141 | UC_X86_INS_VPCONFLICTD,
1142 | UC_X86_INS_VPCONFLICTQ,
1143 | UC_X86_INS_VPERM2F128,
1144 | UC_X86_INS_VPERM2I128,
1145 | UC_X86_INS_VPERMD,
1146 | UC_X86_INS_VPERMI2D,
1147 | UC_X86_INS_VPERMI2PD,
1148 | UC_X86_INS_VPERMI2PS,
1149 | UC_X86_INS_VPERMI2Q,
1150 | UC_X86_INS_VPERMIL2PD,
1151 | UC_X86_INS_VPERMIL2PS,
1152 | UC_X86_INS_VPERMILPD,
1153 | UC_X86_INS_VPERMILPS,
1154 | UC_X86_INS_VPERMPD,
1155 | UC_X86_INS_VPERMPS,
1156 | UC_X86_INS_VPERMQ,
1157 | UC_X86_INS_VPERMT2D,
1158 | UC_X86_INS_VPERMT2PD,
1159 | UC_X86_INS_VPERMT2PS,
1160 | UC_X86_INS_VPERMT2Q,
1161 | UC_X86_INS_VPEXPANDD,
1162 | UC_X86_INS_VPEXPANDQ,
1163 | UC_X86_INS_VPEXTRB,
1164 | UC_X86_INS_VPEXTRD,
1165 | UC_X86_INS_VPEXTRQ,
1166 | UC_X86_INS_VPEXTRW,
1167 | UC_X86_INS_VPGATHERDD,
1168 | UC_X86_INS_VPGATHERDQ,
1169 | UC_X86_INS_VPGATHERQD,
1170 | UC_X86_INS_VPGATHERQQ,
1171 | UC_X86_INS_VPHADDBD,
1172 | UC_X86_INS_VPHADDBQ,
1173 | UC_X86_INS_VPHADDBW,
1174 | UC_X86_INS_VPHADDDQ,
1175 | UC_X86_INS_VPHADDD,
1176 | UC_X86_INS_VPHADDSW,
1177 | UC_X86_INS_VPHADDUBD,
1178 | UC_X86_INS_VPHADDUBQ,
1179 | UC_X86_INS_VPHADDUBW,
1180 | UC_X86_INS_VPHADDUDQ,
1181 | UC_X86_INS_VPHADDUWD,
1182 | UC_X86_INS_VPHADDUWQ,
1183 | UC_X86_INS_VPHADDWD,
1184 | UC_X86_INS_VPHADDWQ,
1185 | UC_X86_INS_VPHADDW,
1186 | UC_X86_INS_VPHMINPOSUW,
1187 | UC_X86_INS_VPHSUBBW,
1188 | UC_X86_INS_VPHSUBDQ,
1189 | UC_X86_INS_VPHSUBD,
1190 | UC_X86_INS_VPHSUBSW,
1191 | UC_X86_INS_VPHSUBWD,
1192 | UC_X86_INS_VPHSUBW,
1193 | UC_X86_INS_VPINSRB,
1194 | UC_X86_INS_VPINSRD,
1195 | UC_X86_INS_VPINSRQ,
1196 | UC_X86_INS_VPINSRW,
1197 | UC_X86_INS_VPLZCNTD,
1198 | UC_X86_INS_VPLZCNTQ,
1199 | UC_X86_INS_VPMACSDD,
1200 | UC_X86_INS_VPMACSDQH,
1201 | UC_X86_INS_VPMACSDQL,
1202 | UC_X86_INS_VPMACSSDD,
1203 | UC_X86_INS_VPMACSSDQH,
1204 | UC_X86_INS_VPMACSSDQL,
1205 | UC_X86_INS_VPMACSSWD,
1206 | UC_X86_INS_VPMACSSWW,
1207 | UC_X86_INS_VPMACSWD,
1208 | UC_X86_INS_VPMACSWW,
1209 | UC_X86_INS_VPMADCSSWD,
1210 | UC_X86_INS_VPMADCSWD,
1211 | UC_X86_INS_VPMADDUBSW,
1212 | UC_X86_INS_VPMADDWD,
1213 | UC_X86_INS_VPMASKMOVD,
1214 | UC_X86_INS_VPMASKMOVQ,
1215 | UC_X86_INS_VPMAXSB,
1216 | UC_X86_INS_VPMAXSD,
1217 | UC_X86_INS_VPMAXSQ,
1218 | UC_X86_INS_VPMAXSW,
1219 | UC_X86_INS_VPMAXUB,
1220 | UC_X86_INS_VPMAXUD,
1221 | UC_X86_INS_VPMAXUQ,
1222 | UC_X86_INS_VPMAXUW,
1223 | UC_X86_INS_VPMINSB,
1224 | UC_X86_INS_VPMINSD,
1225 | UC_X86_INS_VPMINSQ,
1226 | UC_X86_INS_VPMINSW,
1227 | UC_X86_INS_VPMINUB,
1228 | UC_X86_INS_VPMINUD,
1229 | UC_X86_INS_VPMINUQ,
1230 | UC_X86_INS_VPMINUW,
1231 | UC_X86_INS_VPMOVDB,
1232 | UC_X86_INS_VPMOVDW,
1233 | UC_X86_INS_VPMOVM2B,
1234 | UC_X86_INS_VPMOVM2D,
1235 | UC_X86_INS_VPMOVM2Q,
1236 | UC_X86_INS_VPMOVM2W,
1237 | UC_X86_INS_VPMOVMSKB,
1238 | UC_X86_INS_VPMOVQB,
1239 | UC_X86_INS_VPMOVQD,
1240 | UC_X86_INS_VPMOVQW,
1241 | UC_X86_INS_VPMOVSDB,
1242 | UC_X86_INS_VPMOVSDW,
1243 | UC_X86_INS_VPMOVSQB,
1244 | UC_X86_INS_VPMOVSQD,
1245 | UC_X86_INS_VPMOVSQW,
1246 | UC_X86_INS_VPMOVSXBD,
1247 | UC_X86_INS_VPMOVSXBQ,
1248 | UC_X86_INS_VPMOVSXBW,
1249 | UC_X86_INS_VPMOVSXDQ,
1250 | UC_X86_INS_VPMOVSXWD,
1251 | UC_X86_INS_VPMOVSXWQ,
1252 | UC_X86_INS_VPMOVUSDB,
1253 | UC_X86_INS_VPMOVUSDW,
1254 | UC_X86_INS_VPMOVUSQB,
1255 | UC_X86_INS_VPMOVUSQD,
1256 | UC_X86_INS_VPMOVUSQW,
1257 | UC_X86_INS_VPMOVZXBD,
1258 | UC_X86_INS_VPMOVZXBQ,
1259 | UC_X86_INS_VPMOVZXBW,
1260 | UC_X86_INS_VPMOVZXDQ,
1261 | UC_X86_INS_VPMOVZXWD,
1262 | UC_X86_INS_VPMOVZXWQ,
1263 | UC_X86_INS_VPMULDQ,
1264 | UC_X86_INS_VPMULHRSW,
1265 | UC_X86_INS_VPMULHUW,
1266 | UC_X86_INS_VPMULHW,
1267 | UC_X86_INS_VPMULLD,
1268 | UC_X86_INS_VPMULLQ,
1269 | UC_X86_INS_VPMULLW,
1270 | UC_X86_INS_VPMULUDQ,
1271 | UC_X86_INS_VPORD,
1272 | UC_X86_INS_VPORQ,
1273 | UC_X86_INS_VPOR,
1274 | UC_X86_INS_VPPERM,
1275 | UC_X86_INS_VPROTB,
1276 | UC_X86_INS_VPROTD,
1277 | UC_X86_INS_VPROTQ,
1278 | UC_X86_INS_VPROTW,
1279 | UC_X86_INS_VPSADBW,
1280 | UC_X86_INS_VPSCATTERDD,
1281 | UC_X86_INS_VPSCATTERDQ,
1282 | UC_X86_INS_VPSCATTERQD,
1283 | UC_X86_INS_VPSCATTERQQ,
1284 | UC_X86_INS_VPSHAB,
1285 | UC_X86_INS_VPSHAD,
1286 | UC_X86_INS_VPSHAQ,
1287 | UC_X86_INS_VPSHAW,
1288 | UC_X86_INS_VPSHLB,
1289 | UC_X86_INS_VPSHLD,
1290 | UC_X86_INS_VPSHLQ,
1291 | UC_X86_INS_VPSHLW,
1292 | UC_X86_INS_VPSHUFB,
1293 | UC_X86_INS_VPSHUFD,
1294 | UC_X86_INS_VPSHUFHW,
1295 | UC_X86_INS_VPSHUFLW,
1296 | UC_X86_INS_VPSIGNB,
1297 | UC_X86_INS_VPSIGND,
1298 | UC_X86_INS_VPSIGNW,
1299 | UC_X86_INS_VPSLLDQ,
1300 | UC_X86_INS_VPSLLD,
1301 | UC_X86_INS_VPSLLQ,
1302 | UC_X86_INS_VPSLLVD,
1303 | UC_X86_INS_VPSLLVQ,
1304 | UC_X86_INS_VPSLLW,
1305 | UC_X86_INS_VPSRAD,
1306 | UC_X86_INS_VPSRAQ,
1307 | UC_X86_INS_VPSRAVD,
1308 | UC_X86_INS_VPSRAVQ,
1309 | UC_X86_INS_VPSRAW,
1310 | UC_X86_INS_VPSRLDQ,
1311 | UC_X86_INS_VPSRLD,
1312 | UC_X86_INS_VPSRLQ,
1313 | UC_X86_INS_VPSRLVD,
1314 | UC_X86_INS_VPSRLVQ,
1315 | UC_X86_INS_VPSRLW,
1316 | UC_X86_INS_VPSUBB,
1317 | UC_X86_INS_VPSUBD,
1318 | UC_X86_INS_VPSUBQ,
1319 | UC_X86_INS_VPSUBSB,
1320 | UC_X86_INS_VPSUBSW,
1321 | UC_X86_INS_VPSUBUSB,
1322 | UC_X86_INS_VPSUBUSW,
1323 | UC_X86_INS_VPSUBW,
1324 | UC_X86_INS_VPTESTMD,
1325 | UC_X86_INS_VPTESTMQ,
1326 | UC_X86_INS_VPTESTNMD,
1327 | UC_X86_INS_VPTESTNMQ,
1328 | UC_X86_INS_VPTEST,
1329 | UC_X86_INS_VPUNPCKHBW,
1330 | UC_X86_INS_VPUNPCKHDQ,
1331 | UC_X86_INS_VPUNPCKHQDQ,
1332 | UC_X86_INS_VPUNPCKHWD,
1333 | UC_X86_INS_VPUNPCKLBW,
1334 | UC_X86_INS_VPUNPCKLDQ,
1335 | UC_X86_INS_VPUNPCKLQDQ,
1336 | UC_X86_INS_VPUNPCKLWD,
1337 | UC_X86_INS_VPXORD,
1338 | UC_X86_INS_VPXORQ,
1339 | UC_X86_INS_VPXOR,
1340 | UC_X86_INS_VRCP14PD,
1341 | UC_X86_INS_VRCP14PS,
1342 | UC_X86_INS_VRCP14SD,
1343 | UC_X86_INS_VRCP14SS,
1344 | UC_X86_INS_VRCP28PD,
1345 | UC_X86_INS_VRCP28PS,
1346 | UC_X86_INS_VRCP28SD,
1347 | UC_X86_INS_VRCP28SS,
1348 | UC_X86_INS_VRCPPS,
1349 | UC_X86_INS_VRCPSS,
1350 | UC_X86_INS_VRNDSCALEPD,
1351 | UC_X86_INS_VRNDSCALEPS,
1352 | UC_X86_INS_VRNDSCALESD,
1353 | UC_X86_INS_VRNDSCALESS,
1354 | UC_X86_INS_VROUNDPD,
1355 | UC_X86_INS_VROUNDPS,
1356 | UC_X86_INS_VROUNDSD,
1357 | UC_X86_INS_VROUNDSS,
1358 | UC_X86_INS_VRSQRT14PD,
1359 | UC_X86_INS_VRSQRT14PS,
1360 | UC_X86_INS_VRSQRT14SD,
1361 | UC_X86_INS_VRSQRT14SS,
1362 | UC_X86_INS_VRSQRT28PD,
1363 | UC_X86_INS_VRSQRT28PS,
1364 | UC_X86_INS_VRSQRT28SD,
1365 | UC_X86_INS_VRSQRT28SS,
1366 | UC_X86_INS_VRSQRTPS,
1367 | UC_X86_INS_VRSQRTSS,
1368 | UC_X86_INS_VSCATTERDPD,
1369 | UC_X86_INS_VSCATTERDPS,
1370 | UC_X86_INS_VSCATTERPF0DPD,
1371 | UC_X86_INS_VSCATTERPF0DPS,
1372 | UC_X86_INS_VSCATTERPF0QPD,
1373 | UC_X86_INS_VSCATTERPF0QPS,
1374 | UC_X86_INS_VSCATTERPF1DPD,
1375 | UC_X86_INS_VSCATTERPF1DPS,
1376 | UC_X86_INS_VSCATTERPF1QPD,
1377 | UC_X86_INS_VSCATTERPF1QPS,
1378 | UC_X86_INS_VSCATTERQPD,
1379 | UC_X86_INS_VSCATTERQPS,
1380 | UC_X86_INS_VSHUFPD,
1381 | UC_X86_INS_VSHUFPS,
1382 | UC_X86_INS_VSQRTPD,
1383 | UC_X86_INS_VSQRTPS,
1384 | UC_X86_INS_VSQRTSD,
1385 | UC_X86_INS_VSQRTSS,
1386 | UC_X86_INS_VSTMXCSR,
1387 | UC_X86_INS_VSUBPD,
1388 | UC_X86_INS_VSUBPS,
1389 | UC_X86_INS_VSUBSD,
1390 | UC_X86_INS_VSUBSS,
1391 | UC_X86_INS_VTESTPD,
1392 | UC_X86_INS_VTESTPS,
1393 | UC_X86_INS_VUNPCKHPD,
1394 | UC_X86_INS_VUNPCKHPS,
1395 | UC_X86_INS_VUNPCKLPD,
1396 | UC_X86_INS_VUNPCKLPS,
1397 | UC_X86_INS_VZEROALL,
1398 | UC_X86_INS_VZEROUPPER,
1399 | UC_X86_INS_WAIT,
1400 | UC_X86_INS_WBINVD,
1401 | UC_X86_INS_WRFSBASE,
1402 | UC_X86_INS_WRGSBASE,
1403 | UC_X86_INS_WRMSR,
1404 | UC_X86_INS_XABORT,
1405 | UC_X86_INS_XACQUIRE,
1406 | UC_X86_INS_XBEGIN,
1407 | UC_X86_INS_XCHG,
1408 | UC_X86_INS_XCRYPTCBC,
1409 | UC_X86_INS_XCRYPTCFB,
1410 | UC_X86_INS_XCRYPTCTR,
1411 | UC_X86_INS_XCRYPTECB,
1412 | UC_X86_INS_XCRYPTOFB,
1413 | UC_X86_INS_XEND,
1414 | UC_X86_INS_XGETBV,
1415 | UC_X86_INS_XLATB,
1416 | UC_X86_INS_XRELEASE,
1417 | UC_X86_INS_XRSTOR,
1418 | UC_X86_INS_XRSTOR64,
1419 | UC_X86_INS_XRSTORS,
1420 | UC_X86_INS_XRSTORS64,
1421 | UC_X86_INS_XSAVE,
1422 | UC_X86_INS_XSAVE64,
1423 | UC_X86_INS_XSAVEC,
1424 | UC_X86_INS_XSAVEC64,
1425 | UC_X86_INS_XSAVEOPT,
1426 | UC_X86_INS_XSAVEOPT64,
1427 | UC_X86_INS_XSAVES,
1428 | UC_X86_INS_XSAVES64,
1429 | UC_X86_INS_XSETBV,
1430 | UC_X86_INS_XSHA1,
1431 | UC_X86_INS_XSHA256,
1432 | UC_X86_INS_XSTORE,
1433 | UC_X86_INS_XTEST,
1434 | UC_X86_INS_FDISI8087_NOP,
1435 | UC_X86_INS_FENI8087_NOP,
1436 |
1437 | UC_X86_INS_ENDING, // mark the end of the list of insn
1438 | } uc_x86_insn;
1439 |
1440 | #ifdef __cplusplus
1441 | }
1442 | #endif
1443 |
1444 | #endif
1445 |
--------------------------------------------------------------------------------