8000 InstCallback Priority by nsurbay · Pull Request #194 · QBDI/QBDI · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

InstCallback Priority #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,30 @@ Then, the following commands must be run::
Android
+++++++

Cross-compiling for Android requires the NDK to be installed on your workstation. For now, it has only been tested under Linux.
If not already installed, you can download the latest Android NDK package through the `official website <https://developer.android.com/ndk/downloads>`_.
Afterwards, the ``config-android-*.sh`` configuration script needs to be customised to match your NDK installation
directory and the target platform:

* ``NDK_PATH`` should point to your Android NDK
Cross-compiling for Android requires the NDK (or the SDK) to be installed on your workstation.
For now, it has only been tested under Linux.
If not already installed, you can download the latest Android NDK package
through the `official website <https://developer.android.com/ndk/downloads>`_
and extract it.
Afterwards, the ``config-android-*.sh`` configuration script needs to be
customised to match your NDK installation directory and the target platform.::

# Configure and compile QBDI X86_64 with a NDK
mkdir build && cd build
NDK_PATH=<your_NDK_PATH> ../cmake/config/config-android-X86_64.sh
ninja

At this point, you should be able to continue following the instructions of the Linux section since the procedure is the same.
# Configure and compile QBDI X86 with a SDK
mkdir build && cd build
ANDROID_SDK_ROOT=<your_SDK_PATH> ../cmake/config/config-android-X86.sh
ninja

PyQBDI compilation
++++++++++++++++++

The PyQDBI library (apart from the wheel package) can be built by solely passing the **'-DQBDI_TOOLS_PYQBDI=ON'** option to the CMake build system.

However, if you want to build the wheel package, you have to compile the LLVM libraries beforehand.
Once done, you can run these commands::
However, if you want to build the wheel package, you can run these commands::

python -m pip install --upgrade pip
python -m pip install setuptools wheel
Expand Down
343 changes: 205 additions & 138 deletions docs/qbdi_c.doxygen.in

Large diffs are not rendered by default.

344 changes: 205 additions & 139 deletions docs/qbdi_cpp.doxygen.in

Large diffs are not rendered by default.

333 changes: 198 additions & 135 deletions docs/qbdipreload.doxygen.in

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions docs/source/api_c.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ MemoryAccess
InstrRuleCallback
^^^^^^^^^^^^^^^^^

.. doxygenfunction:: qbdi_addInstrRule(InstrRuleCallback cbk, AnalysisType type, void* data)
.. doxygenfunction:: qbdi_addInstrRule
:project: QBDI_C

.. doxygenfunction:: qbdi_addInstrRuleRange(rword start, rword end, InstrRuleCallback cbk, AnalysisType type, void* data)
.. doxygenfunction:: qbdi_addInstrRuleRange
:project: QBDI_C

Removal
Expand Down Expand Up @@ -223,14 +223,14 @@ Register state

For X86 architecture:

.. include:: ../../include/QBDI/State.h
.. include:: ../../include/QBDI/arch/X86/State.h
:start-after: SPHINX_X86_GPRSTATE_BEGIN
:end-before: // SPHINX_X86_GPRSTATE_END
:code:

For X86_64 architecture:

.. include:: ../../include/QBDI/State.h
.. include:: ../../include/QBDI/arch/X86_64/State.h
:start-after: SPHINX_X86_64_GPRSTATE_BEGIN
:end-before: // SPHINX_X86_64_GPRSTATE_END
:code:
Expand All @@ -241,14 +241,14 @@ Register state

For X86 architecture:

.. include:: ../../include/QBDI/State.h
.. include:: ../../include/QBDI/arch/X86/State.h
:start-after: SPHINX_X86_FPRSTATE_BEGIN
:end-before: // SPHINX_X86_FPRSTATE_END
:code:

For X86_64 architecture:

.. include:: ../../include/QBDI/State.h
.. include:: ../../include/QBDI/arch/X86_64/State.h
:start-after: SPHINX_X86_64_FPRSTATE_BEGIN
:end-before: // SPHINX_X86_64_FPRSTATE_END
:code:
Expand Down Expand Up @@ -302,6 +302,9 @@ Callback
.. doxygenenum:: InstPosition
:project: QBDI_C

.. doxygenenum:: CallbackPriority
:project: QBDI_C

.. doxygenenum:: VMAction
:project: QBDI_C

