Archive: Labels not used on compile but still needed


Labels not used on compile but still needed
Here's my problem.

I'm using NSIS to patch the uxtheme.dll file for all versions of XP and Server 2003 by using FileWriteByte. I've successfully setup the code to hex edit the file.

However what I am trying to do is read the file version, then use the file version read to jump to a label like so:


Section "Patch uxtheme.dll"
ClearErrors
GetDLLVersion "$SYSDIR\uxtheme.dll" $R0 $R1
IntOp $0 $R0 / 0x00010000
IntOp $1 $R0 & 0x0000FFFF
IntOp $2 $R1 / 0x00010000
IntOp $3 $R1 & 0x0000FFFF
StrCpy $4 "$0.$1.$2.$3"
StrCpy "$5" "V$4"

Goto $5

DetailPrint "Your uxtheme.dll version is not supported by this patch at the moment."
Return

V5.1.2600.1106:
FileOpen $9 "uxtheme.dll" a
FileSeek $9 0x0000C3FF SET
FileWriteByte $9 "51"
FileWriteByte $9 "246"
FileWriteByte $9 "139"
FileWriteByte $9 "198"
FileWriteByte $9 "201"
FileWriteByte $9 "194"
FileWriteByte $9 "8"
FileWriteByte $9 "0"
FileClose $9
SectionEnd


And then when compiling it tells me
label "V6.0.3790.1159" not used
label "V6.0.3790.1184" not used
label "V6.0.3790.1218" not used
label "V6.0.3790.1247" not used
etc. etc.

When I run the installer, it correctly reads the file version, but it doesn't jump to the right section. Instead it just prints "Your uxtheme.dll version is not supported by this patch at the moment."

Does anyone know what I can do to solve this without using a million StrCmp functions?

You could make your life easier and just use VPatch. It is capable of creating multiple patches in one file. You'll replace all of the above code with one line. You can find documentation and examples in Contrib\VPatch.


Yes, but after looking through the VPatch documentation you need the source file AND the new file. I have the new files, and so from that I discovered what offset I needed to edit for the different file versions. With VPatch it also creates patch files, which I'd have to include in the installer. With the WriteFileByte method I just have to include a few lines of code for different file versions, which was already setup to begin with.

Not to mention the offset is the same for every uxtheme.dll version, independent of the language. However the different language versions of uxtheme.dll contain different text strings and what-not.

The patch will be able to edit 35 different uxtheme.dll files. Using VPatch would take me awhile to setup since they're all named the same and I don't have access to the 35 original files, just the new hacked files.

I just went ahead and setup StrCmp functions, it didn't take too long.


Thanks though.