Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ExePayloadRef for PrimaryPayloadId and SecondaryPayloadId #532

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

drolevar
Copy link
Contributor

@drolevar drolevar commented Jun 20, 2024

This is a fix for the issue wixtoolset/issues#8673 with the custom BootstrapperApplication Id. This property can be anything, for example, "MyBootstrapper", but it's later assigned to PrimaryPayloadId, which is matched against Payload Id here:

    // Find the primary and secondary bootstrapper application payloads.
    for (DWORD i = 0; i < pUserExperience->payloads.cPayloads; ++i)
    {
        BURN_PAYLOAD* pPayload = pUserExperience->payloads.rgPayloads + i;

        if (!pUserExperience->pPrimaryExePayload && CSTR_EQUAL == ::CompareStringOrdinal(pPayload->sczKey, -1, sczPrimaryId, -1, FALSE))
        {
            pUserExperience->pPrimaryExePayload = pPayload;
        }
        else if (fFoundSecondary && !pUserExperience->pSecondaryExePayload && CSTR_EQUAL == ::CompareStringOrdinal(pPayload->sczKey, -1, sczSecondaryId, -1, FALSE))
        {
            pUserExperience->pSecondaryExePayload = pPayload;
        }
    }

While ExePayloadRef is exactly the reference to the exe payload.

@drolevar
Copy link
Contributor Author

@robmen Please, tell if more stuff has to be done, like unit tests, etc.

@robmen
Copy link
Member

robmen commented Jul 15, 2024

Yeah, need the following:

  1. Reference an open issue, it'll need to be approved by triage
  2. Add a test (unit or integration, whichever is most appropriate... this one should be a unit test) - especially for an issue like this which is a very subtle change

@drolevar
Copy link
Contributor Author

drolevar commented Aug 1, 2024

@robmen Ready. Created the issue and added the test.

@drolevar
Copy link
Contributor Author

drolevar commented Sep 5, 2024

@robmen Anything else missing in the PR?

@robmen
Copy link
Member

robmen commented Sep 5, 2024

Nothing missing but time. I'm currently focused on customer work. This PR, in particular, I need time to dig into and make sure I understand the root cause. So, it takes more than a cursory look. The added test case is very much appreciated as it will highlight the broken code path.

@drolevar
Copy link
Contributor Author

drolevar commented Sep 9, 2024

@robmen To facilitate your root cause analysis a little bit.

This issue was introduced in #496.

Prior to that, the application was loaded in burn/engine/userexperience.cpp, in UserExperienceLoad(...) like this:

    LPCWSTR wzPath = pUserExperience->payloads.rgPayloads[0].sczLocalFilePath;
    ...
    // Load BA DLL.
    pUserExperience->hUXModule = ::LoadLibraryExW(wzPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);

So it was the first Payload child of the UX element.

With #496 the UX element got a PrimaryPayloadId element, which is now parsed and then matched to the Id of the Payload in BootstrapperApplicationParseFromXml(...) in burn/engine/bootstrapperapplication.cpp:

    // @PrimaryPayloadId
    hr = XmlGetAttributeEx(pixnUserExperienceNode, L"PrimaryPayloadId", &sczPrimaryId);
    ExitOnRequiredXmlQueryFailure(hr, "Failed to get @PrimaryPayloadId.");

    // @SecondaryPayloadId
    hr = XmlGetAttributeEx(pixnUserExperienceNode, L"SecondaryPayloadId", &sczSecondaryId);
    ExitOnOptionalXmlQueryFailure(hr, fFoundSecondary, "Failed to get @SecondaryPayloadId.");

    ...

    // Find the primary and secondary bootstrapper application payloads.
    for (DWORD i = 0; i < pUserExperience->payloads.cPayloads; ++i)
    {
        BURN_PAYLOAD* pPayload = pUserExperience->payloads.rgPayloads + i;

        if (!pUserExperience->pPrimaryExePayload && CSTR_EQUAL == ::CompareStringOrdinal(pPayload->sczKey, -1, sczPrimaryId, -1, FALSE))
        {
            pUserExperience->pPrimaryExePayload = pPayload;
        }
        else if (fFoundSecondary && !pUserExperience->pSecondaryExePayload && CSTR_EQUAL == ::CompareStringOrdinal(pPayload->sczKey, -1, sczSecondaryId, -1, FALSE))
        {
            pUserExperience->pSecondaryExePayload = pPayload;
        }
    }

So currently if one sets a custom Id to the BootstrapperApplication, it's set used as an Id in the Payload element, but not used in the PrimaryPayloadId attribute, so matching in BootstrapperApplicationParseFromXml(...) fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants