diff --git a/PriorityMod.sln b/PriorityMod.sln
index 754e7d4..b8f498a 100644
--- a/PriorityMod.sln
+++ b/PriorityMod.sln
@@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Root", "Root", "{D8F32DB4-3
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
build.bat = build.bat
+ pack.bat = pack.bat
pack.csx = pack.csx
PriorityMod.toml = PriorityMod.toml
EndProjectSection
diff --git a/PriorityMod/PriorityMod.vcxproj b/PriorityMod/PriorityMod.vcxproj
index faab531..da298dc 100644
--- a/PriorityMod/PriorityMod.vcxproj
+++ b/PriorityMod/PriorityMod.vcxproj
@@ -120,7 +120,7 @@
Windows
true
true
- true
+ false
false
@@ -152,18 +152,24 @@
stdcpp17
+ StdCall
Windows
true
true
- true
+ false
false
+
+
+
+
+
@@ -173,6 +179,8 @@
Create
Create
+
+
diff --git a/PriorityMod/PriorityMod.vcxproj.filters b/PriorityMod/PriorityMod.vcxproj.filters
index 0d3c966..475d222 100644
--- a/PriorityMod/PriorityMod.vcxproj.filters
+++ b/PriorityMod/PriorityMod.vcxproj.filters
@@ -9,6 +9,9 @@
{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+ {6a53091c-4f08-4253-a437-5f360937c238}
+
@@ -17,6 +20,21 @@
Header Files
+
+ Header Files
+
+
+ Targets
+
+
+ Targets
+
+
+ Targets
+
+
+ Targets
+
@@ -28,5 +46,11 @@
Source Files
+
+ Targets
+
+
+ Targets
+
\ No newline at end of file
diff --git a/PriorityMod/Targets/Fallout3.cpp b/PriorityMod/Targets/Fallout3.cpp
new file mode 100644
index 0000000..62b3bfc
--- /dev/null
+++ b/PriorityMod/Targets/Fallout3.cpp
@@ -0,0 +1,19 @@
+#include "../common.h"
+
+#if !_WIN64
+extern "C"
+{
+ DllExport bool FOSEPlugin_Query(const MasterInterface* se, PluginInfo* info)
+ {
+ info->name = ModName;
+ info->infoVersion = PluginInfo::kInfoVersion;
+ info->version = ModVersion;
+ return true;
+ }
+
+ DllExport bool FOSEPlugin_Load(const MasterInterface* se)
+ {
+ return true;
+ }
+};
+#endif
\ No newline at end of file
diff --git a/PriorityMod/Targets/Fallout4.cpp b/PriorityMod/Targets/Fallout4.cpp
new file mode 100644
index 0000000..31843aa
--- /dev/null
+++ b/PriorityMod/Targets/Fallout4.cpp
@@ -0,0 +1,19 @@
+#include "../common.h"
+
+#if _WIN64
+extern "C"
+{
+ DllExport bool F4SEPlugin_Query(const MasterInterface* se, PluginInfo* info)
+ {
+ info->name = ModName;
+ info->infoVersion = PluginInfo::kInfoVersion;
+ info->version = ModVersion;
+ return true;
+ }
+
+ DllExport bool F4SEPlugin_Load(const MasterInterface* se)
+ {
+ return true;
+ }
+};
+#endif
\ No newline at end of file
diff --git a/PriorityMod/Targets/NewVegas.cpp b/PriorityMod/Targets/NewVegas.cpp
new file mode 100644
index 0000000..8be2f8d
--- /dev/null
+++ b/PriorityMod/Targets/NewVegas.cpp
@@ -0,0 +1,19 @@
+#include "../common.h"
+
+#if !_WIN64
+extern "C"
+{
+ DllExport bool NVSEPlugin_Query(const MasterInterface* se, PluginInfo* info)
+ {
+ info->name = ModName;
+ info->infoVersion = PluginInfo::kInfoVersion;
+ info->version = ModVersion;
+ return true;
+ }
+
+ DllExport bool NVSEPlugin_Load(const MasterInterface* se)
+ {
+ return true;
+ }
+};
+#endif
\ No newline at end of file
diff --git a/PriorityMod/Targets/Oblivion.cpp b/PriorityMod/Targets/Oblivion.cpp
new file mode 100644
index 0000000..478ac65
--- /dev/null
+++ b/PriorityMod/Targets/Oblivion.cpp
@@ -0,0 +1,19 @@
+#include "../common.h"
+
+#if !_WIN64
+extern "C"
+{
+ DllExport bool OBSEPlugin_Query(const MasterInterface* se, PluginInfo* info)
+ {
+ info->name = ModName;
+ info->infoVersion = PluginInfo::kInfoVersion;
+ info->version = ModVersion;
+ return true;
+ }
+
+ DllExport bool OBSEPlugin_Load(const MasterInterface* se)
+ {
+ return true;
+ }
+};
+#endif
\ No newline at end of file
diff --git a/PriorityMod/Targets/Oldrim.cpp b/PriorityMod/Targets/Oldrim.cpp
new file mode 100644
index 0000000..6a32fad
--- /dev/null
+++ b/PriorityMod/Targets/Oldrim.cpp
@@ -0,0 +1,19 @@
+#include "../common.h"
+
+#if !_WIN64
+extern "C"
+{
+ DllExport bool SKSEPlugin_Query(const MasterInterface* skse, PluginInfo* info)
+ {
+ info->name = ModName;
+ info->infoVersion = PluginInfo::kInfoVersion;;
+ info->version = ModVersion;
+ return true;
+ }
+
+ DllExport bool SKSEPlugin_Load(const MasterInterface* skse)
+ {
+ return true;
+ }
+};
+#endif
\ No newline at end of file
diff --git a/PriorityMod/Targets/SkyrimSE.cpp b/PriorityMod/Targets/SkyrimSE.cpp
new file mode 100644
index 0000000..8644f70
--- /dev/null
+++ b/PriorityMod/Targets/SkyrimSE.cpp
@@ -0,0 +1,19 @@
+#include "../common.h"
+
+#if _WIN64
+extern "C"
+{
+ DllExport bool SKSEPlugin_Query(const MasterInterface* se, PluginInfo* info)
+ {
+ info->name = ModName;
+ info->infoVersion = PluginInfo::kInfoVersion;
+ info->version = ModVersion;
+ return true;
+ }
+
+ DllExport bool SKSEPlugin_Load(const MasterInterface* se)
+ {
+ return true;
+ }
+};
+#endif
\ No newline at end of file
diff --git a/PriorityMod/common.h b/PriorityMod/common.h
new file mode 100644
index 0000000..2573c32
--- /dev/null
+++ b/PriorityMod/common.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#define DllExport __declspec( dllexport )
+
+#define ModName "FallrimPriority";
+#define ModVersion 3;
+
+typedef unsigned char UInt8; //!< An unsigned 8-bit integer value
+typedef unsigned short UInt16; //!< An unsigned 16-bit integer value
+typedef unsigned long UInt32; //!< An unsigned 32-bit integer value
+typedef unsigned long long UInt64; //!< An unsigned 64-bit integer value
+typedef signed char SInt8; //!< A signed 8-bit integer value
+typedef signed short SInt16; //!< A signed 16-bit integer value
+typedef signed long SInt32; //!< A signed 32-bit integer value
+typedef signed long long SInt64; //!< A signed 64-bit integer value
+typedef float Float32; //!< A 32-bit floating point value
+typedef double Float64; //!< A 64-bit floating point value
+
+typedef UInt32 PluginHandle; // treat this as an opaque type
+
+struct PluginInfo
+{
+ enum
+ {
+ kInfoVersion = 1
+ };
+
+ UInt32 infoVersion;
+ const char* name;
+ UInt32 version;
+};
+
+struct MasterInterface
+{
+ UInt32 obseVersion;
+ UInt32 oblivionVersion;
+ UInt32 editorVersion;
+ UInt32 isEditor;
+};
\ No newline at end of file
diff --git a/PriorityMod/dllmain.cpp b/PriorityMod/dllmain.cpp
index 407ebca..d708ec4 100644
--- a/PriorityMod/dllmain.cpp
+++ b/PriorityMod/dllmain.cpp
@@ -15,8 +15,8 @@ toml::parse_result config;
bool ParseConfig()
{
- LPTSTR buffer = new TCHAR[_MAX_PATH * 3];
- GetModuleFileNameW((HINSTANCE)&__ImageBase, buffer, _MAX_PATH * 3);
+ LPTSTR buffer = new WCHAR[_MAX_PATH * 3];
+ GetModuleFileName((HINSTANCE)&__ImageBase, buffer, _MAX_PATH * 3);
wstring filename = buffer;
@@ -63,6 +63,7 @@ BOOL CALLBACK enum_windows_callback(HWND handle, LPARAM lParam)
void GetGameWindowHandle()
{
+
do
{
EnumWindows(enum_windows_callback, NULL);
@@ -146,9 +147,10 @@ BOOL APIENTRY DllMain(HMODULE hModule,
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
- // Prevent mod being unloaded from Script Extender
static HMODULE current;
- GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPTSTR)¤t, ¤t);
+ GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPTSTR)&DllMain, ¤t);
+
+ // Prevent mod being unloaded from Script Extender
int priority_classes[] = {
IDLE_PRIORITY_CLASS,
BELOW_NORMAL_PRIORITY_CLASS,
@@ -185,6 +187,9 @@ BOOL APIENTRY DllMain(HMODULE hModule,
#endif // !_WIN64
#pragma endregion
+ ApplyAffinity();
+ ApplyPriority();
+
if (config["DynamicPriority"]["enabled"].value_or(1))
_beginthread(DynamicPriority, NULL, NULL);
@@ -195,5 +200,5 @@ BOOL APIENTRY DllMain(HMODULE hModule,
}
}
- return false;
+ return true;
}
diff --git a/pack.bat b/pack.bat
new file mode 100644
index 0000000..f3b6a93
--- /dev/null
+++ b/pack.bat
@@ -0,0 +1,31 @@
+@ REM Check DotNet installed
+@ WHERE dotnet >nul 2>nul
+@ IF %ERRORLEVEL% NEQ 0 goto DotNetNotFound
+
+@ REM Check DotNet-Script available in Path
+@ WHERE dotnet-script >nul 2>nul
+@ IF %ERRORLEVEL% NEQ 0 goto DotNetScriptNotFound
+
+@ REM Build the solution
+@ call build.bat
+
+@ REM Pack
+@ dotnet-script pack.csx
+
+@ exit /b
+
+@ REM ========================
+@ REM DotNet is not Available
+@ REM Throw an exception
+:DotNetNotFound
+@ echo DotNet is not found. 1>&2
+@ echo Make sure DotNet is installed 1>&2
+@ exit /b 1
+
+@ REM ========================
+@ REM DotNet-Script is not Available
+@ REM Throw an exception
+:DotNetScriptNotFound
+@ echo DotNet-Script is not found. 1>&2
+@ echo Install by 'dotnet tool uninstall dotnet-script -g' 1>&2
+@ exit /b 1