25 November 2017

GTK 2.24.31 static library barebone

As a prior reference https://code.google.com/archive/p/static-gtk2-mingw32/
the thing is no patch provided but hints, that's enough though.

So why GTK2? well, after maintaining pygi-aio for several years, nothing really that good.. honestly
There is rough edges, regressions and more importantly it feel less responsive (with slower start-up). Overall GTK 3.x was turbulent version.

Just FYI, it's possible make GTK3 static build, especially prior to GDK's switch to adwaita as default theme, that is GTK 3.6.x where you get "somewhat" native theme, GTK 3.22 also have "somewahat" native theme returned and  it break XP compatibility Well duh.

I made a mod of vispdisp (a streaming image viewer powered by VIPS) and make single exe with GTK 3.6
https://github.com/tumagonx/XPitory/raw/master/static_port/vipsdisp/vipsdisp.exe support huge tiff/jpg/png image (upx'ed 1.56MB)
That's just to prove I'm not making excuse for choosing GTK2 over GTK3 :)

The goal here is to make it barebone otherwise you may as well use the dll version, no?
1 the focus is GTK alone, the rest isn't that important
2 dependencies will be trimmed down until it become what's GTK only really can use from
3 optimization flags

1) With version 2.24.31 I choose Glib 2.34.x which is the minimum to build the latest librsvg (more about it later), Glib also getting bloated too overtime and there are some regressions I don't want to mess with in more recent versions. Supposedly the officially supported static build for Glib was version 2.28-2.30 but it seems my workaround is fine for 2.34. With this other dependencies are pretty much settled:

zlib 1.2.11
win-iconv 0.6
libffi 3.2.1
pixman 0.34
cairo 1.12.18 (I have crash with cairo 1.14.10)
glib 2.34.3
atk 2.8.0
pango 1.40.12 (1.40.14 claim need glib 2.34, but actually it need quite recent one)
gdk-pixbuf 2.26.5
gtk+ 2.24.31

2) Several libraries to be trimmed down:
pixman : has big chunk of SIMD code, configure with --disable-sse2 --disable-ssse3
cairo : only few features that needed by GTK2, configure with --enable-pthread --disable-interpreter --disable-fc --disable-ft --disable-gobject --disable-png --disable-svg --disable-script --disable-ps (note: pthread is needed for static build to avoid mutex crash)
glib : disabling debugging make it smaller, configure with --enable-debug=no
pango : ditto
gdk-pixbuf : only use gdiplus, configure with --with-included-loaders=gdip-png,gdip-gif,gdip-bmp,gdip-tiff,gdip-emf,gdip-jpeg,gdip-wmf,gdip-ico --without-libpng --with-gdiplus --without-libjasper --without-libtiff --without-libjpeg --disable-modules --enable-debug=no
gtk : --disable-modules --with-included-immodules=ime,ipa --enable-debug=no

Do we need svg support? hint: it was one of format that MS really "hate" and hey Qt has it.
if so things get complicated as there is circular dependencies between gdk-pixbuf and librsvg, to solve that merge librsvg objects into libgdk_pixbuf-2.0.a and pass all librsvg dependencies through LIBS that is libcroco and libxml2, overall adds 500KB.

Do we need fontconfig/freetype? it will solve problem of "complex/unusual" font rendering that plagued win32 backend, but it also add almost 700KB (including several config files) and annoying font caching startup once in a while... frankly for most of case it's redundant.

Do we need full jpeg, png and tiff support? gdiplus backend provide less feature for these formats: no progressive mode, no png metadata, incomplete tiiff format/compression and so on. but this will add even more weight 1-1.5MB depends on configuration. Furthermore there is psd, webp, and raw modules that can be enabled

