hlnonvr
hlnonvr copied to clipboard
Patch applier
I don't know if you had intentions to do it or not, but I wrote a simple C# code to replace the engine2 string in hlvr.exe with hlnonvr:
internal void ApplyNonVRPatch()
{
string fullPath = installPath + "\\game\\bin\\win64\\hlvr.exe";
Dictionary<int, string> strings = new Dictionary<int, string>();
byte[] byteArray = File.ReadAllBytes(fullPath);
List<char> chars = new List<char>();
for (int i = 0; i < byteArray.Length; i++)
{
byte b = byteArray[i];
if (b == 0 && chars.Count > 0)
{
string word = new String(chars.ToArray());
strings.Add(i - word.Length, word);
chars.Clear();
}
else if (b > 0)
chars.Add(Convert.ToChar(b));
}
strings = strings.Where(x => x.Value.Contains("engine2"))
.ToDictionary(x => x.Key, x => x.Value);
foreach (KeyValuePair<int, string> kv in strings)
{
string value = kv.Value.Replace("engine2", "hlnonvr");
char[] charArray = value.ToCharArray();
for (int i = 0; i < charArray.Length; i++)
{
byteArray[kv.Key + i] = Convert.ToByte(charArray[i]);
}
}
try
{
File.WriteAllBytes(fullPath.Replace("hlvr.exe", "hlnonvr.exe"), byteArray);
File.Copy(AppDomain.CurrentDomain.BaseDirectory + "/Tools/HLnonVR/hlnonvr.dll", installPath + "\\game\\bin\\win64\\hlnonvr.dll");
}
catch (Exception) { }
}
It wouldn't actually be "distributing valve code", and it would call out people who are afraid to use a hex editor.