diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-06-24 12:26:27 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-06-27 11:14:21 -0500 |
| commit | 78b5daf01555d86293c1012ed3de704752880a6a (patch) | |
| tree | 45524478c868cf63042a5e2ad78cfcd15aac43d6 /src/libs/dutil/WixToolset.DUtil/app2util.cpp | |
| parent | 4f41db7eaa48b0e061a68fd5fc70ce6d127d9039 (diff) | |
| download | wix-78b5daf01555d86293c1012ed3de704752880a6a.tar.gz wix-78b5daf01555d86293c1012ed3de704752880a6a.tar.bz2 wix-78b5daf01555d86293c1012ed3de704752880a6a.zip | |
Move LoadSystemLibrary and LoadSystemLibraryWithPath into apputil.
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/app2util.cpp')
| -rw-r--r-- | src/libs/dutil/WixToolset.DUtil/app2util.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/app2util.cpp b/src/libs/dutil/WixToolset.DUtil/app2util.cpp new file mode 100644 index 00000000..d2e21e39 --- /dev/null +++ b/src/libs/dutil/WixToolset.DUtil/app2util.cpp | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | |||
| 5 | // Exit macros | ||
| 6 | #define AppExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 7 | #define AppExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 8 | #define AppExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 9 | #define AppExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 10 | #define AppExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 11 | #define AppExitWithRootFailure(x, e, s, ...) ExitWithRootFailureSource(DUTIL_SOURCE_APPUTIL, x, e, s, __VA_ARGS__) | ||
| 12 | #define AppExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 13 | #define AppExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_APPUTIL, p, x, e, s, __VA_ARGS__) | ||
| 14 | #define AppExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_APPUTIL, p, x, s, __VA_ARGS__) | ||
| 15 | #define AppExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_APPUTIL, p, x, e, s, __VA_ARGS__) | ||
| 16 | #define AppExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_APPUTIL, p, x, s, __VA_ARGS__) | ||
| 17 | #define AppExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_APPUTIL, e, x, s, __VA_ARGS__) | ||
| 18 | #define AppExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_APPUTIL, g, x, s, __VA_ARGS__) | ||
| 19 | |||
| 20 | DAPI_(void) AppFreeCommandLineArgs( | ||
| 21 | __in LPWSTR* argv | ||
| 22 | ) | ||
| 23 | { | ||
| 24 | // The "ignored" hack in AppParseCommandLine requires an adjustment. | ||
| 25 | LPWSTR* argvOriginal = argv - 1; | ||
| 26 | ::LocalFree(argvOriginal); | ||
| 27 | } | ||
| 28 | |||
| 29 | DAPI_(HRESULT) AppParseCommandLine( | ||
| 30 | __in LPCWSTR wzCommandLine, | ||
| 31 | __in int* pArgc, | ||
| 32 | __in LPWSTR** pArgv | ||
| 33 | ) | ||
| 34 | { | ||
| 35 | HRESULT hr = S_OK; | ||
| 36 | LPWSTR sczCommandLine = NULL; | ||
| 37 | LPWSTR* argv = NULL; | ||
| 38 | int argc = 0; | ||
| 39 | |||
| 40 | // CommandLineToArgvW tries to treat the first argument as the path to the process, | ||
| 41 | // which fails pretty miserably if your first argument is something like | ||
| 42 | // FOO="C:\Program Files\My Company". So give it something harmless to play with. | ||
| 43 | hr = StrAllocConcat(&sczCommandLine, L"ignored ", 0); | ||
| 44 | AppExitOnFailure(hr, "Failed to initialize command line."); | ||
| 45 | |||
| 46 | hr = StrAllocConcat(&sczCommandLine, wzCommandLine, 0); | ||
| 47 | AppExitOnFailure(hr, "Failed to copy command line."); | ||
| 48 | |||
| 49 | argv = ::CommandLineToArgvW(sczCommandLine, &argc); | ||
| 50 | AppExitOnNullWithLastError(argv, hr, "Failed to parse command line."); | ||
| 51 | |||
| 52 | // Skip "ignored" argument/hack. | ||
| 53 | *pArgv = argv + 1; | ||
| 54 | *pArgc = argc - 1; | ||
| 55 | |||
| 56 | LExit: | ||
| 57 | ReleaseStr(sczCommandLine); | ||
| 58 | |||
| 59 | return hr; | ||
| 60 | } | ||
