Add Linux compatibility
This commit is contained in:
parent
35aff4f60c
commit
6459c56f25
@ -19,9 +19,9 @@ namespace patcher::Solution0 {
|
|||||||
static const DWORD KeywordLength = sizeof(Keyword) - 1;
|
static const DWORD KeywordLength = sizeof(Keyword) - 1;
|
||||||
|
|
||||||
static LPCTSTR PossibleName[3] = {
|
static LPCTSTR PossibleName[3] = {
|
||||||
TEXT("navicat.exe"),
|
TEXT("Navicat.exe"), // for Linux compatible, main program name is "Navicat.exe" in Linux, case sensitive
|
||||||
TEXT("modeler.exe"),
|
TEXT("Modeler.exe"), // for Linux compatible
|
||||||
TEXT("rviewer.exe")
|
TEXT("Rviewer.exe") // for Linux compatible
|
||||||
};
|
};
|
||||||
|
|
||||||
static LPCTSTR TargetName = NULL;
|
static LPCTSTR TargetName = NULL;
|
||||||
@ -49,7 +49,7 @@ namespace patcher::Solution0 {
|
|||||||
|
|
||||||
InstallationPath = Path;
|
InstallationPath = Path;
|
||||||
if (InstallationPath.back() != TEXT('\\') && InstallationPath.back() != TEXT('/'))
|
if (InstallationPath.back() != TEXT('\\') && InstallationPath.back() != TEXT('/'))
|
||||||
InstallationPath.push_back(TEXT('\\'));
|
InstallationPath.push_back(TEXT('/')); // for Linux compatible
|
||||||
|
|
||||||
bSuccess = TRUE;
|
bSuccess = TRUE;
|
||||||
|
|
||||||
@ -225,6 +225,57 @@ namespace patcher::Solution0 {
|
|||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL GetVersion(LPDWORD lpMajorVer, LPDWORD lpMinorVer) {
|
||||||
|
BOOL bSuccess = FALSE;
|
||||||
|
DWORD dwLastError = ERROR_SUCCESS;
|
||||||
|
std::Tstring&& TargetFileName = InstallationPath + TargetName;
|
||||||
|
DWORD dwSize = 0;
|
||||||
|
PVOID lpData = NULL;
|
||||||
|
VS_FIXEDFILEINFO* lpVersionInfo = NULL;
|
||||||
|
UINT VersionInfoSize = 0;
|
||||||
|
|
||||||
|
dwSize = GetFileVersionInfoSize(TargetFileName.c_str(),
|
||||||
|
&dwSize); // MSDN doesn't say it can be NULL.
|
||||||
|
// so I use dwSize to receive this deprecated value
|
||||||
|
if (dwSize == 0) {
|
||||||
|
dwLastError = GetLastError();
|
||||||
|
_tprintf_s(TEXT("@%s LINE: %u\n"), TEXT(__FUNCTION__), __LINE__);
|
||||||
|
_tprintf_s(TEXT("Failed @ GetFileVersionInfoSize. CODE: 0x%08X\n"), dwLastError);
|
||||||
|
goto ON_GetVersion_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
lpData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
|
||||||
|
if (lpData == NULL) {
|
||||||
|
dwLastError = GetLastError();
|
||||||
|
_tprintf_s(TEXT("@%s LINE: %u\n"), TEXT(__FUNCTION__), __LINE__);
|
||||||
|
_tprintf_s(TEXT("Failed @ HeapAlloc. CODE: 0x%08X\n"), dwLastError);
|
||||||
|
goto ON_GetVersion_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GetFileVersionInfo(TargetFileName.c_str(), NULL, dwSize, lpData)) {
|
||||||
|
dwLastError = GetLastError();
|
||||||
|
_tprintf_s(TEXT("@%s LINE: %u\n"), TEXT(__FUNCTION__), __LINE__);
|
||||||
|
_tprintf_s(TEXT("Failed @ GetFileVersionInfo. CODE: 0x%08X\n"), dwLastError);
|
||||||
|
goto ON_GetVersion_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!VerQueryValue(lpData, TEXT("\\"), (LPVOID*)&lpVersionInfo, &VersionInfoSize)) {
|
||||||
|
dwLastError = GetLastError();
|
||||||
|
_tprintf_s(TEXT("@%s LINE: %u\n"), TEXT(__FUNCTION__), __LINE__);
|
||||||
|
_tprintf_s(TEXT("Failed @ VerQueryValue. CODE: 0x%08X\n"), dwLastError);
|
||||||
|
goto ON_GetVersion_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*lpMajorVer = lpVersionInfo->dwProductVersionMS;
|
||||||
|
*lpMinorVer = lpVersionInfo->dwProductVersionLS;
|
||||||
|
bSuccess = TRUE;
|
||||||
|
|
||||||
|
ON_GetVersion_ERROR:
|
||||||
|
if (lpData)
|
||||||
|
HeapFree(GetProcessHeap(), NULL, lpData);
|
||||||
|
return bSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
VOID Finalize() {
|
VOID Finalize() {
|
||||||
if (hTarget) {
|
if (hTarget) {
|
||||||
FreeLibrary(hTarget);
|
FreeLibrary(hTarget);
|
||||||
|
|||||||
@ -87,7 +87,7 @@ namespace patcher::Solution1 {
|
|||||||
|
|
||||||
InstallationPath = Path;
|
InstallationPath = Path;
|
||||||
if (InstallationPath.back() != TEXT('\\') && InstallationPath.back() != TEXT('/'))
|
if (InstallationPath.back() != TEXT('\\') && InstallationPath.back() != TEXT('/'))
|
||||||
InstallationPath.push_back(TEXT('\\'));
|
InstallationPath.push_back(TEXT('/')); // for Linux compatible
|
||||||
|
|
||||||
bSuccess = TRUE;
|
bSuccess = TRUE;
|
||||||
|
|
||||||
|
|||||||
@ -78,6 +78,8 @@ int _tmain(int argc, TCHAR* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RSACipher* cipher = NULL;
|
RSACipher* cipher = NULL;
|
||||||
|
DWORD dwMajorVer = 0;
|
||||||
|
DWORD dwMinorVer = 0;
|
||||||
|
|
||||||
cipher = RSACipher::Create();
|
cipher = RSACipher::Create();
|
||||||
if (cipher == NULL) {
|
if (cipher == NULL) {
|
||||||
@ -128,6 +130,9 @@ int _tmain(int argc, TCHAR* argv[]) {
|
|||||||
goto ON_tmain_ERROR;
|
goto ON_tmain_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!patcher::Solution0::GetVersion(&dwMajorVer, &dwMinorVer))
|
||||||
|
goto ON_tmain_ERROR;
|
||||||
|
|
||||||
if (!patcher::Solution0::CheckFile())
|
if (!patcher::Solution0::CheckFile())
|
||||||
goto ON_tmain_ERROR;
|
goto ON_tmain_ERROR;
|
||||||
|
|
||||||
@ -140,11 +145,18 @@ int _tmain(int argc, TCHAR* argv[]) {
|
|||||||
_tprintf_s(TEXT("Solution0 has been done successfully.\n"));
|
_tprintf_s(TEXT("Solution0 has been done successfully.\n"));
|
||||||
_tprintf_s(TEXT("\n"));
|
_tprintf_s(TEXT("\n"));
|
||||||
|
|
||||||
|
// for ver <= 12.0.24
|
||||||
|
if (dwMajorVer == 0x000c0000 && dwMinorVer < 0x00180000)
|
||||||
|
goto ON_tmain_ERROR; // you don't need Solution1 patch.
|
||||||
|
|
||||||
// ------------------
|
// ------------------
|
||||||
// begin Solution1
|
// begin Solution1
|
||||||
// ------------------
|
// ------------------
|
||||||
if (!patcher::Solution1::FindTargetFile())
|
if (!patcher::Solution1::FindTargetFile()) {
|
||||||
|
_tprintf_s(TEXT("@%s LINE: %u\n"), TEXT(__FUNCTION__), __LINE__);
|
||||||
|
_tprintf_s(TEXT("ERROR: Cannot find libcc.dll. Are you sure the path you specified is correct?\n"));
|
||||||
goto ON_tmain_ERROR;
|
goto ON_tmain_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (!patcher::Solution1::FindOffset())
|
if (!patcher::Solution1::FindOffset())
|
||||||
goto ON_tmain_ERROR;
|
goto ON_tmain_ERROR;
|
||||||
|
|||||||
@ -25,6 +25,7 @@ namespace patcher {
|
|||||||
BOOL CheckFile();
|
BOOL CheckFile();
|
||||||
BOOL BackupFile();
|
BOOL BackupFile();
|
||||||
BOOL Do(RSACipher* cipher);
|
BOOL Do(RSACipher* cipher);
|
||||||
|
BOOL GetVersion(LPDWORD lpMajorVer, LPDWORD lpMinorVer);
|
||||||
VOID Finalize();
|
VOID Finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user