jeybee: devs-might be worth having a read through this
http://mamaich-eng.blogspot.com/
jeybee: specifically "No ARM code on Windows on ARM. Period.
Though MS called their new OS "Windows on ARM" (sometimes Windows on Snapdragon, Windows on Tegra and now Windows RT) - you can't see ARM code in it. Everything is THUMB2.
I don't know the reason of such a limitation - but that caused me several days of debugging while I was working on a DosBox dynamic core WinRT port last year. The dynamic code generated by DosBox is ARM, even the original THUMB generator was using small ARM thunks. Original DosBox works fine on ARM Linux, but on Windows RT it behaves differently. The generated code executes once, twice, but on the 100500 time - it crashes.
The reason was simple. If you read the ARM developer's manual, you'll see that OS should determine the previous mode (ARM or THUMB) on kernel mode entrance (via SWI, interrupt, ...). Seems that MS decided to simplify the handler's code - and assume that the user's code is always THUMB. And they always set the T bit on return to the user land.
So if you are running generated ARM code in your program - you may be forced to the THUMB mode any moment by an interrupt or a task switch."
Phorin: "this leaves one thing to be desired: executing ARM code. I already know how we can patch the kernel so that ARM code can execute without the CPU being switched back to Thumb2 all the time." (
https://forum.xda-developers.com/t/bypassing-patchguard.2488560/)
Phorin: "it's currently impossible to execute ARM code reliably on Windows RT is a major reason that Firefox hasn't been ported. Fixing that would require patching two context-switch routines in ntoskrnl.exe." (
https://forum.xda-developers.com/t/bypassing-patchguard.2488560/#post-46610744)
Phorin: And, narrowing it down specifically:
"Specifically, KeContextFromKframes in the Windows NT kernel (ntoskrnl.exe) is setting the T bit when freezing a thread's state for a task switch.
This annoyed us jailbreakers for RT/WinPhone, because we couldn't directly port Chrome's JITter without breaking Microsoft's PatchGuard."
I'm assuming that in Test Mode PatchGuard is irrelevant -- I'd be shocked if that wasn't the case. If it is irrelevant, then we have the solution: patch KeContextFromKframes in ntoskrnl.exe to return the mode it was requested to be called from user space.
Phorin: (
https://stackoverflow.com/a/33427234)
Phorin: Yes, one of those links above talks about it as well as this
https://github.com/Mattiwatti/EfiGuard
Phorin: But that link is for x64

Phorin: Disabling PatchGuard on ARM:
https://github.com/tandasat/meow haven't tried it yet though
Phorin: If Win10 truly does run ARM assembly (not THUMB2), that would be helpful to know. Then I could just reference the Win10's kernel for the context switching back to user space
Phorin: So then we just need to disable PatchGuard (seemingly trivial) and patch ntoskrnl.exe with the context-switching behavior from Win10's ntoskrnl.exe. Normally I'd say that would be trivial, but my understanding is that you can't physically patch the ntoskrnl.exe file itself but instead need some kind of loader to patch it in-memory... Something to which is not really in my wheelhouse of expertise.
Phorin: But sure as hell of a lot easier than trying to port all of that ARM assembly to THUMB
Phorin: Plus it would solve a whole host of issues pertaining to other apps
Phorin: I think the only reason someone didn't do this before is because the trust zone-level jailbreak wasn't out. All of this I've come up with isn't really my idea, but it sounds like no one went back to the beginning after the jailbreak came out