一个很奇怪的问题,关于CoResumeClassObjects函数。

败落 2017-08-28 02:52:40
最近在做windows驱动和服务的开发,遇到一个很奇怪的问题。

之前是服务单独起,用命令行命令启动,现在想要和驱动捆绑在一起,安装驱动同时安装服务,不经过命令行。

代码相同的情况下
编译出来的exe服务,用/service命令 CoResumeClassObjects函数执行正常。
而利用驱动直接起我编写的服务,CoResumeClassObjects返回错误0x80004015。

有大神能解释一下这两种方式有什么不同吗。

...全文
307 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2017-09-05
  • 打赏
  • 举报
回复
百度搜“inf文件格式详解”
败落 2017-09-05
  • 打赏
  • 举报
回复
引用 6 楼 zhao4zhong1 的回复:
在64位Windows下: 64位exe和dll在目录c:\windows\system32目录下; 32位exe和dll在目录c:\windows\syswow64目录下; 所以要注意: 在win64位系统下注册32位ocx或dll需要将32位ocx或dll拷贝到c:\windows\syswow64\目录下。 且注册要用c:\windows\syswow64\regsvr32 xxxxxxx.ocx或dll 在win64位系统下设置32位程序使用的数据库别名要用c:\windows\syswow64\cliconfg.exe 在win64位系统下设置32位程序使用的系统DSN要用c:\windows\syswow64\odbcad32.exe 64 位 Windows 平台注意点之文件系统重定向 http://www.cnblogs.com/jiake/p/4981555.html 64 位 Windows 平台注意点之注册表重定向 http://www.cnblogs.com/jiake/p/4956218.html
请问您对inf文件了解吗?通过inf文件安装驱动服务,现在我有一个驱动程序,和一个与该驱动程序无关的服务程序,可以通过一个inf文件捆绑安装吗?
赵4老师 2017-09-05
  • 打赏
  • 举报
回复
在64位Windows下: 64位exe和dll在目录c:\windows\system32目录下; 32位exe和dll在目录c:\windows\syswow64目录下; 所以要注意: 在win64位系统下注册32位ocx或dll需要将32位ocx或dll拷贝到c:\windows\syswow64\目录下。 且注册要用c:\windows\syswow64\regsvr32 xxxxxxx.ocx或dll 在win64位系统下设置32位程序使用的数据库别名要用c:\windows\syswow64\cliconfg.exe 在win64位系统下设置32位程序使用的系统DSN要用c:\windows\syswow64\odbcad32.exe 64 位 Windows 平台注意点之文件系统重定向 http://www.cnblogs.com/jiake/p/4981555.html 64 位 Windows 平台注意点之注册表重定向 http://www.cnblogs.com/jiake/p/4956218.html
败落 2017-09-04
  • 打赏
  • 举报
回复
引用 4 楼 zhao4zhong1 的回复:
请严格区分32/64位环境。
现在我编译的是32位程序,运行环境是64位,请问一下这样会有什么问题?能否大概讲解一下原理,谢谢了。
赵4老师 2017-09-02
  • 打赏
  • 举报
回复
请严格区分32/64位环境。
败落 2017-09-01
  • 打赏
  • 举报
回复
引用 1 楼 zhao4zhong1 的回复:
搜“Session0穿透”? 用调试器(OD,WINDBG等)调试服务程序 To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ProgramName The ProgramName is the image file for the service application you are debugging. Do not specify a path. For example, the ProgramName might look like MyService.exe. Under this key create a string data value called Debugger. The value of this string should be set to the full path of the debugger that will be used. For example, c:\Debuggers\windbg.exe In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop. This again requires modifying a registry key: you must bitwise-or the type entry for your service with 0x100 (this is the value for SERVICE_INTERACTIVE_PROCESS according to Winnt.h). The exact location and name of this registry entry varies. For example: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyServiceKey Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting. Adjusting the timeout involves setting an entry in the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control Under this key, create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that you want the service to wait before timing out. For example, 60,000 is one minute, while 86,400,000 is 24 hours. 设置ServicesPipeTimeout后需要重启系统才生效 Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.) If your service is running with other services in a Service Host Process, you may need to isolate the service into its own Service Host Process.
您好,问题我已经定位到了,并且也做了对比,现在情况是相同的代码,用命令行注册一个服务并且把服务作为一个com组件使用可以成功,用inf文件注册服务,可以成功声明为com却失败了。
败落 2017-09-01
  • 打赏
  • 举报
回复
我重新描述下问题,我的服务是用atl写的,exe服务,编译之后用sc命令或者/service命令可以正常启动,用inf文件安装服务之后启动 CoResumeClassObjects函数返回错误0x80004015,我想知道是否可以用inf文件单独安装服务,以及服务是否可以作为com用inf文件来安装,看起来这个错误好像是和权限有关系,注册com对象已经成功,声明com对象可用可用却失败了,如果不调这个函数,服务可以正常启动,但是我的服务需要作为一个com来被另一个服务使用,所以必须要调用。
赵4老师 2017-08-29
  • 打赏
  • 举报
回复
搜“Session0穿透”? 用调试器(OD,WINDBG等)调试服务程序 To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ProgramName The ProgramName is the image file for the service application you are debugging. Do not specify a path. For example, the ProgramName might look like MyService.exe. Under this key create a string data value called Debugger. The value of this string should be set to the full path of the debugger that will be used. For example, c:\Debuggers\windbg.exe In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop. This again requires modifying a registry key: you must bitwise-or the type entry for your service with 0x100 (this is the value for SERVICE_INTERACTIVE_PROCESS according to Winnt.h). The exact location and name of this registry entry varies. For example: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyServiceKey Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting. Adjusting the timeout involves setting an entry in the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control Under this key, create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that you want the service to wait before timing out. For example, 60,000 is one minute, while 86,400,000 is 24 hours. 设置ServicesPipeTimeout后需要重启系统才生效 Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.) If your service is running with other services in a Service Host Process, you may need to isolate the service into its own Service Host Process.

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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