Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Windows 2000 上的 Google Chrome

213 views
Skip to first unread message

Ban

unread,
Jun 21, 2009, 9:42:31 AM6/21/09
to
从2009年5月发布的2.0.172.28稳定版的源码中, 可以看出2006年开始设计的时侯是以Windows 2000为起点的, 2.0.172.28版中还遗留很多专门为兼容Windows 2000而额外设计的代码. 后来因某种原因放弃Windows 2000, 于是出现一些不兼容Windows 2000的代码, 比如调用Windows 2000所缺的HeapSetInformation, SystemFunction036. 不过这种代码不多, 我发现只有几个, 自己补上, 另外去掉检测到Windows 2000就警告或退出的人为的限制, 就能用了, SP4都不用装, SP3也行. 自己编译不划算, 为十来处小修改去重新编译2GB源码太小题大做了, 直接修改9MB的官方编译安装包就行了, 反正机器码和源码功能是一一对应的. 指望官方发布Windows 2000版Chrome简直南辕北辙, 2008年9月首次发布时, 要求Windows XP SP1, 2009年5月2.0.172.28版发布时, 要求Windows XP SP2, 下一次可能要求Windows XP SP3了.
win2ksp3_chrome.gif

Ban

unread,
Jun 21, 2009, 10:23:54 AM6/21/09
to
Moses 的 Windows 2000 SP4
win2ksp4_chrome_moses.gif

Moses

unread,
Jun 21, 2009, 10:00:35 PM6/21/09
to
又多了一个办法 :)

不过不太明白编译好的安装包如何修改?

--
楼上 Ban 说的 "Windows 2000 上的 Google Chrome" 在某一分钟的第 51 秒被 Moses 所回复;
文件夹 ID 为 322967;
原帖 2579 行共 2857 字节.

B> 从2009年5月发布的2.0.172.28稳定版的源码中, 可以看出2006年开始设计的时侯是以Windows 2000为起点的,
B> 2.0.172.28版中还遗留很多专门为兼容Windows 2000而额外设计的代码. 后来因某种原因放弃Windows 2000,
B> 于是出现一些不兼容Windows 2000的代码, 比如调用Windows 2000所缺的HeapSetInformation,
B> SystemFunction036. 不过这种代码不多, 我发现只有几个, 自己补上, 另外去掉检测到Windows
B> 2000就警告或退出的人为的限制, 就能用了, SP4都不用装, SP3也行. 自己编译不划算,
B> 为十来处小修改去重新编译2GB源码太小题大做了, 直接修改9MB的官方编译安装包就行了, 反正机器码和源码功能是一一对应的.
B> 指望官方发布Windows 2000版Chrome简直南辕北辙, 2008年9月首次发布时, 要求Windows XP SP1,
B> 2009年5月2.0.172.28版发布时, 要求Windows XP SP2, 下一次可能要求Windows XP SP3了.

Ban

unread,
Jun 22, 2009, 1:24:40 AM6/22/09
to
我用了两个方法,
第一个方法是直接修改执行码, 比如安装包的setup主程序检测到是Win2K就拒绝安装

[] http://src.chromium.org/svn/releases/2.0.172.28/src/chrome/installer/setup/main.cc
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
wchar_t* command_line, int show_command) { ...
// Check to make sure current system is WinXP or later. If not, log
// error message and get out.
if (!InstallUtil::IsOSSupported()) {
LOG(ERROR) << "Chrome only supports Windows XP or later.";
InstallUtil::WriteInstallerResult(system_install,
installer_util::OS_NOT_SUPPORTED,
IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL);
return installer_util::OS_NOT_SUPPORTED;
} ...
}