3) the flags is nothing special and for portability reason -flto is avoided (it will make your exe even smaller but you'll need gcc 4.6-4.8, I think)
cflags : -Os
add -fno-unwind-tables -fno-asynchronous-unwind-tables if EH is SJLJ, but not for DWARF or SEH
add -ffunction-sections -fdata-sections this is effective against simpleton app but lost it once app getting complex, in this case -flto is better replacement for dead code removal.
ldflags : -Os -Wl,-s
add -Wl,--gc-sections to correspond above cflags or -flto if you use it on cflags

The static library is intended for static exe, if monolithic dll desired then we need better replacement for GetModuleFileName (without relying on DllMain) such GetModuleHandleEx otherwise localization path will be unpredictable.
Produced exe for simpleton app is about 3.6MB, 3MB with LTO libraries, and a little over 1MB if compressed with 7zip.That's half of prior effort, not bad.

Patches (including new stock icons replacement) : gtk+-2.24.31-static_patch.7z
Libraries and (flattened) headers : gtk+-2.24.31_win32_win64_sjlj.7z
add to ldflags like: -lgtk-win32-2.0 -lgdk-win32-2.0 -lpangocairo-1.0 -lpangowin32-1.0 -lpango-1.0 -latk-1.0 -lcairo -lpixman-1 -lgdk_pixbuf-2.0 -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lglib-2.0 -lintl -liconv -lz -lffi -lws2_32 -lole32 -lwinmm -ldnsapi -lshlwapi -luuid -lgdi32 -lgdiplus -lusp10 -lmsimg32 -limm32
alternatively create text files named libgtk2.a with linker script:
GROUP(-lgtk-win32-2.0 -lgdk-win32-2.0 -lpangocairo-1.0 -lpangowin32-1.0 -lpango-1.0 -latk-1.0 -lcairo -lpixman-1 -lgdk_pixbuf-2.0 -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lglib-2.0 -lintl -liconv -lz -lffi -lws2_32 -lole32 -lwinmm -ldnsapi -lshlwapi -luuid -lgdi32 -lgdiplus -lusp10 -lmsimg32 -limm32)
then we can just add only -lgtk2 in ldflags

23 November 2017

Qemu for Windows XP

QEMU provide binaries for windows at https://qemu.weilnetz.de/w32/
But around version 2.8 (the builds is snapshot based) it was dropped XP support  (supposedly version 2.9 when it switched to SRWLOCK mutex thread)

I build recent qemu version that compatible with XP (32-bit) by reverting the threading model to 2.8.x version.

The build is LAA (bigmem) and fully static binary

HAXM maybe possible using http://software.intel.com/sites/default/files/haxm-windows_r05.zip note that the installer itself wrongly flagged as NT6 executable! but you can open it using 7-zip and then use the hax.msi to install (only for XP32)

This post (and hopefully much more) will be part of XP revival effort which started at github https://github.com/tumagonx/XPitory (apparently not a viable option for long term use so I move to SF).

06 October 2016

How to use anything to generate thumbnail image of anything in explorer

Yep, that's probably idea of https://github.com/kenjiuno/ThumbGensPack/ made by japanese developer. Thumbnail generation happened in background by command-line application that feed 24bit bmp image, this non-blocking way is safer than using dll but at the cost of spawning repetition (and windows watchdog, antivirus scan and so on) delay of the generator since it's not a "server" process (for example like what RWThumbnails did).

The possibility is endless though you could generate thumbnail for text (e.g imagemagick), svg, image, audio, video, or virtually anything then piping or chaining the processes as long as it produce bmp. More importantly the shellextension works with XP :)

Give it a try!

Python 3.5.2 on XP

Got another request for PyGI AIO on Python 3.5 (and 3.6), with my previous attempt using MinGW-W64 to target UCRT failed. I'm considering to switch entirely to VS2015 for PyGI 3.22 (thanks to Fan for keep  VS project files up-to-date). However the idea of using VS2015 while online put me off.. instead I want to use EnterpriseWDK which I can confirm by compiling libintl that it does linked to vcruntime140.dll (which only contain basic support functions) with the rest probably static linked instead using those API-MS-WIN-CRT*.dll forwarder like python 3.5 do. Even if thats okay, PyGI with VS2015 will be no more that half of current packages as many still gcc oriented.

While tinkering on that I got Python 3.5.2 running on XP :-) with the help from Wine I put the fake kernel32.dll between python35.dll and the real kernel. I put it on github here https://github.com/tumagonx/xompie/

Two problem though:

0. Unlike Python 3.5.0rc which "allow" installation, 3.5.2 wont do this XP. so I use preinstalled files from Win10.

1. Apparently Python using incomplete manifest for its executables:

trustinfo xmlns="urn:schemas-microsoft-com:asm.v3"

    while this is ignored safely in later Windows, XP do choked-up saying "application configuration is incorrect"

2. Then, there is path issue where tcl unable to find its libraries in the usual "tcl" subdirectory and I have to move them to "lib" subdirectory (mixed with python). Might had to do with transplanted Wine's GetFinalPathNameByHandleW? dunno

01 October 2016

Where to find WSSAPI backport for XP

When I read some samples in WSDK I stumbled on bunch of web services examples, where its readme said XP is supported via update, with webservices.lib file as import library I suppose it will be webservices.dll but I can't find it anywhere on my up-to-date XP SP3.

Searching from google show that circa 2009 MS half-heartedly released it (in the effort to kill XP), others hinted whereabout is webservices.dll for XP (one of poster in MSDN said the dll is available on Windows 8 or later CD). Other hint tell someone have issue installing intune on XP on MSDN with detailed log containing webservices.dll existence.

