mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-28 06:56:16 +01:00
Merge branch 'fix/always-use-windows-unicode-apis' into 'master'
gwin32: Always use unicode APIs See merge request GNOME/glib!1848
This commit is contained in:
commit
1810761d8e
@ -131,6 +131,9 @@ _g_win32_mount_new (GVolumeMonitor *volume_monitor,
|
|||||||
{
|
{
|
||||||
GWin32Mount *mount;
|
GWin32Mount *mount;
|
||||||
const gchar *drive = path; //fixme
|
const gchar *drive = path; //fixme
|
||||||
|
WCHAR *drive_utf16;
|
||||||
|
|
||||||
|
drive_utf16 = g_utf8_to_utf16 (drive, -1, NULL, NULL, NULL);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* No volume for mount: Ignore internal things */
|
/* No volume for mount: Ignore internal things */
|
||||||
@ -141,7 +144,7 @@ _g_win32_mount_new (GVolumeMonitor *volume_monitor,
|
|||||||
mount = g_object_new (G_TYPE_WIN32_MOUNT, NULL);
|
mount = g_object_new (G_TYPE_WIN32_MOUNT, NULL);
|
||||||
mount->volume_monitor = volume_monitor != NULL ? g_object_ref (volume_monitor) : NULL;
|
mount->volume_monitor = volume_monitor != NULL ? g_object_ref (volume_monitor) : NULL;
|
||||||
mount->mount_path = g_strdup (path);
|
mount->mount_path = g_strdup (path);
|
||||||
mount->drive_type = GetDriveType (drive);
|
mount->drive_type = GetDriveTypeW (drive_utf16);
|
||||||
mount->can_eject = FALSE; /* TODO */
|
mount->can_eject = FALSE; /* TODO */
|
||||||
mount->name = _win32_get_displayname (drive);
|
mount->name = _win32_get_displayname (drive);
|
||||||
|
|
||||||
@ -151,6 +154,9 @@ _g_win32_mount_new (GVolumeMonitor *volume_monitor,
|
|||||||
if (volume != NULL)
|
if (volume != NULL)
|
||||||
_g_win32_volume_set_mount (volume, mount);
|
_g_win32_volume_set_mount (volume, mount);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
g_free (drive_utf16);
|
||||||
|
|
||||||
return mount;
|
return mount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2484,7 +2484,7 @@ g_win32_registry_key_watch (GWin32RegistryKey *key,
|
|||||||
if (g_once_init_enter (&nt_notify_change_multiple_keys))
|
if (g_once_init_enter (&nt_notify_change_multiple_keys))
|
||||||
{
|
{
|
||||||
NtNotifyChangeMultipleKeysFunc func;
|
NtNotifyChangeMultipleKeysFunc func;
|
||||||
HMODULE ntdll = GetModuleHandle ("ntdll.dll");
|
HMODULE ntdll = GetModuleHandleW (L"ntdll.dll");
|
||||||
|
|
||||||
if (ntdll != NULL)
|
if (ntdll != NULL)
|
||||||
func = (NtNotifyChangeMultipleKeysFunc) GetProcAddress (ntdll, "NtNotifyChangeMultipleKeys");
|
func = (NtNotifyChangeMultipleKeysFunc) GetProcAddress (ntdll, "NtNotifyChangeMultipleKeys");
|
||||||
|
@ -68,13 +68,13 @@ get_viewable_logical_drives (void)
|
|||||||
DWORD no_drives;
|
DWORD no_drives;
|
||||||
gboolean hklm_present = FALSE;
|
gboolean hklm_present = FALSE;
|
||||||
|
|
||||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
|
if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
|
||||||
"Software\\Microsoft\\Windows\\"
|
L"Software\\Microsoft\\Windows\\"
|
||||||
"CurrentVersion\\Policies\\Explorer",
|
L"CurrentVersion\\Policies\\Explorer",
|
||||||
0, KEY_READ, &key) == ERROR_SUCCESS)
|
0, KEY_READ, &key) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (RegQueryValueEx (key, "NoDrives", NULL, &var_type,
|
if (RegQueryValueExW (key, L"NoDrives", NULL, &var_type,
|
||||||
(LPBYTE) &no_drives, &no_drives_size) == ERROR_SUCCESS)
|
(LPBYTE) &no_drives, &no_drives_size) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
/* We need the bits that are set in viewable_drives, and
|
/* We need the bits that are set in viewable_drives, and
|
||||||
* unset in no_drives.
|
* unset in no_drives.
|
||||||
@ -88,13 +88,13 @@ get_viewable_logical_drives (void)
|
|||||||
/* If the key is present in HKLM then the one in HKCU should be ignored */
|
/* If the key is present in HKLM then the one in HKCU should be ignored */
|
||||||
if (!hklm_present)
|
if (!hklm_present)
|
||||||
{
|
{
|
||||||
if (RegOpenKeyEx (HKEY_CURRENT_USER,
|
if (RegOpenKeyExW (HKEY_CURRENT_USER,
|
||||||
"Software\\Microsoft\\Windows\\"
|
L"Software\\Microsoft\\Windows\\"
|
||||||
"CurrentVersion\\Policies\\Explorer",
|
L"CurrentVersion\\Policies\\Explorer",
|
||||||
0, KEY_READ, &key) == ERROR_SUCCESS)
|
0, KEY_READ, &key) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (RegQueryValueEx (key, "NoDrives", NULL, &var_type,
|
if (RegQueryValueExW (key, L"NoDrives", NULL, &var_type,
|
||||||
(LPBYTE) &no_drives, &no_drives_size) == ERROR_SUCCESS)
|
(LPBYTE) &no_drives, &no_drives_size) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
viewable_drives = viewable_drives & ~no_drives;
|
viewable_drives = viewable_drives & ~no_drives;
|
||||||
}
|
}
|
||||||
|
@ -39,20 +39,20 @@ static void
|
|||||||
lookup_funcs (void)
|
lookup_funcs (void)
|
||||||
{
|
{
|
||||||
HMODULE winhttp = NULL;
|
HMODULE winhttp = NULL;
|
||||||
char winhttp_dll[MAX_PATH + 100];
|
WCHAR winhttp_dll[MAX_PATH + 100];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (lookup_done)
|
if (lookup_done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
n = GetSystemDirectory (winhttp_dll, MAX_PATH);
|
n = GetSystemDirectoryW (winhttp_dll, MAX_PATH);
|
||||||
if (n > 0 && n < MAX_PATH)
|
if (n > 0 && n < MAX_PATH)
|
||||||
{
|
{
|
||||||
if (winhttp_dll[n-1] != '\\' &&
|
if (winhttp_dll[n-1] != L'\\' &&
|
||||||
winhttp_dll[n-1] != '/')
|
winhttp_dll[n-1] != L'/')
|
||||||
strcat (winhttp_dll, "\\");
|
wcscat (winhttp_dll, L"\\");
|
||||||
strcat (winhttp_dll, "winhttp.dll");
|
wcscat (winhttp_dll, L"winhttp.dll");
|
||||||
winhttp = LoadLibrary (winhttp_dll);
|
winhttp = LoadLibraryW (winhttp_dll);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (winhttp != NULL)
|
if (winhttp != NULL)
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
#include "gtypes.h"
|
#include "gtypes.h"
|
||||||
#include "gmain.h"
|
#include "gmain.h"
|
||||||
#include "gprintfint.h"
|
#include "gprintfint.h"
|
||||||
|
#include "gunicode.h"
|
||||||
#include "gutils.h"
|
#include "gutils.h"
|
||||||
|
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
@ -206,9 +207,20 @@ g_on_error_query (const gchar *prg_name)
|
|||||||
/* MessageBox is allowed on UWP apps only when building against
|
/* MessageBox is allowed on UWP apps only when building against
|
||||||
* the debug CRT, which will set -D_DEBUG */
|
* the debug CRT, which will set -D_DEBUG */
|
||||||
#if defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP)
|
#if defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP)
|
||||||
MessageBox (NULL, "g_on_error_query called, program terminating",
|
{
|
||||||
(prg_name && *prg_name) ? prg_name : NULL,
|
WCHAR *caption = NULL;
|
||||||
MB_OK|MB_ICONERROR);
|
|
||||||
|
if (prg_name && *prg_name)
|
||||||
|
{
|
||||||
|
caption = g_utf8_to_utf16 (prg_name, -1, NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBoxW (NULL, L"g_on_error_query called, program terminating",
|
||||||
|
caption,
|
||||||
|
MB_OK|MB_ICONERROR);
|
||||||
|
|
||||||
|
g_free (caption);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
printf ("g_on_error_query called, program '%s' terminating\n",
|
printf ("g_on_error_query called, program '%s' terminating\n",
|
||||||
(prg_name && *prg_name) ? prg_name : "(null)");
|
(prg_name && *prg_name) ? prg_name : "(null)");
|
||||||
|
@ -1395,10 +1395,14 @@ g_logv (const gchar *log_domain,
|
|||||||
#if defined(G_OS_WIN32) && (defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP))
|
#if defined(G_OS_WIN32) && (defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP))
|
||||||
if (win32_keep_fatal_message)
|
if (win32_keep_fatal_message)
|
||||||
{
|
{
|
||||||
gchar *locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
|
WCHAR *wide_msg;
|
||||||
|
|
||||||
MessageBox (NULL, locale_msg, NULL,
|
wide_msg = g_utf8_to_utf16 (fatal_msg_buf, -1, NULL, NULL, NULL);
|
||||||
MB_ICONERROR|MB_SETFOREGROUND);
|
|
||||||
|
MessageBoxW (NULL, wide_msg, NULL,
|
||||||
|
MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
|
|
||||||
|
g_free (wide_msg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2789,12 +2793,13 @@ handled:
|
|||||||
#if defined(G_OS_WIN32) && (defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP))
|
#if defined(G_OS_WIN32) && (defined(_DEBUG) || !defined(G_WINAPI_ONLY_APP))
|
||||||
if (!g_test_initialized ())
|
if (!g_test_initialized ())
|
||||||
{
|
{
|
||||||
gchar *locale_msg = NULL;
|
WCHAR *wide_msg;
|
||||||
|
|
||||||
locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
|
wide_msg = g_utf8_to_utf16 (fatal_msg_buf, -1, NULL, NULL, NULL);
|
||||||
MessageBox (NULL, locale_msg, NULL,
|
|
||||||
MB_ICONERROR | MB_SETFOREGROUND);
|
MessageBoxW (NULL, wide_msg, NULL, MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
g_free (locale_msg);
|
|
||||||
|
g_free (wide_msg);
|
||||||
}
|
}
|
||||||
#endif /* !G_OS_WIN32 */
|
#endif /* !G_OS_WIN32 */
|
||||||
|
|
||||||
|
@ -1964,7 +1964,7 @@ load_user_special_dirs (void)
|
|||||||
|
|
||||||
wchar_t *wcp;
|
wchar_t *wcp;
|
||||||
|
|
||||||
p_SHGetKnownFolderPath = (t_SHGetKnownFolderPath) GetProcAddress (GetModuleHandle ("shell32.dll"),
|
p_SHGetKnownFolderPath = (t_SHGetKnownFolderPath) GetProcAddress (GetModuleHandleW (L"shell32.dll"),
|
||||||
"SHGetKnownFolderPath");
|
"SHGetKnownFolderPath");
|
||||||
|
|
||||||
g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
|
g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
|
||||||
@ -2295,26 +2295,14 @@ get_module_for_address (gconstpointer address)
|
|||||||
{
|
{
|
||||||
/* Holds the g_utils_global lock */
|
/* Holds the g_utils_global lock */
|
||||||
|
|
||||||
static gboolean beenhere = FALSE;
|
|
||||||
typedef BOOL (WINAPI *t_GetModuleHandleExA) (DWORD, LPCTSTR, HMODULE *);
|
|
||||||
static t_GetModuleHandleExA p_GetModuleHandleExA = NULL;
|
|
||||||
HMODULE hmodule = NULL;
|
HMODULE hmodule = NULL;
|
||||||
|
|
||||||
if (!address)
|
if (!address)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!beenhere)
|
if (!GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
|
||||||
{
|
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
|
||||||
p_GetModuleHandleExA =
|
address, &hmodule))
|
||||||
(t_GetModuleHandleExA) GetProcAddress (GetModuleHandle ("kernel32.dll"),
|
|
||||||
"GetModuleHandleExA");
|
|
||||||
beenhere = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_GetModuleHandleExA == NULL ||
|
|
||||||
!(*p_GetModuleHandleExA) (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
|
|
||||||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
|
|
||||||
address, &hmodule))
|
|
||||||
{
|
{
|
||||||
MEMORY_BASIC_INFORMATION mbi;
|
MEMORY_BASIC_INFORMATION mbi;
|
||||||
VirtualQuery (address, &mbi, sizeof (mbi));
|
VirtualQuery (address, &mbi, sizeof (mbi));
|
||||||
|
@ -107,12 +107,15 @@ g_win32_ftruncate (gint fd,
|
|||||||
gchar *
|
gchar *
|
||||||
g_win32_getlocale (void)
|
g_win32_getlocale (void)
|
||||||
{
|
{
|
||||||
|
gchar *result;
|
||||||
LCID lcid;
|
LCID lcid;
|
||||||
LANGID langid;
|
LANGID langid;
|
||||||
const gchar *ev;
|
const gchar *ev;
|
||||||
gint primary, sub;
|
gint primary, sub;
|
||||||
char iso639[10];
|
WCHAR iso639[10];
|
||||||
char iso3166[10];
|
gchar *iso639_utf8;
|
||||||
|
WCHAR iso3166[10];
|
||||||
|
gchar *iso3166_utf8;
|
||||||
const gchar *script = NULL;
|
const gchar *script = NULL;
|
||||||
|
|
||||||
/* Let the user override the system settings through environment
|
/* Let the user override the system settings through environment
|
||||||
@ -127,8 +130,8 @@ g_win32_getlocale (void)
|
|||||||
|
|
||||||
lcid = GetThreadLocale ();
|
lcid = GetThreadLocale ();
|
||||||
|
|
||||||
if (!GetLocaleInfo (lcid, LOCALE_SISO639LANGNAME, iso639, sizeof (iso639)) ||
|
if (!GetLocaleInfoW (lcid, LOCALE_SISO639LANGNAME, iso639, sizeof (iso639)) ||
|
||||||
!GetLocaleInfo (lcid, LOCALE_SISO3166CTRYNAME, iso3166, sizeof (iso3166)))
|
!GetLocaleInfoW (lcid, LOCALE_SISO3166CTRYNAME, iso3166, sizeof (iso3166)))
|
||||||
return g_strdup ("C");
|
return g_strdup ("C");
|
||||||
|
|
||||||
/* Strip off the sorting rules, keep only the language part. */
|
/* Strip off the sorting rules, keep only the language part. */
|
||||||
@ -173,7 +176,16 @@ g_win32_getlocale (void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return g_strconcat (iso639, "_", iso3166, script, NULL);
|
|
||||||
|
iso639_utf8 = g_utf16_to_utf8 (iso639, -1, NULL, NULL, NULL);
|
||||||
|
iso3166_utf8 = g_utf16_to_utf8 (iso3166, -1, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
result = g_strconcat (iso639_utf8, "_", iso3166_utf8, script, NULL);
|
||||||
|
|
||||||
|
g_free (iso3166_utf8);
|
||||||
|
g_free (iso639_utf8);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1062,10 +1074,11 @@ g_win32_veh_handler (PEXCEPTION_POINTERS ExceptionInfo)
|
|||||||
{
|
{
|
||||||
EXCEPTION_RECORD *er;
|
EXCEPTION_RECORD *er;
|
||||||
char debugger[MAX_PATH + 1];
|
char debugger[MAX_PATH + 1];
|
||||||
|
WCHAR *debugger_utf16;
|
||||||
const char *debugger_env = NULL;
|
const char *debugger_env = NULL;
|
||||||
const char *catch_list;
|
const char *catch_list;
|
||||||
gboolean catch = FALSE;
|
gboolean catch = FALSE;
|
||||||
STARTUPINFO si;
|
STARTUPINFOW si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
HANDLE event;
|
HANDLE event;
|
||||||
SECURITY_ATTRIBUTES sa;
|
SECURITY_ATTRIBUTES sa;
|
||||||
@ -1165,11 +1178,13 @@ g_win32_veh_handler (PEXCEPTION_POINTERS ExceptionInfo)
|
|||||||
CloseHandle (event);
|
CloseHandle (event);
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
debugger[MAX_PATH] = '\0';
|
||||||
|
|
||||||
|
debugger_utf16 = g_utf8_to_utf16 (debugger, -1, NULL, NULL, NULL);
|
||||||
|
|
||||||
/* Run the debugger */
|
/* Run the debugger */
|
||||||
debugger[MAX_PATH] = '\0';
|
if (0 != CreateProcessW (NULL,
|
||||||
if (0 != CreateProcessA (NULL,
|
debugger_utf16,
|
||||||
debugger,
|
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
TRUE,
|
TRUE,
|
||||||
@ -1190,6 +1205,8 @@ g_win32_veh_handler (PEXCEPTION_POINTERS ExceptionInfo)
|
|||||||
WaitForSingleObject (event, 60000);
|
WaitForSingleObject (event, 60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (debugger_utf16);
|
||||||
|
|
||||||
CloseHandle (event);
|
CloseHandle (event);
|
||||||
|
|
||||||
/* Now the debugger is present, and we can try
|
/* Now the debugger is present, and we can try
|
||||||
|
Loading…
Reference in New Issue
Block a user