-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Path validation fixes #214
Conversation
// ModLoader's hooks require relative paths in LoadLibrary to work | ||
FilepathRemoveParent(buff, CLEO_GetGameDirectory()); | ||
|
||
ptr = LoadLibrary(buff.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not
OPCODE_READ_PARAM_FILEPATH(path);
HMODULE ptr = LoadLibrary(path);
if (ptr != nullptr)
{
m_libraries.insert(ptr);
}
OPCODE_WRITE_PARAM_PTR(ptr);
OPCODE_CONDITION_RESULT(ptr != nullptr);
return OR_CONTINUE;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about LoadLibrary("kernel32.dll")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the path shouldn't change and remain "kernel32.dll"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change work dir with 0A99 it will be added at the beginning then. That function did not used path reading macro on purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdym? If workdir is within game directory it will stripped from the path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ML seems unable to install its hooks if library passed to LoadLibrary is not relative path. It happens when loading cleo plugins too.
I think CLEO_ResolvePath will still resolve some paths as absolute. Like virtual "cleo:"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ML has nothing to do with virtual/absolute paths. What script was reported not working to make this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert the change to 0AA2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ML has nothing to do with virtual/absolute paths. What script was reported not working to make this change?
https://github.com/cleolibrary/CLEO5/blob/master/source/CScriptEngine.cpp#L682
Perhaps if changed it will become dead loop in some cases, as resolved path will still be seen as not resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to make virtual path ML-compatible (i.g. relative to game dir), then we should do it in ResolvePath. stream_custom_script "cleo:\1.cs" and load_library "cleo:\1.dll" should work the same.
9106f1a
to
c8e12a7
Compare
No description provided.