-
Notifications
You must be signed in to change notification settings - Fork 477
MinGW fix #162
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
Open
psychocrypt
wants to merge
1
commit into
fireice-uk:dev
Choose a base branch
from
psychocrypt:fix-MinGW
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
MinGW fix #162
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@psychocrypt Can you verify the correctness of this line by running it? HANDLE type on Windows maps to void* so it will build either way (value of h or address of h) but work only in one case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't verify it because I have no MinGW, I have only cleaned up this PR for the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get MinGW-GCC from: https://sourceforge.net/projects/mingw-w64/files/mingw-w64/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibroheem Nice you are still with us =). Can you point us in the way of any mingw docs showing
&h
is the correct choice here?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Declaration of SetThreadAffinityMask in the file
..\x86_64-w64-mingw32\include\winbase.h
2. HANDLE typedefs ..\x86_64-w64-mingw32\include\winnt.h (line 397 - 403)
HANDLE --> void*
6.2.0\x86_64-w64-mingw32\include\winnt.h
Therefore SetThreadAffinityMask is just a in MinGW:
Hence, nothing goes into hThread, except ptr variable or an address of a (lvalue) variable.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it seem there's a slight difference in the SetThreadAffinityMask provided by MSVC and MinGW.
A pointer is expected in the MinGW version of SetThreadAffinityMask for the param hThread. As shown in the src x86_64-w64-mingw32\include\winnt.h (line 397 - 403), HANDLE is a typedef of void*. Thus a:
is expected in SetThreadAffinityMask (HANDLE hThread, NOT a value.
That is why there's a #ifdef guard specifically for MinGW64.
The code only get compiled for MinGW64 platforms only.
The implementation that expects values can fall back to the #else code
In conclusion, the best way to know is to try it out yourself, then you'll have surity.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not quite correct on theory side this is valid code in C or C++ (in fact it is quite useful for writing shellcodes)
Or if you want to put it another way
void**
=void*
Do you mind if I put this one on hold until I can verify it myself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more point of confusion -
SetThreadAffinityMask
is not provided by the compiler, it is part of the Windows kernel, it is called the same way whether you are using MSVC/GCC/VB/FORTRAN etc.std::thread::native_handle_type
on the other hand is a C++ wrapper around HANDLE that can be specific to the particular C++ library.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant what I saw in the header file provided by MinGW64.
I knew that function is part of Windows Kernel or wherever they might put it, it's not compiler's.
But those headers were provided by MinGW.
I never used VS, so I don't know for sure if there's any difference.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bottom line: MinGW accepts &h and not h, as far as my tests goes.
You can hold, in fact you should hold this up until you're convinced, by testing... ofcourse!