test: fixed unnamed sessions
This commit is contained in:
parent
313a26c8e3
commit
73251b4f3b
5 changed files with 92 additions and 31 deletions
|
|
@ -475,7 +475,7 @@ void Endpoint::setFlow() {
|
||||||
if(FAILED(this->endpoint->QueryInterface(__uuidof(IMMEndpoint), (void**)&flowGetter)))
|
if(FAILED(this->endpoint->QueryInterface(__uuidof(IMMEndpoint), (void**)&flowGetter)))
|
||||||
{ log_debugcpp("no flow..."); }
|
{ log_debugcpp("no flow..."); }
|
||||||
EDataFlow MSflow;
|
EDataFlow MSflow;
|
||||||
HRESULT vafllar = flowGetter->GetDataFlow(&MSflow);
|
flowGetter->GetDataFlow(&MSflow);
|
||||||
this->flow = (MSflow == EDataFlow::eRender ? Flows::FLOW_PLAYBACK : Flows::FLOW_CAPTURE);
|
this->flow = (MSflow == EDataFlow::eRender ? Flows::FLOW_PLAYBACK : Flows::FLOW_CAPTURE);
|
||||||
log_debugcpp("Endpoint flow: " + std::to_string(flow));
|
log_debugcpp("Endpoint flow: " + std::to_string(flow));
|
||||||
flowGetter->Release();
|
flowGetter->Release();
|
||||||
|
|
|
||||||
|
|
@ -196,10 +196,13 @@ std::wstring Session::fetchProcessName(DWORD pid) {
|
||||||
/*
|
/*
|
||||||
* https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot
|
* https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot
|
||||||
* https://stackoverflow.com/questions/11843368/how-to-get-process-description
|
* https://stackoverflow.com/questions/11843368/how-to-get-process-description
|
||||||
|
* https://notes.indezine.com/2018/05/microsoft-locale-ids.html#:~:text=Wait%2C%201033%20is%20the%20decimal,ID%20for%20English%20%E2%80%93%20United%20States.
|
||||||
|
* https://stackoverflow.com/questions/64321036/c-win32-getting-app-name-using-pid-and-executable-path
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Executable path retrieval */
|
/* Executable path retrieval */
|
||||||
std::wstring exePath = L"";
|
std::wstring exePath = L"";
|
||||||
|
std::wstring msixName;
|
||||||
|
|
||||||
HANDLE processList = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pid);
|
HANDLE processList = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pid);
|
||||||
if (processList == INVALID_HANDLE_VALUE) {
|
if (processList == INVALID_HANDLE_VALUE) {
|
||||||
|
|
@ -224,55 +227,111 @@ std::wstring Session::fetchProcessName(DWORD pid) {
|
||||||
}
|
}
|
||||||
CloseHandle(processList);
|
CloseHandle(processList);
|
||||||
|
|
||||||
/* File description retrieval */
|
/* File description retrieval: size and available lang-codepages */
|
||||||
struct LANGANDCODEPAGE {
|
struct LANGANDCODEPAGE {
|
||||||
WORD wLanguage;
|
WORD wLanguage;
|
||||||
WORD wCodePage;
|
WORD wCodePage;
|
||||||
} *translationArray;
|
} *translationArray;
|
||||||
|
|
||||||
DWORD filler;
|
DWORD filler;
|
||||||
DWORD fileVersionInfoSize = GetFileVersionInfoSizeW(exePath.c_str(), &filler);
|
DWORD fileVersionInfoSize = GetFileVersionInfoSizeExW
|
||||||
|
(FILE_VER_GET_LOCALISED | FILE_VER_GET_NEUTRAL, exePath.c_str(), &filler);
|
||||||
if (!fileVersionInfoSize) return exePath;
|
if (!fileVersionInfoSize) return exePath;
|
||||||
|
|
||||||
void* fileVersionInfo = malloc(fileVersionInfoSize);
|
void* fileVersionInfo = malloc(fileVersionInfoSize);
|
||||||
if(!GetFileVersionInfoW(exePath.c_str(),0,fileVersionInfoSize, fileVersionInfo))
|
if(!GetFileVersionInfoExW(FILE_VER_GET_LOCALISED | FILE_VER_GET_NEUTRAL,
|
||||||
|
exePath.c_str(),0,fileVersionInfoSize, fileVersionInfo))
|
||||||
return exePath;
|
return exePath;
|
||||||
|
|
||||||
UINT translationArrayLen = 0;
|
UINT translationArrayLen = 0;
|
||||||
if (!VerQueryValueW(fileVersionInfo, L"\\VarFileInfo\\Translation", (LPVOID*)&translationArray, &translationArrayLen))
|
if (!VerQueryValueW(fileVersionInfo, L"\\VarFileInfo\\Translation", (LPVOID*)&translationArray, &translationArrayLen))
|
||||||
return exePath;
|
return exePath;
|
||||||
|
|
||||||
bool match = false;
|
//File descriptor parsing
|
||||||
for (UINT i = 0; i < (translationArrayLen / sizeof(LANGANDCODEPAGE)); i++) {
|
//TODO: https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserpreferreduilanguages
|
||||||
wchar_t fileDescriptionKey[256];
|
/* It is possible to retrieve user languages and try to use one of those before falling back to whatever
|
||||||
|
* is available. Also possible to hardcode en-US or any other lang-codepage combo. When an actual translation
|
||||||
|
* sysem is put in place, I'll come finish this up.
|
||||||
|
*/
|
||||||
|
uint64_t availableLangs = (translationArrayLen / sizeof(LANGANDCODEPAGE));
|
||||||
|
if (!availableLangs) return exePath;
|
||||||
|
|
||||||
|
int8_t syslangIdx = -1;
|
||||||
|
wchar_t metadataStringKey[256];
|
||||||
|
wchar_t* metadataString = NULL;
|
||||||
|
//std::wstring name;
|
||||||
|
for (UINT i = 0; i < availableLangs; i++) {
|
||||||
LANGID defaultUILanguage = GetUserDefaultUILanguage();
|
LANGID defaultUILanguage = GetUserDefaultUILanguage();
|
||||||
if (defaultUILanguage != translationArray[i].wLanguage)
|
if (defaultUILanguage != translationArray[i].wLanguage)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
match = true;
|
syslangIdx = i;
|
||||||
wchar_t* fileDescription = NULL;
|
break;
|
||||||
UINT fileDescriptionSize = 0;
|
|
||||||
swprintf(fileDescriptionKey, L"\\StringFileInfo\\%04x%04x\\FileDescription",
|
|
||||||
translationArray[i].wLanguage, translationArray[i].wCodePage);
|
|
||||||
if (VerQueryValueW(fileVersionInfo, fileDescriptionKey, (LPVOID*)&fileDescription, &fileDescriptionSize)) {
|
|
||||||
exePath = std::wstring(fileDescription);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match && 1 <= (translationArrayLen / sizeof(LANGANDCODEPAGE))) {
|
UINT metadataStringSize = 0;
|
||||||
wchar_t fileDescriptionKey[256];
|
swprintf(metadataStringKey, L"\\StringFileInfo\\%04x%04x\\FileDescription",
|
||||||
|
translationArray[(syslangIdx < 0 ? 0 : syslangIdx)].wLanguage,
|
||||||
|
translationArray[(syslangIdx < 0 ? 0 : syslangIdx)].wCodePage);
|
||||||
|
if (VerQueryValueW(fileVersionInfo, metadataStringKey, (LPVOID*)&metadataString, &metadataStringSize)
|
||||||
|
&& metadataString[0] != '\0') {
|
||||||
|
return std::wstring(metadataString);
|
||||||
|
}
|
||||||
|
swprintf(metadataStringKey, L"\\StringFileInfo\\%04x%04x\\ProductName",
|
||||||
|
translationArray[(syslangIdx < 0 ? 0 : syslangIdx)].wLanguage,
|
||||||
|
translationArray[(syslangIdx < 0 ? 0 : syslangIdx)].wCodePage);
|
||||||
|
if (VerQueryValueW(fileVersionInfo, metadataStringKey, (LPVOID*)&metadataString, &metadataStringSize)
|
||||||
|
&& metadataString[0] != '\0') {
|
||||||
|
return std::wstring(metadataString);
|
||||||
|
}
|
||||||
|
|
||||||
wchar_t* fileDescription = NULL;
|
//MSIX?
|
||||||
UINT fileDescriptionSize = 0;
|
HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
|
||||||
swprintf(fileDescriptionKey, L"\\StringFileInfo\\%04x%04x\\FileDescription",
|
if(!process) return exePath;
|
||||||
translationArray[0].wLanguage, translationArray[0].wCodePage);
|
|
||||||
if (VerQueryValueW(fileVersionInfo, fileDescriptionKey, (LPVOID*)&fileDescription, &fileDescriptionSize)) {
|
|
||||||
exePath = std::wstring(fileDescription);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(fileVersionInfo);
|
//constant missing in mingw64. TB removed when I upgrade to a mingw64 ver that has it
|
||||||
return exePath;
|
#define APPLICATION_USER_MODEL_ID_MAX_LENGTH 130
|
||||||
|
uint32_t length = APPLICATION_USER_MODEL_ID_MAX_LENGTH;
|
||||||
|
PWSTR userModelId = (PWSTR)malloc(length * sizeof(wchar_t));
|
||||||
|
if(GetApplicationUserModelId(process, &length, userModelId) != ERROR_SUCCESS) {
|
||||||
|
CloseHandle(process);
|
||||||
|
return exePath;
|
||||||
|
}
|
||||||
|
CloseHandle(process);
|
||||||
|
|
||||||
|
static constexpr wchar_t* prefix = L"shell:appsfolder\\";
|
||||||
|
uint32_t prefixLen = wcslen(prefix);
|
||||||
|
uint32_t userModelIdLen = wcslen(userModelId);
|
||||||
|
wchar_t* fullName;
|
||||||
|
fullName = (prefixLen + userModelIdLen < length)
|
||||||
|
? (wchar_t*)malloc(length * sizeof(wchar_t))
|
||||||
|
: (wchar_t*)malloc((length * 2) * sizeof(wchar_t));
|
||||||
|
for (int32_t i = prefixLen - 1; i >= 0; i--) {
|
||||||
|
fullName[i] = prefix[i];
|
||||||
|
}
|
||||||
|
for (uint32_t i = 0; i < userModelIdLen + 1; i++) {
|
||||||
|
fullName[prefixLen + i] = userModelId[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
IShellItem* si;
|
||||||
|
HRESULT hr = SHCreateItemFromParsingName(fullName,
|
||||||
|
nullptr,
|
||||||
|
IID_IShellItem,
|
||||||
|
(void**)&si
|
||||||
|
);
|
||||||
|
free(fullName);
|
||||||
|
LPWSTR humanName = nullptr;
|
||||||
|
si->GetDisplayName(SIGDN_NORMALDISPLAY, &humanName);
|
||||||
|
if(humanName && humanName[0] != '\0') {
|
||||||
|
msixName = std::wstring(humanName);
|
||||||
|
CoTaskMemFree(humanName);
|
||||||
|
}
|
||||||
|
if(si) si->Release();
|
||||||
|
|
||||||
|
if (msixName.length() > 0)
|
||||||
|
return msixName;
|
||||||
|
else return exePath;
|
||||||
|
//free(fileVersionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: conflicting names. change callback name
|
//todo: conflicting names. change callback name
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
#include <Shobjidl.h>
|
||||||
|
#include <appmodel.h>
|
||||||
#include <processthreadsapi.h>
|
#include <processthreadsapi.h>
|
||||||
#include <mmdeviceapi.h>
|
#include <mmdeviceapi.h>
|
||||||
#include <combaseapi.h>
|
#include <combaseapi.h>
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ void MainWindow::compose() {
|
||||||
log_to_file("dpr: %f \n", dpr);
|
log_to_file("dpr: %f \n", dpr);
|
||||||
for (auto *epw : ews) {
|
for (auto *epw : ews) {
|
||||||
if (!epw) continue;
|
if (!epw) continue;
|
||||||
epw->calculateSize(windowWidth * dpr,screenHeight * screen->devicePixelRatio());
|
epw->calculateSize(windowWidth, screenHeight);
|
||||||
log_debugcpp("epw loop");
|
log_debugcpp("epw loop");
|
||||||
log_debugcpp("epw roles: " + print_as_binary((epw->getEndpointHandler()->getRoles())));
|
log_debugcpp("epw roles: " + print_as_binary((epw->getEndpointHandler()->getRoles())));
|
||||||
//std::bitset<sizeof(uint8_t)> content =
|
//std::bitset<sizeof(uint8_t)> content =
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ namespace StylingHelper {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline qreal calculateDpi(const QScreen screen) {
|
static inline qreal calculateDpi() {
|
||||||
return QFontMetrics(QApplication::font()).fontDpi();
|
return QFontMetrics(QApplication::font()).fontDpi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue