# US 2022/0283864 A1 · Advanced memory tracking for kernel mode drivers

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2022/0283864 A1
- Document ID: US20220283864A1
- Status: Published application
- Kind: A1
- Application number: 17/192,546
- Filed: 2021-03-04
- Published: 2022-09-08
- Earliest claimed: 2021-03-04
- Assignees: Microsoft Technology Licensing, LLC
- Applicants: Microsoft Technology Licensing, LLC
- Inventors: Hyuk Joon KWON; Sandeep REPAKA; Andrew M. KLUEMKE; Jakob F. LICHTENBERG; Sebastian LERNER; Matthew John WOOLMAN; Swati KANCHAN
- Web page: https://patentgrep.com/patent/US20220283864A1

## CPC

- G06F 9/5016: {the resource being the memory}
- G06F 9/5022: {Mechanisms to release resources}
- G06F 11/073: {in a memory management context, e.g. virtual memory or cache management (memory management G06F12/00; testing of static memory units G11C29/00)}
- G06F 11/0751: {Error or fault detection not based on redundancy (power supply failures G06F1/30; network fault management H04L41/06)}
- G06F 11/3037: {where the computing system component is a memory, e.g. virtual memory, cache (accessing, addressing or allocating within memory systems or architectures G06F12/00; checking stores for correct operation G11C29/00)}
- G06F 11/3442: {for planning or managing the needed capacity}
- G06F 11/3466: {Performance evaluation by tracing or monitoring}
- G06F 11/3471: {Address tracing}
- G06F 2209/508: Monitor
- G06F 2209/542: Intercept
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Described are examples for tracking memory usage of a driver. A memory allocation request related to the driver to allocate a portion of memory for the driver can be traced in a kernel mode of an operating system. One or more associated allocation parameters can be recorded, and an allocation history of the driver over a period of time can be reported during execution of the driver and based on the one or more allocation parameters indicated by the memory allocation request.

## Claims

### Claim 1

A computer-implemented method for tracking memory usage of a driver, comprising:
tracing, in a kernel mode of an operating system, a memory allocation request related to the driver to allocate a portion of memory for the driver;
recording, based on tracing the memory allocation request, one or more allocation parameters indicated by the memory allocation request; and
reporting, during execution of the driver and based on the one or more allocation parameters indicated by the memory allocation request, an allocation history of the driver over a period of time.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, further comprising:
tracing, in the kernel mode of the operating system, a memory free related to the driver to free the portion of memory for the driver; and
recording, based on tracing the memory free, one or more free parameters of the memory free,
wherein reporting the allocation history of the driver over the period of time is further based on the one or more free parameters.

### Claim 3 (depends on 2)

The computer-implemented method of claim 2, wherein the memory free is traced from a pool manager of the operating system.

### Claim 4 (depends on 2)

The computer-implemented method of claim 2, wherein the allocation history includes at least an allocation count of a number of allocations requested by the driver over the period of time, an amount of memory allocated by the driver over the period of time, a number of memory frees related to the driver over the period of time, and an amount of memory freed by the driver over the period of time.

### Claim 5 (depends on 1)

The computer-implemented method of claim 1, further comprising detecting, during execution of the driver, one or more memory allocation requests by the driver without a corresponding memory free, wherein reporting the allocation history includes reporting an indication of the one or more memory allocation requests.

### Claim 6 (depends on 1)

The computer-implemented method of claim 1, wherein reporting the allocation history of the driver over the period of time is part of generating multiple snapshots of the allocation history the driver over multiple periods of time.

### Claim 7 (depends on 6)

The computer-implemented method of claim 6, further comprising:
detecting, during the execution of the driver and based on the multiple snapshots, a pattern of memory allocation requests, including the memory allocation request, traced from the driver without corresponding memory frees over the period of time;
determining that the pattern indicates a potential memory leak; and
reporting an indication of the potential memory leak.

### Claim 8 (depends on 7)

