Skip to content

Commit

Permalink
Another attempt of trying to fix the sxs errors...
Browse files Browse the repository at this point in the history
  • Loading branch information
WolverinDEV committed Mar 14, 2024
1 parent 627cc39 commit fc15847
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 18 deletions.
46 changes: 38 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@ nalgebra = "0.32.3"
mint = "0.5.9"
clap = { version = "4.3.19", features = ["derive"] }
serde_yaml = "0.9.25"
windows = { version = "0.48.0", features = [
windows = { version = "0.53.0", features = [
"Win32_System_Console",
"Win32_System_SystemInformation",
"Win32_System_SystemInformation",
"Win32_System_ApplicationInstallationAndServicing",
"Win32_UI_Shell",
"Win32_UI_WindowsAndMessaging",
"Win32_Foundation",
"Win32_System_Threading",
"Win32_System_LibraryLoader",
] }

chrono = "0.4.26"
rand = "0.8.5"
libloading = "0.7.4" # Same version as used by ash
libloading = "0.7.4"
utils-state = { version = "0.1.0", path = "../utils/state" }
url = "2.5.0"
tokio = { version = "1.36.0", features = ["full"] }
Expand Down
20 changes: 20 additions & 0 deletions controller/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ use std::{
use chrono::Utc;
use winres::WindowsResource;

const APP_MANIFEST: &'static str = r#"
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>Valthrun Overlay</description>
<assemblyIdentity type="win32" name="dev.wolveringer.valthrun.overlay" version="0.4.2.0" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
"#;

fn main() -> io::Result<()> {
{
let git_hash = if Path::new("../.git").exists() {
Expand Down Expand Up @@ -40,6 +59,7 @@ fn main() -> io::Result<()> {
{
let mut resource = WindowsResource::new();
resource.set_icon("./resources/app-icon.ico");
resource.set_manifest(APP_MANIFEST);
resource.compile()?;
}
Ok(())
Expand Down
40 changes: 37 additions & 3 deletions controller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{
fmt::Debug,
fs::File,
io::BufWriter,
mem,
path::PathBuf,
rc::Rc,
sync::{
Expand Down Expand Up @@ -48,6 +49,7 @@ use imgui::{
FontSource,
Ui,
};
use libloading::Library;
use obfstr::obfstr;
use overlay::{
LoadingError,
Expand All @@ -66,9 +68,20 @@ use tokio::runtime;
use utils_state::StateRegistry;
use valthrun_kernel_interface::KInterfaceError;
use view::ViewController;
use windows::Win32::{
System::Console::GetConsoleProcessList,
UI::Shell::IsUserAnAdmin,
use windows::{
core::PCSTR,
Win32::{
System::{
ApplicationInstallationAndServicing::{
ActivateActCtx,
CreateActCtxA,
ACTCTXA,
},
Console::GetConsoleProcessList,
LibraryLoader::GetModuleHandleA,
},
UI::Shell::IsUserAnAdmin,
},
};

use crate::{
Expand Down Expand Up @@ -415,6 +428,23 @@ fn main_schema_dump(args: &SchemaDumpArgs) -> anyhow::Result<()> {
Ok(())
}

fn preload_vulkan_with_act_ctx() -> anyhow::Result<()> {
unsafe {
let mut act_ctx = mem::zeroed::<ACTCTXA>();
act_ctx.cbSize = mem::size_of_val(&act_ctx) as u32;
act_ctx.dwFlags = 0x80 | 0x08;
act_ctx.hModule = GetModuleHandleA(PCSTR::null()).context("GetModuleHandleA")?;
act_ctx.lpResourceName = PCSTR::from_raw(1 as *const u8);

let mut cookie = 0;
let ctx = CreateActCtxA(&act_ctx).context("CreateActCtxA")?;
ActivateActCtx(ctx, &mut cookie).context("ActivateActCtx")?;
Library::new("vulkan-1").context("vulkan-1")?;
}

Ok(())
}

fn main_overlay() -> anyhow::Result<()> {
let build_info = version_info()?;
log::info!(
Expand All @@ -435,6 +465,10 @@ fn main_overlay() -> anyhow::Result<()> {
log::warn!("{}", obfstr!("Running the controller as administrator might cause failures with your graphic drivers."));
}

if let Err(err) = preload_vulkan_with_act_ctx() {
log::warn!("Act CTX preload failed: {:#}", err);
}

let settings = load_app_settings()?;
let cs2 = match CS2Handle::create(settings.metrics) {
Ok(handle) => handle,
Expand Down
1 change: 1 addition & 0 deletions overlay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ raw-window-handle = "0.5.2"
ash = { version = "0.37", default-features = false, features = ["debug", "loaded"] }
ash-window = "0.12.0"
nalgebra = "0.32.3"
libloading = "0.8.3"

[dev-dependencies]
anyhow = "1.0.75"
Expand Down
6 changes: 6 additions & 0 deletions overlay/src/vulkan_driver.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
use ash::Entry;
use libloading::Library;

use crate::Result;

pub fn get_vulkan_entry() -> Result<ash::Entry> {
unsafe {
Library::new("CFGMGR32.dll").unwrap();
Library::new("advapi32.dll").unwrap();
Library::new("kernel32.dll").unwrap();
}
unsafe { Ok(Entry::load()?) }
}
8 changes: 4 additions & 4 deletions overlay/src/vulkan_render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ unsafe extern "system" fn vulkan_debug_callback(

let message = CStr::from_ptr((*p_callback_data).p_message);
match flag {
Flag::VERBOSE => log::debug!("{typ:?} - {message:?}"),
Flag::INFO => log::info!("{typ:?} - {message:?}"),
Flag::WARNING => log::warn!("{typ:?} - {message:?}"),
_ => log::error!("{typ:?} - {message:?}"),
Flag::VERBOSE => log::debug!("{typ:?} - {}", message.to_string_lossy()),
Flag::INFO => log::info!("{typ:?} - {}", message.to_string_lossy()),
Flag::WARNING => log::warn!("{typ:?} - {}", message.to_string_lossy()),
_ => log::error!("{typ:?} - {}", message.to_string_lossy()),
}
vk::FALSE
}
Expand Down

0 comments on commit fc15847

Please sign in to comment.