1- // Copyright (C) 2022 Intel Corporation
1+ // Copyright (C) 2022-2023 Intel Corporation
22// SPDX-License-Identifier: MIT
33#include " PresentMon.h"
44
55#include < VersionHelpers.h>
66#include < shlwapi.h>
77#include < span>
88
9- static const std::string kEtlSessionName = " ETLProcessing" ;
10- static const std::string kRealTimeSessionName = " PMService" ;
9+ static const std::wstring kEtlSessionName = L " ETLProcessing" ;
10+ static const std::wstring kRealTimeSessionName = L " PMService" ;
1111
1212PresentMonSession::PresentMonSession ()
1313 : target_process_count_(0 ),
@@ -47,7 +47,7 @@ PM_STATUS PresentMonSession::StartTraceSession() {
4747 pm_consumer_->mTrackGPUVideo = true ;
4848 pm_consumer_->mTrackInput = true ;
4949
50- const char * etl_file_name = nullptr ;
50+ const wchar_t * etl_file_name = nullptr ;
5151 if (etl_file_name_.size () > 0 ) {
5252 etl_file_name = etl_file_name_.c_str ();
5353 pm_session_name_ = kEtlSessionName ;
@@ -110,7 +110,7 @@ void PresentMonSession::StopTraceSession() {
110110}
111111
112112PM_STATUS PresentMonSession::ProcessEtlFile (uint32_t client_process_id,
113- const std::string & etl_file_name,
113+ const std::wstring & etl_file_name,
114114 std::string& nsm_file_name) {
115115 if (pm_consumer_ != nullptr ) {
116116 // There is a current consumer running. For now,
@@ -205,13 +205,15 @@ ProcessInfo* PresentMonSession::GetProcessInfo(uint32_t processId) {
205205 // name and also periodically check if it has terminated. This will
206206 // fail (with GetLastError() == ERROR_ACCESS_DENIED) if the process was
207207 // run on another account, unless we're running with SeDebugPrivilege.
208- HANDLE handle = NULL ;
209- char const * processName = " <error>" ;
210- char path[MAX_PATH];
208+ wchar_t const * processName = L" <error>" ;
209+ wchar_t path[MAX_PATH];
211210 DWORD numChars = sizeof (path);
212- handle = OpenProcess (PROCESS_QUERY_LIMITED_INFORMATION, FALSE , processId);
213- if (QueryFullProcessImageNameA (handle, 0 , path, &numChars)) {
214- processName = PathFindFileNameA (path);
211+ HANDLE handle = OpenProcess (PROCESS_QUERY_LIMITED_INFORMATION, FALSE , processId);
212+ if (handle != NULL ) {
213+ if (QueryFullProcessImageNameW (handle, 0 , path, &numChars)) {
214+ processName = PathFindFileNameW (path);
215+ }
216+ CloseHandle (handle);
215217 }
216218
217219 InitProcessInfo (processInfo, processId, handle, processName);
@@ -222,7 +224,7 @@ ProcessInfo* PresentMonSession::GetProcessInfo(uint32_t processId) {
222224
223225void PresentMonSession::InitProcessInfo (ProcessInfo* processInfo, uint32_t processId,
224226 HANDLE handle,
225- std::string const & processName) {
227+ std::wstring const & processName) {
226228 processInfo->mHandle = handle;
227229 processInfo->mModuleName = processName;
228230 processInfo->mTargetProcess = true ;
@@ -661,7 +663,7 @@ void PresentMon::StopStreaming(uint32_t client_process_id,
661663}
662664
663665PM_STATUS PresentMon::ProcessEtlFile (uint32_t client_process_id,
664- const std::string & etl_file_name,
666+ const std::wstring & etl_file_name,
665667 std::string& nsm_file_name) {
666668 return etl_session_.ProcessEtlFile (client_process_id, etl_file_name,
667669 nsm_file_name);
0 commit comments