Skip to content

Commit

Permalink
common: Use SHGetFolderPathA instead of LOCALAPPDATA env var.
Browse files Browse the repository at this point in the history
As the later is not present on Windows XP.

Fixes issue #8.
  • Loading branch information
jrfonseca committed Apr 27, 2015
1 parent c73961d commit 5ff4d8d
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/common/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
*/

#include <assert.h>
#include <stdlib.h>

#include <windows.h>
#include <tchar.h>
#include <stdlib.h>
#include <psapi.h>
#include <shlobj.h>
#include <dbghelp.h>

#include "outdbg.h"
Expand Down Expand Up @@ -58,17 +59,23 @@ InitializeSym(HANDLE hProcess, BOOL fInvadeProcess)
{
// Provide default symbol search path
// http://msdn.microsoft.com/en-gb/library/windows/hardware/ff558829.aspx
char szSymSearchPathBuf[512];
char szSymSearchPathBuf[MAX_PATH * 2];
const char *szSymSearchPath = NULL;
if (getenv("_NT_SYMBOL_PATH") == NULL &&
getenv("_NT_ALTERNATE_SYMBOL_PATH") == NULL) {
const char *szLocalAppData = getenv("LOCALAPPDATA");
assert(szLocalAppData != NULL);
_snprintf(szSymSearchPathBuf,
sizeof szSymSearchPathBuf,
"srv*%s\\drmingw*http://msdl.microsoft.com/download/symbols",
szLocalAppData);
szSymSearchPath = szSymSearchPathBuf;
char szLocalAppData[MAX_PATH];
HRESULT hr = SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, szLocalAppData);
assert(SUCCEEDED(hr));
if (SUCCEEDED(hr)) {
_snprintf(szSymSearchPathBuf,
sizeof szSymSearchPathBuf,
"srv*%s\\drmingw*http://msdl.microsoft.com/download/symbols",
szLocalAppData);
szSymSearchPath = szSymSearchPathBuf;
} else {
// No cache
szSymSearchPath = "srv*http://msdl.microsoft.com/download/symbols";
}
}

return SymInitialize(hProcess, szSymSearchPath, fInvadeProcess);
Expand Down

0 comments on commit 5ff4d8d

Please sign in to comment.