Skip to content

Commit

Permalink
Merge pull request #73 from matanki-saito/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
matanki-saito authored Jan 9, 2019
2 parents 5996bed + 96607dd commit 9735dcd
Show file tree
Hide file tree
Showing 13 changed files with 159 additions and 16 deletions.
13 changes: 7 additions & 6 deletions Plugin/MainTextLineBreak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,15 +553,15 @@ namespace MainTextLineBreak {

//左側のブロックの開始位置
// push offset asc_XXXXXX
byte_pattern::temp_instance().find_pattern("68 ? ? ? ? 8D 4D C0 E8 71 24 07 00");
byte_pattern::temp_instance().find_pattern("68 ? ? ? ? 8D ? ? ? ? 24 07 00");
if (byte_pattern::temp_instance().has_size(1, desc)) {
ee_2_v301 = byte_pattern::temp_instance().get_first().address();
}
else return CK2ERROR1;

//右側のブロックの開始位置
// push offset asc_XXXXXX
byte_pattern::temp_instance().find_pattern("68 ? ? ? ? 8D 4D C0 E8 DA 23 07 00");
byte_pattern::temp_instance().find_pattern("68 ? ? ? ? 8D ? ? ? ? 23 07 00");
if (byte_pattern::temp_instance().has_size(1, desc)) {
ee_3_v301 = byte_pattern::temp_instance().get_first().address();
}
Expand Down Expand Up @@ -667,11 +667,12 @@ namespace MainTextLineBreak {
return NOERROR;

case v3_0_X:
// lea ecx,[ebp+var_88]
byte_pattern::temp_instance().find_pattern("8D 8D 78 FF FF FF E8 60 C5 62 FF");
// mov eax, [ebp+arg_10]
byte_pattern::temp_instance().find_pattern("8B 45 18 8B CE 8A 55 20 89 4D E4");
if (byte_pattern::temp_instance().has_size(1, desc)) {
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(), x_1_v301);
x_2_v301 = byte_pattern::temp_instance().get_first().address(0xB);
// lea ecx,[ebp+var_88]
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(-0x22), x_1_v301);
x_2_v301 = byte_pattern::temp_instance().get_first().address(0xB - 0x22);
}
else return CK2ERROR1;
return NOERROR;
Expand Down
10 changes: 5 additions & 5 deletions Plugin/NickNameFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ namespace NickNameFix
else return CK2ERROR1;
return NOERROR;
case v3_0_X:
// lea ecx,[ebp+var_DC]
byte_pattern::temp_instance().find_pattern("8D 8D 24 FF FF FF E8 F1 8A EF FF");
// mov ecx, [edi+7Ch]
byte_pattern::temp_instance().find_pattern("8B 75 08 C6 45 FC 19 8B 4F 7C");
if (byte_pattern::temp_instance().has_size(1, desc)) {
// lea eax,[ebp+var_C4]
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(-0x59), start);

issue_14_end_R_v30 = byte_pattern::temp_instance().get_first().address();
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(-0x4A), start);
// lea ecx,[ebp+var_DC]
issue_14_end_R_v30 = byte_pattern::temp_instance().get_first().address(0xF);
}
else return CK2ERROR1;
return NOERROR;
Expand Down
2 changes: 1 addition & 1 deletion Plugin/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ BOOL WINAPI DllMain(HMODULE module, DWORD reason, void *reserved)
byte_pattern::debug_output2("Multibyte DLL [OK]");
}
else {
MessageBoxW(NULL, L"[Multibyte DLL ERROR]\n\nYour current version is 3.0.1.1 is not supported by now.\n\nThe latest supprot version is 3.0.1, please rollback your main exe.\n\Or play game in english after delete d3d9.dll...\n\n Thanks", L"Multibyte DLL", MB_OK);
MessageBoxW(NULL, L"[Multibyte DLL ERROR]\n\nThe latest supprot version is 3.0.1.1, please rollback your main exe.\n\Or play game in english after delete d3d9.dll...\n\n Thanks", L"Multibyte DLL", MB_OK);
byte_pattern::debug_output2("Multibyte DLL [NG]");
exit(-1);
}
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ This dll makes it possible to display double-byte characters on Crusader Kings I
## Find bugs
If you find a bug, **create a issue** in this repository.
If possible, please write the issue report in English. However you can also create it in your language (Japanese, Korean, Chinese, Russian etc).

## Autoupdate
Plugin.dll will be updated automatically. It requires an Internet connection at game run. If you do not need or play offline game, please DELETE "plugins/autoupdate.bat" file.

## Licence
MIT Licence
Expand All @@ -23,5 +26,5 @@ This dll was forked by the following project. Thank you so much.

