[PATCH v7 4/8] ntdll: Return BIOS info from NtQuerySystemInformation on Linux

Huw Davies huw at codeweavers.com
Mon Jun 18 06:26:29 CDT 2018


On Mon, Jun 18, 2018 at 12:21:52PM +0100, Huw Davies wrote:
> On Mon, Jun 18, 2018 at 05:09:32AM -0600, Alex Henrie wrote:
> > Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
> > ---
> >  dlls/ntdll/nt.c         | 172 ++++++++++++++++++++++++++++++++++++++++
> >  dlls/ntdll/tests/info.c |  11 ++-
> >  2 files changed, 181 insertions(+), 2 deletions(-)
> > 
> > diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
> > index dc0ce04f42..40e36c0ffd 100644
> > --- a/dlls/ntdll/nt.c
> > +++ b/dlls/ntdll/nt.c
> > @@ -1850,6 +1879,127 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
> >  }
> >  #endif
> >  
> > +static inline void copy_smbios_string(char **buffer, char *s, size_t len)
> > +{
> > +    if (!len) return;
> > +    strcpy(*buffer, s);
> > +    *buffer += len + 1;
> > +}
> > +
> > +#ifdef linux
> > +
> > +#define FWSS 128 /* firmware string size */
> > +
> > +static void get_smbios_string(const char *path, char *s, size_t *len)
> > +{
> > +    FILE *file = fopen(path, "r");
> > +    if (!file)
> > +    {
> > +        *len = 0;
> > +        return;
> > +    }
> > +
> > +    *len = fread(s, 1, FWSS - 1, file);
> 
> That's pretty ugly.  This function really shouldn't
> assume the size of the buffer is has to play with.

Note, it may be more convenient to use a separate
'size' [in] parameter rather than use len as [in,out].

Huw.



More information about the wine-devel mailing list