[] http://src.chromium.org/svn/releases/2.0.172.28/src/chrome/installer/util/install_util.cc
bool InstallUtil::IsOSSupported() {
int major, minor;
win_util::WinVersion version = win_util::GetWinVersion();
win_util::GetServicePackLevel(&major, &minor);
// We do not support Win2K or older, or XP without service pack 2.
LOG(INFO) << "Windows Version: " << version
<< ", Service Pack: " << major << "." << minor;
if ((version > win_util::WINVERSION_XP) ||
(version == win_util::WINVERSION_XP && major >= 2)) {
return true;
}
return false;
}

把这段源码对应的执行码jne(0x75)改为jmp(0xeb), 就相当于把源码if (!InstallUtil::IsOSSupported())改为if (!InstallUtil::IsOSSupported(), false), 即忽略检测结果, 总是继续安装.

[] setup.exe
0040458f e8e53b0000 call setup+0x8179 (00408179) {setup!IsOSSupported}
00404594 84c0 test al,al
00404596 757c jne setup+0x4614 (00404614) //操作系统>= XP SP2才继续安装
改为
00404596 eb7c jmp setup+0x4614 (00404614) //总是继续安装

第二个方法是修改PE文件头, 比如chrome.exe和chrome.dll的文件头输入表包含HeapSetInformation, 造成程序初始化失败(系统无法从KERNEL32.dll找到HeapSetInformation这个API)

[] http://src.chromium.org/svn/releases/2.0.172.28/src/base/process_util_win.cc
void EnableTerminationOnHeapCorruption() {
// Ignore the result code. Supported on XP SP3 and Vista.
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
}

我就把文件头输入表(ImportDirectoryTable.NameRVA)的"KERNEL32.dll"改为自制的"chrom2k.dll", chrom2k.dll自制1个山寨版HeapSetInformation(设置ERROR_NOT_SUPPORTED, 返回0), 其余的API直接在输出表中forward到KERNEL32.dll的API.

[] chrom2k.c
BOOL WINAPI k2HeapSetInformation(
HANDLE HeapHandle,
HEAP_INFORMATION_CLASS HeapInformationClass,
PVOID HeapInformation,
SIZE_T HeapInformationLength) {
SetLastError(ERROR_NOT_SUPPORTED);
return FALSE; //0
}
#pragma comment(linker, "/export:HeapSetInformation=_k2HeapSetInformation@16")
#define K(f) comment(linker, "/export:" #f "=KERNEL32." #f)
#pragma K(HeapDestroy)
#pragma K(HeapCreate)
#pragma K(HeapReAlloc)
...

"Moses" <moses...@gmail.com> wrote:
> 又多了一个办法 :)
> 不过不太明白编译好的安装包如何修改?

�IJ���

unread,
Jun 22, 2009, 3:19:03 AM6/22/09
to
SystemFunction036
���API�����õģ�msdn���Ҳ���

"Ban" <B...@rixi.an> д����Ϣ news:2...@rixi.an...
��2009��5�·�����2.0.172.28�ȶ����Դ����, ���Կ���2006�꿪ʼ��Ƶ�ʱ������Windows
2000Ϊ����, 2.0.172.28���л������ܶ�ר��Ϊ����Windows 2000�������ƵĴ���.
������ij��ԭ�����Windows 2000, ���dz���һЩ������Windows 2000�Ĵ���, �������Windows 2000��ȱ��HeapSetInformation, SystemFunction036. �������ִ��벻��,
�ҷ���ֻ�м���, �Լ�����, ����ȥ����⵽Windows 2000�;�����˳�����Ϊ������,
��������, SP4������װ, SP3Ҳ��. �Լ����벻����, Ϊʮ����С�޸�ȥ���±���2GBԴ��̫С�������, ֱ���޸�9MB�Ĺٷ����밲װ�������, ����������Դ�빦����һһ��Ӧ
��. ָ��ٷ�����Windows 2000��Chrome��ֱ��ԯ����, 2008��9���״η���ʱ, Ҫ��Windows
XP SP1, 2009��5��2.0.172.28�淢��ʱ, Ҫ��Windows XP SP2, ��һ�ο���Ҫ��Windows
XP SP3��.


