Hi All,
I think I have found a bug in Windows Vista when loading a v6.0 relocationable executable files with LoadLibrary function. It’s seems like the Vista uses a different algorithm for decideding the image base for CreateProcess and a different algorithm for LoadLibrary. The relocation, however, is done by CreateProcess algorithm.
I don’t think I’m fully understand the algorithm or it’s attributes.
As you can see in the WinDbg log below, “IEUser.exe”, which in dumpbin shows the following
OPTIONAL HEADER VALUES
10B magic # (PE32)
8.00 linker version
11000 size of code
38800 size of initialized data
0 size of uninitialized data
5301 entry point (01005301)
1000 base of code
12000 base of data
1000000 image base (01000000 to 0104BFFF)
1000 section alignment
200 file alignment
6.00 operating system version
6.00 image version
6.00 subsystem version
0 Win32 version
4C000 size of image
400 size of headers
5392A checksum
2 subsystem (Windows GUI)
8140 DLL characteristics
RESERVED - UNKNOWN
NX compatible
Terminal Server Aware
Should normally be loaded at 1000000 is now loaded at 00ac0000. The relocation process changes the binary but to the wrong address!!!
Original code:
.text:01005310 8B FF mov edi, edi
.text:01005312 55 push ebp
.text:01005313 8B EC mov ebp, esp
.text:01005315 83 EC 10 sub esp, 10h
.text:01005318 A1 00 20 01 01 mov eax, ___security_cookie
After relocaton:
00ac5318 a100204b00 mov eax,dword ptr ds:[004B2000h] <=== WRONG! SHOULD BE 0xad2000
Notice that the relocation base is ALWAYS start based on 4A000 (Even at your computer/load library application)!
Does anyone has a clue?
Best Regards,
Elad Raz
integrity-project.com
Microsoft (R) Windows Debugger Version 6.7.0005.1
Copyright (c) Microsoft Corporation. All rights reserved.
CommandLine: C:\Windows\System32\rundll32.exe “C:\Program Files\Internet Explorer\IEUser.exe” start
Symbol search path is: *** Invalid ***
****************************************************************************
* Symbol loading may be unreliable without a symbol search path. *
* Use .symfix to have the debugger choose a symbol path. *
* After setting your symbol path, use .reload to refresh symbol locations. *
****************************************************************************
Executable search path is:
ModLoad: 00df0000 00dfe000 rundll32.exe
ModLoad: 775d0000 776ee000 ntdll.dll
ModLoad: 770e0000 771b8000 C:\Windows\system32\kernel32.dll
ModLoad: 75e90000 75f2e000 C:\Windows\system32\USER32.dll
ModLoad: 77060000 770ab000 C:\Windows\system32\GDI32.dll
ModLoad: 76ef0000 76faf000 C:\Windows\system32\ADVAPI32.dll
ModLoad: 77370000 77433000 C:\Windows\system32\RPCRT4.dll
ModLoad: 76fb0000 7705a000 C:\Windows\system32\msvcrt.dll
ModLoad: 75f30000 75f59000 C:\Windows\system32\imagehlp.dll
(c08.f64): Break instruction exception - code 80000003 (first chance)
eax=00000000 ebx=00000000 ecx=001cfaf0 edx=77630f34 esi=fffffffe edi=77695d14
eip=77612ea8 esp=001cfb08 ebp=001cfb38 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
*** ERROR: Symbol file could not be found. Defaulted to export symbols for ntdll.dll -
ntdll!DbgBreakPoint:
77612ea8 cc int 3
0:000> g
ModLoad: 73760000 7377e000 C:\Windows\system32\ShimEng.dll
ModLoad: 75c90000 75cbc000 C:\Windows\System32\apphelp.dll
ModLoad: 73460000 734e7000 C:\Windows\AppPatch\AcLayers.DLL
ModLoad: 76240000 76d0e000 C:\Windows\system32\SHELL32.dll
ModLoad: 76090000 760e5000 C:\Windows\system32\SHLWAPI.dll
ModLoad: 77220000 77364000 C:\Windows\system32\ole32.dll
ModLoad: 76d10000 76d9c000 C:\Windows\system32\OLEAUT32.dll
ModLoad: 75d40000 75d5e000 C:\Windows\System32\USERENV.dll
ModLoad: 75d20000 75d34000 C:\Windows\System32\Secur32.dll
ModLoad: 74ac0000 74b01000 C:\Windows\System32\WINSPOOL.DRV
ModLoad: 758e0000 758f4000 C:\Windows\System32\MPR.dll
ModLoad: 776f0000 7770e000 C:\Windows\system32\IMM32.DLL
ModLoad: 760f0000 761b7000 C:\Windows\system32\MSCTF.dll
ModLoad: 77720000 77729000 C:\Windows\system32\LPK.DLL
ModLoad: 761c0000 7623d000 C:\Windows\system32\USP10.dll
ModLoad: 74be0000 74d74000 C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6000.16386_none_5d07289e07e1d100\comctl32.dll
ModLoad: 00ac0000 00b0c000 ieuser.exe
ModLoad: 00ac0000 00b0c000 C:\Program Files\Internet Explorer\IEUser.exe
ModLoad: 74ba0000 74bdf000 C:\Windows\System32\uxtheme.dll
(c08.cfc): Break instruction exception - code 80000003 (first chance)
eax=7ffde000 ebx=00000000 ecx=00000000 edx=7765f06d esi=00000000 edi=00000000
eip=77612ea8 esp=00c5f790 ebp=00c5f7bc iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
ntdll!DbgBreakPoint:
77612ea8 cc int 3
0:001> u 0x0ac5318
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\system32\kernel32.dll -
*** ERROR: Module load completed but symbols could not be loaded for C:\Program Files\Internet Explorer\IEUser.exe
IEUser+0x5318:
00ac5318 a100204b00 mov eax,dword ptr ds:[004B2000h]
00ac531d 8365f800 and dword ptr [ebp-8],0
00ac5321 8365fc00 and dword ptr [ebp-4],0
00ac5325 57 push edi
00ac5326 bf4ee640bb mov edi,0BB40E64Eh
00ac532b 3bc7 cmp eax,edi
00ac532d 0f85b0090000 jne IEUser+0x5ce3 (00ac5ce3)
00ac5333 56 push esi
0:001> dd 004B2000
004b2000 1a2ccf0d dea0d859 0226c97f dea1d859
004b2010 1a13c938 dea2d859 0210cf57 dea3d859
004b2020 0211c622 dea4d859 1220cf54 dea5d859
004b2030 022fcf1f dea6d859 022cc984 dea7d859
004b2040 020fc9e2 dea8d859 022cc9ee dea9d859
004b2050 0215cf38 deaad859 0225cf55 deabd859
004b2060 0224c936 deacd859 0211c66a deadd859
004b2070 0222c6e4 deaed859 0233cc50 deb2d859
0:001> dd 0xad2000
00ad2000 bb40e64e 44bf19b1 ffffffff 00000000
00ad2010 00000000 00000000 00000000 00000000
00ad2020 00000000 00000000 00000000 00000000
00ad2030 00000000 00000000 00000000 00000000
00ad2040 ffffffff 00000000 00000000 00000000
00ad2050 00000000 00000000 00000000 00000000
00ad2060 00000000 00000000 00000000 00000000
00ad2070 00000000 00000000 00000000 00000000