Detect Wine

This commit is contained in:
nastys
2019-10-14 22:19:42 +02:00
parent ca79d4aa87
commit c01c189677
3 changed files with 11806 additions and 11800 deletions
+51 -30
View File
@@ -7,6 +7,8 @@ namespace GPUModel
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <string>
#include <stdio.h>
#pragma comment(lib, "advapi32")
void*(*NvAPI_QueryInterface)(unsigned int offset) = NULL;
int(*NvAPI_Initialize)() = NULL;
@@ -14,45 +16,64 @@ namespace GPUModel
int(*NvAPI_EnumPhysicalGPUs)(int64_t** handle, int* count) = NULL;
int(*NvAPI_GPU_GetShortName)(int64_t* handle, char* name) = NULL;
std::string getWineVer()
{
HMODULE hntdll = LoadLibraryW(L"ntdll.dll");
char*(WINAPI * wine_get_version)() = (char*(WINAPI*)())GetProcAddress(hntdll, "wine_get_version");
if (wine_get_version)
{
//puts("Wine detected.");
//printf("Running on Wine... %s\n", wine_get_version());
return std::string(wine_get_version());
}
return "";
}
std::string getGpuName()
{
NvAPI_QueryInterface = (void*(*)(unsigned int offset))GetProcAddress(LoadLibraryW(L"nvapi64.dll"), "nvapi_QueryInterface");
if (NvAPI_QueryInterface == nullptr)
{
return "Other";
}
NvAPI_Initialize = (int(*)())NvAPI_QueryInterface(0x0150E828);
NvAPI_Unload = (int(*)()) NvAPI_QueryInterface(0xD22BDD7E);
NvAPI_EnumPhysicalGPUs = (int(*)(int64_t** handle, int* count))NvAPI_QueryInterface(0xE5AC921F);
NvAPI_GPU_GetShortName = (int(*)(int64_t* handle, char* name))NvAPI_QueryInterface(0xD988F0F3);
if (NvAPI_Initialize == nullptr ||
NvAPI_Unload == nullptr ||
NvAPI_EnumPhysicalGPUs == nullptr ||
NvAPI_GPU_GetShortName == nullptr)
/* if (getWineVer() != "")
{
return "Unknown";
}
else {*/
HMODULE hdlNvapi = LoadLibraryW(L"nvapi64.dll");
int64_t* hdlGpu[64] = { 0 };
int nGpu = 0;
if (hdlNvapi == NULL) return
std::string("Other");
NvAPI_Initialize();
NvAPI_EnumPhysicalGPUs(hdlGpu, &nGpu);
NvAPI_QueryInterface = (void* (*)(unsigned int offset))GetProcAddress(hdlNvapi, "nvapi_QueryInterface");
if (NvAPI_QueryInterface == nullptr)
return std::string("Other");
//printf("[ShaderPatch] nGpu: %d\n", nGpu);
if (nGpu < 1)
{
NvAPI_Initialize = (int(*)())NvAPI_QueryInterface(0x0150E828);
NvAPI_Unload = (int(*)()) NvAPI_QueryInterface(0xD22BDD7E);
NvAPI_EnumPhysicalGPUs = (int(*)(int64_t * *handle, int* count))NvAPI_QueryInterface(0xE5AC921F);
NvAPI_GPU_GetShortName = (int(*)(int64_t * handle, char* name))NvAPI_QueryInterface(0xD988F0F3);
if (NvAPI_Initialize == nullptr ||
NvAPI_Unload == nullptr ||
NvAPI_EnumPhysicalGPUs == nullptr ||
NvAPI_GPU_GetShortName == nullptr)
return std::string("Unknown");
int64_t* hdlGpu[64] = { 0 };
int nGpu = 0;
NvAPI_Initialize();
NvAPI_EnumPhysicalGPUs(hdlGpu, &nGpu);
//printf("[ShaderPatch] nGpu: %d\n", nGpu);
if (nGpu < 1)
{
NvAPI_Unload();
return std::string("Unknown");
}
char nameBuf[64];
NvAPI_GPU_GetShortName(hdlGpu[0], nameBuf);
NvAPI_Unload();
return "Unknown";
}
char nameBuf[64];
NvAPI_GPU_GetShortName(hdlGpu[0], nameBuf);
NvAPI_Unload();
return std::string(nameBuf);
return std::string(nameBuf);
//}
}
}
+54 -69
View File
@@ -7,7 +7,7 @@
#include <GL\GL.h>
#include "SkinnedMessageBox.h"
#include "PluginConfig.h"
#include "GPUModel.h""
#include "GPUModel.h"
namespace Launcher {
@@ -158,10 +158,16 @@ namespace Launcher {
String^ gpuModel = gcnew String(GPUModel::getGpuName().c_str());
String^ wineVersion = gcnew String(GPUModel::getWineVer().c_str());
glutDestroyWindow(window); // destroy the window so it doesn't remain on screen
if (glutMainLoopEventDynamic != NULL) glutMainLoopEventDynamic(); // freeglut needs this
this->labelGPU->Text = "GPU Info:\n";
if (wineVersion != "")
{
this->labelGPU->Text = "Wine " + wineVersion + " (at least 4.12.1 is required)\n";
}
else this->labelGPU->Text = "GPU Info:\n";
this->labelGPU->Text += vendor + " " + renderer + "\n";
this->labelGPU->Text += "OpenGL: " + version + "\n";
@@ -335,10 +341,9 @@ namespace Launcher {
//
this->button_Launch->FlatAppearance->BorderColor = System::Drawing::SystemColors::Control;
this->button_Launch->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
this->button_Launch->Location = System::Drawing::Point(4, 473);
this->button_Launch->Margin = System::Windows::Forms::Padding(4);
this->button_Launch->Location = System::Drawing::Point(3, 315);
this->button_Launch->Name = L"button_Launch";
this->button_Launch->Size = System::Drawing::Size(102, 34);
this->button_Launch->Size = System::Drawing::Size(68, 23);
this->button_Launch->TabIndex = 20;
this->button_Launch->Text = L"Launch";
this->button_Launch->Click += gcnew System::EventHandler(this, &ui::Button_Launch_Click);
@@ -348,12 +353,11 @@ namespace Launcher {
this->button_Help->DialogResult = System::Windows::Forms::DialogResult::Cancel;
this->button_Help->FlatAppearance->BorderColor = System::Drawing::SystemColors::Control;
this->button_Help->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
this->button_Help->Location = System::Drawing::Point(114, 473);
this->button_Help->Margin = System::Windows::Forms::Padding(4);
this->button_Help->Location = System::Drawing::Point(76, 315);
this->button_Help->Name = L"button_Help";
this->button_Help->Size = System::Drawing::Size(103, 34);
this->button_Help->Size = System::Drawing::Size(69, 23);
this->button_Help->TabIndex = 21;
this->button_Help->Text = L"Get help";
this->button_Help->Text = L"HELP ME";
this->button_Help->Click += gcnew System::EventHandler(this, &ui::Button_Help_Click);
//
// groupBox_ScreenRes
@@ -361,11 +365,9 @@ namespace Launcher {
this->groupBox_ScreenRes->Controls->Add(this->panel_ScreenRes);
this->groupBox_ScreenRes->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
this->groupBox_ScreenRes->ForeColor = System::Drawing::Color::White;
this->groupBox_ScreenRes->Location = System::Drawing::Point(8, 9);
this->groupBox_ScreenRes->Margin = System::Windows::Forms::Padding(4);
this->groupBox_ScreenRes->Location = System::Drawing::Point(5, 6);
this->groupBox_ScreenRes->Name = L"groupBox_ScreenRes";
this->groupBox_ScreenRes->Padding = System::Windows::Forms::Padding(4);
this->groupBox_ScreenRes->Size = System::Drawing::Size(417, 169);
this->groupBox_ScreenRes->Size = System::Drawing::Size(278, 113);
this->groupBox_ScreenRes->TabIndex = 10;
this->groupBox_ScreenRes->TabStop = false;
this->groupBox_ScreenRes->Text = L"Screen Resolution";
@@ -373,10 +375,9 @@ namespace Launcher {
// panel_ScreenRes
//
this->panel_ScreenRes->AutoScroll = true;
this->panel_ScreenRes->Location = System::Drawing::Point(6, 28);
this->panel_ScreenRes->Margin = System::Windows::Forms::Padding(4);
this->panel_ScreenRes->Location = System::Drawing::Point(4, 19);
this->panel_ScreenRes->Name = L"panel_ScreenRes";
this->panel_ScreenRes->Size = System::Drawing::Size(403, 133);
this->panel_ScreenRes->Size = System::Drawing::Size(269, 89);
this->panel_ScreenRes->TabIndex = 0;
//
// tabControl
@@ -388,10 +389,9 @@ namespace Launcher {
this->tabControl->Controls->Add(this->tabPage_Components);
this->tabControl->Controls->Add(this->tabPage_Plugins);
this->tabControl->Location = System::Drawing::Point(0, 0);
this->tabControl->Margin = System::Windows::Forms::Padding(4);
this->tabControl->Name = L"tabControl";
this->tabControl->SelectedIndex = 0;
this->tabControl->Size = System::Drawing::Size(441, 465);
this->tabControl->Size = System::Drawing::Size(294, 310);
this->tabControl->TabIndex = 10;
//
// tabPage_Resolution
@@ -402,11 +402,10 @@ namespace Launcher {
this->tabPage_Resolution->Controls->Add(this->labelGPU);
this->tabPage_Resolution->Controls->Add(this->groupBox_InternalRes);
this->tabPage_Resolution->Controls->Add(this->groupBox_ScreenRes);
this->tabPage_Resolution->Location = System::Drawing::Point(4, 32);
this->tabPage_Resolution->Margin = System::Windows::Forms::Padding(4);
this->tabPage_Resolution->Location = System::Drawing::Point(4, 25);
this->tabPage_Resolution->Name = L"tabPage_Resolution";
this->tabPage_Resolution->Padding = System::Windows::Forms::Padding(4);
this->tabPage_Resolution->Size = System::Drawing::Size(433, 429);
this->tabPage_Resolution->Padding = System::Windows::Forms::Padding(3, 3, 3, 3);
this->tabPage_Resolution->Size = System::Drawing::Size(286, 281);
this->tabPage_Resolution->TabIndex = 0;
this->tabPage_Resolution->Text = L"Resolution";
//
@@ -414,11 +413,12 @@ namespace Launcher {
//
this->labelGPU->AutoSize = true;
this->labelGPU->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(80)), static_cast<System::Int32>(static_cast<System::Byte>(24)),
static_cast<System::Int32>(static_cast<System::Byte>(24)), static_cast<System::Int32>(static_cast<System::Byte>(24)));;
this->labelGPU->Location = System::Drawing::Point(12, 314);
this->labelGPU->MinimumSize = System::Drawing::Size(410, 20);
static_cast<System::Int32>(static_cast<System::Byte>(24)), static_cast<System::Int32>(static_cast<System::Byte>(24)));
this->labelGPU->Location = System::Drawing::Point(8, 209);
this->labelGPU->Margin = System::Windows::Forms::Padding(2, 0, 2, 0);
this->labelGPU->MinimumSize = System::Drawing::Size(273, 13);
this->labelGPU->Name = L"labelGPU";
this->labelGPU->Size = System::Drawing::Size(410, 20);
this->labelGPU->Size = System::Drawing::Size(273, 13);
this->labelGPU->TabIndex = 21;
this->labelGPU->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
//
@@ -427,11 +427,9 @@ namespace Launcher {
this->groupBox_InternalRes->Controls->Add(this->panel_IntRes);
this->groupBox_InternalRes->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
this->groupBox_InternalRes->ForeColor = System::Drawing::Color::White;
this->groupBox_InternalRes->Location = System::Drawing::Point(8, 186);
this->groupBox_InternalRes->Margin = System::Windows::Forms::Padding(4);
this->groupBox_InternalRes->Location = System::Drawing::Point(5, 124);
this->groupBox_InternalRes->Name = L"groupBox_InternalRes";
this->groupBox_InternalRes->Padding = System::Windows::Forms::Padding(4);
this->groupBox_InternalRes->Size = System::Drawing::Size(417, 124);
this->groupBox_InternalRes->Size = System::Drawing::Size(278, 83);
this->groupBox_InternalRes->TabIndex = 20;
this->groupBox_InternalRes->TabStop = false;
this->groupBox_InternalRes->Text = L"Internal Resolution";
@@ -439,10 +437,9 @@ namespace Launcher {
// panel_IntRes
//
this->panel_IntRes->AutoScroll = true;
this->panel_IntRes->Location = System::Drawing::Point(6, 28);
this->panel_IntRes->Margin = System::Windows::Forms::Padding(4);
this->panel_IntRes->Location = System::Drawing::Point(4, 19);
this->panel_IntRes->Name = L"panel_IntRes";
this->panel_IntRes->Size = System::Drawing::Size(403, 88);
this->panel_IntRes->Size = System::Drawing::Size(269, 59);
this->panel_IntRes->TabIndex = 1;
//
// tabPage_Patches
@@ -450,10 +447,9 @@ namespace Launcher {
this->tabPage_Patches->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(64)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(64)));
this->tabPage_Patches->Controls->Add(this->panel_Patches);
this->tabPage_Patches->Location = System::Drawing::Point(4, 32);
this->tabPage_Patches->Margin = System::Windows::Forms::Padding(4);
this->tabPage_Patches->Location = System::Drawing::Point(4, 25);
this->tabPage_Patches->Name = L"tabPage_Patches";
this->tabPage_Patches->Size = System::Drawing::Size(433, 429);
this->tabPage_Patches->Size = System::Drawing::Size(286, 281);
this->tabPage_Patches->TabIndex = 1;
this->tabPage_Patches->Text = L"Options";
//
@@ -461,9 +457,8 @@ namespace Launcher {
//
this->panel_Patches->AutoScroll = true;
this->panel_Patches->Location = System::Drawing::Point(0, 0);
this->panel_Patches->Margin = System::Windows::Forms::Padding(4);
this->panel_Patches->Name = L"panel_Patches";
this->panel_Patches->Size = System::Drawing::Size(429, 425);
this->panel_Patches->Size = System::Drawing::Size(286, 283);
this->panel_Patches->TabIndex = 9;
//
// tabPage_Playerdata
@@ -471,10 +466,9 @@ namespace Launcher {
this->tabPage_Playerdata->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(64)), static_cast<System::Int32>(static_cast<System::Byte>(64)));
this->tabPage_Playerdata->Controls->Add(this->panel_Playerdata);
this->tabPage_Playerdata->Location = System::Drawing::Point(4, 32);
this->tabPage_Playerdata->Margin = System::Windows::Forms::Padding(4);
this->tabPage_Playerdata->Location = System::Drawing::Point(4, 25);
this->tabPage_Playerdata->Name = L"tabPage_Playerdata";
this->tabPage_Playerdata->Size = System::Drawing::Size(433, 429);
this->tabPage_Playerdata->Size = System::Drawing::Size(286, 281);
this->tabPage_Playerdata->TabIndex = 3;
this->tabPage_Playerdata->Text = L"Player";
//
@@ -482,9 +476,8 @@ namespace Launcher {
//
this->panel_Playerdata->AutoScroll = true;
this->panel_Playerdata->Location = System::Drawing::Point(0, 0);
this->panel_Playerdata->Margin = System::Windows::Forms::Padding(4);
this->panel_Playerdata->Name = L"panel_Playerdata";
this->panel_Playerdata->Size = System::Drawing::Size(429, 425);
this->panel_Playerdata->Size = System::Drawing::Size(286, 283);
this->panel_Playerdata->TabIndex = 1;
//
// tabPage_Components
@@ -492,11 +485,10 @@ namespace Launcher {
this->tabPage_Components->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(64)), static_cast<System::Int32>(static_cast<System::Byte>(64)));
this->tabPage_Components->Controls->Add(this->panel_Components);
this->tabPage_Components->Location = System::Drawing::Point(4, 32);
this->tabPage_Components->Margin = System::Windows::Forms::Padding(4);
this->tabPage_Components->Location = System::Drawing::Point(4, 25);
this->tabPage_Components->Name = L"tabPage_Components";
this->tabPage_Components->Padding = System::Windows::Forms::Padding(4);
this->tabPage_Components->Size = System::Drawing::Size(433, 429);
this->tabPage_Components->Padding = System::Windows::Forms::Padding(3, 3, 3, 3);
this->tabPage_Components->Size = System::Drawing::Size(286, 281);
this->tabPage_Components->TabIndex = 2;
this->tabPage_Components->Text = L"Components";
//
@@ -504,21 +496,19 @@ namespace Launcher {
//
this->panel_Components->AutoScroll = true;
this->panel_Components->Location = System::Drawing::Point(0, 0);
this->panel_Components->Margin = System::Windows::Forms::Padding(4);
this->panel_Components->Name = L"panel_Components";
this->panel_Components->Size = System::Drawing::Size(429, 425);
this->panel_Components->Size = System::Drawing::Size(286, 283);
this->panel_Components->TabIndex = 0;
//
// tabPage_Plugins
//
this->tabPage_Plugins->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(64)), static_cast<System::Int32>(static_cast<System::Byte>(64)));
this->tabPage_Plugins->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(64)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(64)));
this->tabPage_Plugins->Controls->Add(this->panel_Plugins);
this->tabPage_Plugins->Location = System::Drawing::Point(4, 32);
this->tabPage_Plugins->Margin = System::Windows::Forms::Padding(4);
this->tabPage_Plugins->Location = System::Drawing::Point(4, 25);
this->tabPage_Plugins->Name = L"tabPage_Plugins";
this->tabPage_Plugins->Padding = System::Windows::Forms::Padding(4);
this->tabPage_Plugins->Size = System::Drawing::Size(433, 429);
this->tabPage_Plugins->Padding = System::Windows::Forms::Padding(3, 3, 3, 3);
this->tabPage_Plugins->Size = System::Drawing::Size(286, 281);
this->tabPage_Plugins->TabIndex = 3;
this->tabPage_Plugins->Text = L"Plugins";
//
@@ -526,9 +516,8 @@ namespace Launcher {
//
this->panel_Plugins->AutoScroll = true;
this->panel_Plugins->Location = System::Drawing::Point(0, 0);
this->panel_Plugins->Margin = System::Windows::Forms::Padding(4);
this->panel_Plugins->Name = L"panel_Plugins";
this->panel_Plugins->Size = System::Drawing::Size(429, 425);
this->panel_Plugins->Size = System::Drawing::Size(286, 283);
this->panel_Plugins->TabIndex = 0;
//
// button_Discord
@@ -539,10 +528,9 @@ namespace Launcher {
this->button_Discord->FlatAppearance->MouseOverBackColor = System::Drawing::Color::Transparent;
this->button_Discord->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
this->button_Discord->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button_Discord.Image")));
this->button_Discord->Location = System::Drawing::Point(337, 466);
this->button_Discord->Margin = System::Windows::Forms::Padding(4);
this->button_Discord->Location = System::Drawing::Point(225, 311);
this->button_Discord->Name = L"button_Discord";
this->button_Discord->Size = System::Drawing::Size(48, 48);
this->button_Discord->Size = System::Drawing::Size(32, 32);
this->button_Discord->TabIndex = 31;
this->button_Discord->UseVisualStyleBackColor = false;
this->button_Discord->Click += gcnew System::EventHandler(this, &ui::button_Discord_Click);
@@ -556,10 +544,9 @@ namespace Launcher {
this->button_github->FlatAppearance->MouseOverBackColor = System::Drawing::Color::Transparent;
this->button_github->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
this->button_github->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button_github.Image")));
this->button_github->Location = System::Drawing::Point(393, 466);
this->button_github->Margin = System::Windows::Forms::Padding(4);
this->button_github->Location = System::Drawing::Point(262, 311);
this->button_github->Name = L"button_github";
this->button_github->Size = System::Drawing::Size(48, 48);
this->button_github->Size = System::Drawing::Size(32, 32);
this->button_github->TabIndex = 32;
this->button_github->UseVisualStyleBackColor = false;
this->button_github->Click += gcnew System::EventHandler(this, &ui::button_github_Click);
@@ -568,10 +555,9 @@ namespace Launcher {
//
this->button_Apply->FlatAppearance->BorderColor = System::Drawing::SystemColors::Control;
this->button_Apply->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
this->button_Apply->Location = System::Drawing::Point(225, 473);
this->button_Apply->Margin = System::Windows::Forms::Padding(4);
this->button_Apply->Location = System::Drawing::Point(150, 315);
this->button_Apply->Name = L"button_Apply";
this->button_Apply->Size = System::Drawing::Size(104, 34);
this->button_Apply->Size = System::Drawing::Size(69, 23);
this->button_Apply->TabIndex = 33;
this->button_Apply->Text = L"Apply";
this->button_Apply->Click += gcnew System::EventHandler(this, &ui::button_Apply_Click);
@@ -579,14 +565,14 @@ namespace Launcher {
// ui
//
this->AcceptButton = this->button_Launch;
this->AutoScaleDimensions = System::Drawing::SizeF(144, 144);
this->AutoScaleDimensions = System::Drawing::SizeF(96, 96);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Dpi;
this->AutoSize = true;
this->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(64)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(64)));
this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->ClientSize = System::Drawing::Size(440, 514);
this->ClientSize = System::Drawing::Size(293, 343);
this->Controls->Add(this->button_Apply);
this->Controls->Add(this->tabControl);
this->Controls->Add(this->button_Help);
@@ -598,7 +584,6 @@ namespace Launcher {
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
this->Icon = (cli::safe_cast<System::Drawing::Icon^>(resources->GetObject(L"$this.Icon")));
this->KeyPreview = true;
this->Margin = System::Windows::Forms::Padding(4);
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"ui";
File diff suppressed because it is too large Load Diff