大网数据广告活动
性能与资源

Initializing the Symbol Handler

· 52CE 我爱测

The following code demonstrates how to initialize the symbol handler.

The following code demonstrates how to initialize the symbol handler. The SymSetOptions function defers symbol loading until symbol information is requested. The code loads the symbols for each module in the specified process by passing a value of TRUE for the bInvade parameter of the SymInitialize function. (This function calls the SymLoadModule64 function for each module the process has mapped into its address space.)

If the specified process is not the process that called SymInitialize, the code passes a process identifier as the first parameter of SymInitialize.

Specifying NULL as the second parameter of SymInitialize indicates that the symbol handler should use the default search path to locate symbol files. For detailed information on how the symbol handler locates symbol files or how an application can specify a symbol search path, see Symbol Paths.

DWORD  error;
HANDLE hCurrentProcess;
HANDLE hProcess;

SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);

hCurrentProcess = GetCurrentProcess();

if (!DuplicateHandle(hCurrentProcess, hCurrentProcess, hCurrentProcess, &hProcess, 0, FALSE, DUPLICATE_SAME_ACCESS))
{
    // DuplicateHandle failed
    error = GetLastError();
    printf("DuplicateHandle returned error : %d\n", error);
    return FALSE;
}

if (!SymInitialize(hProcess, NULL, TRUE))
{
    // SymInitialize failed
    error = GetLastError();
    printf("SymInitialize returned error : %d\n", error);
    return FALSE;
}

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 07/14/2025
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。