The latter bring me to find where the missing update is, just googling "windows_intune_setup" with extension of exe or zip or iso, once you find it get windows_intune_setup.exe and extract it with:

Windows_Intune_Setup.exe /Extract [EXISTING PATH]

We will get two msi (x86 and x64), extract them with:
msiexec /a Windows_Intune_[X86/X64].msi /qb TARGETDIR="[X86/X64 PATH]"

We will get files for OnlineManagement installation, but we can't find webservices.dll or at least it almost tricked me... but the admin-installed msi file is too big which make me suspicious. Open it with 7zip, voila MS hide them in msi Binary table:


Just extract and rename XP and Server2003 files into *.exe and vista file into *.msu. Note that X64 msi contain 32bit XP update. Windows Live installer version 14 also have vista files. File version is 6.0.6001.18302 and same as the one bundled in newer Windows CD/ISO which signed while this one use security catalog file.

There we get nice update installer (not just dll) which you can integrate to your iso/wim.

Now, of course the legal matter exists! Intune client software is deployable for only authorized users! (just like WSSAPI backport is) I just tell you where MS hide it, you can freely choose gSOAP or...

09 September 2016

A rather quiet traffic for Windows 10 Rs1

Finally replacing Windows 8.1 with Windows 10! Within my first three days I need to make sure  that my internet connection didn't abused by Windows and under my control. Having experienced Windows 8.1 before, where explorer, rundll32 and svchost acted as ping bot or downloader this time there is more coming in Windows 10 despite during installation I've opted to turn off "sharing my stuff" with MS features.

Note the following tips are completely favor "bandwidth saving" over "security"

Let's start with services.msc
In XP, I just need to disable Windows Update and BITS, now we get telemetry (note every apps compiled with VS 2015? seems to inherit this ability, intended or not, managed or unmanaged)

- Background Intelligent Transfer Service (BITS)
"supposedly" and used to be the main downloader, but no longer

- Windows Update (wuauserv)
this need tuned on when installing offline update files

- Connected User Experiences and Telemetry (DiagTrack)
why I still need to disable this? well it still popped out sometime.

- Program Compatibility Assistant Service
this one is unrelated, but I need to mention here as this thing keep get in the way, choked up, and eventually dying and bring down system resources. Especially when I do three parallel sessions of mingw compilation script for 24 hours. Additionally in this case, using exclusion for Defender will help too.

Move to gpedit.msc
Contrary to usual mantra of dumbed-down Windows: "We (SYSTEM) will manage it for you", gpedit.msc give us tons of rules that SYSTEM will ahem.. *supposedly* obey. But I don't know why they sometime get telepathy with Redmond to do something else.

Allow definition updates from Microsoft Update
Allow real-time definition updates based on reports to Microsoft MAPS
Allow search and Cortana to use location
Allow Telemetry
Check for the latest virus and spyware definitions on startup
Enabling Windows Update Power Management to automatically wake up the system to install scheduled updates (err, this claimed not apply to W10, but just in case)
Initiate definition update on startup

Define the order of sources for downloading definition updates
Disable all apps from Windows Store *Enterprise/Education only
Do not allow web search
Don't search the web or display web results in Search
Turn off access to the Store
Turn off Application Telemetry
Turn off Automatic Download and Update of Map Data
Turn off game updates
Turn off Help and Support Center Microsoft Knowledge Base search
Turn off Search Companion content file updates
Turn off the offer to update to the latest version of Windows
Turn off Windows Update device driver search prompt

Windows Update advanced options:
defer feature updates (like LTSB ?)

Into Windows Firewall rules:
Programs Inbound/Outbound:


- Service  (Background Tasks Infrastructure Service, I think) that spawn BackgroundTransferHost.exe

  Within a logon session, it activated during the first-time the internet connected. I ca't find any reference reference from registry. Firewall is impotent to block it. I think this is modern app version of BITS. I need to kill BackgroundTransferHost manually.
- Spawned Rundll32 that spawn svchost (uh oh, or something like that),  there is ping activity but not bandwidth intensive. I need to kill rundll32 manually.

At the moment that's all I can do and it's considerable quiet for dial-up user like me.
I recommend ProcessHacker to monitor process and network activity.

There are several  BackgroundTransferHost.exe, in System32(or SysWOW64) and deep inside subdir of winsxs (or winsxs\wow64) so include them all in firewall might works, if not put it on Applocker?

09 March 2016

32-bit OSes in Windows XP Era