The computer-implemented method of claim 7, wherein reporting the indication of the potential memory leak includes reporting the one or more allocation parameters of at least two of the multiple snapshots that correspond to the pattern that indicates the potential memory leak.

### Claim 9 (depends on 1)

The computer-implemented method of claim 1, wherein tracing the memory allocation request includes replacing a first function call for the memory allocation request with a second function call provided by a driver verifier to initiate the memory allocation request to the driver verifier, wherein tracing the memory allocation request is performed by the driver verifier.

### Claim 10 (depends on 9)

The computer-implemented method of claim 9, wherein replacing the first function call with the second function call includes modifying an import address table (TAT) to replace the first function call with the second function call.

### Claim 11

A device for tracking memory usage of a driver, comprising:
a memory storing one or more parameters or instructions for executing an operating system and the driver that facilitates communicating with hardware or other devices; and
at least one processor coupled to the memory, wherein the at least one processor is configured to:
trace, in a kernel mode of the operating system, a memory allocation request related to the driver to allocate a portion of memory for the driver;
record, based on tracing the memory allocation request, one or more allocation parameters indicated by the memory allocation request; and
report, during execution of the driver and based on the one or more allocation parameters indicated by the memory allocation request, an allocation history of the driver over a period of time.

### Claim 12 (depends on 11)

The device of claim 11, wherein the at least one processor is further configured to:
trace, in the kernel mode of the operating system, a memory free related to the driver to free the portion of memory for the driver; and
record, based on tracing the memory free, one or more free parameters of the memory free,
wherein reporting the allocation history of the driver over the period of time is further based on the one or more free parameters.

### Claim 13 (depends on 12)

The device of claim 12, wherein the memory free is traced from a pool manager of the operating system.

### Claim 14 (depends on 12)

The device of claim 12, wherein the allocation history includes at least an allocation count of a number of allocations requested by the driver over the period of time, an amount of memory allocated by the driver over the period of time, a number of memory frees related to the driver over the period of time, and an amount of memory freed by the driver over the period of time.

### Claim 15 (depends on 11)

The device of claim 11, wherein the at least one processor is further configured to detect, during execution of the driver, one or more memory allocation requests by the driver without a corresponding memory free, wherein the at least one processor is configured to report the allocation history including an indication of the one or more memory allocation requests.

### Claim 16 (depends on 11)

The device of claim 11, wherein the at least one processor is configured to report the allocation history of the driver over the period of time including generating multiple snapshots of the allocation history the driver over multiple periods of time.

### Claim 17 (depends on 16)

The device of claim 16, wherein the at least one processor is further configured to:
detect, during the execution of the driver and based on the multiple snapshots, a pattern of memory allocation requests, including the memory allocation request, traced from the driver without corresponding memory frees over the period of time;
determine that the pattern indicates a potential memory leak; and
report an indication of the potential memory leak.

### Claim 18 (depends on 11)

The device of claim 11, wherein the at least one processor is configured to trace the memory allocation request at least in part by replacing a first function call for the memory allocation request with a second function call provided by a driver verifier to initiate the memory allocation request to the driver verifier.

### Claim 19

A computer-readable medium, comprising code executable by one or more processors for tracking memory usage of a driver, the code comprising code for:
tracing, in a kernel mode of an operating system, a memory allocation request related to the driver to allocate a portion of memory for the driver;
recording, based on tracing the memory allocation request, one or more allocation parameters indicated by the memory allocation request; and
reporting, during execution of the driver and based on the one or more allocation parameters indicated by the memory allocation request, an allocation history of the driver over a period of time.

### Claim 20 (depends on 19)

The computer-readable medium of claim 19, further comprising code for:
tracing, in the kernel mode of the operating system, a memory free related to the driver to free the portion of memory for the driver; and
recording, based on tracing the memory free, one or more free parameters of the memory free,
wherein the code for reporting reports the allocation history of the driver over the period of time is further based on the one or more free parameters.
