1 | /* $Id: msiDarwinDescriptorDecoder.cpp 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * msiDarwinDescriptorDecoder
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2016-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | #include <stdio.h>
|
---|
20 | #include <iprt/win/windows.h> /* Avoid -Wall warnings. */
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 | typedef DWORD (WINAPI *PFNMSIDECOMPOSEDESCRIPTORW)(PCWSTR pwszDescriptor,
|
---|
25 | LPWSTR pwszProductCode /*[40]*/,
|
---|
26 | LPWSTR pwszFeatureId /*[40]*/,
|
---|
27 | LPWSTR pwszComponentCode /*[40]*/,
|
---|
28 | DWORD *poffArguments);
|
---|
29 |
|
---|
30 | int wmain(int cArgs, wchar_t **papwszArgs)
|
---|
31 | {
|
---|
32 | HMODULE hmodMsi = LoadLibrary("msi.dll");
|
---|
33 | PFNMSIDECOMPOSEDESCRIPTORW pfnMsiDecomposeDescriptorW;
|
---|
34 | pfnMsiDecomposeDescriptorW = (PFNMSIDECOMPOSEDESCRIPTORW)GetProcAddress(hmodMsi, "MsiDecomposeDescriptorW");
|
---|
35 | if (!pfnMsiDecomposeDescriptorW)
|
---|
36 | {
|
---|
37 | fprintf(stderr, "Failed to load msi.dll or resolve 'MsiDecomposeDescriptorW'\n");
|
---|
38 | return 1;
|
---|
39 | }
|
---|
40 |
|
---|
41 | int rcExit = 0;
|
---|
42 | for (int iArg = 1; iArg < cArgs; iArg++)
|
---|
43 | {
|
---|
44 | wchar_t wszProductCode[40] = { 0 };
|
---|
45 | wchar_t wszFeatureId[40] = { 0 };
|
---|
46 | wchar_t wszComponentCode[40] = { 0 };
|
---|
47 | DWORD offArguments = ~(DWORD)0;
|
---|
48 | DWORD dwErr = pfnMsiDecomposeDescriptorW(papwszArgs[iArg], wszProductCode, wszFeatureId, wszComponentCode, &offArguments);
|
---|
49 | if (dwErr == 0)
|
---|
50 | {
|
---|
51 | fprintf(stderr,
|
---|
52 | "#%u: '%ls'\n"
|
---|
53 | " -> Product=%ls\n"
|
---|
54 | " -> FeatureId=%ls\n"
|
---|
55 | " -> ComponentCode=%ls\n"
|
---|
56 | " -> offArguments=%#lx (%ld)\n"
|
---|
57 | , iArg, papwszArgs[iArg], wszProductCode, wszFeatureId, wszComponentCode, offArguments, offArguments);
|
---|
58 | }
|
---|
59 | else
|
---|
60 | {
|
---|
61 | fprintf(stderr,
|
---|
62 | "#%u: '%ls'\n"
|
---|
63 | " -> error %lu (%#lx)\n"
|
---|
64 | , iArg, papwszArgs[iArg], dwErr, dwErr);
|
---|
65 | rcExit = 1;
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | return rcExit;
|
---|
70 | }
|
---|
71 |
|
---|