3 Commits
Author SHA1 Message Date
Double Sine aa27171558 Add support for 12.0.28 and deprecate version judgement 2018-05-11 23:14:00 +08:00
Double Sine 432e647fe1 Add support for 12.0.27 2018-04-26 15:51:26 +08:00
Double Sine 618190dde3 Fix bug 2018-03-31 15:49:25 +08:00
6 changed files with 39 additions and 31 deletions
+2 -2
View File
@@ -22,8 +22,8 @@
#else
#pragma comment(lib, "libcryptoMT.lib")
#endif
#pragma comment(lib, "WS2_32.lib") // some symbol are used in OpenSSL lib
#pragma comment(lib, "Crypt32.lib") // some symbol are used in OpenSSL lib
#pragma comment(lib, "WS2_32.lib") // some symbol are used in OpenSSL static lib
#pragma comment(lib, "Crypt32.lib") // some symbol are used in OpenSSL static lib
#define NAVICAT_12
+4 -4
View File
@@ -28,26 +28,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
+21 -16
View File
@@ -339,26 +339,31 @@ namespace patcher::Solution1 {
_tprintf_s(TEXT("Failed to open libcc.dll. CODE: 0x%08x @[patcher::Solution1::Do -> CreateFile]\r\n"), GetLastError());
return FALSE;
}
// Start from win8, lpNumberOfBytesWritten parameter in WriteFile can be null if lpOverlapped is null.
// But win7 is not. lpNumberOfBytesWritten cannot be null if lpOverlapped is null.
// However MSDN does not mention that.
DWORD WrittenBytes;
// start patch 0
_tprintf_s(TEXT("----------Start to do patch 0----------\r\n"));
_tprintf_s(TEXT("\r\nStart to do patch 0......\r\n"));
if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, Patch_Offset[0], nullptr, FILE_BEGIN)) {
_tprintf_s(TEXT("Failed to set file pointer. CODE: 0x%08x @[patcher::Solution1::Do -> SetFilePointer]\r\n"), GetLastError());
CloseHandle(hFile);
return FALSE;
}
_tprintf_s(TEXT("At offset +0x%08x, write:\r\n\"%hs\"\r\n"), Patch_Offset[0], encrypted_pem_pubkey0.c_str());
if (FALSE == WriteFile(hFile, encrypted_pem_pubkey0.c_str(), encrypted_pem_pubkey0.length(), nullptr, nullptr)) {
if (FALSE == WriteFile(hFile, encrypted_pem_pubkey0.c_str(), encrypted_pem_pubkey0.length(), &WrittenBytes, nullptr)) {
_tprintf_s(TEXT("Failed to write patch 0. CODE: 0x%08x @[patcher::Solution1::Do -> WriteFile]\r\n"), GetLastError());
CloseHandle(hFile);
return FALSE;
}
_tprintf_s(TEXT("----------patch 0 done----------\r\n"));
_tprintf_s(TEXT("patch 0 done.....\r\n"));
// start patch 1
_tprintf_s(TEXT("----------Start to do patch 1----------\r\n"));
_tprintf_s(TEXT("\r\nStart to do patch 1.....\r\n"));
if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, Patch_Offset[1], nullptr, FILE_BEGIN)) {
_tprintf_s(TEXT("Failed to set file pointer. CODE: 0x%08x @[patcher::Solution1::Do -> SetFilePointer]\r\n"), GetLastError());
CloseHandle(hFile);
@@ -366,16 +371,16 @@ namespace patcher::Solution1 {
}
_tprintf_s(TEXT("At offset +0x%08x, write immediate value %d (type: uint32_t)\r\n"), Patch_Offset[1], imm1);
if (FALSE == WriteFile(hFile, &imm1, sizeof(imm1), nullptr, nullptr)) {
if (FALSE == WriteFile(hFile, &imm1, sizeof(imm1), &WrittenBytes, nullptr)) {
_tprintf_s(TEXT("Failed to write patch 1. CODE: 0x%08x @[patcher::Solution1::Do -> WriteFile]\r\n"), GetLastError());
CloseHandle(hFile);
return FALSE;
}
_tprintf_s(TEXT("----------patch 1 done----------\r\n"));
_tprintf_s(TEXT("patch 1 done.....\r\n"));
// start patch 2
_tprintf_s(TEXT("----------Start to do patch 2----------\r\n"));
_tprintf_s(TEXT("\r\nStart to do patch 2.....\r\n"));
if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, Patch_Offset[2], nullptr, FILE_BEGIN)) {
_tprintf_s(TEXT("Failed to set file pointer. CODE: 0x%08x @[patcher::Solution1::Do -> SetFilePointer]\r\n"), GetLastError());
CloseHandle(hFile);
@@ -383,16 +388,16 @@ namespace patcher::Solution1 {
}
_tprintf_s(TEXT("At offset +0x%08x, write:\r\n\"%hs\"\r\n"), Patch_Offset[2], encrypted_pem_pubkey2.c_str());
if (FALSE == WriteFile(hFile, encrypted_pem_pubkey2.c_str(), encrypted_pem_pubkey2.length(), nullptr, nullptr)) {
if (FALSE == WriteFile(hFile, encrypted_pem_pubkey2.c_str(), encrypted_pem_pubkey2.length(), &WrittenBytes, nullptr)) {
_tprintf_s(TEXT("Failed to write patch 2. CODE: 0x%08x @[patcher::Solution1::Do -> WriteFile]\r\n"), GetLastError());
CloseHandle(hFile);
return FALSE;
}
_tprintf_s(TEXT("----------patch 2 done----------\r\n"));
_tprintf_s(TEXT("patch 2 done.....\r\n"));
// start patch 3
_tprintf_s(TEXT("----------Start to do patch 3----------\r\n"));
_tprintf_s(TEXT("\r\nStart to do patch 3.....\r\n"));
if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, Patch_Offset[3], nullptr, FILE_BEGIN)) {
_tprintf_s(TEXT("Failed to set file pointer. CODE: 0x%08x @[patcher::Solution1::Do -> SetFilePointer]\r\n"), GetLastError());
CloseHandle(hFile);
@@ -400,16 +405,16 @@ namespace patcher::Solution1 {
}
_tprintf_s(TEXT("At offset +0x%08x, write immediate value %d (type: uint32_t)\r\n"), Patch_Offset[3], imm3);
if (FALSE == WriteFile(hFile, &imm3, sizeof(imm3), nullptr, nullptr)) {
if (FALSE == WriteFile(hFile, &imm3, sizeof(imm3), &WrittenBytes, nullptr)) {
_tprintf_s(TEXT("Failed to write patch 3. CODE: 0x%08x @[patcher::Solution1::Do -> WriteFile]\r\n"), GetLastError());
CloseHandle(hFile);
return FALSE;
}
_tprintf_s(TEXT("----------patch 3 done----------\r\n"));
_tprintf_s(TEXT("patch 3 done.....\r\n"));
// start patch 4
_tprintf_s(TEXT("----------Start to do patch 4----------\r\n"));
_tprintf_s(TEXT("\r\nStart to do patch 4.....\r\n"));
if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, Patch_Offset[4], nullptr, FILE_BEGIN)) {
_tprintf_s(TEXT("Failed to set file pointer. CODE: 0x%08x @[patcher::Solution1::Do -> SetFilePointer]\r\n"), GetLastError());
CloseHandle(hFile);
@@ -417,13 +422,13 @@ namespace patcher::Solution1 {
}
_tprintf_s(TEXT("At offset +0x%08x, write:\r\n\"%hs\"\r\n"), Patch_Offset[4], encrypted_pem_pubkey4.c_str());
if (FALSE == WriteFile(hFile, encrypted_pem_pubkey4.c_str(), encrypted_pem_pubkey4.length(), nullptr, nullptr)) {
if (FALSE == WriteFile(hFile, encrypted_pem_pubkey4.c_str(), encrypted_pem_pubkey4.length(), &WrittenBytes, nullptr)) {
_tprintf_s(TEXT("Failed to write patch 4. CODE: 0x%08x @[patcher::Solution1::Do -> WriteFile]\r\n"), GetLastError());
CloseHandle(hFile);
return FALSE;
}
_tprintf_s(TEXT("----------patch 4 done----------\r\n"));
_tprintf_s(TEXT("patch 4 done.....\r\n\r\n"));
return TRUE;
}
+6 -3
View File
@@ -46,10 +46,13 @@ int _tmain(int argc, TCHAR* argv[]) {
BOOL status;
if (NavicatMajorVersion <= 0x000C0000 && NavicatMinorVersion < 0x00190000) { // for navicat ver < 12.0.25
status = patcher::Solution0::Do(navicat_exe_path.c_str());
} else if (NavicatMajorVersion == 0x000C0000 && NavicatMinorVersion == 0x00190000) { // for navicat ver = 12.0.25
status = patcher::Solution1::Do(libcc_dll_path.c_str(), argc == 3 ? argv[2] : nullptr);
} else if (NavicatMajorVersion == 0x000C0000 && NavicatMinorVersion == 0x001A0000) { // for navicat ver = 12.0.26
} else if (NavicatMajorVersion == 0x000C0000 && NavicatMinorVersion <= 0x001C0000) { // for navicat ver <= 12.0.28
status = patcher::Solution1::Do(libcc_dll_path.c_str(), argc == 3 ? argv[2] : nullptr);
} else {
_tprintf_s(TEXT("Warning: Unknown version detected, still continue? [y/n] "));
TCHAR selection = _gettchar();
if (selection == 'Y' || selection == 'y')
status = patcher::Solution1::Do(libcc_dll_path.c_str(), argc == 3 ? argv[2] : nullptr);
}
_tprintf_s(TEXT("%s\r\n"), status == TRUE ? TEXT("Success!") : TEXT("Failed!"));
+2 -2
View File
@@ -19,8 +19,8 @@
#else
#pragma comment(lib, "libcryptoMT.lib")
#endif
#pragma comment(lib, "WS2_32.lib") // some symbol are used in OpenSSL lib
#pragma comment(lib, "Crypt32.lib") // some symbol are used in OpenSSL lib
#pragma comment(lib, "WS2_32.lib") // some symbol are used in OpenSSL static lib
#pragma comment(lib, "Crypt32.lib") // some symbol are used in OpenSSL static lib
#pragma comment(lib, "version.lib") // GetFileVersionInfoSize, GetFileVersionInfo, VerQueryValue are in this lib
namespace patcher {
+4 -4
View File
@@ -28,26 +28,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>