Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/generated/linux/storage_winuser.c.clog.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ tracepoint(CLOG_STORAGE_WINUSER_C, LibraryErrorStatus , arg2, arg3);\



/*----------------------------------------------------------
// Decoder Ring for AllocFailure
// Allocation of '%s' failed. (%llu bytes)
// QuicTraceEvent(
AllocFailure,
"Allocation of '%s' failed. (%llu bytes)",
"RegEnumValueA ValueName",
AllocatedLength);
// arg2 = arg2 = "RegEnumValueA ValueName" = arg2
// arg3 = arg3 = AllocatedLength = arg3
----------------------------------------------------------*/
#ifndef _clog_4_ARGS_TRACE_AllocFailure
#define _clog_4_ARGS_TRACE_AllocFailure(uniqueId, encoded_arg_string, arg2, arg3)\
tracepoint(CLOG_STORAGE_WINUSER_C, AllocFailure , arg2, arg3);\

#endif




#ifdef __cplusplus
}
#endif
Expand Down
23 changes: 23 additions & 0 deletions src/generated/linux/storage_winuser.c.clog.h.lttng.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,26 @@ TRACEPOINT_EVENT(CLOG_STORAGE_WINUSER_C, LibraryErrorStatus,
ctf_string(arg3, arg3)
)
)



/*----------------------------------------------------------
// Decoder Ring for AllocFailure
// Allocation of '%s' failed. (%llu bytes)
// QuicTraceEvent(
AllocFailure,
"Allocation of '%s' failed. (%llu bytes)",
"RegEnumValueA ValueName",
AllocatedLength);
// arg2 = arg2 = "RegEnumValueA ValueName" = arg2
// arg3 = arg3 = AllocatedLength = arg3
----------------------------------------------------------*/
TRACEPOINT_EVENT(CLOG_STORAGE_WINUSER_C, AllocFailure,
TP_ARGS(
const char *, arg2,
unsigned long long, arg3),
TP_FIELDS(
ctf_string(arg2, arg2)
ctf_integer(uint64_t, arg3, arg3)
)
)
104 changes: 103 additions & 1 deletion src/platform/storage_winuser.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,107 @@ CxPlatStorageClear(
_In_ CXPLAT_STORAGE* Storage
)
{
return HRESULT_FROM_WIN32(RegDeleteTreeA(Storage->RegKey, NULL));
//
// Clear only values in this registry key, not subkeys, to preserve
// separation between global and per-app settings. RegDeleteTreeA would
// delete the entire subtree and wipe all app-specific data when clearing
// global storage.
//
QUIC_STATUS Status = QUIC_STATUS_SUCCESS;
DWORD Error = NO_ERROR;
DWORD AllocatedLength = 0;
PSTR ValueName = NULL;

//
// Query registry key info to get the maximum value name length
//
Error = RegQueryInfoKeyA(
Storage->RegKey,
NULL, // Class
NULL, // ClassLength
NULL, // Reserved
NULL, // SubKeys
NULL, // MaxSubKeyLen
NULL, // MaxClassLen
NULL, // Values
&AllocatedLength, // MaxValueNameLen
NULL, // MaxValueLen
NULL, // SecurityDescriptor
NULL); // LastWriteTime

if (Error != NO_ERROR) {
Comment thread
gaurav2699 marked this conversation as resolved.
Status = HRESULT_FROM_WIN32(Error);
QuicTraceEvent(
LibraryErrorStatus,
"[ lib] ERROR, %u, %s.",
Status,
"RegQueryInfoKeyA failed");
goto Exit;
}
//
// Add 1 for null terminator (RegQueryInfoKeyA returns length without null terminator)
//
AllocatedLength++;

ValueName = CXPLAT_ALLOC_PAGED(AllocatedLength, QUIC_POOL_PLATFORM_TMP_ALLOC);
if (ValueName == NULL) {
Status = QUIC_STATUS_OUT_OF_MEMORY;
QuicTraceEvent(
AllocFailure,
"Allocation of '%s' failed. (%llu bytes)",
"RegEnumValueA ValueName",
AllocatedLength);
goto Exit;
}

//
// Iterate through all values and delete them
Comment thread
gaurav2699 marked this conversation as resolved.
// We always use index 0 because deletion shifts the remaining values
//
while (TRUE) {
DWORD NameLength = AllocatedLength;
Error =
RegEnumValueA(
Storage->RegKey,
0, // Always use index 0 since we delete as we go
ValueName,
&NameLength,
NULL, // Reserved
NULL, // Type
NULL, // Data
NULL); // DataLength

if (Error == ERROR_NO_MORE_ITEMS) {
Status = QUIC_STATUS_SUCCESS;
break;
} else if (Error != NO_ERROR) {
Status = HRESULT_FROM_WIN32(Error);
QuicTraceEvent(
LibraryErrorStatus,
"[ lib] ERROR, %u, %s.",
Status,
"RegEnumValueA failed");
goto Exit;
}

//
// Delete this value
//
Status = RegDeleteValueA(Storage->RegKey, ValueName);
if (QUIC_FAILED(Status)) {
QuicTraceEvent(
LibraryErrorStatus,
"[ lib] ERROR, %u, %s.",
Status,
"ZwDeleteValueKey failed");
goto Exit;
}
}

Exit:
if (ValueName != NULL) {
CXPLAT_FREE(ValueName, QUIC_POOL_PLATFORM_TMP_ALLOC);
}

return Status;
}
Loading