在 native API 中,Microsoft 为每个 API 调用导出两个版本,一个以 Zw 为前缀,一个以 Nt 为前缀,例如。 ZwCreateThread 和 NtCreateThread。
我的问题是这两个版本的调用之间有什么区别,什么时候以及为什么应该专门使用 Zw 或 Nt? 据我了解,Zw 版本确保调用者驻留在内核模式下,而 Nt 则不然。
我也想知道 Zw 和 Nt 前缀/缩写的具体含义? 可以猜测 Nt 可能是指 NT(新技术)Windows 系列或 Native(可能不是)? 至于Zw,它代表什么吗?
最佳答案
除了 Larry Osterman 的回答(你应该绝对阅读)之外,还有一件事我应该提到:
由于 NtXxx 变体会像调用来自用户模式一样执行检查,这意味着传递给 NtXxs 函数的任何缓冲区必须驻留在用户模式地址空间中,而不是内核模式 .因此,如果您在驱动程序中调用类似 NtCreateFile 的函数并将指针传递给内核模式缓冲区,您将因此返回 STATUS_ACCESS_VIOLATION。
参见 Using Nt and Zw Versions of the Native System Services Routines .
A kernel-mode driver calls the Zw version of a native system services routine to inform the routine that the parameters come from a trusted, kernel-mode source. In this case, the routine assumes that it can safely use the parameters without first validating them. However, if the parameters might be from either a user-mode source or a kernel-mode source, the driver instead calls the Nt version of the routine, which determines, based on the history of the calling thread, whether the parameters originated in user mode or kernel mode.
Native system services routines make additional assumptions about the parameters that they receive. If a routine receives a pointer to a buffer that was allocated by a kernel-mode driver, the routine assumes that the buffer was allocated in system memory, not in user-mode memory. If the routine receives a handle that was opened by a user-mode application, the routine looks for the handle in the user-mode handle table, not in the kernel-mode handle table.
另外,Zw 不代表任何东西。参见 What Does the Zw Prefix Mean? :
The Windows native system services routines have names that begin with the prefixes Nt and Zw. The Nt prefix is an abbreviation of Windows NT, but the Zw prefix has no meaning. Zw was selected partly to avoid potential naming conflicts with other APIs, and partly to avoid using any potentially useful two-letter prefixes that might be needed in the future.
关于Windows native API : When and why use Zw vs Nt prefixed api calls?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4770553/
我正在尝试找到一种将Git添加到Windows路径的方法。每当我尝试从JetBrains简洁的IDE、RubyMine或GitBash本身运行RakeFiles时,我都会收到错误消息,该标题发布在以下位置:Nosuchfileordirectory-gitls-files根据一位开发人员的说法,我需要将Git添加到我的Windows路径中。除了Mac,我还没有找到如何修复此错误的方法。有没有人可以帮助我弄清楚如何使用Windows解决此问题? 最佳答案 右键单击“我的电脑”并选择属性点击高级系统设置点击EnvironmentVari
一、lsmodlsmod命令,用于列出当前linux系统中加载的模块。当驱动开发人员编写好驱动代码,并生成驱动代码对应的驱动模块后,可以通过insmodxxx.ko将驱动模块(.ko)加载到linux操作系统中。最后,通过lsmod命令就可以看到xxx.ko已经加载到linux系统当中了。1.1驱动代码:back@ubuntu2205:~$catdriver.c#include#include#includeinthello_probe(structplatform_device*pdev){printk("[%s]matchok\n",__FILE__);return0;}inthello_
我正在编译一个自定义内核,我想测试图像文件的大小。这些是结果:ls-la|grepvmlinux-rwxr-xr-x1rootroot8167158May2112:14vmlinuxdu-hvmlinux3.8Mvmlinuxsizevmlinuxtextdatabssdechexfilename222124867614854476834421643485f4vmlinux由于它们都显示不同的尺寸,那么哪一个最接近实际图像尺寸?它们为什么不同? 最佳答案 它们都是正确的,它们只是显示不同的尺寸。ls显示文件的大小(当您打开并阅读它时
目录查看本地镜像搜索可用mysql拉取最新版本运行镜像查看进程是否正常问题解决查看本地镜像查看本地是否已经有mysql镜像了dockerimages|grepmysql正常此步骤不会有返回结果搜索可用mysqldockersearchmysql拉取最新版本dockerpullmysql:latest再次查看镜像已存在运行镜像设置密码端口等dockerrun--namemysql-will-d-p3306:3306-eMYSQL_ROOT_PASSWORD=123456mysql查看进程是否正常dockerps|grepmysql如果没有,查询dockerps-a查看所有(没有-a的话查看的是成
目录考试注意事项A卷 74LS192+74LS00B卷 74LS153+74LS00/74LS20+ 74LS139 C卷 74LS153+74LS00/74LS20+ 74LS139课程感悟考试注意事项1.考试前请检查实验箱号和仪器号与座位号是否一样,不一样请请示老师更换;2.请自行检查导线、芯片、仪器的好坏,如有问题,请及时找教师更换;否则由于导线、芯片损坏而影响考试结果的,后果自负;3.不得自行拔下实验箱芯片,除非老师确认芯片损坏后方能更换;否则作为蓄意损坏实验仪器设备论处,根据情况扣20~40分;4.实验完毕后收拾仪器和实验桌为实验基本素质,不收拾仪器者将根据情况扣分(10分内)
我尝试为我的CLion项目运行一些基本命令,但它就是行不通。这是我的CMake设置。cmake_minimum_required(VERSION3.6)project(hello)set(CMAKE_CXX_FLAGS"${CMAKE_CXX_FLAGS}-std=c++11")set(SOURCE_FILESmain.cpp)add_executable(hello${SOURCE_FILES})add_custom_command(OUTPUThello.outCOMMANDls-lhelloDEPENDShello)add_custom_target(run_hello_outD
dir是windows中列出当前位置有哪些文件的命令,类似于linux中的ls命令。但是,它们默认显示的信息不同。这是windowsdir的示例输出之一:2016-06-3003:47PM.2016-06-3003:47PM..2015-06-0403:49PM12,292.DS_Store2016-06-1005:10PM11.gitattributes2016-06-3003:47PM318.gitignore2015-09-2510:09AM0.gitmodules2016-08-0311:25AMapp2015-08-1005:07PM2,502artisan2016-06-3
ls-la和ls-l都提供了比ls命令更多的信息。然而,因为他们的输出非常相似,我不清楚这两个命令之间的区别是什么。gitbash中的ls-la和ls-l有什么区别? 最佳答案 这是下面标志的含义。两者不一样。在第一种情况下(ls-l)隐藏文件/文件夹不会列出,而在第二种情况下(ls-la)隐藏文件/文件夹将显示。-l-lusealonglistingformat-a-a,--alldonotignoreentriesstartingwith.这意味着也显示隐藏的文件/目录。 关于win
我正在尝试从远程服务器获取文件夹列表,但无法将远程服务器安装到我的本地计算机(因为权限问题)。我用过smbclient"//165.186.89.21/DeptDQ_141Q_FOTA""--user=myid"-c'ls;'获取文件夹列表。结果是成功的。但是,实际上我想在上面的命令行中使用ls-l当我尝试使用这条线获得结果时smbclient"//165.186.89.21/DeptDQ_141Q_FOTA""--user=LGE\final.lee"-c'ls-l;'返回NT_STATUS_NO_SUCH_FILElisting\-l64000blocksofsize1677721
知道试图说的错误是什么吗?Traceback(mostrecentcalllast):File"",line1,insubprocess.call(["ls","-l"])File"D:\Python27\lib\subprocess.py",line522,incallreturnPopen(*popenargs,**kwargs).wait()File"D:\Python27\lib\subprocess.py",line710,in__init__errread,errwrite)File"D:\Python27\lib\subprocess.py",line958,in_exe