On Wed, 9 Sep 2020 11:53:53 -0700, Narcisa Ana Maria Vasile wrote:
> On Mon, Aug 24, 2020 at 11:53:44PM +0300, Dmitry Kozlyuk wrote:
> > On Thu, 20 Aug 2020 15:23:55 -0700, Narcisa Ana Maria Vasile wrote:
[snip]
> > > +ClassName = "Windows UIO"
> > > +DiskName = "DPDK netUIO Installation Disk"
> > > +netuio.DeviceDesc = "netuio Device"
> > > +netuio.SVCDESC = "netuio Service"
> > > +
> > > + // Build symbolic link name as <netuio_symbolic_link>_BDF
> > > (bus/device/func)
> > > + CHAR symbolic_link[64] = { 0 };
> > > + sprintf_s(symbolic_link, sizeof(symbolic_link), "%s_%04d%02d%02d",
> > > + NETUIO_DEVICE_SYMBOLIC_LINK_ANSI,
> > > netuio_contextdata->addr.bus_num,
> > > + netuio_contextdata->addr.dev_num,
> > > netuio_contextdata->addr.func_num);
> > > +
> > > + ANSI_STRING ansi_symbolic_link;
> > > + RtlInitAnsiString(&ansi_symbolic_link, symbolic_link);
> > > +
> > > + status = RtlAnsiStringToUnicodeString(&netuio_symbolic_link,
> > > &ansi_symbolic_link, TRUE);
> > > + if (!NT_SUCCESS(status))
> > > + return status;
> >
> > Why not use Unicode directly?
> >
> It looks like either way, a cast will be needed (for example, if I use wchar
> for symbolic_link and then
> RtlInitUnicodeString()). I've left it as is, but let me know if there's an
> elegant solution that I didn't see.
It's not that important, really, you can leave the code as-is. FWIW, I meant
something like this:
DECLARE_UNICODE_STRING_SIZE(symbolic_link_name, NETUIO_MAX_SYMLINK_LEN);
RtlUnicodeStringPrintf(
symbolic_link_name,
NETUIO_DEVICE_SYMBOLIC_LINK_UNICODE,
...);
https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntstrsafe/nf-ntstrsafe-rtlunicodestringprintf