I'm using DIA Sdk to extract some information from PDB files. I create the non-com DiaSourceAlt object so I must use LocalFree to free strings.
The following piece of code works fine in x86 but, on x64, the LocalFree call corrupts the heap.
IDiaSymbol *lpSymbol;
BSTR bStrName;
...
hRes = lpSymbol->get_undecoratedNameEx(0x87FE, &bStrName);
if (SUCCEDED(hRes))
LocalFree(bStrName);
Any suggestion? (I'm using msdia90.dll)
Regards, Mauro.
After doing some reverse engineering I discovered that one MUST pass "(LPBYTE)bstr - 4" because msdia##.dll allocates using LocalAlloc and increments the pointer by four before returning data to the user.
I think this behavior is to emulate BSTR which stores the length of the string in a DWORD just before the address the pointer points to. I discovered the issue using the x64 version. In x86 although it has the same problem, app does not crash but generates a leak.
Regards.