template and fixed guid obtaining
This commit is contained in:
parent
4e10385a3b
commit
44461afdc4
3 changed files with 39 additions and 13 deletions
|
|
@ -144,7 +144,8 @@ Endpoint::~Endpoint(){
|
||||||
|
|
||||||
|
|
||||||
void Overseer::initCOMLibrary(){
|
void Overseer::initCOMLibrary(){
|
||||||
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { log_debugcpp("si"); };
|
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE))) {
|
||||||
|
log_debugcpp("si"); };
|
||||||
|
|
||||||
|
|
||||||
//Retrieving endpoint enumerator
|
//Retrieving endpoint enumerator
|
||||||
|
|
@ -154,17 +155,29 @@ void Overseer::initCOMLibrary(){
|
||||||
(void**)&deviceEnumerator)) )
|
(void**)&deviceEnumerator)) )
|
||||||
{ log_debugcpp("si"); };
|
{ log_debugcpp("si"); };
|
||||||
|
|
||||||
/*
|
|
||||||
* LPGUID tempGuid = nullptr;
|
GUID tempGuid;
|
||||||
* if(FAILED(CoCreateGuid(tempGuid))) { log_debugcpp("Failed to obtain GUID"); };
|
/*
|
||||||
*
|
* HRESULT her = CoCreateGuid(&tempGuid);
|
||||||
* this->guid.data1 = tempGuid->Data1;
|
* std::bitset<32> bon(her);
|
||||||
* this->guid.data2 = tempGuid->Data2;
|
* //if (hr == EPT_S_CANT_CREATE)
|
||||||
* this->guid.data3 = tempGuid->Data3;
|
* log_debugcpp("Failed to obtain GUID: " /\*<< std::hex *\/<< her << std::dec << " " << bon);
|
||||||
* for (int i = 0; i < 8; i++){
|
*/
|
||||||
* this->guid.data4[i] = tempGuid->Data4[i];
|
if(FAILED(CoCreateGuid(&tempGuid))) { log_debugcpp("Failed to obtain GUID: " ); };
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
this->guid.data1 = tempGuid.Data1;
|
||||||
|
this->guid.data2 = tempGuid.Data2;
|
||||||
|
this->guid.data3 = tempGuid.Data3;
|
||||||
|
for (int i = 0; i < 8; i++){
|
||||||
|
this->guid.data4[i] = tempGuid.Data4[i];
|
||||||
|
log_debugcpp("GUID DATA4 BYTE " << i << ": ");
|
||||||
|
log_debugcpp(print_as_binary(8, uint32_t, this->guid.data4[i]));
|
||||||
|
}
|
||||||
|
log_debugcpp("GUID DATA1: " << this->guid.data1);
|
||||||
|
log_debugcpp("GUID DATA2: " << this->guid.data2);
|
||||||
|
log_debugcpp("GUID DATA3: " << this->guid.data3);
|
||||||
|
|
||||||
//TODO: Release lpguid?
|
//TODO: Release lpguid?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
14
src/debug.h
14
src/debug.h
|
|
@ -2,10 +2,22 @@
|
||||||
|
|
||||||
#if defined (QT_DEBUG) || defined (DEBUG) || defined (_DEBUG)
|
#if defined (QT_DEBUG) || defined (DEBUG) || defined (_DEBUG)
|
||||||
|
|
||||||
|
template<size_t Y, typename T>
|
||||||
|
std::bitset<Y> varToBitset(T info) {
|
||||||
|
std::bitset<Y> content(info);
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
#define log_debugcpp(str) do { \
|
#define log_debugcpp(str) do { \
|
||||||
std::cout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
std::cout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define print_as_binary(len, type, info) varToBitset<len, type>(info)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define log_debugcpp(str)
|
#define log_debugcpp(str)
|
||||||
|
#define print_as_binary(len, info)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue