编写驱动程序的问题

coolali 2003-11-03 01:35:01
请教:
我想知道在驱动程序是否可以调用Windows的API,比如:LoadLibrary,
如果不能直接调用,是否可以通过回调函数实现,如果可以,应该怎么实现,
如果哪位知道,麻烦能够讲一下,谢啦。
...全文
44 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
coolali 2003-11-05
  • 打赏
  • 举报
回复
多谢,先给分吧。
看来在驱动中是没有办法实现了,不知有没有其他的方法可以实现类似的功能。

会思考的草 2003-11-04
  • 打赏
  • 举报
回复
具体说就是Ring3和Ring0的代码不能互相调用。
coolali 2003-11-04
  • 打赏
  • 举报
回复
to codewarrior(会思考的草):
说实话我对驱动程序不是很了解,如果可以你能够说说两者之间的有什么不同吗?
我现在的需求是想在驱动中调用我在dll中实现的方法,不知是否可以?
如果可以,应该怎么做?谢啦
会思考的草 2003-11-04
  • 打赏
  • 举报
回复
有没有看见这一行:
User-mode drivers have unlimited stack space, access to the Win32 API, and easier debugging (with user-mode debuggers).
会思考的草 2003-11-04
  • 打赏
  • 举报
回复
算了,俺E文不过关,还是看原版的吧。
Windows® drivers can run in either user mode or kernel mode.

User-mode drivers run in the non-privileged processor mode in which other application code, including protected subsystem code, executes. User-mode drivers cannot gain access to system data except by calling the Win32® API which, in turn, calls system services.
Kernel-mode drivers run as part of the operating system's executive, the underlying operating system component that supports one or more protected subsystems.
User-mode and kernel-mode drivers have different structures, different entry points, and different system interfaces. Whether a device requires a user-mode or kernel-mode driver depends on the type of device and the support already provided for it in the operating system.

Some device drivers can run wholly or partially in user mode. User-mode drivers have unlimited stack space, access to the Win32 API, and easier debugging (with user-mode debuggers).

For example, printer drivers are divided into user interface and rendering components. The user interface component runs in user mode, and calls the Win32 API to render images. The Win32 API, in turn, calls the rendering component, which can run in either kernel mode or user mode.

Most device drivers run in kernel mode. Kernel-mode drivers can perform certain protected operations and can access system structures that user-mode drivers cannot access. The increased access comes at the price, however, of more difficult debugging and a greater chance of system corruption. When code runs in the privileged kernel-mode environment, the operating system, by design, performs fewer checks on data integrity and the validity of requests.
会思考的草 2003-11-04
  • 打赏
  • 举报
回复
首先要看你的驱动程序是内核态还是用户态。如果分不清内核态和用户态驱动的区别,请看下面我翻译的DDK解释。
内核态的代码不能调用用户态的代码(比如API)。
用户态的代码也不能调用内核态的代码(比如IoCreateDevice)
这和是不是驱动没有关系。
会思考的草 2003-11-04
  • 打赏
  • 举报
回复
LoadLibraray是Ring3的API,内核驱动不可以用。
会思考的草 2003-11-04
  • 打赏
  • 举报
回复
那你首先要知道你的dll是否运行在核心态。sys驱动程序也可以看成一个内核态的dll。
孤必有邻 2003-11-04
  • 打赏
  • 举报
回复
好像是这样说的,在DDK代码中,不能调用api中的绝大部分函数是不能调用的,(极少数可以),但是这些函数通常都有一个对应的函数,实现相同的功能。
coolali 2003-11-04
  • 打赏
  • 举报
回复
我现在的问题是:
我想在驱动程序中调用我在另一个DLL中实现的方法,不知是否可以?

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