It is definitely the SYMOPT_EXACT_SYMBOL setting which is causing the 1168 error to be thrown. Otherwise having multiple symbols or '::' is fine, and the API can return a valid address.
One work-around would be to use mangled names:
#pragma optimize("", off)
class base
{
public:
void method(int i) { printf("in method(int)\n"); }
void method(double d) { printf("in method(double)\n"); }
};
int __cdecl main(int argc, char* argv[])
{
HANDLE hProcess = GetCurrentProcess();
SymInitialize(hProcess, NULL, TRUE);
SymSetOptions(SYMOPT_EXACT_SYMBOLS);
SetLastError(0);
SYMBOL_INFO symbol = {0};
symbol.SizeOfStruct = sizeof(symbol);
BOOL result = SymFromName(hProcess, "cpptest!?method@base@@QEAAXH@Z", &symbol);
printf("symbol : 0x%I64X\n", symbol.Address);
printf("error : %u, result : %u\n", GetLastError(), result);
return 0;
}
And for future reference, WinDbg uses the IDebugSymbols::StartSymbolMatch API to lookup multiple symbols.