That epic commit

Seems to work well 👍
This commit is contained in:
binarymaster 2014-12-10 19:11:36 +03:00
parent 239cd5fe3f
commit 939a884f20
2 changed files with 23 additions and 20 deletions

View File

@ -24,7 +24,7 @@ INI_FILE::INI_FILE(wchar_t *FilePath)
DWORD Status = 0; DWORD Status = 0;
DWORD NumberOfBytesRead = 0; DWORD NumberOfBytesRead = 0;
HANDLE hFile = CreateFile(FilePath, GENERIC_ALL, FILE_SHARE_READ | FILE_SHARE_WRITE, HANDLE hFile = CreateFile(FilePath, GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) if (hFile == INVALID_HANDLE_VALUE)
@ -376,7 +376,7 @@ bool INI_FILE::GetVariableInSection(char *SectionName, char *VariableName, INI_V
if (ValueLen > 32) ValueLen = 32; // 32 hex digits if (ValueLen > 32) ValueLen = 32; // 32 hex digits
memset(RetVariable, 0x00, sizeof(*RetVariable)); memset(RetVariable, 0x00, sizeof(*RetVariable));
memcpy(RetVariable->Name, Variable.VariableName, ValueLen); memcpy(RetVariable->Name, Variable.VariableName, strlen(Variable.VariableName));
for (DWORD i = 0; i <= ValueLen; i++) for (DWORD i = 0; i <= ValueLen; i++)
{ {

View File

@ -16,6 +16,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "IniFile.h" #include "IniFile.h"
#include <stdlib.h>
typedef struct typedef struct
{ {
@ -520,6 +521,7 @@ void Hook()
IniFile = new INI_FILE(ConfigFile); IniFile = new INI_FILE(ConfigFile);
// TODO: implement this
if (IniFile == NULL) if (IniFile == NULL)
{ {
WriteToLog("Error: Failed to load configuration\r\n"); WriteToLog("Error: Failed to load configuration\r\n");
@ -541,12 +543,14 @@ void Hook()
} }
} }
} }
else memcpy((void*)LogFile, LogFileVar.Value, strlen(LogFileVar.Value)); else
{
Log = new char[1024]; // TODO: Change it before add UNICODE in IniFile
wsprintfA(Log, "Log file: %S\r\n", LogFile); wchar_t wcLogFile[256];
WriteToLog(Log); memset(wcLogFile, 0x00, 256);
delete[] Log; mbstowcs(wcLogFile, LogFileVar.Value, 255);
wcscpy(LogFile, wcLogFile);
}
SIZE_T bw; SIZE_T bw;
WORD Ver = 0; WORD Ver = 0;
@ -603,10 +607,10 @@ void Hook()
WriteToLog("freeze\r\n"); WriteToLog("freeze\r\n");
SetThreadsState(false); SetThreadsState(false);
bool bSLHook; bool Bool;
if (!(IniFile->GetVariableInSection("Main", "SLPolicyHookNT60", &bSLHook))) bSLHook = true; if (!(IniFile->GetVariableInSection("Main", "SLPolicyHookNT60", &Bool))) Bool = true;
if ((Ver == 0x0600) && bSLHook) if ((Ver == 0x0600) && Bool)
{ {
// Windows Vista // Windows Vista
// uses SL Policy API (slc.dll) // uses SL Policy API (slc.dll)
@ -636,9 +640,9 @@ void Hook()
} }
} }
if (!(IniFile->GetVariableInSection("Main", "SLPolicyHookNT61", &bSLHook))) bSLHook = true; if (!(IniFile->GetVariableInSection("Main", "SLPolicyHookNT61", &Bool))) Bool = true;
if ((Ver == 0x0601) && bSLHook) if ((Ver == 0x0601) && Bool)
{ {
// Windows 7 // Windows 7
// uses SL Policy API (slc.dll) // uses SL Policy API (slc.dll)
@ -699,7 +703,6 @@ void Hook()
{ {
if (GetModuleCodeSectionInfo(hTermSrv, &TermSrvBase, &TermSrvSize)) if (GetModuleCodeSectionInfo(hTermSrv, &TermSrvBase, &TermSrvSize))
{ {
bool Bool;
#ifdef _WIN64 #ifdef _WIN64
if (!(IniFile->GetVariableInSection(Sect, "LocalOnlyPatch.x64", &Bool))) Bool = false; if (!(IniFile->GetVariableInSection(Sect, "LocalOnlyPatch.x64", &Bool))) Bool = false;
#else #else