Windows 上的系统调用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2759101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:17:56  来源:igfitidea点击:

System calls on Windows

windowssystem-calls

提问by B.Gen.Hyman.O.Neill

I just want to ask, I know that standart system calls in Linux are done by int instruction pointing into Interrupt Vector Table. I assume this is similiar on Windows. But, how do you call some higher-level specific system routines? Such as how do you tell Windows to create a window? I know this is handled by the code in the dll, but what actually happend at assembler-instruction level? Does the routine in dll calls software interrupt by int instruction, or is there any different approach to handle this? Thanks.

我只是想问一下,我知道 Linux 中的标准系统调用是通过指向中断向量表的 int 指令完成的。我认为这在 Windows 上是类似的。但是,您如何调用某些更高级别的特定系统例程?比如你怎么告诉Windows创建一个窗口?我知道这是由 dll 中的代码处理的,但是在汇编程序指令级别实际发生了什么?dll中的例程是否通过int指令调用软件中断,或者有什么不同的方法来处理这个问题?谢谢。

采纳答案by Kelly S. French

Making a Win32 call to create a window is not really related to an interrupt. The client application is already linked with the .dll that provides the call which exposes the address for the linker to use. Since you are asking about the difference in calling mechanism, I'm limiting the discussion here to those Win32 calls that are available to any application as opposed to kernel-level calls or device drivers. At an assembly language level, it would be the same as any other function call since most Win32 calls are user-level calls which internally make the needed kernel calls. The linker provides the address of the Win32 function as the target for some sort of branching instruction, the specifics would depend on the compiler.

进行 Win32 调用以创建窗口与中断并没有真正的关系。客户端应用程序已与提供调用的 .dll 链接,该调用公开链接器使用的地址。由于您是在询问调用机制的差异,因此我将此处的讨论限制在可用于任何应用程序的 Win32 调用,而不是内核级调用或设备驱动程序。在汇编语言级别,它与任何其他函数调用相同,因为大多数 Win32 调用是用户级调用,它们在内部进行所需的内核调用。链接器提供 Win32 函数的地址作为某种分支指令的目标,具体取决于编译器。

[Edit] It looks like you are right about the interrupts and the int. vector table. CodeGuru has a good article with the OS details on how NT kernel calls work. Link:
http://www.codeguru.com/cpp/w-p/system/devicedriverdevelopment/article.php/c8035

[编辑] 看起来您对中断和 int 是正确的。矢量表。CodeGuru 有一篇很好的文章,其中详细介绍了 NT 内核调用的工作原理。链接:http:
//www.codeguru.com/cpp/wp/system/devicedriverdevelopment/article.php/c8035