-
Notifications
You must be signed in to change notification settings - Fork 113
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
Update DS2_ReplaceServerAddressHook.cpp #220
Changes from 2 commits
7b4525c
b46eece
90d54e8
9d9a86e
f2a8f94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ bool DS2_ReplaceServerAddressHook::PatchHostname(Injector& injector) | |
std::wstring WideHostname = WidenString(Config.ServerHostname); | ||
size_t CopyLength = (WideHostname.size() + 1) * 2; | ||
|
||
char* winePrefix = std::getenv("WINEPREFIX"); | ||
|
||
while (true) | ||
{ | ||
std::vector<intptr_t> address_matches = injector.SearchString({ | ||
|
@@ -46,9 +48,13 @@ bool DS2_ReplaceServerAddressHook::PatchHostname(Injector& injector) | |
{ | ||
continue; | ||
} | ||
if (((info.Protect & PAGE_READWRITE) == 0 && (info.Protect & PAGE_EXECUTE_READWRITE) == 0)) | ||
{ | ||
continue; | ||
//if i'm not running in wine do the check | ||
if (winePrefix == nullptr) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. couple of coding style issues:
|
||
Log("you are using windows"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remove this please, it isn't needed. |
||
if (((info.Protect & PAGE_READWRITE) == 0 && (info.Protect & PAGE_EXECUTE_READWRITE) == 0)) | ||
{ | ||
continue; | ||
} | ||
} | ||
|
||
wchar_t* ptr = (wchar_t*)key; | ||
|
@@ -77,6 +83,8 @@ bool DS2_ReplaceServerAddressHook::PatchHostname(Injector& injector) | |
|
||
bool DS2_ReplaceServerAddressHook::PatchKey(Injector& injector) | ||
{ | ||
char* winePrefix = std::getenv("WINEPREFIX"); | ||
|
||
while (true) | ||
{ | ||
const RuntimeConfig& Config = Injector::Instance().GetConfig(); | ||
|
@@ -99,10 +107,22 @@ bool DS2_ReplaceServerAddressHook::PatchKey(Injector& injector) | |
{ | ||
// If the memory is not writable yet, modify its protection (steam drm fucks with the protection during boot). | ||
MEMORY_BASIC_INFORMATION info; | ||
if (VirtualQuery((void*)key, &info, sizeof(info)) == 0 || | ||
((info.Protect & PAGE_READWRITE) == 0 && (info.Protect & PAGE_EXECUTE_READWRITE) == 0)) | ||
// If the programm is running on wine | ||
if(winePrefix != nullptr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space after if please, also the comment doesn't really add anything, please remove it. |
||
{ | ||
continue; | ||
Log("you are using wine"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the log please. |
||
if (VirtualQuery((void*)key, &info, sizeof(info)) == 0) //wine doesn't emulate memory seafe features of windows {il TroncoNinja e' stato qui} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment on previous line please - also please stick to english, even if its just a fun tag :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious, what does wine actually return for the protection flags? I would expect it to return the same values as windows, as I can see a whole slew of compatibility issues if that wasn't the case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the Flags are all correct, as far as my testing goes, the problem is in the info struct, more specifically the changes made in the info.Protect (in windows info.Protect=64, in wine/proton info.Protect = 128). The memory seems to have the PAGE_EXECUTE_WRITECOPY flag instead of PAGE_EXECUTE_READWRITE. the flags for memory safety in linux are different, as far as my research goes, wine has problems(design) translating the flags/translating memory managment |
||
{ | ||
continue; | ||
} | ||
} | ||
else | ||
{ | ||
if (VirtualQuery((void*)key, &info, sizeof(info)) == 0 || | ||
((info.Protect & PAGE_READWRITE) == 0 && (info.Protect & PAGE_EXECUTE_READWRITE) == 0)) | ||
{ | ||
continue; | ||
} | ||
} | ||
|
||
memcpy((char*)key, Config.ServerPublicKey.c_str(), CopyLength); | ||
|
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.
Whats the reason for 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.
my bad, it was only for running in my GitHub action to test the package, didn't mean to commit this, i will re-add the code