设备驱动程序的ImagePath

发布于 2024-10-14 02:43:22 字数 536 浏览 7 评论 0原文

我总是直接设置驱动程序 Imagepath。(C:\Windows\System32\drivers\abc.sys)

但我只知道许多设备驱动程序将其 ImagePath 设置为 %SystemRoot%\system32\svchost.exe -k netsvcs
在此处输入图像描述
这是 Lanmanworkstation 驱动程序的注册表配置单元。
我猜Lanmanworkstation驱动程序的镜像文件是mrxsmb.sys
但他们没有放置“System32\drivers\mrxsmb.sys”。为什么。

svchost.exe -k netsvcs 是什么意思?
即使没有确定的路径,StartService 功能也能正常工作。
服务管理器(?我不确定)如何找到驱动程序的图像路径?

使用这个有什么好处吗?
如果我决定使用这种方式,我的驱动程序代码是否需要修改?

I always set my drivers Imagepath directly.(C:\Windows\System32\drivers\abc.sys)

But I just knew many device drivers set their ImagePath to %SystemRoot%\system32\svchost.exe -k netsvcs
enter image description here
This is Lanmanworkstation driver's registry hive.
I guess Lanmanworkstation driver's image file is mrxsmb.sys
But they didn't put 'System32\drivers\mrxsmb.sys'. Why.

What does svchost.exe -k netsvcs mean?
Even though there is no certain path, StartService function works well.
How does Service Manager(? i'm not sure) find the driver's image path?

Is there an advantage using this?
What if I decide to use this way, are there my driver codes should modify?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

演出会有结束 2024-10-21 02:43:22

您对设备驱动程序和服务感到困惑。
svchost.exe 用于在多个服务之间共享同一进程。该实现是 Windows 内部的,因此不支持在 Windows 外部使用。

如果您编写设备驱动程序(用于硬件或过滤器驱动程序)或不为 Microsoft 工作,则无法使用 svchost。

造成混乱的原因是旧式 (NT4)、非即插即用驱动程序可以使用服务控制管理器 API 启动。

You are confusing between device drivers and services.
svchost.exe is used to share the same process between multiple services. The implementation is internal to Windows so use outside of Windows is not supported.

If you write a device driver (for hardware, or a filter driver) or do not work for Microsoft, you cannot use svchost.

The reason for the confusion is because old style (NT4), non-plug-and-play drivers can be started using the Service Control Manager APIs.

无法言说的痛 2024-10-21 02:43:22

svchost 是其他服务的主机进程,包含在 DLL 中。 “-k”后面的部分表示服务组。您可以在 ServiceDll 值中的 HKLM\System\CurrentControlSet\Services\LanmanWorkstation\Parameters 中找到服务 DLL 路径。我猜测如果删除图像路径它仍然可以正确启动的原因是因为服务类型设置为 SERVICE_WIN32_SHARE_PROCESS ,并且 SCM 可能会忽略图像路径(对此不确定)。

svchost is a host process for other services, contained in DLLs. The part after the "-k" indicates the service group. You can find the service DLL path in HKLM\System\CurrentControlSet\Services\LanmanWorkstation\Parameters in the ServiceDll value. I'm guessing the reason it still starts correctly if you remove the image path is because the service type is set to SERVICE_WIN32_SHARE_PROCESS, and the SCM probably ignores the image path (not sure about this).

小鸟爱天空丶 2024-10-21 02:43:22

svchost.exe是一个“多用途”服务。它将多个服务合并在一个 exe 文件中,每个服务都可以使用服务管理控制台等进行单独控制。 svchost.exe 的参数指明了 exe 文件内的“子服务”。

由于 startService() 不是服务本身的控制消息,而只是启动某个可执行文件的请求(该可执行文件本身必须“知道”它是一个服务(以及该服务),然后向服务控制管理器注册), windows 将简单地执行 ImagePath 指向的二进制文件。

在本例中(LanManWorkstation),该二进制文件是svchost.exe,为其提供的参数是-k netsvc。这让 svchost.exe 知道应该启动它提供的众多服务中的哪一个。

与往常一样,二进制文件本身不需要包含所有函数,但也可以加载其他库。 mrxsmb.sys 很可能就是这样一个库,尽管我不确定这一点。

所以这个答案更多的是“它一般是如何工作的”而不是“是的,netsvc 和 mrxsmb.sys 是 LanManWorkstation”。

svchost.exe is a "multi-purpose" service. It incorporates multiple services in one single exe file, each of which can be seperately controlled using e.g. services management console. The parameters to svchost.exe states the "subservice" inside the exe file.

As startService() is not a control message to the service itself but instead only the request to start a certain executable (which itself must "know" that it is a service (and wich service) and will then register with service control manager), windows will simply execute the binary that ImagePath points to.

In this case (LanManWorkstation) this binary is svchost.exe, the parameter given to it is -k netsvc. This lets svchost.exe know which of the many service it provides should be started.

As usual, the binary doesn't need to contain all the function in itself but can also load additional libraries. mrxsmb.sys may well be such a library, though I'm not sure of this point.

So this answer is more of a "how does it work in general" than a "yes, netsvc and mrxsmb.sys are LanManWorkstation".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文