Changeset 278322 in webkit
- Timestamp:
- Jun 1, 2021, 1:04:18 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
win/DLLLauncher/DLLLauncherMain.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r278318 r278322 1 2021-06-01 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 Sync Tools/win/DLLLauncher/DLLLauncherMain.cpp with Source/JavaScriptCore/shell/DLLLauncherMain.cpp 4 https://bugs.webkit.org/show_bug.cgi?id=226451 5 6 Reviewed by Don Olmstead. 7 8 Tools/win/DLLLauncher/DLLLauncherMain.cpp and 9 Source/JavaScriptCore/shell/DLLLauncherMain.cpp should be same. 10 But, r231403 changed only JavaScriptCore's one. r178530 changed 11 only Tools's one. 12 13 r178530 added flags for Debug CRT Heap. However, WebKit isn't 14 using Debug CRT Heap nowadays. And, using _CRTDBG_CHECK_ALWAYS_DF 15 flag makes WebKit unbearably slow. 16 17 Just copied JavaScriptCore's one to overwrite Tools's one. 18 19 * win/DLLLauncher/DLLLauncherMain.cpp: 20 (copyEnvironmentVariable): 21 (getStringValue): 22 (applePathFromRegistry): 23 (appleApplicationSupportDirectory): 24 (iTunesDirectory): 25 (prependPath): 26 (fatalError): 27 (directoryExists): 28 (modifyPath): 29 (getLastErrorString): 30 (wWinMain): 31 1 32 2021-06-01 Chris Dumez <cdumez@apple.com> 2 33 -
trunk/Tools/win/DLLLauncher/DLLLauncherMain.cpp
r274769 r278322 36 36 #include <windows.h> 37 37 38 using namespace std;39 40 38 static void enableTerminationOnHeapCorruption() 41 39 { … … 44 42 } 45 43 46 static wstring copyEnvironmentVariable(constwstring& variable)44 static std::wstring copyEnvironmentVariable(const std::wstring& variable) 47 45 { 48 46 DWORD length = ::GetEnvironmentVariableW(variable.c_str(), 0, 0); 49 47 if (!length) 50 return wstring();51 vector<wchar_t> buffer(length);48 return std::wstring(); 49 std::vector<wchar_t> buffer(length); 52 50 if (!GetEnvironmentVariable(variable.c_str(), &buffer[0], buffer.size()) || !buffer[0]) 53 return wstring();51 return std::wstring(); 54 52 return &buffer[0]; 55 53 } 56 54 57 55 #if !defined(WIN_CAIRO) 58 static wstring getStringValue(HKEY key, constwstring& valueName)56 static std::wstring getStringValue(HKEY key, const std::wstring& valueName) 59 57 { 60 58 DWORD type = 0; 61 59 DWORD bufferSize = 0; 62 60 if (::RegQueryValueExW(key, valueName.c_str(), 0, &type, 0, &bufferSize) != ERROR_SUCCESS || type != REG_SZ) 63 return wstring();64 65 vector<wchar_t> buffer(bufferSize / sizeof(wchar_t));61 return std::wstring(); 62 63 std::vector<wchar_t> buffer(bufferSize / sizeof(wchar_t)); 66 64 if (::RegQueryValueExW(key, valueName.c_str(), 0, &type, reinterpret_cast<LPBYTE>(&buffer[0]), &bufferSize) != ERROR_SUCCESS) 67 return wstring();65 return std::wstring(); 68 66 69 67 return &buffer[0]; 70 68 } 71 69 72 static wstring applePathFromRegistry(const wstring& key, constwstring& value)70 static std::wstring applePathFromRegistry(const std::wstring& key, const std::wstring& value) 73 71 { 74 72 HKEY applePathKey = 0; 75 73 if (::RegOpenKeyExW(HKEY_LOCAL_MACHINE, key.c_str(), 0, KEY_READ, &applePathKey) != ERROR_SUCCESS) 76 return wstring();77 wstring path = getStringValue(applePathKey, value);74 return std::wstring(); 75 std::wstring path = getStringValue(applePathKey, value); 78 76 ::RegCloseKey(applePathKey); 79 77 return path; 80 78 } 81 79 82 static wstring appleApplicationSupportDirectory()80 static std::wstring appleApplicationSupportDirectory() 83 81 { 84 82 return applePathFromRegistry(L"SOFTWARE\\Apple Inc.\\Apple Application Support", L"InstallDir"); 85 83 } 86 84 87 static wstring iTunesDirectory()85 static std::wstring iTunesDirectory() 88 86 { 89 87 return applePathFromRegistry(L"SOFTWARE\\Apple Computer, Inc.\\iTunes\\", L"InstallDir"); 90 88 } 91 89 92 static bool prependPath(const wstring& directoryToPrepend)93 { 94 wstring pathVariable = L"PATH";95 wstring oldPath = copyEnvironmentVariable(pathVariable);96 wstring newPath = directoryToPrepend + L';' + oldPath;90 static bool prependPath(const std::wstring& directoryToPrepend) 91 { 92 std::wstring pathVariable = L"PATH"; 93 std::wstring oldPath = copyEnvironmentVariable(pathVariable); 94 std::wstring newPath = directoryToPrepend + L';' + oldPath; 97 95 return ::SetEnvironmentVariableW(pathVariable.c_str(), newPath.c_str()); 98 96 } 99 97 #endif 100 98 101 static int fatalError(const wstring& programName, constwstring& message)102 { 103 wstring caption = programName + L" can't open.";99 static int fatalError(const std::wstring& programName, const std::wstring& message) 100 { 101 std::wstring caption = programName + L" can't open."; 104 102 #if USE_CONSOLE_ENTRY_POINT 105 103 fwprintf(stderr, L"%s\n%s\n", caption.c_str(), message.c_str()); … … 110 108 } 111 109 112 static bool directoryExists(const wstring& path)110 static bool directoryExists(const std::wstring& path) 113 111 { 114 112 DWORD attrib = ::GetFileAttributes(path.c_str()); … … 117 115 } 118 116 119 static bool modifyPath(const wstring& programName)117 static bool modifyPath(const std::wstring& programName) 120 118 { 121 119 #ifdef WIN_CAIRO 122 120 123 wstring pathWinCairo = copyEnvironmentVariable(L"WEBKIT_LIBRARIES");121 std::wstring pathWinCairo = copyEnvironmentVariable(L"WEBKIT_LIBRARIES"); 124 122 if (!directoryExists(pathWinCairo)) 125 123 return true; … … 136 134 137 135 #else 138 auto modifyPathWith = [&] (const wstring& pathPrefix) {136 auto modifyPathWith = [&] (const std::wstring& pathPrefix) { 139 137 if (!prependPath(pathPrefix)) { 140 138 fatalError(programName, L"Failed to modify PATH environment variable."); … … 144 142 }; 145 143 146 const wstring& applicationSupportPathPrefix = appleApplicationSupportDirectory();144 const std::wstring& applicationSupportPathPrefix = appleApplicationSupportDirectory(); 147 145 if (directoryExists(applicationSupportPathPrefix)) 148 146 return modifyPathWith(applicationSupportPathPrefix); 149 147 150 const wstring& iTunesPathPrefix = iTunesDirectory();148 const std::wstring& iTunesPathPrefix = iTunesDirectory(); 151 149 if (directoryExists(iTunesPathPrefix)) 152 150 return modifyPathWith(iTunesPathPrefix); … … 157 155 } 158 156 159 static wstring getLastErrorString(HRESULT hr)157 static std::wstring getLastErrorString(HRESULT hr) 160 158 { 161 159 static const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; … … 175 173 int main(int argc, const char* argv[]) 176 174 #else 177 int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpstrCmdLine, _In_ int nCmdShow) 178 #endif 179 { 180 #ifdef _CRTDBG_MAP_ALLOC 181 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 182 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); 183 #endif 184 185 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF); 186 175 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpstrCmdLine, int nCmdShow) 176 #endif 177 { 187 178 enableTerminationOnHeapCorruption(); 188 179 … … 194 185 ::PathRemoveExtensionW(exePath); 195 186 196 wstring programName = ::PathFindFileNameW(exePath);187 std::wstring programName = ::PathFindFileNameW(exePath); 197 188 198 189 if (!modifyPath(programName)) … … 200 191 201 192 // Load our corresponding DLL. 202 wstring dllName = programName + L"Lib.dll";193 std::wstring dllName = programName + L"Lib.dll"; 203 194 if (!::PathRemoveFileSpecW(exePath)) 204 195 return fatalError(programName, L"::PathRemoveFileSpecW failed: " + getLastErrorString(::GetLastError())); … … 207 198 HMODULE module = ::LoadLibraryW(exePath); 208 199 if (!module) 209 return fatalError(programName, L"::LoadLibraryW failed: \npath=" + wstring(exePath) + L"\n" + getLastErrorString(::GetLastError()));200 return fatalError(programName, L"::LoadLibraryW failed: \npath=" + std::wstring(exePath) + L"\n" + getLastErrorString(::GetLastError())); 210 201 211 202 #if USE_CONSOLE_ENTRY_POINT
Note:
See TracChangeset
for help on using the changeset viewer.