MagSetWindowSource
not is necessary, i tested here (Delphi code) without this
api and screenshot still is works.
It keeps crashing, if I comment out the
MagSetWindowSource
. Callstack points to `msvcrt.memcpi` so I guess there's something fishy somewhere else. Could be anything like wrong types, calling conventions, buffer overreads, ... Same problem might cause your black image. Buffer overreads/overflows can be tricky sometimes and do not always result in reproducable problems.