Author Topic: Weird problem with UpdateResource  (Read 606 times)

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Weird problem with UpdateResource
« 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:
Have anyone idea, why GuiImage.exe is not a valid Win32 application with this manifest
Code: [Select]
<?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:
Code: [Select]
sgSeg segment public DWORD 'BSS' ; special segment for SetGlobals
  align 16
  gvStart dd ?
  ORG gvStart+4096-1
  db ?
sgSeg ends
When opened with PeView, 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 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):
Quote
If you are wondering how Windows launches a manifested application, it is internally calling ShellExecute(), ShellExecuteEx().
manifest insanity ::)

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Gdi+ and XP manifest
« Reply #1 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.

TWell

  • Member
  • ****
  • Posts: 748
Re: Weird problem with UpdateResource
« Reply #2 on: May 18, 2017, 10:40:56 PM »
Windows 8.1:
Both programs shows TIFFs.

Siekmanski

  • Member
  • *****
  • Posts: 1094
Re: Weird problem with UpdateResource
« Reply #3 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.

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: Weird problem with UpdateResource
« Reply #4 on: May 18, 2017, 11:50:58 PM »
Thanks for testing, Tim & Marinus :icon14:

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 :(

Siekmanski

  • Member
  • *****
  • Posts: 1094
Re: Weird problem with UpdateResource
« Reply #5 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.

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: Weird problem with UpdateResource
« Reply #6 on: May 19, 2017, 12:53:17 AM »
ortex.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.

HSE

  • Member
  • ****
  • Posts: 533
  • <AMD>< 7-32>
Re: Weird problem with UpdateResource
« Reply #7 on: May 19, 2017, 01:20:22 AM »
NoManifest work with 2 tif files.

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: Weird problem with UpdateResource
« Reply #8 on: May 19, 2017, 02:05:13 AM »
And the other one fails? Win7-64?

HSE

  • Member
  • ****
  • Posts: 533
  • <AMD>< 7-32>
Re: Weird problem with UpdateResource
« Reply #9 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)