Skip to content

Commit

Permalink
Fix endian-ness of hostname patching for dark souls 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
TLeonardUK committed Jan 8, 2024
1 parent ee60c10 commit 8bcccec
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ bool DS2_ReplaceServerAddressHook::PatchHostname(Injector& injector)
continue;
}

memcpy((char*)key, WideHostname.c_str(), CopyLength);
wchar_t* ptr = (wchar_t*)key;
for (size_t i = 0; i < WideHostname.size() + 1; i++)
{
wchar_t chr = WideHostname[i];

// Flip endian
char* source = (char*)&chr;
std::swap(source[0], source[1]);

memcpy(ptr, source, sizeof(wchar_t));
ptr++;
}
FoundKey = true;
}

Expand Down

0 comments on commit 8bcccec

Please sign in to comment.