{"record":{"id":"fb5f458c0c31fc92","repo":"slackhq/nebula","slug":"cocreateinstance-networklistmanager-s","errorCode":null,"errorMessage":"CoCreateInstance(NetworkListManager): %s","messagePattern":"CoCreateInstance\\(NetworkListManager\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"overlay/network_category_windows.go","lineNumber":278,"sourceCode":"\t\t\treturn windows.CoUninitialize, nil\n\t\tcase hrRPCEChangedMode:\n\t\t\treturn func() {}, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"CoInitializeEx: %w\", err)\n}\n\nfunc createNetworkListManager() (*iNetworkListManager, error) {\n\tvar nlm *iNetworkListManager\n\tr1, _, _ := procCoCreateInstance.Call(\n\t\tuintptr(unsafe.Pointer(&clsidNetworkListManager)),\n\t\t0,\n\t\tuintptr(clsCtxAll),\n\t\tuintptr(unsafe.Pointer(&iidINetworkListManager)),\n\t\tuintptr(unsafe.Pointer(&nlm)),\n\t)\n\tif hr := hresult(r1); hr.failed() {\n\t\treturn nil, fmt.Errorf(\"CoCreateInstance(NetworkListManager): %s\", hr)\n\t}\n\treturn nlm, nil\n}\n\n// setNetworkCategory locates the network connection bound to adapterGUID and\n// sets the category of its parent network. Returns errAdapterNotFound if the\n// adapter is not yet visible in the NLM enumeration.\nfunc setNetworkCategory(adapterGUID windows.GUID, cat networkCategory) error {\n\tdeinit, err := coInit()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer deinit()\n\n\tnlm, err := createNetworkListManager()\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/overlay/network_category_windows.go#L260-L296","documentation":"CoCreateInstance failed to instantiate the Network List Manager COM object (CLSID_NetworkListManager). createNetworkListManager calls CoCreateInstance after COM has been initialized, and any failing HRESULT is reported with this message. Without the NLM instance the library cannot enumerate networks or set the category for an adapter.","triggerScenarios":"Calling setNetworkCategory or Test_NLM_round_trip on Windows when the COM instantiation of the NLM class fails: CoInitializeEx was not called first on that thread (COM not initialized), the Network List Manager COM class is not registered (broken Windows install), class access is denied (security policy/hardened environment), or an out-of-memory condition.","commonSituations":"Calling NLM functions before coInit/CoInitializeEx on the thread; running under service hardening or restricted tokens that block CLSID access; Windows systems with damaged COM registration for the Network List Manager; non-Windows builds accidentally compiled (though the file is _windows.go).","solutions":["Ensure coInit/CoInitializeEx ran successfully on the same thread before createNetworkListManager","Read the printed HRESULT to distinguish REGDB_E_CLASSNOTREG (repair Windows/COM), E_ACCESSDENIED (permissions/policy), or E_OUTOFMEMORY","Run under an account that permits access to the Network List Manager COM class; check group policy/AV restrictions","Repair COM registration of the NetworkListManager class (sfc /scannow, re-register DLLs)","Verify the Network List Manager (netprofm) service is running"],"exampleFix":"// before\nr1, _, _ := procCoCreateInstance.Call(...) // COM never initialized on this goroutine\n// after\nif err := coInit(); err != nil { return err } // initialize COM first\nr1, _, _ := procCoCreateInstance.Call(...)","handlingStrategy":"try-catch","validationCode":"if runtime.GOOS != \"windows\" {\n    return fmt.Errorf(\"network list manager is windows-only\")\n}\n// ensure the Network List Manager service exists\nexec.Command(\"sc\", \"query\", \"netprofm\").Run()","typeGuard":null,"tryCatchPattern":"nlm, err := createNetworkListManager()\nif err != nil {\n    if strings.Contains(err.Error(), \"CoCreateInstance\") {\n        // check COM was initialized; retry after coInit or fail fast with HRESULT logged\n    }\n    return err\n}","preventionTips":["Always call coInit before any NLM COM call on the same thread","Run with an account not restricted by COM access policies","Verify netprofm service is running on the host","Keep Windows patched; REGDB_E_CLASSNOTREG indicates broken COM registration"],"tags":["windows","com","network"],"backgroundTag":"com-class-instantiation-failed","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}