Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Remove KB816542 dependency on Windows 2000


  • Please log in to reply
1 reply to this topic
fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
KB816542 is a Windows 2000 update that backports the Windows XP low-fragmentation heap algorithm, needed by programs compiled using VC++ 2010. However, this update is:
[*:ik6ts5vp]Hard to download: you have to give Microsoft your e-mail address and they will send it to you.
[*:ik6ts5vp]Only available for English systems.So, by doing the following changes in the win2kcompat.asm the dependency is removed:
; Copyright 2010 Steve Gray aka 'Lexikos'
;   Permission is granted to use and/or redistribute this code without restriction.
;
; Visual C++ 2010 ordinarily creates a dependency on EncodePointer, DecodePointer,
; HeapSetInformation and HeapQueryInformation; which means XP SP2 or later is
; required to run the executable.  Assembling this file and linking the result into
; the application prevents this dependency at the expense of any added security or
; performance enhancements those four functions might've provided.
;
; Note that there are two alternative approaches:
;
;  1) Compile a lib containing the functions and link that ahead of kernel32.lib.
;     This requires the use of the /FORCE:MULTIPLE linker option, which is not ideal.
;
;  2) Compile a dll containing the functions and use that.  This doesn't seem to have
;     the same 'multiply defined symbols' problem as #1, but means that the exe won't
;     run on *any* OS without a copy of the dll.
;
.model flat
.code

; Override dll import symbols:
__imp__EncodePointer@4 DWORD XxcodePointer
__imp__DecodePointer@4 DWORD XxcodePointer
[color=red]__imp__HeapSetInformation@16 DWORD HeapSetInformation
__imp__HeapQueryInformation@20 DWORD HeapQueryInformation[/color]
public __imp__EncodePointer@4
public __imp__DecodePointer@4
[color=red]public __imp__HeapSetInformation@16
public __imp__HeapQueryInformation@20[/color]

; Equivalent: PVOID EncodePointer(PVOID Ptr) { return Ptr; }
XxcodePointer:	
	mov eax, [esp+4]
	ret 4

[color=red]; Equivalent: BOOL HeapSetInformation(HANDLE, DWORD, PVOID, DWORD) { return 0; /* fail */ }
HeapSetInformation:
	mov eax, 0
	ret 16[/color]

[color=red]; Equivalent: BOOL HeapQueryInformation(HANDLE, DWORD, PVOID, DWORD, PDWORD) { return 0; /* fail */ }
HeapQueryInformation:
	mov eax, 0
	ret 20[/color]

end

Successfully tested on Spanish Windows 2000 SP4.

EDIT: Post #900. Wow.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Have you confirmed this cannot adversely affect Windows XP+ systems?

However, this update is:
[*:1z2jfzdk]Hard to download: you have to give Microsoft your e-mail address and they will send it to you.

I just ran Windows Update...