cmderdev / cmder

Lovely console emulator package for Windows
https://cmder.app
MIT License
25.84k stars 2.02k forks source link

Support for ARM64 (Windows 10/11) #2633

Open command0r opened 2 years ago

command0r commented 2 years ago

Purpose of the issue

Version Information

Cmder v1.3.18 Windows 11 (21H2, build 22000.318), ARM edition

Description of the issue

I'm running Windows 11 in Parallels Desktop 17 as a VM. Once this is a newer generation Apple M1 laptop, it means ARM architecture, and hence, a very specific version of Windows 11 (i.e., for ARM devices). Cmder doesn't run out of the box after installation. At first, it hangs, and then it crashes without and visible signs of error.

In the Event Log --> Application I can see an error related to a crash: Faulting application name: cmd.exe, version: 10.0.22000.51, time stamp: 0x23fe19cb Faulting module name: xtajit64.dll, version: 10.0.22000.120, time stamp: 0x4237ca8c Exception code: 0xc0000409 Fault offset: 0x0000000000029968 Faulting process id: 0x1ed0 Faulting application start time: 0x01d7eae24fdb648d Faulting application path: C:\Windows\SYSTEM32\cmd.exe Faulting module path: C:\Windows\System32\xtajit64.dll Report Id: 55911a84-5154-473c-9705-c79e1da12d4d Faulting package full name: Faulting package-relative application ID:

Here's the window screenshot (not much use, but just to give you an idea): cmder

What I tried: I tried to use it in compatibility mode, but that just generates another type of error and the app is still unusable.

Please advice.

daxgames commented 2 years ago

ARM is not supported, at the moment.

command0r commented 2 years ago

Good stuff. Is it not supported just now or the support is not even planned for the future editions?

DRSDavidSoft commented 2 years ago

Edit: I wasn't aware of the minhook library issue when I wrote this, which ConEmu relies on.

@command0r It shouldn't be too hard to target M1 ARM and/or Raspberry Pi ARM Windows builds, both the launcher and ConEmu can be built for them.

I have a MacBook Pro running Parallels 17.5 and Windows 11, I'll see if I can make a port of Cmder to run on ARM64 builds.

N.b: It's not recommended to run x86_64 builds of Cmder on ARM.

chrisant996 commented 2 years ago

@command0r It shouldn't be too hard to target M1 ARM and/or Raspberry Pi ARM Windows builds, both the launcher and ConEmu can be built for them.

@DRSDavidSoft have you read up on why an ARM version of ConEmu doesn't exist? The minhook library doesn't support ARM. Unless you have a solution for that, then it is currently impossible to build ConEmu for ARM.

DRSDavidSoft commented 2 years ago

@chrisant996 Good point, I actually wasn't aware of the issue, but until native ConEmu ARM builds, I suppose the Windows Terminal is a good native ARM terminal for Cmder shell on Windows 11.

It won't be the official ConEmu/Cmder package, but would still provide access to the useful Clink/PowerShell profiles.

I actually was working on a "core" edition of Cmder that would only provide the batch scripts and Clink shell, as I mainly use Cmder myself with Conhost (i.e. cmd.exe) and other terminals (also over OpenSSH).

If doable, I'm also interested to see if I can either work on minhook or a fork for ConEmu that would use Detour as an alternative (although, developers experienced in this regard would've surely made some progress in this regard if this was an easy task).

chrisant996 commented 2 years ago

@chrisant996 Good point, I actually wasn't aware of the issue, but until native ConEmu ARM builds, I suppose the Windows Terminal is a good native ARM terminal for Cmder shell on Windows 11.

It won't be the official ConEmu/Cmder package, but would still provide access to the useful Clink/PowerShell profiles.

How so? Clink does not support ARM, either, for the same reason. No one seems to have implemented an IAT hooking implementation for ARM yet (not minhook, and not any alternative IAT hooking libraries).

(Btw, I'm the current Clink author.)

It's not just a matter of needing an ARM device or emulator to test on -- it's also a matter of analyzing the ARM assembly and identifying all the ways the API jumps can appear in assembly code, and handling all of them.

If doable, I'm also interested to see if I can either work on minhook or a fork for ConEmu that would use Detour as an alternative (although, developers experienced in this regard would've surely made some progress in this regard if this was an easy task).

Detours may cause problems and incompatibilities between programs, and they may not be immediately obvious. Detours uses a very different hooking approach than IAT hooks. In Clink I tried using Detours, and it caused multiple incompatibilities and failures. I was forced to disable the use of Detours in Clink as it was impossible to make Clink function reliably/properly.

I recommend reading up on both IAT and Detours, and analyzing the differences very carefully. They are different beasts, and simply swapping one for the other is likely to cause compatibility problems and/or functionality problems.

What is needed is ARM support for IAT hooking. It's probably something I could get working if I had an ARM device + ARM assembly manuals + enough time and motivation. (I currently lack an ARM device/emulator, time, and motivation -- I assume that ARM assembly reference manuals can be found on the internet.)

DRSDavidSoft commented 2 years ago

@chrisant996 I seem to be greatly underestimating this case, so I apologise for not actually evaluating the case before making my earlier comments.

Great work on Clink/1, can't stress enough how much I appreciate your work on refactoring the old code and adding the recent features, especially the (long overdue) remaining bugs after the original author stopped working on the project.

At the moment, what I understand is that the primary issue is with the underlying hooking methods (that both ConEmu and Clink use).

So, I'll focus my efforts on understanding ARM64 assembly and compatibility issues, to see if I can make a progress in bringing Cmder natively there.

Again, sorry for my misunderstandings and confusions!

chrisant996 commented 2 years ago

Great work on Clink/1, can't stress how much I appreciate your work on refactoring the old code and adding the recent features, especially the (long overdue) remaining bugs after the original author stopped working on the project.

❤️

At the moment, what I understand is that the primary issue is with the underlying hooking methods (that both ConEmu and Clink use).

So, I'll focus my efforts on understanding ARM64 assembly and compatibility issues, to see if I can make a progress in bringing Cmder natively there.

I imagine there are quite a few projects that would benefit from IAT hooking support for ARM, so on behalf of all such projects I wish you excellent luck! 😎

chrisant996 commented 1 year ago

Clink supports ARM64 since v1.4.7, so that part is covered now.

IAT hooking is the same for x64 and ARM64, so ConEmu could use Detours for any minhook-style jmp hooking, and the same IAT hooking as usual for any IAT hooking.

DRSDavidSoft commented 3 months ago

@Maximus5 Any news on ARM support for ConEmu?

bogdanbabos commented 2 months ago

@Maximus5 no hope of porting to Windows ARM64 is there?