mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-01-07 03:26:56 +08:00
Fix lints
This commit is contained in:
parent
6434814d1d
commit
27a10c58ca
@ -2,17 +2,14 @@ fn main() {
|
||||
cc::Build::new()
|
||||
.include("mhycrypto")
|
||||
.cpp(true)
|
||||
|
||||
.file("mhycrypto/memecrypto.cpp")
|
||||
.file("mhycrypto/metadata.cpp")
|
||||
.file("mhycrypto/metadatastringdec.cpp")
|
||||
|
||||
.compile("mhycrypto");
|
||||
|
||||
cc::Build::new()
|
||||
cc::Build::new()
|
||||
.include("mhycrypto")
|
||||
.file("mhycrypto/aes.c")
|
||||
|
||||
.compile("mhycrypto-aes");
|
||||
|
||||
tauri_build::build()
|
||||
|
@ -43,7 +43,7 @@ bool gen_global_metadata_key(uint8_t* src, size_t srcn) {
|
||||
|
||||
uint64_t* key = (uint64_t*)src;
|
||||
|
||||
for (int i = 0; i < srcn / sizeof(uint64_t); i++)
|
||||
for (size_t i = 0; i < srcn / sizeof(uint64_t); i++)
|
||||
key[i] = rand();
|
||||
|
||||
*(uint16_t *) (src + 0xc8) = 0xfc2e; // Magic
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::fs;
|
||||
use file_diff::diff;
|
||||
use std::{io::{Read, Write}};
|
||||
use std::fs;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn rename(path: String, new_name: String) {
|
||||
@ -142,7 +142,7 @@ pub fn write_file(path: String, contents: String) {
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
println!("Failed to open file: {}", e);
|
||||
|
||||
|
||||
// attempt to create file. otherwise return
|
||||
match fs::File::create(&path_buf) {
|
||||
Ok(file) => file,
|
||||
@ -159,7 +159,6 @@ pub fn write_file(path: String, contents: String) {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
println!("Failed to write to file: {}", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,12 @@ use sysinfo::{System, SystemExt};
|
||||
mod downloader;
|
||||
mod file_helpers;
|
||||
mod lang;
|
||||
mod metadata_patcher;
|
||||
mod proxy;
|
||||
mod structs;
|
||||
mod system_helpers;
|
||||
mod unzip;
|
||||
mod web;
|
||||
mod metadata_patcher;
|
||||
|
||||
static WATCH_GAME_PROCESS: Lazy<Mutex<String>> = Lazy::new(|| Mutex::new(String::new()));
|
||||
|
||||
@ -73,7 +73,7 @@ fn is_game_running() -> bool {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn enable_process_watcher(window: tauri::Window,process: String) {
|
||||
fn enable_process_watcher(window: tauri::Window, process: String) {
|
||||
*WATCH_GAME_PROCESS.lock().unwrap() = process;
|
||||
|
||||
window.listen("disable_process_watcher", |_e| {
|
||||
|
@ -4,19 +4,25 @@ use std::fs::OpenOptions;
|
||||
use std::io::Read;
|
||||
use std::io::Write;
|
||||
|
||||
extern {
|
||||
fn decrypt_global_metadata(data : *mut u8, size : u64);
|
||||
fn encrypt_global_metadata(data : *mut u8, size : u64);
|
||||
extern "C" {
|
||||
fn decrypt_global_metadata(data: *mut u8, size: u64);
|
||||
fn encrypt_global_metadata(data: *mut u8, size: u64);
|
||||
}
|
||||
|
||||
fn dll_decrypt_global_metadata(data : *mut u8, size : u64) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
fn dll_decrypt_global_metadata(
|
||||
data: *mut u8,
|
||||
size: u64,
|
||||
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
unsafe {
|
||||
decrypt_global_metadata(data, size);
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
|
||||
fn dll_encrypt_global_metadata(data : *mut u8, size : u64) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
fn dll_encrypt_global_metadata(
|
||||
data: *mut u8,
|
||||
size: u64,
|
||||
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
unsafe {
|
||||
encrypt_global_metadata(data, size);
|
||||
Ok(true)
|
||||
@ -46,7 +52,11 @@ pub fn patch_metadata(metadata_folder: &str) -> bool {
|
||||
}
|
||||
|
||||
//write encrypted to file
|
||||
let mut file = match OpenOptions::new().create(true).write(true).open(&(metadata_folder.to_owned() + "\\global-metadata-patched.dat")) {
|
||||
let mut file = match OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.open(&(metadata_folder.to_owned() + "\\global-metadata-patched.dat"))
|
||||
{
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
println!("Failed to open global-metadata: {}", e);
|
||||
@ -55,7 +65,7 @@ pub fn patch_metadata(metadata_folder: &str) -> bool {
|
||||
};
|
||||
|
||||
file.write_all(&encrypted).unwrap();
|
||||
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
@ -82,13 +92,13 @@ fn decrypt_metadata(file_path: &str) -> Vec<u8> {
|
||||
match dll_decrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) {
|
||||
Ok(_) => {
|
||||
println!("Successfully decrypted global-metadata");
|
||||
return data;
|
||||
data
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Failed to decrypt global-metadata: {}", e);
|
||||
return Vec::new();
|
||||
Vec::new()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn replace_keys(data: &[u8]) -> Vec<u8> {
|
||||
@ -143,16 +153,16 @@ fn encrypt_metadata(old_data: &[u8]) -> Vec<u8> {
|
||||
match dll_encrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) {
|
||||
Ok(_) => {
|
||||
println!("Successfully encrypted global-metadata");
|
||||
return data;
|
||||
data
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Failed to encrypt global-metadata: {}", e);
|
||||
return Vec::new();
|
||||
Vec::new()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn do_vecs_match<T: PartialEq>(a: &Vec<T>, b: &Vec<T>) -> bool {
|
||||
let matching = a.iter().zip(b.iter()).filter(|&(a, b)| a == b).count();
|
||||
matching == a.len() && matching == b.len()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user