Skip to content
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

Updating Zydis-Pascal to the latest Zydis version #2

Open
wants to merge 35 commits into
base: master
Choose a base branch
from

Conversation

Coldzer0
Copy link

This work is still in progress.

I'm converting the code based on the examples ^_^
So, all structs and APIs converted are the ones that are needed for the examples to work.

I'll update this based on examples till I convert all of them, and then I will add any other needed APIs.

Copy link
Member

@flobernd flobernd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your work! I've not been using Delphi/Pascal for a while and definitely would not have been able to design the updated bindings in such a nice and compatible way.

I left a few (rather minor) comments and suggestions 🙂

Comment on lines -11 to -17
#### Dynamic
- Extract the `Zydis32.dll` or `Zydis64.dll` from the `Bin32`/`Bin64` folder to the directory that contains your application or install the library to your `C:\Windows\System32\` (64-bit) / `C:\Windows\SysWOW64\` (32-bit) directory
- Enable the `{$DEFINE ZYDIS_DYNAMIC_LINK}` compiler-directive (enabled by default) in `Zydis.pas`

#### Static
- Extract the complete `Bin32`/`Bin64` folder to the root of the pascal bindings directory
- Disable the `{$DEFINE ZYDIS_DYNAMIC_LINK}` compiler-directive in `Zydis.pas`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a super huge fan of including binary files in a Git repository, but we can consider going that route, if we feel like this would lower the burden of using the bindings.

Anyways, I think that part of the readme should stay. At least the part about dynamic linking might be important to some users - regardless of whether we bundle the static binaries in the repo or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Delphi is still mainly used on Windows, but I'm not sure how the situation is for FPC. It easily gets compilcated when we have to bundle a set of X86(_64) and ARM(64) binaries for different OSs like Windows, Linux, FreeBSD, etc. This was the original reason for not including the binaries in the repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could create a GitHub Actions release workflow that uses GCC or Clang to cross-compile Zydis for different target architectures and operating systems in different formats (.a, .obj, .dll, ...).

Copy link
Author

@Coldzer0 Coldzer0 Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that dynamic linking is essential for many users.
For me, I only use Delphi for User Interface projects, but Pascal, I do use it for all platforms.

GitHub Actions release workflow would be great for auto-bundling Zydis binaries.

README.md Outdated Show resolved Hide resolved
Zydis/Zydis.Decoder.pas Outdated Show resolved Hide resolved
Zydis/Zydis.apis.pas Outdated Show resolved Hide resolved
@Coldzer0
Copy link
Author

Thanks a lot for your work! I've not been using Delphi/Pascal for a while and definitely would not have been able to design the updated bindings in such a nice and compatible way.

I left a few (rather minor) comments and suggestions 🙂

You are welcome ^_^, And thanks for your kind words.

Move all Formatter types to it's own unit to use it for high-level implementation
Move all Decoder types to it's own unit to use it for high-level implementation
Move all Disassembler types to it's own unit to use it for high-level implementation
Tested on Windows And Linux - x64
Tested on Windows And Linux - x64
Tested on Windows And Linux - x64
@Coldzer0
Copy link
Author

Coldzer0 commented Nov 1, 2023

@flobernd

I added EncodeFromScratch example and needed Types and APIs.
I tested all three examples on Windows & Linux - x64.

I moved all Types from Disassembler, Decoder, and Formatter Units to new Units;
5291745
49adc6f
447f253

this way, we can use them for high-level implementation.

@Coldzer0
Copy link
Author

Coldzer0 commented Nov 2, 2023

Now, all examples are Delphi compatible.
And compiles for Linux with FPC.

Copy link
Member

@flobernd flobernd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for all the work! This looks really good 🙂 Let me know when you feel like you are done for now. We can merge the PR and improve/complete it in some follow up PRs.

I’ll try to find some time to work on the GitHub Action to generate the binary files.

Zydis/Zydis.Disassembler.pas Outdated Show resolved Hide resolved
Zydis/Zydis.Enums.pas Show resolved Hide resolved
@Coldzer0
Copy link
Author

@flobernd

You can merge this pull request, and I'll open a new one for the other examples and updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants