我正在做作业,并试图从键盘上读取键。我尝试使用// DetailsFragment.kt
class DetailsFragment : Fragment() {
companion object {
fun create(user: User, transitionName: String): DetailsFragment {
val args = Bundle()
args.putParcelable("user", user)
args.putString("transition_name", transitionName)
val fragment = DetailsFragment()
fragment.arguments = args
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fragment.sharedElementEnterTransition = ChangeBounds()
fragment.sharedElementReturnTransition = ChangeBounds()
}
return fragment
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_details, container, false).apply {
val transitionName = arguments?.getString("transition_name", "")
ViewCompat.setTransitionName(findViewById(R.id.picture), transitionName)
}
}
}
中断并从此代码开始
16h
组装算法为:
int main(){
char key, shiftKey(2);
asm ("movb %1, %%al;"
"int $0x16;"
"movb %%al, %0;"
:"=r"(key)
:"r"(shiftKey)
:"%al"
);
std::cout << int(key);
}
寄存器al
movb 2, al
int 16h
现在应该具有所有键的遮罩,例如shift,capslock等。此代码因al
而崩溃。所以我没有适当的信息我做错了什么。