Expand Down Expand Up @@ -430,9 +433,14 @@ Log
.. doxygenenum:: LogPriority
:project: QBDI_C

.. doxygenfunction:: qbdi_setLogOutput
.. doxygenfunction:: qbdi_setLogFile
:project: QBDI_C

.. doxygenfunction:: qbdi_addLogFilter
.. doxygenfunction:: qbdi_setLogConsole
:project: QBDI_C

.. doxygenfunction:: qbdi_setLogDefault
:project: QBDI_C

.. doxygenfunction:: qbdi_setLogPriority
:project: QBDI_C
18 changes: 12 additions & 6 deletions docs/source/api_cpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ Register state

For X86 architecture:

.. include:: ../../include/QBDI/State.h
.. include:: ../../include/QBDI/arch/X86/State.h
:start-after: SPHINX_X86_GPRSTATE_BEGIN
:end-before: // SPHINX_X86_GPRSTATE_END
:code:

For X86_64 architecture:

.. include:: ../../include/QBDI/State.h
.. include:: ../../include/QBDI/arch/X86_64/State.h
:start-after: SPHINX_X86_64_GPRSTATE_BEGIN
:end-before: // SPHINX_X86_64_GPRSTATE_END
:code:
Expand All @@ -190,14 +190,14 @@ Register state

For X86 architecture:

.. include:: ../../include/QBDI/State.h
.. include:: ../../include/QBDI/arch/X86/State.h
:start-after: SPHINX_X86_FPRSTATE_BEGIN
:end-before: // SPHINX_X86_FPRSTATE_END
:code:

For X86_64 architecture:

.. include:: ../../include/QBDI/State.h
.. include:: ../../include/QBDI/arch/X86_64/State.h
:start-after: SPHINX_X86_64_FPRSTATE_BEGIN
:end-before: // SPHINX_X86_64_FPRSTATE_END
:code:
Expand Down Expand Up @@ -243,6 +243,8 @@ Callback

.. doxygenenum:: QBDI::InstPosition

.. doxygenenum:: QBDI::CallbackPriority

.. doxygenenum:: QBDI::VMAction

.. _instanalysis-cpp:
Expand Down Expand Up @@ -340,9 +342,13 @@ Log

.. doxygenenum:: QBDI::LogPriority

.. doxygenfunction:: QBDI::setLogOutput
.. doxygenfunction:: QBDI::setLogFile

.. doxygenfunction:: QBDI::setLogPriority

.. doxygenfunction:: QBDI::setLogConsole

.. doxygenfunction:: QBDI::addLogFilter
.. doxygenfunction:: QBDI::setLogDefault

Range
+++++
Expand Down
5 changes: 5 additions & 0 deletions docs/source/api_js.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ Callback
.. js:autoattribute:: PREINST
.. js:autoattribute:: POSTINST

.. js:autoclass:: CallbackPriority

.. js:autoattribute:: PRIORITY_DEFAULT
.. js:autoattribute:: PRIORITY_MEMACCESS_LIMIT

.. _instanalysis-js:

InstAnalysis
Expand Down
4 changes: 3 additions & 1 deletion docs/source/api_pyqbdi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ Callback
10000
.. autodata:: pyqbdi.InstPosition

.. autodata:: pyqbdi.CallbackPriority

.. autodata:: pyqbdi.VMAction

.. _instanalysis-pyqbdi:
Expand Down Expand Up @@ -332,7 +334,7 @@ Log

.. autodata:: pyqbdi.LogPriority

.. autofunction:: pyqbdi.addLogFilter
.. autofunction:: pyqbdi.setLogPriority

Range
+++++
Expand Down
34 changes: 33 additions & 1 deletion docs/source/compilation.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
.. _developer-compilation:

Compilation From Source
=======================

.. include:: ../../README.rst
:start-after: .. compil
:end-before: .. compil-end

CMake Parameters
++++++++++++++++

The compilation of QBDI can be configured with the command line. Each parameter
should be placed on the command line with the form ``-D<param>=<value>``.

