@@ -22,14 +22,14 @@ _ebpf_store_update_extension_header_information(ebpf_store_key_t key, _In_ const
2222}
2323
2424static ebpf_result_t
25- _ebpf_store_open_or_create_provider_registry_key (_Out_ ebpf_store_key_t * provider_key )
25+ _ebpf_store_open_or_create_provider_registry_key (ebpf_store_key_t root_store_key , _Out_ ebpf_store_key_t * provider_key )
2626{
2727 ebpf_result_t result = EBPF_SUCCESS ;
2828 ebpf_store_key_t root_key = NULL ;
2929 * provider_key = NULL ;
3030
3131 // Open (or create) root eBPF registry path.
32- result = ebpf_create_registry_key (ebpf_store_root_key , ebpf_store_root_sub_key , REG_CREATE_FLAGS , & root_key );
32+ result = ebpf_create_registry_key (root_store_key , ebpf_store_root_sub_key , REG_CREATE_FLAGS , & root_key );
3333
3434 if (!IS_SUCCESS (result )) {
3535 goto Exit ;
@@ -106,9 +106,11 @@ _ebpf_store_update_helper_prototype(
106106 return result ;
107107}
108108
109- ebpf_result_t
110- ebpf_store_update_global_helper_information (
111- _In_reads_ (helper_info_count ) ebpf_helper_function_prototype_t * helper_info , uint32_t helper_info_count )
109+ static ebpf_result_t
110+ _ebpf_store_update_global_helper_information (
111+ ebpf_store_key_t root_key ,
112+ _In_reads_ (helper_info_count ) ebpf_helper_function_prototype_t * helper_info ,
113+ uint32_t helper_info_count )
112114{
113115 ebpf_result_t result = EBPF_SUCCESS ;
114116 ebpf_store_key_t provider_key = NULL ;
@@ -124,7 +126,7 @@ ebpf_store_update_global_helper_information(
124126 }
125127
126128 // Open (or create) provider registry path.
127- result = _ebpf_store_open_or_create_provider_registry_key (& provider_key );
129+ result = _ebpf_store_open_or_create_provider_registry_key (root_key , & provider_key );
128130 if (!IS_SUCCESS (result )) {
129131 goto Exit ;
130132 }
@@ -151,8 +153,31 @@ ebpf_store_update_global_helper_information(
151153}
152154
153155ebpf_result_t
154- ebpf_store_update_section_information (
155- _In_reads_ (section_info_count ) const ebpf_program_section_info_t * section_info , uint32_t section_info_count )
156+ ebpf_store_update_global_helper_information (
157+ _In_reads_ (helper_info_count ) ebpf_helper_function_prototype_t * helper_info , uint32_t helper_info_count )
158+ {
159+ // First update the HKCU root key.
160+ ebpf_result_t result =
161+ _ebpf_store_update_global_helper_information (ebpf_store_hkcu_root_key , helper_info , helper_info_count );
162+ if (!IS_SUCCESS (result )) {
163+ return result ;
164+ }
165+
166+ // Next update the HKLM root key. It possible that the user does not have permission to update the HKLM root key.
167+ // Suppress error in that case.
168+ result = _ebpf_store_update_global_helper_information (ebpf_store_hklm_root_key , helper_info , helper_info_count );
169+ if (result == EBPF_ACCESS_DENIED ) {
170+ result = EBPF_SUCCESS ;
171+ }
172+
173+ return result ;
174+ }
175+
176+ static ebpf_result_t
177+ _ebpf_store_update_section_information (
178+ ebpf_store_key_t root_key ,
179+ _In_reads_ (section_info_count ) const ebpf_program_section_info_t * section_info ,
180+ uint32_t section_info_count )
156181{
157182 ebpf_result_t result = EBPF_SUCCESS ;
158183 ebpf_store_key_t provider_key = NULL ;
@@ -163,7 +188,7 @@ ebpf_store_update_section_information(
163188 }
164189
165190 // Open (or create) provider registry path.
166- result = _ebpf_store_open_or_create_provider_registry_key (& provider_key );
191+ result = _ebpf_store_open_or_create_provider_registry_key (root_key , & provider_key );
167192 if (!IS_SUCCESS (result )) {
168193 goto Exit ;
169194 }
@@ -240,6 +265,28 @@ ebpf_store_update_section_information(
240265 return result ;
241266}
242267
268+ ebpf_result_t
269+ ebpf_store_update_section_information (
270+ _In_reads_ (section_info_count ) const ebpf_program_section_info_t * section_info , uint32_t section_info_count )
271+ {
272+ ebpf_result_t result = EBPF_SUCCESS ;
273+
274+ // First update the HKCU root key.
275+ result = _ebpf_store_update_section_information (ebpf_store_hkcu_root_key , section_info , section_info_count );
276+ if (!IS_SUCCESS (result )) {
277+ return result ;
278+ }
279+
280+ // Next update the HKLM root key. It possible that the user does not have permission to update the HKLM root key.
281+ // Suppress error in that case.
282+ result = _ebpf_store_update_section_information (ebpf_store_hklm_root_key , section_info , section_info_count );
283+ if (result == EBPF_ACCESS_DENIED ) {
284+ result = EBPF_SUCCESS ;
285+ }
286+
287+ return result ;
288+ }
289+
243290static ebpf_result_t
244291_ebpf_store_update_program_descriptor (
245292 ebpf_store_key_t descriptor_key , _In_ const ebpf_program_type_descriptor_t * program_type_descriptor )
@@ -351,9 +398,11 @@ _ebpf_store_update_program_info(ebpf_store_key_t program_key, _In_ const ebpf_pr
351398 return result ;
352399}
353400
354- ebpf_result_t
355- ebpf_store_update_program_information_array (
356- _In_reads_ (program_info_count ) const ebpf_program_info_t * program_info , uint32_t program_info_count )
401+ static ebpf_result_t
402+ _ebpf_store_update_program_information_array (
403+ ebpf_store_key_t root_key ,
404+ _In_reads_ (program_info_count ) const ebpf_program_info_t * program_info ,
405+ uint32_t program_info_count )
357406{
358407 ebpf_result_t result = EBPF_SUCCESS ;
359408 ebpf_store_key_t provider_key = NULL ;
@@ -365,7 +414,7 @@ ebpf_store_update_program_information_array(
365414 }
366415
367416 // Open (or create) provider registry path.
368- result = _ebpf_store_open_or_create_provider_registry_key (& provider_key );
417+ result = _ebpf_store_open_or_create_provider_registry_key (root_key , & provider_key );
369418 if (!IS_SUCCESS (result )) {
370419 goto Exit ;
371420 }
@@ -428,14 +477,36 @@ ebpf_store_update_program_information_array(
428477}
429478
430479ebpf_result_t
431- ebpf_store_delete_program_information (_In_ const ebpf_program_info_t * program_info )
480+ ebpf_store_update_program_information_array (
481+ _In_reads_ (program_info_count ) const ebpf_program_info_t * program_info , uint32_t program_info_count )
482+ {
483+ ebpf_result_t result = EBPF_SUCCESS ;
484+
485+ // First update the HKCU root key.
486+ result = _ebpf_store_update_program_information_array (ebpf_store_hkcu_root_key , program_info , program_info_count );
487+ if (!IS_SUCCESS (result )) {
488+ return result ;
489+ }
490+
491+ // Next update the HKLM root key. It possible that the user does not have permission to update the HKLM root key.
492+ // Suppress error in that case.
493+ result = _ebpf_store_update_program_information_array (ebpf_store_hklm_root_key , program_info , program_info_count );
494+ if (result == EBPF_ACCESS_DENIED ) {
495+ result = EBPF_SUCCESS ;
496+ }
497+
498+ return result ;
499+ }
500+
501+ static ebpf_result_t
502+ _ebpf_store_delete_program_information (ebpf_store_key_t root_key , _In_ const ebpf_program_info_t * program_info )
432503{
433504 ebpf_result_t result = EBPF_SUCCESS ;
434505 ebpf_store_key_t provider_key = NULL ;
435506 ebpf_store_key_t program_info_key = NULL ;
436507
437508 // Open (or create) provider registry path.
438- result = _ebpf_store_open_or_create_provider_registry_key (& provider_key );
509+ result = _ebpf_store_open_or_create_provider_registry_key (root_key , & provider_key );
439510 if (!IS_SUCCESS (result )) {
440511 goto Exit ;
441512 }
@@ -467,14 +538,35 @@ ebpf_store_delete_program_information(_In_ const ebpf_program_info_t* program_in
467538}
468539
469540ebpf_result_t
470- ebpf_store_delete_section_information (_In_ const ebpf_program_section_info_t * section_info )
541+ ebpf_store_delete_program_information (_In_ const ebpf_program_info_t * program_info )
542+ {
543+ ebpf_result_t result = EBPF_SUCCESS ;
544+
545+ // First delete from HKCU root key.
546+ result = _ebpf_store_delete_program_information (ebpf_store_hkcu_root_key , program_info );
547+ if (!IS_SUCCESS (result )) {
548+ return result ;
549+ }
550+
551+ // Next delete from HKLM root key. It possible that the user does not have permission to delete from the HKLM root
552+ // key. Suppress error in that case.
553+ result = _ebpf_store_delete_program_information (ebpf_store_hklm_root_key , program_info );
554+ if (result == EBPF_ACCESS_DENIED ) {
555+ result = EBPF_SUCCESS ;
556+ }
557+
558+ return result ;
559+ }
560+
561+ static ebpf_result_t
562+ _ebpf_store_delete_section_information (ebpf_store_key_t root_key , _In_ const ebpf_program_section_info_t * section_info )
471563{
472564 ebpf_result_t result = EBPF_SUCCESS ;
473565 ebpf_store_key_t provider_key = NULL ;
474566 ebpf_store_key_t section_info_key = NULL ;
475567
476568 // Open (or create) provider registry path.
477- result = _ebpf_store_open_or_create_provider_registry_key (& provider_key );
569+ result = _ebpf_store_open_or_create_provider_registry_key (root_key , & provider_key );
478570 if (!IS_SUCCESS (result )) {
479571 goto Exit ;
480572 }
@@ -496,3 +588,24 @@ ebpf_store_delete_section_information(_In_ const ebpf_program_section_info_t* se
496588
497589 return result ;
498590}
591+
592+ ebpf_result_t
593+ ebpf_store_delete_section_information (_In_ const ebpf_program_section_info_t * section_info )
594+ {
595+ ebpf_result_t result = EBPF_SUCCESS ;
596+
597+ // First delete from HKCU root key.
598+ result = _ebpf_store_delete_section_information (ebpf_store_hkcu_root_key , section_info );
599+ if (!IS_SUCCESS (result )) {
600+ return result ;
601+ }
602+
603+ // Next delete from HKLM root key. It possible that the user does not have permission to delete from the HKLM root
604+ // key. Suppress error in that case.
605+ result = _ebpf_store_delete_section_information (ebpf_store_hklm_root_key , section_info );
606+ if (result == EBPF_ACCESS_DENIED ) {
607+ result = EBPF_SUCCESS ;
608+ }
609+
610+ return result ;
611+ }
0 commit comments