Skip to content

Commit 7d15f99

Browse files
committed
Merge tag '2026-03-27' into push-2026-03-27
Change-Id: I5591d208740fabe58bef3e70e777bb8a8d50ebba
2 parents 1f22144 + 0c30d74 commit 7d15f99

19 files changed

Lines changed: 899 additions & 120 deletions

.github/workflows/ci-windows.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ jobs:
4949
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
5050
with:
5151
name: PCMforWindows
52-
path: build/bin/**/*
52+
path: |
53+
build/bin/**/*
54+
third-party-software.txt

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ if(UNIX) # APPLE, LINUX, FREE_BSD
139139
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
140140

141141
install(DIRECTORY "perfmon" DESTINATION ${CMAKE_INSTALL_DATADIR}/pcm)
142+
install(FILES "third-party-software.txt" DESTINATION ${CMAKE_INSTALL_DATADIR}/pcm)
142143

143144
endif(UNIX)
144145

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ build_script:
1818
- msbuild src\WinMSRDriver\MSR.vcxproj /m /t:Build /p:Configuration=Release /p:Platform=x64
1919

2020
after_build:
21-
- cmd: 7z a pcm-all.zip %APPVEYOR_BUILD_FOLDER%\build\bin\Release\*.exe %APPVEYOR_BUILD_FOLDER%\build\bin\Release\*.dll %APPVEYOR_BUILD_FOLDER%\build\src\Release\*.lib %APPVEYOR_BUILD_FOLDER%\build\src\Release\*.exp %APPVEYOR_BUILD_FOLDER%\src\windows\PCM-Service.exe.config %APPVEYOR_BUILD_FOLDER%\src\WinMSRDriver\x64\Release\MSR\msr.*
21+
- cmd: 7z a pcm-all.zip %APPVEYOR_BUILD_FOLDER%\build\bin\Release\*.exe %APPVEYOR_BUILD_FOLDER%\build\bin\Release\*.dll %APPVEYOR_BUILD_FOLDER%\build\src\Release\*.lib %APPVEYOR_BUILD_FOLDER%\build\src\Release\*.exp %APPVEYOR_BUILD_FOLDER%\src\windows\PCM-Service.exe.config %APPVEYOR_BUILD_FOLDER%\src\WinMSRDriver\x64\Release\MSR\msr.* %APPVEYOR_BUILD_FOLDER%\third-party-software.txt
2222
artifacts:
2323
- path: pcm-all.zip
2424
name: pcm-all

