Skip to content

Commit b6d3858

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/cpp-docs-pr (branch live)
2 parents fe3f776 + e7226c8 commit b6d3858

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

docs/cpp/declspec.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
description: "Learn more about: `__declspec`"
33
title: "__declspec"
4-
ms.date: 03/01/2022
4+
ms.date: 1/14/2025
55
f1_keywords: ["__declspec_cpp", "__declspec", "_declspec"]
66
helpviewer_keywords: ["__declspec keyword [C++]"]
77
---
88
# `__declspec`
99

1010
**Microsoft Specific**
1111

12-
The extended attribute syntax for specifying storage-class information uses the **`__declspec`** keyword, which specifies that an instance of a given type is to be stored with a Microsoft-specific storage-class attribute listed below. Examples of other storage-class modifiers include the **`static`** and **`extern`** keywords. However, these keywords are part of the ANSI specification of the C and C++ languages, and as such aren't covered by extended attribute syntax. The extended attribute syntax simplifies and standardizes Microsoft-specific extensions to the C and C++ languages.
12+
The extended attribute syntax for specifying storage-class information uses the `__declspec` keyword, which specifies that an instance of a given type is to be stored with a Microsoft-specific storage-class attribute listed below. Examples of other storage-class modifiers include the `static` and `extern` keywords. However, these keywords are part of the ANSI specification of the C and C++ languages, and as such aren't covered by extended attribute syntax. The extended attribute syntax simplifies and standardizes Microsoft-specific extensions to the C and C++ languages.
1313

1414
## Grammar
1515

@@ -30,6 +30,7 @@ The extended attribute syntax for specifying storage-class information uses the
3030
 **`dllimport`**\
3131
 **`dllexport`**\
3232
 **`empty_bases`**\
33+
 **`hybrid_patchable`**\
3334
 **`jitintrinsic`**\
3435
 **`naked`**\
3536
 **`noalias`**\

docs/cpp/hybrid-patchable.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
description: "Learn more about: hybrid_patchable (C++)"
3+
title: "hybrid_patchable (C++)"
4+
ms.date: 1/15/2025
5+
f1_keywords: ["hybrid_patchable"]
6+
helpviewer_keywords: ["__declspec keyword [C++], hybrid_patchable", "hybrid_patchable __declspec keyword"]
7+
---
8+
# `hybrid_patchable` (C++)
9+
10+
**Microsoft Specific**
11+
12+
Use `__declspec(hybrid_patchable)` to mark a function as a hybrid patchable function. This attribute generates a fast-forward sequence. Fast-forward sequences are small x64 functions which contain no real logic, and tail-call the real Arm64EC function. Because fast-forward sequences are primarily used for hooking, if they are unaltered, execution is transferred directly to the Arm64EC function.
13+
14+
## Syntax
15+
16+
> `__declspec(hybrid_patchable)`
17+
18+
## Remarks
19+
20+
`__declspec(hybrid_patchable)` is an ARM64EC-only feature.
21+
22+
**Example:**
23+
24+
```cpp
25+
__declspec(hybrid_patchable) int Example()
26+
{
27+
return 1;
28+
}
29+
```
30+
31+
Generates the following fast-forward sequence:
32+
33+
```
34+
EXP+#Example:
35+
00000001400CE000: 48 8B C4 mov rax,rsp
36+
00000001400CE003: 48 89 58 20 mov qword ptr [rax+20h],rbx
37+
00000001400CE007: 55 push rbp
38+
00000001400CE008: 5D pop rbp
39+
00000001400CE009: E9 BA 7A F3 FF jmp #Example
40+
00000001400CE00E: CC int 3
41+
00000001400CE00F: CC int 3
42+
```
43+
44+
**END Microsoft Specific**
45+
46+
## See also
47+
48+
[`__declspec`](../cpp/declspec.md)\
49+
[Fast-Forward sequences](/windows/arm/arm64ec-abi#fast-forward-sequences)

docs/cpp/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ items:
696696
href: ../cpp/using-dllimport-and-dllexport-in-cpp-classes.md
697697
- name: empty_bases
698698
href: ../cpp/empty-bases.md
699+
- name: hybrid_patchable
700+
href: ../cpp/hybrid-patchable.md
699701
- name: jitintrinsic
700702
href: ../cpp/jitintrinsic.md
701703
- name: naked

0 commit comments

Comments
 (0)