Skip to content

Commit 083cea9

Browse files
Fix PresentMon2.sln build
1 parent 1f6be67 commit 083cea9

File tree

5 files changed

+30
-29
lines changed

5 files changed

+30
-29
lines changed

IntelPresentMon/PresentMonService/NamedPipeCmdProcess.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2022 Intel Corporation
1+
// Copyright (C) 2022-2023 Intel Corporation
22
// SPDX-License-Identifier: MIT
33
#include "NamedPipeCmdProcess.h"
44
#include "..\PresentMonUtils\NamedPipeHelper.h"
@@ -20,8 +20,8 @@ bool EncodeStartStream(PresentMon* pm, MemBuffer* rqstBuf, MemBuffer* rspBuf) {
2020
rspStatus = pm->StartStreaming(genRqstInfo->clientProcessId,
2121
genRqstInfo->targetProcessId, nsmFileName);
2222
} else {
23-
std::string etlFileName = genRqstInfo->etlFileName;
24-
rspStatus = pm->ProcessEtlFile(genRqstInfo->clientProcessId, etlFileName, nsmFileName);
23+
std::wstring wetlFileName(genRqstInfo->etlFileName, genRqstInfo->etlFileName + strlen(genRqstInfo->etlFileName));
24+
rspStatus = pm->ProcessEtlFile(genRqstInfo->clientProcessId, wetlFileName, nsmFileName);
2525
}
2626

2727
IPMSMResponseHeader response{};

IntelPresentMon/PresentMonService/PresentMon.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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

1212
PresentMonSession::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

112112
PM_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

223225
void 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

663665
PM_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);

IntelPresentMon/PresentMonService/PresentMon.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2022 Intel Corporation
1+
// Copyright (C) 2022-2023 Intel Corporation
22
// SPDX-License-Identifier: MIT
33
#pragma once
44
#include <Windows.h>
@@ -22,7 +22,7 @@ struct SwapChainData {
2222
};
2323

2424
struct ProcessInfo {
25-
std::string mModuleName;
25+
std::wstring mModuleName;
2626
std::unordered_map<uint64_t, SwapChainData> mSwapChain;
2727
HANDLE mHandle;
2828
bool mTargetProcess;
@@ -43,7 +43,7 @@ class PresentMonSession {
4343
bool IsTraceSessionActive() { return (pm_consumer_ != nullptr); }
4444

4545
PM_STATUS ProcessEtlFile(uint32_t client_process_id,
46-
const std::string& etl_file_name,
46+
const std::wstring& etl_file_name,
4747
std::string& nsm_file_name);
4848

4949
PM_STATUS StartStreaming(uint32_t client_process_id,
@@ -95,7 +95,7 @@ class PresentMonSession {
9595
uint64_t stopQpc, bool* hitStopQpc);
9696
ProcessInfo* GetProcessInfo(uint32_t processId);
9797
void InitProcessInfo(ProcessInfo* processInfo, uint32_t processId,
98-
HANDLE handle, std::string const& processName);
98+
HANDLE handle, std::wstring const& processName);
9999
void UpdateProcesses(
100100
std::vector<ProcessEvent> const& processEvents,
101101
std::vector<std::pair<uint32_t, uint64_t>>* terminatedProcesses);
@@ -108,7 +108,7 @@ class PresentMonSession {
108108
void CheckForTerminatedRealtimeProcesses(
109109
std::vector<std::pair<uint32_t, uint64_t>>* terminatedProcesses);
110110

111-
std::string pm_session_name_;
111+
std::wstring pm_session_name_;
112112

113113
std::unique_ptr<PMTraceConsumer> pm_consumer_;
114114
TraceSession trace_session_;
@@ -131,7 +131,7 @@ class PresentMonSession {
131131
std::atomic<bool> quit_output_thread_;
132132
std::atomic<bool> process_trace_finished_;
133133

134-
std::string etl_file_name_;
134+
std::wstring etl_file_name_;
135135

136136
// Event for when streaming has started
137137
std::unique_ptr<std::remove_pointer_t<HANDLE>, HandleDeleter>
@@ -162,7 +162,7 @@ class PresentMon {
162162
void StopStreaming(uint32_t client_process_id, uint32_t target_process_id);
163163

164164
PM_STATUS ProcessEtlFile(uint32_t client_process_id,
165-
const std::string& etl_file_name,
165+
const std::wstring& etl_file_name,
166166
std::string& nsm_file_name);
167167

168168
std::vector<std::shared_ptr<pwr::PowerTelemetryAdapter>> EnumerateAdapters();

IntelPresentMon/Streamer/Streamer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2022 Intel Corporation
1+
// Copyright (C) 2022-2023 Intel Corporation
22
// SPDX-License-Identifier: MIT
33
// Streamer.cpp : Defines the functions for the static library.
44

@@ -120,7 +120,7 @@ void Streamer::ProcessPresentEvent(
120120
PresentEvent* present_event,
121121
PresentMonPowerTelemetryInfo* power_telemetry_info,
122122
CpuTelemetryInfo* cpu_telemetry_info, uint64_t last_present_qpc,
123-
uint64_t last_displayed_qpc, std::string app_name,
123+
uint64_t last_displayed_qpc, std::wstring app_name,
124124
std::bitset<static_cast<size_t>(GpuTelemetryCapBits::gpu_telemetry_count)>
125125
gpu_telemetry_cap_bits,
126126
std::bitset<static_cast<size_t>(CpuTelemetryCapBits::cpu_telemetry_count)>
@@ -181,8 +181,7 @@ void Streamer::ProcessPresentEvent(
181181
// updated in the copy above.
182182
data.present_event.last_present_qpc = last_present_qpc;
183183
data.present_event.last_displayed_qpc = last_displayed_qpc;
184-
app_name.copy(data.present_event.application,
185-
sizeof(data.present_event.application));
184+
app_name.assign(data.present_event.application, data.present_event.application + sizeof(data.present_event.application));
186185
// Now copy the power telemetry data
187186
memcpy_s(&data.power_telemetry, sizeof(PresentMonPowerTelemetryInfo),
188187
power_telemetry_info, sizeof(PresentMonPowerTelemetryInfo));

IntelPresentMon/Streamer/Streamer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2022 Intel Corporation
1+
// Copyright (C) 2022-2023 Intel Corporation
22
// SPDX-License-Identifier: MIT
33
#pragma once
44

@@ -43,7 +43,7 @@ class Streamer {
4343
PresentEvent* present_event,
4444
PresentMonPowerTelemetryInfo* power_telemetry_info,
4545
CpuTelemetryInfo* cpu_telemetry_info, uint64_t last_present_qpc,
46-
uint64_t last_displayed_qpc, std::string app_name,
46+
uint64_t last_displayed_qpc, std::wstring app_name,
4747
std::bitset<static_cast<size_t>(GpuTelemetryCapBits::gpu_telemetry_count)>
4848
gpu_telemetry_cap_bits,
4949
std::bitset<static_cast<size_t>(CpuTelemetryCapBits::cpu_telemetry_count)>

0 commit comments

Comments
 (0)