Mega bug fixes!

This commit is contained in:
binarymaster 2014-12-09 03:15:58 +03:00
parent e2968a43de
commit 39b8c6fade

View File

@ -523,8 +523,7 @@ void Hook()
if(!(IniFile->GetVariableInSection("Main", "LogFile", &LogFileVar))) if(!(IniFile->GetVariableInSection("Main", "LogFile", &LogFileVar)))
{ {
memcpy((void*)LogFile, LogFileVar.Value, strlen(LogFileVar.Value)); GetModuleFileName(GetCurrentModule(), LogFile, 255);
for(DWORD i = wcslen(LogFile); i > 0; i--) for(DWORD i = wcslen(LogFile); i > 0; i--)
{ {
if(LogFile[i] == '\\') if(LogFile[i] == '\\')
@ -534,8 +533,7 @@ void Hook()
} }
} }
} }
// else... else memcpy((void*)LogFile, LogFileVar.Value, strlen(LogFileVar.Value));
// LogFileVar => LogFile
char *Log; char *Log;
SIZE_T bw; SIZE_T bw;
@ -603,13 +601,6 @@ void Hook()
WriteToLog("freeze\r\n"); WriteToLog("freeze\r\n");
SetThreadsState(false); SetThreadsState(false);
WriteToLog("Loading patch codes...\r\n");
INI_SECTION_VARLIST PatchList;
IniFile->GetSectionVariablesList("PatchCodes", &PatchList);
bool bSLHook; bool bSLHook;
if (!(IniFile->GetVariableInSection("Main", "SLPolicyHookNT60", &bSLHook))) bSLHook = true; if (!(IniFile->GetVariableInSection("Main", "SLPolicyHookNT60", &bSLHook))) bSLHook = true;
@ -643,7 +634,7 @@ void Hook()
} }
} }
if (!(IniFile->GetVariableInSection("Main", "SLPolicyHookNT60", &bSLHook))) bSLHook = true; if (!(IniFile->GetVariableInSection("Main", "SLPolicyHookNT61", &bSLHook))) bSLHook = true;
if ((Ver == 0x0601) && bSLHook) if ((Ver == 0x0601) && bSLHook)
{ {
@ -696,6 +687,7 @@ void Hook()
} }
char *Sect; char *Sect;
INI_VAR_STRING PatchName;
INI_VAR_BYTEARRAY Patch; INI_VAR_BYTEARRAY Patch;
Sect = new char[1024]; Sect = new char[1024];
wsprintfA(Sect, "%d.%d.%d.%d", FV.wVersion.Major, FV.wVersion.Minor, FV.Release, FV.Build); wsprintfA(Sect, "%d.%d.%d.%d", FV.wVersion.Major, FV.wVersion.Minor, FV.Release, FV.Build);
@ -706,9 +698,9 @@ void Hook()
{ {
bool Bool; bool Bool;
#ifdef _WIN64 #ifdef _WIN64
if (!(IniFile->GetVariableInSection(Sect, "LocalOnlyPatch.x64", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "LocalOnlyPatch.x64", &Bool))) Bool = false;
#else #else
if (!(IniFile->GetVariableInSection(Sect, "LocalOnlyPatch.x86", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "LocalOnlyPatch.x86", &Bool))) Bool = false;
#endif #endif
if (Bool) if (Bool)
{ {
@ -716,20 +708,21 @@ void Hook()
Bool = false; Bool = false;
#ifdef _WIN64 #ifdef _WIN64
SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "LocalOnlyOffset.x64", 0)); SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "LocalOnlyOffset.x64", 0));
Bool = IniFile->GetVariableInSection(Sect, "LocalOnlyCode.x64", &Patch); // [!] returns patch name, not the patch itself Bool = IniFile->GetVariableInSection(Sect, "LocalOnlyCode.x64", &PatchName);
#else #else
SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "LocalOnlyOffset.x86", 0)); SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "LocalOnlyOffset.x86", 0));
Bool = IniFile->GetVariableInSection(Sect, "LocalOnlyCode.x86", &Patch); // [!] returns patch name, not the patch itself Bool = IniFile->GetVariableInSection(Sect, "LocalOnlyCode.x86", &PatchName);
#endif #endif
if (Bool) Bool = IniFile->GetVariableInSection("PatchCodes", PatchName.Value, &Patch);
// Patch.Value is char // Patch.Value is char
// WriteProcessMemory uses LPCVOID lpBuffer, so... // WriteProcessMemory uses LPCVOID lpBuffer, so...
// maybe &Patch.Value ? // maybe &Patch.Value ?
if (Bool && (SignPtr > TermSrvBase)) WriteProcessMemory(GetCurrentProcess(), (LPVOID)SignPtr, Patch.Value, Patch.ArraySize, &bw); if (Bool && (SignPtr > TermSrvBase)) WriteProcessMemory(GetCurrentProcess(), (LPVOID)SignPtr, Patch.Value, Patch.ArraySize, &bw);
} }
#ifdef _WIN64 #ifdef _WIN64
if (!(IniFile->GetVariableInSection(Sect, "SingleUserPatch.x64", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "SingleUserPatch.x64", &Bool))) Bool = false;
#else #else
if (!(IniFile->GetVariableInSection(Sect, "SingleUserPatch.x86", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "SingleUserPatch.x86", &Bool))) Bool = false;
#endif #endif
if (Bool) if (Bool)
{ {
@ -737,20 +730,21 @@ void Hook()
Bool = false; Bool = false;
#ifdef _WIN64 #ifdef _WIN64
SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "SingleUserOffset.x64", 0)); SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "SingleUserOffset.x64", 0));
Bool = IniFile->GetVariableInSection(Sect, "SingleUserCode.x64", &Patch); // [!] returns patch name, not the patch itself Bool = IniFile->GetVariableInSection(Sect, "SingleUserCode.x64", &PatchName);
#else #else
SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "SingleUserOffset.x86", 0)); SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "SingleUserOffset.x86", 0));
Bool = IniFile->GetVariableInSection(Sect, "SingleUserCode.x86", &Patch); // [!] returns patch name, not the patch itself Bool = IniFile->GetVariableInSection(Sect, "SingleUserCode.x86", &PatchName);
#endif #endif
if (Bool) Bool = IniFile->GetVariableInSection("PatchCodes", PatchName.Value, &Patch);
// Patch.Value is char // Patch.Value is char
// WriteProcessMemory uses LPCVOID lpBuffer, so... // WriteProcessMemory uses LPCVOID lpBuffer, so...
// maybe &Patch.Value ? // maybe &Patch.Value ?
if (Bool && (SignPtr > TermSrvBase)) WriteProcessMemory(GetCurrentProcess(), (LPVOID)SignPtr, Patch.Value, Patch.ArraySize, &bw); if (Bool && (SignPtr > TermSrvBase)) WriteProcessMemory(GetCurrentProcess(), (LPVOID)SignPtr, Patch.Value, Patch.ArraySize, &bw);
} }
#ifdef _WIN64 #ifdef _WIN64
if (!(IniFile->GetVariableInSection(Sect, "DefPolicyPatch.x64", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "DefPolicyPatch.x64", &Bool))) Bool = false;
#else #else
if (!(IniFile->GetVariableInSection(Sect, "DefPolicyPatch.x86", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "DefPolicyPatch.x86", &Bool))) Bool = false;
#endif #endif
if (Bool) if (Bool)
{ {
@ -758,20 +752,21 @@ void Hook()
Bool = false; Bool = false;
#ifdef _WIN64 #ifdef _WIN64
SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "DefPolicyOffset.x64", 0)); SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "DefPolicyOffset.x64", 0));
Bool = IniFile->GetVariableInSection(Sect, "DefPolicyCode.x64", &Patch); // [!] returns patch name, not the patch itself Bool = IniFile->GetVariableInSection(Sect, "DefPolicyCode.x64", &PatchName);
#else #else
SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "DefPolicyOffset.x86", 0)); SignPtr = (PLATFORM_DWORD)(TermSrvBase + INIReadDWordHex(IniFile, Sect, "DefPolicyOffset.x86", 0));
Bool = IniFile->GetVariableInSection(Sect, "DefPolicyCode.x86", &Patch); // [!] returns patch name, not the patch itself Bool = IniFile->GetVariableInSection(Sect, "DefPolicyCode.x86", &PatchName);
#endif #endif
if (Bool) Bool = IniFile->GetVariableInSection("PatchCodes", PatchName.Value, &Patch);
// Patch.Value is char // Patch.Value is char
// WriteProcessMemory uses LPCVOID lpBuffer, so... // WriteProcessMemory uses LPCVOID lpBuffer, so...
// maybe &Patch.Value ? // maybe &Patch.Value ?
if (Bool && (SignPtr > TermSrvBase)) WriteProcessMemory(GetCurrentProcess(), (LPVOID)SignPtr, Patch.Value, Patch.ArraySize, &bw); if (Bool && (SignPtr > TermSrvBase)) WriteProcessMemory(GetCurrentProcess(), (LPVOID)SignPtr, Patch.Value, Patch.ArraySize, &bw);
} }
#ifdef _WIN64 #ifdef _WIN64
if (!(IniFile->GetVariableInSection(Sect, "SLPolicyInternal.x64", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "SLPolicyInternal.x64", &Bool))) Bool = false;
#else #else
if (!(IniFile->GetVariableInSection(Sect, "SLPolicyInternal.x86", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "SLPolicyInternal.x86", &Bool))) Bool = false;
#endif #endif
if (Bool) if (Bool)
{ {
@ -813,9 +808,9 @@ void Hook()
if (SignPtr > TermSrvBase) WriteProcessMemory(GetCurrentProcess(), (LPVOID)SignPtr, &Jump, sizeof(FARJMP), &bw); if (SignPtr > TermSrvBase) WriteProcessMemory(GetCurrentProcess(), (LPVOID)SignPtr, &Jump, sizeof(FARJMP), &bw);
} }
#ifdef _WIN64 #ifdef _WIN64
if (!(IniFile->GetVariableInSection(Sect, "SLInitHook.x64", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "SLInitHook.x64", &Bool))) Bool = false;
#else #else
if (!(IniFile->GetVariableInSection(Sect, "SLInitHook.x86", &Bool))) Bool = true; if (!(IniFile->GetVariableInSection(Sect, "SLInitHook.x86", &Bool))) Bool = false;
#endif #endif
if (Bool) if (Bool)
{ {