1 | /* $Id: msiDarwinDescriptorDecoder.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * msiDarwinDescriptorDecoder
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2016-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | #include <stdio.h>
|
---|
30 | #include <iprt/win/windows.h> /* Avoid -Wall warnings. */
|
---|
31 |
|
---|
32 |
|
---|
33 |
|
---|
34 | typedef DWORD (WINAPI *PFNMSIDECOMPOSEDESCRIPTORW)(PCWSTR pwszDescriptor,
|
---|
35 | LPWSTR pwszProductCode /*[40]*/,
|
---|
36 | LPWSTR pwszFeatureId /*[40]*/,
|
---|
37 | LPWSTR pwszComponentCode /*[40]*/,
|
---|
38 | DWORD *poffArguments);
|
---|
39 |
|
---|
40 | int wmain(int cArgs, wchar_t **papwszArgs)
|
---|
41 | {
|
---|
42 | HMODULE hmodMsi = LoadLibrary("msi.dll");
|
---|
43 | PFNMSIDECOMPOSEDESCRIPTORW pfnMsiDecomposeDescriptorW;
|
---|
44 | pfnMsiDecomposeDescriptorW = (PFNMSIDECOMPOSEDESCRIPTORW)GetProcAddress(hmodMsi, "MsiDecomposeDescriptorW");
|
---|
45 | if (!pfnMsiDecomposeDescriptorW)
|
---|
46 | {
|
---|
47 | fprintf(stderr, "Failed to load msi.dll or resolve 'MsiDecomposeDescriptorW'\n");
|
---|
48 | return 1;
|
---|
49 | }
|
---|
50 |
|
---|
51 | int rcExit = 0;
|
---|
52 | for (int iArg = 1; iArg < cArgs; iArg++)
|
---|
53 | {
|
---|
54 | wchar_t wszProductCode[40] = { 0 };
|
---|
55 | wchar_t wszFeatureId[40] = { 0 };
|
---|
56 | wchar_t wszComponentCode[40] = { 0 };
|
---|
57 | DWORD offArguments = ~(DWORD)0;
|
---|
58 | DWORD dwErr = pfnMsiDecomposeDescriptorW(papwszArgs[iArg], wszProductCode, wszFeatureId, wszComponentCode, &offArguments);
|
---|
59 | if (dwErr == 0)
|
---|
60 | {
|
---|
61 | fprintf(stderr,
|
---|
62 | "#%u: '%ls'\n"
|
---|
63 | " -> Product=%ls\n"
|
---|
64 | " -> FeatureId=%ls\n"
|
---|
65 | " -> ComponentCode=%ls\n"
|
---|
66 | " -> offArguments=%#lx (%ld)\n"
|
---|
67 | , iArg, papwszArgs[iArg], wszProductCode, wszFeatureId, wszComponentCode, offArguments, offArguments);
|
---|
68 | }
|
---|
69 | else
|
---|
70 | {
|
---|
71 | fprintf(stderr,
|
---|
72 | "#%u: '%ls'\n"
|
---|
73 | " -> error %lu (%#lx)\n"
|
---|
74 | , iArg, papwszArgs[iArg], dwErr, dwErr);
|
---|
75 | rcExit = 1;
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | return rcExit;
|
---|
80 | }
|
---|
81 |
|
---|