diff --git a/preview/MsixCore/msixmgr/PSFScriptExecuter.cpp b/preview/MsixCore/msixmgr/PSFScriptExecuter.cpp index b5c5f041..21241034 100644 --- a/preview/MsixCore/msixmgr/PSFScriptExecuter.cpp +++ b/preview/MsixCore/msixmgr/PSFScriptExecuter.cpp @@ -19,9 +19,14 @@ HRESULT PSFScriptExecuter::ExecuteForAddRequest() // Read script parameters from PSF config and update executionInfo RETURN_IF_FAILED(m_msixRequest->GetPackageInfo()->ProcessPSFIfNecessary()); - - std::wstring workingDirectory = m_msixRequest->GetPackageInfo()->GetExecutionInfo()->workingDirectory; + std::wstring scriptName = m_msixRequest->GetPackageInfo()->GetScriptSettings()->scriptPath; + if (scriptName.length() == 0) + { + return S_OK; + } + + std::wstring workingDirectory = m_msixRequest->GetPackageInfo()->GetExecutionInfo()->workingDirectory; std::wstring scriptPath = workingDirectory + L"\\" + scriptName; std::wstring psArguments = L"-file \"" + scriptPath + L"\""; diff --git a/preview/MsixCore/msixmgr/RegistryDevirtualizer.cpp b/preview/MsixCore/msixmgr/RegistryDevirtualizer.cpp index 93c8cf11..eb5a7a78 100644 --- a/preview/MsixCore/msixmgr/RegistryDevirtualizer.cpp +++ b/preview/MsixCore/msixmgr/RegistryDevirtualizer.cpp @@ -136,10 +136,14 @@ HRESULT RegistryDevirtualizer::CopyAndDevirtualizeRegistryTree(RegistryKey* virt } RETURN_IF_FAILED(RegistryKey::EnumKeyAndDoActionForAllSubkeys(virtualKey, - [&](PCWSTR subKeyName, RegistryKey*, bool*) -> HRESULT + [&](PCWSTR enumeratedSubKeyName, RegistryKey*, bool*) -> HRESULT { + std::wstring subKeyNameWstring(enumeratedSubKeyName); + RETURN_IF_FAILED(DetokenizeData(subKeyNameWstring)); + PCWSTR subKeyName = subKeyNameWstring.c_str(); + RegistryKey sourceSubKey; - RETURN_IF_FAILED(virtualKey->OpenSubKey(subKeyName, KEY_READ, &sourceSubKey)); + RETURN_IF_FAILED(virtualKey->OpenSubKey(enumeratedSubKeyName, KEY_READ, &sourceSubKey)); TraceLoggingWrite(g_MsixTraceLoggingProvider, "Creating subkey", @@ -189,6 +193,8 @@ HRESULT RegistryDevirtualizer::CopyAndDevirtualizeRegistryTree(RegistryKey* virt // for each value of this key, devirtualize it and write it to the real key. for (DWORD i = 0; i < valuesCount; i++) { + valueNameBuffer[0] = 0; + valueDataBuffer[0] = 0; DWORD nameLength = static_cast(valueNameBuffer.size()); DWORD dataLength = static_cast(valueDataBuffer.size()); valueType = REG_NONE; @@ -197,6 +203,7 @@ HRESULT RegistryDevirtualizer::CopyAndDevirtualizeRegistryTree(RegistryKey* virt reinterpret_cast(&valueDataBuffer[0]), &dataLength)); std::wstring valueNameString(valueNameBuffer.begin(), valueNameBuffer.end()); + RETURN_IF_FAILED(DetokenizeData(valueNameString)); RETURN_IF_FAILED(DevirtualizeValue(realKey, valueNameString.c_str(), valueDataBuffer, dataLength, valueType)); } return S_OK;