forked from cleolibrary/CLEO4
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace call_function to CFileMgr::SetDir from scripts with CLEO_SetS…
…criptWorkDir
- Loading branch information
Showing
4 changed files
with
63 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
#include "CLEO.h" | ||
#include <string> | ||
|
||
namespace AntiHacks | ||
{ | ||
// checks if specific function call is allowed. Performs replacement action if needed | ||
static bool CheckCall(CLEO::CRunningScript* thread, void* function, void* object, CLEO::SCRIPT_VAR* args, size_t argCount, DWORD& result) | ||
{ | ||
switch ((size_t)function) | ||
{ | ||
// Setting work directory. Some older mods used these instead of 0A99 opcode | ||
case 0x005387D0: // CFileMgr::SetDir(const char* relPath) | ||
case 0x00836F1E: // _chdir(LPCSTR lpPathName) | ||
case 0x0085824C: // SetCurrentDirectoryA(LPCSTR lpPathName) | ||
{ | ||
auto resolved = std::string(args[0].pcParam); | ||
resolved.resize(MAX_PATH); | ||
CLEO_ResolvePath(thread, resolved.data(), resolved.size()); | ||
|
||
CLEO_SetScriptWorkDir(thread, resolved.c_str()); | ||
return false; // block call | ||
} | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
|
||
return true; // allow call | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters