8typedef signed char int8_t;
11typedef long long int64_t;
12typedef unsigned char uint8_t;
13typedef unsigned short uint16_t;
14typedef unsigned int uint32_t;
15typedef unsigned long long uint64_t;
19#define UINT32_MAX ((uint32_t)0xFFFFFFFF)
32#define UBPF_STACK_SIZE 512
34#define IMMEDIATE(X) (int32_t)(X)
35#define OFFSET(X) (int16_t)(X)
36#define POINTER(X) (uint64_t)(X)
38#define READ_ONCE_64(destination, source, offset) \
39 destination = (uint64_t)ReadNoFence64((volatile const long long*)(source + offset))
40#define READ_ONCE_32(destination, source, offset) \
41 destination = (uint32_t)ReadNoFence((volatile const long*)(source + offset))
42#define READ_ONCE_16(destination, source, offset) \
43 destination = (uint16_t)ReadNoFence16((volatile const short*)(source + offset))
44#define READ_ONCE_8(destination, source, offset) \
45 destination = (uint8_t)ReadNoFence8((volatile const char*)(source + offset))
48#define READ_ONCE_S32(destination, source, offset) \
49 destination = (uint64_t)(int64_t)(int32_t)ReadNoFence((volatile const long*)(source + offset))
50#define READ_ONCE_S16(destination, source, offset) \
51 destination = (uint64_t)(int64_t)(int16_t)ReadNoFence16((volatile const short*)(source + offset))
52#define READ_ONCE_S8(destination, source, offset) \
53 destination = (uint64_t)(int64_t)(int8_t)ReadNoFence8((volatile const char*)(source + offset))
55#define WRITE_ONCE_64(destination, source, offset) \
56 WriteNoFence64((volatile long long*)(destination + offset), (long long)source)
57#define WRITE_ONCE_32(destination, source, offset) WriteNoFence((volatile long*)(destination + offset), (long)source)
58#define WRITE_ONCE_16(destination, source, offset) \
59 WriteNoFence16((volatile short*)(destination + offset), (short)source)
60#define WRITE_ONCE_8(destination, source, offset) WriteNoFence8((volatile char*)(destination + offset), (char)source)
63#define htobe16(X) swap16(X)
64#define htobe32(X) swap32(X)
65#define htobe64(X) swap64(X)
72#if !defined(UNREFERENCED_PARAMETER)
73#define UNREFERENCED_PARAMETER(P) (P)
76 typedef uint64_t (*
helper_function_t)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t,
void*);
244 _Out_
size_t* count);
247 _Out_
size_t* count);
249 _Outptr_result_buffer_maybenull_(*
size)
const uint8_t**
hash,
254 _Out_
size_t* count);
257 _Out_
size_t* count);
269 return value << 8 | value >> 8;
281 return swap16(value >> 16) | ((uint32_t)
swap16(value & ((1 << 16) - 1))) << 16;
293 return swap32(value >> 32) | ((uint64_t)
swap32(value & ((1ull << 32ull) - 1))) << 32;
296#define EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION 1
297#define EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(helper_function_entry_t, name)
298#define EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION_TOTAL_SIZE sizeof(helper_function_entry_t)
299#define EBPF_NATIVE_HELPER_FUNCTION_ENTRY_HEADER \
300 {EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION, \
301 EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION_SIZE, \
302 EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION_TOTAL_SIZE}
304#define EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION 1
305#define EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION_SIZE \
306 EBPF_SIZE_INCLUDING_FIELD(helper_function_data_t, tail_call)
307#define EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION_TOTAL_SIZE sizeof(helper_function_data_t)
308#define EBPF_NATIVE_HELPER_FUNCTION_DATA_HEADER \
309 {EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION, \
310 EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION_SIZE, \
311 EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION_TOTAL_SIZE}
313#define EBPF_NATIVE_BTF_RESOLVED_FUNCTION_ENTRY_CURRENT_VERSION 1
314#define EBPF_NATIVE_BTF_RESOLVED_FUNCTION_ENTRY_CURRENT_VERSION_SIZE \
315 EBPF_SIZE_INCLUDING_FIELD(btf_resolved_function_entry_t, module_guid)
316#define EBPF_NATIVE_BTF_RESOLVED_FUNCTION_ENTRY_CURRENT_VERSION_TOTAL_SIZE sizeof(btf_resolved_function_entry_t)
317#define EBPF_NATIVE_BTF_RESOLVED_FUNCTION_ENTRY_HEADER \
318 {EBPF_NATIVE_BTF_RESOLVED_FUNCTION_ENTRY_CURRENT_VERSION, \
319 EBPF_NATIVE_BTF_RESOLVED_FUNCTION_ENTRY_CURRENT_VERSION_SIZE, \
320 EBPF_NATIVE_BTF_RESOLVED_FUNCTION_ENTRY_CURRENT_VERSION_TOTAL_SIZE}
322#define EBPF_NATIVE_BTF_RESOLVED_FUNCTION_DATA_CURRENT_VERSION 1
323#define EBPF_NATIVE_BTF_RESOLVED_FUNCTION_DATA_CURRENT_VERSION_SIZE \
324 EBPF_SIZE_INCLUDING_FIELD(btf_resolved_function_data_t, address)
325#define EBPF_NATIVE_BTF_RESOLVED_FUNCTION_DATA_CURRENT_VERSION_TOTAL_SIZE sizeof(btf_resolved_function_data_t)
326#define EBPF_NATIVE_BTF_RESOLVED_FUNCTION_DATA_HEADER \
327 {EBPF_NATIVE_BTF_RESOLVED_FUNCTION_DATA_CURRENT_VERSION, \
328 EBPF_NATIVE_BTF_RESOLVED_FUNCTION_DATA_CURRENT_VERSION_SIZE, \
329 EBPF_NATIVE_BTF_RESOLVED_FUNCTION_DATA_CURRENT_VERSION_TOTAL_SIZE}
331#define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION 1
332#define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(map_entry_t, map_flags)
333#define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_TOTAL_SIZE sizeof(map_entry_t)
334#define EBPF_NATIVE_MAP_ENTRY_HEADER \
335 {EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION, \
336 EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_SIZE, \
337 EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_TOTAL_SIZE}
339#define EBPF_NATIVE_MAP_DATA_CURRENT_VERSION 1
340#define EBPF_NATIVE_MAP_DATA_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(map_data_t, array_data)
341#define EBPF_NATIVE_MAP_DATA_CURRENT_VERSION_TOTAL_SIZE sizeof(map_data_t)
342#define EBPF_NATIVE_MAP_DATA_HEADER \
343 {EBPF_NATIVE_MAP_DATA_CURRENT_VERSION, \
344 EBPF_NATIVE_MAP_DATA_CURRENT_VERSION_SIZE, \
345 EBPF_NATIVE_MAP_DATA_CURRENT_VERSION_TOTAL_SIZE}
347#define EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION 1
348#define EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION_SIZE \
349 EBPF_SIZE_INCLUDING_FIELD(program_entry_t, btf_resolved_function_count)
350#define EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION_TOTAL_SIZE sizeof(program_entry_t)
351#define EBPF_NATIVE_PROGRAM_ENTRY_HEADER \
352 {EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION, \
353 EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION_SIZE, \
354 EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION_TOTAL_SIZE}
356#define EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION 1
357#define EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION_SIZE \
358 EBPF_SIZE_INCLUDING_FIELD(program_runtime_context_t, btf_resolved_function_data)
359#define EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION_TOTAL_SIZE sizeof(program_runtime_context_t)
360#define EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_HEADER \
361 {EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION, \
362 EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION_SIZE, \
363 EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION_TOTAL_SIZE}
365#define EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION 1
366#define EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(map_initial_values_t, values)
367#define EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION_TOTAL_SIZE sizeof(map_initial_values_t)
368#define EBPF_NATIVE_MAP_INITIAL_VALUES_HEADER \
369 {EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION, \
370 EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION_SIZE, \
371 EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION_TOTAL_SIZE}
373#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION 1
374#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION_SIZE \
375 EBPF_SIZE_INCLUDING_FIELD(global_variable_section_info_t, initial_data)
376#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION_TOTAL_SIZE sizeof(global_variable_section_info_t)
377#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_HEADER \
378 {EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION, \
379 EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION_SIZE, \
380 EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION_TOTAL_SIZE}
382#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION 1
383#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION_SIZE \
384 EBPF_SIZE_INCLUDING_FIELD(global_variable_section_data_t, address_of_map_value)
385#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION_TOTAL_SIZE sizeof(global_variable_section_data_t)
386#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_HEADER \
387 {EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION, \
388 EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION_SIZE, \
389 EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION_TOTAL_SIZE}
391#define EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION 1
392#define EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(metadata_table_t, map_initial_values)
393#define EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION_TOTAL_SIZE sizeof(metadata_table_t)
394#define EBPF_NATIVE_METADATA_TABLE_HEADER \
395 {EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION, \
396 EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION_SIZE, \
397 EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION_TOTAL_SIZE}
struct _program_runtime_context program_runtime_context_t
struct _global_variable_section_info global_variable_section_info_t
struct _helper_function_data helper_function_data_t
uint64_t swap64(uint64_t value)
Inline function used to implement the 64 bit EBPF_OP_LE/EBPF_OP_BE instruction.
Definition bpf2c.h:291
uint64_t(* helper_function_t)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, void *)
Definition bpf2c.h:76
struct _map_initial_values map_initial_values_t
Map initial values. This structure contains the initial values for a map. The values are used to init...
struct _ebpf_native_map_definition ebpf_native_map_definition_t
Stable map definition embedded in native module metadata.
struct _map_entry map_entry_t
Map entry. This structure contains the address of the map and the map definition. The address is writ...
struct _helper_function_entry helper_function_entry_t
Helper function entry. This structure defines a helper function entry in the metadata table....
uint32_t swap32(uint32_t value)
Inline function used to implement the 32 bit EBPF_OP_LE/EBPF_OP_BE instruction.
Definition bpf2c.h:279
struct _btf_resolved_function_data btf_resolved_function_data_t
struct _global_variable_section_data global_variable_section_data_t
uint16_t swap16(uint16_t value)
Inline function used to implement the 16 bit EBPF_OP_LE/EBPF_OP_BE instruction.
Definition bpf2c.h:267
struct _program_entry program_entry_t
Program entry. This structure contains the address of the program and additional information about th...
struct _btf_resolved_function_entry btf_resolved_function_entry_t
struct _bpf2c_version bpf2c_version_t
Version information for the SDK used to compile the native module. This structure contains the versio...
struct _metadata_table metadata_table_t
Metadata table for a module. This structure is returned by the module's metadata function,...
struct _map_data map_data_t
This file contains eBPF definitions common to eBPF programs, core execution engine as well as eBPF AP...
enum bpf_map_type ebpf_map_type_t
enum ebpf_pin_type ebpf_pin_type_t
Pinning type for eBPF objects. The values should match the LIBBPF_PIN_* pin types defined in libbpf.
ebpf_extension_header_t ebpf_native_module_header_t
Header of an eBPF native module data structure. Every eBPF native module data structure must start wi...
Definition ebpf_structs.h:523
GUID ebpf_attach_type_t
Definition ebpf_windows.h:67
GUID ebpf_program_type_t
Definition ebpf_windows.h:66
uint8_t GUID[16]
Definition ebpf_windows.h:12
Version information for the SDK used to compile the native module. This structure contains the versio...
Definition bpf2c.h:228
uint32_t major
Definition bpf2c.h:229
uint32_t revision
Definition bpf2c.h:231
uint32_t minor
Definition bpf2c.h:230
ebpf_native_module_header_t header
Definition bpf2c.h:107
helper_function_t address
Definition bpf2c.h:108
_Field_z_ const char * name
Definition bpf2c.h:101
GUID module_guid
Definition bpf2c.h:102
ebpf_native_module_header_t header
Definition bpf2c.h:100
Stable map definition embedded in native module metadata.
Definition bpf2c.h:117
uint32_t id
Definition bpf2c.h:124
uint32_t key_size
Definition bpf2c.h:119
uint32_t inner_map_idx
Definition bpf2c.h:122
uint32_t max_entries
Definition bpf2c.h:121
uint32_t value_size
Definition bpf2c.h:120
uint32_t inner_id
Definition bpf2c.h:125
ebpf_map_type_t type
Definition bpf2c.h:118
ebpf_pin_type_t pinning
Definition bpf2c.h:123
unsigned char * address_of_map_value
Definition bpf2c.h:178
ebpf_native_module_header_t header
Definition bpf2c.h:177
size_t size
Definition bpf2c.h:171
const void * initial_data
Definition bpf2c.h:172
const char * name
Definition bpf2c.h:170
ebpf_native_module_header_t header
Definition bpf2c.h:169
bool tail_call
Definition bpf2c.h:95
helper_function_t address
Definition bpf2c.h:94
ebpf_native_module_header_t header
Definition bpf2c.h:93
Helper function entry. This structure defines a helper function entry in the metadata table....
Definition bpf2c.h:85
const char * name
Definition bpf2c.h:88
uint32_t helper_id
Definition bpf2c.h:87
ebpf_native_module_header_t header
Definition bpf2c.h:86
uintptr_t address
Definition bpf2c.h:149
uint8_t * array_data
Direct pointer to array map data (NULL for non-array maps).
Definition bpf2c.h:150
ebpf_native_module_header_t header
Definition bpf2c.h:148
Map entry. This structure contains the address of the map and the map definition. The address is writ...
Definition bpf2c.h:134
uint32_t map_flags
Definition bpf2c.h:143
uint64_t zero_marker[2]
Definition bpf2c.h:138
ebpf_native_map_definition_t definition
Definition bpf2c.h:141
ebpf_native_module_header_t header
Definition bpf2c.h:140
const char * name
Definition bpf2c.h:142
Map initial values. This structure contains the initial values for a map. The values are used to init...
Definition bpf2c.h:160
const char ** values
Definition bpf2c.h:164
size_t count
Definition bpf2c.h:163
ebpf_native_module_header_t header
Definition bpf2c.h:161
const char * name
Definition bpf2c.h:162
Program entry. This structure contains the address of the program and additional information about th...
Definition bpf2c.h:195
uint16_t helper_count
Number of helper functions used by the program.
Definition bpf2c.h:209
uint64_t zero
Definition bpf2c.h:199
const char * program_info_hash_type
Type of the program info hash.
Definition bpf2c.h:215
uint16_t referenced_map_count
Number of maps referenced by the program.
Definition bpf2c.h:207
const char * program_name
Name of the program.
Definition bpf2c.h:205
size_t bpf_instruction_count
Number of BPF instructions in the program.
Definition bpf2c.h:210
uint64_t(* function)(void *, const program_runtime_context_t *)
Address of the program.
Definition bpf2c.h:202
ebpf_native_module_header_t header
Definition bpf2c.h:201
size_t program_info_hash_length
Length of the program info hash.
Definition bpf2c.h:214
uint16_t * referenced_map_indices
List of map indices referenced by the program.
Definition bpf2c.h:206
uint16_t btf_resolved_function_count
Number of BTF-resolved functions used by the program.
Definition bpf2c.h:219
ebpf_attach_type_t * expected_attach_type
Expected attach type of the program.
Definition bpf2c.h:212
const char * pe_section_name
Name of the PE section containing the program.
Definition bpf2c.h:203
const uint8_t * program_info_hash
Hash of the program info.
Definition bpf2c.h:213
const char * section_name
Name of the section containing the program.
Definition bpf2c.h:204
_Field_size_(btf_resolved_function_count) btf_resolved_function_entry_t *btf_resolved_functions
ebpf_program_type_t * program_type
Type of the program.
Definition bpf2c.h:211
helper_function_entry_t * helpers
List of helper functions used by the program.
Definition bpf2c.h:208
map_data_t * map_data
Definition bpf2c.h:185
global_variable_section_data_t * global_variable_section_data
Definition bpf2c.h:186
helper_function_data_t * helper_data
Definition bpf2c.h:184
ebpf_native_module_header_t header
Definition bpf2c.h:183
btf_resolved_function_data_t * btf_resolved_function_data
Definition bpf2c.h:187