News for hackers. Stuff that matters.
Re:Arm64EC – Run x86_64 and Arm code in the same process by jart on Sunday June 23, 2024 @11:29PM (#40772475)
Wow! This might actually make it possible for Actually Portable Executable to support running on Windows ARM. I'm already putting the ARM code inside all my binaries. There's just never been a way to encode that in the PE headers. But if my emulated WinMain() function for x86-64 could detect that it's being emulated and then simply ask a WIN32 API to jump to the ARM entrypoint instead, it'd be the perfect solution to my problems. I actually think I'm going to rush out and buy a Windows ARM computer right now.
Re:Arm64EC – Run x86_64 and Arm code in the same process by yjftsjthsd-h on Monday June 24, 2024 @12:13AM (#40772619)
And this kind of beautiful insanity is why you're one of my favorite developers of this era.

Also,

> I'm already putting the ARM code inside all my binaries.

Wait, I thought CPU architecture was the one limitation that did affect APE - you mean on unix-likes APE binaries are already compatible across amd64 and aarch64?

Edit: rereading https://justine.lol/cosmo3/ it does say that, doesn't it - and ARM64 listing "Windows (non-native)" just means that one platform uses (for the next few hours-days, at least...) emulation. That's amazing:)

Re:Arm64EC – Run x86_64 and Arm code in the same process by zorgmonkey on Monday June 24, 2024 @12:16AM (#40772629)
I'm pretty sure the API you'll want to detect that is IsWow64Process2.
Re:Arm64EC – Run x86_64 and Arm code in the same process by szundi on Monday June 24, 2024 @02:44AM (#40773110)
I love the 2s and Exes at the end of Windows API call names
Re:Arm64EC – Run x86_64 and Arm code in the same process by formerly_proven on Monday June 24, 2024 @03:15AM (#40773273)
wait/waitid/waitpid/wait3/wait4

dup/dup2/dup3

creat/open/openat/openat2

cough

Re:Arm64EC – Run x86_64 and Arm code in the same process by skissane on Monday June 24, 2024 @05:38AM (#40774035)
Even more: clone3, __clone2 (only exists on Itanium), fchmodat2, preadv2, pwritev2, pipe2, sync_file_range2, mmap2 (only certain architectures; for x86, only 32-bit), renameat2, mlock2, faccessat2, epoll_pwait2

My personal prediction is sooner or later we'll see execveat2, to permit setting /proc/PID/comm when using execveat [0].

I doubt we'll ever see clone4, because clone3 is passed a structure argument with the structure size, so new fields can be supported just by increasing the structure size. If other syscalls had done that from the start, much of the 2/3/etc would have been avoided. It is actually a very common practice on Windows (since NT), it has only much more recently been adopted in the Linux kernel

[0] see https://uapi-group.org/kernel-features/

Re:Arm64EC – Run x86_64 and Arm code in the same process by phaedrus on Monday June 24, 2024 @12:02PM (#40777702)
I work on a team that supports some equipment related to airplanes. An acronym for one piece of equipment that is decades old is "RCSU". When I got a support call talking about "RSCU", I assumed the person meant "RCSU".

Nope. It turns out, when they made their next-generation piece of equipment, the vendor differentiated it by swapping the inner two letters in an already easy-to-say-wrong acronym.

My reaction was, "WTF didn't they just call it the RCSU2?!"

Re:Arm64EC – Run x86_64 and Arm code in the same process by Just_Harry on Monday June 24, 2024 @09:36AM (#40775900)
My favourite is MapViewOfFile3FromApp [0], which is one of the seven variants of MapViewOfFile.

[0]: https://learn.microsoft.com/windows/win32/api/memoryapi/nf-m...

Re:Arm64EC – Run x86_64 and Arm code in the same process by orthoxerox on Monday June 24, 2024 @04:34AM (#40773690)
IsWow64Process2ForRealThisTime
Re:Arm64EC – Run x86_64 and Arm code in the same process by ale42 on Monday June 24, 2024 @06:07AM (#40774190)
wonder why they didn't call it IsWow64ProcessEx
Re:Arm64EC – Run x86_64 and Arm code in the same process by layer8 on Monday June 24, 2024 @01:04PM (#40778428)
The vague convention, as far as I understand, is that Ex denotes an extended variant of a function for more advanced use cases (e.g. with additional parameters/options) which is functionally a superset of the original function, whereas numbered versions are intended to be complete replacements and/or may change the semantics compared to the prior version.
Re:Arm64EC – Run x86_64 and Arm code in the same process by throwaway2037 on Monday June 24, 2024 @11:55PM (#40784318)
Re:Arm64EC – Run x86_64 and Arm code in the same process by lewurm on Monday June 24, 2024 @01:11AM (#40772790)
> I actually think I'm going to rush out and buy a Windows ARM computer right now.

If you have an Apple Silicon machine you can run a Windows Insider build via UTM in a VM.

Re:Arm64EC – Run x86_64 and Arm code in the same process by mappu on Monday June 24, 2024 @01:53AM (#40772932)
I found the http://www.emulators.com/docs/abc_arm64ec_explained.htm article extremely helpful at understanding what the ABI is doing, you might like it too.
Re:Arm64EC – Run x86_64 and Arm code in the same process by adzm on Monday June 24, 2024 @09:47AM (#40776016)
This was a brilliant and informative read, deserving of its own post really. Thanks!
Re:Arm64EC – Run x86_64 and Arm code in the same process by KerrAvon on Monday June 24, 2024 @05:58PM (#40781351)
tl;dr: Microsoft reinvented the Mixed Mode Manager from Mac System 7.1.x circa 1993.
Re:Arm64EC – Run x86_64 and Arm code in the same process by pjmlp on Tuesday June 25, 2024 @04:04AM (#40785768)
Or the Windows 3.1 Enhanced Mode with V86, more likely.
Re:Arm64EC – Run x86_64 and Arm code in the same process by szundi on Monday June 24, 2024 @02:42AM (#40773102)
Quickly create a donation page, you have this moment haha
Re:Arm64EC – Run x86_64 and Arm code in the same process by dwattttt on Monday June 24, 2024 @07:09AM (#40774592)
PE headers have a field for machine type, you're looking for Machine in FileHeader: https://learn.microsoft.com/en-us/windows/win32/debug/pe-for... and https://learn.microsoft.com/en-us/windows/win32/debug/pe-for...

EDIT: Or maybe what you're looking for is hybrid PEs? https://ffri.github.io/ProjectChameleon/new_reloc_chpev2/

Re:Arm64EC – Run x86_64 and Arm code in the same process by justinfrankel on Monday June 24, 2024 @07:32AM (#40774756)
If you have an Apple Silicon mac you can install Win11 in UTM and it works great for dev purposes. Can get the free builds via Windows Insider, too.
Re:Arm64EC – Run x86_64 and Arm code in the same process by conradev on Monday June 24, 2024 @03:17PM (#40779631)
I would recommend getting an official consumer build to test all of the latest consumer features like Copilot

Parallels has a Microsoft partnership and has an official AMR64 image which I was able to grab (and run in anything). I’m sure there are a lot more now, though!

Re:Arm64EC – Run x86_64 and Arm code in the same process by dboreham on Monday June 24, 2024 @09:17AM (#40775671)
> could detect that it's being emulated

Down the rabbit hole...

> buy a Windows ARM computer

You can still get Surface Pro X (16G/LTE) on Amazon for $800

Re:Arm64EC – Run x86_64 and Arm code in the same process by officeplant on Monday June 24, 2024 @10:51AM (#40776749)
If you're lucky you can also find the snapdragon thinkpads for under $350 on amazon.
Re:Arm64EC – Run x86_64 and Arm code in the same process by adastra22 on Monday June 24, 2024 @02:56PM (#40779443)
Whoa
Re:Arm64EC – Run x86_64 and Arm code in the same process by officeplant on Tuesday June 25, 2024 @03:17PM (#40792430)
unfortunately that time seems to have passed, the refurb units I can find now are back up to $650.
Re:Arm64EC – Run x86_64 and Arm code in the same process by darby_nine on Tuesday June 25, 2024 @11:24AM (#40789829)
It looks like this might be provided by "Arm64X", which does seem to encode the dual-arch nature at the binary level: https://learn.microsoft.com/en-us/windows/arm/arm64x-pe