4

I'm currently trying to port my image optimizer application to a NanoServer docker image. One of the tools my image optimizer uses is truepng.exe. (Can be downloaded here: http://x128.ho.ua/clicks/clicks.php?uri=TruePNG_0625.zip)

I simply created a nanoserver container and mounted a folder that contained truepng.exe:

docker run --rm -it -v C:\data:C:\data mcr.microsoft.com/windows/nanoserver:2004-amd64

When I now run truepng.exe I expect some output regarding command line arguments missing:

C:\MyLocalWindowsMachine>truepng
TruePNG 0.6.2.5 : PNG Optimizer
by x128 (2010-2017)
x128@ua.fm

...

However when I call this from inside the nanoserver docker container I basically see no output:

C:\data>truepng

C:\data>echo %ERRORLEVEL%
-1073741515

As you can see above, the exit code is set to -1073741515. According to this it typically means that there's a dependency missing.

I then downloaded https://github.com/lucasg/Dependencies to see the dependencies of truepng:

enter image description here

It seems it has some dependencies on 5 DLL's. Looking these up I found that there's apparently something called 'Reverse Forwarders': https://cloudblogs.microsoft.com/windowsserver/2015/11/16/moving-to-nano-server-the-new-deployment-option-in-windows-server-2016/

According to the following post though they should already be included in nanoserver: https://social.technet.microsoft.com/Forums/en-US/5b36a6d3-84c9-4940-8b7a-9e2a38468291/reverse-forwarders-package-in-tp5?forum=NanoServer

After all this investigation I've also been playing around with manually copying over the DLL's from my local machine (system32) to the docker machine without any success (it just kept breaking other things like the copy command which required me to recreate the container). Next to that I've also copied the files from SysWOW64, but this didn't help either.

I'm currently quite stranded on how to proceed further as I'm not even sure if the tool is missing dependencies or if something else is going on. Is there a way to investigate what DLL's are missing once a tool is starting?

Kind regards,

Devedse

Edit 1: Idea from @CherryDT I tried running gflags (https://social.msdn.microsoft.com/Forums/en-US/f004a7e5-9024-4555-9ada-e692fbc3160d/how-to-start-quotloader-snapsquot?forum=vcgeneral) which gave the following output:

C:\data>"C:\data\gflags.exe" /i TruePNG.exe +sls
Current Registry Settings for TruePNG.exe executable are: 00000000

After this I tried running Dbgview.exe, this however never resulted in a log file being written:

C:\data>"C:\data\DebugView\Dbgview.exe" /v /l debugview-log.txt /g /n

C:\data>

I also started TruePNG.exe again, but again, no log file was written.

I tried querying the EventLogs using a dotnet core application, but this resulted in the following exception:

Unhandled exception. System.InvalidOperationException: Cannot open log Application on computer '.'. This function is not supported on this system.
   at System.Diagnostics.EventLogInternal.OpenForRead(String currentMachineName)
   at System.Diagnostics.EventLogInternal.GetEntryAtNoThrow(Int32 index)
   at System.Diagnostics.EventLogEntryCollection.GetEntryAtNoThrow(Int32 index)
   at System.Diagnostics.EventLogEntryCollection.EntriesEnumerator.MoveNext()
   at EventLogReaderTest.ConsoleApp.Program.Main(String[] args) in C:\data\EventLogReaderTest.ConsoleApp\Program.cs:line 22
Devedse
  • 1,801
  • 1
  • 19
  • 33
  • Do you see anything in the event log that would explain which dependency is missing exactly? You can also [enable loader snaps](https://social.msdn.microsoft.com/Forums/en-US/f004a7e5-9024-4555-9ada-e692fbc3160d/how-to-start-quotloader-snapsquot?forum=vcgeneral) and then start [DebugView](https://learn.microsoft.com/en-us/sysinternals/downloads/debugview) (configured to [log to a file](https://documentation.help/DebugView/documentation.pdf)) inside the same container before you try running it again. Then check the debug log. – CherryDT Sep 01 '20 at 13:25
  • @CherryDT I've been playing around with this but it seems like both gflags.exe and Dbgview.exe need a UI to work. Is there an alternative? – Devedse Sep 01 '20 at 18:39
  • Both of them should work with command line too, as described in the links that I sent. – CherryDT Sep 01 '20 at 19:21
  • @CherryDT I added some more comments to the main post, did I possibly do something wrong? It seems like the Dbgview tool should remain running, but it doesn't seem to do that. – Devedse Sep 01 '20 at 19:24

1 Answers1

4

Windows Nano Server is tiny and only supports 64-bit applications, tools, and agents. The missing dependency in this case is the entire x86 emulation layer (WoW64), as TruePNG is a 32-bit application.

Windows Server Core contains WoW64 and other components missing from Nano Server. Use a Windows Server Core image instead.

Example command:

docker run --rm -it -v C:\Temp:C:\Temp mcr.microsoft.com/windows/servercore:2004 C:\Temp\TruePNG.exe

Yields the expected output:

TruePNG 0.6.2.5 : PNG Optimizer
by x128 (2010-2017)
x128@ua.fm

TruePNG {options} files

options:
/f#     PNG delta filters 0=None, 1=Sub, 2=Up, 3=Average, 4=Paeth, 5=Mixed
/fe     PNG extra filters, overrides /f switch
/i#     PNG interlace method 0=None, 1=Adam7 (default input)
/g#     PNG gamma 0=Remove, 1=Apply & Remove, 2=Keep (default)
[...]
Rafael Rivera
  • 871
  • 8
  • 22
  • Thanks, this is the answer I've been waiting for :). – Devedse Sep 29 '20 at 22:39
  • This also fixed a problem where we needed to install `vcredist_x86.exe` 2012 in a container and we could not make it work. Changing to server core [image](https://hub.docker.com/_/microsoft-windows-servercore), and installing it on that fixed our problem. – meyer1994 Nov 27 '20 at 01:57