File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,10 +68,25 @@ static void more_core(void)
6868
6969 /* allocate a memory block */
7070#ifdef MS_WIN32
71+ #ifdef MS_WINDOWS_DESKTOP
7172 item = (ITEM * )VirtualAlloc (NULL ,
7273 count * sizeof (ITEM ),
7374 MEM_COMMIT ,
7475 PAGE_EXECUTE_READWRITE );
76+ #else // UWP
77+ /* Due security restrictions, UWP not allows request Read-Write-Execute permissions at once.
78+ The correct flow in UWP for execute dynamic code in memmory is:
79+ 1. Alloate as Read-Write (PAGE_READWRITE) and write dynamic code to memmory.
80+ 2. Change to Executable (PAGE_EXECUTE_READ) with 'VirtualProtectFromApp'.
81+ 3. Flush cache with 'FlushInstructionCache' to ensure CPU instruction cache coherency
82+ before executing the generated code.
83+ TODO: Implement 2 and 3 in the appropriate places. For now, this defers
84+ the error from import time to time of use (or never, if an app avoids it). */
85+ item = (ITEM * )VirtualAllocFromApp (NULL ,
86+ count * sizeof (ITEM ),
87+ MEM_COMMIT | MEM_RESERVE ,
88+ PAGE_READWRITE );
89+ #endif // !MS_WINDOWS_DESKTOP
7590 if (item == NULL )
7691 return ;
7792#else
You can’t perform that action at this time.
0 commit comments