Skip to content

Commit

Permalink
specify the name of the product policy
Browse files Browse the repository at this point in the history
  • Loading branch information
a1ive committed Dec 10, 2024
1 parent 162bd8a commit 2343e68
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ This command exports system, disk, SMBIOS, and network information to `report.js
Print network mapped drives and shared folders.
- --public-ip
Print public IP address.
- --product-policy
- --product-policy[=`NAME`]
Print ProductPolicy.
`NAME` specifies the name of the product policy.
- --font
Print installed fonts.

Expand Down
1 change: 1 addition & 0 deletions libnw/libnw.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ typedef struct _NWLIB_CONTEXT
LPCSTR PciClass;
LPCSTR DiskPath;
LPCSTR NetGuid;
LPCSTR ProductPolicy;

#define NW_NET_ACTIVE (1 << 0)
#define NW_NET_PHYS (1 << 1)
Expand Down
9 changes: 7 additions & 2 deletions libnw/productpolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ static void
PrintProductPolicyEntry(PNODE node, PPRODUCT_POLICY_VALUE ppValue)
{
CHAR hex[] = "0123456789ABCDEF";
PNODE pp = NWL_NodeAppendNew(node, "Entry", NFLG_TABLE_ROW);
PNODE pp;
PUINT8 pValueData = (PUINT8)ppValue + sizeof(PRODUCT_POLICY_VALUE) + ppValue->wNameSize;
LPCSTR pName;

wcsncpy_s(NWLC->NwBufW, NWINFO_BUFSZW,
(WCHAR*)((PUINT8)ppValue + sizeof(PRODUCT_POLICY_VALUE)), ppValue->wNameSize / sizeof(WCHAR));
NWL_NodeAttrSet(pp, "Name", NWL_Ucs2ToUtf8(NWLC->NwBufW), 0);
pName = NWL_Ucs2ToUtf8(NWLC->NwBufW);
if (NWLC->ProductPolicy && _stricmp(pName, NWLC->ProductPolicy) != 0)
return;
pp = NWL_NodeAppendNew(node, "Entry", NFLG_TABLE_ROW);
NWL_NodeAttrSet(pp, "Name", pName, 0);
//NWL_NodeAttrSetf(pp, "Flags", NAFLG_FMT_NUMERIC, "%lu", ppValue->dwFlags);

switch (ppValue->wType)
Expand Down
4 changes: 2 additions & 2 deletions libnw/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#define NWINFO_MAJOR_VERSION 1
#define NWINFO_MINOR_VERSION 0
#define NWINFO_MICRO_VERSION 5
#define NWINFO_BUILD_VERSION 1
#define NWINFO_MICRO_VERSION 6
#define NWINFO_BUILD_VERSION 0

#define NWINFO_VERSION NWINFO_MAJOR_VERSION,NWINFO_MINOR_VERSION,NWINFO_MICRO_VERSION,NWINFO_BUILD_VERSION
#define NWINFO_VERSION_STR QUOTE(NWINFO_MAJOR_VERSION.NWINFO_MINOR_VERSION.NWINFO_MICRO_VERSION.NWINFO_BUILD_VERSION)
Expand Down
10 changes: 8 additions & 2 deletions nwinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ static void nwinfo_help(void)
" --shares Print network mapped drives and shared folders.\n"
" --audio Print audio devices.\n"
" --public-ip Print public IP address.\n"
" --product-policy Print ProductPolicy.\n"
" --product-policy[=NAME]\n"
" Print ProductPolicy.\n"
" NAME specifies the name of the product policy.\n"
" --gpu Print GPU usage.\n"
" --font Print installed fonts.\n");
}
Expand Down Expand Up @@ -288,8 +290,12 @@ int main(int argc, char* argv[])
nwContext.AudioInfo = TRUE;
else if (_stricmp(argv[i], "--public-ip") == 0)
nwContext.PublicIpInfo = TRUE;
else if (_stricmp(argv[i], "--product-policy") == 0)
else if (_strnicmp(argv[i], "--product-policy", 16) == 0)
{
nwContext.ProductPolicyInfo = TRUE;
if (argv[i][16] == '=' && argv[i][17])
nwContext.ProductPolicy = &argv[i][17];
}
else if (_stricmp(argv[i], "--gpu") == 0)
nwContext.GpuInfo = TRUE;
else if (_stricmp(argv[i], "--font") == 0)
Expand Down

0 comments on commit 2343e68

Please sign in to comment.