Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 16-Apr-15 6:43am
v3
Comments
ZurdoDev 15-Apr-15 15:56pm    
Access denied will generally mean a permissions issue so I'd keep investigating that direction.
LLAKW 15-Apr-15 16:02pm    
Thank you very much for the reply. I'll look further into that.
Sergey Alexandrovich Kryukov 15-Apr-15 16:27pm    
What happens if you run as administrator?
Where is your C# declaration of MiniDumpWriteDump (P/Invoke)?
—SA
LLAKW 15-Apr-15 16:47pm    
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
Sergey Alexandrovich Kryukov 15-Apr-15 18:24pm    
Please see Solution 1.
—SA

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900