Another retro post to celebrate XP consistency on double digit market share for 14 years as seen from http://www.netmarketshare.com. A prove that windows users are generally conservative (including Windows 7 users) and only about 10% who always want new shiny OS (considering most migrated Windows 10 users came from Windows 8.1) and those are likely who bragging their screenshot all over the internet despite far skewed reality. And I believe XP still have significant usage on non-connected/intranet/industrial computers.

XP era which started when it was released in Oct 2001 throughout 2006 until MS made (supposedly successor) Vista in beginning of 2007. The timespan itself is unusual, 5 years compared to 2-3 years for other versions. Here is few list, I have tried most them in the past though few are really hard to find.

Release date Operating System Notes
Oct 2001 Windows XP The last 32-bit *only* Windows (XP64 is Windows 2003)
SP3 in 2008, EOL 2019 (XP POSReady)
Dec 2001 OS/2 4.52 Last version, FP15/CP5 in 2005. Last update 2007
Apr 2002 Plan 9 r4 Last major version
enhanced by 9atom, forked by 9front
Aug 2002 MVS 3.8j TK-3 24bit mainframe turnkey from 1981 S/370 [Hercules]
can be patched into MVS/380 (31bit alternate to MVS/XA)
Aug 2003 Netware 6.5 Last version, SP8 in 2008. EOL 2010
Oct 2003 BSD/OS 5.1 Last version (formerly BSDi), EOL 2004
Anyone has this?
Jun 2004 UnixWare 7.1.4 Last version, MP4 in 2008
Jun 2004 QNX 6.3 6.3.2 rollup update in 2007
Jul 2004 SkyOS 5 beta Last major version, dead in 2008 and still beta
Aug 2004 eComStation 1.2 OS/2-based
Jan 2005 Solaris 10 Last version that mostly 32-bit on Intel port
U11 in 2013. EOL 2018
Jan 2005 Inferno r4 Last major version [Hosted]
Feb 2005 RHEL 4.0 U8(4.8) in 2009, U9 in2011, EOS 2012 (extended 2015)
Mar 2005 PhOS beta6 Last and beta only, enhancement of leaked BeOS 5.1
Mar 2005 z/VSE 3.1 Last version that is 31-bit [Hercules]
Apr 2005 MorphOS 1.4 Amiga-like, 1.4.5 available for free [WinUAE?]
Apr 2005 Mac OSX 10.4 First hackintosh and last version that mostly 32-bit
Last with Classic Env. 10.4.11 in 2007, Last update in 2009
May 2005 Darwin 8.1 Last available standalone Darwin
May 2005 Windows Mobile 5
Jun 2005 OpenServer 6.0 Last version, MP4 in 2009
Oct 2005 Minix 3.1 3.?.x are development releases
Nov 2005 FreeBSD 6 6.4 in 2008. EOL 2010
Dec 2005 Syllable 0.6 Dying at 0.6.7 in 2012
Dec 2005 NetBSD 3.0 3.1 in 2006. EOL 2009
Apr 2006 Zeta 1.2 Dead at 1.5.1 in 2007, BeOS-based
May 2006 Contiki 1.3 [Hosted]
Jun 2006 (K)Ubuntu 6.06 6.06.1 update for desktop. EOL 2009
Jul 2006 SLES 10 SP4 in 2011. EOS 2013 (extended 2016)
Jul 2006 Symbian OS 9.3 Last version by Nokia before turned to Symbian^1 [WINS]
Sep 2006 Menuet32 0.83B Dying.. focus goes to Menuet64
Sep 2006 ReactOS 0.3 0.3.x are development releases
Nov 2006 VxWorks 6.4 Older 5.5 in 2002 [VxSim]
Nov 2006 RISC OS 6 Last major version 6.x and 5.x [VirtualRPC]
Dec 2006 AmigaOS 4.0 First to use PPC [WinUAE]
May 2001 OpenVMS 7.3 Last version. EOL 2012 [SimH]
Oops this one before XP...
Funny how many PC commercial OSes dying/died during XP era.

06 February 2016

How to "use" isobuster for free

Since the day when CD burners don't have buffer underrun protection and that my HDD free space actually smaller than CD capacity this little software with cool batman icon always become a lifesaver. That time isobuster still free (pre 1.0 version), now within few years we might discard optical media for data completely (backup is OK though).

Isobuster interpret multisession disc, all kind of ISO 9660 extensions (Joliet, RR), UDF, extra track such HFS or FAT and El-torito boot image. It also show you the important thing: LBA! so you can tell by its physical location which files is vulnerable to disc defect. Finally isobuster do interruptible copying for recovery purpose. The old 0.99.9 still works on modern Windows as long as you run as administrator (or just add elevation manifest to it) but there is no support for UDF.

