mirror of
https://github.com/mon/ifs_layeredfs.git
synced 2026-04-26 01:20:28 -05:00
Make things more GCC friendly
This commit is contained in:
parent
6a2772c246
commit
80570600c4
4
layeredfs/3rd_party/stb_dxt.cpp
vendored
4
layeredfs/3rd_party/stb_dxt.cpp
vendored
|
|
@ -33,6 +33,6 @@
|
|||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
// #pragma once
|
||||
#define STB_DXT_IMPLEMENTATION
|
||||
#include "stb_dxt.h"
|
||||
#include "stb_dxt.h"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -7,13 +8,13 @@
|
|||
#include "3rd_party/MinHook.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define AVS_STRUCT_DEF(ret_type, name, ...) char* name;
|
||||
#define AVS_STRUCT_DEF(ret_type, name, ...) const char* name;
|
||||
|
||||
const char *avs_loaded_dll_name;
|
||||
|
||||
typedef struct {
|
||||
char *version_name;
|
||||
char *unique_check; // for IIDX vs SDVX cloud, almost all funcs are identical
|
||||
const char *version_name;
|
||||
const char *unique_check; // for IIDX vs SDVX cloud, almost all funcs are identical
|
||||
|
||||
FOREACH_AVS_FUNC(AVS_STRUCT_DEF)
|
||||
} avs_exports_t;
|
||||
|
|
@ -25,7 +26,7 @@ const LPCWSTR dll_names[] = {
|
|||
};
|
||||
|
||||
const avs_exports_t avs_exports[] = {
|
||||
[&] { avs_exports_t x = { 0 };
|
||||
[] { avs_exports_t x = { 0 };
|
||||
x.version_name = "normal";
|
||||
x.unique_check = NULL;
|
||||
x.log_body_fatal = "log_body_fatal";
|
||||
|
|
@ -58,7 +59,7 @@ const avs_exports_t avs_exports[] = {
|
|||
x.cstream_destroy = "cstream_destroy";
|
||||
return x;
|
||||
}(),
|
||||
[&] { avs_exports_t x = { 0 };
|
||||
[] { avs_exports_t x = { 0 };
|
||||
x.version_name = "2.13.x (XC058ba5------)";
|
||||
x.unique_check = NULL;
|
||||
x.log_body_fatal = "XC058ba5000084";
|
||||
|
|
@ -91,7 +92,7 @@ const avs_exports_t avs_exports[] = {
|
|||
x.cstream_destroy = "XC058ba500012b";
|
||||
return x;
|
||||
}(),
|
||||
[&] { avs_exports_t x = { 0 };
|
||||
[] { avs_exports_t x = { 0 };
|
||||
x.version_name = "2.15.x (XCd229cc------)";
|
||||
x.unique_check = NULL;
|
||||
x.log_body_fatal = "XCd229cc0000e6";
|
||||
|
|
@ -124,7 +125,7 @@ const avs_exports_t avs_exports[] = {
|
|||
x.cstream_destroy = "XCd229cc0000e3";
|
||||
return x;
|
||||
}(),
|
||||
[&] { avs_exports_t x = { 0 }; // sdvx cloud
|
||||
[] { avs_exports_t x = { 0 }; // sdvx cloud
|
||||
x.version_name = "2.16.[3-7] (XCnbrep7------)";
|
||||
x.unique_check = "XCnbrep700013c";
|
||||
x.log_body_fatal = "XCnbrep700017a";
|
||||
|
|
@ -157,7 +158,7 @@ const avs_exports_t avs_exports[] = {
|
|||
x.cstream_destroy = "XCnbrep7000134";
|
||||
return x;
|
||||
}(),
|
||||
[&] { avs_exports_t x = { 0 }; // IIDX, "nbrep but different"
|
||||
[] { avs_exports_t x = { 0 }; // IIDX, "nbrep but different"
|
||||
x.version_name = "2.16.1 (XCnbrep7 but different)",
|
||||
x.unique_check = NULL;
|
||||
x.log_body_fatal = "XCnbrep7000168";
|
||||
|
|
@ -190,7 +191,7 @@ const avs_exports_t avs_exports[] = {
|
|||
x.cstream_destroy = "XCnbrep7000128";
|
||||
return x;
|
||||
}(),
|
||||
[&] { avs_exports_t x = { 0 }; // avs 64 bit, pretty much. 2.16.3 with different prefix
|
||||
[] { avs_exports_t x = { 0 }; // avs 64 bit, pretty much. 2.16.3 with different prefix
|
||||
x.version_name = "2.17.x (XCgsqzn0------)";
|
||||
x.unique_check = NULL;
|
||||
x.log_body_fatal = "XCgsqzn000017a";
|
||||
|
|
@ -234,9 +235,9 @@ void* hook_avs_fs_mount(char* mountpoint, char* fsroot, char* fstype, int a5) {
|
|||
return avs_fs_mount(mountpoint, fsroot, fstype, a5);
|
||||
}*/
|
||||
|
||||
#define TEST_HOOK_AND_APPLY(func) if (MH_CreateHookApi(dll_name, avs_exports[i]. ## func, hook_ ## func, (LPVOID*) &func) != MH_OK || func == NULL) continue
|
||||
#define LOAD_FUNC(func) if( (func = (decltype(func))GetProcAddress(mod_handle, avs_exports[i]. ## func)) == NULL) continue
|
||||
#define CHECK_UNIQUE(func) if( avs_exports[i]. ## func != NULL && GetProcAddress(mod_handle, avs_exports[i]. ## func) == NULL) continue
|
||||
#define TEST_HOOK_AND_APPLY(func) if (MH_CreateHookApi(dll_name, avs_exports[i].func, (LPVOID)hook_ ## func, (LPVOID*)&func) != MH_OK || func == NULL) continue
|
||||
#define LOAD_FUNC(func) if( (func = (decltype(func))GetProcAddress(mod_handle, avs_exports[i].func)) == NULL) continue
|
||||
#define CHECK_UNIQUE(func) if( avs_exports[i].func != NULL && GetProcAddress(mod_handle, avs_exports[i].func) == NULL) continue
|
||||
|
||||
#define AVS_FUNC_LOAD(ret_type, name, ...) LOAD_FUNC(name);
|
||||
|
||||
|
|
@ -255,7 +256,7 @@ bool init_avs(void) {
|
|||
LPCWSTR dll_name = NULL;
|
||||
HMODULE mod_handle = NULL;
|
||||
for (int i = 0; i < lenof(dll_names); i++) {
|
||||
mod_handle = GetModuleHandle(dll_names[i]);
|
||||
mod_handle = GetModuleHandleW(dll_names[i]);
|
||||
if (mod_handle != NULL) {
|
||||
dll_name = dll_names[i];
|
||||
break;
|
||||
|
|
@ -292,6 +293,7 @@ bool init_avs(void) {
|
|||
property_t prop_from_file_handle(AVS_FILE f) {
|
||||
void* prop_buffer = NULL;
|
||||
property_t prop = NULL;
|
||||
int ret;
|
||||
|
||||
int flags = PROP_CREATE_FLAGS;
|
||||
auto memsize = property_read_query_memsize_long(avs_fs_read, f, NULL, NULL, NULL);
|
||||
|
|
@ -316,7 +318,7 @@ property_t prop_from_file_handle(AVS_FILE f) {
|
|||
}
|
||||
|
||||
avs_fs_lseek(f, 0, SEEK_SET);
|
||||
int ret = property_insert_read(prop, 0, avs_fs_read, f);
|
||||
ret = property_insert_read(prop, 0, avs_fs_read, f);
|
||||
avs_fs_close(f);
|
||||
|
||||
if (ret < 0) {
|
||||
|
|
@ -471,7 +473,7 @@ unsigned char* lz_compress(unsigned char* input, size_t length, size_t *compress
|
|||
compressor->input_buffer = input;
|
||||
compressor->input_size = (uint32_t)length;
|
||||
// worst case, for every 8 bytes there will be an extra flag byte
|
||||
auto to_add = max(length / 8, 1);
|
||||
auto to_add = std::max(length / 8, (size_t)1);
|
||||
auto compress_size = length + to_add;
|
||||
auto compress_buffer = (unsigned char*)malloc(compress_size);
|
||||
compressor->output_buffer = compress_buffer;
|
||||
|
|
@ -499,7 +501,7 @@ unsigned char* lz_compress(unsigned char* input, size_t length, size_t *compress
|
|||
|
||||
typedef struct {
|
||||
uint32_t code;
|
||||
char* msg;
|
||||
const char* msg;
|
||||
} prop_error_info_t;
|
||||
|
||||
const prop_error_info_t prop_error_list[73] = {
|
||||
|
|
@ -588,7 +590,7 @@ const char* get_prop_error_str(int32_t code) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
char* prop_data_to_str(int type, void* data) {
|
||||
const char* prop_data_to_str(int type, void* data) {
|
||||
static char ret[64];
|
||||
|
||||
type &= 63;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -6,14 +6,18 @@
|
|||
|
||||
#define SUPPRESS_PRINTF
|
||||
|
||||
void stdout_log(char level, const char *fmt, va_list args) {
|
||||
printf("%c:", level);
|
||||
vprintf(fmt, args);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void log_to_file(char level, const char* fmt, va_list args) {
|
||||
static CriticalSectionLock log_mutex;
|
||||
static FILE* logfile = NULL;
|
||||
static bool tried_to_open = false;
|
||||
#ifndef SUPPRESS_PRINTF
|
||||
printf("%c:", level);
|
||||
vprintf(fmt, args);
|
||||
printf("\n");
|
||||
stdout_log(level, fmt, args);
|
||||
#endif
|
||||
// don't reopen every time: slow as shit
|
||||
if (!tried_to_open) {
|
||||
|
|
@ -71,3 +75,35 @@ log_formatter_t imp_log_body_fatal = default_log_body_fatal;
|
|||
log_formatter_t imp_log_body_warning = default_log_body_warning;
|
||||
log_formatter_t imp_log_body_info = default_log_body_info;
|
||||
log_formatter_t imp_log_body_misc = default_log_body_misc;
|
||||
|
||||
void stdout_log_body_fatal(const char *module, const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
stdout_log('F', fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
void stdout_log_body_warning(const char *module, const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
stdout_log('W', fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
void stdout_log_body_info(const char *module, const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
stdout_log('I', fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
void stdout_log_body_misc(const char *module, const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
stdout_log('M', fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void log_to_stdout(void) {
|
||||
imp_log_body_fatal = stdout_log_body_fatal;
|
||||
imp_log_body_warning = stdout_log_body_warning;
|
||||
imp_log_body_info = stdout_log_body_info;
|
||||
imp_log_body_misc = stdout_log_body_misc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
// layeredfs super-verbose (since most people have loglevel misc already)
|
||||
#define log_verbose(...) if(config.verbose_logs) {log_misc(__VA_ARGS__);}
|
||||
|
||||
// for the playpen
|
||||
void log_to_stdout(void);
|
||||
|
||||
typedef void (*log_formatter_t)(const char *module, const char *fmt, ...);
|
||||
|
||||
extern log_formatter_t imp_log_body_fatal;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <stdarg.h>
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "avs.h"
|
||||
|
|
@ -139,7 +139,7 @@ std::vector<std::string> folders_in_folder(const char* root) {
|
|||
|
||||
time_t file_time(const char* path) {
|
||||
auto wide = str_widen(path);
|
||||
auto hFile = CreateFile(wide, // file to open
|
||||
auto hFile = CreateFileW(wide, // file to open
|
||||
GENERIC_READ, // open for reading
|
||||
FILE_SHARE_READ, // share for reading
|
||||
NULL, // default security
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
|
||||
// This class is a lightweight replacement for std::mutex on Windows platforms.
|
||||
// std::mutex does not work on Windows XP SP2 with the latest VC++ libraries,
|
||||
|
|
@ -55,4 +55,4 @@ of the input file used when generating it. This code is not
|
|||
standalone and requires a support library to be linked with it. This
|
||||
support library is itself covered by the above license.
|
||||
|
||||
**/
|
||||
**/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user