Ad
  • Custom User Avatar

    It cannot be solved in a portable way, yes. Solutions have to assume ABI, which for CW is SystemV for linux.

    Majotiry of solutions takes approach with inline assembly, but there are some smart solutions which avoid it. But still you need some address-of magic/abuse to get the stack parameters, yes.

    Bottom line is: it cannot be solved in a portable way, but it can be solved without inline assembly.

  • Custom User Avatar

    This is a C challenge, but I don't believe it's possible purely in C, for x64 - is it?

    Since the first six arguments in SYS-V ABI are passed in registers rdi, rsi, rdx, rcx, r8, r9 and not on the stack, there's no real way to get them without using __asm or other non-C mechanisms perhaps.

    I can find some arguments on the stack by abusing*,&. However, some arguments don't appear to be available without using __asm to try and extract it from registers directly. I could however be wrong. I do see n on the stack, which also confuses me as I would think it would only be in RDI, but past that I don't see anything until argument six of the variadic part. Am I wrong or is the challenge? Is it supposed to be solved with __asm?