| 974 | } |
| 975 | |
| 976 | BOOL StackWalker::LoadModules() |
| 977 | { |
| 978 | if (this->m_sw == NULL) |
| 979 | { |
| 980 | SetLastError(ERROR_DLL_INIT_FAILED); |
| 981 | return FALSE; |
| 982 | } |
| 983 | if (m_modulesLoaded != FALSE) |
| 984 | return TRUE; |
| 985 | |
| 986 | // Build the sym-path: |
| 987 | char* szSymPath = NULL; |
| 988 | if ((this->m_options & SymBuildPath) != 0) |
| 989 | { |
| 990 | const size_t nSymPathLen = 4096; |
| 991 | szSymPath = (char*)malloc(nSymPathLen); |
| 992 | if (szSymPath == NULL) |
| 993 | { |
| 994 | SetLastError(ERROR_NOT_ENOUGH_MEMORY); |
| 995 | return FALSE; |
| 996 | } |
| 997 | szSymPath[0] = 0; |
| 998 | // Now first add the (optional) provided sympath: |
| 999 | if (this->m_szSymPath != NULL) |
| 1000 | { |
| 1001 | strcat_s(szSymPath, nSymPathLen, this->m_szSymPath); |
| 1002 | strcat_s(szSymPath, nSymPathLen, ";"); |
| 1003 | } |
| 1004 | |
| 1005 | strcat_s(szSymPath, nSymPathLen, ".;"); |
| 1006 | |
| 1007 | const size_t nTempLen = 1024; |
| 1008 | char szTemp[nTempLen]; |
| 1009 | // Now add the current directory: |
| 1010 | if (GetCurrentDirectoryA(nTempLen, szTemp) > 0) |
| 1011 | { |
| 1012 | szTemp[nTempLen - 1] = 0; |
| 1013 | strcat_s(szSymPath, nSymPathLen, szTemp); |
| 1014 | strcat_s(szSymPath, nSymPathLen, ";"); |
| 1015 | } |
| 1016 | |
| 1017 | // Now add the path for the main-module: |
| 1018 | if (GetModuleFileNameA(NULL, szTemp, nTempLen) > 0) |
| 1019 | { |
| 1020 | szTemp[nTempLen - 1] = 0; |
| 1021 | for (char* p = (szTemp + strlen(szTemp) - 1); p >= szTemp; --p) |
| 1022 | { |
| 1023 | // locate the rightmost path separator |
| 1024 | if ((*p == '\\') || (*p == '/') || (*p == ':')) |
| 1025 | { |
| 1026 | *p = 0; |
| 1027 | break; |
| 1028 | } |
| 1029 | } // for (search for path separator...) |
| 1030 | if (strlen(szTemp) > 0) |
| 1031 | { |
| 1032 | strcat_s(szSymPath, nSymPathLen, szTemp); |
| 1033 | strcat_s(szSymPath, nSymPathLen, ";"); |
no test coverage detected