doc/WINDOWS_HOWTO.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _For support of systems with more than _**_64_**_ logical cores you need to comp
1414
alternatively you can perform `cmake -B build`, open *PCM.sln* form *build* folder in and build required project in Visual Studio.
1515
.exe and .dll files will be located in *build\bin\Release* folder
1616
3. As Administrator create PCM directory in Windows "Program Files" directory (e.g. `C:\Program Files (x86)\PCM\`)
17-
4. As Administrator copy the msr.sys driver and pcm.exe into the PCM directory
17+
4. As Administrator copy the msr.sys driver into `c:\windows\system32` and pcm.exe into the PCM directory
1818
5. Run pcm.exe utility from the PCM directory as Administrator
1919

2020
For Windows 7+ and Windows Server 2008+ R2 the PCM utilities need to be run as Administrator:
@@ -51,7 +51,7 @@ If you do not want or cannot compile the msr.sys driver you might use a third-pa
5151
Instructions:
5252

5353
1. Download the free RealTemp utility package from [http://www.techpowerup.com/realtemp/](http://www.techpowerup.com/realtemp/) or any other free utility that uses the open-source WinRing0 driver (like OpenHardwareMonitor [http://code.google.com/p/open-hardware-monitor/downloads/list](http://code.google.com/p/open-hardware-monitor/downloads/list)).
54-
2. Copy WinRing0.dll, WinRing0.sys, WinRing0x64.dll, WinRing0x64.sys files from there into the PCM.exe binary location, into the PCM-Service.exe location and into c:\windows\system32
54+
2. Copy WinRing0.dll, WinRing0.sys, WinRing0x64.dll, WinRing0x64.sys files from there into c:\windows\system32
5555
3. Run the PCM.exe tool and/or go to step 6 (perfmon utility).
5656

5757
## Compile the Windows MSR driver
@@ -122,7 +122,7 @@ Starting from this release, **pcm-sensor-server** is now supported on Windows. T
122122
123123
### Running pcm-sensor-server on Windows
124124
125-
1. Create a directory for PCM in a protected location (e.g., `C:\Program Files\PCM\` or `C:\Program Files (x86)\PCM\`). Copy `msr.sys` and `pcm-sensor-server.exe` to this directory. **Important:** Do not place PCM binaries in user-writable directories (e.g., Downloads, Desktop, `C:\Users\Public\`) to prevent DLL planting attacks.
125+
1. Create a directory for PCM in a protected location (e.g., `C:\Program Files\PCM\` or `C:\Program Files (x86)\PCM\`). Copy `pcm-sensor-server.exe` to this directory and `msr.sys` to `c:\windows\system32`. If using WinPmem for memory bandwidth statistics, also copy `winpmem_x64.sys` (or `winpmem_x86.sys`) to `c:\windows\system32`. **Important:** Do not place PCM binaries or drivers in user-writable directories (e.g., Downloads, Desktop, `C:\Users\Public\`) to prevent driver planting attacks.
126126
127127
2. Run as Administrator (required for MSR access):
128128
```

src/cpucounters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3279,7 +3279,7 @@ PCM::PCM() :
32793279
#endif
32803280
#ifdef _MSC_VER
32813281
// WARNING: This driver code (msr.sys) is only for testing purposes, not for production use
3282-
Driver drv(Driver::msrLocalPath());
3282+
Driver drv(Driver::msrSystemPath());
32833283
// drv.stop(); // restart driver (usually not needed)
32843284
if (!drv.start())
32853285
{

src/cpucounters.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,11 @@ class PCM_API PCM
20742074
//! \return socket identifier
20752075
int32 getSocketId(uint32 core_id) const { return (int32)topology[core_id].socket_id; }
20762076

2077+
//! \brief Determines die of given processor ID within a socket
2078+
//! \param os_id processor identifier
2079+
//! \return die identifier
2080+
int32 getDieId(uint32 os_id) const { return (int32)topology[os_id].die_id; }
2081+
20772082
//! \brief Maps NUMA node ID to CPU socket ID
20782083
//! \param numa_node_id NUMA node identifier
20792084
//! \return socket identifier, or -1 if mapping is not available or numa_node_id is invalid

src/mmio.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ class PCMPmem : public WinPmem {
3838
SYSTEM_INFO sys_info;
3939
SecureZeroMemory(&sys_info, sizeof(sys_info));
4040

41-
GetCurrentDirectory(MAX_PATH - 10, driver_filename);
41+
// Use System32 directory to avoid untrusted search path vulnerability
42+
if (!GetSystemDirectory(driver_filename, MAX_PATH - 10))
43+
{
44+
std::wcerr << "Failed to get System32 directory path.\n";
45+
return -1;
46+
}
4247

4348
GetNativeSystemInfo(&sys_info);
4449
switch (sys_info.wProcessorArchitecture)
@@ -47,15 +52,15 @@ class PCMPmem : public WinPmem {
4752
_tcscat_s(driver_filename, MAX_PATH, TEXT("\\winpmem_x64.sys"));
4853
if (GetFileAttributes(driver_filename) == INVALID_FILE_ATTRIBUTES)
4954
{
50-
std::cerr << "ERROR: winpmem_x64.sys not found in current directory. Download it from https://github.com/Velocidex/WinPmem/blob/f044f340dd05658d026b0f293cdfa92876159872/kernel/binaries/winpmem_x64.sys .\n";
55+
std::cerr << "ERROR: winpmem_x64.sys not found in System32 directory. Download it from https://github.com/Velocidex/WinPmem/blob/f044f340dd05658d026b0f293cdfa92876159872/kernel/binaries/winpmem_x64.sys .\n";
5156
std::cerr << "ERROR: Memory bandwidth statistics will not be available.\n";
5257
}
5358
break;
5459
case PROCESSOR_ARCHITECTURE_INTEL:
5560
_tcscat_s(driver_filename, MAX_PATH, TEXT("\\winpmem_x86.sys"));
5661
if (GetFileAttributes(driver_filename) == INVALID_FILE_ATTRIBUTES)
5762
{
58-
std::cerr << "ERROR: winpmem_x86.sys not found in current directory. Download it from https://github.com/Velocidex/WinPmem/blob/f044f340dd05658d026b0f293cdfa92876159872/kernel/binaries/winpmem_x86.sys .\n";
63+
std::cerr << "ERROR: winpmem_x86.sys not found in System32 directory. Download it from https://github.com/Velocidex/WinPmem/blob/f044f340dd05658d026b0f293cdfa92876159872/kernel/binaries/winpmem_x86.sys .\n";
5964
std::cerr << "ERROR: Memory bandwidth statistics will not be available.\n";
6065
}
6166
break;

src/pcm-memory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ int mainThrows(int argc, char * argv[])
15121512
}
15131513
else if (check_argument_equals(*argv, {"--installDriver"}))
15141514
{
1515-
Driver tmpDrvObject = Driver(Driver::msrLocalPath());
1515+
Driver tmpDrvObject = Driver(Driver::msrSystemPath());
15161516
if (!tmpDrvObject.start())
15171517
{
15181518
tcerr << "Can not access CPU counters\n";

src/pcm-msr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int mainThrows(int argc, char * argv[])
123123
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
124124

125125
// WARNING: This driver code (msr.sys) is only for testing purposes, not for production use
126-
Driver drv = Driver(Driver::msrLocalPath());
126+
Driver drv = Driver(Driver::msrSystemPath());
127127
// drv.stop(); // restart driver (usually not needed)
128128
if (!drv.start())
129129
{

src/pcm-pcicfg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int mainThrows(int argc, char * argv[])
116116
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
117117

118118
// WARNING: This driver code (msr.sys) is only for testing purposes, not for production use
119-
Driver drv = Driver(Driver::msrLocalPath());
119+
Driver drv = Driver(Driver::msrSystemPath());
120120
// drv.stop(); // restart driver (usually not needed)
121121
if (!drv.start())
122122
{
@@ -137,7 +137,7 @@ int mainThrows(int argc, char * argv[])
137137
}
138138

139139
// List all PCI devices
140-
forAllDevices([&dec, &verbosity, &pciDB](const uint32 group, const uint32 bus, const uint32 device, const uint32 function, const uint32 device_id)
140+
forAllDevices([&dec, &verbosity, &pciDB](const uint32 group, const uint32 bus, const uint32 device, const uint32 function, const uint32 /* device_id */)
141141
{
142142
if (PciHandleType::exists(group, bus, device, function) == false)
143143
{

0 commit comments

Comments
 (0)