graham

unread,
Jun 22, 2009, 3:48:33 AM6/22/09
to
����ù�GDI++�￴��ȥ���Һ�ϲ������ʸ������

����GDI++����֮��ϵͳ�Դ��Tahoma��ô���ö�������Ⱦ�ú����룬ֻ�����ò���Ⱦ


"Ban" <B...@rixi.an> д����Ϣ����:2...@rixi.an...
Moses �� Windows 2000 SP4


Ban

unread,
Jun 22, 2009, 5:18:57 AM6/22/09
to
SystemFunction036是Advapi32.dll里的一个API, 功能是调用内部的NewGenRandom生成一个伪随机数.

[] Advapi32.dll 5.1.2600.5512
ADVAPI32!SystemFunction036:
77da8292 8bff mov edi,edi
77da8294 55 push ebp
77da8295 8bec mov ebp,esp
77da8297 ff750c push dword ptr [ebp+0Ch]
77da829a ff7508 push dword ptr [ebp+8]
77da829d 6a00 push 0
77da829f 6a00 push 0
77da82a1 e809000000 call ADVAPI32!NewGenRandom (77da82af)
77da82a6 5d pop ebp
77da82a7 c20800 ret 8

MSDN文档有SystemFunction036, 不过是以RtlGenRandom为标题.

[] http://msdn.microsoft.com/en-us/library/aa387694.aspx
The RtlGenRandom function generates a pseudo-random number. Note This function has no associated import library. This function is available as a resource named SystemFunction036 in Advapi32.dll. Minimum supported client Windows XP

Chrome调用C库的rand_s来生成伪随机数.

