[wine-zh] Re: Full Stack on Wine 计划 - 初始化 Wine 注册表时区相关的键值

  • From: Huanjie Liu <micking.liu@xxxxxxxxx>
  • To: Qian Hong <fracting@xxxxxxxxx>
  • Date: Mon, 4 May 2015 14:07:00 +0800

Hi

在 2015年5月3日 上午8:53,Qian Hong <fracting@xxxxxxxxx>写道:

Hi 大家好


预告下一个任务:

Windows 和 Wine 下,有一组时区相关的注册表路径:


[HKLM\\System\\CurrentControlSet\\Control\\TimeZoneInformation]

该路径下有 StandardName,TimeZoneKeyName 等键值。

例如,在中文的 Windows 下,"TimeZoneKeyName" 默认是 "China Standard Time"

但是,Wine 只模拟了该注册表键,没有模拟该注册表值,后果就是一些依赖该注册表值的程序不能正常运行。


MSYS2 的 tzset 工具就是一个依赖该注册表键值的程序。
在 MSYS2 on Windows 中,运行 `$ tzset`, 输出应该是 Asia/Shanghai
或者其他跟你的locale设置对应的地区。
而在 MSYS2 on Wine中,输出却是tzset: can't find matching POSIX timezone for
Windows timezone ""

要解决这个问题,笨办法是,在Wine的注册表(wine regedit)中手工地将 TimeZoneKeyName 设置为 "China
Standard Time"
或者其他合法的值。但是为了一劳永逸地解决这个问题,我们要在Wine初始化的时候,根据Linux当前的时区设置自动设置TimeZoneKeyName。

准备工作包括阅读tzset的代码和阅读Wine的代码。

tzset的代码在MSYS2的源码仓库中:
https://github.com/Alexpux/Cygwin.git
msys2-runtime/winsup/utils/tzset.c 和 msys2-runtime/winsup/utils/tzmap.h


在 Wine 的测试源码中,可以了解到可能有用的时区相关的API(测试代码是不错的学习API使用方法的参考来源):
dlls/kernel32/tests/time.c:test_GetTimeZoneInformation()

我们的目的是,参考 dlls/kernel32/kernel_main.c:process_attach()中的LOCALE_InitRegistry
(在 dlls/kernel32/locale.c 中),写一个TIMEZONE_InitRegistry, 放在
dlls/kernel32/time.c 中。

另外,在Wine的loader/wine.inf.in中,有部分时区数据可以了解一下,这些设置在Wine初始化的时候也会被填充进注册表,节选如下:
2592 [Timezones]
2593 ; The timezone information (TZI field) comes from the Olson
timezone database
2594 ; http://www.twinsun.com/tz/tz-link.htm
2595 ; The mapping of Windows timezone names to Olson Tzids is based on the
2596 ; Unicode.org CLDR data:
2597 ; http://unicode.org/cldr/data/diff/supplemental/windows_tzid.html
2598 HKLM,%CurrentVersionNT%\Time Zones\Afghanistan Standard
Time,"Display",,"Asia/Kabul"
2599 HKLM,%CurrentVersionNT%\Time Zones\Afghanistan Standard
Time,"Dlt",,"Afghanistan Daylight Time"
2600 HKLM,%CurrentVersionNT%\Time Zones\Afghanistan Standard
Time,"Std",,"Afghanistan Standard Time"
2601 HKLM,%CurrentVersionNT%\Time Zones\Afghanistan Standard

Time,"TZI",1,f2,fe,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

这个任务可不可以请 Quanyang 和 Huanjie 两位分工,一人写测试一人写实现,互相帮助互相挑错?请加入一起交流,谢谢~

好的,第一个任务完成后将试着做做这个任务


BTW,Wine上游有一个相关的bug,做完这个bug之后,如果觉得不难可以顺便一起修掉:
https://bugs.winehq.org/show_bug.cgi?id=37760

--
Regards,
Qian Hong

-
http://www.winehq.org




--
I won't go
Mick

Other related posts: