-
-
Notifications
You must be signed in to change notification settings - Fork 437
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
How should I organize header files (.h) in order to compile and build DisassembleSimple.c in Visual Studio 2019 #421
Comments
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:
Library path will depend on your build method (msvc projects vs CMake). If you are using static library don't forget to define |
@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. |
Zydis is not a header-only library. You will need to link with |
@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. |
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 If you want kernel sample ( |
@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) 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. |
No, it's a sign of a linking issue. Zydis wraps its declarations with a conditional |
@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:
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. |
As I said, it's far from correct. Zydis already does |
@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.
|
In a proper setup |
@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! |
I'm trying to compile and build the example file called Disassemble.c its located from the following URL:
zydis/examples/DisassembleSimple.c
Lines 38 to 63 in 214536a
I'm using Visual Studio 2019 Community on Windows 8.1.
But I'm getting the following error:
Error (active) E0020 identifier "ZydisDisassembledInstruction" is undefined ConsoleApp1
I just need some documentation on how to install Zydis with all headers as I do know how to add the include directories to VS 2019.
The text was updated successfully, but these errors were encountered: