The MASM Forum

General => The Workshop => Topic started by: jj2007 on November 28, 2016, 01:39:13 AM

Title: Weird problem with UpdateResource
Post by: jj2007 on November 28, 2016, 01:39:13 AM
Tim discovered this by accident when trying to insert a manifest into one of my gdi+ exercises:
Quote from: TWell on November 27, 2016, 12:37:11 AM
Have anyone idea, why GuiImage.exe is not a valid Win32 application with this manifest<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="Co.Prd.Prg" type="win32" />
<dependency><dependentAssembly><assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*" />
</dependentAssembly></dependency></assembly>
EDIT: manifest wasn't a problem.

The exe was trashed. After a lot of testing, I could identify the culprit in the MasmBasic source:
sgSeg segment public DWORD 'BSS' ; special segment for SetGlobals
  align 16
  gvStart dd ?
  ORG gvStart+4096-1
  db ?
sgSeg ends

When opened with PeView (http://wjradburn.com/software/), this segment appeared at the end of executables - and this worked just fine, except when trying to change the regular .rsrc section with UpdateResource.

In the meantime, I've removed this segment (it was not needed anyway), so MB 27NovV2 (http://masm32.com/board/index.php?topic=94.0) is OK for updating resources.
In the process of testing, I also discovered that a file named UpdateResource.exe requires elevation (same for Setup.exe and a few other "reserved" exe names). Launching it with CreateProcess just fails silently, but GetLastError reveals the problem. I've added a check to RichMasm; testbed attached.

On a side note (Windows SDK Support Team Blog (https://blogs.msdn.microsoft.com/winsdk/2013/08/27/why-am-i-receiving-the-error-code-740-the-requested-operation-requires-elevation-when-launchingstarting-an-application/)):
QuoteIf you are wondering how Windows launches a manifested application, it is internally calling ShellExecute(), ShellExecuteEx().
manifest insanity ::)
Title: Gdi+ and XP manifest
Post by: jj2007 on May 18, 2017, 10:21:53 PM
Just discovered a pretty odd behaviour of GdipCreateBitmapFromStream: It works for TIFF images if there is no XP manifest. Otherwise it chokes for some types of tiff images, e.g. with invalid parameter.

Testbed attached, extract to a folder and drag a tiff over the exe.
Title: Re: Weird problem with UpdateResource
Post by: TWell on May 18, 2017, 10:40:56 PM
Windows 8.1:
Both programs shows TIFFs.
Title: Re: Weird problem with UpdateResource
Post by: Siekmanski on May 18, 2017, 11:36:02 PM
Both exe files -> "Could not open multipage_tiff_example.tif for Recall, FileRead$ etc." and then exits.
Title: Re: Weird problem with UpdateResource
Post by: jj2007 on May 18, 2017, 11:50:58 PM
Thanks for testing, Tim & Marinus :icon14:

Quote from: Siekmanski on May 18, 2017, 11:36:02 PM
Both exe files -> "Could not open multipage_tiff_example.tif for Recall, FileRead$ etc." and then exits.

Did you extract the two tiffs to the same folder, and drag them over the exe?

For me, both exes work under Win10. Only Win7-64 has the problem.

In my XP VM, the smaller tiff works fine, the other one works with none of the exes :(
Title: Re: Weird problem with UpdateResource
Post by: Siekmanski on May 19, 2017, 12:11:21 AM
No, I launched the executables instead of dragging the images over the exe.
When I did, both work as a charm and they play the animation from the MultiFrame.tif  8)

ortex.tiff isn't an animation? it doesn't animate.
Title: Re: Weird problem with UpdateResource
Post by: jj2007 on May 19, 2017, 12:53:17 AM
Quote from: Siekmanski on May 19, 2017, 12:11:21 AMortex.tiff isn't an animation? it doesn't animate.

Right, I forgot to mention that. Anybody with Win7? I'd like to know if it's OS-dependent or just my machine.
Title: Re: Weird problem with UpdateResource
Post by: HSE on May 19, 2017, 01:20:22 AM
NoManifest work with 2 tif files.
Title: Re: Weird problem with UpdateResource
Post by: jj2007 on May 19, 2017, 02:05:13 AM
And the other one fails? Win7-64?
Title: Re: Weird problem with UpdateResource
Post by: HSE on May 19, 2017, 02:59:12 AM
XpManifest launch the error message.







<---   only smartest see here  :biggrin: ( not so easy to align the line)