* ``QBDI_PLATFORM`` (mandatory) : Target platform of the compilation
(supported: ``windows``, ``linux``, ``android``, ``osx``)
* ``QBDI_ARCH`` (mandatory) : Target architecture of the compilation
(supported: ``X86_64``, ``X86``)
* ``QBDI_CCACHE`` (default ON) : enable compilation optimisation with ccache or sccache.
* ``QBDI_DISABLE_AVX`` (default OFF) : disable the support of AVX instruction
on X86 and X86_64
* ``QBDI_ASAN`` (default OFF) : compile with ASAN to detect memory leak in QBDI.
* ``QBDI_LOG_DEBUG`` (default OFF) : enable the debug level of the logging
system. Note that the support of this level has an impact on the performances,
even if this log level is not enabled.
* ``QBDI_STATIC_LIBRARY`` (default ON) : build the static library of QBDI. Note
than some subproject need ``QBDI_STATIC_LIBRARY`` (test, PyQBDI, ...)
* ``QBDI_SHARED_LIBRARY`` (default ON) : build the shared library of QBDI. Note
than some subproject need ``QBDI_SHARED_LIBRARY`` (Frida/QBDI, examples, ...)
* ``QBDI_TEST`` (default ON) : build the tests suite
* ``QBDI_BENCHMARK`` (default OFF) : build the benchmark tools
* ``QBDI_TOOLS_QBDIPRELOAD`` (default ON on supported platform) : build
QBDIPreload static library (supported on Linux and OSX).
* ``QBDI_TOOLS_VALIDATOR`` (default ON on supported platform) : build
the validator library (supported on Linux and OSX).
* ``QBDI_TOOLS_PYQBDI`` (default ON on X86_64) : build PyQBDI library.
Supported on Linux, Windows and OSX.
* ``QBDI_TOOLS_FRIDAQBDI`` (default ON) : add Frida/QBDI in the package.


3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ def extract_version(cmakefile):

if read_the_docs_build:
# Update documentation in doxygen config file (what is normally done by cmake)
sedcmd = "sed 's/${QBDI_VERSION_MAJOR}/%u/;s/${QBDI_VERSION_MINOR}/%u/;s/${QBDI_VERSION_PATCH}/%u/'" % (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
sedcmd = "sed 's/${QBDI_VERSION_MAJOR}/%u/;s/${QBDI_VERSION_MINOR}/%u/;s/${QBDI_VERSION_PATCH}/%u/;s/${CMAKE_CURRENT_BINARY_DIR}/./ '" % (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
# Call doxygen
subprocess.call("cd ../; %s qbdi_cpp.doxygen.in > qbdi_cpp.doxygen" % sedcmd, shell=True)
subprocess.call("cd ../; %s qbdi_c.doxygen.in > qbdi_c.doxygen" % sedcmd, shell=True)
subprocess.call("cd ../; %s qbdipreload.doxygen.in > qbdipreload.doxygen" % sedcmd, shell=True)
subprocess.call("cp ../../include/QBDI/arch/X86_64/* ../../include/QBDI/", shell=True)
subprocess.call('cd ../; doxygen qbdi_cpp.doxygen', shell=True)
subprocess.call('cd ../; doxygen qbdi_c.doxygen', shell=True)
subprocess.call('cd ../; doxygen qbdipreload.doxygen', shell=True)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Developer Documentation

.. toctree::
:maxdepth: 2

Compilation <compilation>
Repository Organization <repo_organization>
Testing <testing>
Expand Down
4 changes: 2 additions & 2 deletions docs/source/get_started-c.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ a callback for every instruction. The callback can be called before the instruct

.. code:: c

uint32_t cid = qbdi_addCodeCB(vm, QBDI_PREINST, showInstruction, NULL);
uint32_t cid = qbdi_addCodeCB(vm, QBDI_PREINST, showInstruction, NULL, 0);
assert(cid != QBDI_INVALID_EVENTID);

The function returns a callback ID or the special ID :cpp:enumerator:`QBDI_INVALID_EVENTID <VMError::QBDI_INVALID_EVENTID>` if
Expand All @@ -130,7 +130,7 @@ All QBDI callbacks allow users to pass a custom parameter ``data`` of type ``voi
}

unsigned iterationCount = 0;
qbdi_addMnemonicCB(vm, "CALL*", QBDI_PREINST, countIteration, &iterationCount);
qbdi_addMnemonicCB(vm, "CALL*", QBDI_PREINST, countIteration, &iterationCount, 0);


Set instrumented ranges
Expand Down
110 changes: 0 additions & 110 deletions docs/source/logs.rst

This file was deleted.

Loading
0