I know that Isobuster can be used in free (sometime nagging) mode but I'm not talk about that. The tool is FTK Imager Lite by accessdata. This forensic tool known to bundle isobuster 2.4 as shared library from version 2.6 onward, you can get older (and smaller) version via archive.org too. For current version: http://accessdata.com/support/adownloads

The basic important functionality is there, no LBA column list though instead placed in file property panel. No ISO image dumping except forensic image format. And no data carving (isobuster 3?). Overall what make isobuster so special already covered. Enjoy!

Two advanced free hex editors for Windows

Back in the day when all of my software were pirated software, WinHex is the single best thing I ever need. Now to replicate its functionality I have to combine two application HexEdit and TinyHexer or more.


1. TinyHexer was my first free hex editor, it was the best during its time and probably still if only it support big file. The homepage www.mirkes.de has gone so you need to find mirror for mpth_18.exe or mpthme_18.exe. Here is mirror from softpedia http://download.softpedia.com/kRHV01DUV2Ym8XNnMprEEBK6t2a4wgfe/software/programming/.

TinyHexer's strength lies on good manipulation features and plugins which serious user will establish workflow with this tool. Furthermore tinyhexer is highly extendable, it has Delphi SDK (the file is gone?), scripting and macro replay. TinyHexer also has good reference help including scripting but not covering many of its plugins. One to note somehow tinyhexer doesn't allow paste in overwrite mode, make it hard when you have to combine/patching part of files, another minor inconvenient is the full page mouse scrolling.


2. HexEdit (okay what an ambiguous name here :P) the homepage is http://www.hexedit.com/. Personally I use this as tinyhexer replacement, but not for all features otherwise some are overlapped between the two. For example HexEdit missing opening process' memory but beside that HexEdit is completely different kind of hex editor. The overwhelming editing aids such track changes, mark/bookmark, highlighter, etc really make HexEdit like a word processor for binary files. Manipulation feature also extensive, lots of bitwise operation and conversion it even has data encryption (built-in) and arbitrary compression (via Zlib). HexEdit also have user expandable file structure template for analysis similar to tinyhexer.

One of its unique feature (WinHex can do this) that I like is "Keep Same Time" toggle which keep file date modification once you done editing. Its search function is comparable (no regexp unfortunately) but slower to tinyhexer. Startup also rather slow probably because its complex UI (based on MFC). The bundled manual is excellent, you'll need it for something like this. HexEdit also extendable via macro replay. In short HexEdit is the most advanced (if not overkill) open source hex editor I have ever used.

The niche extras. Two more hex editor deserve mention here for its built-in live disassembly and other for low-level operation.


3. FileInsight from McAfee http://www.mcafee.com/us/downloads/free-tools/index.aspx is hex editor specific for malware analysis so large file support is not a concern. Live disassembly is done using libdasm, by the way it will produce assembly for *any* interpretable binary data. The interface is rather flashy :D, I think this is a Delphi app. Its PE structure analysis is on par with the tinyhexer's plugin. And despite being niche, FileInsight also extendable, this time using JavaScript (via built-in spidermonkey engine) or Python (need preinstalled python). Note that open source wxHexEditor also can do live disassembly (via udis86) with other feature similar to the popular HxD.

disk editor
4. Active @ Disk Editor http://lsoft.net/disk_utilit.aspx is a low-level access hex editor that I have no other free comparison. The first two hex editor here able to open disk in raw however without the ability to traverse or sync with actual filesystem those two miss the usefulness. Most forensic tools also do low-level (raw mode) but usually for read-only acquisition and reinterpret the filesystem wholly including orphaned files (recovery) which Active @ Disk Editor doesn't (that what paid Active @ UNDELETE will do). Supported filesystem include: NTFS, FAT, HFS+, ExtFS, UFS and BtrFS. Like hexedit and tinyhexer, diskeditor also have templates in this case: boot record, partition table and so on. I found the interface rather confusing (Qt based) and could be more streamlined but this is no major issue. As bonus it could edit disk images too.


28 January 2016

NatGeo CNG image converter

Love geography? or you have downloaded their free huge magazine scans library? then you may interested in this tool from http://diplograph.net/posts/decoding_the_complete_national_geographic_images

In short cng2jpg de-obfuscate NatGeo's jpg files (lossless operation).

This is win32 version of C commandline application by Paul Knight, I just change the filemode to make windows version work.

cng2jpg.7z 11Kb

Alternatively .NET GUI application available at https://github.com/keithn/cng2jpg/releases