Minor cleanup in sample extension (#726)

* Hard code the extension name in only one place
* Change "Test" to "Sample" in various comments

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
This commit is contained in:
Dave Thaler 2022-01-23 21:52:40 -08:00 коммит произвёл GitHub
Родитель 8dc0f5e1b5
Коммит 228d7f6b60
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 44 добавлений и 23 удалений

Просмотреть файл

@ -5,7 +5,7 @@
## Initialize parameters
##
$build_directory=".\x64\Debug"
[System.Collections.ArrayList]$built_files=@( "EbpfCore.sys", "EbpfApi.dll", "ebpfnetsh.dll", "ebpfsvc.exe", "NetEbpfExt.sys", "sample_ebpf_ext.sys", "ucrtbased.dll", "MSVCP140D.dll", "VCRUNTIME140D.dll", "VCRUNTIME140_1D.dll", "bpftool.exe", "bindmonitor.o", "bpf.o", "bpf_call.o", "divide_by_zero.o", "droppacket.o", "droppacket_unsafe.o", "map_in_map.o", "reflect_packet.o", "tail_call.o", "tail_call_bad.o", "tail_call_map.o", "test_sample_ebpf.o", "test_utility_helpers.o")
[System.Collections.ArrayList]$built_files=@( "EbpfCore.sys", "EbpfApi.dll", "ebpfnetsh.dll", "ebpfsvc.exe", "NetEbpfExt.sys", "sample_ebpf_ext.sys", "sample_ext_app.exe", "ucrtbased.dll", "MSVCP140D.dll", "VCRUNTIME140D.dll", "VCRUNTIME140_1D.dll", "bpftool.exe", "bindmonitor.o", "bpf.o", "bpf_call.o", "divide_by_zero.o", "droppacket.o", "droppacket_unsafe.o", "map_in_map.o", "reflect_packet.o", "tail_call.o", "tail_call_bad.o", "tail_call_map.o", "test_sample_ebpf.o", "test_utility_helpers.o")
$destination_directory="C:\Temp"
$error.clear()
$vm="Windows 10 dev environment"

Просмотреть файл

@ -22,7 +22,6 @@
#define EBPF_CORE_DRIVER_NAME L"ebpfcore"
#define EBPF_EXTENSION_DRIVER_BINARY_NAME L"sample_ebpf_ext.sys"
#define EBPF_EXTENSION_DRIVER_NAME L"SampleEbpfExt"
#define EBPF_SERVICE_BINARY_NAME L"ebpfsvc.exe"
#define EBPF_SERVICE_NAME L"ebpfsvc"
@ -31,7 +30,7 @@ static service_install_helper
_ebpf_core_driver_helper(EBPF_CORE_DRIVER_NAME, EBPF_CORE_DRIVER_BINARY_NAME, SERVICE_KERNEL_DRIVER);
static service_install_helper
_ebpf_extension_driver_helper(EBPF_EXTENSION_DRIVER_NAME, EBPF_EXTENSION_DRIVER_BINARY_NAME, SERVICE_KERNEL_DRIVER);
_ebpf_extension_driver_helper(SAMPLE_EBPF_EXT_NAME_W, EBPF_EXTENSION_DRIVER_BINARY_NAME, SERVICE_KERNEL_DRIVER);
static service_install_helper
_ebpf_service_helper(EBPF_SERVICE_NAME, EBPF_SERVICE_BINARY_NAME, SERVICE_WIN32_OWN_PROCESS);

Просмотреть файл

@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT
/**
* @brief Implementation of eBPF Test extension hook and program information NPI providers registration and
* @brief Implementation of eBPF Sample extension hook and program information NPI providers registration and
* unregistration.
*/
@ -23,7 +23,7 @@
// f788ef4a-207d-4dc3-85cf-0f2ea107213c
DEFINE_GUID(EBPF_PROGRAM_TYPE_SAMPLE, 0xf788ef4a, 0x207d, 0x4dc3, 0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c);
// Test Extension helper function addresses table.
// Sample Extension helper function addresses table.
static int64_t
_sample_ebpf_extension_helper_function1(_In_ const sample_program_context_t* context);
static int64_t
@ -48,7 +48,7 @@ static ebpf_extension_data_t _sample_ebpf_extension_program_info_provider_data =
sizeof(_sample_ebpf_extension_program_data),
&_sample_ebpf_extension_program_data};
// Test eBPF Extension Program Information NPI Provider Module GUID: ab3a3a18-b901-4a7e-96ad-034b8ddb24e5
// Sample eBPF Extension Program Information NPI Provider Module GUID: ab3a3a18-b901-4a7e-96ad-034b8ddb24e5
const NPI_MODULEID DECLSPEC_SELECTANY _sample_ebpf_extension_program_info_provider_moduleid = {
sizeof(NPI_MODULEID), MIT_GUID, {0xab3a3a18, 0xb901, 0x4a7e, {0x96, 0xad, 0x03, 0x4b, 0x8d, 0xdb, 0x24, 0xe5}}};
@ -87,7 +87,7 @@ _sample_ebpf_extension_program_info_provider_attach_client(
NTSTATUS
_sample_ebpf_extension_program_info_provider_detach_client(_In_ void* provider_binding_context);
// Test eBPF extension Program Information NPI provider characteristics
// Sample eBPF extension Program Information NPI provider characteristics
const NPI_PROVIDER_CHARACTERISTICS _sample_ebpf_extension_program_info_provider_characteristics = {
0,
@ -129,7 +129,7 @@ static sample_ebpf_extension_program_info_provider_t _sample_ebpf_extension_prog
// f788ef4b-207d-4dc3-85cf-0f2ea107213c
DEFINE_GUID(EBPF_ATTACH_TYPE_SAMPLE, 0xf788ef4b, 0x207d, 0x4dc3, 0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c);
// Test eBPF Extension Hook NPI Provider Module GUID: ab3a3a19-b901-4a7e-96ad-034b8ddb24e5
// Sample eBPF Extension Hook NPI Provider Module GUID: ab3a3a19-b901-4a7e-96ad-034b8ddb24e5
const NPI_MODULEID DECLSPEC_SELECTANY _sample_ebpf_extension_hook_provider_moduleid = {
sizeof(NPI_MODULEID), MIT_GUID, {0xab3a3a19, 0xb901, 0x4a7e, {0x96, 0xad, 0x03, 0x4b, 0x8d, 0xdb, 0x24, 0xe5}}};
@ -168,7 +168,7 @@ _sample_ebpf_extension_hook_provider_attach_client(
NTSTATUS
_sample_ebpf_extension_hook_provider_detach_client(_In_ void* provider_binding_context);
// Test eBPF extension Hook NPI provider characteristics
// Sample eBPF extension Hook NPI provider characteristics
ebpf_attach_provider_data_t _sample_ebpf_extension_attach_provider_data;
ebpf_extension_data_t _sample_ebpf_extension_hook_provider_data = {

Просмотреть файл

@ -39,7 +39,7 @@ NTSTATUS
sample_ebpf_extension_hook_provider_register();
/**
* @brief Unregister test hook provider.
* @brief Unregister sample hook provider.
*
*/
void
@ -60,9 +60,9 @@ sample_ebpf_extension_invoke_program(_In_ const sample_program_context_t* contex
/**
* @brief Invoke eBPF program attached to a hook provider instance and measure the execution time.
*
* @param[in] request Request containing the parameters of the test.
* @param[in] request Request containing the parameters of the sample.
* @param[in] request_length Length of the request buffer.
* @param[out] reply Reply containing the results of the test.
* @param[out] reply Reply containing the results of the sample.
*
* @retval EBPF_SUCCESS Operation succeeded.
* @retval EBPF_OPERATION_NOT_SUPPORTED Operation not supported.

Просмотреть файл

@ -15,8 +15,8 @@
#include "sample_ext_helpers.h"
#include "sample_ext_ioctls.h"
#define SAMPLE_EBPF_EXT_DEVICE_NAME L"\\Device\\SampleEbpfExt"
#define SAMPLE_EBPF_EXT_SYMBOLIC_DEVICE_NAME L"\\GLOBAL??\\SampleEbpfExtIoDevice"
#define SAMPLE_EBPF_EXT_DEVICE_NAME L"\\Device\\" SAMPLE_EBPF_EXT_NAME_W
#define SAMPLE_EBPF_EXT_SYMBOLIC_DEVICE_NAME L"\\GLOBAL??\\" SAMPLE_EBPF_EXT_DEVICE_BASE_NAME
// Driver global variables
static DEVICE_OBJECT* _sample_ebpf_ext_driver_device_object;
@ -228,7 +228,12 @@ _sample_ebpf_ext_driver_io_device_control(
);
if (!NT_SUCCESS(status)) {
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "SampleEbpfExt: Input buffer failure %d\n", status));
KdPrintEx(
(DPFLTR_IHVDRIVER_ID,
DPFLTR_INFO_LEVEL,
"%s: Input buffer failure %d\n",
SAMPLE_EBPF_EXT_NAME_A,
status));
goto Done;
}
@ -255,7 +260,8 @@ _sample_ebpf_ext_driver_io_device_control(
KdPrintEx(
(DPFLTR_IHVDRIVER_ID,
DPFLTR_INFO_LEVEL,
"SampleEbpfExt: Output buffer failure %d\n",
"%s: Output buffer failure %d\n",
SAMPLE_EBPF_EXT_NAME_A,
status));
goto Done;
}
@ -299,7 +305,12 @@ _sample_ebpf_ext_driver_io_device_control(
);
if (!NT_SUCCESS(status)) {
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "SampleEbpfExt: Input buffer failure %d\n", status));
KdPrintEx(
(DPFLTR_IHVDRIVER_ID,
DPFLTR_INFO_LEVEL,
"%s: Input buffer failure %d\n",
SAMPLE_EBPF_EXT_NAME_A,
status));
goto Done;
}
@ -316,7 +327,12 @@ _sample_ebpf_ext_driver_io_device_control(
// Retrieve output buffer associated with the request object.
status = WdfRequestRetrieveOutputBuffer(request, output_buffer_length, &output_buffer, &actual_output_length);
if (!NT_SUCCESS(status)) {
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "SampleEbpfExt: Output buffer failure %d\n", status));
KdPrintEx(
(DPFLTR_IHVDRIVER_ID,
DPFLTR_INFO_LEVEL,
"%s: Output buffer failure %d\n",
SAMPLE_EBPF_EXT_NAME_A,
status));
goto Done;
}
@ -344,4 +360,4 @@ _sample_ebpf_ext_driver_io_device_control(
Done:
WdfRequestCompleteWithInformation(request, status, output_buffer_length);
return;
}
}

Просмотреть файл

@ -2,12 +2,18 @@
// SPDX-License-Identifier: MIT
/**
* @brief Header file for the test eBPF extension driver's device IOCTLs.
* @brief Header file for the sample eBPF extension driver's device IOCTLs.
*/
#pragma once
#define SAMPLE_EBPF_EXT_DEVICE_WIN32_NAME L"\\\\.\\SampleEbpfExtIoDevice"
#define SAMPLE_EBPF_EXT_NAME_A "SampleEbpfExt"
#define WIDEN2(x) L##x
#define WIDEN(x) WIDEN2(x)
#define SAMPLE_EBPF_EXT_NAME_W WIDEN(SAMPLE_EBPF_EXT_NAME_A)
#define SAMPLE_EBPF_EXT_DEVICE_BASE_NAME SAMPLE_EBPF_EXT_NAME_W L"IoDevice"
#define SAMPLE_EBPF_EXT_DEVICE_WIN32_NAME L"\\\\.\\" SAMPLE_EBPF_EXT_DEVICE_BASE_NAME
//
// IOCTL Codes

Просмотреть файл

@ -19,7 +19,7 @@ static ebpf_context_descriptor_t _sample_ebpf_context_descriptor = {
EBPF_OFFSET_OF(sample_program_context_t, data_end),
-1};
// Test Extension Helper function prototype descriptors.
// Sample Extension Helper function prototype descriptors.
static ebpf_helper_function_prototype_t _sample_ebpf_extension_helper_function_prototype[] = {
{SAMPLE_EXT_HELPER_FUNCTION_START + 1,
"sample_ebpf_extension_helper_function1",

Просмотреть файл

@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT
// Test eBPF program for EBPF_PROGRAM_TYPE_SAMPLE implemented in
// the Test eBPF extension.
// the Sample eBPF extension.
#include "sample_common_routines.h"
#include "sample_ext_helpers.h"