Can't enumerate appdomains with ICorPublishAppDomainEnum

0

I'm trying to inject a DLL and enumerate app domains in the target process:

void EnumAppDomains()
{
    HRESULT hr = 0;
    ICorPublish *pPublish = NULL;
    ICorPublishProcess *pProcess = NULL;
    ICorPublishAppDomainEnum *pDomainEnum = NULL;
    ICorPublishAppDomain *appDomains[1];

    hr = CoCreateInstance(CLSID_CorpubPublish, NULL, CLSCTX_INPROC_SERVER, IID_ICorPublish, (LPVOID*)&pPublish);
    if (!SUCCEEDED(hr))
    {
        DbgPrint(L"CoCreateInstance(): 0x%X\n", hr);
        return;
    }

    hr = pPublish->GetProcess(GetCurrentProcessId(), &pProcess);
    if (!SUCCEEDED(hr))
    {
        DbgPrint(L"ICorPublishProcess::GetProcess(): 0x%X\n", hr);
        return;
    }

    ...

It always fail at hr = pPublish->GetProcess(GetCurrentProcessId(), &pProcess);:

[4016] ICorPublishProcess::GetProcess(): 0x80070057

The error is invalid parameter, what could go wrong here?

c#
c++
asked on Stack Overflow Mar 26, 2020 by daisy

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0