Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this correct? #2

Open
shrikantbmali opened this issue Mar 23, 2021 · 2 comments
Open

Is this correct? #2

shrikantbmali opened this issue Mar 23, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@shrikantbmali
Copy link

shrikantbmali commented Mar 23, 2021

I'd expect the DebugPort to have a valid pointer if the status was successful?
Which also then indicates the debugger port is active?

if (DebugPort == new IntPtr(-1))

@Mecanik
Copy link
Owner

Mecanik commented Mar 23, 2021

Yes, that's correct; sorry about that.

I might have done small mistakes due to being rushed to write it... please use it with a grain of salt and always test.

Soon, I will update the code with improved checks, more checks and system calls.

@Mecanik Mecanik added the bug Something isn't working label Mar 23, 2021
@vibheksoni
Copy link

vibheksoni commented Jul 21, 2023

private static int CheckDebugPort()
            {
                NtStatus status;
                IntPtr DebugPort = IntPtr.Zero;
                int ReturnLength;

                unsafe
                {
                    status = NtQueryInformationProcess(System.Diagnostics.Process.GetCurrentProcess().Handle, PROCESSINFOCLASS.ProcessDebugPort, out DebugPort, Marshal.SizeOf(DebugPort), out ReturnLength);

                    if (status == NtStatus.Success && DebugPort != IntPtr.Zero)
                    {
                        return 1;
                    }
                }

                return 0;
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants