MCPcopy Create free account
hub / github.com/JochenKalmbach/StackWalker / LoadModules

Method LoadModules

Main/StackWalker/StackWalker.cpp:910–1025  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

908}
909
910BOOL StackWalker::LoadModules()
911{
912 if (this->m_sw == NULL)
913 {
914 SetLastError(ERROR_DLL_INIT_FAILED);
915 return FALSE;
916 }
917 if (m_modulesLoaded != FALSE)
918 return TRUE;
919
920 // Build the sym-path:
921 char* szSymPath = NULL;
922 if ((this->m_options & SymBuildPath) != 0)
923 {
924 const size_t nSymPathLen = 4096;
925 szSymPath = (char*)malloc(nSymPathLen);
926 if (szSymPath == NULL)
927 {
928 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
929 return FALSE;
930 }
931 szSymPath[0] = 0;
932 // Now first add the (optional) provided sympath:
933 if (this->m_szSymPath != NULL)
934 {
935 strcat_s(szSymPath, nSymPathLen, this->m_szSymPath);
936 strcat_s(szSymPath, nSymPathLen, ";");
937 }
938
939 strcat_s(szSymPath, nSymPathLen, ".;");
940
941 const size_t nTempLen = 1024;
942 char szTemp[nTempLen];
943 // Now add the current directory:
944 if (GetCurrentDirectoryA(nTempLen, szTemp) > 0)
945 {
946 szTemp[nTempLen - 1] = 0;
947 strcat_s(szSymPath, nSymPathLen, szTemp);
948 strcat_s(szSymPath, nSymPathLen, ";");
949 }
950
951 // Now add the path for the main-module:
952 if (GetModuleFileNameA(NULL, szTemp, nTempLen) > 0)
953 {
954 szTemp[nTempLen - 1] = 0;
955 for (char* p = (szTemp + strlen(szTemp) - 1); p >= szTemp; --p)
956 {
957 // locate the rightmost path separator
958 if ((*p == '\\') || (*p == '/') || (*p == ':'))
959 {
960 *p = 0;
961 break;
962 }
963 } // for (search for path separator...)
964 if (strlen(szTemp) > 0)
965 {
966 strcat_s(szSymPath, nSymPathLen, szTemp);
967 strcat_s(szSymPath, nSymPathLen, ";");

Callers 2

ShowObjectMethod · 0.95
StackWalker.cppFile · 0.45

Calls 2

OnDbgHelpErrMethod · 0.95
InitMethod · 0.80

Tested by

no test coverage detected