6#if defined(DART_HOST_OS_WINDOWS)
16#if !defined(PLATFORM_DISABLE_SOCKET)
26const char* Platform::executable_name_ =
nullptr;
27int Platform::script_index_ = 1;
28char** Platform::argv_ =
nullptr;
36 _set_invalid_parameter_handler(InvalidParameterHandler);
40 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
41 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
42 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
43 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
44 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
45 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
49 _set_error_mode(_OUT_TO_STDERR);
60 UINT new_mode = SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
61 if (
getenv(
"DART_SUPPRESS_WER") !=
nullptr) {
62 new_mode |= SEM_NOGPFAULTERRORBOX;
64 UINT existing_mode = SetErrorMode(new_mode);
65 SetErrorMode(new_mode | existing_mode);
67 SetExceptionHandler();
74 DartExceptionHandler(
struct _EXCEPTION_POINTERS* ExceptionInfo) {
75 if ((ExceptionInfo->ExceptionRecord->ExceptionCode ==
76 EXCEPTION_ACCESS_VIOLATION) ||
77 (ExceptionInfo->ExceptionRecord->ExceptionCode ==
78 EXCEPTION_ILLEGAL_INSTRUCTION)) {
80 "\n===== CRASH =====\n"
81 "ExceptionCode=%d, ExceptionFlags=%d, ExceptionAddress=%p\n",
82 ExceptionInfo->ExceptionRecord->ExceptionCode,
83 ExceptionInfo->ExceptionRecord->ExceptionFlags,
84 ExceptionInfo->ExceptionRecord->ExceptionAddress);
92 return EXCEPTION_CONTINUE_SEARCH;
95 static void SetExceptionHandler() {
96 SetUnhandledExceptionFilter(DartExceptionHandler);
100 static void InvalidParameterHandler(
const wchar_t* expression,
104 uintptr_t reserved) {
120 GetSystemInfo(&
info);
121 return info.dwNumberOfProcessors;
129 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
131static bool GetCurrentVersionDWord(
const wchar_t* field,
DWORD*
value) {
132 DWORD value_size =
sizeof(*value);
134 RRF_RT_REG_DWORD,
nullptr,
value, &value_size);
138static bool GetCurrentVersionString(
const wchar_t* field,
const char**
value) {
139 wchar_t wversion[256];
140 DWORD wversion_size =
sizeof(wversion);
142 RRF_RT_REG_SZ,
nullptr, wversion, &wversion_size);
150static const char* VersionNumber() {
154 if (!GetCurrentVersionDWord(
L"CurrentMajorVersionNumber", &major)) {
156 if (!GetCurrentVersionString(
L"CurrentVersion", &
version)) {
163 if (!GetCurrentVersionDWord(
L"CurrentMinorVersionNumber", &minor)) {
172 if (!GetCurrentVersionString(
L"ProductName", &
name)) {
177 const char* version_number = VersionNumber();
178 if (version_number ==
nullptr) {
184 if (!GetCurrentVersionString(
L"CurrentBuild", &
build)) {
189 const char*
kFormat =
"\"%s\" %s (Build %s)";
190 int len = snprintf(
nullptr, 0, kFormat,
name, version_number,
build);
205 wchar_t locale_name[LOCALE_NAME_MAX_LENGTH];
206 int result = GetUserDefaultLocaleName(locale_name, LOCALE_NAME_MAX_LENGTH);
214#if defined(PLATFORM_DISABLE_SOCKET)
221 const int HOSTNAME_MAXLENGTH = 256;
222 wchar_t hostname_w[HOSTNAME_MAXLENGTH];
223 if (GetHostNameW(hostname_w, HOSTNAME_MAXLENGTH) != 0) {
226 return WideCharToMultiByte(CP_UTF8, 0, hostname_w, -1,
buffer, buffer_length,
227 nullptr,
nullptr) != 0;
232 wchar_t* strings = GetEnvironmentStringsW();
233 if (strings ==
nullptr) {
236 wchar_t* tmp = strings;
238 while (*tmp !=
'\0') {
246 tmp += (wcslen(tmp) + 1);
252 for (intptr_t current = 0; current <
i;) {
257 tmp += (wcslen(tmp) + 1);
259 FreeEnvironmentStringsW(strings);
264 return executable_name_;
271 const int kTmpBufferSize = 32768;
272 wchar_t* tmp_buffer =
277 GetModuleFileNameW(
nullptr, tmp_buffer, kTmpBufferSize);
290 const int kTmpBufferSize = 32768;
291 wchar_t tmp_buffer[kTmpBufferSize];
293 GetModuleFileNameW(
nullptr, tmp_buffer, kTmpBufferSize);
297 WideToUtf8Scope wide_to_utf8_scope(tmp_buffer);
298 if (wide_to_utf8_scope.length() <= result_size) {
299 strncpy(
result, wide_to_utf8_scope.utf8(), result_size);
300 return wide_to_utf8_scope.length();
313 ::ExitProcess(exit_code);
322 ::ExitProcess(exit_code);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static void RestoreConfig()
static char * ScopedCStringFormatted(const char *format,...) PRINTF_ATTRIBUTE(1
static char * ScopedCString(intptr_t length)
static const char * GetCanonicalPath(Namespace *namespc, const char *path, char *dest=nullptr, int dest_size=0)
static char * WideToUtf8(wchar_t *wide, intptr_t len=-1, intptr_t *result_len=nullptr)
Dart_NativeFunction function
static constexpr int kCurrentVersion
bool InitOnce(char **error)
DART_EXPORT void Dart_PrepareToAbort()
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)
DART_EXPORT void Dart_DumpNativeStackTrace(void *context)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
#define HKEY_LOCAL_MACHINE
WINBASEAPI VOID WINAPI SetLastError(_In_ DWORD dwErrCode)
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)