Freigeben über


Иногда люди воспринимают вещи слишком буквально.

?? ???? ???????? ? inbox ??????:

The documentation for QueueUserApc states "an APC cannot be queued from a 64-bit process to a 32-bit process or vice versa."

However on Vista Ultimate x64, we can queue a user APC from a 32-bit process to a 64-bit process. In our test application the 64-bit recipient crashes, we haven't explored why just yet, but the point is that the operation should not succeed and the 64-bit application's APC queue should never have the APC inserted.

Is it an OS bug?

???????????? ? ??????? QueueUserApc ??????????, ??? ??????????? ????? ????????? (APC) ?? ????? ???? ???????? ?? 64-? ??????? ???????? ??? ?????????? ? 32-? ?????? ? ????????.

?????? ?? Vista Ultimate x64 ?? ????? ????????? ??????????? ????? ????????????????? ?????? ?? 32-? ??????? ???????? ? 64-? ?????? ????????. ? ????? ???????? ?????????? 64-? ?????? ?????????? ?????? ? ?? ??? ?? ???????? ??????, ?? ???? ? ???, ??? ???????? (QueueUserApc) ?? ?????? ??????????? ??????? ? ??????????? ????? ?? ?????? ??????????? ? ??????? ??????? 64-? ?????????? ????????.

??? ??? ???

?????? ???????????? ???, ??? ??? ??? ?????? ?????? ?? ??? ???? ?? ????????? ??? ??????, ???? ??????? QueueUserApc ?????? ?? ????? ?????? ???????????? ??????? Win32. ?? ????? ????? ??????????? ?????? ??? ??????? ??????. :-)

??? ?????? ??????????, ??? ????? ??????????? ?????? ???????? (APC). ?? ??? ????? ????? ????? ?????????? ???? ?????. Windows NT ???????????? ??????????? ????????? ???????????????? ?????? – “alertable wait”. ????? ????????????? ? ??? ????????? ????? ????? ???????????? “Ex” ?????? “WaitFor” ??????? ??? ??????? ???????????? ?????-?????. ??? ????????? ????????????? ???, ??? ????? ????? ???? ? ????? ?????? ????????, ??? ???? ?????????? ????? ???????? ?? ????????????? (??????? ??????????????) ??????. ??? ??????????? ???????????? ????? ??? ??????????? ?????????? ? ?????????? ???????? ?????-??????. ? ???????, ???? ? NtWriteFile ??????? ?? ??????? ApcRoutine, ?? ?? ?????????? ???????? ???? ??????? ApcRoutine ?????? ? ??????? ????????? ??????????? ???????.

??????? QueueUserApc ????????? ??????????????? ???? ?????????? ? ????? ????????? ?????. ??? ??????? ?????? ?????? ?? ?????????? APC ????????? ? ???????????? ??????. ????????? ????? ??????? (????????, ?????? ? ??????? ???????????) ? ????????? ???????? ??????, ??? ?????? ??? ????????????? ? ????????? alertable wait. ?????????, ?? ?????? ???????? ??????????? ? ???, ??? ????? ????????? ????? ???? ?????. ??????? ????? ?? ??????????? ??? ????????????. ???? ????? ????????? ???????, ?? ??????? ?????, ?????? ?????, ?????? ? ????? access violation. ??? ???? ?????, ????????? QueueUserApc, ????????? ??????, ??? ?? ? ??? ?? ??????.

?????, ????????? 32-? ? 64-? ?????? ???????? ?????????? ?????? ?????? ??????, ?? ? ??????? 64-? ????????? ???????? ?? 32-? ??????? ???? ????????? ?????? ???????? ?????????. 32-? ?????? ??? ?????? ?? ????? ??????????? ???????? 64-? ?????? ????? ? QueueUserApc. ???????? 32-? ????? ????????, ?? ????????? ?????? ?????????. ????????, ??? ???????? ????? 32-? ??????? ???? ?? ?????? 64-? ??????? ????? ?????????????? ???? ??????? 4GB.

???????? ?????? ??? ???, ??? ???????????? ????????: https://www.nynaeve.net/?p=202

???????? ?????? ? ????????????? ???????. ?????????, ??? ????, ??? QueueUserApc ????????? ????????? ????? ? ??????? ?????? ? ?????? ????????????, ????? ??????? ???????. ???? ?? ????? ???? ??? ?????? ?????? ? ????????????, ??????? ?????? ???? ?? ??????????, ??? “ ??? ??????????? ????? ????????? (APC) ?? ??????? ??????????? ?? 64-? ??????? ???????? ??? ?????????? ? 32-? ?????? ? ????????.” ????????? ???????, ?? ????? ??????.

???? ? ???, ??? QueueUserApc ?????? ?? ????? ??????????? ????????? ??????????? ???????? ?????? ?? ???? ???????. ????? ??? ???? ???????? ??????? ???????? ?????? ?????? ???? ???????? ? ??????? ??????? PROCESS_QUERY_INFORMATION ??? PROCESS_QUERY_LIMITED_INFORMATION. ????????? ???????????? ??????????? ????? ? ????, ?? ??? ?????? ??? ????, ??? ??????? ??? ??? ?????? ????? ???????? 32-? ?????? APC ?? 64-? ?????????? ????. ? ??????????, ???????????? Wow64 ??????, ??? ??????? ?? ????? ???????, ? ????? ???????? ?? ???? ???????????. ??????? ?????????? ???? ??????? ??????, ??? ????? ????????? ? ?????? ?????? ?????????? ??????????? ?????????????? ???????? ? ??????? ???????? ??????.

?????????, ??????? ??, ?? ??? ?? ???? ??????????, ??? 32-? ???????? ?????????? ????? ???????? ???????? ?????? 64-? ????????? ??????????? ??? ?? ????? ?? ????? ???? ??? ???? ?? ???? ?? ?????? ??? ? ??????, ????? ??????????? ??????? ?????????. ??? ? ??? ???????, ?????????? ????? ????? ???????? ????? ? ??? ????? ?? ?????????? ?????, ??? ?????????? ???????? ? ????? ???????? ??????. ?????????? ????? ?????? ????? ??????? ??????? THREAD_SET_CONTEXT ? ???????? ??????, ??? ????????, ??? ?????????? ??????? ? ??? ????? ?????? ???????? ??? ??????? ???????.

Cross-posted from blog.not-a-kernel-guy.com.