zl程序教程

您现在的位置是:首页 >  系统

当前栏目

reactos操作系统实现(172)

操作系统 实现 reactos
2023-09-14 09:10:39 时间

NtUserTranslateMessage函数实现键盘的消息转换,实现代码如下:

#001  BOOL APIENTRY

#002  NtUserTranslateMessage(LPMSG lpMsg,

#003                         HKL dwhkl)

#004  {

#005     NTSTATUS Status;

#006     MSG SafeMsg;

#007     DECLARE_RETURN(BOOL);

#008 

 

进入界面临界区代码。

#009     DPRINT("Enter NtUserTranslateMessage/n");

#010     UserEnterExclusive();

#011 

 

从用户空间拷贝消息到内核。

#012     Status = MmCopyFromCaller(&SafeMsg, lpMsg, sizeof(MSG));

#013     if(!NT_SUCCESS(Status))

#014     {

#015        SetLastNtError(Status);

#016        RETURN( FALSE);

#017     }

#018 

 

调用函数IntTranslateKbdMessage来转换键盘消息。

#019     RETURN( IntTranslateKbdMessage(&SafeMsg, dwhkl));

#020 

#021  CLEANUP:

#022     DPRINT("Leave NtUserTranslateMessage: ret=%i/n",_ret_);

#023     UserLeave();

#024     END_CLEANUP;

#025  }