[PATCH 05/10] d3dx9: Implement d3dx_effect_DeleteParameterBlock().

Paul Gofman gofmanp at gmail.com
Tue Nov 12 13:19:09 CST 2019


On 11/12/19 21:51, Matteo Bruni wrote:
> On Thu, Nov 7, 2019 at 10:19 PM Paul Gofman <gofmanp at gmail.com> wrote:
>
>> @@ -4121,11 +4129,27 @@ static HRESULT WINAPI d3dx_effect_ApplyParameterBlock(ID3DXEffect *iface, D3DXHA
>>  #if D3DX_SDK_VERSION >= 26
>>  static HRESULT WINAPI d3dx_effect_DeleteParameterBlock(ID3DXEffect *iface, D3DXHANDLE parameter_block)
>>  {
> Any idea what is the behavior with version < 26? Was the allocated
> memory just dropped on the floor?

As I interpret the test, the parameter block is deleted upon effect
delete (I decided so by checking object reference: the texture looses
the last effect's reference when the effect is deleted without explicit
parameter block deletion). So I guess the earlier versions did not have
explicit DeleteParameterBlock(), but all allocated block got deleted on
effect release.


>
>> -    struct d3dx_effect *This = impl_from_ID3DXEffect(iface);
>> +    struct d3dx_parameter_block *block = get_valid_parameter_block(parameter_block);
>> +    struct d3dx_effect *effect = impl_from_ID3DXEffect(iface);
>> +    struct d3dx_parameter_block *b;
>>
>> -    FIXME("(%p)->(%p): stub\n", This, parameter_block);
>> +    TRACE("iface %p, parameter_block %p.\n", iface, parameter_block);
>>
>> -    return E_NOTIMPL;
>> +    if (!block)
>> +        return D3DERR_INVALIDCALL;
>> +
>> +    LIST_FOR_EACH_ENTRY(b, &effect->parameter_block_list, struct d3dx_parameter_block, entry)
>> +    {
>> +        if (b == block)
>> +        {
>> +            list_remove(&b->entry);
>> +            free_parameter_block(b);
>> +            return D3D_OK;
>> +        }
>> +    }
>> +
>> +    WARN("Block is not found in issued block list, not freeing memory.\n");
>> +    return D3DERR_INVALIDCALL;
>>  }
>>  #endif
> What happens if the parameter block is currently active?

I am not sure what do you mean by active block? As far as understood,
the block does not have active state: applying it is equivalent to
separately setting all the parameters it contains, the block is just a
collection of parameter values. The block which is currently being
recorded cannot be freed here, as the application did not get its handle
yet, it will get it only when it calls EndParameterBlock(), and at that
moment the block is finalized and the recording of the block stops, it
is not a current recording block anymore. If you mean what happens if
someone will try to apply parameter block which was previously deleted
here, I did not test that, but I don't see yet how this can result in
anything but use after free in native d3dx.






More information about the wine-devel mailing list