HyperDbg Debugger
Loading...
Searching...
No Matches
sympath.cpp File Reference

.sympath command More...

#include "pch.h"

Functions

VOID CommandSympathHelp ()
 help of the .sympath command
VOID CommandSympath (vector< CommandToken > CommandTokens, string Command)
 .sympath command handler

Detailed Description

.sympath command

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2021-05-27

Function Documentation

◆ CommandSympath()

VOID CommandSympath ( vector< CommandToken > CommandTokens,
string Command )

.sympath command handler

Parameters
CommandTokens
Command
Returns
VOID
46{
47 string SymbolServer = "";
48 string Token;
49
50 if (CommandTokens.size() == 1)
51 {
52 //
53 // Show the current symbol path
54 //
55 if (!CommandSettingsGetValueFromConfigFile("SymbolServer", SymbolServer))
56 {
57 ShowMessages("symbol server is not configured, please use '.help .sympath'\n");
58 }
59 else
60 {
61 ShowMessages("current symbol server is : %s\n", SymbolServer.c_str());
62 }
63 }
64 else
65 {
66 //
67 // Save the symbol path
68 //
69
70 //
71 // Because technically, the "https://" is containing characters that resemble the command token,
72 // it's better to use the symbol server in quotes, but due to the fact that for compatibility reasons,
73 // with the previous versions, we should support the old syntax, we should check if the symbol server
74 // is in quotes or not to support both syntaxes
75 //
76
77 //
78 // Trim the command
79 //
80 Trim(Command);
81
82 //
83 // Remove .sympath from it
84 //
85 Command.erase(0, GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).size());
86
87 //
88 // Trim it again
89 //
90 Trim(Command);
91
92 //
93 // Check if the symbol server starts with quotes
94 //
95 if (Command.at(0) == '\"')
96 {
97 //
98 // Means that the symbol server is in quotes
99 //
100 Command = GetCaseSensitiveStringFromCommandToken(CommandTokens.at(1));
101 }
102
103 //
104 // *** validate the symbols ***
105 //
106
107 //
108 // Check if the string contains '*'
109 //
110 CHAR Delimiter = '*';
111 if (Command.find(Delimiter) != std::string::npos)
112 {
113 //
114 // Found
115 //
116 Token = Command.substr(0, Command.find(Delimiter));
117 // using transform() function and ::tolower in STL
118 transform(Token.begin(), Token.end(), Token.begin(), ::tolower);
119
120 //
121 // Check if it starts with srv
122 //
123 if (!Token.compare("srv"))
124 {
125 //
126 // Save the config
127 //
128 CommandSettingsSetValueFromConfigFile("SymbolServer", Command);
129
130 //
131 // Show the message
132 //
133 ShowMessages("symbol server/path is configured successfully\n");
134 ShowMessages("use '.sym load', '.sym reload', or '.sym download' to load pdb files\n");
135 }
136 else
137 {
138 ShowMessages("symbol path is invalid\n\n");
140 return;
141 }
142 }
143 else
144 {
145 ShowMessages("symbol path is invalid\n\n");
147 return;
148 }
149 }
150}
char CHAR
Definition BasicTypes.h:33
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
VOID Trim(std::string &s)
trim from both ends and start of a string (in place)
Definition common.cpp:715
VOID CommandSettingsSetValueFromConfigFile(std::string OptionName, std::string OptionValue)
Sets the setting values from config file.
Definition settings.cpp:115
BOOLEAN CommandSettingsGetValueFromConfigFile(std::string OptionName, std::string &OptionValue)
Gets the setting values from config file.
Definition settings.cpp:60
VOID CommandSympathHelp()
help of the .sympath command
Definition sympath.cpp:24

◆ CommandSympathHelp()

VOID CommandSympathHelp ( )

help of the .sympath command

Returns
VOID
25{
26 ShowMessages(".sympath : shows and sets the symbol server and path.\n\n");
27
28 ShowMessages("syntax : \t.sympath\n");
29 ShowMessages("syntax : \t.sympath [SymServer (string)]\n");
30
31 ShowMessages("\n");
32 ShowMessages("\t\te.g : .sympath\n");
33 ShowMessages("\t\te.g : .sympath \"SRV*c:\\Symbols*https://msdl.microsoft.com/download/symbols\" \n");
34}