> For the complete documentation index, see [llms.txt](https://docs.hyperdbg.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperdbg.org/using-hyperdbg/kernel-mode-debugging/examples/events/triggering-special-instructions.md).

# Triggering Special Instructions

There are special instructions in x86 and AMD64 processors that might be configured to cause vm-exits when executed; thus, we can intercept them.

For example, we might be interested in the execution of I/O instructions (IN & OUT). We can monitor memory-mapped I/O using the [!monitor](https://docs.hyperdbg.org/commands/extension-commands/monitor) command, but for I/O mapped devices, we can use [!ioin](https://docs.hyperdbg.org/commands/extension-commands/ioin) and [!ioout](https://docs.hyperdbg.org/commands/extension-commands/ioout) commands.

{% hint style="danger" %}
Do not try to monitor all I/O ports or the I/O port for the serial device connected to the debugger if you are operating on **Debugger Mode**.
{% endhint %}

Using these commands, we can monitor I/O ports. For example, let's say we want to monitor the I/O port `0x3f8` for `IN`instruction.

```c
HyperDbg> !ioin 0x3f8
```

If we want to monitor port `0x3f8` for `OUT` instruction, we use the following command.

```c
HyperDbg> !ioout 0x3f8
```

Let's intercept another instruction.

We know that **CPUID** is an important instruction that tries to get processor features to see if a processor supports a special feature or not.

For example, we want to intercept all the CPUIDs that a process with process ID **0x490** tries to execute.

```c
HyperDbg> !cpuid pid 490
```

You can also break on the execution of other instructions like:

* **RDTSC** and **RDTSCP** using [!tsc](https://docs.hyperdbg.org/commands/extension-commands/tsc) command
* **RDPMC** using [!pmc](https://docs.hyperdbg.org/commands/extension-commands/pmc) command
* **VMCALL**s using [!vmcall](https://docs.hyperdbg.org/commands/extension-commands/vmcall) command


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.hyperdbg.org/using-hyperdbg/kernel-mode-debugging/examples/events/triggering-special-instructions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
