From: Lorenzo Ferrillo <lorenzofersteam(a)live.it> --- dlls/kernelbase/main.c | 50 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/dlls/kernelbase/main.c b/dlls/kernelbase/main.c index c000413e900..dd7c7951b45 100644 --- a/dlls/kernelbase/main.c +++ b/dlls/kernelbase/main.c @@ -303,7 +303,7 @@ ULONG WINAPI PerfSetCounterSetInfo( HANDLE handle, PERF_COUNTERSET_INFO *templat } -static unsigned int get_performance_counter_index(PERF_COUNTERSET_INSTANCE *instance, ULONG counter_id, struct counterset_template ** out_template,struct counterset_instance ** out_instance) +static PERF_COUNTER_INFO* get_performance_counter_info(PERF_COUNTERSET_INSTANCE *instance, ULONG counter_id ,struct counterset_instance ** out_instance) { unsigned int i; struct counterset_template *template; @@ -313,16 +313,10 @@ static unsigned int get_performance_counter_index(PERF_COUNTERSET_INSTANCE *inst template = inst->template; *out_instance = inst; - *out_template = template; for (i = 0; i < template->counterset.NumCounters; ++i) - if (template->counter[i].CounterId == counter_id) return i; - return template->counterset.NumCounters; -} - -static BYTE* get_performance_counter_address(struct counterset_template* template, struct counterset_instance* instance, unsigned int counter_index) -{ - return (BYTE*) &instance->instance + sizeof(PERF_COUNTERSET_INSTANCE) + template->counter[counter_index].Offset; + if (template->counter[i].CounterId == counter_id) return &template->counter[i]; + return NULL; } /*********************************************************************** @@ -332,22 +326,20 @@ ULONG WINAPI PerfSetCounterRefValue(HANDLE provider, PERF_COUNTERSET_INSTANCE *i ULONG counterid, void *address) { struct perf_provider *prov = perf_provider_from_handle( provider ); - struct counterset_template *template; struct counterset_instance *inst; - unsigned int counter_index;; + PERF_COUNTER_INFO* counter;; FIXME( "provider %p, instance %p, counterid %lu, address %p semi-stub.\n", provider, instance, counterid, address ); if (!prov || !instance || !address) return ERROR_INVALID_PARAMETER; - counter_index = get_performance_counter_index(instance, counterid, &template, &inst); + counter = get_performance_counter_info(instance, counterid, &inst); - if (counter_index== template->counterset.NumCounters) return ERROR_NOT_FOUND; - if (!(template->counter[counter_index].Attrib & PERF_ATTRIB_BY_REFERENCE)) return ERROR_INVALID_PARAMETER; - - *(void **)(get_performance_counter_address(template,inst, counter_index)) = address; + if (counter == NULL) return ERROR_NOT_FOUND; + if (!(counter->Attrib & PERF_ATTRIB_BY_REFERENCE)) return ERROR_INVALID_PARAMETER; + *(void**)((BYTE*) &inst->instance + sizeof(PERF_COUNTERSET_INSTANCE) + counter->Offset) = address; return STATUS_SUCCESS; } @@ -358,22 +350,21 @@ ULONG WINAPI PerfSetULongCounterValue(HANDLE provider, PERF_COUNTERSET_INSTANCE ULONG counterid, ULONG value) { struct perf_provider *prov = perf_provider_from_handle( provider ); - struct counterset_template *template; struct counterset_instance *inst; - unsigned int counter_index; + PERF_COUNTER_INFO* counter; TRACE( "provider %p, instance %p, counterid %lu, address %lu semi-stub.\n", provider, instance, counterid, value ); if (!prov || !instance) return ERROR_INVALID_PARAMETER; - counter_index = get_performance_counter_index(instance, counterid, &template, &inst); + counter = get_performance_counter_info(instance, counterid, &inst); - if (counter_index == template->counterset.NumCounters) return ERROR_NOT_FOUND; - if (template->counter[counter_index].Attrib & PERF_ATTRIB_BY_REFERENCE) return ERROR_INVALID_PARAMETER; - if (template->counter[counter_index].Type & PERF_SIZE_LARGE) return ERROR_INVALID_PARAMETER; + if (counter == NULL) return ERROR_NOT_FOUND; + if (counter->Attrib & PERF_ATTRIB_BY_REFERENCE) return ERROR_INVALID_PARAMETER; + if (counter->Type & PERF_SIZE_LARGE) return ERROR_INVALID_PARAMETER; - *(ULONG*)(get_performance_counter_address(template,inst, counter_index)) = value; + *(ULONG*)((BYTE*) &inst->instance + sizeof(PERF_COUNTERSET_INSTANCE) + counter->Offset) = value; return STATUS_SUCCESS; } @@ -385,22 +376,21 @@ ULONG WINAPI PerfSetULongLongCounterValue(HANDLE provider, PERF_COUNTERSET_INSTA ULONG counterid, ULONGLONG value) { struct perf_provider *prov = perf_provider_from_handle( provider ); - struct counterset_template *template; struct counterset_instance *inst; - unsigned int counter_index; + PERF_COUNTER_INFO* counter; TRACE( "provider %p, instance %p, counterid %lu, address %I64u semi-stub.\n", provider, instance, counterid, value ); if (!prov || !instance) return ERROR_INVALID_PARAMETER; - counter_index = get_performance_counter_index(instance, counterid, &template, &inst); + counter = get_performance_counter_info(instance, counterid, &inst); - if (counter_index == template->counterset.NumCounters) return ERROR_NOT_FOUND; - if (template->counter[counter_index].Attrib & PERF_ATTRIB_BY_REFERENCE) return ERROR_INVALID_PARAMETER; - if (!(template->counter[counter_index].Type & PERF_SIZE_LARGE)) return ERROR_INVALID_PARAMETER; + if (counter == NULL) return ERROR_NOT_FOUND; + if (counter->Attrib & PERF_ATTRIB_BY_REFERENCE) return ERROR_INVALID_PARAMETER; + if (!(counter->Type & PERF_SIZE_LARGE)) return ERROR_INVALID_PARAMETER; - *(ULONGLONG*)(get_performance_counter_address(template,inst, counter_index)) = value; + *(ULONGLONG*)((BYTE*) &inst->instance + sizeof(PERF_COUNTERSET_INSTANCE) + counter->Offset) = value; return STATUS_SUCCESS; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3799