[EU4CHS](https://bitbucket.org/kelashi/eu4chs/src/master/)

## ini
ini
## plugin.ini
TBD
4 changes: 4 additions & 0 deletions d3d9/d3d9.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="filedl.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="filedl.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
Expand Down
8 changes: 8 additions & 0 deletions d3d9/d3d9.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="filedl.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="filedl.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
11 changes: 9 additions & 2 deletions d3d9/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <Objbase.h>
#pragma comment(lib, "Ole32.lib")

#include "filedl.h"

using namespace std;
using namespace std::experimental::filesystem::v1;

Expand Down Expand Up @@ -58,10 +60,15 @@ void Initialize(HMODULE hSelf)
{
wchar_t pluginpath[MAX_PATH];

GetModuleFileNameW(hSelf, pluginpath, MAX_PATH);
GetModuleFileNameW(hSelf, pluginpath, MAX_PATH);

const path pluginsPath = path{ pluginpath }.parent_path() / L"plugins";

if (!InitAutoUpdate(pluginsPath)) exit(-1);

InitD3D9();
LoadScripts(path{ pluginpath }.parent_path() / L"plugins");

LoadScripts(pluginsPath);
}

BOOL WINAPI DllMain(HMODULE module, DWORD reason, LPVOID reserved)
Expand Down
55 changes: 55 additions & 0 deletions d3d9/filedl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "filedl.h"

bool createProcess(WCHAR* szCmd, DWORD flag) {
STARTUPINFO si;
PROCESS_INFORMATION pi;
WCHAR *message = L"Autoupdate error. Please DELETE 'plugins/autoupdate.bat'.";
WCHAR *title = NULL;

memset(&si, 0, sizeof(STARTUPINFO));
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
si.cb = sizeof(STARTUPINFO);

BOOL createProcessSuccess = CreateProcess(NULL, szCmd, NULL, NULL, FALSE, flag, NULL, NULL, &si, &pi);

if (!createProcessSuccess) {
title = L"Autoupdate createProcess failed.";
}
else {
DWORD result = WaitForSingleObject(pi.hProcess, 10 * 1000); // 10 sec
switch (result)
{
case WAIT_FAILED:
title = L"Autoupdate wait failed.";
break;
case WAIT_TIMEOUT:
title = L"Autoupdate wait timeout.";
break;
default:
break;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

if (title != NULL) {
MessageBox(NULL, message, title, MB_OK);
return false;
}
}

return true;
}

bool InitAutoUpdate(const path &pluginsPath)
{
path batFilePath = path{ pluginsPath } / L"autoupdate.bat";

if (std::experimental::filesystem::exists(batFilePath)) {
return createProcess(
wcsdup(batFilePath.c_str()),
CREATE_NO_WINDOW
);
}

return true;
}
11 changes: 11 additions & 0 deletions d3d9/filedl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include <windows.h>
#include <conio.h>
#include <stdio.h>
#include <filesystem>

using namespace std;
using namespace std::experimental::filesystem::v1;

bool InitAutoUpdate(const path &folder);
25 changes: 25 additions & 0 deletions other/autoupdate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cd /d %~dp0

SET pluginMD5=
SET exeMD5=

rem https://stackoverflow.com/questions/38771114/saving-result-of-certutil-hashfile-to-a-variable-and-remove-spaces-of-the-hash

setlocal enabledelayedexpansion
set /a count=1
for /f "skip=1 delims=:" %%a in ('CertUtil -hashfile ./plugin.dll MD5') do (
if !count! equ 1 set "pluginMD5=%%a"
set/a count+=1
)
set "pluginMD5=%pluginMD5: =%
set /a count=1
for /f "skip=1 delims=:" %%a in ('CertUtil -hashfile ../ck2game.exe MD5') do (
if !count! equ 1 set "exeMD5=%%a"
set/a count+=1
)
set "exeMD5=%exeMD5: =%
set url=https://d3mq2c18xv0s3o.cloudfront.net/api/v1/distribution/139275487/%exeMD5%?dll_md5=%pluginMD5%
call "curl.exe" -k -f --connect-timeout 3 -m 6 -s -o "Plugin.dll" %url%
29 changes: 29 additions & 0 deletions other/autoupdate_test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cd /d %~dp0

SET pluginMD5=
SET exeMD5=

rem https://stackoverflow.com/questions/38771114/saving-result-of-certutil-hashfile-to-a-variable-and-remove-spaces-of-the-hash

setlocal enabledelayedexpansion
set /a count=1
for /f "skip=1 delims=:" %%a in ('CertUtil -hashfile ./plugin.dll MD5') do (
if !count! equ 1 set "pluginMD5=%%a"
set/a count+=1
)
set "pluginMD5=%pluginMD5: =%
set /a count=1
for /f "skip=1 delims=:" %%a in ('CertUtil -hashfile ../ck2game.exe MD5') do (
if !count! equ 1 set "exeMD5=%%a"
set/a count+=1
)
set "exeMD5=%exeMD5: =%
set url=https://d3mq2c18xv0s3o.cloudfront.net/api/v1/distribution/139275487/%exeMD5%?dll_md5=%pluginMD5%
echo %url%
call "curl.exe" -f -k -v --connect-timeout 3 -m 6 -o "Plugin.dll" %url%

pause
Binary file added other/curl.exe
Binary file not shown.
File renamed without changes.

0 comments on commit 9735dcd

Please sign in to comment.