C#对MiniDumpWriteDump的调用失败并显示“Access is denied”。可能是什么问题呢。 [英] C# The call to MiniDumpWriteDump is failing with "Access is denied". What could be the problem.

查看:246
本文介绍了C#对MiniDumpWriteDump的调用失败并显示“Access is denied”。可能是什么问题呢。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在64位系统上。我们正在运行服务,并且当时正在尝试编写服务的小型转储。登录的用户拥有管理员权限...该服务正在该帐户下运行。



电话是这样的:



代码页顶部的声明...

[DllImport(Dbghelp.dll)]

static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId,IntPtr hFile,int DumpType,IntPtr exParam,IntPtr UserStreamParam,IntPtr CallBackParam);



并致电...



MiniDumpWriteDump(processHandle,(uint)process.Id,file.SafeFileHandle.DangerousGetHandle(),MiniDumpWithFullMemory,IntPtr.Zero,IntPtr.Zero,IntPtr.Zero);



这是在启用SEDebugPrivilege之后(不确定我是否必须,但试过了)

此外,在我正在进行的服务上尝试了OpenProcess。



****

调用OpenProcess总是在这个系统上返回0 ...看来我可能确实在服务上有访问问题,但是在哪里是配置?非常感谢大家:D



但是在访问被拒绝的情况下总是在MiniDump上捕获异常。

任何人都有任何信息或关于我做错了什么的想法?

谢谢,如果我需要添加任何东西,请告诉我。

解决方案

< blockquote class =FQ>

LLAKW写道:



感谢您的回复。我们是通过命令行执行此操作,因此我需要在命令行上设置以管理员身份运行的内容吗?或者我是否需要在exe上检查运行管理员?我会用声明更新原始问题。

非常感谢

当然。



注意记录管理员是不够的,除非你使用的是没有UAC的过时的Windows XP。



对我来说,最简单的方法是创建一个批处理文件使用您用于应用程序启动的命令行,并使用上下文菜单项以管理员身份运行从shell(任何文件管理器,例如资源管理器)运行它。您可以将if与应用程序本身一起使用,或者与整个文件管理器一起使用,以便从该文件管理器进程实例启动的所有应用程序也将以作为管理员启动。它将显示UAC确认对话框,因此您需要确认您的协议以使用提升的权限启动应用程序。无法绕过UAC对话框,因为它可能不安全。



有关详细信息,请参阅:http://www.sevenforums.com/tutorials/11841-run-administrator.html



另请参阅: http://en.wikipedia.org/wiki/User_Account_Control



对不起,这只是答案的一部分,只回答问题的评论。但这是你在继续之前需要知道的重要事项。



-SA


This is on a 64 bit system. We have a service running and an attempt is being made at writing a mini dump of the service at that time. The user logged on has admin rights... and the service is running under that account.

The call is like this:

Declaration at top of code page...
[DllImport("Dbghelp.dll")]
static extern bool MiniDumpWriteDump(IntPtr hProcess,uint ProcessId, IntPtr hFile, int DumpType, IntPtr exParam, IntPtr UserStreamParam, IntPtr CallBackParam);

and call...

MiniDumpWriteDump(processHandle, (uint)process.Id, file.SafeFileHandle.DangerousGetHandle(), MiniDumpWithFullMemory, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

This is after enabling SEDebugPrivilege (wasn't sure if I had to, but tried that)
Also, tried OpenProcess on the service I am going after.

****
A call to OpenProcess always returns 0 on this system... It seems I may indeed have access problems on the service, but where is that configured? Thanks so much to everyone :D

But always catch the exception on the MiniDump with Access is denied.
Would anyone have any information or ideas on what I am doing wrong?
Thank you, and if I need to add anything, please let me know.

解决方案

LLAKW wrote:


Thank you for the reply as well. We are doing this by command line, so would there be something I need to set on the command line to run as admin? Or would I need maybe to check the run as admin on the exe? And I'll update the original question with the declaration.
Thank you very much

Sure.

Note that being logged as administrator won't be enough, unless you are using obsolete Windows XP which did not have UAC.

To me, the simplest way would be to create a batch file with the command line(s) you are using for application start and run it from the shell (any file manager, for example, such as Explorer) using the context menu item "Run As Administrator". You can use if with the application itself, or, say with the whole file manager, so all the application started from this instance of file manager process will also be started "As Administrator". It will show the UAC confirmation dialog, so you need to confirm your agreement to start the application with elevated privileges. The UAC dialog cannot be bypassed, as it could be unsafe.

For more information, please see: http://www.sevenforums.com/tutorials/11841-run-administrator.html.

See also: http://en.wikipedia.org/wiki/User_Account_Control.

Sorry, this is only a part of the answer, answering only to the comment to the question. But this is something important you need to know before you proceed.

—SA


这篇关于C#对MiniDumpWriteDump的调用失败并显示“Access is denied”。可能是什么问题呢。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