old sdk generator dll

This commit is contained in:
Janis 2023-06-21 18:56:57 +02:00
parent 679f97397a
commit f57d3491e4
4 changed files with 135 additions and 10 deletions

View file

@ -5,4 +5,24 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "sdk_generator_version"
path = "src/lib.rs"
crate-type = ["cdylib"]
[dependencies]
log = "0.4.0"
anyhow = "1.0"
pdb-helper = {path = "../pdb-helper"}
simple_logger = "*"
unreal-sdk = {path = "../unreal-sdk"}
[dependencies.windows]
version = "0.44"
features = [
"Win32_Foundation",
"Win32_System_Threading",
]

11
sdk-generator/build.rs Normal file
View file

@ -0,0 +1,11 @@
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
let def = root.join("proxy.def");
println!("cargo:rustc-link-lib=dylib=d3d11");
println!("cargo:rustc-link-arg=/def:{}", def.display());
}

20
sdk-generator/proxy.def Normal file
View file

@ -0,0 +1,20 @@
LIBRARY VERSION.dll
EXPORTS
GetFileVersionInfoA=c:\windows\system32\version.dll.GetFileVersionInfoA
GetFileVersionInfoByHandle=c:\windows\system32\version.dll.GetFileVersionInfoByHandle
GetFileVersionInfoExA=c:\windows\system32\version.dll.GetFileVersionInfoExA
GetFileVersionInfoExW=c:\windows\system32\version.dll.GetFileVersionInfoExW
GetFileVersionInfoSizeA=c:\windows\system32\version.dll.GetFileVersionInfoSizeA
GetFileVersionInfoSizeExA=c:\windows\system32\version.dll.GetFileVersionInfoSizeExA
GetFileVersionInfoSizeExW=c:\windows\system32\version.dll.GetFileVersionInfoSizeExW
GetFileVersionInfoSizeW=c:\windows\system32\version.dll.GetFileVersionInfoSizeW
GetFileVersionInfoW=c:\windows\system32\version.dll.GetFileVersionInfoW
VerFindFileA=c:\windows\system32\version.dll.VerFindFileA
VerFindFileW=c:\windows\system32\version.dll.VerFindFileW
VerInstallFileA=c:\windows\system32\version.dll.VerInstallFileA
VerInstallFileW=c:\windows\system32\version.dll.VerInstallFileW
VerLanguageNameA=c:\windows\system32\version.dll.VerLanguageNameA
VerLanguageNameW=c:\windows\system32\version.dll.VerLanguageNameW
VerQueryValueA=c:\windows\system32\version.dll.VerQueryValueA
VerQueryValueW=c:\windows\system32\version.dll.VerQueryValueW

View file

@ -1,14 +1,88 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
use std::{collections::HashSet, time::Duration};
#[cfg(test)]
mod tests {
use super::*;
use pdb_helper as pdb;
use simple_logger::SimpleLogger;
use unreal_sdk::sdk::output::rust::generate_partial_sdk_to_tmp;
use windows::s;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
#[no_mangle]
pub extern "win64" fn DllMain(_module: usize, reason: u32, _: usize) -> bool {
match reason {
1 => {
if std::env::current_exe()
.expect("current exe")
.file_name()
.expect("file name")
.to_string_lossy()
== "ShooterGame.exe"
{
SimpleLogger::new().init().unwrap();
log::info!("hello");
std::thread::spawn(move || {
let _wnd = loop {
let window = unsafe {
windows::Win32::UI::WindowsAndMessaging::FindWindowA(
None,
s!("ARK: Survival Evolved"),
)
};
if window.0 != 0 {
log::debug!("found window: {window:?}");
break window;
}
log::trace!("window was 0");
std::thread::sleep(std::time::Duration::from_millis(150));
};
let globals = pdb::get_pdb().find_ue_globals().expect("globals");
unreal_sdk::global_tables::names::GNAMES
.write()
.unwrap()
.set_names(globals.names.cast());
unreal_sdk::global_tables::objects::GOBJECTS
.write()
.unwrap()
.set_objects(globals.objects.cast());
std::thread::sleep(Duration::from_secs(30));
let sdk = unreal_sdk::sdk::Sdk::new().patch();
_ = generate_partial_sdk_to_tmp(
&sdk,
HashSet::from_iter([
"Package_ShooterGame",
"Package_DeathItemCache",
"Package_WeapC4",
"Package_ExplorerChest_Base",
"Package_PointOfInterestBP_MissionStart",
"Package_BP_DedicatedStorage",
"Package_ElectricGenerator",
"Package_ExplorerChest_Base",
"Package_FeedingTroughBaseBP",
"Package_MilkGlider_Character_BP",
"Package_PointOfInterestBP_MissionStart",
"Package_SleepingBag",
"Package_StorageBox_Huge",
"Package_StorageBox_TekGenerator",
"Package_StructureAmmoContainer",
"Package_StructureTurretBaseBP_Heavy",
"Package_StructureTurretBaseBP",
"Package_StructureTurretTek",
"Package_Structure_DinoLeash",
"Package_Structure_TekAlarm",
"Package_BP_DedicatedStorage",
"Package_Buff_Companion_HLNA",
"Package_Buff_TekArmor_Pants",
"Package_Buff_TekArmor_Gloves",
"Package_Buff_TekArmor_Sword",
"Package_Buff_TekArmor_Shirt_Rework",
]),
);
});
}
}
_ => {}
}
true
}