You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 10自定义SNMP扩展代理安装配置故障排查求助

Troubleshooting 64-bit SNMP Extension Agent DLL Issues on Windows 10/Server 2016

Let’s walk through the most likely causes and fixes for your SNMP extension agent being ignored—since you’ve already ruled out 32-bit DLL mismatches, we’ll focus on the gotchas specific to modern 64-bit Windows systems:

1. Verify Unmangled Exported Functions

C++ name mangling is a common culprit here. Even if you implemented SnmpExtensionInit and SnmpExtensionQuery, the compiler might have altered their names (e.g., adding _SnmpExtensionInit@12 or similar for __stdcall).

  • Use the dumpbin tool (included with Visual Studio) to check your DLL’s export table:
    dumpbin /exports "C:\Program Files\testing\MyAgent.dll"
    
  • Look for exact matches of SnmpExtensionInit and SnmpExtensionQuery (no extra characters or underscores). If they’re missing, wrap your function declarations in extern "C" to disable name mangling:
    extern "C" {
        BOOL WINAPI SnmpExtensionInit(DWORD dwTimeZeroReference, DWORD dwReserved, AsnObjectIdentifier *pFirstSupportedRegion);
        BOOL WINAPI SnmpExtensionQuery(BYTE bRequestType, SnmpVarBindList *pVarBindList, AsnInteger *pErrorStatus, AsnInteger *pErrorIndex);
    }
    

2. Check for Missing Dependencies

Your DLL might be failing to load because it depends on other libraries (like 64-bit Visual C++ Runtime) that aren’t present on the target system.

  • Use Dependency Walker (or dumpbin /dependents) to scan your DLL:
    dumpbin /dependents "C:\Program Files\testing\MyAgent.dll"
    
  • Ensure all listed dependencies exist in the system PATH or the same directory as your DLL. Install the matching 64-bit Visual C++ Redistributable package if needed.

3. Fix Registry and File Permissions

The SNMP service runs under the Local Service account, which needs read access to both your registry keys and DLL file:

  • Registry Permissions:
    • Open Regedit, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\MyAgent\CurrentVersion and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ExtensionAgents.
    • Right-click each key → Permissions → Add Local Service → Grant it Read permissions.
  • File/Directory Permissions:
    • Right-click C:\Program Files\testing\ → Properties → Security tab → Add Local Service → Grant Read & execute permissions for the folder and DLL.

4. Validate Registry Path Configuration

Double-check your registry entries to avoid subtle typos or expansion issues:

  • Confirm the Pathname value in HKEY_LOCAL_MACHINE\SOFTWARE\MyAgent\CurrentVersion is set as REG_EXPAND_SZ (you mentioned this, but ensure there are no typos in the path, like extra spaces or misspelled folder names).
  • If you used environment variables (e.g., %PROGRAMFILES%), test expanding them manually to ensure they resolve to the correct 64-bit path (modern Windows expands %PROGRAMFILES% to C:\Program Files for 64-bit processes).

5. Enable Verbose SNMP Logging

Enable debug logging to get more specific error details from the SNMP service:

  1. Open Regedit and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters.
  2. Create a new DWORD (32-bit) Value named DebugLevel and set its value to 0x00000003 (enables error and warning logs).
  3. Restart the SNMP service.
  4. Check the System Event Log again—you’ll likely get a more detailed error code (e.g., ERROR_PROC_NOT_FOUND if functions are missing, or ERROR_ACCESS_DENIED for permissions issues).

6. Test DLL Loading Manually

Write a simple 64-bit test program to verify your DLL loads correctly and exposes the required functions outside of the SNMP service context:

#include <windows.h>
#include <stdio.h>
#include <snmp.h>

// Define function pointers matching SNMP API signatures
typedef BOOL (WINAPI *SnmpExtensionInitFunc)(DWORD, DWORD, AsnObjectIdentifier*);
typedef BOOL (WINAPI *SnmpExtensionQueryFunc)(BYTE, SnmpVarBindList*, AsnInteger*, AsnInteger*);

int main() {
    HMODULE hDll = LoadLibrary(L"C:\\Program Files\\testing\\MyAgent.dll");
    if (!hDll) {
        printf("LoadLibrary failed! Error code: %d\n", GetLastError());
        return 1;
    }

    SnmpExtensionInitFunc initFunc = (SnmpExtensionInitFunc)GetProcAddress(hDll, "SnmpExtensionInit");
    if (!initFunc) {
        printf("Failed to find SnmpExtensionInit! Error code: %d\n", GetLastError());
        FreeLibrary(hDll);
        return 1;
    }

    SnmpExtensionQueryFunc queryFunc = (SnmpExtensionQueryFunc)GetProcAddress(hDll, "SnmpExtensionQuery");
    if (!queryFunc) {
        printf("Failed to find SnmpExtensionQuery! Error code: %d\n", GetLastError());
        FreeLibrary(hDll);
        return 1;
    }

    printf("Success! DLL loaded and functions found.\n");
    FreeLibrary(hDll);
    return 0;
}

Compile this as a 64-bit executable and run it. If it fails, the error code will point you directly to the problem (e.g., 126 for missing dependencies, 127 for missing functions).


内容的提问来源于stack exchange,提问作者Navjot Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 19:42:53