We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
以下是子系统的主要组件:
您将需要在服务器或驱动程序中存储进程或线程状态。如果您将其存储在服务器中,您可能需要类似
NtRegisterThreadTerminatePort
的东西来确保在进程或线程退出时进行清理。如果您使用驱动程序,则需要 PsSetCreateProcessNotifyRoutine。最后,如果您使用的是 XP 及更低版本,则可以添加新的系统调用。您可以通过调用
KeAddSystemServiceTable
来完成此操作。要从用户模式调用系统调用,您需要创建如下存根(对于 x86):在 Vista 及更高版本上,您无法再添加新的系统服务表,因为只有两个空间:内核的系统调用和 win32k 的系统来电。
经过一番谷歌搜索后,我发现了这个:http://winntposix.sourceforge.net/。我认为它与您正在寻找的内容非常相似,并且使用了我提到的很多东西。
Here are the major components of a subsystem:
You will want to store process or thread state in either your server or driver. If you're storing it in the server, you might need something like
NtRegisterThreadTerminatePort
to ensure you get to clean up when a process or thread exits. If you're using a driver, you need PsSetCreateProcessNotifyRoutine.And lastly, if you're on XP and below, you can add new system calls. You can do this by calling
KeAddSystemServiceTable
. To invoke the system calls from user-mode, you need to create stubs like this (for x86):On Vista and above you can no longer add new system service tables because there is only room for two: the kernel's system calls and win32k's system calls.
After a bit of Googling I found this: http://winntposix.sourceforge.net/. I think it's very similar to what you're looking for, and uses a lot of the things I have mentioned.
我也对原生 API 很着迷。 :)
我很高兴地说,它远不像某些人所说的那样危险或无证。 :]
“Hello, world”没有源代码,因为本机 API 与控制台的交互不太容易,因为它是 Win32 子系统的一部分,需要通过端口进行客户端/服务器通信。如果您需要编写控制台应用程序,则需要直接与 CSRSS 通信,其消息格式未记录(尽管其某些格式可以在 ReactOS 的源代码——如果你熟悉 ReactOS,它会给你带来很多好处)。
我很快就会在这里发布一个您可能会感兴趣的示例;现在,请注意您的唯一选项是与 NTDLL.dll 链接,为此,您需要驱动程序开发工具包(因为您需要 lib 文件)。
更新:看看这个!
(我有一种感觉,没有人会发布像这样反叛的东西。用原生 API 显示 GUI?!我一定是疯了!)
如果您有任何问题,请随时提问!我并不害怕原生 API! :)
编辑 2:
如果您尝试制作自己的 Kernel32 DLL 版本,并像 Kernel32 对每个进程所做的那样加载它(因此是一个新的子系统),我只是想让您知道我认为这是不可能的。它与 非常相似这个问题我几天前问过,看来你不能扩展NT PE Loader来了解新的子系统,所以我认为这是不可能的。
I'm also obsessed with the native API. :)
And I'm glad to say that it's nowhere near as dangerous or as undocumented as some people make it seem. :]
There's no source code for "Hello, world" because the native API doesn't interact so easily with the console, since it's part of the Win32 subsystem and requires client/server communication with ports. If you need to write a console application, you need to communicate directly with CSRSS, whose message formats are undocumented (although some of its format can be found in ReactOS's source -- it would do you many benefits if you get familiar with ReactOS).
I'll post an example here soon that you might find interesting; for now, do be aware that your only option ever is to link with NTDLL.dll, and that, for that, you need the Driver Development Kit (since you need the lib file).
Update: Check this out!
(I have a feeling no one else will post something quite as rebellious as this. Showing GUI with the native API?! I must be crazy!)
If you have any questions, feel free to ask! I'm not scared of the native API! :)
Edit 2:
If you're trying to make your own DLL version of Kernel32 and have it load like Kernel32 does with every process (hence a new subsystem), I just wanted to let you know that I don't think it's possible. It's rather similar to this question that I asked a couple of days ago, and it seems that you can't extend the NT PE Loader to know about new subsystems, so I don't think it'll be possible.