Comments (12)
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.
@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.
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.
@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.
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.
@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.
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.
@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.
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.
@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.
In a proper setup #include <Zydis/Zydis.h>
is all that is required.
from zydis.
@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)
- Compile error in VS2019 HOT 2
- [HELP] OperandDefinitions.inc Need a C89 style define file. HOT 2
- Movabs not supported with ZydisDisassembleIntel HOT 4
- ATT: Missing parenthesis for absolute memory operands HOT 8
- Is there a separate function for Length disassembly in zydis? HOT 11
- Question about ZydisEncoderDecodedInstructionToEncoderRequest's operand_count parameter HOT 3
- Encoder generates wrong relative offset with bnd prefix
- Missing enum definitions in Documentation HOT 1
- Incorrect operand size with mov instruction HOT 3
- How to get operand address as a ZyanU64? HOT 5
- Encoder mishandles 16-bit address truncation behavior HOT 2
- Build failed: build zydis as a dynamic link library on MacOS HOT 4
- Encoder fails to enforce predicted instruction size in some scenarios
- Incorrect disassembly of push rdi HOT 2
- ZydisDecodedInstruction has ZYDIS_ATTRIB_IS_RELATIVE attribute when decoding absolute JMP HOT 3
- ZydisWinKernel.c 0xC0000428 HOT 3
- Zydis.dll dependent on kernel32 HOT 8
- Add [in,out] hints to Doxygen parameter strings HOT 7
- undocumented/unintended ZYDIS_FORMATTER_FUNC_POST_OPERAND behavior HOT 6
- Amalgamated build should auto-define `ZYDIS_STATIC_BUILD` HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zydis.