ZwTerminateProcess failed with [DllImport]
I just want to use ZwTerminateProcess() native function through my C# Application.
I've been written this part of code :
Code:
[DllImport("ntdll.dll")]
public static extern NtStatus ZwTerminateProcess(
[In] [Optional] IntPtr ProcessHandle,
[In] NtStatus ExitStatus
);
but the compiler issues some error code :
Code:
Error 2 The type or namespace name 'NtStatus' could not be found (are you missing a using directive or an assembly reference?)
how Can I import this function ?
Re: ZwTerminateProcess failed with [DllImport]
There's really no need to try to pinvoke to a kernel mode api when in user mode.
If you are trying to terminate a project, you can use the Process class methods or pinvoke to TerminateProcess api.
Re: ZwTerminateProcess failed with [DllImport]
It's just for learning purpose dear dear arjay, I know what you are saying :)
may help me?
Re: ZwTerminateProcess failed with [DllImport]
All you have to do is to define NtStatus.
Re: ZwTerminateProcess failed with [DllImport]
I think if found the answer, I should define it as :
typedef int NTSTATUS
how to add this to C#?
Re: ZwTerminateProcess failed with [DllImport]
Quote:
Originally Posted by
escap3
I think if found the answer, I should define it as :
typedef int NTSTATUS
how to add this to C#?
I don't think you have to define that. Just treat it as an 'int' (i.e. instead of using NTSTATUS use Int32 or int).