[Ttssh2-commit] [9288] dllutil内のファイル名の扱いをすべてUnicodeに変更

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 5月 27日 (木) 23:15:12 JST


Revision: 9288
          https://osdn.net/projects/ttssh2/scm/svn/commits/9288
Author:   zmatsuo
Date:     2021-05-27 23:15:12 +0900 (Thu, 27 May 2021)
Log Message:
-----------
dllutil内のファイル名の扱いをすべてUnicodeに変更

- 変更前は TCHAR を使って切り替えられるようにしていた
- つねに Unicode扱いととした

Modified Paths:
--------------
    trunk/teraterm/common/compat_win.cpp
    trunk/teraterm/common/dllutil.cpp
    trunk/teraterm/common/dllutil.h
    trunk/teraterm/ttpset/ttset_keyboard_entry.c

-------------- next part --------------
Modified: trunk/teraterm/common/compat_win.cpp
===================================================================
--- trunk/teraterm/common/compat_win.cpp	2021-05-26 14:11:09 UTC (rev 9287)
+++ trunk/teraterm/common/compat_win.cpp	2021-05-27 14:15:12 UTC (rev 9288)
@@ -29,7 +29,6 @@
 /* compat_win */
 
 #include <windows.h>
-#include <tchar.h>
 #include <windns.h>
 
 #include "compat_win.h"
