diff --git a/Cargo.lock b/Cargo.lock index 300ae12..937a9fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,6 +14,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + [[package]] name = "cc" version = "1.0.83" @@ -29,23 +35,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "concat-string" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7439becb5fafc780b6f4de382b1a7a3e70234afe783854a4702ee8adbb838609" - -[[package]] -name = "find-winsdk" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8cbf17b871570c1f8612b763bac3e86290602bcf5dc3c5ce657e0e1e9071d9e" -dependencies = [ - "serde", - "serde_derive", - "winreg", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -58,9 +47,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.150" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libudis86-sys" @@ -109,9 +98,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" @@ -133,23 +122,23 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -165,7 +154,6 @@ dependencies = [ "rrplug", "thiserror", "windows-sys", - "windres", ] [[package]] @@ -174,7 +162,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -183,7 +171,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "mach", "winapi", @@ -207,22 +195,22 @@ dependencies = [ [[package]] name = "rrplug" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5a67ff1c1d55e85436570c3c6b2f2305933c5d05bd580e42d415c8f6e2d9394" +version = "4.0.0" +source = "git+https://github.com/R2NorthstarTools/rrplug.git?rev=fe7dc7c8324cffdf50618a158f5b56e33892b315#fe7dc7c8324cffdf50618a158f5b56e33892b315" dependencies = [ + "bitflags 2.4.2", "log", "once_cell", "parking_lot", "rrplug_proc", "thiserror", + "windows", ] [[package]] name = "rrplug_proc" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "930d71becdab7212381db722301476c0a057d16ed1c13ece20c44e7049134ca4" +version = "4.0.0" +source = "git+https://github.com/R2NorthstarTools/rrplug.git?rev=fe7dc7c8324cffdf50618a158f5b56e33892b315#fe7dc7c8324cffdf50618a158f5b56e33892b315" dependencies = [ "proc-macro2", "quote", @@ -235,26 +223,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "serde" -version = "1.0.192" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.192" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "slice-pool2" version = "0.4.3" @@ -263,15 +231,15 @@ checksum = "7a3d689654af89bdfeba29a914ab6ac0236d382eb3b764f7454dde052f2821f8" [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "syn" -version = "2.0.39" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -280,18 +248,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", @@ -338,13 +306,32 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core", + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -353,13 +340,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -368,30 +370,60 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -399,27 +431,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +name = "windows_x86_64_gnullvm" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] -name = "windres" -version = "0.2.2" +name = "windows_x86_64_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82115619221b2b66001a39088b8059d171b1f9005a00d6a10c6e8a71a30a4cdc" -dependencies = [ - "concat-string", - "find-winsdk", -] +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] -name = "winreg" -version = "0.5.1" +name = "windows_x86_64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a" -dependencies = [ - "serde", - "winapi", -] +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/Cargo.toml b/Cargo.toml index 24d6daa..455ecd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rrplug = "=3.0.0" +rrplug = { git = "https://github.com/R2NorthstarTools/rrplug.git", rev = "fe7dc7c8324cffdf50618a158f5b56e33892b315" } once_cell = "1.18.0" log = "0.4.19" parking_lot = "0.12.1" @@ -14,8 +14,5 @@ thiserror = "1.0.44" retour = { version = "0.3.1", features = ["static-detour"] } windows-sys = { version = "0.48.0", features = ["Win32_System_LibraryLoader", "Win32_Foundation", "Win32_System_Console"] } -[build-dependencies] -windres = "0.2.2" - [lib] crate-type = ["cdylib"] diff --git a/build.rs b/build.rs index 97b5056..f328e4d 100644 --- a/build.rs +++ b/build.rs @@ -1,8 +1 @@ -extern crate windres; -use windres::Build; - -fn main() { - Build::new() - .compile("manifest/Resource.rc") - .expect("failed to include resources in the dll"); -} +fn main() {} diff --git a/manifest/Resource.rc b/manifest/Resource.rc deleted file mode 100644 index 7783776..0000000 --- a/manifest/Resource.rc +++ /dev/null @@ -1,96 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// RCDATA -// - -IDR_RCDATA1 RCDATA "manifest.json" - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "" - VALUE "FileDescription", "" - VALUE "FileVersion", "1.0.0.0" - VALUE "InternalName", "" - VALUE "LegalCopyright", "" - VALUE "OriginalFilename", "" - VALUE "ProductName", "" - VALUE "ProductVersion", "1.0.0.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/manifest/manifest.json b/manifest/manifest.json deleted file mode 100644 index 17520f4..0000000 --- a/manifest/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "r2rcon-rs", - "displayname": "R2RCON-RS", - "dependencyName": "R2RCON_RS", - "description": "rcon yes", - "api_version": "3", - "version": "1.0", - "run_on_server": true, - "run_on_client": true -} \ No newline at end of file diff --git a/manifest/resource.h b/manifest/resource.h deleted file mode 100644 index bf40714..0000000 --- a/manifest/resource.h +++ /dev/null @@ -1,11 +0,0 @@ -#define SUBLANG_ENGLISH_US 0x01 -#define LANG_ENGLISH 0x09 -#define IDR_RCDATA1 101 -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/src/lib.rs b/src/lib.rs index 4d48846..106db20 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,14 @@ pub struct RconPlugin { } impl Plugin for RconPlugin { - fn new(_: &PluginData) -> Self { + const PLUGIN_INFO: PluginInfo = PluginInfo::new( + "r2rcon-rs\0", + "R2RCON_RS\0", + "R2RCONRS\0", + PluginContext::all(), + ); + + fn new(_reloaded: bool) -> Self { let (console_sender, console_recv) = mpsc::channel(); let rcon_args = env::args() @@ -44,7 +51,7 @@ impl Plugin for RconPlugin { break 'start_server; }; - server = RconServer::try_new(&bind_ip, password, console_recv) + server = RconServer::try_new(bind_ip, password, console_recv) .map_err(|err| log::info!("failed to connect to socket : {err:?}")) .map(|s| { hook_write_console(); @@ -59,7 +66,7 @@ impl Plugin for RconPlugin { } } - fn on_dll_load(&self, _: Option<&EngineData>, dll_ptr: &DLLPointer) { + fn on_dll_load(&self, _: Option<&EngineData>, dll_ptr: &DLLPointer, _token: EngineToken) { unsafe { EngineFunctions::try_init(dll_ptr, &ENGINE_FUNCTIONS) }; if let WhichDll::Client = dll_ptr.which_dll() { @@ -68,7 +75,7 @@ impl Plugin for RconPlugin { } } - fn runframe(&self) { + fn runframe(&self, _token: EngineToken) { _ = self.server.as_ref().map(|s| s.lock().run()); } } diff --git a/src/rcon.rs b/src/rcon.rs index 1ee110a..8dfedc9 100644 --- a/src/rcon.rs +++ b/src/rcon.rs @@ -1,4 +1,4 @@ -use rrplug::to_c_string; +use rrplug::mid::utils::{to_cstring, try_cstring}; use std::{ io::{self, Read, Write}, net::{TcpListener, TcpStream}, @@ -104,7 +104,7 @@ impl RconServer { } pub fn run(&mut self) { - while let Some(_) = self.console.next_line_catpure() {} // string allocation could be remove + while self.console.next_line_catpure().is_some() {} // string allocation could be remove match self.server.accept() { Ok((conn, addr)) => match conn.set_nonblocking(true) { @@ -253,7 +253,8 @@ fn parse_response( } log::info!("executing command : {content}"); - let cmd = to_c_string!(content); + let cmd = try_cstring(&content) + .unwrap_or_else(|_| to_cstring(content.replace('\0', "").as_str())); let funcs = ENGINE_FUNCTIONS.wait(); unsafe { (funcs.cbuf_add_text_type)(