• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision9325 (tree)
Time2021-06-30 00:20:36
Authorzmatsuo

Log Message

layer for unicode をライブラリに分離

- Windows 9xをサポートするためのパートをライブラリとして切り出し

- MSUL(unicows.lib)と同様に、ライブラリをリンクするだけで 9x をサポート
- Tera Term のソース(layer for unicode 以外の部分)では 9x を気にする必要がなくなった

- vs2005 のプロジェクトを調整
- CMakeLists.txt 調整

- VS2005 を使用しないと 95での起動はできない
- しかしVS2005をサポートしている cmake のバージョンが古い

Change Summary

Incremental Difference

--- trunk/TTXKanjiMenu/CMakeLists.txt (revision 9324)
+++ trunk/TTXKanjiMenu/CMakeLists.txt (revision 9325)
@@ -10,6 +10,11 @@
1010 )
1111
1212 if(SUPPORT_OLD_WINDOWS)
13+ target_link_libraries(
14+ ${PACKAGE_NAME}
15+ PRIVATE
16+ layer_for_unicode
17+ )
1318 if(MSVC)
1419 target_sources(
1520 ${PACKAGE_NAME}
--- trunk/TTXSamples/TTXAdditionalTitle/CMakeLists.txt (revision 9324)
+++ trunk/TTXSamples/TTXAdditionalTitle/CMakeLists.txt (revision 9325)
@@ -10,6 +10,11 @@
1010 )
1111
1212 if(SUPPORT_OLD_WINDOWS)
13+ target_link_libraries(
14+ ${PACKAGE_NAME}
15+ PRIVATE
16+ layer_for_unicode
17+ )
1318 if(MSVC)
1419 target_sources(
1520 ${PACKAGE_NAME}
--- trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt (revision 9324)
+++ trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt (revision 9325)
@@ -10,6 +10,11 @@
1010 )
1111
1212 if(SUPPORT_OLD_WINDOWS)
13+ target_link_libraries(
14+ ${PACKAGE_NAME}
15+ PRIVATE
16+ common_static
17+ )
1318 if(MSVC)
1419 target_sources(
1520 ${PACKAGE_NAME}
--- trunk/TTXSamples/TTXCallSysMenu/CMakeLists.txt (revision 9324)
+++ trunk/TTXSamples/TTXCallSysMenu/CMakeLists.txt (revision 9325)
@@ -10,6 +10,11 @@
1010 )
1111
1212 if(SUPPORT_OLD_WINDOWS)
13+ target_link_libraries(
14+ ${PACKAGE_NAME}
15+ PRIVATE
16+ layer_for_unicode
17+ )
1318 if(MSVC)
1419 target_sources(
1520 ${PACKAGE_NAME}
--- trunk/TTXSamples/TTXFixedWinSize/CMakeLists.txt (revision 9324)
+++ trunk/TTXSamples/TTXFixedWinSize/CMakeLists.txt (revision 9325)
@@ -10,6 +10,11 @@
1010 )
1111
1212 if(SUPPORT_OLD_WINDOWS)
13+ target_link_libraries(
14+ ${PACKAGE_NAME}
15+ PRIVATE
16+ layer_for_unicode
17+ )
1318 if(MSVC)
1419 target_sources(
1520 ${PACKAGE_NAME}
--- trunk/TTXSamples/TTXResizeMenu/CMakeLists.txt (revision 9324)
+++ trunk/TTXSamples/TTXResizeMenu/CMakeLists.txt (revision 9325)
@@ -10,6 +10,11 @@
1010 )
1111
1212 if(SUPPORT_OLD_WINDOWS)
13+ target_link_libraries(
14+ ${PACKAGE_NAME}
15+ PRIVATE
16+ layer_for_unicode
17+ )
1318 if(MSVC)
1419 target_sources(
1520 ${PACKAGE_NAME}
--- trunk/TTXSamples/TTXResizeWin/CMakeLists.txt (revision 9324)
+++ trunk/TTXSamples/TTXResizeWin/CMakeLists.txt (revision 9325)
@@ -10,6 +10,11 @@
1010 )
1111
1212 if(SUPPORT_OLD_WINDOWS)
13+ target_link_libraries(
14+ ${PACKAGE_NAME}
15+ PRIVATE
16+ layer_for_unicode
17+ )
1318 if(MSVC)
1419 target_sources(
1520 ${PACKAGE_NAME}
--- trunk/TTXSamples/TTXShowCommandLine/CMakeLists.txt (revision 9324)
+++ trunk/TTXSamples/TTXShowCommandLine/CMakeLists.txt (revision 9325)
@@ -10,6 +10,11 @@
1010 )
1111
1212 if(SUPPORT_OLD_WINDOWS)
13+ target_link_libraries(
14+ ${PACKAGE_NAME}
15+ PRIVATE
16+ layer_for_unicode
17+ )
1318 if(MSVC)
1419 target_sources(
1520 ${PACKAGE_NAME}
--- trunk/TTXSamples/TTXttyrec/CMakeLists.txt (revision 9324)
+++ trunk/TTXSamples/TTXttyrec/CMakeLists.txt (revision 9325)
@@ -10,6 +10,11 @@
1010 )
1111
1212 if(SUPPORT_OLD_WINDOWS)
13+ target_link_libraries(
14+ TTXttyplay
15+ PRIVATE
16+ layer_for_unicode
17+ )
1318 if(MSVC)
1419 target_sources(
1520 TTXttyplay
@@ -58,6 +63,11 @@
5863 )
5964
6065 if(SUPPORT_OLD_WINDOWS)
66+ target_link_libraries(
67+ TTXttyrec
68+ PRIVATE
69+ layer_for_unicode
70+ )
6171 if(MSVC)
6272 target_sources(
6373 TTXttyrec
--- trunk/TTXSamples/ttxtest/CMakeLists.txt (revision 9324)
+++ trunk/TTXSamples/ttxtest/CMakeLists.txt (revision 9325)
@@ -8,6 +8,11 @@
88 )
99
1010 if(SUPPORT_OLD_WINDOWS)
11+ target_link_libraries(
12+ ${PACKAGE_NAME}
13+ PRIVATE
14+ layer_for_unicode
15+ )
1116 if(MSVC)
1217 target_sources(
1318 ${PACKAGE_NAME}
--- trunk/teraterm/CMakeLists.txt (revision 9324)
+++ trunk/teraterm/CMakeLists.txt (revision 9325)
@@ -37,9 +37,20 @@
3737 common_static
3838 PROPERTIES FOLDER teraterm)
3939
40-if(SUPPORT_OLD_WINDOWS AND MINGW)
41- add_subdirectory(libmingw)
42- set_target_properties(
43- mingw_msvcrt
44- PROPERTIES FOLDER teraterm)
40+if(SUPPORT_OLD_WINDOWS)
41+ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
42+ add_subdirectory(common/layer_for_unicode)
43+ set_target_properties(
44+ layer_for_unicode
45+ PROPERTIES FOLDER teraterm)
46+ endif()
47+
48+ if(MINGW)
49+ add_subdirectory(libmingw)
50+ set_target_properties(
51+ mingw_msvcrt
52+ PROPERTIES FOLDER teraterm)
53+ endif(MINGW)
4554 endif()
55+
56+
--- trunk/teraterm/common/CMakeLists.txt (revision 9324)
+++ trunk/teraterm/common/CMakeLists.txt (revision 9325)
@@ -25,8 +25,6 @@
2525 getcontent.h
2626 i18n.h
2727 i18n_static.c
28- layer_for_unicode_crt.h
29- layer_for_unicode_crt.cpp
3028 tipwin.cpp
3129 tipwin.h
3230 tmfc.cpp
@@ -51,5 +49,6 @@
5149 target_link_libraries(
5250 ${PACKAGE_NAME}
5351 PUBLIC
52+ #
5453 setupapi
5554 )
--- trunk/teraterm/common/fileread.cpp (revision 9324)
+++ trunk/teraterm/common/fileread.cpp (revision 9325)
@@ -37,7 +37,6 @@
3737
3838 #include "codeconv.h"
3939 #include "ttlib.h"
40-#include "layer_for_unicode_crt.h"
4140
4241 #include "fileread.h"
4342
@@ -100,7 +99,7 @@
10099 uint8_t *LoadFileBinary(const wchar_t *FileName, size_t *_len)
101100 {
102101 FILE *fp;
103- __wfopen_s(&fp, FileName, L"rb");
102+ _wfopen_s(&fp, FileName, L"rb");
104103 if (fp == NULL) {
105104 return NULL;
106105 }
@@ -254,7 +253,7 @@
254253 *_len = 0;
255254 }
256255 FILE *fp;
257- __wfopen_s(&fp, FileName, L"rb");
256+ _wfopen_s(&fp, FileName, L"rb");
258257 if (fp == NULL) {
259258 return NULL;
260259 }
--- trunk/teraterm/common/layer_for_unicode/.gitignore (nonexistent)
+++ trunk/teraterm/common/layer_for_unicode/.gitignore (revision 9325)
@@ -0,0 +1,3 @@
1+Makefile
2+*.asm
3+*.obj
--- trunk/teraterm/common/layer_for_unicode/CMakeLists.txt (nonexistent)
+++ trunk/teraterm/common/layer_for_unicode/CMakeLists.txt (revision 9325)
@@ -0,0 +1,102 @@
1+cmake_minimum_required(VERSION 3.11)
2+
3+set(PACKAGE_NAME "layer_for_unicode")
4+
5+project(${PACKAGE_NAME})
6+
7+add_library(
8+ ${PACKAGE_NAME}
9+ STATIC
10+ init_ptr.cpp
11+ ../layer_for_unicode.cpp
12+ ../layer_for_unicode.h
13+ ../layer_for_unicode_comctl32.cpp
14+ )
15+
16+target_include_directories(
17+ ${PACKAGE_NAME}
18+ PRIVATE
19+ ..
20+ )
21+
22+if(NOT EXISTS "list_asm.cmake")
23+ execute_process(
24+ COMMAND ${PERL} generate.pl
25+ RESULT_VARIABLE rv
26+ WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
27+ )
28+ if(NOT rv STREQUAL "0")
29+ message(FATAL_ERROR "execute error ${PERL}")
30+ endif()
31+endif()
32+
33+if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
34+
35+ set(OBJ_DIR ".")
36+ include("list_obj.cmake")
37+
38+ target_sources(
39+ ${PACKAGE_NAME}
40+ PRIVATE
41+ ${SRC}
42+ )
43+
44+else()
45+ # VS2010+
46+
47+ include("list_asm.cmake")
48+
49+ if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
50+ set(BUILDTOOLS_NASM ${CMAKE_CURRENT_LIST_DIR}/../../../buildtools/nasm/nasm.exe)
51+ if(EXISTS ${BUILDTOOLS_NASM})
52+ set(CMAKE_ASM_NASM_COMPILER ${BUILDTOOLS_NASM})
53+ endif()
54+ endif()
55+ set(CMAKE_ASM_NASM_OBJECT_FORMAT win32)
56+ set(CMAKE_ASM_NASM_FLAGS_DEBUG "-g -Fcv8")
57+
58+ enable_language(ASM_NASM)
59+
60+ target_sources(
61+ ${PACKAGE_NAME}
62+ PRIVATE
63+ ${SRC}
64+ )
65+
66+ source_group(
67+ "assember"
68+ REGULAR_EXPRESSION
69+ "asm")
70+endif()
71+
72+if(${CMAKE_VERSION} VERSION_GREATER "3.12.0")
73+ target_link_libraries(
74+ ${PACKAGE_NAME}
75+ PUBLIC
76+ common_static
77+ $<$<CONFIG:Release>:libucrt.lib libvcruntime.lib>
78+ $<$<CONFIG:Debug>:libucrtd.lib libvcruntimed.lib>
79+ )
80+else()
81+ target_link_libraries(
82+ ${PACKAGE_NAME}
83+ PUBLIC
84+ $<$<CONFIG:Release>:LIBCMT.lib LIBCPMT.lib>
85+ $<$<CONFIG:Debug>:LIBCMTd.lib LIBCPMTd.lib>
86+ )
87+endif()
88+
89+target_link_libraries(
90+ ${PACKAGE_NAME}
91+ PUBLIC
92+ oleaut32
93+ advapi32
94+ ole32
95+ user32
96+ kernel32
97+ gdi32
98+ comdlg32
99+ comctl32
100+ shell32
101+ uuid
102+ )
--- trunk/teraterm/common/layer_for_unicode/README.md (nonexistent)
+++ trunk/teraterm/common/layer_for_unicode/README.md (revision 9325)
@@ -0,0 +1,11 @@
1+Layer for unicode
2+=================
3+
4+- Unicode API を持たない9x系用
5+- Unicode API を ANSI API でエミュレーションする
6+
7+## 準備
8+
9+- linuxでは nasm パッケージが必要
10+ `apt-get install nasm`
11+
--- trunk/teraterm/common/layer_for_unicode/generate.pl (nonexistent)
+++ trunk/teraterm/common/layer_for_unicode/generate.pl (revision 9325)
@@ -0,0 +1,152 @@
1+use utf8;
2+use strict;
3+
4+sub ShowAPIs {
5+ my $apis_ref = $_[0];
6+ my @apis = @$apis_ref;
7+ foreach my $api_ref (@apis) {
8+ my %api = %{$api_ref};
9+ print $api{"dll"}, " ", $api{"symbol"}, "@", $api{"param_bytes"}, "\n";
10+ }
11+}
12+
13+sub ReadSymbleList {
14+ open(FILE, "symbol_list.txt") || die "Cannot open file.";
15+
16+ my(%table, $val, $key);
17+ my($symbols);
18+
19+ my @apis = ();
20+ while (my $line = <FILE>) {
21+ if ($line =~ /^\s*(\w+)\s+(\w+)@(\d+)/) {
22+ my %api = (
23+ "dll" => $1,
24+ "symbol" => $2,
25+ "param_bytes" => $3
26+ );
27+ push(@apis, \%api);
28+ }
29+ }
30+ close(FILE);
31+
32+ return @apis;
33+}
34+
35+sub CreateAsm() {
36+ my($dll, $symbol, $param_bytes) = @_;
37+
38+ my $template = "templ_nasm.asm.in";
39+ my $filename = "$symbol.asm";
40+ open(IN, $template) || die "cannot open $template";
41+ open(OUT, ">$filename") || die "cannot open $filename";
42+
43+ while (my $line = <IN>) {
44+ $line =~ s/%SYMBOL%/$symbol/;
45+ $line =~ s/%PARAM_BYTES%/$param_bytes/;
46+ $line =~ s/%DLL%/$dll/;
47+ print OUT $line;
48+ }
49+ close(IN);
50+ close(OUT);
51+}
52+
53+sub CreateAsmArray() {
54+ my $apis_ref = $_[0];
55+ my @apis = @$apis_ref;
56+ foreach my $api_ref (@apis) {
57+ my %api = %{$api_ref};
58+ my $dll = $api{"dll"};
59+ my $symbol = $api{"symbol"};
60+ my $param_bytes = $api{"param_bytes"};
61+ &CreateAsm($dll, $symbol, $param_bytes);
62+ }
63+}
64+
65+sub CreateMakefile() {
66+ my $apis_ref = $_[0];
67+ my @apis = @$apis_ref;
68+ my $top = <<"EOS";
69+# generated by perl script
70+
71+NASM = ../../../buildtools/nasm/nasm.exe
72+NASM_FLAGS = -f win32 -g -F cv8
73+
74+all: all_objs
75+
76+clean:
77+ rm -rf *.obj *.asm
78+
79+generate:
80+ perl generate.pl
81+
82+all_objs: \\
83+EOS
84+ open(OUT, ">Makefile") || die "Cannot open file.";
85+ print OUT $top;
86+ foreach my $api_ref (@apis) {
87+ my %api = %{$api_ref};
88+ my $symbol = $api{"symbol"};
89+ print OUT " $symbol.obj \\\n";
90+ }
91+ print OUT "\n";
92+ foreach my $api_ref (@apis) {
93+ my %api = %{$api_ref};
94+ my $dll = $api{"dll"};
95+ my $symbol = $api{"symbol"};
96+ my $param_bytes = $api{"param_bytes"};
97+ print OUT "$symbol.obj: $symbol.asm\n";
98+ print OUT " \${NASM} \${NASM_FLAGS} $symbol.asm -o \$@\n";
99+ print OUT "\n";
100+ }
101+ close(OUT);
102+}
103+
104+sub CreateAsmCmake() {
105+ my $apis_ref = $_[0];
106+ my @apis = @$apis_ref;
107+
108+ open(OUT, ">list_asm.cmake") || die "Cannot open file.";
109+ my $top = <<"EOS";
110+# generated by perl script
111+
112+set(SRC
113+EOS
114+ print OUT $top;
115+ foreach my $api_ref (@apis) {
116+ my %api = %{$api_ref};
117+ my $symbol = $api{"symbol"};
118+ print OUT " $symbol.asm\n";
119+# print OUT " ${ASM_DIR}/$symbol.asm\n";
120+ }
121+ print OUT " )\n";
122+ close(OUT);
123+}
124+
125+sub CreateObjCmake() {
126+ my $apis_ref = $_[0];
127+ my @apis = @$apis_ref;
128+
129+ open(OUT, ">list_obj.cmake") || die "Cannot open file.";
130+ my $top = <<"EOS";
131+# generated by perl script
132+
133+set(SRC
134+EOS
135+ print OUT $top;
136+ foreach my $api_ref (@apis) {
137+ my %api = %{$api_ref};
138+ my $symbol = $api{"symbol"};
139+ print OUT " \${OBJ_DIR}/$symbol.obj\n";
140+ }
141+ print OUT " )\n";
142+ close(OUT);
143+}
144+
145+my @apis = &ReadSymbleList();
146+ShowAPIs(\@apis);
147+&CreateAsmArray(\@apis);
148+&CreateMakefile(\@apis);
149+&CreateAsmCmake(\@apis);
150+&CreateObjCmake(\@apis);
151+
152+exit(0);
--- trunk/teraterm/common/layer_for_unicode/init_ptr.cpp (nonexistent)
+++ trunk/teraterm/common/layer_for_unicode/init_ptr.cpp (revision 9325)
@@ -0,0 +1,98 @@
1+/*
2+ * Copyright (C) 2021- TeraTerm Project
3+ * All rights reserved.
4+ *
5+ * Redistribution and use in source and binary forms, with or without
6+ * modification, are permitted provided that the following conditions
7+ * are met:
8+ *
9+ * 1. Redistributions of source code must retain the above copyright
10+ * notice, this list of conditions and the following disclaimer.
11+ * 2. Redistributions in binary form must reproduce the above copyright
12+ * notice, this list of conditions and the following disclaimer in the
13+ * documentation and/or other materials provided with the distribution.
14+ * 3. The name of the author may not be used to endorse or promote products
15+ * derived from this software without specific prior written permission.
16+ *
17+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+ */
28+
29+#include <windows.h>
30+
31+#include "codeconv.h"
32+
33+static bool IsWindowsNTKernel(void)
34+{
35+#if defined(_MSC_VER) && _MSC_VER > 1400
36+ // VS2005よりあたらしい場合は、NTのみをターゲットとする
37+ return true;
38+#else
39+ static bool kernel_checked;
40+ static bool nt_kernel;
41+
42+ if (kernel_checked) {
43+ return nt_kernel;
44+ }
45+ kernel_checked = true;
46+
47+ // VS2005 or MinGW
48+ OSVERSIONINFOA osvi;
49+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
50+ GetVersionExA(&osvi);
51+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
52+ // Windows 9x
53+ nt_kernel = false;
54+ }
55+ else {
56+ nt_kernel = true;
57+ }
58+ return nt_kernel;
59+#endif
60+}
61+
62+static HMODULE _GetModuleHandleW(LPCWSTR lpModuleName)
63+{
64+ char* lpStringA = ToCharW(lpModuleName);
65+ HMODULE h = GetModuleHandleA(lpStringA);
66+ free(lpStringA);
67+ return h;
68+}
69+
70+static DWORD DLLGetApiAddress(const wchar_t *dllPath,
71+ const char *ApiName, void **pFunc)
72+{
73+ HMODULE hDll = _GetModuleHandleW(dllPath);
74+ if (hDll == NULL) {
75+ *pFunc = NULL;
76+ return ERROR_FILE_NOT_FOUND;
77+ } else {
78+ *pFunc = (void *)GetProcAddress(hDll, ApiName);
79+ if (*pFunc == NULL) {
80+ return ERROR_PROC_NOT_FOUND;
81+ }
82+ return NO_ERROR; // = 0
83+ }
84+}
85+
86+extern "C" void init_ptr(const wchar_t *dll, const char *func_name, void *wrap_func, void **func_ptr)
87+{
88+ if (!IsWindowsNTKernel()) {
89+ *func_ptr = wrap_func;
90+ return;
91+ }
92+
93+ void *ptr;
94+ DWORD r = DLLGetApiAddress(dll, func_name, &ptr);
95+ if (r == NO_ERROR) {
96+ *func_ptr = ptr;
97+ }
98+}
--- trunk/teraterm/common/layer_for_unicode/symbol_list.txt (nonexistent)
+++ trunk/teraterm/common/layer_for_unicode/symbol_list.txt (revision 9325)
@@ -0,0 +1,55 @@
1+user32 SetWindowTextW@8
2+user32 SetDlgItemTextW@12
3+user32 GetDlgItemTextW@16
4+user32 SendDlgItemMessageW@20
5+user32 SendMessageW@16
6+user32 CreateWindowExW@48
7+user32 RegisterClassW@4
8+user32 MessageBoxW@16
9+user32 InsertMenuW@20
10+user32 AppendMenuW@16
11+user32 GetWindowTextW@12
12+user32 GetWindowTextLengthW@4
13+user32 CallWindowProcW@20
14+user32 CreateDialogIndirectParamW@20
15+user32 DialogBoxIndirectParamW@20
16+user32 SetWindowLongW@12
17+user32 GetWindowLongW@8
18+
19+kernel32 GetFileAttributesW@4
20+kernel32 GetModuleFileNameW@12
21+kernel32 SetCurrentDirectoryW@4
22+kernel32 GetCurrentDirectoryW@8
23+kernel32 OutputDebugStringW@4
24+kernel32 GetPrivateProfileStringW@24
25+kernel32 WritePrivateProfileStringW@16
26+kernel32 GetPrivateProfileIntW@16
27+kernel32 CreateProcessW@40
28+kernel32 CopyFileW@12
29+kernel32 DeleteFileW@4
30+kernel32 MoveFileW@8
31+kernel32 CreateFileW@28
32+kernel32 FindFirstFileW@8
33+kernel32 FindNextFileW@8
34+kernel32 RemoveDirectoryW@4
35+kernel32 GetFullPathNameW@16
36+kernel32 LoadLibraryW@4
37+kernel32 ExpandEnvironmentStringsW@12
38+kernel32 GetModuleHandleW@4
39+kernel32 GetSystemDirectoryW@8
40+kernel32 GetTempPathW@8
41+kernel32 GetTempFileNameW@16
42+
43+gdi32 AddFontResourceW@4
44+gdi32 RemoveFontResourceW@4
45+
46+comctl32 CreatePropertySheetPageW@4
47+comctl32 PropertySheetW@4
48+
49+comdlg32 GetOpenFileNameW@4
50+comdlg32 GetSaveFileNameW@4
51+
52+shell32 DragQueryFileW@16
53+shell32 Shell_NotifyIconW@8
54+shell32 SHBrowseForFolderW@4
55+shell32 SHGetPathFromIDListW@8
--- trunk/teraterm/common/layer_for_unicode/templ_nasm.asm.in (nonexistent)
+++ trunk/teraterm/common/layer_for_unicode/templ_nasm.asm.in (revision 9325)
@@ -0,0 +1,40 @@
1+;;; nasm -f win32 %SYMBOL%.asm
2+
3+ global __imp__%SYMBOL%@%PARAM_BYTES%
4+ global %SYMBOL%
5+ global _%SYMBOL%@%PARAM_BYTES%
6+
7+ extern __%SYMBOL%@%PARAM_BYTES%
8+ extern _init_ptr
9+
10+ section .data
11+
12+ ;; pointer of %SYMBOL%(), stdcall style
13+__imp__%SYMBOL%@%PARAM_BYTES%:
14+ dd init
15+
16+
17+ section .text
18+
19+ ;; call api pointer initializer
20+init:
21+ pusha
22+ push dword __imp__%SYMBOL%@%PARAM_BYTES% ; place to save the pointer
23+ push dword __%SYMBOL%@%PARAM_BYTES% ; wrapper
24+ push dword api_str
25+ push dword %DLL%_dll_str
26+ call _init_ptr
27+ add esp,byte 16
28+ popa
29+
30+ ;; call api
31+;%SYMBOL%:
32+;_%SYMBOL%@%PARAM_BYTES%:
33+ jmp [__imp__%SYMBOL%@%PARAM_BYTES%]
34+
35+
36+ section .data
37+%DLL%_dll_str:
38+ dw __utf16__("%DLL%.dll"), 0
39+api_str:
40+ db "%SYMBOL%",0
--- trunk/teraterm/common/layer_for_unicode.cpp (revision 9324)
+++ trunk/teraterm/common/layer_for_unicode.cpp (revision 9325)
@@ -60,7 +60,7 @@
6060
6161 static Initializer initializer;
6262
63-BOOL _SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString)
63+BOOL WINAPI _SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString)
6464 {
6565 if (pSetDlgItemTextW != NULL) {
6666 return pSetDlgItemTextW(hDlg, nIDDlgItem, lpString);
@@ -72,7 +72,7 @@
7272 return retval;
7373 }
7474
75-UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch)
75+UINT WINAPI _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch)
7676 {
7777 if (pDragQueryFileW != NULL) {
7878 return pDragQueryFileW(hDrop, iFile, lpszFile, cch);
@@ -106,7 +106,7 @@
106106 return retval;
107107 }
108108
109-DWORD _GetFileAttributesW(LPCWSTR lpFileName)
109+DWORD WINAPI _GetFileAttributesW(LPCWSTR lpFileName)
110110 {
111111 if (pGetFileAttributesW != NULL) {
112112 return pGetFileAttributesW(lpFileName);
@@ -179,7 +179,7 @@
179179 return strW;
180180 }
181181
182-int _GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
182+int WINAPI _GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
183183 {
184184 if (pGetWindowTextW != NULL) {
185185 return pGetWindowTextW(hWnd, lpString, nMaxCount);
@@ -194,7 +194,7 @@
194194 return (int)(dest_len - 1);
195195 }
196196
197-int _GetWindowTextLengthW(HWND hWnd)
197+int WINAPI _GetWindowTextLengthW(HWND hWnd)
198198 {
199199 if (pGetWindowTextLengthW != NULL) {
200200 return pGetWindowTextLengthW(hWnd);
@@ -257,7 +257,7 @@
257257 return retval;
258258 }
259259
260-LRESULT _SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
260+LRESULT WINAPI _SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
261261 {
262262 if (pSendMessageW != NULL) {
263263 return pSendMessageW(hWnd, Msg, wParam, lParam);
@@ -265,7 +265,7 @@
265265 return SendMessageAFromW(hWnd, Msg, wParam, lParam);
266266 }
267267
268-LRESULT _SendDlgItemMessageW(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam)
268+LRESULT WINAPI _SendDlgItemMessageW(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam)
269269 {
270270 if (pSendDlgItemMessageW != NULL) {
271271 return pSendDlgItemMessageW(hDlg, nIDDlgItem, Msg, wParam, lParam);
@@ -275,8 +275,9 @@
275275 return SendMessageAFromW(hWnd, Msg, wParam, lParam);
276276 }
277277
278-HWND _CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y,
279- int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
278+HWND WINAPI _CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X,
279+ int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance,
280+ LPVOID lpParam)
280281 {
281282 if (pCreateWindowExW != NULL) {
282283 return pCreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu,
@@ -294,7 +295,7 @@
294295 return hWnd;
295296 }
296297
297-ATOM _RegisterClassW(const WNDCLASSW *lpWndClass)
298+ATOM WINAPI _RegisterClassW(const WNDCLASSW *lpWndClass)
298299 {
299300 if (pRegisterClassW != NULL) {
300301 return pRegisterClassW(lpWndClass);
@@ -325,7 +326,7 @@
325326 return atom;
326327 }
327328
328-BOOL _SetWindowTextW(HWND hWnd, LPCWSTR lpString)
329+BOOL WINAPI _SetWindowTextW(HWND hWnd, LPCWSTR lpString)
329330 {
330331 if (pSetWindowTextW != NULL) {
331332 return pSetWindowTextW(hWnd, lpString);
@@ -337,7 +338,7 @@
337338 return retval;
338339 }
339340
340-UINT _GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int cchMax)
341+UINT WINAPI _GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int cchMax)
341342 {
342343 if (pGetDlgItemTextW != NULL) {
343344 return pGetDlgItemTextW(hDlg, nIDDlgItem, lpString, cchMax);
@@ -366,7 +367,7 @@
366367 *
367368 * TODO:9x系でDrawTextWが正しく動作する?
368369 */
369-int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format)
370+int WINAPI _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format)
370371 {
371372 if (IsWindowsNTKernel()) {
372373 return DrawTextW(hdc, lpchText, cchText, lprc, format);
@@ -380,7 +381,7 @@
380381 return result;
381382 }
382383
383-int _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
384+int WINAPI _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
384385 {
385386 if (pMessageBoxW != NULL) {
386387 return pMessageBoxW(hWnd, lpText, lpCaption, uType);
@@ -394,7 +395,7 @@
394395 return result;
395396 }
396397
397-BOOL _InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
398+BOOL WINAPI _InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
398399 {
399400 if (pInsertMenuW != NULL) {
400401 return pInsertMenuW(hMenu, uPosition, uFlags, uIDNewItem, lpNewItem);
@@ -406,7 +407,7 @@
406407 return result;
407408 }
408409
409-BOOL _AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
410+BOOL WINAPI _AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
410411 {
411412 if (pAppendMenuW != NULL) {
412413 return pAppendMenuW(hMenu, uFlags, uIDNewItem, lpNewItem);
@@ -417,7 +418,7 @@
417418 return result;
418419 }
419420
420-int _AddFontResourceW(LPCWSTR lpFileName)
421+int WINAPI _AddFontResourceW(LPCWSTR lpFileName)
421422 {
422423 char *filenameA = ToCharW(lpFileName);
423424 int result = AddFontResourceA(filenameA);
@@ -425,7 +426,7 @@
425426 return result;
426427 }
427428
428-BOOL _RemoveFontResourceW(LPCWSTR lpFileName)
429+BOOL WINAPI _RemoveFontResourceW(LPCWSTR lpFileName)
429430 {
430431 char *filenameA = ToCharW(lpFileName);
431432 int result = RemoveFontResourceA(filenameA);
@@ -436,7 +437,7 @@
436437 /*
437438 * lpData.cbSize == 952のときのみ ANSI関数で処理する
438439 */
439-BOOL _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData)
440+BOOL WINAPI _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData)
440441 {
441442 if (pShell_NotifyIconW != NULL) {
442443 return pShell_NotifyIconW(dwMessage, (PNOTIFYICONDATAW)lpData);
@@ -474,7 +475,7 @@
474475 return r;
475476 }
476477
477-HWND _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc,
478+HWND WINAPI _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc,
478479 LPARAM dwInitParam)
479480 {
480481 if (pCreateDialogIndirectParamW != NULL) {
@@ -483,7 +484,7 @@
483484 return CreateDialogIndirectParamA(hInstance, lpTemplate, hWndParent, lpDialogFunc, dwInitParam);
484485 }
485486
486-INT_PTR _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent,
487+INT_PTR WINAPI _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent,
487488 DLGPROC lpDialogFunc, LPARAM lParamInit)
488489 {
489490 if (pDialogBoxIndirectParamW != NULL) {
@@ -492,7 +493,7 @@
492493 return DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, lParamInit);
493494 }
494495
495-LONG _SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong)
496+LONG WINAPI _SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong)
496497 {
497498 if (pSetWindowLongW != NULL) {
498499 return pSetWindowLongW(hWnd, nIndex, dwNewLong);
@@ -500,7 +501,7 @@
500501 return SetWindowLongA(hWnd, nIndex, dwNewLong);
501502 }
502503
503-LONG_PTR _SetWindowLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong)
504+LONG_PTR WINAPI _SetWindowLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong)
504505 {
505506 #ifdef _WIN64
506507 if (pSetWindowLongPtrW != NULL) {
@@ -512,7 +513,7 @@
512513 #endif
513514 }
514515
515-LONG _GetWindowLongW(HWND hWnd, int nIndex)
516+LONG WINAPI _GetWindowLongW(HWND hWnd, int nIndex)
516517 {
517518 if (pGetWindowLongW != NULL) {
518519 return pGetWindowLongW(hWnd, nIndex);
@@ -520,7 +521,7 @@
520521 return GetWindowLongA(hWnd, nIndex);
521522 }
522523
523-LONG_PTR _GetWindowLongPtrW(HWND hWnd, int nIndex)
524+LONG_PTR WINAPI _GetWindowLongPtrW(HWND hWnd, int nIndex)
524525 {
525526 #ifdef _WIN64
526527 if (pGetWindowLongPtrW != NULL) {
@@ -532,7 +533,7 @@
532533 #endif
533534 }
534535
535-LRESULT _CallWindowProcW(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
536+LRESULT WINAPI _CallWindowProcW(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
536537 {
537538 if (pCallWindowProcW != NULL) {
538539 return pCallWindowProcW(lpPrevWndFunc, hWnd, Msg, wParam, lParam);
@@ -540,7 +541,7 @@
540541 return CallWindowProcA(lpPrevWndFunc, hWnd, Msg, wParam, lParam);
541542 }
542543
543-void _OutputDebugStringW(LPCWSTR lpOutputString)
544+void WINAPI _OutputDebugStringW(LPCWSTR lpOutputString)
544545 {
545546 if (pOutputDebugStringW != NULL) {
546547 return pOutputDebugStringW(lpOutputString);
@@ -551,7 +552,7 @@
551552 free(strA);
552553 }
553554
554-DWORD _GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer)
555+DWORD WINAPI _GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer)
555556 {
556557 if (pGetCurrentDirectoryW != NULL) {
557558 return pGetCurrentDirectoryW(nBufferLength, lpBuffer);
@@ -565,7 +566,7 @@
565566 return r;
566567 }
567568
568-BOOL _SetCurrentDirectoryW(LPCWSTR lpPathName)
569+BOOL WINAPI _SetCurrentDirectoryW(LPCWSTR lpPathName)
569570 {
570571 if (pSetCurrentDirectoryW != NULL) {
571572 return pSetCurrentDirectoryW(lpPathName);
@@ -576,7 +577,7 @@
576577 return r;
577578 }
578579
579-LPITEMIDLIST _SHBrowseForFolderW(LPBROWSEINFOW lpbi)
580+LPITEMIDLIST WINAPI _SHBrowseForFolderW(LPBROWSEINFOW lpbi)
580581 {
581582 if (pSHBrowseForFolderW != NULL) {
582583 return pSHBrowseForFolderW(lpbi);
@@ -597,7 +598,7 @@
597598 return pidlBrowse;
598599 }
599600
600-BOOL _SHGetPathFromIDListW(LPITEMIDLIST pidl, LPWSTR pszPath)
601+BOOL WINAPI _SHGetPathFromIDListW(LPITEMIDLIST pidl, LPWSTR pszPath)
601602 {
602603 if (pSHGetPathFromIDListW != NULL) {
603604 return pSHGetPathFromIDListW(pidl, pszPath);
@@ -609,7 +610,7 @@
609610 return r;
610611 }
611612
612-DWORD _GetPrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
613+DWORD WINAPI _GetPrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
613614 LPWSTR lpReturnedString, DWORD nSize, LPCWSTR lpFileName)
614615 {
615616 if (pGetPrivateProfileStringW != NULL) {
@@ -617,6 +618,9 @@
617618 lpReturnedString, nSize, lpFileName);
618619 }
619620
621+ if (lpDefault == NULL) {
622+ lpDefault = L"";
623+ }
620624 char *buf = (char* )malloc(nSize);
621625 char *appA = ToCharW(lpAppName);
622626 char *keyA = ToCharW(lpKeyName);
@@ -633,7 +637,7 @@
633637 return r;
634638 }
635639
636-BOOL _WritePrivateProfileStringW(LPCWSTR lpAppName,LPCWSTR lpKeyName,LPCWSTR lpString,LPCWSTR lpFileName)
640+BOOL WINAPI _WritePrivateProfileStringW(LPCWSTR lpAppName,LPCWSTR lpKeyName,LPCWSTR lpString,LPCWSTR lpFileName)
637641 {
638642 if (pWritePrivateProfileStringW != NULL) {
639643 return pWritePrivateProfileStringW(lpAppName, lpKeyName, lpString, lpFileName);
@@ -651,7 +655,7 @@
651655 return r;
652656 }
653657
654-UINT _GetPrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, INT nDefault, LPCWSTR lpFileName)
658+UINT WINAPI _GetPrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, INT nDefault, LPCWSTR lpFileName)
655659 {
656660 if (pGetPrivateProfileIntW != NULL) {
657661 return pGetPrivateProfileIntW(lpAppName, lpKeyName, nDefault, lpFileName);
@@ -667,7 +671,7 @@
667671 return r;
668672 }
669673
670-BOOL _CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine,
674+BOOL WINAPI _CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine,
671675 LPSECURITY_ATTRIBUTES lpProcessAttributes,
672676 LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles,
673677 DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory,
@@ -716,7 +720,7 @@
716720 return r;
717721 }
718722
719-BOOL _CopyFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, BOOL bFailIfExists)
723+BOOL WINAPI _CopyFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, BOOL bFailIfExists)
720724 {
721725 if (pCopyFileW != NULL) {
722726 return pCopyFileW(lpExistingFileName, lpNewFileName, bFailIfExists);
@@ -729,7 +733,7 @@
729733 return r;
730734 }
731735
732-BOOL _DeleteFileW(LPCWSTR lpFileName)
736+BOOL WINAPI _DeleteFileW(LPCWSTR lpFileName)
733737 {
734738 if (pDeleteFileW != NULL) {
735739 return pDeleteFileW(lpFileName);
@@ -740,7 +744,7 @@
740744 return r;
741745 }
742746
743-BOOL _MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName)
747+BOOL WINAPI _MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName)
744748 {
745749 if (pMoveFileW != NULL) {
746750 return pMoveFileW(lpExistingFileName, lpNewFileName);
@@ -753,7 +757,7 @@
753757 return r;
754758 }
755759
756-HANDLE _CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
760+HANDLE WINAPI _CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
757761 LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
758762 HANDLE hTemplateFile)
759763 {
@@ -783,7 +787,7 @@
783787 ::MultiByteToWideChar(CP_ACP, 0, a->cAlternateFileName, _countof(a->cAlternateFileName), w->cAlternateFileName, _countof(w->cAlternateFileName));
784788 }
785789
786-HANDLE _FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData)
790+HANDLE WINAPI _FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData)
787791 {
788792 if (pFindFirstFileW != NULL) {
789793 return pFindFirstFileW(lpFileName, lpFindFileData);
@@ -797,7 +801,7 @@
797801 return handle;
798802 }
799803
800-BOOL _FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData)
804+BOOL WINAPI _FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData)
801805 {
802806 if (pFindNextFileW != NULL) {
803807 return pFindNextFileW(hFindFile, lpFindFileData);
@@ -808,7 +812,7 @@
808812 return r;
809813 }
810814
811-BOOL _RemoveDirectoryW(LPCWSTR lpPathName)
815+BOOL WINAPI _RemoveDirectoryW(LPCWSTR lpPathName)
812816 {
813817 if (pRemoveDirectoryW != NULL) {
814818 return pRemoveDirectoryW(lpPathName);
@@ -819,40 +823,47 @@
819823 return r;
820824 }
821825
822-DWORD _GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart)
826+DWORD WINAPI _GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart)
823827 {
824828 if (pGetFullPathNameW != NULL) {
825829 return pGetFullPathNameW(lpFileName, nBufferLength, lpBuffer, lpFilePart);
826830 }
827831
828- char *filenameA = ToCharW(lpFileName);
829- char bufA[MAX_PATH];
830- char *filepartA;
831- DWORD r = GetFullPathNameA(filenameA, sizeof(bufA), bufA, &filepartA);
832- if (r == 0) {
833- // error
832+ if (nBufferLength == 0 || lpBuffer == NULL) {
833+ char *filenameA = ToCharW(lpFileName);
834+ DWORD r = GetFullPathNameA(filenameA, 0, NULL, NULL);
834835 free(filenameA);
835- return 0;
836+ return r;
836837 }
837- wchar_t *bufW = ToWcharA(bufA);
838- r = (DWORD)wcslen(bufW);
839- if (nBufferLength == 0 || lpBuffer == NULL) {
840- // 必要な文字数を返す('\0'含む)
841- r = r + 1;
842- } else {
843- // パスをコピーして、文字列長を返す('\0'含まない)
844- wcsncpy_s(lpBuffer, nBufferLength, bufW, _TRUNCATE);
845- if (lpFilePart != NULL) {
846- *lpFilePart = lpBuffer + (filepartA - filenameA) * sizeof(wchar_t);
838+ else {
839+ char *filenameA = ToCharW(lpFileName);
840+ char bufA[MAX_PATH];
841+ char *filepartA;
842+ DWORD r = GetFullPathNameA(filenameA, sizeof(bufA), bufA, &filepartA);
843+ if (r == 0) {
844+ // error
845+ free(filenameA);
846+ return 0;
847847 }
848+ wchar_t *bufW = ToWcharA(bufA);
849+ r = (DWORD)wcslen(bufW);
850+ if (nBufferLength == 0 || lpBuffer == NULL) {
851+ // 必要な文字数を返す('\0'含む)
852+ r = r + 1;
853+ } else {
854+ // パスをコピーして、文字列長を返す('\0'含まない)
855+ wcsncpy_s(lpBuffer, nBufferLength, bufW, _TRUNCATE);
856+ if (lpFilePart != NULL) {
857+ *lpFilePart = lpBuffer + (filepartA - filenameA) * sizeof(wchar_t);
858+ }
859+ }
860+ free(filenameA);
861+ free(bufW);
862+ return r;
848863 }
849- free(filenameA);
850- free(bufW);
851-
852- return r;
853864 }
854865
855-HMODULE _LoadLibraryW(LPCWSTR lpLibFileName)
866+HMODULE WINAPI _LoadLibraryW(LPCWSTR lpLibFileName)
856867 {
857868 if (pLoadLibraryW != NULL) {
858869 return pLoadLibraryW(lpLibFileName);
@@ -863,7 +874,7 @@
863874 return r;
864875 }
865876
866-DWORD _GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize)
877+DWORD WINAPI _GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize)
867878 {
868879 if (pGetModuleFileNameW != NULL) {
869880 return pGetModuleFileNameW(hModule, lpFilename, nSize);
@@ -878,7 +889,7 @@
878889 return wlen - 1; // not including the terminating null character
879890 }
880891
881-DWORD _ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
892+DWORD WINAPI _ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
882893 {
883894 if (pExpandEnvironmentStringsW != NULL) {
884895 return pExpandEnvironmentStringsW(lpSrc, lpDst, nSize);
@@ -895,7 +906,7 @@
895906 return r;
896907 }
897908
898-HMODULE _GetModuleHandleW(LPCWSTR lpModuleName)
909+HMODULE WINAPI _GetModuleHandleW(LPCWSTR lpModuleName)
899910 {
900911 char *lpStringA = ToCharW(lpModuleName);
901912 HMODULE h = GetModuleHandleA(lpStringA);
@@ -903,7 +914,7 @@
903914 return h;
904915 }
905916
906-UINT _GetSystemDirectoryW(LPWSTR lpBuffer, UINT uSize)
917+UINT WINAPI _GetSystemDirectoryW(LPWSTR lpBuffer, UINT uSize)
907918 {
908919 char buf[MAX_PATH];
909920 UINT r = GetSystemDirectoryA(buf, _countof(buf));
@@ -914,7 +925,7 @@
914925 return wlen - 1; // not including the terminating null character
915926 }
916927
917-DWORD _GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer)
928+DWORD WINAPI _GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer)
918929 {
919930 if (pGetTempPathW != NULL) {
920931 return pGetTempPathW(nBufferLength, lpBuffer);
@@ -929,7 +940,7 @@
929940 return wlen - 1; // not including the terminating null character
930941 }
931942
932-UINT _GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString, UINT uUnique, LPWSTR lpTempFileName)
943+UINT WINAPI _GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString, UINT uUnique, LPWSTR lpTempFileName)
933944 {
934945 if (pGetTempFileNameW != NULL) {
935946 return pGetTempFileNameW(lpPathName, lpPrefixString, uUnique, lpTempFileName);
--- trunk/teraterm/common/layer_for_unicode.h (revision 9324)
+++ trunk/teraterm/common/layer_for_unicode.h (revision 9325)
@@ -93,82 +93,82 @@
9393 //HICON hBalloonIcon; // Vista+
9494 } TT_NOTIFYICONDATAW_V2;
9595
96-BOOL _SetWindowTextW(HWND hWnd, LPCWSTR lpString);
97-BOOL _SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString);
98-UINT _GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int cchMax);
99-LRESULT _SendDlgItemMessageW(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam);
100-LRESULT _SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
101-HWND _CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y,
96+BOOL WINAPI _SetWindowTextW(HWND hWnd, LPCWSTR lpString);
97+BOOL WINAPI _SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString);
98+UINT WINAPI _GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int cchMax);
99+LRESULT WINAPI _SendDlgItemMessageW(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam);
100+LRESULT WINAPI _SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
101+HWND WINAPI WINAPI _CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y,
102102 int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance,
103103 LPVOID lpParam);
104-ATOM _RegisterClassW(const WNDCLASSW *lpWndClass);
105-int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format);
106-int _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
107-BOOL _InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);
108-BOOL _AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);
109-int _GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount);
110-int _GetWindowTextLengthW(HWND hWnd);
111-LONG _SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong);
112-LONG _GetWindowLongW(HWND hWnd, int nIndex);
113-LONG_PTR _SetWindowLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong);
114-LONG_PTR _GetWindowLongPtrW(HWND hWnd, int nIndex);
115-LRESULT _CallWindowProcW(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
104+ATOM WINAPI _RegisterClassW(const WNDCLASSW *lpWndClass);
105+int WINAPI _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format);
106+int WINAPI _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
107+BOOL WINAPI _InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);
108+BOOL WINAPI _AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);
109+int WINAPI _GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount);
110+int WINAPI _GetWindowTextLengthW(HWND hWnd);
111+LONG WINAPI _SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong);
112+LONG WINAPI _GetWindowLongW(HWND hWnd, int nIndex);
113+LONG_PTR WINAPI _SetWindowLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong);
114+LONG_PTR WINAPI _GetWindowLongPtrW(HWND hWnd, int nIndex);
115+LRESULT WINAPI _CallWindowProcW(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
116116
117117 // kernel32.dll
118-DWORD _GetFileAttributesW(LPCWSTR lpFileName);
119-DWORD _GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer);
120-BOOL _SetCurrentDirectoryW(LPCWSTR lpPathName);
121-void _OutputDebugStringW(LPCWSTR lpOutputString);
122-DWORD _GetPrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
118+DWORD WINAPI _GetFileAttributesW(LPCWSTR lpFileName);
119+DWORD WINAPI _GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer);
120+BOOL WINAPI _SetCurrentDirectoryW(LPCWSTR lpPathName);
121+void WINAPI _OutputDebugStringW(LPCWSTR lpOutputString);
122+DWORD WINAPI _GetPrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
123123 LPWSTR lpReturnedString, DWORD nSize, LPCWSTR lpFileName);
124-BOOL _WritePrivateProfileStringW(LPCWSTR lpAppName,LPCWSTR lpKeyName,LPCWSTR lpString,LPCWSTR lpFileName);
125-UINT _GetPrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, INT nDefault, LPCWSTR lpFileName);
126-BOOL _CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine,
124+BOOL WINAPI _WritePrivateProfileStringW(LPCWSTR lpAppName,LPCWSTR lpKeyName,LPCWSTR lpString,LPCWSTR lpFileName);
125+UINT WINAPI _GetPrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, INT nDefault, LPCWSTR lpFileName);
126+BOOL WINAPI _CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine,
127127 LPSECURITY_ATTRIBUTES lpProcessAttributes,
128128 LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles,
129129 DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory,
130130 LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
131-BOOL _CopyFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, BOOL bFailIfExists);
132-BOOL _DeleteFileW(LPCWSTR lpFileName);
133-BOOL _MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName);
134-HANDLE _CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
131+BOOL WINAPI _CopyFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, BOOL bFailIfExists);
132+BOOL WINAPI _DeleteFileW(LPCWSTR lpFileName);
133+BOOL WINAPI _MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName);
134+HANDLE WINAPI _CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
135135 LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
136136 HANDLE hTemplateFile);
137-HANDLE _FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData);
138-BOOL _FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData);
139-BOOL _RemoveDirectoryW(LPCWSTR lpPathName);
140-DWORD _GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart);
141-HMODULE _LoadLibraryW(LPCWSTR lpLibFileName);
142-DWORD _GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize);
143-DWORD _ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize);
144-HMODULE _GetModuleHandleW(LPCWSTR lpModuleName);
145-UINT _GetSystemDirectoryW(LPWSTR lpBuffer, UINT uSize);
146-DWORD _GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer);
147-UINT _GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString, UINT uUnique, LPWSTR lpTempFileName);
137+HANDLE WINAPI _FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData);
138+BOOL WINAPI _FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData);
139+BOOL WINAPI _RemoveDirectoryW(LPCWSTR lpPathName);
140+DWORD WINAPI _GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart);
141+HMODULE WINAPI _LoadLibraryW(LPCWSTR lpLibFileName);
142+DWORD WINAPI WINAPI _GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize);
143+DWORD WINAPI _ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize);
144+HMODULE WINAPI _GetModuleHandleW(LPCWSTR lpModuleName);
145+UINT WINAPI _GetSystemDirectoryW(LPWSTR lpBuffer, UINT uSize);
146+DWORD WINAPI _GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer);
147+UINT WINAPI _GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString, UINT uUnique, LPWSTR lpTempFileName);
148148
149149 // gdi32.lib
150-int _AddFontResourceW(LPCWSTR lpFileName);
151-BOOL _RemoveFontResourceW(LPCWSTR lpFileName);
150+int WINAPI _AddFontResourceW(LPCWSTR lpFileName);
151+BOOL WINAPI _RemoveFontResourceW(LPCWSTR lpFileName);
152152
153153 // Comctl32.lib
154-HPROPSHEETPAGE _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 constPropSheetPagePointer);
155-INT_PTR _PropertySheetW(PROPSHEETHEADERW *constPropSheetHeaderPointer);
156-//INT_PTR _PropertySheetW(PROPSHEETHEADERW_V1 *constPropSheetHeaderPointer);
154+HPROPSHEETPAGE WINAPI _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 constPropSheetPagePointer);
155+INT_PTR WINAPI _PropertySheetW(PROPSHEETHEADERW *constPropSheetHeaderPointer);
156+//INT_PTR WINAPI _PropertySheetW(PROPSHEETHEADERW_V1 *constPropSheetHeaderPointer);
157157
158158 // Comdlg32.lib
159-BOOL _GetOpenFileNameW(LPOPENFILENAMEW ofnW);
160-BOOL _GetSaveFileNameW(LPOPENFILENAMEW ofnW);
159+BOOL WINAPI _GetOpenFileNameW(LPOPENFILENAMEW ofnW);
160+BOOL WINAPI _GetSaveFileNameW(LPOPENFILENAMEW ofnW);
161161
162162 // shell32.lib
163-UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
164-BOOL _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData);
165-LPITEMIDLIST _SHBrowseForFolderW(LPBROWSEINFOW lpbi);
166-BOOL _SHGetPathFromIDListW(LPITEMIDLIST pidl, LPWSTR pszPath);
163+UINT WINAPI _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
164+BOOL WINAPI _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData);
165+LPITEMIDLIST WINAPI _SHBrowseForFolderW(LPBROWSEINFOW lpbi);
166+BOOL WINAPI _SHGetPathFromIDListW(LPITEMIDLIST pidl, LPWSTR pszPath);
167167
168-HWND _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate,
168+HWND WINAPI _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate,
169169 HWND hWndParent, DLGPROC lpDialogFunc,
170170 LPARAM dwInitParam);
171-INT_PTR _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent,
171+INT_PTR WINAPI _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent,
172172 DLGPROC lpDialogFunc, LPARAM lParamInit);
173173
174174 #ifdef __cplusplus
--- trunk/teraterm/common/layer_for_unicode.md (nonexistent)
+++ trunk/teraterm/common/layer_for_unicode.md (revision 9325)
@@ -0,0 +1,84 @@
1+layer for unicode
2+=================
3+
4+## layer for unicode について
5+
6+Unicode API が存在しない環境で Unicode API を利用するためのライブラリ
7+- [Microsoft Layer for Unicode, MSLU](https://ja.wikipedia.org/wiki/Microsoft_Layer_for_Unicode)
8+- Windows 9x系を想定
9+- Unicode APIが利用できる場合は利用する
10+- Unicode APIが利用できない場合はANSI(非Unicode)APIを使用
11+ - Unicode API をエミュレーションする
12+
13+## ビルド
14+
15+### 必要なツール
16+
17+- nasm
18+ - buildtools/ で `cmake -P nasm.cmake` を実行すると準備することができる
19+- perl
20+- make
21+
22+### 準備
23+
24+ビルド前に次のコマンドを実行しておく
25+
26+```
27+perl generate.pl
28+make
29+```
30+
31+## 経緯
32+
33+- Tera Term では 9x系をサポートするため独自実装していた
34+ - Microsoft Layer for Unicode を使用すると dll が必要となる
35+ - 同梱するためにはライセンス、再頒布の検討が必要
36+ - dllが配布されなくなる可能性がある
37+ - Tera Term では独自実装のコードをバイナリにstaticにリンクしていた
38+- 従来 Tera Term の layer for unicode を使用するためには、少しコードを変更する必要があった
39+ - includeの追加
40+ - WIN32 API 名を少し変更する
41+ - 例 SetDlgItemTextW() -> _SetDlgItemTextW()
42+- ライブラリとして分離したい,モチベーション
43+ - 9x系のサポートを Tera Term 本体の開発と分離したい
44+ - Microsoft Layer for Unicode への置き換えを可能にしたい
45+ - x64(64bit)環境ではUnicode APIが存在するはずなので組み込まずにバイナリを作りたい
46+ - 将来9xサポートをやめるときにソースを修正を最小としたい
47+- [libunicodes](http://libunicows.sourceforge.net/)プロジェクトを参考にライブラリとして分離
48+ - Cでは記述できないのでアセンブラを使用
49+ - nasm を採用
50+ - linuxでも使用できる
51+ - ソースはテンプレートから自動生成
52+ - テンプレートを作成すれば他のアセンブラでも作成可能
53+ - ラベルに`@`が含まれるため
54+ - 例 `__imp__GetDlgItemTextW@16`
55+
56+## 方針
57+
58+- Tera Term が動作する程度に実装
59+- Microsoft Layer for Unicode と同等のAPI
60+ - `nm "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.xxxxxx.0\um\x86\unicows.lib"`
61+ - Visual Studio 2019 Win32 に含まれている
62+ - Visual Studio 2019 で作成したバイナリは 9x では動作しない
63+ - 従来のコードをそのままビルドできるよう,互換性を維持するため存在すると思われる
64+
65+## ライブラリの利用
66+
67+- 利用する側のソース
68+ - 利用するうえで特に気にかけることはない
69+- 利用する側のライブラリのリンク
70+ - kernel32.lib, user32.lib などよりも前に layer for unicode ライブラリをリンクする
71+ - 順序を誤ると Unicode API を使用するバイナリとなる
72+ - static リンクであれば、バイナリ内のAPIを置き換えることができる
73+ - CreateFileW() を使用していると思われる wfopen() も利用可能となる
74+- バイナリ内に Unicode API が存在するかチェックする例
75+ - 存在しない場合
76+
77+ $ objdump -p ../../release/ttermpro.exe | grep CreateFile
78+ b1256 83 CreateFileA
79+
80+ - 存在する場合
81+
82+ $ objdump -p ../../release/ttermpro.exe | grep CreateFile
83+ b0618 83 CreateFileA
84+ b016c 86 CreateFileW
--- trunk/teraterm/common/layer_for_unicode_comctl32.cpp (revision 9324)
+++ trunk/teraterm/common/layer_for_unicode_comctl32.cpp (revision 9325)
@@ -40,7 +40,7 @@
4040
4141 #include "layer_for_unicode.h"
4242
43-HPROPSHEETPAGE _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 psp)
43+HPROPSHEETPAGE WINAPI _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 psp)
4444 {
4545 if (pCreatePropertySheetPageW != NULL) {
4646 return pCreatePropertySheetPageW((LPCPROPSHEETPAGEW)psp);
@@ -70,7 +70,7 @@
7070 // SDK: Windows Server 2003 R2 Platform SDK
7171 // (Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1)
7272 //INT_PTR _PropertySheetW(PROPSHEETHEADERW_V1 *psh)
73-INT_PTR _PropertySheetW(PROPSHEETHEADERW *psh)
73+INT_PTR WINAPI _PropertySheetW(PROPSHEETHEADERW *psh)
7474 {
7575 if (pPropertySheetW != NULL) {
7676 return pPropertySheetW((PROPSHEETHEADERW *)psh);
@@ -150,7 +150,7 @@
150150 return result;
151151 }
152152
153-BOOL _GetOpenFileNameW(LPOPENFILENAMEW ofnW)
153+BOOL WINAPI _GetOpenFileNameW(LPOPENFILENAMEW ofnW)
154154 {
155155 if (pGetOpenFileNameW != NULL) {
156156 return pGetOpenFileNameW(ofnW);
@@ -159,7 +159,7 @@
159159 return GetOpenSaveFileNameA(GetOpenFileNameA, ofnW);
160160 }
161161
162-BOOL _GetSaveFileNameW(LPOPENFILENAMEW ofnW)
162+BOOL WINAPI _GetSaveFileNameW(LPOPENFILENAMEW ofnW)
163163 {
164164 if (pGetSaveFileNameW != NULL) {
165165 return pGetSaveFileNameW(ofnW);
--- trunk/teraterm/keycode/CMakeLists.txt (revision 9324)
+++ trunk/teraterm/keycode/CMakeLists.txt (revision 9325)
@@ -12,6 +12,11 @@
1212 )
1313
1414 if(SUPPORT_OLD_WINDOWS)
15+ target_link_libraries(
16+ ${PACKAGE_NAME}
17+ PRIVATE
18+ layer_for_unicode
19+ )
1520 if(MSVC)
1621 target_sources(
1722 ${PACKAGE_NAME}
@@ -60,6 +65,12 @@
6065 )
6166
6267 if(SUPPORT_OLD_WINDOWS)
68+ target_link_libraries(
69+ ${PACKAGE_NAME_2}
70+ PRIVATE
71+ common_static
72+ layer_for_unicode
73+ )
6374 if(MSVC)
6475 target_sources(
6576 ${PACKAGE_NAME_2}
--- trunk/teraterm/teraterm/CMakeLists.txt (revision 9324)
+++ trunk/teraterm/teraterm/CMakeLists.txt (revision 9325)
@@ -206,6 +206,17 @@
206206
207207 if(SUPPORT_OLD_WINDOWS)
208208 if(MSVC)
209+ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
210+ set(CMAKE_C_STANDARD_LIBRARIES "")
211+ set(CMAKE_CXX_STANDARD_LIBRARIES "")
212+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB")
213+ else()
214+ target_link_options(
215+ ${PACKAGE_NAME}
216+ PRIVATE
217+ /NODEFAULTLIB
218+ )
219+ endif()
209220 target_sources(
210221 ${PACKAGE_NAME}
211222 PRIVATE
@@ -271,6 +282,8 @@
271282 /pdbaltpath:ttermpro.pdb
272283 /map
273284 )
285+ else()
286+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /map")
274287 endif()
275288 elseif(MINGW)
276289 target_link_options(
@@ -289,12 +302,31 @@
289302 ttptek
290303 ${ONIGURUMA_LIB}
291304 ${SFMT_LIB}
292- #
305+ )
306+
307+if(SUPPORT_OLD_WINDOWS)
308+ target_link_libraries(
309+ ${PACKAGE_NAME}
310+ PRIVATE
311+ layer_for_unicode
312+ )
313+endif()
314+
315+target_link_libraries(
316+ ${PACKAGE_NAME}
317+ PRIVATE
318+ advapi32
319+ comctl32
320+ comdlg32
293321 gdi32
294- comctl32
295- ws2_32
296322 imagehlp
323+ kernel32
324+ ole32
325+ oleaut32
326+ shell32
327+ user32
297328 uuid
329+ ws2_32
298330 )
299331
300332 install(
--- trunk/teraterm/ttpcmn/CMakeLists.txt (revision 9324)
+++ trunk/teraterm/ttpcmn/CMakeLists.txt (revision 9325)
@@ -17,6 +17,17 @@
1717
1818 if(SUPPORT_OLD_WINDOWS)
1919 if(MSVC)
20+ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
21+ set(CMAKE_C_STANDARD_LIBRARIES "")
22+ set(CMAKE_CXX_STANDARD_LIBRARIES "")
23+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB")
24+ else()
25+ target_link_options(
26+ ${PACKAGE_NAME}
27+ PRIVATE
28+ /NODEFAULTLIB
29+ )
30+ endif()
2031 target_sources(
2132 ${PACKAGE_NAME}
2233 PRIVATE
@@ -88,6 +99,19 @@
8899 ${PACKAGE_NAME}
89100 PRIVATE
90101 common_static
102+ )
103+
104+if(SUPPORT_OLD_WINDOWS)
105+ target_link_libraries(
106+ ${PACKAGE_NAME}
107+ PRIVATE
108+ layer_for_unicode
109+ )
110+endif()
111+
112+target_link_libraries(
113+ ${PACKAGE_NAME}
114+ PRIVATE
91115 ole32
92116 setupapi
93117 )
--- trunk/teraterm/ttpset/CMakeLists.txt (revision 9324)
+++ trunk/teraterm/ttpset/CMakeLists.txt (revision 9325)
@@ -13,6 +13,17 @@
1313
1414 if(SUPPORT_OLD_WINDOWS)
1515 if(MSVC)
16+ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
17+ set(CMAKE_C_STANDARD_LIBRARIES "")
18+ set(CMAKE_CXX_STANDARD_LIBRARIES "")
19+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB")
20+ else()
21+ target_link_options(
22+ ${PACKAGE_NAME}
23+ PRIVATE
24+ /NODEFAULTLIB
25+ )
26+ endif()
1627 target_sources(
1728 ${PACKAGE_NAME}
1829 PRIVATE
@@ -72,6 +83,15 @@
7283 ttpcmn
7384 )
7485
86+if(SUPPORT_OLD_WINDOWS)
87+ target_link_libraries(
88+ ${PACKAGE_NAME}
89+ PRIVATE
90+ layer_for_unicode
91+# ${CRT_LIB}
92+ )
93+endif()
94+
7595 install(
7696 TARGETS ${PACKAGE_NAME}
7797 RUNTIME
--- trunk/ttpmenu/CMakeLists.txt (revision 9324)
+++ trunk/ttpmenu/CMakeLists.txt (revision 9325)
@@ -34,6 +34,11 @@
3434 "teraterm\/common\/")
3535
3636 if(SUPPORT_OLD_WINDOWS)
37+ target_link_libraries(
38+ ${PACKAGE_NAME}
39+ PRIVATE
40+ layer_for_unicode
41+ )
3742 if(MSVC)
3843 target_sources(
3944 ${PACKAGE_NAME}
--- trunk/ttssh2/matcher/CMakeLists.txt (revision 9324)
+++ trunk/ttssh2/matcher/CMakeLists.txt (revision 9325)
@@ -1,13 +1,17 @@
1-project(matcher)
2-
3-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
4-
5-set(SRC
6- matcher.c
7- test.c
8- )
9-
10-add_executable(
11- matcher
12- ${SRC}
13- )
1+set(PACKAGE_NAME "matcher")
2+
3+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
4+
5+add_executable(
6+ ${PACKAGE_NAME}
7+ matcher.c
8+ test.c
9+ )
10+
11+if(SUPPORT_OLD_WINDOWS)
12+ target_link_libraries(
13+ ${PACKAGE_NAME}
14+ PRIVATE
15+ layer_for_unicode
16+ )
17+endif()
--- trunk/ttssh2/ttssh/CMakeLists.txt (revision 9324)
+++ trunk/ttssh2/ttssh/CMakeLists.txt (revision 9325)
@@ -1,8 +1,11 @@
1-project(ttssh)
1+set(PACKAGE_NAME "ttssh")
22
3+project(${PACKAGE_NAME})
4+
35 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
46
5-set(SRC
7+add_executable(
8+ ${PACKAGE_NAME} WIN32
69 resource.h
710 ttsecure.ico
811 ttssh.c
@@ -9,7 +12,31 @@
912 ttssh.rc
1013 )
1114
12-add_executable(
13- ttssh WIN32
14- ${SRC}
15+if(SUPPORT_OLD_WINDOWS)
16+ target_link_libraries(
17+ ${PACKAGE_NAME}
18+ PRIVATE
19+ layer_for_unicode
20+ )
21+ if(MSVC)
22+ target_sources(
23+ ${PACKAGE_NAME}
24+ PRIVATE
25+ ../../teraterm/common/compat_w95_vs2005.c
26+ )
27+ endif()
28+ if(MINGW)
29+ target_link_libraries(
30+ ${PACKAGE_NAME}
31+ PRIVATE
32+ -Wl,--whole-archive
33+ mingw_msvcrt
34+ -Wl,--no-whole-archive
35+ )
36+ endif()
37+endif(SUPPORT_OLD_WINDOWS)
38+
39+install(
40+ TARGETS ${PACKAGE_NAME}
41+ DESTINATION .
1542 )
--- trunk/ttssh2/ttxssh/CMakeLists.txt (revision 9324)
+++ trunk/ttssh2/ttxssh/CMakeLists.txt (revision 9325)
@@ -116,6 +116,17 @@
116116
117117 if(SUPPORT_OLD_WINDOWS)
118118 if(MSVC)
119+ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
120+ set(CMAKE_C_STANDARD_LIBRARIES "")
121+ set(CMAKE_CXX_STANDARD_LIBRARIES "")
122+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB")
123+ else()
124+ target_link_options(
125+ ${PACKAGE_NAME}
126+ PRIVATE
127+ /NODEFAULTLIB
128+ )
129+ endif()
119130 target_sources(
120131 ${PACKAGE_NAME}
121132 PRIVATE
@@ -179,7 +190,19 @@
179190 argon2
180191 ${ZLIB_LIB}
181192 ${OPENSSL_LIB}
182- #
193+ )
194+
195+if(SUPPORT_OLD_WINDOWS)
196+ target_link_libraries(
197+ ${PACKAGE_NAME}
198+ PRIVATE
199+ layer_for_unicode
200+ )
201+endif()
202+
203+target_link_libraries(
204+ ${PACKAGE_NAME}
205+ PRIVATE
183206 ws2_32
184207 gdi32
185208 comdlg32
Show on old repository browser