Files
reactos/sdk/lib/drivers/wdf/shared/support/fxtelemetry.cpp
T
3fe5b8b0bb [SDK][WDF][USBDEX][NTOSKRNL_VISTA] Fully enable KMDF (#8396)
[SDK][WDFLDR] Add kmdf loader driver
[SDK][WDF] Add kmdf drver init static library
[SDK][WDF] Modify kmdf driver for working with wdfldr driver
[SDK][CDROM] Cdrom driver dynamically linking with kmdf
[SDK][WDF] Add kmdfdriver module type
[SDK][WDF][USBDEX][NTOSKRNL_VISTA] Fully enable KMDF
[KMDF][WDFLDR][WDF01000] Fix Windows 10 Compatibility WDFLDR and WDF01000
[WDF01000] NO_KERNEL_LIST_ENTRY_CHECKS for wdf01000 3rd party code

This PR is an accumulation of three peoples work, with the goal of the trying to get WDF to work like it should.
This has been tested in combination with some extra NT6+ ntoskrnl against multiple drivers.

---------

Co-authored-by: Max Korostil <[email protected]>
Co-authored-by: Victor Perevertkin <[email protected]>
Co-authored-by: Adam Słaboń <[email protected]>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <[email protected]>
2025-11-03 06:38:52 -08:00

150 lines
3.0 KiB
C++

/*++
Copyright (c) Microsoft Corporation
Module Name:
FxTelemetry.cpp
Abstract:
This module implements a telemetry methods.
Author:
Environment:
Both kernel and user mode
Revision History:
Notes:
--*/
#include "fxsupportpch.hpp"
#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
#include "fxldr.h"
#include <ntstrsafe.h>
#else
#include "driverframeworks-usermode-umevents.h"
#include "fxldrum.h"
#endif
extern "C" {
#if defined(EVENT_TRACING)
#include "fxtelemetry.tmh"
#endif
}
#if defined(__cplusplus)
extern "C" {
#endif
VOID
GetNameFromPath(
_In_ PCUNICODE_STRING Path,
_Out_ PUNICODE_STRING Name
)
/*++
Routine Description:
Given a potential full path name, return just the filename portion, OR,
Given a potential full registry path name, return just the subkey portion.
Pointer to the filename protion in the full path name string, OR,
Pointer to the subkey portion in the full registry path name.
Arguments:
Path - Pointer to the full path name string.
Name - Pointer to receive the name
Return Value:
None
--*/
{
BOOLEAN foundSlash;
ASSERT(Path != NULL);
//
// Ideally a check of Path->Length == 0 would be sufficient except that
// PreFAST thinks that Length can be odd, so it thinks Length == 1 is possible.
// Comparing Length < sizeof(WCHAR) satisfies PreFAST and keeps the logic
// at runtime correct.
//
if (Path->Length < sizeof(WCHAR)) {
RtlZeroMemory(Name, sizeof(UNICODE_STRING));
return;
}
//
// Initialize Name to point to the last WCHAR of the buffer and we will work
// our way backwards to the beginning of the string or a '\'
//
Name->Buffer = WDF_PTR_ADD_OFFSET_TYPE(Path->Buffer,
Path->Length - sizeof(WCHAR),
PWCH);
Name->Length = sizeof(WCHAR);
foundSlash = FALSE;
while (Name->Buffer >= Path->Buffer) {
if (*Name->Buffer == L'\\') {
//
// Skip the \ in the buffer moving forward a character and adjusting
// the length
//
foundSlash = TRUE;
Name->Buffer++;
Name->Length -= sizeof(WCHAR);
break;
}
//
// Move backwards in the string
//
Name->Buffer--;
Name->Length += sizeof(WCHAR);
}
if (foundSlash && Name->Length == 0) {
//
// Handle the case where a slash was found and it is the only character
//
Name->Buffer = NULL;
}
else if (foundSlash == FALSE) {
//
// Handle the case where no slash was found. In this case, Name->Buffer
// points to one WCHAR before the beginning of the string.
//
Name->Length -= sizeof(WCHAR);
Name->Buffer++;
}
//
// Need to set MaximumLength to the same value as Length so that the struct
// format is valid.
//
Name->MaximumLength = Name->Length;
}
#if defined(__cplusplus)
}
#endif