Repository navigation
gh-152433: Windows: fix ctypes error in UWP build
#154700
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,10 +68,24 @@ static void more_core(void) | |||||||||||||||||
|
|
||||||||||||||||||
| /* allocate a memory block */ | ||||||||||||||||||
| #ifdef MS_WIN32 | ||||||||||||||||||
| #ifdef MS_WINDOWS_DESKTOP | ||||||||||||||||||
| item = (ITEM *)VirtualAlloc(NULL, | ||||||||||||||||||
| count * sizeof(ITEM), | ||||||||||||||||||
| MEM_COMMIT, | ||||||||||||||||||
| PAGE_EXECUTE_READWRITE); | ||||||||||||||||||
| #else // UWP | ||||||||||||||||||
| /* Due security restrictions, UWP not allows request Read-Write-Execute permissions at once. | ||||||||||||||||||
| The correct flow in UWP for execute dynamic code in memmory is: | ||||||||||||||||||
| 1. Alloate as Read-Write (PAGE_READWRITE) and write dynamic code to memmory. | ||||||||||||||||||
| 2. Change to Executable (PAGE_EXECUTE_READ) with 'VirtualProtectFromApp'. | ||||||||||||||||||
| 3. Flush cache with 'FlushInstructionCache' to ensure CPU instruction cache coherency | ||||||||||||||||||
| before executing the generated code. | ||||||||||||||||||
| !@todo implement points 2. 3. in the appropriate places */ | ||||||||||||||||||
| item = (ITEM*)VirtualAllocFromApp(NULL, | ||||||||||||||||||
| count * sizeof(ITEM), | ||||||||||||||||||
| MEM_COMMIT | MEM_RESERVE, | ||||||||||||||||||
| PAGE_READWRITE); | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this works without
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More work is needed for The cpython/Modules/_ctypes/_ctypes.c Lines 6390 to 6397 in e5d4fa2
This causes errors immediately upon But executing code in memory remains necessary for full Let's say this PR only enables "limited" ctypes functionality on UWP but causes no harm on Windows Desktop.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we say that in a comment against this code, for next time one of us has to remember why we did it this way?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a code comment with more context and what remains to be implemented. |
||||||||||||||||||
| #endif // !MS_WINDOWS_DESKTOP | ||||||||||||||||||
| if (item == NULL) | ||||||||||||||||||
| return; | ||||||||||||||||||
| #else | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.