[] http://src.chromium.org/svn/releases/2.0.172.28/src/base/rand_util_win.cc
uint32 RandUint32() {
CHECK(rand_s(&number) == 0);

而VC运行库的rand_s依赖这个RtlGenRandom, 也就是SystemFunction036.

[] http://msdn.microsoft.com/en-us/library/sxtz2fa8.aspx
rand_s depends on the RtlGenRandom API, which is only available in Windows XP and later.

[] vc8\crt\src\rand_s.c
#define RtlGenRandom SystemFunction036
errno_t __cdecl rand_s(unsigned int *_RandomValue) {
HMODULE hAdvApi32=LoadLibrary("ADVAPI32.DLL");
pfnRtlGenRandom = ( PGENRANDOM ) GetProcAddress( hAdvApi32, _TO_STR( RtlGenRandom ) );
if ( !(*pfnRtlGenRandom)( _RandomValue, ( ULONG )sizeof( unsigned int ) ) ) {
errno = ENOMEM;
return errno;
}
return 0;
}

我是自制一个山寨版SystemFunction036, 用ADVAPI32!CryptGenRandom(这里只是32bit的伪随机数, ntdll!RtlRandomEx其实也可以)来实现.

[] chrom2k.c
BOOLEAN WINAPI k2RtlGenRandom(
PVOID RandomBuffer,
ULONG RandomBufferLength){
HCRYPTPROV hpro;
BOOLEAN re;
DWORD flag = 0;
retry:
re = CryptAcquireContext(&hpro, 0, 0, PROV_RSA_FULL, flag);
if (!re) {
if (NTE_BAD_KEYSET == GetLastError()) {
flag = CRYPT_NEWKEYSET;
goto retry;
} else {
msg(erro, "k2RtlGenRandom failed");
return FALSE;
}
}
re = CryptGenRandom(hpro, RandomBufferLength, RandomBuffer);
if (!re)
msg(erro, "k2RtlGenRandom failed");
CryptReleaseContext(hpro, 0);
return re;
}
#pragma comment(linker, "/export:SystemFunction036=_k2RtlGenRandom@8")

"四不象" <tabri...@hotmail.com> wrote:
> SystemFunction036
> 这个API干嘛用的?msdn里找不到

四不象

unread,
Jun 22, 2009, 11:01:13 PM6/22/09
to
靠,google就为了生成个随机数就让chrome不支持2000啊,没天理

On 6月22日, 下午5时18分, "Ban" <B...@rixi.an> wrote:
> SystemFunction036是Advapi32.dll里的一个API, 功能是调用内部的NewGenRandom生成一个伪随机数.
>
> [] Advapi32.dll 5.1.2600.5512
> ADVAPI32!SystemFunction036:
> 77da8292 8bff mov edi,edi
> 77da8294 55 push ebp
> 77da8295 8bec mov ebp,esp
> 77da8297 ff750c push dword ptr [ebp+0Ch]
> 77da829a ff7508 push dword ptr [ebp+8]
> 77da829d 6a00 push 0
> 77da829f 6a00 push 0
> 77da82a1 e809000000 call ADVAPI32!NewGenRandom (77da82af)
> 77da82a6 5d pop ebp
> 77da82a7 c20800 ret 8
>
> MSDN文档有SystemFunction036, 不过是以RtlGenRandom为标题.
>
> []http://msdn.microsoft.com/en-us/library/aa387694.aspx
> The RtlGenRandom function generates a pseudo-random number. Note This function has no associated import library. This function is available as a resource named SystemFunction036 in Advapi32.dll. Minimum supported client Windows XP
>
> Chrome调用C库的rand_s来生成伪随机数.
>

> []http://src.chromium.org/svn/releases/2.0.172.28/src/base/rand_util_wi...

> "四不象" <tabris17...@hotmail.com> wrote:
> > SystemFunction036
> > 这个API干嘛用的?msdn里找不到

��King

unread,
Jun 23, 2009, 6:36:26 AM6/23/09
to
漂锟斤拷锟斤拷锟斤拷

--
锟斤拷锟斤拷"Ban"锟侥达拷锟斤拷锟斤拷锟斤拷锟结到...锟斤拷

>Moses 锟斤拷 Windows 2000 SP4

Moses

unread,
Jun 22, 2009, 8:41:16 PM6/22/09
to
比较复杂啊... = =


--
楼上 Ban 说的 "Re: Windows 2000 上的 Google Chrome" 在某一分钟的第 06 秒被 Moses 所回复;
文件夹 ID 为 322967;
原帖 101 行共 5115 字节.

B> 我用了两个方法,
B> 第一个方法是直接修改执行码, 比如安装包的setup主程序检测到是Win2K就拒绝安装

B> [] http://src.chromium.org/svn/releases/2.0.172.28/src/chrome/installer/setup/main.cc
B> int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
B> wchar_t* command_line, int show_command) { ...
B> // Check to make sure current system is WinXP or later. If not, log
B> // error message and get out.
B> if (!InstallUtil::IsOSSupported()) {
B> LOG(ERROR) << "Chrome only supports Windows XP or later.";
B> InstallUtil::WriteInstallerResult(system_install,
B> installer_util::OS_NOT_SUPPORTED,
B> IDS_INSTALL_OS_NOT_SUPPORTED_BASE,
B> NULL);
B> return installer_util::OS_NOT_SUPPORTED;
B> } ...
B> }

B> [] http://src.chromium.org/svn/releases/2.0.172.28/src/chrome/installer/util/install_util.cc
B> bool InstallUtil::IsOSSupported() {
B> int major, minor;
B> win_util::WinVersion version = win_util::GetWinVersion();
B> win_util::GetServicePackLevel(&major, &minor);
B> // We do not support Win2K or older, or XP without service pack 2.
B> LOG(INFO) << "Windows Version: " << version
B> << ", Service Pack: " << major << "." << minor;
B> if ((version > win_util::WINVERSION_XP) ||
B> (version == win_util::WINVERSION_XP && major >= 2)) {
B> return true;
B> }
B> return false;
B> }

