Description
Problem:
- Download msys 2022-10-28 from https://github.com/msys2/msys2-installer/releases/tag/2022-10-28 (needs NT6 enabled!)
- Run `flex --version`
See https://github.com/git-for-windows/msys2-runtime/commit/5fe6d81012e97a348608511450f6a63750c906b6
Needs a shim. Patch RtlGetCurrentDirectory_U export point to a decoy version written in asm:
#include <ksamd64.inc>
|
EXTERN RtlGetCurrentDirectory_U:PROC
|
EXTERN RtlAcquirePebLock:PROC
|
EXTERN FastPebLock:QWORD
|
EXTERN RtlEnterCriticalSection:PROC
|
EXTERN RtlpCurDirRef:QWORD
|
|
.code
|
MsysDecoy_UseRtlpCurDirRef:
|
// This path should never be executed!
|
int HEX(2c)
|
lea rcx, FastPebLock[rip]
|
call RtlEnterCriticalSection
|
mov rbx, qword ptr [RtlpCurDirRef]
|
test rbx, rbx
|
MsysDecoy_continue:
|
jmp RtlGetCurrentDirectory_U
|
|
PUBLIC RtlGetCurrentDirectory_U_RtlpMsysDecoy
|
RtlGetCurrentDirectory_U_RtlpMsysDecoy:
|
// Short jmp that hopefully does not contain a 0xe8
|
jmp short MsysDecoy_continue
|
// This emulates the call that msys/cygwin are looking for
|
// and will never be executed
|
call MsysDecoy_UseRtlpCurDirRefEND
|
The shim should be registered to "msys-2.0.dll".