Giter Site home page Giter Site logo

Comments (12)

mappzor avatar mappzor commented on June 15, 2024

If you just want to compile examples it's best to use provided VS2022 projects or generate VS2019/VS2022 projects with CMake.

To use Zydis in your own projects, you will need to include Zydis and Zycore paths for headers:

zydis\dependencies\zycore\include
zydis\include

Library path will depend on your build method (msvc projects vs CMake). If you are using static library don't forget to define ZYDIS_STATIC_BUILD in Properties -> C/C++ -> Preprocessor ->Preprocessor Definitions.

from zydis.

Victor6799 avatar Victor6799 commented on June 15, 2024

@mappzor thanks. Just another question please. If I want to decode (dissemble) binary data (1-15) bytes at a time do I not need to statically link the zydis.lib and/or Zycore.lib with my project and include the header (*.h) for the exported functions that I'm referencing in my project ? Thanks again.

from zydis.

mappzor avatar mappzor commented on June 15, 2024

Zydis is not a header-only library. You will need to link with zydis.lib, doesn't matter if you want to achieve dynamic or static linking.

from zydis.

Victor6799 avatar Victor6799 commented on June 15, 2024

@mappzor can you tell me firstly how to properly download the repository for Zydis ? Should I use Git-Bash or just download the zip file from the website ? I would like to compile and build all examples. I've tried both using Git and downloading the zip file but when I try building the SLN for Zydis and ZyCore I get compile errors such as *.h and *.c project (both) files cannot be found. Second thing that I would like to do is to build the Zydis.lib so I can link it in with my kernel mode project. How can I accomplish this second request ? I'm using Visual Studio 2022 Community for building Zydis.sln.

from zydis.

mappzor avatar mappzor commented on June 15, 2024

DO NOT download the zip file because it doesn't contain Zycore (git submodules don't work well with Github's releases, nothing can be done about this). You need to perform recursive clone as suggested in readme git clone --recursive 'https://github.com/zyantific/zydis.git'. This will download Zycore into dependencies folder.

If you want kernel sample (ZydisWinKernel) you should use provided solution file from msvc folder. CMake won't do the job here. Keep in mind those project files are for VS2022 only.

from zydis.

Victor6799 avatar Victor6799 commented on June 15, 2024

@mappzor thank you again. Just wanted to share that I was able to compile the solution for Visual Studio 2022 successfully thank you. Also I was able to successfully link the Zydis.lib file in my kernel mode project without any problems except for one hitch. In the Defines.h file I had to make the following change in order for the linking to work successfully:

define ZYDIS_EXPORT ZYAN_DLLIMPORT (old)
define ZYDIS_EXPORT ZYAN_DLLIMPORT extern "C" (new)

The reason I believe this change was necessary was because my file (in my project where I was calling ZydisDisassembleIntel(...)) had the extension cpp and was likely being mangled by the compiler/linker. So I made the above change, Please let me know if this was a good decision.

from zydis.

mappzor avatar mappzor commented on June 15, 2024

Please let me know if this was a good decision.

No, it's a sign of a linking issue.

Zydis wraps its declarations with a conditional extern "C", so inclusion from C++ code is not an issue under normal circumstances. Also in the worst case you want to do something like this instead of manually modifying your dependencies.

from zydis.

Victor6799 avatar Victor6799 commented on June 15, 2024

@mappzor many thanks for being patient. I finally got my project to compile and link successfully. However I tried the recommended solution from the link you provided and still was getting the linking error. Here is what I did I declared the exported function in my .h file as follows:

ZYDIS_EXPORT extern "C" ZyanStatus ZydisDisassembleIntel(ZydisMachineMode machine_mode,
    ZyanU64 runtime_address, const void* buffer, ZyanUSize length,
    ZydisDisassembledInstruction* instruction);

Please keep in mind that without the extern "C" I still would get the linking error. I also tried defining the macro __cplusplus in my Project Properties but still would get same linking error. I'm not sure whether this is correct or not. Please feel free to comment. Thanks again.

from zydis.

mappzor avatar mappzor commented on June 15, 2024

As I said, it's far from correct. Zydis already does extern "C" when __cplusplus is defined. It's a linking issue on your end. Make sure you are using the correct Zydis build. You probably want static build, so make sure ZYDIS_STATIC_BUILD is correctly defined in your project and that Zydis is actually built as static.

from zydis.

Victor6799 avatar Victor6799 commented on June 15, 2024

@mappzor thank you. So this is where I'm at now. I declared the following function (see below) in my .h file and statically linked Zydis.lib file and the project now links successfully. Is this the correct way to do it ? I did not make any changes to any of the .h Zydis files.

ZyanStatus ZydisDisassembleIntel(ZydisMachineMode machine_mode, ZyanU64 runtime_address, const void* buffer, ZyanUSize length, ZydisDisassembledInstruction* instruction);

from zydis.

mappzor avatar mappzor commented on June 15, 2024

In a proper setup #include <Zydis/Zydis.h> is all that is required.

from zydis.

Victor6799 avatar Victor6799 commented on June 15, 2024

@mappzor thank you again. Its working exactly as you stated. All that was needed was the inclusion of the Zydis.h header file and the inclusion of the ZYDIS_STATIC_BUILD preprocessor definition and the linking of the Zydis.lib library. REALLY good job on this project. Job well done!

from zydis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.