imagehlp: improve last error handling in ImageGetCertificateData

Aric Stewart aric at
Tue Dec 11 19:57:55 CST 2007

Indeed testing with my test app i see that if the Len is sufficient but 
the buffer is null i get a return of FALSE and a last error of 
ERROR_INVALID_PARAMETER.  I will update my patch.


Juan Lang wrote:
>> Humm,  I wrote a test program mimicking the calls in the application I
>> am working on and found this behavior. The app was passing in a NULL
>> buffer and a pointer for the size set to 0,  We where exiting with TRUE
>> and not setting the last error correctly which was confusing the app.
> In that case, this part of the patch is still suspect:
> -    if( *RequiredLength < size )
> +    if( !Certificate )
>      {
>          *RequiredLength = size;
> -        SetLastError( ERROR_INSUFFICIENT_BUFFER );
> -        return FALSE;
> +        return TRUE;
> I'm not sure how Windows behaves in this case, but if it returns FALSE
> (ERROR_INSUFFICIENT_BUFFER) when Certificate is NULL and
> *RequiredLength is 0, I'd be surprised if it returned TRUE when
> Certificate is NULL and *RequiredLength is large enough.
>> I am not sure how i would set up a regression test since wouldn't we
>> need an exe with a certificate in it to test with? There must be a
>> programmatic way to set that up.
> Indeed, I thought the same thing, and tried copying in bits from
> kernel32/tests/process.c to create an image.  I failed to create one
> that Windows would accept, so I gave up.  You can blame that on my
> laziness, though.  Feel free to try yourself.
> --Juan

More information about the wine-devel mailing list