B> 把这段源码对应的执行码jne(0x75)改为jmp(0xeb), 就相当于把源码if
B> (!InstallUtil::IsOSSupported())改为if (!InstallUtil::IsOSSupported(),
B> false), 即忽略检测结果, 总是继续安装.

B> [] setup.exe
B> 0040458f e8e53b0000 call setup+0x8179 (00408179)
B> {setup!IsOSSupported} 00404594 84c0 test al,al
B> 00404596 757c jne setup+0x4614 (00404614) //操作系统>= XP
B> SP2才继续安装 改为
B> 00404596 eb7c jmp setup+0x4614 (00404614) //总是继续安装

B> 第二个方法是修改PE文件头, 比如chrome.exe和chrome.dll的文件头输入表包含HeapSetInformation,
B> 造成程序初始化失败(系统无法从KERNEL32.dll找到HeapSetInformation这个API)

B> [] http://src.chromium.org/svn/releases/2.0.172.28/src/base/process_util_win.cc
B> void EnableTerminationOnHeapCorruption() {
B> // Ignore the result code. Supported on XP SP3 and Vista.
B> HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
B> }

B> 我就把文件头输入表(ImportDirectoryTable.NameRVA)的"KERNEL32.dll"改为自制的"chrom2k.dll"
B> , chrom2k.dll自制1个山寨版HeapSetInformation(设置ERROR_NOT_SUPPORTED, 返回0),
B> 其余的API直接在输出表中forward到KERNEL32.dll的API.

B> [] chrom2k.c
B> BOOL WINAPI k2HeapSetInformation(
B> HANDLE HeapHandle,
B> HEAP_INFORMATION_CLASS HeapInformationClass,
B> PVOID HeapInformation,
B> SIZE_T HeapInformationLength) {
B> SetLastError(ERROR_NOT_SUPPORTED);
B> return FALSE; //0
B> }
B> #pragma comment(linker,
B> "/export:HeapSetInformation=_k2HeapSetInformation@16") #define K(f)
B> comment(linker, "/export:" #f "=KERNEL32." #f) #pragma K(HeapDestroy)
B> #pragma K(HeapCreate)
B> #pragma K(HeapReAlloc)
B> ...

Ban

unread,
Jun 23, 2009, 6:50:38 PM6/23/09
to
这是chrome决定不支持Windows 2000后才漫不经心地用的. Google中途放弃Windows 2000是出于金钱考虑, 多支持一个操作系统就多一份维护开支, chrome每次修改都要额外在Windows 2000上进行全面测试, 虽然Windows 2000用户(1.13%)和Linux用户(1.12%)差不多, 但Google认为Windows 2000用户多数是公司用户, 公司一般限制使用第三方软件, chrome很难从中捞到好处.

PS: 因为chrome的--single-process选项没功夫去全面测试, 所以chrome的正式发行版本这个选项也不支持.

PS: ntdll!RtlRandomEx写错了, 应是ntdll!RtlRandom.

"四不象" <tabri...@gmail.com> wrote:
> 靠,google就为了生成个随机数就让chrome不支持2000啊,没天理
>
> "Ban" <B...@rixi.an> wrote:
> 我是自制一个山寨版SystemFunction036, 用ADVAPI32!CryptGenRandom(这里只是32bit的伪随机数, ntdll!RtlRandomEx其实也可以)来实现.

�����

unread,
Jun 24, 2009, 10:41:26 PM6/24/09
to
���˰���
��Windows�˽��һ���������

"Ban" <B...@rixi.an> д����Ϣ news:2...@rixi.an...

��������������,
��һ��������ֱ���޸�ִ����, ���簲װ���setup�������⵽��Win2K�;ܾ�װ
�ڶ����������޸�PE�ļ�ͷ, ����chrome.exe��chrome.dll���ļ�ͷ������HeapSetInformation,
��ɳ����ʼ��ʧ��(ϵͳ�޷���KERNEL32.dll�ҵ�HeapSetInformation���API)


0 new messages