# Connection

Currently, the only way to communicate to the kernel debugger is over the serial port. For future versions, we will add other IRQL-compatible mechanisms to communicate.

For this purpose, we used **kdserial** from Windows SDK to connect to the debuggee. The connection over the serial port is initialized from the user-mode controller of HyperDbg.

First, we let Windows to initialize the serial port from standard entry points like `CreateFile`. After that, we set the baud-rate and timeout details. We let Windows initialize the handle because this way, we make sure that Windows won't give the handle of this device to any other application and no other application is able to send anything over this port.

The mechanism to pause the debuggee is also implemented in user-mode. It is because we are not trying to handle each pause requests from the debugger in polling mode as this is not an optimized way.

Instead of this, we use the interrupt-mode of the serial device in the user-mode. This way, whenever the debugger needs to pause the debuggee, first it sends a request, and as it's in interrupt-mode, then Windows notifies the user-mode application about the new request from the debugger.

![Debugger Connection](https://1255335821-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M2wWz6ePF27bvsJcWed%2Fuploads%2Fgit-blob-f6689c292ee394f68d6e53be1b9f42ceeebd121e%2Fconnection-illustration.png?alt=media)

If the request is valid, then the user-mode application sends an IOCTL to the kernel, and from that IOCTL, we execute a VMCALL to enter all cores to the vmx-root mode.

In vmx-root mode, we halt all cores, and as the IF flag of RFLAGS is cleared, so no interrupt is allowed and this way, we halt all the cores and check for a new command from the debugger in polling mode.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hyperdbg.org/design/debugger-internals/kernel-debugger/connection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
