Pascal/Delphi binding (#987)

* Pascal/Delphi binding

Pascal/Delphi language binding

* update credits
This commit is contained in:
Coldzer0 2018-08-03 14:33:25 +02:00 committed by Nguyen Anh Quynh
parent c7be4a2160
commit 84220d8360
17 changed files with 4864 additions and 0 deletions

View File

@ -67,3 +67,4 @@ Andrew Dutcher: uc_context_{save, restore} API.
Stephen Groat: improved CI setup.
David Zimmer: VB6 binding.
zhangwm: ARM & ARM64 big endian.
Mohamed Osama: FreePascal/Delphi binding.

View File

@ -25,6 +25,7 @@ build:
$(MAKE) -C java gen_const
$(MAKE) -C ruby gen_const
python const_generator.py dotnet
python const_generator.py pascal
install: build
$(MAKE) -C python install

View File

@ -9,6 +9,7 @@ The following bindings are contributed by community.
- Ruby binding: by Sascha Schirra
- Haskell binding: by Adrian Herrera.
- VB6 binding: David Zimmer.
- FreePascal/Delphi binding: Mohamed Osama.
More bindings created & maintained externally by community are available as follows.

View File

@ -88,6 +88,22 @@ template = {
'comment_open': ' //',
'comment_close': '',
},
'pascal': {
'header': "// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT\n\nunit %sConst;\n\ninterface\n\nconst",
'footer': "\nimplementation\nend.",
'line_format': ' UC_%s = %s;\n',
'out_file': os.path.join('pascal', 'unicorn', '%sConst.pas'),
# prefixes for constant filenames of all archs - case sensitive
'arm.h': 'Arm',
'arm64.h': 'Arm64',
'mips.h': 'Mips',
'x86.h': 'X86',
'sparc.h': 'Sparc',
'm68k.h': 'M68k',
'unicorn.h': 'Unicorn',
'comment_open': '//',
'comment_close': '',
},
}
# markup for comments to be added to autogen files

339
bindings/pascal/LICENSE Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C) 2018 Coldzer0
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

52
bindings/pascal/README.md Normal file
View File

@ -0,0 +1,52 @@
# unicorn-engine-pascal
Pascal/Delphi language binding for the [Unicorn emulator](http://www.unicorn-engine.org/)
([GitHub](https://github.com/unicorn-engine/unicorn)).
*Unicorn* is a lightweight multi-platform, multi-architecture CPU emulator framework
based on [QEMU](http://www.qemu.org/).
## License
`GPLv2`
## Compilers Compatibility
#### Free Pascal >= v3
- `Mac OS`
- `Windows`
- `Linux`
#### Delphi
- `Windows`
## Features
* Same API as the C core
- with some workarounds for Pascals case insensitivity:
`uc_mem_write()` -> `uc_mem_write_()`, `uc_mem_read()` -> `uc_mem_read_()`
- and the missing feature passing variable number of arguments to functions (`...`):
i solve it by using -> `args : Array of Const;`
you can pass args inside [] like :
```pascal
uc_hook_add(uc, trace, UC_HOOK_INSN, @HookIn, nil, 1,0,[UC_X86_INS_IN];
```
the main loader in `Unicorn_dyn.pas` , check X86 example for more info .
* Multiplatform (Mac OS , Windows and Linux are tested)
## Examples
* `X86` Emulate 16, 32, 64 Bit x86
## Version History
* `1.1`
* Add Delphi Compatibility [ Windows ]
* `1.0`
* this is the first version it has all APIs of UNICORN v1.0.1
## TODO
- Add more Examples
- Add <b>Mac , Linux</b> Support for Delphi

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="10"/>
<General>
<Flags>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<MainUnitHasScaledStatement Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="x86"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
</General>
<BuildModes Count="3">
<Item1 Name="Default" Default="True"/>
<Item2 Name="Debug">
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="x86"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="../unicorn"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<UseHeaptrc Value="True"/>
<TrashVariables Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
</Item2>
<Item3 Name="Release">
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="x86"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="../unicorn"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
</Debugging>
<LinkSmart Value="True"/>
</Linking>
</CompilerOptions>
</Item3>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<CommandLineParams Value="-32"/>
</local>
</RunParams>
<Units Count="1">
<Unit0>
<Filename Value="x86.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="x86"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="../unicorn"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectSession>
<Version Value="10"/>
<BuildModes Active="Debug"/>
<Units Count="10">
<Unit0>
<Filename Value="x86.lpr"/>
<IsPartOfProject Value="True"/>
<TopLine Value="8"/>
<CursorPos X="34" Y="4"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="../unicorn/UnicornConst.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="25" Y="2"/>
<UsageCount Value="10"/>
</Unit1>
<Unit2>
<Filename Value="../unicorn/Unicorn_dyn.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<CursorPos X="80" Y="3"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="/usr/local/share/fpcsrc/rtl/objpas/sysutils/sysstrh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="71"/>
<CursorPos X="25" Y="77"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<Filename Value="/usr/local/share/fpcsrc/rtl/inc/systemh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="331"/>
<CursorPos X="3" Y="339"/>
<UsageCount Value="10"/>
</Unit4>
<Unit5>
<Filename Value="/usr/local/share/fpcsrc/packages/rtl-console/src/unix/crt.pp"/>
<UnitName Value="Crt"/>
<EditorIndex Value="-1"/>
<TopLine Value="1104"/>
<CursorPos X="7" Y="534"/>
<UsageCount Value="10"/>
</Unit5>
<Unit6>
<Filename Value="/usr/local/share/fpcsrc/packages/rtl-console/src/inc/crth.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="31"/>
<CursorPos X="11" Y="44"/>
<UsageCount Value="10"/>
</Unit6>
<Unit7>
<Filename Value="/usr/local/share/fpcsrc/rtl/darwin/termio.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="24"/>
<UsageCount Value="10"/>
</Unit7>
<Unit8>
<Filename Value="../unicorn/X86Const.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="57"/>
<UsageCount Value="10"/>
</Unit8>
<Unit9>
<Filename Value="/usr/local/share/fpcsrc/rtl/inc/dynlibs.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="46"/>
<CursorPos X="25" Y="53"/>
<UsageCount Value="10"/>
</Unit9>
</Units>
<JumpHistory Count="26" HistoryIndex="25">
<Position1>
<Filename Value="x86.lpr"/>
<Caret Line="332" TopLine="323"/>
</Position1>
<Position2>
<Filename Value="x86.lpr"/>
<Caret Line="333" TopLine="323"/>
</Position2>
<Position3>
<Filename Value="x86.lpr"/>
<Caret Line="338" TopLine="331"/>
</Position3>
<Position4>
<Filename Value="x86.lpr"/>
<Caret Line="340" Column="42" TopLine="330"/>
</Position4>
<Position5>
<Filename Value="x86.lpr"/>
<Caret Line="339" Column="29" TopLine="335"/>
</Position5>
<Position6>
<Filename Value="x86.lpr"/>
<Caret Line="684" Column="42" TopLine="507"/>
</Position6>
<Position7>
<Filename Value="x86.lpr"/>
<Caret Line="51" Column="73" TopLine="43"/>
</Position7>
<Position8>
<Filename Value="x86.lpr"/>
<Caret Line="32" Column="16" TopLine="27"/>
</Position8>
<Position9>
<Filename Value="x86.lpr"/>
<Caret Line="895" Column="18" TopLine="889"/>
</Position9>
<Position10>
<Filename Value="x86.lpr"/>
<Caret Line="894" Column="6" TopLine="889"/>
</Position10>
<Position11>
<Filename Value="x86.lpr"/>
<Caret Line="52" Column="73" TopLine="44"/>
</Position11>
<Position12>
<Filename Value="x86.lpr"/>
<Caret Line="279" TopLine="268"/>
</Position12>
<Position13>
<Filename Value="x86.lpr"/>
<Caret Line="280" Column="26" TopLine="272"/>
</Position13>
<Position14>
<Filename Value="x86.lpr"/>
<Caret Line="898" Column="16" TopLine="883"/>
</Position14>
<Position15>
<Filename Value="x86.lpr"/>
<Caret Line="889" Column="40" TopLine="879"/>
</Position15>
<Position16>
<Filename Value="x86.lpr"/>
<Caret Line="447" Column="44" TopLine="440"/>
</Position16>
<Position17>
<Filename Value="x86.lpr"/>
<Caret Line="894" Column="12" TopLine="887"/>
</Position17>
<Position18>
<Filename Value="x86.lpr"/>
<Caret Line="255" Column="28" TopLine="247"/>
</Position18>
<Position19>
<Filename Value="x86.lpr"/>
<Caret Line="984" Column="8" TopLine="973"/>
</Position19>
<Position20>
<Filename Value="x86.lpr"/>
<Caret Line="987" Column="9" TopLine="976"/>
</Position20>
<Position21>
<Filename Value="x86.lpr"/>
<Caret Line="22" Column="15" TopLine="17"/>
</Position21>
<Position22>
<Filename Value="../unicorn/Unicorn_dyn.pas"/>
<Caret Line="128" Column="37" TopLine="119"/>
</Position22>
<Position23>
<Filename Value="../unicorn/Unicorn_dyn.pas"/>
<Caret Line="600" TopLine="597"/>
</Position23>
<Position24>
<Filename Value="../unicorn/Unicorn_dyn.pas"/>
<Caret Line="9" Column="3" TopLine="8"/>
</Position24>
<Position25>
<Filename Value="../unicorn/Unicorn_dyn.pas"/>
<Caret Line="640" Column="15" TopLine="632"/>
</Position25>
<Position26>
<Filename Value="x86.lpr"/>
<Caret Line="989" Column="132" TopLine="6"/>
</Position26>
</JumpHistory>
</ProjectSession>
<Debugging>
<Watches Count="2">
<Item1>
<Expression Value="mem"/>
<DisplayStyle Value="wdfPointer"/>
</Item1>
<Item2>
<Expression Value="X86_CODE32"/>
<DisplayStyle Value="wdfMemDump"/>
</Item2>
</Watches>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,288 @@
// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
unit Arm64Const;
interface
const
// ARM64 registers
UC_ARM64_REG_INVALID = 0;
UC_ARM64_REG_X29 = 1;
UC_ARM64_REG_X30 = 2;
UC_ARM64_REG_NZCV = 3;
UC_ARM64_REG_SP = 4;
UC_ARM64_REG_WSP = 5;
UC_ARM64_REG_WZR = 6;
UC_ARM64_REG_XZR = 7;
UC_ARM64_REG_B0 = 8;
UC_ARM64_REG_B1 = 9;
UC_ARM64_REG_B2 = 10;
UC_ARM64_REG_B3 = 11;
UC_ARM64_REG_B4 = 12;
UC_ARM64_REG_B5 = 13;
UC_ARM64_REG_B6 = 14;
UC_ARM64_REG_B7 = 15;
UC_ARM64_REG_B8 = 16;
UC_ARM64_REG_B9 = 17;
UC_ARM64_REG_B10 = 18;
UC_ARM64_REG_B11 = 19;
UC_ARM64_REG_B12 = 20;
UC_ARM64_REG_B13 = 21;
UC_ARM64_REG_B14 = 22;
UC_ARM64_REG_B15 = 23;
UC_ARM64_REG_B16 = 24;
UC_ARM64_REG_B17 = 25;
UC_ARM64_REG_B18 = 26;
UC_ARM64_REG_B19 = 27;
UC_ARM64_REG_B20 = 28;
UC_ARM64_REG_B21 = 29;
UC_ARM64_REG_B22 = 30;
UC_ARM64_REG_B23 = 31;
UC_ARM64_REG_B24 = 32;
UC_ARM64_REG_B25 = 33;
UC_ARM64_REG_B26 = 34;
UC_ARM64_REG_B27 = 35;
UC_ARM64_REG_B28 = 36;
UC_ARM64_REG_B29 = 37;
UC_ARM64_REG_B30 = 38;
UC_ARM64_REG_B31 = 39;
UC_ARM64_REG_D0 = 40;
UC_ARM64_REG_D1 = 41;
UC_ARM64_REG_D2 = 42;
UC_ARM64_REG_D3 = 43;
UC_ARM64_REG_D4 = 44;
UC_ARM64_REG_D5 = 45;
UC_ARM64_REG_D6 = 46;
UC_ARM64_REG_D7 = 47;
UC_ARM64_REG_D8 = 48;
UC_ARM64_REG_D9 = 49;
UC_ARM64_REG_D10 = 50;
UC_ARM64_REG_D11 = 51;
UC_ARM64_REG_D12 = 52;
UC_ARM64_REG_D13 = 53;
UC_ARM64_REG_D14 = 54;
UC_ARM64_REG_D15 = 55;
UC_ARM64_REG_D16 = 56;
UC_ARM64_REG_D17 = 57;
UC_ARM64_REG_D18 = 58;
UC_ARM64_REG_D19 = 59;
UC_ARM64_REG_D20 = 60;
UC_ARM64_REG_D21 = 61;
UC_ARM64_REG_D22 = 62;
UC_ARM64_REG_D23 = 63;
UC_ARM64_REG_D24 = 64;
UC_ARM64_REG_D25 = 65;
UC_ARM64_REG_D26 = 66;
UC_ARM64_REG_D27 = 67;
UC_ARM64_REG_D28 = 68;
UC_ARM64_REG_D29 = 69;
UC_ARM64_REG_D30 = 70;
UC_ARM64_REG_D31 = 71;
UC_ARM64_REG_H0 = 72;
UC_ARM64_REG_H1 = 73;
UC_ARM64_REG_H2 = 74;
UC_ARM64_REG_H3 = 75;
UC_ARM64_REG_H4 = 76;
UC_ARM64_REG_H5 = 77;
UC_ARM64_REG_H6 = 78;
UC_ARM64_REG_H7 = 79;
UC_ARM64_REG_H8 = 80;
UC_ARM64_REG_H9 = 81;
UC_ARM64_REG_H10 = 82;
UC_ARM64_REG_H11 = 83;
UC_ARM64_REG_H12 = 84;
UC_ARM64_REG_H13 = 85;
UC_ARM64_REG_H14 = 86;
UC_ARM64_REG_H15 = 87;
UC_ARM64_REG_H16 = 88;
UC_ARM64_REG_H17 = 89;
UC_ARM64_REG_H18 = 90;
UC_ARM64_REG_H19 = 91;
UC_ARM64_REG_H20 = 92;
UC_ARM64_REG_H21 = 93;
UC_ARM64_REG_H22 = 94;
UC_ARM64_REG_H23 = 95;
UC_ARM64_REG_H24 = 96;
UC_ARM64_REG_H25 = 97;
UC_ARM64_REG_H26 = 98;
UC_ARM64_REG_H27 = 99;
UC_ARM64_REG_H28 = 100;
UC_ARM64_REG_H29 = 101;
UC_ARM64_REG_H30 = 102;
UC_ARM64_REG_H31 = 103;
UC_ARM64_REG_Q0 = 104;
UC_ARM64_REG_Q1 = 105;
UC_ARM64_REG_Q2 = 106;
UC_ARM64_REG_Q3 = 107;
UC_ARM64_REG_Q4 = 108;
UC_ARM64_REG_Q5 = 109;
UC_ARM64_REG_Q6 = 110;
UC_ARM64_REG_Q7 = 111;
UC_ARM64_REG_Q8 = 112;
UC_ARM64_REG_Q9 = 113;
UC_ARM64_REG_Q10 = 114;
UC_ARM64_REG_Q11 = 115;
UC_ARM64_REG_Q12 = 116;
UC_ARM64_REG_Q13 = 117;
UC_ARM64_REG_Q14 = 118;
UC_ARM64_REG_Q15 = 119;
UC_ARM64_REG_Q16 = 120;
UC_ARM64_REG_Q17 = 121;
UC_ARM64_REG_Q18 = 122;
UC_ARM64_REG_Q19 = 123;
UC_ARM64_REG_Q20 = 124;
UC_ARM64_REG_Q21 = 125;
UC_ARM64_REG_Q22 = 126;
UC_ARM64_REG_Q23 = 127;
UC_ARM64_REG_Q24 = 128;
UC_ARM64_REG_Q25 = 129;
UC_ARM64_REG_Q26 = 130;
UC_ARM64_REG_Q27 = 131;
UC_ARM64_REG_Q28 = 132;
UC_ARM64_REG_Q29 = 133;
UC_ARM64_REG_Q30 = 134;
UC_ARM64_REG_Q31 = 135;
UC_ARM64_REG_S0 = 136;
UC_ARM64_REG_S1 = 137;
UC_ARM64_REG_S2 = 138;
UC_ARM64_REG_S3 = 139;
UC_ARM64_REG_S4 = 140;
UC_ARM64_REG_S5 = 141;
UC_ARM64_REG_S6 = 142;
UC_ARM64_REG_S7 = 143;
UC_ARM64_REG_S8 = 144;
UC_ARM64_REG_S9 = 145;
UC_ARM64_REG_S10 = 146;
UC_ARM64_REG_S11 = 147;
UC_ARM64_REG_S12 = 148;
UC_ARM64_REG_S13 = 149;
UC_ARM64_REG_S14 = 150;
UC_ARM64_REG_S15 = 151;
UC_ARM64_REG_S16 = 152;
UC_ARM64_REG_S17 = 153;
UC_ARM64_REG_S18 = 154;
UC_ARM64_REG_S19 = 155;
UC_ARM64_REG_S20 = 156;
UC_ARM64_REG_S21 = 157;
UC_ARM64_REG_S22 = 158;
UC_ARM64_REG_S23 = 159;
UC_ARM64_REG_S24 = 160;
UC_ARM64_REG_S25 = 161;
UC_ARM64_REG_S26 = 162;
UC_ARM64_REG_S27 = 163;
UC_ARM64_REG_S28 = 164;
UC_ARM64_REG_S29 = 165;
UC_ARM64_REG_S30 = 166;
UC_ARM64_REG_S31 = 167;
UC_ARM64_REG_W0 = 168;
UC_ARM64_REG_W1 = 169;
UC_ARM64_REG_W2 = 170;
UC_ARM64_REG_W3 = 171;
UC_ARM64_REG_W4 = 172;
UC_ARM64_REG_W5 = 173;
UC_ARM64_REG_W6 = 174;
UC_ARM64_REG_W7 = 175;
UC_ARM64_REG_W8 = 176;
UC_ARM64_REG_W9 = 177;
UC_ARM64_REG_W10 = 178;
UC_ARM64_REG_W11 = 179;
UC_ARM64_REG_W12 = 180;
UC_ARM64_REG_W13 = 181;
UC_ARM64_REG_W14 = 182;
UC_ARM64_REG_W15 = 183;
UC_ARM64_REG_W16 = 184;
UC_ARM64_REG_W17 = 185;
UC_ARM64_REG_W18 = 186;
UC_ARM64_REG_W19 = 187;
UC_ARM64_REG_W20 = 188;
UC_ARM64_REG_W21 = 189;
UC_ARM64_REG_W22 = 190;
UC_ARM64_REG_W23 = 191;
UC_ARM64_REG_W24 = 192;
UC_ARM64_REG_W25 = 193;
UC_ARM64_REG_W26 = 194;
UC_ARM64_REG_W27 = 195;
UC_ARM64_REG_W28 = 196;
UC_ARM64_REG_W29 = 197;
UC_ARM64_REG_W30 = 198;
UC_ARM64_REG_X0 = 199;
UC_ARM64_REG_X1 = 200;
UC_ARM64_REG_X2 = 201;
UC_ARM64_REG_X3 = 202;
UC_ARM64_REG_X4 = 203;
UC_ARM64_REG_X5 = 204;
UC_ARM64_REG_X6 = 205;
UC_ARM64_REG_X7 = 206;
UC_ARM64_REG_X8 = 207;
UC_ARM64_REG_X9 = 208;
UC_ARM64_REG_X10 = 209;
UC_ARM64_REG_X11 = 210;
UC_ARM64_REG_X12 = 211;
UC_ARM64_REG_X13 = 212;
UC_ARM64_REG_X14 = 213;
UC_ARM64_REG_X15 = 214;
UC_ARM64_REG_X16 = 215;
UC_ARM64_REG_X17 = 216;
UC_ARM64_REG_X18 = 217;
UC_ARM64_REG_X19 = 218;
UC_ARM64_REG_X20 = 219;
UC_ARM64_REG_X21 = 220;
UC_ARM64_REG_X22 = 221;
UC_ARM64_REG_X23 = 222;
UC_ARM64_REG_X24 = 223;
UC_ARM64_REG_X25 = 224;
UC_ARM64_REG_X26 = 225;
UC_ARM64_REG_X27 = 226;
UC_ARM64_REG_X28 = 227;
UC_ARM64_REG_V0 = 228;
UC_ARM64_REG_V1 = 229;
UC_ARM64_REG_V2 = 230;
UC_ARM64_REG_V3 = 231;
UC_ARM64_REG_V4 = 232;
UC_ARM64_REG_V5 = 233;
UC_ARM64_REG_V6 = 234;
UC_ARM64_REG_V7 = 235;
UC_ARM64_REG_V8 = 236;
UC_ARM64_REG_V9 = 237;
UC_ARM64_REG_V10 = 238;
UC_ARM64_REG_V11 = 239;
UC_ARM64_REG_V12 = 240;
UC_ARM64_REG_V13 = 241;
UC_ARM64_REG_V14 = 242;
UC_ARM64_REG_V15 = 243;
UC_ARM64_REG_V16 = 244;
UC_ARM64_REG_V17 = 245;
UC_ARM64_REG_V18 = 246;
UC_ARM64_REG_V19 = 247;
UC_ARM64_REG_V20 = 248;
UC_ARM64_REG_V21 = 249;
UC_ARM64_REG_V22 = 250;
UC_ARM64_REG_V23 = 251;
UC_ARM64_REG_V24 = 252;
UC_ARM64_REG_V25 = 253;
UC_ARM64_REG_V26 = 254;
UC_ARM64_REG_V27 = 255;
UC_ARM64_REG_V28 = 256;
UC_ARM64_REG_V29 = 257;
UC_ARM64_REG_V30 = 258;
UC_ARM64_REG_V31 = 259;
// pseudo registers
UC_ARM64_REG_PC = 260;
UC_ARM64_REG_CPACR_EL1 = 261;
// thread registers
UC_ARM64_REG_TPIDR_EL0 = 262;
UC_ARM64_REG_TPIDRRO_EL0 = 263;
UC_ARM64_REG_TPIDR_EL1 = 264;
UC_ARM64_REG_ENDING = 265;
// alias registers
UC_ARM64_REG_IP0 = 215;
UC_ARM64_REG_IP1 = 216;
UC_ARM64_REG_FP = 1;
UC_ARM64_REG_LR = 2;
implementation
end.

View File

@ -0,0 +1,136 @@
// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
unit ArmConst;
interface
const
// ARM registers
UC_ARM_REG_INVALID = 0;
UC_ARM_REG_APSR = 1;
UC_ARM_REG_APSR_NZCV = 2;
UC_ARM_REG_CPSR = 3;
UC_ARM_REG_FPEXC = 4;
UC_ARM_REG_FPINST = 5;
UC_ARM_REG_FPSCR = 6;
UC_ARM_REG_FPSCR_NZCV = 7;
UC_ARM_REG_FPSID = 8;
UC_ARM_REG_ITSTATE = 9;
UC_ARM_REG_LR = 10;
UC_ARM_REG_PC = 11;
UC_ARM_REG_SP = 12;
UC_ARM_REG_SPSR = 13;
UC_ARM_REG_D0 = 14;
UC_ARM_REG_D1 = 15;
UC_ARM_REG_D2 = 16;
UC_ARM_REG_D3 = 17;
UC_ARM_REG_D4 = 18;
UC_ARM_REG_D5 = 19;
UC_ARM_REG_D6 = 20;
UC_ARM_REG_D7 = 21;
UC_ARM_REG_D8 = 22;
UC_ARM_REG_D9 = 23;
UC_ARM_REG_D10 = 24;
UC_ARM_REG_D11 = 25;
UC_ARM_REG_D12 = 26;
UC_ARM_REG_D13 = 27;
UC_ARM_REG_D14 = 28;
UC_ARM_REG_D15 = 29;
UC_ARM_REG_D16 = 30;
UC_ARM_REG_D17 = 31;
UC_ARM_REG_D18 = 32;
UC_ARM_REG_D19 = 33;
UC_ARM_REG_D20 = 34;
UC_ARM_REG_D21 = 35;
UC_ARM_REG_D22 = 36;
UC_ARM_REG_D23 = 37;
UC_ARM_REG_D24 = 38;
UC_ARM_REG_D25 = 39;
UC_ARM_REG_D26 = 40;
UC_ARM_REG_D27 = 41;
UC_ARM_REG_D28 = 42;
UC_ARM_REG_D29 = 43;
UC_ARM_REG_D30 = 44;
UC_ARM_REG_D31 = 45;
UC_ARM_REG_FPINST2 = 46;
UC_ARM_REG_MVFR0 = 47;
UC_ARM_REG_MVFR1 = 48;
UC_ARM_REG_MVFR2 = 49;
UC_ARM_REG_Q0 = 50;
UC_ARM_REG_Q1 = 51;
UC_ARM_REG_Q2 = 52;
UC_ARM_REG_Q3 = 53;
UC_ARM_REG_Q4 = 54;
UC_ARM_REG_Q5 = 55;
UC_ARM_REG_Q6 = 56;
UC_ARM_REG_Q7 = 57;
UC_ARM_REG_Q8 = 58;
UC_ARM_REG_Q9 = 59;
UC_ARM_REG_Q10 = 60;
UC_ARM_REG_Q11 = 61;
UC_ARM_REG_Q12 = 62;
UC_ARM_REG_Q13 = 63;
UC_ARM_REG_Q14 = 64;
UC_ARM_REG_Q15 = 65;
UC_ARM_REG_R0 = 66;
UC_ARM_REG_R1 = 67;
UC_ARM_REG_R2 = 68;
UC_ARM_REG_R3 = 69;
UC_ARM_REG_R4 = 70;
UC_ARM_REG_R5 = 71;
UC_ARM_REG_R6 = 72;
UC_ARM_REG_R7 = 73;
UC_ARM_REG_R8 = 74;
UC_ARM_REG_R9 = 75;
UC_ARM_REG_R10 = 76;
UC_ARM_REG_R11 = 77;
UC_ARM_REG_R12 = 78;
UC_ARM_REG_S0 = 79;
UC_ARM_REG_S1 = 80;
UC_ARM_REG_S2 = 81;
UC_ARM_REG_S3 = 82;
UC_ARM_REG_S4 = 83;
UC_ARM_REG_S5 = 84;
UC_ARM_REG_S6 = 85;
UC_ARM_REG_S7 = 86;
UC_ARM_REG_S8 = 87;
UC_ARM_REG_S9 = 88;
UC_ARM_REG_S10 = 89;
UC_ARM_REG_S11 = 90;
UC_ARM_REG_S12 = 91;
UC_ARM_REG_S13 = 92;
UC_ARM_REG_S14 = 93;
UC_ARM_REG_S15 = 94;
UC_ARM_REG_S16 = 95;
UC_ARM_REG_S17 = 96;
UC_ARM_REG_S18 = 97;
UC_ARM_REG_S19 = 98;
UC_ARM_REG_S20 = 99;
UC_ARM_REG_S21 = 100;
UC_ARM_REG_S22 = 101;
UC_ARM_REG_S23 = 102;
UC_ARM_REG_S24 = 103;
UC_ARM_REG_S25 = 104;
UC_ARM_REG_S26 = 105;
UC_ARM_REG_S27 = 106;
UC_ARM_REG_S28 = 107;
UC_ARM_REG_S29 = 108;
UC_ARM_REG_S30 = 109;
UC_ARM_REG_S31 = 110;
UC_ARM_REG_C1_C0_2 = 111;
UC_ARM_REG_C13_C0_2 = 112;
UC_ARM_REG_C13_C0_3 = 113;
UC_ARM_REG_ENDING = 114;
// alias registers
UC_ARM_REG_R13 = 12;
UC_ARM_REG_R14 = 10;
UC_ARM_REG_R15 = 11;
UC_ARM_REG_SB = 75;
UC_ARM_REG_SL = 76;
UC_ARM_REG_FP = 77;
UC_ARM_REG_IP = 78;
implementation
end.

View File

@ -0,0 +1,32 @@
// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
unit M68kConst;
interface
const
// M68K registers
UC_M68K_REG_INVALID = 0;
UC_M68K_REG_A0 = 1;
UC_M68K_REG_A1 = 2;
UC_M68K_REG_A2 = 3;
UC_M68K_REG_A3 = 4;
UC_M68K_REG_A4 = 5;
UC_M68K_REG_A5 = 6;
UC_M68K_REG_A6 = 7;
UC_M68K_REG_A7 = 8;
UC_M68K_REG_D0 = 9;
UC_M68K_REG_D1 = 10;
UC_M68K_REG_D2 = 11;
UC_M68K_REG_D3 = 12;
UC_M68K_REG_D4 = 13;
UC_M68K_REG_D5 = 14;
UC_M68K_REG_D6 = 15;
UC_M68K_REG_D7 = 16;
UC_M68K_REG_SR = 17;
UC_M68K_REG_PC = 18;
UC_M68K_REG_ENDING = 19;
implementation
end.

View File

@ -0,0 +1,203 @@
// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
unit MipsConst;
interface
const
// MIPS registers
UC_MIPS_REG_INVALID = 0;
// General purpose registers
UC_MIPS_REG_PC = 1;
UC_MIPS_REG_0 = 2;
UC_MIPS_REG_1 = 3;
UC_MIPS_REG_2 = 4;
UC_MIPS_REG_3 = 5;
UC_MIPS_REG_4 = 6;
UC_MIPS_REG_5 = 7;
UC_MIPS_REG_6 = 8;
UC_MIPS_REG_7 = 9;
UC_MIPS_REG_8 = 10;
UC_MIPS_REG_9 = 11;
UC_MIPS_REG_10 = 12;
UC_MIPS_REG_11 = 13;
UC_MIPS_REG_12 = 14;
UC_MIPS_REG_13 = 15;
UC_MIPS_REG_14 = 16;
UC_MIPS_REG_15 = 17;
UC_MIPS_REG_16 = 18;
UC_MIPS_REG_17 = 19;
UC_MIPS_REG_18 = 20;
UC_MIPS_REG_19 = 21;
UC_MIPS_REG_20 = 22;
UC_MIPS_REG_21 = 23;
UC_MIPS_REG_22 = 24;
UC_MIPS_REG_23 = 25;
UC_MIPS_REG_24 = 26;
UC_MIPS_REG_25 = 27;
UC_MIPS_REG_26 = 28;
UC_MIPS_REG_27 = 29;
UC_MIPS_REG_28 = 30;
UC_MIPS_REG_29 = 31;
UC_MIPS_REG_30 = 32;
UC_MIPS_REG_31 = 33;
// DSP registers
UC_MIPS_REG_DSPCCOND = 34;
UC_MIPS_REG_DSPCARRY = 35;
UC_MIPS_REG_DSPEFI = 36;
UC_MIPS_REG_DSPOUTFLAG = 37;
UC_MIPS_REG_DSPOUTFLAG16_19 = 38;
UC_MIPS_REG_DSPOUTFLAG20 = 39;
UC_MIPS_REG_DSPOUTFLAG21 = 40;
UC_MIPS_REG_DSPOUTFLAG22 = 41;
UC_MIPS_REG_DSPOUTFLAG23 = 42;
UC_MIPS_REG_DSPPOS = 43;
UC_MIPS_REG_DSPSCOUNT = 44;
// ACC registers
UC_MIPS_REG_AC0 = 45;
UC_MIPS_REG_AC1 = 46;
UC_MIPS_REG_AC2 = 47;
UC_MIPS_REG_AC3 = 48;
// COP registers
UC_MIPS_REG_CC0 = 49;
UC_MIPS_REG_CC1 = 50;
UC_MIPS_REG_CC2 = 51;
UC_MIPS_REG_CC3 = 52;
UC_MIPS_REG_CC4 = 53;
UC_MIPS_REG_CC5 = 54;
UC_MIPS_REG_CC6 = 55;
UC_MIPS_REG_CC7 = 56;
// FPU registers
UC_MIPS_REG_F0 = 57;
UC_MIPS_REG_F1 = 58;
UC_MIPS_REG_F2 = 59;
UC_MIPS_REG_F3 = 60;
UC_MIPS_REG_F4 = 61;
UC_MIPS_REG_F5 = 62;
UC_MIPS_REG_F6 = 63;
UC_MIPS_REG_F7 = 64;
UC_MIPS_REG_F8 = 65;
UC_MIPS_REG_F9 = 66;
UC_MIPS_REG_F10 = 67;
UC_MIPS_REG_F11 = 68;
UC_MIPS_REG_F12 = 69;
UC_MIPS_REG_F13 = 70;
UC_MIPS_REG_F14 = 71;
UC_MIPS_REG_F15 = 72;
UC_MIPS_REG_F16 = 73;
UC_MIPS_REG_F17 = 74;
UC_MIPS_REG_F18 = 75;
UC_MIPS_REG_F19 = 76;
UC_MIPS_REG_F20 = 77;
UC_MIPS_REG_F21 = 78;
UC_MIPS_REG_F22 = 79;
UC_MIPS_REG_F23 = 80;
UC_MIPS_REG_F24 = 81;
UC_MIPS_REG_F25 = 82;
UC_MIPS_REG_F26 = 83;
UC_MIPS_REG_F27 = 84;
UC_MIPS_REG_F28 = 85;
UC_MIPS_REG_F29 = 86;
UC_MIPS_REG_F30 = 87;
UC_MIPS_REG_F31 = 88;
UC_MIPS_REG_FCC0 = 89;
UC_MIPS_REG_FCC1 = 90;
UC_MIPS_REG_FCC2 = 91;
UC_MIPS_REG_FCC3 = 92;
UC_MIPS_REG_FCC4 = 93;
UC_MIPS_REG_FCC5 = 94;
UC_MIPS_REG_FCC6 = 95;
UC_MIPS_REG_FCC7 = 96;
// AFPR128
UC_MIPS_REG_W0 = 97;
UC_MIPS_REG_W1 = 98;
UC_MIPS_REG_W2 = 99;
UC_MIPS_REG_W3 = 100;
UC_MIPS_REG_W4 = 101;
UC_MIPS_REG_W5 = 102;
UC_MIPS_REG_W6 = 103;
UC_MIPS_REG_W7 = 104;
UC_MIPS_REG_W8 = 105;
UC_MIPS_REG_W9 = 106;
UC_MIPS_REG_W10 = 107;
UC_MIPS_REG_W11 = 108;
UC_MIPS_REG_W12 = 109;
UC_MIPS_REG_W13 = 110;
UC_MIPS_REG_W14 = 111;
UC_MIPS_REG_W15 = 112;
UC_MIPS_REG_W16 = 113;
UC_MIPS_REG_W17 = 114;
UC_MIPS_REG_W18 = 115;
UC_MIPS_REG_W19 = 116;
UC_MIPS_REG_W20 = 117;
UC_MIPS_REG_W21 = 118;
UC_MIPS_REG_W22 = 119;
UC_MIPS_REG_W23 = 120;
UC_MIPS_REG_W24 = 121;
UC_MIPS_REG_W25 = 122;
UC_MIPS_REG_W26 = 123;
UC_MIPS_REG_W27 = 124;
UC_MIPS_REG_W28 = 125;
UC_MIPS_REG_W29 = 126;
UC_MIPS_REG_W30 = 127;
UC_MIPS_REG_W31 = 128;
UC_MIPS_REG_HI = 129;
UC_MIPS_REG_LO = 130;
UC_MIPS_REG_P0 = 131;
UC_MIPS_REG_P1 = 132;
UC_MIPS_REG_P2 = 133;
UC_MIPS_REG_MPL0 = 134;
UC_MIPS_REG_MPL1 = 135;
UC_MIPS_REG_MPL2 = 136;
UC_MIPS_REG_ENDING = 137;
UC_MIPS_REG_ZERO = 2;
UC_MIPS_REG_AT = 3;
UC_MIPS_REG_V0 = 4;
UC_MIPS_REG_V1 = 5;
UC_MIPS_REG_A0 = 6;
UC_MIPS_REG_A1 = 7;
UC_MIPS_REG_A2 = 8;
UC_MIPS_REG_A3 = 9;
UC_MIPS_REG_T0 = 10;
UC_MIPS_REG_T1 = 11;
UC_MIPS_REG_T2 = 12;
UC_MIPS_REG_T3 = 13;
UC_MIPS_REG_T4 = 14;
UC_MIPS_REG_T5 = 15;
UC_MIPS_REG_T6 = 16;
UC_MIPS_REG_T7 = 17;
UC_MIPS_REG_S0 = 18;
UC_MIPS_REG_S1 = 19;
UC_MIPS_REG_S2 = 20;
UC_MIPS_REG_S3 = 21;
UC_MIPS_REG_S4 = 22;
UC_MIPS_REG_S5 = 23;
UC_MIPS_REG_S6 = 24;
UC_MIPS_REG_S7 = 25;
UC_MIPS_REG_T8 = 26;
UC_MIPS_REG_T9 = 27;
UC_MIPS_REG_K0 = 28;
UC_MIPS_REG_K1 = 29;
UC_MIPS_REG_GP = 30;
UC_MIPS_REG_SP = 31;
UC_MIPS_REG_FP = 32;
UC_MIPS_REG_S8 = 32;
UC_MIPS_REG_RA = 33;
UC_MIPS_REG_HI0 = 45;
UC_MIPS_REG_HI1 = 46;
UC_MIPS_REG_HI2 = 47;
UC_MIPS_REG_HI3 = 48;
UC_MIPS_REG_LO0 = 45;
UC_MIPS_REG_LO1 = 46;
UC_MIPS_REG_LO2 = 47;
UC_MIPS_REG_LO3 = 48;
implementation
end.

View File

@ -0,0 +1,104 @@
// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
unit SparcConst;
interface
const
// SPARC registers
UC_SPARC_REG_INVALID = 0;
UC_SPARC_REG_F0 = 1;
UC_SPARC_REG_F1 = 2;
UC_SPARC_REG_F2 = 3;
UC_SPARC_REG_F3 = 4;
UC_SPARC_REG_F4 = 5;
UC_SPARC_REG_F5 = 6;
UC_SPARC_REG_F6 = 7;
UC_SPARC_REG_F7 = 8;
UC_SPARC_REG_F8 = 9;
UC_SPARC_REG_F9 = 10;
UC_SPARC_REG_F10 = 11;
UC_SPARC_REG_F11 = 12;
UC_SPARC_REG_F12 = 13;
UC_SPARC_REG_F13 = 14;
UC_SPARC_REG_F14 = 15;
UC_SPARC_REG_F15 = 16;
UC_SPARC_REG_F16 = 17;
UC_SPARC_REG_F17 = 18;
UC_SPARC_REG_F18 = 19;
UC_SPARC_REG_F19 = 20;
UC_SPARC_REG_F20 = 21;
UC_SPARC_REG_F21 = 22;
UC_SPARC_REG_F22 = 23;
UC_SPARC_REG_F23 = 24;
UC_SPARC_REG_F24 = 25;
UC_SPARC_REG_F25 = 26;
UC_SPARC_REG_F26 = 27;
UC_SPARC_REG_F27 = 28;
UC_SPARC_REG_F28 = 29;
UC_SPARC_REG_F29 = 30;
UC_SPARC_REG_F30 = 31;
UC_SPARC_REG_F31 = 32;
UC_SPARC_REG_F32 = 33;
UC_SPARC_REG_F34 = 34;
UC_SPARC_REG_F36 = 35;
UC_SPARC_REG_F38 = 36;
UC_SPARC_REG_F40 = 37;
UC_SPARC_REG_F42 = 38;
UC_SPARC_REG_F44 = 39;
UC_SPARC_REG_F46 = 40;
UC_SPARC_REG_F48 = 41;
UC_SPARC_REG_F50 = 42;
UC_SPARC_REG_F52 = 43;
UC_SPARC_REG_F54 = 44;
UC_SPARC_REG_F56 = 45;
UC_SPARC_REG_F58 = 46;
UC_SPARC_REG_F60 = 47;
UC_SPARC_REG_F62 = 48;
UC_SPARC_REG_FCC0 = 49;
UC_SPARC_REG_FCC1 = 50;
UC_SPARC_REG_FCC2 = 51;
UC_SPARC_REG_FCC3 = 52;
UC_SPARC_REG_G0 = 53;
UC_SPARC_REG_G1 = 54;
UC_SPARC_REG_G2 = 55;
UC_SPARC_REG_G3 = 56;
UC_SPARC_REG_G4 = 57;
UC_SPARC_REG_G5 = 58;
UC_SPARC_REG_G6 = 59;
UC_SPARC_REG_G7 = 60;
UC_SPARC_REG_I0 = 61;
UC_SPARC_REG_I1 = 62;
UC_SPARC_REG_I2 = 63;
UC_SPARC_REG_I3 = 64;
UC_SPARC_REG_I4 = 65;
UC_SPARC_REG_I5 = 66;
UC_SPARC_REG_FP = 67;
UC_SPARC_REG_I7 = 68;
UC_SPARC_REG_ICC = 69;
UC_SPARC_REG_L0 = 70;
UC_SPARC_REG_L1 = 71;
UC_SPARC_REG_L2 = 72;
UC_SPARC_REG_L3 = 73;
UC_SPARC_REG_L4 = 74;
UC_SPARC_REG_L5 = 75;
UC_SPARC_REG_L6 = 76;
UC_SPARC_REG_L7 = 77;
UC_SPARC_REG_O0 = 78;
UC_SPARC_REG_O1 = 79;
UC_SPARC_REG_O2 = 80;
UC_SPARC_REG_O3 = 81;
UC_SPARC_REG_O4 = 82;
UC_SPARC_REG_O5 = 83;
UC_SPARC_REG_SP = 84;
UC_SPARC_REG_O7 = 85;
UC_SPARC_REG_Y = 86;
UC_SPARC_REG_XCC = 87;
UC_SPARC_REG_PC = 88;
UC_SPARC_REG_ENDING = 89;
UC_SPARC_REG_O6 = 84;
UC_SPARC_REG_I6 = 67;
implementation
end.

View File

@ -0,0 +1,111 @@
// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
unit UnicornConst;
interface
const UC_API_MAJOR = 1;
UC_API_MINOR = 0;
UC_VERSION_MAJOR = 1;
UC_VERSION_MINOR = 0;
UC_VERSION_EXTRA = 2;
UC_SECOND_SCALE = 1000000;
UC_MILISECOND_SCALE = 1000;
UC_ARCH_ARM = 1;
UC_ARCH_ARM64 = 2;
UC_ARCH_MIPS = 3;
UC_ARCH_X86 = 4;
UC_ARCH_PPC = 5;
UC_ARCH_SPARC = 6;
UC_ARCH_M68K = 7;
UC_ARCH_MAX = 8;
UC_MODE_LITTLE_ENDIAN = 0;
UC_MODE_BIG_ENDIAN = 1073741824;
UC_MODE_ARM = 0;
UC_MODE_THUMB = 16;
UC_MODE_MCLASS = 32;
UC_MODE_V8 = 64;
UC_MODE_MICRO = 16;
UC_MODE_MIPS3 = 32;
UC_MODE_MIPS32R6 = 64;
UC_MODE_MIPS32 = 4;
UC_MODE_MIPS64 = 8;
UC_MODE_16 = 2;
UC_MODE_32 = 4;
UC_MODE_64 = 8;
UC_MODE_PPC32 = 4;
UC_MODE_PPC64 = 8;
UC_MODE_QPX = 16;
UC_MODE_SPARC32 = 4;
UC_MODE_SPARC64 = 8;
UC_MODE_V9 = 16;
UC_ERR_OK = 0;
UC_ERR_NOMEM = 1;
UC_ERR_ARCH = 2;
UC_ERR_HANDLE = 3;
UC_ERR_MODE = 4;
UC_ERR_VERSION = 5;
UC_ERR_READ_UNMAPPED = 6;
UC_ERR_WRITE_UNMAPPED = 7;
UC_ERR_FETCH_UNMAPPED = 8;
UC_ERR_HOOK = 9;
UC_ERR_INSN_INVALID = 10;
UC_ERR_MAP = 11;
UC_ERR_WRITE_PROT = 12;
UC_ERR_READ_PROT = 13;
UC_ERR_FETCH_PROT = 14;
UC_ERR_ARG = 15;
UC_ERR_READ_UNALIGNED = 16;
UC_ERR_WRITE_UNALIGNED = 17;
UC_ERR_FETCH_UNALIGNED = 18;
UC_ERR_HOOK_EXIST = 19;
UC_ERR_RESOURCE = 20;
UC_ERR_EXCEPTION = 21;
UC_MEM_READ = 16;
UC_MEM_WRITE = 17;
UC_MEM_FETCH = 18;
UC_MEM_READ_UNMAPPED = 19;
UC_MEM_WRITE_UNMAPPED = 20;
UC_MEM_FETCH_UNMAPPED = 21;
UC_MEM_WRITE_PROT = 22;
UC_MEM_READ_PROT = 23;
UC_MEM_FETCH_PROT = 24;
UC_MEM_READ_AFTER = 25;
UC_HOOK_INTR = 1;
UC_HOOK_INSN = 2;
UC_HOOK_CODE = 4;
UC_HOOK_BLOCK = 8;
UC_HOOK_MEM_READ_UNMAPPED = 16;
UC_HOOK_MEM_WRITE_UNMAPPED = 32;
UC_HOOK_MEM_FETCH_UNMAPPED = 64;
UC_HOOK_MEM_READ_PROT = 128;
UC_HOOK_MEM_WRITE_PROT = 256;
UC_HOOK_MEM_FETCH_PROT = 512;
UC_HOOK_MEM_READ = 1024;
UC_HOOK_MEM_WRITE = 2048;
UC_HOOK_MEM_FETCH = 4096;
UC_HOOK_MEM_READ_AFTER = 8192;
UC_HOOK_MEM_UNMAPPED = 112;
UC_HOOK_MEM_PROT = 896;
UC_HOOK_MEM_READ_INVALID = 144;
UC_HOOK_MEM_WRITE_INVALID = 288;
UC_HOOK_MEM_FETCH_INVALID = 576;
UC_HOOK_MEM_INVALID = 1008;
UC_HOOK_MEM_VALID = 7168;
UC_QUERY_MODE = 1;
UC_QUERY_PAGE_SIZE = 2;
UC_QUERY_ARCH = 3;
UC_PROT_NONE = 0;
UC_PROT_READ = 1;
UC_PROT_WRITE = 2;
UC_PROT_EXEC = 4;
UC_PROT_ALL = 7;
implementation
end.

View File

@ -0,0 +1,673 @@
{
FreePascal/Delphi bindings for the UnicornEngine Emulator Engine \
Tested On Mac - Win - Linux >> with FreePascal v3.0.4 & Delphi Berlin 10.2 .
Copyright(c) 2018 Coldzer0 <Coldzer0 [at] protonmail.ch> .
License: GPLv2 .
}
unit Unicorn_dyn;
{$IFDEF FPC}
{$MODE Delphi}
{$PackRecords C}
{$ENDIF}
interface
uses
{$IFDEF FPC}dynlibs,Crt{$ELSE}
{$ifdef mswindows}
windows,sysutils
{$ENDIF}
{$ENDIF};
const
{$IFDEF Darwin}
UNICORN_LIB = './libunicorn.dylib';
{$ENDIF}
{$ifdef Linux}
UNICORN_LIB = './libunicorn.so';
{$endif}
{$ifdef mswindows}
UNICORN_LIB = './unicorn.dll';
{$endif}
type
uc_engine = Pointer;
uc_context = Pointer; // Opaque storage for CPU context, used with uc_context_*()
uc_hook = UIntPtr;
uc_arch = Cardinal;
uc_mode = Cardinal;
uc_err = Cardinal;
uc_query_type = Cardinal;
{$IFNDEF FPC} // Delphi Support .
PUInt32 = ^UInt32;
{$ENDIF}
type
{
Callback functions
Callback function for tracing code (UC_HOOK_CODE & UC_HOOK_BLOCK)
@address: address where the code is being executed
@size: size of machine instruction(s) being executed, or 0 when size is unknown
@user_data: user data passed to tracing APIs.
}
uc_cb_hookcode_t = procedure(uc : uc_engine; address : UInt64; size : UInt32; user_data : Pointer); cdecl;
{
Callback function for tracing interrupts (for uc_hook_intr())
@intno: interrupt number
@user_data: user data passed to tracing APIs.
}
uc_cb_hookintr_t = procedure(uc : uc_engine; intno : UInt32; user_data : Pointer); cdecl;
{
Callback function for tracing IN instruction of X86
@port: port number
@size: data size (1/2/4) to be read from this port
@user_data: user data passed to tracing APIs.
}
uc_cb_insn_in_t = function(uc : uc_engine; port : UInt32; siz : integer; user_data : Pointer) : UInt32; cdecl;
{
Callback function for OUT instruction of X86 .
@port: port number
@size: data size (1/2/4) to be written to this port
@value: data value to be written to this port
}
uc_cb_insn_out_t = procedure(uc : uc_engine; port : UInt32; size : integer; value : UInt32; user_data : Pointer); cdecl;
// All type of memory accesses for UC_HOOK_MEM_*
uc_mem_type = integer;
// All type of hooks for uc_hook_add() API.
uc_hook_type = integer;
{
Callback function for hooking memory (UC_MEM_READ, UC_MEM_WRITE & UC_MEM_FETCH)
@type: this memory is being READ, or WRITE
@address: address where the code is being executed
@size: size of data being read or written
@value: value of data being written to memory, or irrelevant if type = READ.
@user_data: user data passed to tracing APIs
}
uc_cb_hookmem_t = procedure(uc : uc_engine; _type : uc_mem_type; address : UInt64; size : integer; value : Int64; user_data : Pointer); cdecl;
{
Callback function for handling invalid memory access events (UNMAPPED and
PROT events)
@type: this memory is being READ, or WRITE
@address: address where the code is being executed
@size: size of data being read or written
@value: value of data being written to memory, or irrelevant if type = READ.
@user_data: user data passed to tracing APIs
@return: return true to continue, or false to stop program (due to invalid memory).
NOTE: returning true to continue execution will only work if if the accessed
memory is made accessible with the correct permissions during the hook.
In the event of a UC_MEM_READ_UNMAPPED or UC_MEM_WRITE_UNMAPPED callback,
the memory should be uc_mem_map()-ed with the correct permissions, and the
instruction will then read or write to the address as it was supposed to.
In the event of a UC_MEM_FETCH_UNMAPPED callback, the memory can be mapped
in as executable, in which case execution will resume from the fetched address.
The instruction pointer may be written to in order to change where execution resumes,
but the fetch must succeed if execution is to resume.
}
uc_cb_eventmem_t = function(uc : uc_engine; _type : uc_mem_type; address : UInt64; size : integer; value : Int64; user_data : Pointer) : LongBool; cdecl;
type
{
Memory region mapped by uc_mem_map() and uc_mem_map_ptr()
Retrieve the list of memory regions with uc_mem_regions()
}
uc_mem_region = record
rBegin : UInt64; // begin address of the region (inclusive)
rEnd : UInt64; // end address of the region (inclusive)
rPerms : UInt32; // memory permissions of the region
end;
uc_mem_regionArray = array[0..(MaxInt div SizeOf(uc_mem_region))-1] of uc_mem_region;
Puc_mem_regionArray = ^uc_mem_regionArray;
// Exports
var
(*
Return combined API version & major and minor version numbers.
@major: major number of API version
@minor: minor number of API version
@return hexical number as (major << 8 | minor), which encodes both
major & minor versions.
NOTE: This returned value can be compared with version number made
with macro UC_MAKE_VERSION .
For example, second API version would return 1 in @major, and 1 in @minor
The return value would be 0x0101
NOTE: if you only care about returned value, but not major and minor values,
set both @major & @minor arguments to NULL.
*)
uc_version : function (var major, minor : Cardinal) : Cardinal; cdecl;
(*
Determine if the given architecture is supported by this library.
@arch: architecture type (UC_ARCH_* )
@return True if this library supports the given arch.
*)
uc_arch_supported : function (arch : uc_arch) : LongBool; cdecl;
(*
Create new instance of unicorn engine.
@arch: architecture type (UC_ARCH_* )
@mode: hardware mode. This is combined of UC_MODE_*
@uc: pointer to uc_engine, which will be updated at return time
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_open : function (arch : uc_arch; mode : uc_mode; var uc : uc_engine) : uc_err; cdecl;
(*
Close UC instance: MUST do to release the handle when it is not used anymore.
NOTE: this must be called only when there is no longer usage of Unicorn.
The reason is the this API releases some cached memory, thus access to any
Unicorn API after uc_close() might crash your application.
After this, @uc is invalid, and nolonger usable.
@uc: pointer to a handle returned by uc_open()
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_close : function (uc : uc_engine) : uc_err; cdecl;
(*
Query internal status of engine.
@uc: handle returned by uc_open()
@type: query type. See uc_query_type
@result: save the internal status queried .
@return: error code of uc_err enum type (UC_ERR_*, see above)
*)
uc_query : function (uc : uc_engine; qtype : uc_query_type; result : PCardinal) : uc_err ; cdecl;
(*
Report the last error number when some API function fail.
Like glibc's errno, uc_errno might not retain its old value once accessed.
@uc: handle returned by uc_open()
@return: error code of uc_err enum type (UC_ERR_*, see above)
*)
uc_errno : function (uc : uc_engine) : uc_err; cdecl;
(*
Return a string describing given error code.
@code: error code (see UC_ERR_* )
@return: returns a pointer to a string that describes the error code
passed in the argument @code
*)
uc_strerror : function (code : uc_err) : PAnsiChar; cdecl;
(*
Write to register.
@uc: handle returned by uc_open()
@regid: register ID that is to be modified.
@value: pointer to the value that will set to register @regid .
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
for detailed error).
*)
uc_reg_write : function (uc : uc_engine; regid : Integer; const value : Pointer) : uc_err; cdecl;
(*
Read register value.
@uc: handle returned by uc_open()
@regid: register ID that is to be retrieved.
@value: pointer to a variable storing the register value.
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_reg_read: function (uc : uc_engine; regid : Integer; value : Pointer) : uc_err; cdecl ;
(*
Write multiple register values.
@uc: handle returned by uc_open()
@rges: array of register IDs to store
@value: pointer to array of register values
@count: length of both *regs and *vals
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_reg_write_batch : function(uc : uc_engine; regs : PIntegerArray; const values : Pointer; count : Integer) : uc_err; cdecl;
(*
Read multiple register values.
@uc: handle returned by uc_open()
@rges: array of register IDs to retrieve
@value: pointer to array of values to hold registers
@count: length of both *regs and *vals
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_reg_read_batch : function(uc : uc_engine; regs : PIntegerArray; var values : Pointer; count : integer) : uc_err; cdecl;
(*
Write to a range of bytes in memory.
@uc: handle returned by uc_open()
@address: starting memory address of bytes to set.
@bytes: pointer to a variable containing data to be written to memory.
@size: size of memory to write to.
NOTE: @bytes must be big enough to contain @size bytes.
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
for detailed error).
*)
uc_mem_write_ : function (uc : uc_engine; address : UInt64; const bytes : Pointer;
size : Cardinal) : uc_err; cdecl;
(*
Read a range of bytes in memory.
@uc: handle returned by uc_open()
@address: starting memory address of bytes to get.
@bytes: pointer to a variable containing data copied from memory.
@size: size of memory to read.
NOTE: @bytes must be big enough to contain @size bytes.
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_mem_read_ : function (uc : uc_engine; address : UInt64; bytes : Pointer;
size : Cardinal) : uc_err; cdecl;
(*
Emulate machine code in a specific duration of time.
@uc: handle returned by uc_open()
@begin: address where emulation starts
@until: address where emulation stops (i.e when this address is hit)
@timeout: duration to emulate the code (in microseconds). When this value is 0,
we will emulate the code in infinite time, until the code is finished.
@count: the number of instructions to be emulated. When this value is 0,
we will emulate all the code available, until the code is finished.
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_emu_start : function (uc : uc_engine; _begin, _until , timeout : UInt64;
count : Cardinal) : uc_err; cdecl;
(*
Stop emulation (which was started by uc_emu_start() API.
This is typically called from callback functions registered via tracing APIs.
NOTE: for now, this will stop the execution only after the current block.
@uc: handle returned by uc_open()
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_emu_stop : function (uc : uc_engine) : uc_err; cdecl;
(*
function (uc : uc_engine; var hh : uc_hook; _type : integer;
callback : Pointer; user_data : Pointer; _Begin, _End : UInt64; args : Array Of Const) : uc_err; cdecl;
Register callback for a hook event.
The callback will be run when the hook event is hit.
@uc: handle returned by uc_open()
@hh: hook handle returned from this registration. To be used in uc_hook_del() API
@type: hook type
@callback: callback to be run when instruction is hit
@user_data: user-defined data. This will be passed to callback function in its
last argument @user_data
@begin: start address of the area where the callback is effect (inclusive)
@end: end address of the area where the callback is effect (inclusive)
NOTE 1: the callback is called only if related address is in range [@begin, @end]
NOTE 2: if @begin > @end, callback is called whenever this hook type is triggered
@...: variable arguments (depending on @type)
NOTE: if @type = UC_HOOK_INSN, this is the instruction ID (ex: UC_X86_INS_OUT)
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_hook_add : function (uc : uc_engine; var hh : uc_hook; _type : integer;
callback : Pointer; user_data : Pointer; _Begin, _End : UInt64; args : Array Of Const) : uc_err; cdecl;
//uc_hook_add_1 : function (uc : uc_engine; var hh : uc_hook; _type : integer;
// callback : Pointer; user_data : Pointer; _Begin, _End : UInt64; arg1 : integer) : uc_err; cdecl;
//
//uc_hook_add_2 : function (uc : uc_engine; var hh : uc_hook; _type : integer;
// callback : Pointer; user_data : Pointer; _Begin, _End : UInt64; arg1, arg2 : UInt64) : uc_err; cdecl;
//
(*
Unregister (remove) a hook callback.
This API removes the hook callback registered by uc_hook_add().
NOTE: this should be called only when you no longer want to trace.
After this, @hh is invalid, and nolonger usable.
@uc: handle returned by uc_open()
@hh: handle returned by uc_hook_add()
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
for detailed error).
*)
uc_hook_del : function (uc : uc_engine; hh : uc_hook) : uc_err; cdecl ;
(*
Map memory in for emulation.
This API adds a memory region that can be used by emulation.
@uc: handle returned by uc_open()
@address: starting address of the new memory region to be mapped in.
This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
@size: size of the new memory region to be mapped in.
This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
@perms: Permissions for the newly mapped region.
This must be some combination of UC_PROT_READ | UC_PROT_WRITE | UC_PROT_EXEC,
or this will return with UC_ERR_ARG error.
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_mem_map : function (uc : uc_engine; address : UInt64; size : Cardinal; perms : UInt32) : uc_err; cdecl;
(*
Map existing host memory in for emulation.
This API adds a memory region that can be used by emulation.
@uc: handle returned by uc_open()
@address: starting address of the new memory region to be mapped in.
This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
@size: size of the new memory region to be mapped in.
This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
@perms: Permissions for the newly mapped region.
This must be some combination of UC_PROT_READ | UC_PROT_WRITE | UC_PROT_EXEC,
or this will return with UC_ERR_ARG error.
@ptr: pointer to host memory backing the newly mapped memory. This host memory is
expected to be an equal or larger size than provided, and be mapped with at
least PROT_READ | PROT_WRITE. If it is not, the resulting behavior is undefined.
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_mem_map_ptr : function(uc : uc_engine; address : UInt64; size : Cardinal; perms : UInt32; ptr : Pointer) : uc_err; cdecl;
(*
Unmap a region of emulation memory.
This API deletes a memory mapping from the emulation memory space.
@handle: handle returned by uc_open()
@address: starting address of the memory region to be unmapped.
This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
@size: size of the memory region to be modified.
This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
for detailed error).
*)
uc_mem_unmap : function (uc : uc_engine; address : UInt64; size : Cardinal) : uc_err; cdecl ;
(*
Set memory permissions for emulation memory.
This API changes permissions on an existing memory region.
@handle: handle returned by uc_open()
@address: starting address of the memory region to be modified.
This address must be aligned to 4KB, or this will return with UC_ERR_ARG error.
@size: size of the memory region to be modified.
This size must be multiple of 4KB, or this will return with UC_ERR_ARG error.
@perms: New permissions for the mapped region.
This must be some combination of UC_PROT_READ | UC_PROT_WRITE | UC_PROT_EXEC,
or this will return with UC_ERR_ARG error.
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
for detailed error).
*)
uc_mem_protect : function (uc : uc_engine; address : UInt64; size : Cardinal; perms : UInt32) : uc_err; cdecl ;
(*
Retrieve all memory regions mapped by uc_mem_map() and uc_mem_map_ptr()
This API allocates memory for @regions, and user must free this memory later
by free() to avoid leaking memory.
NOTE: memory regions may be splitted by uc_mem_unmap()
@uc: handle returned by uc_open()
@regions: pointer to an array of uc_mem_region struct. >> Check "Puc_mem_regionArray"
This is allocated by Unicorn, and must be freed by user later.
@count: pointer to number of struct uc_mem_region contained in @regions
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_mem_regions : function(uc : uc_engine; var regions : Puc_mem_regionArray; count : PUInt32) : uc_err; cdecl ;
(*
Allocate a region that can be used with uc_context_{save,restore} to perform
quick save/rollback of the CPU context, which includes registers and some
internal metadata. Contexts may not be shared across engine instances with
differing arches or modes.
@uc: handle returned by uc_open()
@context: pointer to a uc_engine*. This will be updated with the pointer to
the new context on successful return of this function.
Later, this allocated memory must be freed with uc_free().
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*)
uc_context_alloc : function ( uc : uc_engine; var context : uc_context) : uc_err; cdecl ;
(*
Free the memory allocated by uc_context_alloc & uc_mem_regions.
@mem: memory allocated by uc_context_alloc (returned in *context), or
by uc_mem_regions (returned in *regions)
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
for detailed error).
*)
uc_free : function (context : Pointer) : uc_err; cdecl ;
(*
Save a copy of the internal CPU context.
This API should be used to efficiently make or update a saved copy of the
internal CPU state.
@uc: handle returned by uc_open()
@context: handle returned by uc_context_alloc()
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
for detailed error).
*)
uc_context_save : function ( uc : uc_engine; context : uc_context) : uc_err; cdecl;
(*
Restore the current CPU context from a saved copy.
This API should be used to roll the CPU context back to a previous
state saved by uc_context_save().
@uc: handle returned by uc_open()
@context: handle returned by uc_context_alloc that has been used with uc_context_save
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
for detailed error).
*)
uc_context_restore : function(uc : uc_engine; context : uc_context) : uc_err; cdecl;
{============================= Global Functions ================================}
// function uc_hook_add(uc : uc_engine; var hh : uc_hook; _type : integer;
// callback : Pointer; user_data : Pointer; mBegin, mEnd : UInt64) : uc_err; overload;
//function uc_hook_add(uc : uc_engine; var hh : uc_hook; _type : integer;
// callback : Pointer; user_data : Pointer; mBegin, mEnd , arg1 : UInt64) : uc_err; overload;
//function uc_hook_add(uc : uc_engine; var hh : uc_hook; _type : integer;
// callback : Pointer; user_data : Pointer; mBegin, mEnd , arg1, arg2 : UInt64) : uc_err; overload;
//
function UC_MAKE_VERSION(major,minor : Cardinal): Cardinal;
implementation
function UC_MAKE_VERSION(major,minor : Cardinal): Cardinal;
begin
Result := ((major shl 8) + minor);
end;
var
UC_Handle : {$IFDEF FPC}dynlibs.{$ENDIF}HModule;
function dyn_loadfunc(name : {$IFDEF FPC}string{$ELSE}PChar{$ENDIF}) : Pointer;
begin
Result := {$IFDEF FPC}dynlibs.{$ENDIF}GetProcAddress(UC_Handle,name);
end;
function loadUC(): Boolean;
var
LastError : String;
begin
Result := false;
UC_Handle := {$IFDEF FPC}dynlibs.{$ENDIF}LoadLibrary(UNICORN_LIB);
if UC_Handle <> 0 then
begin
@uc_version := dyn_loadfunc('uc_version');
if (@uc_version = nil) then exit(false);
@uc_arch_supported := dyn_loadfunc('uc_arch_supported');
if (@uc_arch_supported = nil) then exit(false);
@uc_open := dyn_loadfunc('uc_open');
if (@uc_open = nil) then exit(false);
@uc_close := dyn_loadfunc('uc_close');
if (@uc_close = nil) then exit(false);
@uc_query := dyn_loadfunc('uc_query');
if (@uc_query = nil) then exit(false);
@uc_errno := dyn_loadfunc('uc_errno');
if (@uc_errno = nil) then exit(false);
@uc_strerror := dyn_loadfunc('uc_strerror');
if (@uc_strerror = nil) then exit(false);
@uc_reg_write := dyn_loadfunc('uc_reg_write');
if (@uc_reg_write = nil) then exit(false);
@uc_reg_read := dyn_loadfunc('uc_reg_read');
if (@uc_reg_read = nil) then exit(false);
@uc_reg_write_batch := dyn_loadfunc('uc_reg_write_batch');
if (@uc_reg_write_batch = nil) then exit(false);
@uc_reg_read_batch := dyn_loadfunc('uc_reg_read_batch');
if (@uc_reg_read_batch = nil) then exit(false);
@uc_mem_write_ := dyn_loadfunc('uc_mem_write');
if (@uc_mem_write_ = nil) then exit(false);
@uc_mem_read_ := dyn_loadfunc('uc_mem_read');
if (@uc_mem_read_ = nil) then exit(false);
@uc_emu_start := dyn_loadfunc('uc_emu_start');
if (@uc_emu_start = nil) then exit(false);
@uc_emu_stop := dyn_loadfunc('uc_emu_stop');
if (@uc_emu_stop = nil) then exit(false);
@uc_hook_add := dyn_loadfunc('uc_hook_add');
if (@uc_hook_add = nil) then exit(false);
@uc_hook_del := dyn_loadfunc('uc_hook_del');
if (@uc_hook_del = nil) then exit(false);
@uc_mem_map := dyn_loadfunc('uc_mem_map');
if (@uc_mem_map = nil) then exit(false);
@uc_mem_map_ptr := dyn_loadfunc('uc_mem_map_ptr');
if (@uc_mem_map_ptr = nil) then exit(false);
@uc_mem_unmap := dyn_loadfunc('uc_mem_unmap');
if (@uc_mem_unmap = nil) then exit(false);
@uc_mem_protect := dyn_loadfunc('uc_mem_protect');
if (@uc_mem_protect = nil) then exit(false);
@uc_mem_regions := dyn_loadfunc('uc_mem_regions');
if (@uc_mem_regions = nil) then exit(false);
@uc_context_alloc := dyn_loadfunc('uc_context_alloc');
if (@uc_context_alloc = nil) then exit(false);
@uc_context_save := dyn_loadfunc('uc_context_save');
if (@uc_context_save = nil) then exit(false);
@uc_context_restore := dyn_loadfunc('uc_context_restore');
if (@uc_context_restore = nil) then exit(false);
@uc_free := dyn_loadfunc('uc_free');
if (@uc_free = nil) then exit(false);
Result := true;
end
else
begin
{$IFDEF FPC}TextColor(LightRed);{$ENDIF}
LastError := {$IFDEF FPC}GetLoadErrorStr;{$ELSE}
{$ifdef mswindows}
SysErrorMessage(GetLastError,UC_Handle);
SetLastError(0);
{$ENDIF}
{$ENDIF}
WriteLn('error while loading unicorn library : ',LastError,#10);
{$IFDEF FPC}NormVideo;{$ENDIF}
end;
end;
procedure FreeUC();
begin
if UC_Handle <> 0 then
{$IFDEF FPC}dynlibs.{$ENDIF}FreeLibrary(UC_Handle);
end;
initialization
UC_Handle := 0;
if not loadUC then halt(0);
finalization
FreeUC();
end.

File diff suppressed because it is too large Load Diff