@@ -310,16 +309,16 @@
 };
 
 static const DllInfo DllInfos[] = {
-	{ _T("user32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_user32 },
-	{ _T("msimg32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_msimg32 },
-	{ _T("gdi32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_gdi32 },
-	{ _T("Shcore.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_Shcore },
-	{ _T("kernel32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_kernel32 },
-	{ _T("shell32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_shell32 },
-	{ _T("Comctl32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_comctl32 },
-	{ _T("hhctrl.ocx"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_hhctrl },
-	{ _T("comdlg32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_comdlg32 },
-	{ _T("dnsapi.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_dnsapi },
+	{ L"user32.dll", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_user32 },
+	{ L"msimg32.dll", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_msimg32 },
+	{ L"gdi32.dll", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_gdi32 },
+	{ L"Shcore.dll", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_Shcore },
+	{ L"kernel32.dll", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_kernel32 },
+	{ L"shell32.dll", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_shell32 },
+	{ L"Comctl32.dll", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_comctl32 },
+	{ L"hhctrl.ocx", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_hhctrl },
+	{ L"comdlg32.dll", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_comdlg32 },
+	{ L"dnsapi.dll", DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_dnsapi },
 	{},
 };
 

Modified: trunk/teraterm/common/dllutil.cpp
===================================================================
--- trunk/teraterm/common/dllutil.cpp	2021-05-26 14:11:09 UTC (rev 9287)
+++ trunk/teraterm/common/dllutil.cpp	2021-05-27 14:15:12 UTC (rev 9288)
@@ -27,7 +27,6 @@
  */
 
 #include <windows.h>
-#include <tchar.h>
 #include <assert.h>
 #if !defined(_CRTDBG_MAP_ALLOC)
 #define _CRTDBG_MAP_ALLOC
@@ -37,7 +36,7 @@
 #include "dllutil.h"
 
 typedef struct {
-	const TCHAR *dllName;
+	const wchar_t *dllName;
 	DLLLoadFlag LoadFlag;
 	HMODULE handle;
 	int refCount;
@@ -46,9 +45,9 @@
 static HandleList_t *HandleList;
 static int HandleListCount;
 
-static HMODULE GetHandle(const TCHAR *dllName, DLLLoadFlag LoadFlag)
+static HMODULE GetHandle(const wchar_t *dllName, DLLLoadFlag LoadFlag)
 {
-	TCHAR dllPath[MAX_PATH];
+	wchar_t dllPath[MAX_PATH];
 	HMODULE module;
 	int i;
 	HandleList_t *p;
@@ -55,7 +54,7 @@
 	int r;
 
 	if (LoadFlag == DLL_GET_MODULE_HANDLE) {
-		module = GetModuleHandle(dllName);
+		module = GetModuleHandleW(dllName);
 		assert(module != NULL);
 		return module;
 	}
@@ -63,7 +62,7 @@
 	// \x88ȑO\x82Ƀ\x8D\x81[\x83h\x82\xB5\x82\xBD?
 	p = HandleList;
 	for (i = 0; i < HandleListCount; i++) {
-		if (_tcscmp(p->dllName, dllName) == 0) {
+		if (wcscmp(p->dllName, dllName) == 0) {
 			p->refCount++;
 			return p->handle;
 		}
@@ -74,22 +73,22 @@
 	dllPath[0] = 0;
 	switch (LoadFlag) {
 	case DLL_LOAD_LIBRARY_SYSTEM:
-		r = GetSystemDirectory(dllPath, _countof(dllPath));
+		r = GetSystemDirectoryW(dllPath, _countof(dllPath));
 		assert(r != 0);
 		if (r == 0) return NULL;
 		break;
 	case DLL_LOAD_LIBRARY_CURRENT:
-		r = GetModuleFileName(NULL, dllPath, _countof(dllPath));
+		r = GetModuleFileNameW(NULL, dllPath, _countof(dllPath));
 		assert(r != 0);
 		if (r == 0) return NULL;
-		*_tcsrchr(dllPath, _T('\\')) = 0;
+		*wcsrchr(dllPath, L'\\') = 0;
 		break;
 	default:
 		return NULL;
 	}
-	_tcscat_s(dllPath, _countof(dllPath), _T("\\"));
-	_tcscat_s(dllPath, _countof(dllPath), dllName);
-	module = LoadLibrary(dllPath);
+	wcscat_s(dllPath, _countof(dllPath), L"\\");
+	wcscat_s(dllPath, _countof(dllPath), dllName);
+	module = LoadLibraryW(dllPath);
 	if (module == NULL) {
 		// \x91\xB6\x8D݂\xB5\x82Ȃ\xA2,dll\x82\xB6\x82\xE1\x82Ȃ\xA2?
 		return NULL;
@@ -99,7 +98,7 @@
 	HandleListCount++;
 	HandleList = (HandleList_t *)realloc(HandleList, sizeof(HandleList_t)*HandleListCount);
 	p = &HandleList[i];
-	p->dllName = _tcsdup(dllName);
+	p->dllName = wcsdup(dllName);
 	p->handle = module;
 	p->LoadFlag = LoadFlag;
 	p->refCount = 1;
@@ -106,7 +105,7 @@
 	return module;
 }
 
-static void FreeHandle(const TCHAR *dllName, DLLLoadFlag LoadFlag)
+static void FreeHandle(const wchar_t *dllName, DLLLoadFlag LoadFlag)
 {
 	int i;
 	HandleList_t *p;
@@ -119,7 +118,7 @@
 	// \x83\x8A\x83X\x83g\x82\xA9\x82\xE7\x8D폜\x82\xB7\x82\xE9
 	p = HandleList;
 	for (i = 0; i < HandleListCount; i++) {
-		if (_tcscmp(p->dllName, dllName) != 0) {
+		if (wcscmp(p->dllName, dllName) != 0) {
 			continue;
 		}
 
@@ -151,7 +150,7 @@
  * @retval	ERROR_FILE_NOT_FOUND	DLL\x82\xAA\x8C\xA9\x82‚\xA9\x82\xE7\x82Ȃ\xA2(\x95s\x90\xB3\x82ȃt\x83@\x83C\x83\x8B)
  * @retval	ERROR_PROC_NOT_FOUND	\x8A֐\x94\x83G\x83\x93\x83g\x83\x8A\x82\xAA\x8C\xA9\x82‚\xA9\x82\xE7\x82Ȃ\xA2
  */
-DWORD DLLGetApiAddress(const TCHAR *dllPath, DLLLoadFlag LoadFlag,
+DWORD DLLGetApiAddress(const wchar_t *dllPath, DLLLoadFlag LoadFlag,
 					   const char *ApiName, void **pFunc)
 {
 	HMODULE hDll = GetHandle(dllPath, LoadFlag);
@@ -176,7 +175,7 @@
  * @retval	ERROR_FILE_NOT_FOUND	DLL\x82\xAA\x8C\xA9\x82‚\xA9\x82\xE7\x82Ȃ\xA2(\x95s\x90\xB3\x82ȃt\x83@\x83C\x83\x8B)
  * @retval	ERROR_PROC_NOT_FOUND	\x8A֐\x94\x83G\x83\x93\x83g\x83\x8A\x82\xAA\x8C\xA9\x82‚\xA9\x82\xE7\x82Ȃ\xA2
  */
-DWORD DLLGetApiAddressFromList(const TCHAR *dllPath, DLLLoadFlag LoadFlag,
+DWORD DLLGetApiAddressFromList(const wchar_t *dllPath, DLLLoadFlag LoadFlag,
 							   DLLFuncFlag FuncFlag, const APIInfo *ApiInfo)
 {
 	HMODULE hDll = GetHandle(dllPath, LoadFlag);
@@ -233,7 +232,7 @@
 {
 	BOOL (WINAPI *pSetDefaultDllDirectories)(DWORD);
 	BOOL (WINAPI *pSetDllDirectoryA)(LPCSTR);
-	const TCHAR *kernel32 = _T("kernel32.dll");
+	const wchar_t *kernel32 = L"kernel32.dll";
 
 #if !defined(LOAD_LIBRARY_SEARCH_SYSTEM32)
 #define LOAD_LIBRARY_SEARCH_SYSTEM32        0x00000800
@@ -251,6 +250,7 @@
 	// SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82Ȃ\xAD\x82Ă\xE0
 	// SetDllDirectory() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82\xCD
 	// \x83J\x83\x8C\x83\x93\x83g\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xBE\x82\xAF\x82ł\xE0\x8C\x9F\x8D\xF5\x83p\x83X\x82\xA9\x82\xE7\x82͂\xB8\x82\xB5\x82Ă\xA8\x82\xAD\x81B
+	// \x83J\x83\x8C\x83\x93\x83g\x82\xF0\x8AO\x82\xB7(""\x82\xF0\x83Z\x83b\x83g\x82\xB7\x82\xE9)\x82\xBE\x82\xAF\x82Ȃ̂ŁAANSI\x94ł\xC5ok
 	DLLGetApiAddress(kernel32, DLL_GET_MODULE_HANDLE,
 					 "SetDllDirectoryA", (void **)&pSetDllDirectoryA);
 	if (pSetDllDirectoryA != NULL) {

Modified: trunk/teraterm/common/dllutil.h
===================================================================
--- trunk/teraterm/common/dllutil.h	2021-05-26 14:11:09 UTC (rev 9287)
+++ trunk/teraterm/common/dllutil.h	2021-05-27 14:15:12 UTC (rev 9288)
@@ -47,7 +47,7 @@
 } APIInfo;
 
 typedef struct {
-	const TCHAR *DllName;
+	const wchar_t *DllName;
 	DLLLoadFlag LoadFlag;
 	DLLFuncFlag FuncFlag;
 	const APIInfo *APIInfoPtr;
@@ -56,9 +56,9 @@
 void DLLInit();
 void DLLExit();
 void DLLGetApiAddressFromLists(const DllInfo *dllInfos);
-DWORD DLLGetApiAddressFromList(const TCHAR *dllPath, DLLLoadFlag LoadFlag,
+DWORD DLLGetApiAddressFromList(const wchar_t *dllPath, DLLLoadFlag LoadFlag,
 							   DLLFuncFlag FuncFlag, const APIInfo *ApiInfo);
-DWORD DLLGetApiAddress(const TCHAR *dllPath, DLLLoadFlag LoadFlag,
+DWORD DLLGetApiAddress(const wchar_t *dllPath, DLLLoadFlag LoadFlag,
 					   const char *ApiName, void **pFunc);
 
 #ifdef __cplusplus

Modified: trunk/teraterm/ttpset/ttset_keyboard_entry.c
===================================================================
--- trunk/teraterm/ttpset/ttset_keyboard_entry.c	2021-05-26 14:11:09 UTC (rev 9287)
+++ trunk/teraterm/ttpset/ttset_keyboard_entry.c	2021-05-27 14:15:12 UTC (rev 9288)
@@ -35,7 +35,7 @@
 void PASCAL ReadKeyboardCnf(PCHAR FNameA, PKeyMap KeyMap, BOOL ShowWarning)
 {
 	void (*ReadKeyboardCnfExe)(PCHAR FNameA, PKeyMap KeyMap, BOOL ShowWarning);
-	DWORD r = DLLGetApiAddress("ttermpro.exe", DLL_LOAD_LIBRARY_CURRENT, "ReadKeyboardCnfExe", (void **)&ReadKeyboardCnfExe);
+	DWORD r = DLLGetApiAddress(L"ttermpro.exe", DLL_LOAD_LIBRARY_CURRENT, "ReadKeyboardCnfExe", (void **)&ReadKeyboardCnfExe);
 	if (r != NO_ERROR) {
 		return;
 	}


Ttssh2-commit メーリングリストの案内
Back to archive index