diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 8a440e37..4f89b041 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -31,15 +31,15 @@ jobs:
set PLUGIN_SDK_DIR=%GITHUB_WORKSPACE%\third-party\plugin-sdk
msbuild -m CLEO5.sln /property:Configuration=Release /property:Platform=GTASA
- - name: Core - Sign
- uses: x87/code-sign-action@develop
- with:
- certificate: '${{ secrets.DIG_KEY_CERT }}'
- password: '${{ secrets.DIG_KEY_PWD }}'
- certificatename: 'Seemann'
- description: 'CLEO 5'
- timestampUrl: 'http://timestamp.digicert.com'
- filename: './.output/Release/cleo.asi'
+# - name: Core - Sign
+# uses: x87/code-sign-action@develop
+# with:
+# certificate: '${{ secrets.DIG_KEY_CERT }}'
+# password: '${{ secrets.DIG_KEY_PWD }}'
+# certificatename: 'Seemann'
+# description: 'CLEO 5'
+# timestampUrl: 'http://timestamp.digicert.com'
+# filename: './.output/Release/cleo.asi'
- name: Core - VirusTotal Scan
uses: crazy-max/ghaction-virustotal@v4
@@ -53,15 +53,15 @@ jobs:
set PLUGIN_SDK_DIR=%GITHUB_WORKSPACE%\third-party\plugin-sdk
msbuild -m cleo_plugins/CLEO_Plugins.sln /property:Configuration=Release /property:Platform=x86
- - name: Plugins - Sign
- uses: x87/code-sign-action@develop
- with:
- certificate: '${{ secrets.DIG_KEY_CERT }}'
- password: '${{ secrets.DIG_KEY_PWD }}'
- certificatename: 'Seemann'
- description: 'CLEO 5 Plugin'
- timestampUrl: 'http://timestamp.digicert.com'
- folder: './cleo_plugins/.output'
+# - name: Plugins - Sign
+# uses: x87/code-sign-action@develop
+# with:
+# certificate: '${{ secrets.DIG_KEY_CERT }}'
+# password: '${{ secrets.DIG_KEY_PWD }}'
+# certificatename: 'Seemann'
+# description: 'CLEO 5 Plugin'
+# timestampUrl: 'http://timestamp.digicert.com'
+# folder: './cleo_plugins/.output'
- name: Plugins - VirusTotal Scan
uses: crazy-max/ghaction-virustotal@v4
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 39f32e00..5ea22bac 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -27,15 +27,15 @@ jobs:
set PLUGIN_SDK_DIR=%GITHUB_WORKSPACE%\third-party\plugin-sdk
msbuild -m CLEO5.sln /property:Configuration=Release /property:Platform=GTASA
- - name: Core - Sign
- uses: x87/code-sign-action@develop
- with:
- certificate: '${{ secrets.DIG_KEY_CERT }}'
- password: '${{ secrets.DIG_KEY_PWD }}'
- certificatename: 'Seemann'
- description: 'CLEO 5'
- timestampUrl: 'http://timestamp.digicert.com'
- filename: './.output/Release/cleo.asi'
+# - name: Core - Sign
+# uses: x87/code-sign-action@develop
+# with:
+# certificate: '${{ secrets.DIG_KEY_CERT }}'
+# password: '${{ secrets.DIG_KEY_PWD }}'
+# certificatename: 'Seemann'
+# description: 'CLEO 5'
+# timestampUrl: 'http://timestamp.digicert.com'
+# filename: './.output/Release/cleo.asi'
- name: Core - VirusTotal Scan
uses: crazy-max/ghaction-virustotal@v4
@@ -49,15 +49,15 @@ jobs:
set PLUGIN_SDK_DIR=%GITHUB_WORKSPACE%\third-party\plugin-sdk
msbuild -m cleo_plugins/CLEO_Plugins.sln /property:Configuration=Release /property:Platform=x86
- - name: Plugins - Sign
- uses: x87/code-sign-action@develop
- with:
- certificate: '${{ secrets.DIG_KEY_CERT }}'
- password: '${{ secrets.DIG_KEY_PWD }}'
- certificatename: 'Seemann'
- description: 'CLEO 5 Plugin'
- timestampUrl: 'http://timestamp.digicert.com'
- folder: './cleo_plugins/.output'
+# - name: Plugins - Sign
+# uses: x87/code-sign-action@develop
+# with:
+# certificate: '${{ secrets.DIG_KEY_CERT }}'
+# password: '${{ secrets.DIG_KEY_PWD }}'
+# certificatename: 'Seemann'
+# description: 'CLEO 5 Plugin'
+# timestampUrl: 'http://timestamp.digicert.com'
+# folder: './cleo_plugins/.output'
- name: Plugins - VirusTotal Scan
uses: crazy-max/ghaction-virustotal@v4
diff --git a/CLEO5.vcxproj b/CLEO5.vcxproj
index fd6b68af..3634d5bb 100644
--- a/CLEO5.vcxproj
+++ b/CLEO5.vcxproj
@@ -72,6 +72,10 @@
NotUsing
NotUsing
+
+ NotUsing
+ NotUsing
+
@@ -94,6 +98,7 @@
+
@@ -114,14 +119,14 @@
DynamicLibrary
false
- MultiByte
+ Unicode
v143
true
DynamicLibrary
true
- MultiByte
+ Unicode
v143
@@ -139,14 +144,16 @@
$(SolutionDir).output\.obj\$(Configuration)\
CLEO
.asi
- $(PLUGIN_SDK_DIR)\shared\;$(PLUGIN_SDK_DIR)\shared\game\;$(SolutionDir)third-party\SimpleJSON;$(IncludePath)
+ $(PLUGIN_SDK_DIR)\shared\;$(PLUGIN_SDK_DIR)\shared\game\;$(SolutionDir)third-party\simdjson;$(IncludePath)
+ false
+ false
$(SolutionDir).output\$(Configuration)\
$(SolutionDir).output\.obj\$(Configuration)\
CLEO
.asi
- $(PLUGIN_SDK_DIR)\shared\;$(PLUGIN_SDK_DIR)\shared\game\;$(SolutionDir)third-party\SimpleJSON;$(IncludePath)
+ $(PLUGIN_SDK_DIR)\shared\;$(PLUGIN_SDK_DIR)\shared\game\;$(SolutionDir)third-party\simdjson;$(IncludePath)
$(GTA_SA_DIR)\gta_sa.exe
@@ -168,6 +175,10 @@
Create
stdcpp17
None
+ Speed
+ false
+ false
+ false
true
@@ -178,7 +189,8 @@
Windows
$(SolutionDir)source\cleo.def
false
- /Brepro %(AdditionalOptions)
+ false
+ false
xcopy /Y "$(OutDir)$(TargetName).lib" "$(SolutionDir)cleo_sdk\"
diff --git a/CLEO5.vcxproj.filters b/CLEO5.vcxproj.filters
index 827563b3..ca3d4e19 100644
--- a/CLEO5.vcxproj.filters
+++ b/CLEO5.vcxproj.filters
@@ -7,9 +7,6 @@
{d188d452-fbc6-48b5-bd49-d4036c989109}
-
- {5cead5cc-9a75-4d2e-99b5-ebbc8f9d6d86}
-
{3104a2cb-d9c5-4eb5-9910-cf77d903db30}
@@ -22,6 +19,15 @@
{9c8be703-c930-47b1-b0cb-7c4b80922a48}
+
+ {d2916069-8bff-46e6-9a07-6b845c4361dd}
+
+
+ {2fba67c2-5ab9-4f75-82ed-e1024b272094}
+
+
+ {5cead5cc-9a75-4d2e-99b5-ebbc8f9d6d86}
+
@@ -31,31 +37,31 @@
source
- plugin_sdk
+ third_party\plugin_sdk
- plugin_sdk
+ third_party\plugin_sdk
- plugin_sdk
+ third_party\plugin_sdk
- plugin_sdk
+ third_party\plugin_sdk
- plugin_sdk
+ third_party\plugin_sdk
- plugin_sdk
+ third_party\plugin_sdk
- plugin_sdk
+ third_party\plugin_sdk
- plugin_sdk
+ third_party\plugin_sdk
- plugin_sdk
+ third_party\plugin_sdk
source\utils
@@ -94,22 +100,25 @@
source\extensions
- plugin_sdk
+ third_party\plugin_sdk
source\utils
- plugin_sdk
+ third_party\plugin_sdk
source\extensions
- plugin_sdk
+ third_party\plugin_sdk
- plugin_sdk
+ third_party\plugin_sdk
+
+
+ third_party\simdjson
@@ -173,6 +182,9 @@
source\utils
+
+ third_party\simdjson
+
diff --git a/source/CCustomOpcodeSystem.cpp b/source/CCustomOpcodeSystem.cpp
index 067292e3..ca08a3ca 100644
--- a/source/CCustomOpcodeSystem.cpp
+++ b/source/CCustomOpcodeSystem.cpp
@@ -6,7 +6,6 @@
#include "CCheat.h"
#include "CModelInfo.h"
-#include
#include
#include
#include
@@ -70,30 +69,8 @@ namespace CLEO
template void operator+=(FuncScriptDeleteDelegateT mFunc) { funcs.push_back(mFunc); }
template void operator-=(FuncScriptDeleteDelegateT mFunc) { funcs.erase(std::remove(funcs.begin(), funcs.end(), mFunc), funcs.end()); }
void operator()(CRunningScript *script)
- {
- for (auto& f : funcs)
- {
- // check if function pointer lays within any of currently loaded modules (.asi or .cleo plugins)
- void* ptr = f;
- MODULEENTRY32 module;
- module.dwSize = sizeof(MODULEENTRY32);
- HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
- Module32First(snapshot, &module);
- if (snapshot != INVALID_HANDLE_VALUE)
- {
- size_t count = 0;
- do
- {
- if(ptr >= module.modBaseAddr && ptr <= (module.modBaseAddr + module.modBaseSize))
- {
- f(script);
- break;
- }
- } while (Module32Next(snapshot, &module));
- CloseHandle(snapshot);
- }
- }
-
+ {
+ for (auto& f : funcs) f(script);
}
};
ScriptDeleteDelegate scriptDeleteDelegate;
@@ -749,7 +726,6 @@ namespace CLEO
// handle program flow
scmFunc->Return(cs); // jump back to cleo_call, right after last input param. Return slot var args starts here
- if (scmFunc->moduleExportRef != nullptr) GetInstance().ModuleSystem.ReleaseModuleRef((char*)scmFunc->moduleExportRef); // exiting export - release module
delete scmFunc;
if (returnArgs)
@@ -1021,7 +997,6 @@ namespace CLEO
SHOW_ERROR("Not found module '%s' export '%s', requested by opcode [0AB1] in script %s", modulePath.c_str(), moduleTxt.c_str(), ((CCustomScript*)thread)->GetInfoStr().c_str());
return thread->Suspend();
}
- scmFunc->moduleExportRef = scriptRef.base; // to be released on return
reinterpret_cast(thread)->SetScriptFileDir(FS::path(modulePath).parent_path().string().c_str());
reinterpret_cast(thread)->SetScriptFileName(FS::path(modulePath).filename().string().c_str());
diff --git a/source/CDebug.cpp b/source/CDebug.cpp
index 0ac92941..91c3a626 100644
--- a/source/CDebug.cpp
+++ b/source/CDebug.cpp
@@ -23,33 +23,7 @@ std::string stringPrintf(const char* format, ...)
return result;
}
-void CDebug::Trace(eLogLevel level, const char* format, ...)
-{
- va_list args;
- va_start(args, format);
- TraceVArg(level, format, args);
- va_end(args);
-}
-
-void CDebug::Trace(const CLEO::CRunningScript* thread, CLEO::eLogLevel level, const char* format, ...)
-{
- if(thread != nullptr && thread->IsCustom())
- {
- const auto cs = (CCustomScript*)thread;
-
- if(cs->GetCompatibility() < CLEO_VER_5)
- {
- return; // do not log this in older versions
- }
- }
-
- va_list args;
- va_start(args, format);
- TraceVArg(level, format, args);
- va_end(args);
-}
-
-const char* CDebug::TraceVArg(CLEO::eLogLevel level, const char* format, va_list args)
+void CDebug::Trace(CLEO::eLogLevel level, const char* msg)
{
std::lock_guard guard(mutex);
@@ -57,12 +31,15 @@ const char* CDebug::TraceVArg(CLEO::eLogLevel level, const char* format, va_list
// time stamp
SYSTEMTIME t;
- GetLocalTime(&t);
+
+ //GetLocalTime(&t);
+ void (__stdcall * GTA_GetLocalTime)(LPSYSTEMTIME lpSystemTime) = memory_pointer(0x0081E514); // use ingame function instead as GetLocalTime seems to be considered suspicious by some AV software
+ GTA_GetLocalTime(&t);
+
sprintf(szBuf, "%02d/%02d/%04d %02d:%02d:%02d.%03d ", t.wDay, t.wMonth, t.wYear, t.wHour, t.wMinute, t.wSecond, t.wMilliseconds);
char* stampEnd = szBuf + strlen(szBuf);
- // put params into format
- vsprintf(stampEnd, format, args);
+ strcpy(stampEnd, msg);
// output to file
if(m_hFile.good())
@@ -84,42 +61,12 @@ const char* CDebug::TraceVArg(CLEO::eLogLevel level, const char* format, va_list
((callback*)func)(level, stampEnd);
}
}
-
- return stampEnd;
-}
-
-void CDebug::Error(const char* format, ...)
-{
- va_list args;
- va_start(args, format);
- auto msg = TraceVArg(eLogLevel::Error, format, args);
- va_end(args);
-
- QUERY_USER_NOTIFICATION_STATE pquns;
- SHQueryUserNotificationState(&pquns);
- bool fullscreen = (pquns == QUNS_BUSY) || (pquns == QUNS_RUNNING_D3D_FULL_SCREEN) || (pquns == QUNS_PRESENTATION_MODE);
-
- auto mainWnd = RsGlobal.ps->window;
-
- if(fullscreen)
- {
- PostMessage(mainWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
- ShowWindow(mainWnd, SW_MINIMIZE);
- }
-
- MessageBox(mainWnd, msg, "CLEO error", MB_SYSTEMMODAL | MB_TOPMOST | MB_ICONERROR | MB_OK);
-
- if (fullscreen)
- {
- PostMessage(mainWnd, WM_SYSCOMMAND, SC_RESTORE, 0);
- ShowWindow(mainWnd, SW_RESTORE);
- }
}
extern "C"
{
void WINAPI CLEO_Log(eLogLevel level, const char* msg)
{
- Debug.Trace(level, "%s", msg);
+ Debug.Trace(level, msg);
}
}
diff --git a/source/CDebug.h b/source/CDebug.h
index 89dd1ae2..c1da6c0e 100644
--- a/source/CDebug.h
+++ b/source/CDebug.h
@@ -16,25 +16,22 @@ class CDebug
Trace(CLEO::eLogLevel::Default, "Log started.");
#ifdef _DEBUG
- Trace(CLEO::eLogLevel::Default, "CLEO v%s DEBUG", CLEO_VERSION_STR);
+ CLEO::Trace(CLEO::eLogLevel::Default, "CLEO v%s DEBUG", CLEO_VERSION_STR);
#else
- Trace(CLEO::eLogLevel::Default, "CLEO v%s", CLEO_VERSION_STR);
+ CLEO::Trace(CLEO::eLogLevel::Default, "CLEO v%s", CLEO_VERSION_STR);
#endif
}
~CDebug()
{
- Trace(CLEO::eLogLevel::Default, "Log finished.");
+ CLEO::Trace(CLEO::eLogLevel::Default, "Log finished.");
}
- void Trace(CLEO::eLogLevel level, const char* format, ...);
- void Trace(const CLEO::CRunningScript* thread, CLEO::eLogLevel level, const char* format, ...);
- void Error(const char* format, ...);
+ void Trace(CLEO::eLogLevel level, const char* msg);
private:
std::mutex mutex;
std::ofstream m_hFile;
- const char* TraceVArg(CLEO::eLogLevel level, const char* format, va_list args);
-};
+ };
extern CDebug Debug;
diff --git a/source/CModuleSystem.cpp b/source/CModuleSystem.cpp
index 0e7d5597..66078032 100644
--- a/source/CModuleSystem.cpp
+++ b/source/CModuleSystem.cpp
@@ -3,7 +3,6 @@
#include "CModuleSystem.h"
#include "FileEnumerator.h"
-#include
#include
using namespace CLEO;
@@ -35,10 +34,6 @@ const ScriptDataRef CModuleSystem::GetExport(std::string modulePath, std::string
auto& module = it->second;
auto e = module.GetExport(std::string(exportName));
- if (e.Valid())
- {
- module.refCount++;
- }
return e;
}
@@ -72,34 +67,6 @@ bool CModuleSystem::LoadCleoModules()
return LoadDirectory(path.c_str());
}
-void CLEO::CModuleSystem::AddModuleRef(const char* baseIP)
-{
- for (auto& it : modules)
- {
- auto& module = it.second;
-
- if (module.data.data() == baseIP)
- {
- module.refCount++;
- return;
- }
- }
-}
-
-void CLEO::CModuleSystem::ReleaseModuleRef(const char* baseIP)
-{
- for (auto& it : modules)
- {
- auto& module = it.second;
-
- if (module.data.data() == baseIP)
- {
- module.refCount--;
- return;
- }
- }
-}
-
void CModuleSystem::NormalizePath(std::string& path)
{
for (char& c : path)
@@ -113,73 +80,11 @@ void CModuleSystem::NormalizePath(std::string& path)
};
}
-void CModuleSystem::CModule::Update()
-{
- while (updateActive)
- {
- if (!updateNeeded)
- {
- FS::file_time_type time;
- try
- {
- time = FS::last_write_time(filepath);
- }
- catch (...)
- {
- time = {};
- }
-
- // file not exists or up to date
- if (time == FS::file_time_type{} || time == fileTime)
- {
- // query files once a second
- for(size_t i = 0; i < 100 && updateActive; i++)
- std::this_thread::sleep_for(std::chrono::milliseconds(10));
-
- continue;
- }
-
- updateNeeded = true;
- }
-
- if (refCount != 0)
- {
- continue; // module currently in use
- }
-
- auto file = filepath;
- auto result = LoadFromFile(file.c_str());
- updateNeeded = false;
- Debug.Trace(eLogLevel::Debug, "Module reload %s '%s'", result ? "OK" : "FAILED", file.c_str());
- }
-}
-
-CModuleSystem::CModule::CModule() :
- updateThread(&CModuleSystem::CModule::Update, this)
-{
-}
-
-CModuleSystem::CModule::~CModule()
-{
- updateActive = false;
- updateThread.join();
-}
-
void CModuleSystem::CModule::Clear()
{
- if (refCount != 0)
- {
- TRACE("Warning! Module '%s' cleared despite in use %d time(s)", filepath.c_str(), refCount.load());
- }
-
- std::lock_guard guard(updateMutex);
-
filepath.clear();
data.clear();
exports.clear();
-
- refCount = 0;
- fileTime = {};
}
const char* CModuleSystem::CModule::GetFilepath() const
@@ -190,20 +95,8 @@ const char* CModuleSystem::CModule::GetFilepath() const
bool CModuleSystem::CModule::LoadFromFile(const char* path)
{
Clear();
-
- std::lock_guard guard(updateMutex);
-
filepath = path;
- try
- {
- fileTime = FS::last_write_time(path);
- }
- catch(...)
- {
- fileTime = {};
- }
-
std::ifstream file(path, std::ios::binary);
if (!file.good())
{
diff --git a/source/CModuleSystem.h b/source/CModuleSystem.h
index b78aee14..869a7cd8 100644
--- a/source/CModuleSystem.h
+++ b/source/CModuleSystem.h
@@ -1,8 +1,5 @@
#pragma once
-#include
#include