layer for unicode をライブラリに分離
- Windows 9xをサポートするためのパートをライブラリとして切り出し
- vs2005 のプロジェクトを調整
- CMakeLists.txt 調整
@@ -10,6 +10,11 @@ | ||
10 | 10 | ) |
11 | 11 | |
12 | 12 | if(SUPPORT_OLD_WINDOWS) |
13 | + target_link_libraries( | |
14 | + ${PACKAGE_NAME} | |
15 | + PRIVATE | |
16 | + layer_for_unicode | |
17 | + ) | |
13 | 18 | if(MSVC) |
14 | 19 | target_sources( |
15 | 20 | ${PACKAGE_NAME} |
@@ -10,6 +10,11 @@ | ||
10 | 10 | ) |
11 | 11 | |
12 | 12 | if(SUPPORT_OLD_WINDOWS) |
13 | + target_link_libraries( | |
14 | + ${PACKAGE_NAME} | |
15 | + PRIVATE | |
16 | + layer_for_unicode | |
17 | + ) | |
13 | 18 | if(MSVC) |
14 | 19 | target_sources( |
15 | 20 | ${PACKAGE_NAME} |
@@ -10,6 +10,11 @@ | ||
10 | 10 | ) |
11 | 11 | |
12 | 12 | if(SUPPORT_OLD_WINDOWS) |
13 | + target_link_libraries( | |
14 | + ${PACKAGE_NAME} | |
15 | + PRIVATE | |
16 | + common_static | |
17 | + ) | |
13 | 18 | if(MSVC) |
14 | 19 | target_sources( |
15 | 20 | ${PACKAGE_NAME} |
@@ -10,6 +10,11 @@ | ||
10 | 10 | ) |
11 | 11 | |
12 | 12 | if(SUPPORT_OLD_WINDOWS) |
13 | + target_link_libraries( | |
14 | + ${PACKAGE_NAME} | |
15 | + PRIVATE | |
16 | + layer_for_unicode | |
17 | + ) | |
13 | 18 | if(MSVC) |
14 | 19 | target_sources( |
15 | 20 | ${PACKAGE_NAME} |
@@ -10,6 +10,11 @@ | ||
10 | 10 | ) |
11 | 11 | |
12 | 12 | if(SUPPORT_OLD_WINDOWS) |
13 | + target_link_libraries( | |
14 | + ${PACKAGE_NAME} | |
15 | + PRIVATE | |
16 | + layer_for_unicode | |
17 | + ) | |
13 | 18 | if(MSVC) |
14 | 19 | target_sources( |
15 | 20 | ${PACKAGE_NAME} |
@@ -10,6 +10,11 @@ | ||
10 | 10 | ) |
11 | 11 | |
12 | 12 | if(SUPPORT_OLD_WINDOWS) |
13 | + target_link_libraries( | |
14 | + ${PACKAGE_NAME} | |
15 | + PRIVATE | |
16 | + layer_for_unicode | |
17 | + ) | |
13 | 18 | if(MSVC) |
14 | 19 | target_sources( |
15 | 20 | ${PACKAGE_NAME} |
@@ -10,6 +10,11 @@ | ||
10 | 10 | ) |
11 | 11 | |
12 | 12 | if(SUPPORT_OLD_WINDOWS) |
13 | + target_link_libraries( | |
14 | + ${PACKAGE_NAME} | |
15 | + PRIVATE | |
16 | + layer_for_unicode | |
17 | + ) | |
13 | 18 | if(MSVC) |
14 | 19 | target_sources( |
15 | 20 | ${PACKAGE_NAME} |
@@ -10,6 +10,11 @@ | ||
10 | 10 | ) |
11 | 11 | |
12 | 12 | if(SUPPORT_OLD_WINDOWS) |
13 | + target_link_libraries( | |
14 | + ${PACKAGE_NAME} | |
15 | + PRIVATE | |
16 | + layer_for_unicode | |
17 | + ) | |
13 | 18 | if(MSVC) |
14 | 19 | target_sources( |
15 | 20 | ${PACKAGE_NAME} |
@@ -10,6 +10,11 @@ | ||
10 | 10 | ) |
11 | 11 | |
12 | 12 | if(SUPPORT_OLD_WINDOWS) |
13 | + target_link_libraries( | |
14 | + TTXttyplay | |
15 | + PRIVATE | |
16 | + layer_for_unicode | |
17 | + ) | |
13 | 18 | if(MSVC) |
14 | 19 | target_sources( |
15 | 20 | TTXttyplay |
@@ -58,6 +63,11 @@ | ||
58 | 63 | ) |
59 | 64 | |
60 | 65 | if(SUPPORT_OLD_WINDOWS) |
66 | + target_link_libraries( | |
67 | + TTXttyrec | |
68 | + PRIVATE | |
69 | + layer_for_unicode | |
70 | + ) | |
61 | 71 | if(MSVC) |
62 | 72 | target_sources( |
63 | 73 | TTXttyrec |
@@ -8,6 +8,11 @@ | ||
8 | 8 | ) |
9 | 9 | |
10 | 10 | if(SUPPORT_OLD_WINDOWS) |
11 | + target_link_libraries( | |
12 | + ${PACKAGE_NAME} | |
13 | + PRIVATE | |
14 | + layer_for_unicode | |
15 | + ) | |
11 | 16 | if(MSVC) |
12 | 17 | target_sources( |
13 | 18 | ${PACKAGE_NAME} |
@@ -37,9 +37,20 @@ | ||
37 | 37 | common_static |
38 | 38 | PROPERTIES FOLDER teraterm) |
39 | 39 | |
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) | |
45 | 54 | endif() |
55 | + | |
56 | + |
@@ -25,8 +25,6 @@ | ||
25 | 25 | getcontent.h |
26 | 26 | i18n.h |
27 | 27 | i18n_static.c |
28 | - layer_for_unicode_crt.h | |
29 | - layer_for_unicode_crt.cpp | |
30 | 28 | tipwin.cpp |
31 | 29 | tipwin.h |
32 | 30 | tmfc.cpp |
@@ -51,5 +49,6 @@ | ||
51 | 49 | target_link_libraries( |
52 | 50 | ${PACKAGE_NAME} |
53 | 51 | PUBLIC |
52 | + # | |
54 | 53 | setupapi |
55 | 54 | ) |
@@ -37,7 +37,6 @@ | ||
37 | 37 | |
38 | 38 | #include "codeconv.h" |
39 | 39 | #include "ttlib.h" |
40 | -#include "layer_for_unicode_crt.h" | |
41 | 40 | |
42 | 41 | #include "fileread.h" |
43 | 42 |
@@ -100,7 +99,7 @@ | ||
100 | 99 | uint8_t *LoadFileBinary(const wchar_t *FileName, size_t *_len) |
101 | 100 | { |
102 | 101 | FILE *fp; |
103 | - __wfopen_s(&fp, FileName, L"rb"); | |
102 | + _wfopen_s(&fp, FileName, L"rb"); | |
104 | 103 | if (fp == NULL) { |
105 | 104 | return NULL; |
106 | 105 | } |
@@ -254,7 +253,7 @@ | ||
254 | 253 | *_len = 0; |
255 | 254 | } |
256 | 255 | FILE *fp; |
257 | - __wfopen_s(&fp, FileName, L"rb"); | |
256 | + _wfopen_s(&fp, FileName, L"rb"); | |
258 | 257 | if (fp == NULL) { |
259 | 258 | return NULL; |
260 | 259 | } |
@@ -0,0 +1,3 @@ | ||
1 | +Makefile | |
2 | +*.asm | |
3 | +*.obj |
@@ -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 | + ) |
@@ -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 | + |
@@ -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); |
@@ -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 | +} |
@@ -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 |
@@ -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 |
@@ -60,7 +60,7 @@ | ||
60 | 60 | |
61 | 61 | static Initializer initializer; |
62 | 62 | |
63 | -BOOL _SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString) | |
63 | +BOOL WINAPI _SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString) | |
64 | 64 | { |
65 | 65 | if (pSetDlgItemTextW != NULL) { |
66 | 66 | return pSetDlgItemTextW(hDlg, nIDDlgItem, lpString); |
@@ -72,7 +72,7 @@ | ||
72 | 72 | return retval; |
73 | 73 | } |
74 | 74 | |
75 | -UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch) | |
75 | +UINT WINAPI _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch) | |
76 | 76 | { |
77 | 77 | if (pDragQueryFileW != NULL) { |
78 | 78 | return pDragQueryFileW(hDrop, iFile, lpszFile, cch); |
@@ -106,7 +106,7 @@ | ||
106 | 106 | return retval; |
107 | 107 | } |
108 | 108 | |
109 | -DWORD _GetFileAttributesW(LPCWSTR lpFileName) | |
109 | +DWORD WINAPI _GetFileAttributesW(LPCWSTR lpFileName) | |
110 | 110 | { |
111 | 111 | if (pGetFileAttributesW != NULL) { |
112 | 112 | return pGetFileAttributesW(lpFileName); |
@@ -179,7 +179,7 @@ | ||
179 | 179 | return strW; |
180 | 180 | } |
181 | 181 | |
182 | -int _GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount) | |
182 | +int WINAPI _GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount) | |
183 | 183 | { |
184 | 184 | if (pGetWindowTextW != NULL) { |
185 | 185 | return pGetWindowTextW(hWnd, lpString, nMaxCount); |
@@ -194,7 +194,7 @@ | ||
194 | 194 | return (int)(dest_len - 1); |
195 | 195 | } |
196 | 196 | |
197 | -int _GetWindowTextLengthW(HWND hWnd) | |
197 | +int WINAPI _GetWindowTextLengthW(HWND hWnd) | |
198 | 198 | { |
199 | 199 | if (pGetWindowTextLengthW != NULL) { |
200 | 200 | return pGetWindowTextLengthW(hWnd); |
@@ -257,7 +257,7 @@ | ||
257 | 257 | return retval; |
258 | 258 | } |
259 | 259 | |
260 | -LRESULT _SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) | |
260 | +LRESULT WINAPI _SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) | |
261 | 261 | { |
262 | 262 | if (pSendMessageW != NULL) { |
263 | 263 | return pSendMessageW(hWnd, Msg, wParam, lParam); |
@@ -265,7 +265,7 @@ | ||
265 | 265 | return SendMessageAFromW(hWnd, Msg, wParam, lParam); |
266 | 266 | } |
267 | 267 | |
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) | |
269 | 269 | { |
270 | 270 | if (pSendDlgItemMessageW != NULL) { |
271 | 271 | return pSendDlgItemMessageW(hDlg, nIDDlgItem, Msg, wParam, lParam); |
@@ -275,8 +275,9 @@ | ||
275 | 275 | return SendMessageAFromW(hWnd, Msg, wParam, lParam); |
276 | 276 | } |
277 | 277 | |
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) | |
280 | 281 | { |
281 | 282 | if (pCreateWindowExW != NULL) { |
282 | 283 | return pCreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, |
@@ -294,7 +295,7 @@ | ||
294 | 295 | return hWnd; |
295 | 296 | } |
296 | 297 | |
297 | -ATOM _RegisterClassW(const WNDCLASSW *lpWndClass) | |
298 | +ATOM WINAPI _RegisterClassW(const WNDCLASSW *lpWndClass) | |
298 | 299 | { |
299 | 300 | if (pRegisterClassW != NULL) { |
300 | 301 | return pRegisterClassW(lpWndClass); |
@@ -325,7 +326,7 @@ | ||
325 | 326 | return atom; |
326 | 327 | } |
327 | 328 | |
328 | -BOOL _SetWindowTextW(HWND hWnd, LPCWSTR lpString) | |
329 | +BOOL WINAPI _SetWindowTextW(HWND hWnd, LPCWSTR lpString) | |
329 | 330 | { |
330 | 331 | if (pSetWindowTextW != NULL) { |
331 | 332 | return pSetWindowTextW(hWnd, lpString); |
@@ -337,7 +338,7 @@ | ||
337 | 338 | return retval; |
338 | 339 | } |
339 | 340 | |
340 | -UINT _GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int cchMax) | |
341 | +UINT WINAPI _GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int cchMax) | |
341 | 342 | { |
342 | 343 | if (pGetDlgItemTextW != NULL) { |
343 | 344 | return pGetDlgItemTextW(hDlg, nIDDlgItem, lpString, cchMax); |
@@ -366,7 +367,7 @@ | ||
366 | 367 | * |
367 | 368 | * TODO:9x系でDrawTextWが正しく動作する? |
368 | 369 | */ |
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) | |
370 | 371 | { |
371 | 372 | if (IsWindowsNTKernel()) { |
372 | 373 | return DrawTextW(hdc, lpchText, cchText, lprc, format); |
@@ -380,7 +381,7 @@ | ||
380 | 381 | return result; |
381 | 382 | } |
382 | 383 | |
383 | -int _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType) | |
384 | +int WINAPI _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType) | |
384 | 385 | { |
385 | 386 | if (pMessageBoxW != NULL) { |
386 | 387 | return pMessageBoxW(hWnd, lpText, lpCaption, uType); |
@@ -394,7 +395,7 @@ | ||
394 | 395 | return result; |
395 | 396 | } |
396 | 397 | |
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) | |
398 | 399 | { |
399 | 400 | if (pInsertMenuW != NULL) { |
400 | 401 | return pInsertMenuW(hMenu, uPosition, uFlags, uIDNewItem, lpNewItem); |
@@ -406,7 +407,7 @@ | ||
406 | 407 | return result; |
407 | 408 | } |
408 | 409 | |
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) | |
410 | 411 | { |
411 | 412 | if (pAppendMenuW != NULL) { |
412 | 413 | return pAppendMenuW(hMenu, uFlags, uIDNewItem, lpNewItem); |
@@ -417,7 +418,7 @@ | ||
417 | 418 | return result; |
418 | 419 | } |
419 | 420 | |
420 | -int _AddFontResourceW(LPCWSTR lpFileName) | |
421 | +int WINAPI _AddFontResourceW(LPCWSTR lpFileName) | |
421 | 422 | { |
422 | 423 | char *filenameA = ToCharW(lpFileName); |
423 | 424 | int result = AddFontResourceA(filenameA); |
@@ -425,7 +426,7 @@ | ||
425 | 426 | return result; |
426 | 427 | } |
427 | 428 | |
428 | -BOOL _RemoveFontResourceW(LPCWSTR lpFileName) | |
429 | +BOOL WINAPI _RemoveFontResourceW(LPCWSTR lpFileName) | |
429 | 430 | { |
430 | 431 | char *filenameA = ToCharW(lpFileName); |
431 | 432 | int result = RemoveFontResourceA(filenameA); |
@@ -436,7 +437,7 @@ | ||
436 | 437 | /* |
437 | 438 | * lpData.cbSize == 952のときのみ ANSI関数で処理する |
438 | 439 | */ |
439 | -BOOL _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData) | |
440 | +BOOL WINAPI _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData) | |
440 | 441 | { |
441 | 442 | if (pShell_NotifyIconW != NULL) { |
442 | 443 | return pShell_NotifyIconW(dwMessage, (PNOTIFYICONDATAW)lpData); |
@@ -474,7 +475,7 @@ | ||
474 | 475 | return r; |
475 | 476 | } |
476 | 477 | |
477 | -HWND _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc, | |
478 | +HWND WINAPI _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc, | |
478 | 479 | LPARAM dwInitParam) |
479 | 480 | { |
480 | 481 | if (pCreateDialogIndirectParamW != NULL) { |
@@ -483,7 +484,7 @@ | ||
483 | 484 | return CreateDialogIndirectParamA(hInstance, lpTemplate, hWndParent, lpDialogFunc, dwInitParam); |
484 | 485 | } |
485 | 486 | |
486 | -INT_PTR _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent, | |
487 | +INT_PTR WINAPI _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent, | |
487 | 488 | DLGPROC lpDialogFunc, LPARAM lParamInit) |
488 | 489 | { |
489 | 490 | if (pDialogBoxIndirectParamW != NULL) { |
@@ -492,7 +493,7 @@ | ||
492 | 493 | return DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, lParamInit); |
493 | 494 | } |
494 | 495 | |
495 | -LONG _SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong) | |
496 | +LONG WINAPI _SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong) | |
496 | 497 | { |
497 | 498 | if (pSetWindowLongW != NULL) { |
498 | 499 | return pSetWindowLongW(hWnd, nIndex, dwNewLong); |
@@ -500,7 +501,7 @@ | ||
500 | 501 | return SetWindowLongA(hWnd, nIndex, dwNewLong); |
501 | 502 | } |
502 | 503 | |
503 | -LONG_PTR _SetWindowLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong) | |
504 | +LONG_PTR WINAPI _SetWindowLongPtrW(HWND hWnd, int nIndex, LONG_PTR dwNewLong) | |
504 | 505 | { |
505 | 506 | #ifdef _WIN64 |
506 | 507 | if (pSetWindowLongPtrW != NULL) { |
@@ -512,7 +513,7 @@ | ||
512 | 513 | #endif |
513 | 514 | } |
514 | 515 | |
515 | -LONG _GetWindowLongW(HWND hWnd, int nIndex) | |
516 | +LONG WINAPI _GetWindowLongW(HWND hWnd, int nIndex) | |
516 | 517 | { |
517 | 518 | if (pGetWindowLongW != NULL) { |
518 | 519 | return pGetWindowLongW(hWnd, nIndex); |
@@ -520,7 +521,7 @@ | ||
520 | 521 | return GetWindowLongA(hWnd, nIndex); |
521 | 522 | } |
522 | 523 | |
523 | -LONG_PTR _GetWindowLongPtrW(HWND hWnd, int nIndex) | |
524 | +LONG_PTR WINAPI _GetWindowLongPtrW(HWND hWnd, int nIndex) | |
524 | 525 | { |
525 | 526 | #ifdef _WIN64 |
526 | 527 | if (pGetWindowLongPtrW != NULL) { |
@@ -532,7 +533,7 @@ | ||
532 | 533 | #endif |
533 | 534 | } |
534 | 535 | |
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) | |
536 | 537 | { |
537 | 538 | if (pCallWindowProcW != NULL) { |
538 | 539 | return pCallWindowProcW(lpPrevWndFunc, hWnd, Msg, wParam, lParam); |
@@ -540,7 +541,7 @@ | ||
540 | 541 | return CallWindowProcA(lpPrevWndFunc, hWnd, Msg, wParam, lParam); |
541 | 542 | } |
542 | 543 | |
543 | -void _OutputDebugStringW(LPCWSTR lpOutputString) | |
544 | +void WINAPI _OutputDebugStringW(LPCWSTR lpOutputString) | |
544 | 545 | { |
545 | 546 | if (pOutputDebugStringW != NULL) { |
546 | 547 | return pOutputDebugStringW(lpOutputString); |
@@ -551,7 +552,7 @@ | ||
551 | 552 | free(strA); |
552 | 553 | } |
553 | 554 | |
554 | -DWORD _GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) | |
555 | +DWORD WINAPI _GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) | |
555 | 556 | { |
556 | 557 | if (pGetCurrentDirectoryW != NULL) { |
557 | 558 | return pGetCurrentDirectoryW(nBufferLength, lpBuffer); |
@@ -565,7 +566,7 @@ | ||
565 | 566 | return r; |
566 | 567 | } |
567 | 568 | |
568 | -BOOL _SetCurrentDirectoryW(LPCWSTR lpPathName) | |
569 | +BOOL WINAPI _SetCurrentDirectoryW(LPCWSTR lpPathName) | |
569 | 570 | { |
570 | 571 | if (pSetCurrentDirectoryW != NULL) { |
571 | 572 | return pSetCurrentDirectoryW(lpPathName); |
@@ -576,7 +577,7 @@ | ||
576 | 577 | return r; |
577 | 578 | } |
578 | 579 | |
579 | -LPITEMIDLIST _SHBrowseForFolderW(LPBROWSEINFOW lpbi) | |
580 | +LPITEMIDLIST WINAPI _SHBrowseForFolderW(LPBROWSEINFOW lpbi) | |
580 | 581 | { |
581 | 582 | if (pSHBrowseForFolderW != NULL) { |
582 | 583 | return pSHBrowseForFolderW(lpbi); |
@@ -597,7 +598,7 @@ | ||
597 | 598 | return pidlBrowse; |
598 | 599 | } |
599 | 600 | |
600 | -BOOL _SHGetPathFromIDListW(LPITEMIDLIST pidl, LPWSTR pszPath) | |
601 | +BOOL WINAPI _SHGetPathFromIDListW(LPITEMIDLIST pidl, LPWSTR pszPath) | |
601 | 602 | { |
602 | 603 | if (pSHGetPathFromIDListW != NULL) { |
603 | 604 | return pSHGetPathFromIDListW(pidl, pszPath); |
@@ -609,7 +610,7 @@ | ||
609 | 610 | return r; |
610 | 611 | } |
611 | 612 | |
612 | -DWORD _GetPrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault, | |
613 | +DWORD WINAPI _GetPrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault, | |
613 | 614 | LPWSTR lpReturnedString, DWORD nSize, LPCWSTR lpFileName) |
614 | 615 | { |
615 | 616 | if (pGetPrivateProfileStringW != NULL) { |
@@ -617,6 +618,9 @@ | ||
617 | 618 | lpReturnedString, nSize, lpFileName); |
618 | 619 | } |
619 | 620 | |
621 | + if (lpDefault == NULL) { | |
622 | + lpDefault = L""; | |
623 | + } | |
620 | 624 | char *buf = (char* )malloc(nSize); |
621 | 625 | char *appA = ToCharW(lpAppName); |
622 | 626 | char *keyA = ToCharW(lpKeyName); |
@@ -633,7 +637,7 @@ | ||
633 | 637 | return r; |
634 | 638 | } |
635 | 639 | |
636 | -BOOL _WritePrivateProfileStringW(LPCWSTR lpAppName,LPCWSTR lpKeyName,LPCWSTR lpString,LPCWSTR lpFileName) | |
640 | +BOOL WINAPI _WritePrivateProfileStringW(LPCWSTR lpAppName,LPCWSTR lpKeyName,LPCWSTR lpString,LPCWSTR lpFileName) | |
637 | 641 | { |
638 | 642 | if (pWritePrivateProfileStringW != NULL) { |
639 | 643 | return pWritePrivateProfileStringW(lpAppName, lpKeyName, lpString, lpFileName); |
@@ -651,7 +655,7 @@ | ||
651 | 655 | return r; |
652 | 656 | } |
653 | 657 | |
654 | -UINT _GetPrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, INT nDefault, LPCWSTR lpFileName) | |
658 | +UINT WINAPI _GetPrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, INT nDefault, LPCWSTR lpFileName) | |
655 | 659 | { |
656 | 660 | if (pGetPrivateProfileIntW != NULL) { |
657 | 661 | return pGetPrivateProfileIntW(lpAppName, lpKeyName, nDefault, lpFileName); |
@@ -667,7 +671,7 @@ | ||
667 | 671 | return r; |
668 | 672 | } |
669 | 673 | |
670 | -BOOL _CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, | |
674 | +BOOL WINAPI _CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, | |
671 | 675 | LPSECURITY_ATTRIBUTES lpProcessAttributes, |
672 | 676 | LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, |
673 | 677 | DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, |
@@ -716,7 +720,7 @@ | ||
716 | 720 | return r; |
717 | 721 | } |
718 | 722 | |
719 | -BOOL _CopyFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, BOOL bFailIfExists) | |
723 | +BOOL WINAPI _CopyFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, BOOL bFailIfExists) | |
720 | 724 | { |
721 | 725 | if (pCopyFileW != NULL) { |
722 | 726 | return pCopyFileW(lpExistingFileName, lpNewFileName, bFailIfExists); |
@@ -729,7 +733,7 @@ | ||
729 | 733 | return r; |
730 | 734 | } |
731 | 735 | |
732 | -BOOL _DeleteFileW(LPCWSTR lpFileName) | |
736 | +BOOL WINAPI _DeleteFileW(LPCWSTR lpFileName) | |
733 | 737 | { |
734 | 738 | if (pDeleteFileW != NULL) { |
735 | 739 | return pDeleteFileW(lpFileName); |
@@ -740,7 +744,7 @@ | ||
740 | 744 | return r; |
741 | 745 | } |
742 | 746 | |
743 | -BOOL _MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName) | |
747 | +BOOL WINAPI _MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName) | |
744 | 748 | { |
745 | 749 | if (pMoveFileW != NULL) { |
746 | 750 | return pMoveFileW(lpExistingFileName, lpNewFileName); |
@@ -753,7 +757,7 @@ | ||
753 | 757 | return r; |
754 | 758 | } |
755 | 759 | |
756 | -HANDLE _CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, | |
760 | +HANDLE WINAPI _CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, | |
757 | 761 | LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, |
758 | 762 | HANDLE hTemplateFile) |
759 | 763 | { |
@@ -783,7 +787,7 @@ | ||
783 | 787 | ::MultiByteToWideChar(CP_ACP, 0, a->cAlternateFileName, _countof(a->cAlternateFileName), w->cAlternateFileName, _countof(w->cAlternateFileName)); |
784 | 788 | } |
785 | 789 | |
786 | -HANDLE _FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData) | |
790 | +HANDLE WINAPI _FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData) | |
787 | 791 | { |
788 | 792 | if (pFindFirstFileW != NULL) { |
789 | 793 | return pFindFirstFileW(lpFileName, lpFindFileData); |
@@ -797,7 +801,7 @@ | ||
797 | 801 | return handle; |
798 | 802 | } |
799 | 803 | |
800 | -BOOL _FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData) | |
804 | +BOOL WINAPI _FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData) | |
801 | 805 | { |
802 | 806 | if (pFindNextFileW != NULL) { |
803 | 807 | return pFindNextFileW(hFindFile, lpFindFileData); |
@@ -808,7 +812,7 @@ | ||
808 | 812 | return r; |
809 | 813 | } |
810 | 814 | |
811 | -BOOL _RemoveDirectoryW(LPCWSTR lpPathName) | |
815 | +BOOL WINAPI _RemoveDirectoryW(LPCWSTR lpPathName) | |
812 | 816 | { |
813 | 817 | if (pRemoveDirectoryW != NULL) { |
814 | 818 | return pRemoveDirectoryW(lpPathName); |
@@ -819,40 +823,47 @@ | ||
819 | 823 | return r; |
820 | 824 | } |
821 | 825 | |
822 | -DWORD _GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart) | |
826 | +DWORD WINAPI _GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart) | |
823 | 827 | { |
824 | 828 | if (pGetFullPathNameW != NULL) { |
825 | 829 | return pGetFullPathNameW(lpFileName, nBufferLength, lpBuffer, lpFilePart); |
826 | 830 | } |
827 | 831 | |
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); | |
834 | 835 | free(filenameA); |
835 | - return 0; | |
836 | + return r; | |
836 | 837 | } |
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; | |
847 | 847 | } |
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; | |
848 | 863 | } |
849 | - free(filenameA); | |
850 | - free(bufW); | |
851 | - | |
852 | - return r; | |
853 | 864 | } |
854 | 865 | |
855 | -HMODULE _LoadLibraryW(LPCWSTR lpLibFileName) | |
866 | +HMODULE WINAPI _LoadLibraryW(LPCWSTR lpLibFileName) | |
856 | 867 | { |
857 | 868 | if (pLoadLibraryW != NULL) { |
858 | 869 | return pLoadLibraryW(lpLibFileName); |
@@ -863,7 +874,7 @@ | ||
863 | 874 | return r; |
864 | 875 | } |
865 | 876 | |
866 | -DWORD _GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize) | |
877 | +DWORD WINAPI _GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize) | |
867 | 878 | { |
868 | 879 | if (pGetModuleFileNameW != NULL) { |
869 | 880 | return pGetModuleFileNameW(hModule, lpFilename, nSize); |
@@ -878,7 +889,7 @@ | ||
878 | 889 | return wlen - 1; // not including the terminating null character |
879 | 890 | } |
880 | 891 | |
881 | -DWORD _ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize) | |
892 | +DWORD WINAPI _ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize) | |
882 | 893 | { |
883 | 894 | if (pExpandEnvironmentStringsW != NULL) { |
884 | 895 | return pExpandEnvironmentStringsW(lpSrc, lpDst, nSize); |
@@ -895,7 +906,7 @@ | ||
895 | 906 | return r; |
896 | 907 | } |
897 | 908 | |
898 | -HMODULE _GetModuleHandleW(LPCWSTR lpModuleName) | |
909 | +HMODULE WINAPI _GetModuleHandleW(LPCWSTR lpModuleName) | |
899 | 910 | { |
900 | 911 | char *lpStringA = ToCharW(lpModuleName); |
901 | 912 | HMODULE h = GetModuleHandleA(lpStringA); |
@@ -903,7 +914,7 @@ | ||
903 | 914 | return h; |
904 | 915 | } |
905 | 916 | |
906 | -UINT _GetSystemDirectoryW(LPWSTR lpBuffer, UINT uSize) | |
917 | +UINT WINAPI _GetSystemDirectoryW(LPWSTR lpBuffer, UINT uSize) | |
907 | 918 | { |
908 | 919 | char buf[MAX_PATH]; |
909 | 920 | UINT r = GetSystemDirectoryA(buf, _countof(buf)); |
@@ -914,7 +925,7 @@ | ||
914 | 925 | return wlen - 1; // not including the terminating null character |
915 | 926 | } |
916 | 927 | |
917 | -DWORD _GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) | |
928 | +DWORD WINAPI _GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) | |
918 | 929 | { |
919 | 930 | if (pGetTempPathW != NULL) { |
920 | 931 | return pGetTempPathW(nBufferLength, lpBuffer); |
@@ -929,7 +940,7 @@ | ||
929 | 940 | return wlen - 1; // not including the terminating null character |
930 | 941 | } |
931 | 942 | |
932 | -UINT _GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString, UINT uUnique, LPWSTR lpTempFileName) | |
943 | +UINT WINAPI _GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString, UINT uUnique, LPWSTR lpTempFileName) | |
933 | 944 | { |
934 | 945 | if (pGetTempFileNameW != NULL) { |
935 | 946 | return pGetTempFileNameW(lpPathName, lpPrefixString, uUnique, lpTempFileName); |
@@ -93,82 +93,82 @@ | ||
93 | 93 | //HICON hBalloonIcon; // Vista+ |
94 | 94 | } TT_NOTIFYICONDATAW_V2; |
95 | 95 | |
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, | |
102 | 102 | int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, |
103 | 103 | 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); | |
116 | 116 | |
117 | 117 | // 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, | |
123 | 123 | 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, | |
127 | 127 | LPSECURITY_ATTRIBUTES lpProcessAttributes, |
128 | 128 | LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, |
129 | 129 | DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, |
130 | 130 | 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, | |
135 | 135 | LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, |
136 | 136 | 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); | |
148 | 148 | |
149 | 149 | // gdi32.lib |
150 | -int _AddFontResourceW(LPCWSTR lpFileName); | |
151 | -BOOL _RemoveFontResourceW(LPCWSTR lpFileName); | |
150 | +int WINAPI _AddFontResourceW(LPCWSTR lpFileName); | |
151 | +BOOL WINAPI _RemoveFontResourceW(LPCWSTR lpFileName); | |
152 | 152 | |
153 | 153 | // 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); | |
157 | 157 | |
158 | 158 | // Comdlg32.lib |
159 | -BOOL _GetOpenFileNameW(LPOPENFILENAMEW ofnW); | |
160 | -BOOL _GetSaveFileNameW(LPOPENFILENAMEW ofnW); | |
159 | +BOOL WINAPI _GetOpenFileNameW(LPOPENFILENAMEW ofnW); | |
160 | +BOOL WINAPI _GetSaveFileNameW(LPOPENFILENAMEW ofnW); | |
161 | 161 | |
162 | 162 | // 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); | |
167 | 167 | |
168 | -HWND _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate, | |
168 | +HWND WINAPI _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate, | |
169 | 169 | HWND hWndParent, DLGPROC lpDialogFunc, |
170 | 170 | LPARAM dwInitParam); |
171 | -INT_PTR _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent, | |
171 | +INT_PTR WINAPI _DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEA hDialogTemplate, HWND hWndParent, | |
172 | 172 | DLGPROC lpDialogFunc, LPARAM lParamInit); |
173 | 173 | |
174 | 174 | #ifdef __cplusplus |
@@ -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 |
@@ -40,7 +40,7 @@ | ||
40 | 40 | |
41 | 41 | #include "layer_for_unicode.h" |
42 | 42 | |
43 | -HPROPSHEETPAGE _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 psp) | |
43 | +HPROPSHEETPAGE WINAPI _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 psp) | |
44 | 44 | { |
45 | 45 | if (pCreatePropertySheetPageW != NULL) { |
46 | 46 | return pCreatePropertySheetPageW((LPCPROPSHEETPAGEW)psp); |
@@ -70,7 +70,7 @@ | ||
70 | 70 | // SDK: Windows Server 2003 R2 Platform SDK |
71 | 71 | // (Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1) |
72 | 72 | //INT_PTR _PropertySheetW(PROPSHEETHEADERW_V1 *psh) |
73 | -INT_PTR _PropertySheetW(PROPSHEETHEADERW *psh) | |
73 | +INT_PTR WINAPI _PropertySheetW(PROPSHEETHEADERW *psh) | |
74 | 74 | { |
75 | 75 | if (pPropertySheetW != NULL) { |
76 | 76 | return pPropertySheetW((PROPSHEETHEADERW *)psh); |
@@ -150,7 +150,7 @@ | ||
150 | 150 | return result; |
151 | 151 | } |
152 | 152 | |
153 | -BOOL _GetOpenFileNameW(LPOPENFILENAMEW ofnW) | |
153 | +BOOL WINAPI _GetOpenFileNameW(LPOPENFILENAMEW ofnW) | |
154 | 154 | { |
155 | 155 | if (pGetOpenFileNameW != NULL) { |
156 | 156 | return pGetOpenFileNameW(ofnW); |
@@ -159,7 +159,7 @@ | ||
159 | 159 | return GetOpenSaveFileNameA(GetOpenFileNameA, ofnW); |
160 | 160 | } |
161 | 161 | |
162 | -BOOL _GetSaveFileNameW(LPOPENFILENAMEW ofnW) | |
162 | +BOOL WINAPI _GetSaveFileNameW(LPOPENFILENAMEW ofnW) | |
163 | 163 | { |
164 | 164 | if (pGetSaveFileNameW != NULL) { |
165 | 165 | return pGetSaveFileNameW(ofnW); |
@@ -12,6 +12,11 @@ | ||
12 | 12 | ) |
13 | 13 | |
14 | 14 | if(SUPPORT_OLD_WINDOWS) |
15 | + target_link_libraries( | |
16 | + ${PACKAGE_NAME} | |
17 | + PRIVATE | |
18 | + layer_for_unicode | |
19 | + ) | |
15 | 20 | if(MSVC) |
16 | 21 | target_sources( |
17 | 22 | ${PACKAGE_NAME} |
@@ -60,6 +65,12 @@ | ||
60 | 65 | ) |
61 | 66 | |
62 | 67 | if(SUPPORT_OLD_WINDOWS) |
68 | + target_link_libraries( | |
69 | + ${PACKAGE_NAME_2} | |
70 | + PRIVATE | |
71 | + common_static | |
72 | + layer_for_unicode | |
73 | + ) | |
63 | 74 | if(MSVC) |
64 | 75 | target_sources( |
65 | 76 | ${PACKAGE_NAME_2} |
@@ -206,6 +206,17 @@ | ||
206 | 206 | |
207 | 207 | if(SUPPORT_OLD_WINDOWS) |
208 | 208 | 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() | |
209 | 220 | target_sources( |
210 | 221 | ${PACKAGE_NAME} |
211 | 222 | PRIVATE |
@@ -271,6 +282,8 @@ | ||
271 | 282 | /pdbaltpath:ttermpro.pdb |
272 | 283 | /map |
273 | 284 | ) |
285 | + else() | |
286 | + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /map") | |
274 | 287 | endif() |
275 | 288 | elseif(MINGW) |
276 | 289 | target_link_options( |
@@ -289,12 +302,31 @@ | ||
289 | 302 | ttptek |
290 | 303 | ${ONIGURUMA_LIB} |
291 | 304 | ${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 | |
293 | 321 | gdi32 |
294 | - comctl32 | |
295 | - ws2_32 | |
296 | 322 | imagehlp |
323 | + kernel32 | |
324 | + ole32 | |
325 | + oleaut32 | |
326 | + shell32 | |
327 | + user32 | |
297 | 328 | uuid |
329 | + ws2_32 | |
298 | 330 | ) |
299 | 331 | |
300 | 332 | install( |
@@ -17,6 +17,17 @@ | ||
17 | 17 | |
18 | 18 | if(SUPPORT_OLD_WINDOWS) |
19 | 19 | 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() | |
20 | 31 | target_sources( |
21 | 32 | ${PACKAGE_NAME} |
22 | 33 | PRIVATE |
@@ -88,6 +99,19 @@ | ||
88 | 99 | ${PACKAGE_NAME} |
89 | 100 | PRIVATE |
90 | 101 | 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 | |
91 | 115 | ole32 |
92 | 116 | setupapi |
93 | 117 | ) |
@@ -13,6 +13,17 @@ | ||
13 | 13 | |
14 | 14 | if(SUPPORT_OLD_WINDOWS) |
15 | 15 | 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() | |
16 | 27 | target_sources( |
17 | 28 | ${PACKAGE_NAME} |
18 | 29 | PRIVATE |
@@ -72,6 +83,15 @@ | ||
72 | 83 | ttpcmn |
73 | 84 | ) |
74 | 85 | |
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 | + | |
75 | 95 | install( |
76 | 96 | TARGETS ${PACKAGE_NAME} |
77 | 97 | RUNTIME |
@@ -34,6 +34,11 @@ | ||
34 | 34 | "teraterm\/common\/") |
35 | 35 | |
36 | 36 | if(SUPPORT_OLD_WINDOWS) |
37 | + target_link_libraries( | |
38 | + ${PACKAGE_NAME} | |
39 | + PRIVATE | |
40 | + layer_for_unicode | |
41 | + ) | |
37 | 42 | if(MSVC) |
38 | 43 | target_sources( |
39 | 44 | ${PACKAGE_NAME} |
@@ -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() |
@@ -1,8 +1,11 @@ | ||
1 | -project(ttssh) | |
1 | +set(PACKAGE_NAME "ttssh") | |
2 | 2 | |
3 | +project(${PACKAGE_NAME}) | |
4 | + | |
3 | 5 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") |
4 | 6 | |
5 | -set(SRC | |
7 | +add_executable( | |
8 | + ${PACKAGE_NAME} WIN32 | |
6 | 9 | resource.h |
7 | 10 | ttsecure.ico |
8 | 11 | ttssh.c |
@@ -9,7 +12,31 @@ | ||
9 | 12 | ttssh.rc |
10 | 13 | ) |
11 | 14 | |
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 . | |
15 | 42 | ) |
@@ -116,6 +116,17 @@ | ||
116 | 116 | |
117 | 117 | if(SUPPORT_OLD_WINDOWS) |
118 | 118 | 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() | |
119 | 130 | target_sources( |
120 | 131 | ${PACKAGE_NAME} |
121 | 132 | PRIVATE |
@@ -179,7 +190,19 @@ | ||
179 | 190 | argon2 |
180 | 191 | ${ZLIB_LIB} |
181 | 192 | ${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 | |
183 | 206 | ws2_32 |
184 | 207 | gdi32 |
185 | 208 | comdlg32 |