Skip to content

Commit 57d3dd6

Browse files
changed back to <FunctionName>W
1 parent 9f6dfd6 commit 57d3dd6

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

resource_detectors/process_detector_utils.cc

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,17 @@ std::vector<std::string> ExtractCommandWithArgs(const std::string &command_line_
8989
std::vector<std::string> GetCommandWithArgs(const int32_t &pid)
9090
{
9191
#ifdef _MSC_VER
92-
int argc = 0;
93-
LPTSTR cmdLine = GetCommandLine();
94-
95-
# ifdef UNICODE
96-
// for UNICODE
97-
LPWSTR *argvW = CommandLineToArgvW(cmdLine, &argc);
92+
int argc = 0;
93+
LPWSTR *argvW = CommandLineToArgvW(GetCommandLineW(), &argc);
9894
if (!argvW)
9995
{
100-
return {};
96+
return {}; // returns an empty vector if CommandLineToArgvW fails
10197
}
10298

10399
std::vector<std::string> args;
104100
for (int i = 0; i < argc; i++)
105101
{
102+
// Convert UTF-16 to UTF-8
106103
int size_needed = WideCharToMultiByte(CP_UTF8, 0, argvW[i], -1, NULL, 0, NULL, NULL);
107104
if (size_needed > 0)
108105
{
@@ -114,23 +111,7 @@ std::vector<std::string> GetCommandWithArgs(const int32_t &pid)
114111

115112
LocalFree(argvW);
116113
return args;
117-
# else
118-
// for Non-UNICODE
119-
LPSTR *argvA = CommandLineToArgvA(cmdLine, &argc);
120-
if (!argvA)
121-
{
122-
return {};
123-
}
124-
125-
std::vector<std::string> args;
126-
for (int i = 0; i < argc; i++)
127-
{
128-
args.push_back(argvA[i]);
129-
}
130-
131-
LocalFree(argvA);
132-
return args;
133-
# endif // endif for UNICODE
114+
#else
134115
std::string command_line_path = FormFilePath(pid, kCmdlineName);
135116
return ExtractCommandWithArgs(command_line_path);
136117
#endif

0 commit comments

Comments
 (0)