Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

15 December 2017

Migration pain from DVD disc

Since 2001 I have used CD, beyond scratches it's quite realiable, I have hundreds CDs still readable from which I bought between 2001-2007, that's up to 15 years durability and counting. There is an exception: all "GTPro CDR+" brand CDs are unreadable (all of them!), it's single most popular brand in my area (probably in the entire country) and represent  about half of all of my CDs. Was it a dumping case? who knows... Good things my conscience say I should not trust just one brand.

Since late 2000's I switched to DVDs and the awful traits just started to crop up just after 5 years period. "disc rot" which in my experience seems only happen with DVD, while in other hand CDs experience crumpling due to unprotected data layer surface (upside) which common on cheap disc, especially in outer region where physical contact often made with tray. DVD instead rot from inside, and it rot badly and visibly, a clear sign that this "backup" media need immediate replacement... duh!


The importance of LBA in your catalog

When data is stored in "continous and read only" manner, Knowing the LBA is like knowing the page number of a printed book, the table of content. That the lesson I learned (from isobuster) and unfortunately most cataloging software doesn't store LBA. Why important? because different burning software has different sorting order.

For example cdrtfe use:
All caps -> Title Case -> lowercase precedence for filename aka:

ZACK -> lower LBA
Duck
alabama -> higher LBA

And not just filename order, directory hierarchy also has several pattern order on how LBA then assigned to the files inside (root to child, parent directory grouping to root, etc).
Thus only have filename, size, or even metadata is NOT good enough. Because in the end during the nightmare you'll be like "Which burning software I use to burn that disc?" not good!

Imagine if TOC is not readable "enough" (I said "enough" because there may several TOC available: ISO9660, Joliet, Amiga RockRidge, Mac HFS, UDF etc and having one of supported and not fake one being readable is enough). You're left with huge multiple chunk of readable raw data with 2KB blocksize to recover, and with most type of files being binary you need to figure out header and end header of filetype, which size belong which file and so on, yeah possible as they are sequential... but not gonna do that to a hundred of 4 GB DVDs ain't we?


Recovery Tools

The tool that I use is cdrtools' readcd and isobuster. The latter is to figure out LBA from salvaged TOC, note that TOC not always written inner (lowest LBA) some software write TOC at highest LBA (outer) which most likely worst idea. Readcd is capable of image cloning as well as on-demand sector range copying. Note that isobuster is also capable of unstoppable copying but IMO not as good as readcd, therefor I use the free version 0.99.9, cdrtools is open source.

Note about unstoppable copying in both software:
While isobuster will pause on error via dialog box which then you can retry and continue.
With readcd (a commandline app) you can "force-pause" the pending not-yet-started loop cycle by selecting something (with left click) in the cmd window in Windows 10 or right-click -> select (block) for earlier Windows but you need to monitor the progress. Otherwise you can join readable chunks from sector range copying.

Condition

Unreadable: a disc that might superficially pristine (not even single scratch/rot) but become unrecognizable or before that, have tons of read errors all over area after period of being kept.
Disc rot: mostly happen from outer region to inner and quite visible, has washed out coloration.
Inaccessible: Disc TOC isn't readable "enough", On NT6 drive letter will show but will give error message when you access it
Unrecognizable: Your disc no longer considered a disc, it just some another plastic to your drive. None of your disc area is readable and not just the data area. Here on NT6 Drive letter wont show. So readcd/isobuster can't access it as well. Being uncognizable in mostly persistent and nothing you can do about it but at early stage you can bet your luck.

Dealing with physical damage

Use toothpaste to wash the disc from glued dirt and especially deep scratches. Note I don't know what going to happen to the disc due to detergent, but it always give new hope for retrieval, afterall once I get the data the disc will go straight to the bin.

Dealing with disc rot

Just because the area start to rot doesn't mean it become completely unreadable. Anywhere in the rotten area you could bet your luck to retrieve tiny file of several blocks. Most DVD any brand that I have tend to develop rot at varying degree. Somehow having TOC readable mean good chance of read for the rest data, not so much when TOC not readable that is resort to use sector range copying, of the very same disc but in different recovey session. So don't give up to make the TOC readable first. By average I could recover 3 to 3.7GB of 4GB data.

Dealing with the unreadabledisc

Now here we go the shitty part, the unreadable disc, the worst case scenario. Many remain mystery for me, like how the hell this crap being manufactured and being brand related occurrence. In my experience DVD brand printed as "mitsubishi" is known to be suicidal . From my experience there are several factor involved in recovery chance (of course most of the blame goes to the disc manufacturer):
- proper drive read speed (lowest speed is not always better!)

- the laser itself (yep this quite low-level so different drive, different chances)
- initial drive's spin-up/down
- operating temperature

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?
Considerations:
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
gettext 0.18.3.2
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
cppflags : -DGLIB_STATIC_COMPILATION -DGOBJECT_STATIC_COMPILATION -DGDK_PIXBUF_STATIC_COMPILATION -DPANGO_STATIC_COMPILATION -DATK_STATIC_COMPILATION -DGTK_STATIC_COMPILATION -DGDK_STATIC_COMPILATION

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.

Downloads
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

15 January 2016

Visual True Type for XP

Been years looking how to download this thing from Microsoft. Previously this was only available "by request" to Microsoft typography group or something, however it's near impossible to get a reply. Originally the program itself released circa 1999-2001 (yeah Win 9.x era and slightly updated when XP released). Now that it was made freely available https://www.microsoft.com/en-us/download/details.aspx?id=48728 (previously MS VOLT also made free and has been regularly updated). Together with other free tools in https://www.microsoft.com/typography/default.mspx are extensive font development tool for Windows. But there is one problem: VTT 6 is not for XP! geh

So I ask an anon question at stackexchange regarding backporting vista apps. I kind of expecting to get l33t answer like reconstructing IAT and some OllyDbg hacking session but it was shim method that come up. Well it was a technique commonly practiced anyway.

To summarize:
- VTT.exe need CompareStringEx and InitializeCriticalSectionEx which unavailable in XP kernel.
- Both functions available in msvcp140.dll (part of Visual C++ 2015 redistributable) with slightly different name along with other interesting backported functions
- VTT.exe is compiled with linker's osversion set to Vista (6.0)
- VTT.exe also protected with Microsoft digital signature

The shim will sit between vtt.exe and kernel32.dll+msvcp140.dll, so we could use renamed function redirection or loadlibrary way. I choose the first since there are not much of imported functions.

Basically I made shim that contain lowercase version of the function (you could use MSDN or MinGW headers to see the correct declaration) which call the actual function in kernel32.dll and msvcp140.dll for the missing one.

for example:
...
// CompareStringEx
WINBASEAPI int WINAPI __crtCompareStringEx (LPCWSTR lpLocaleName, DWORD dwCmpFlags, LPCWCH lpString1, int cchCount1, LPCWCH lpString2, int cchCount2, LPNLSVERSIONINFO lpVersionInformation, LPVOID lpReserved, LPARAM lParam);

WINBASEAPI int WINAPI comparestringex (LPCWSTR lpLocaleName, DWORD dwCmpFlags, LPCWCH lpString1, int cchCount1, LPCWCH lpString2, int cchCount2, LPNLSVERSIONINFO lpVersionInformation, LPVOID lpReserved, LPARAM lParam) {
__crtCompareStringEx (lpLocaleName, dwCmpFlags, lpString1, cchCount1, lpString2, cchCount2, lpVersionInformation, lpReserved, lParam);
}
...

and compile with:
gcc -shared -Wl,--kill-at -o vttforxp.dll vttforxp.c -L. -lmsvcp140 -s

Next we need to rename imported functions in VTT.exe to lowercase too (yeah kind of risky here) and rename kernel32.dll to vttforxp.dll, we can use hex editor.

Next we remove the digital signature, since it obviously become invalid now. we can use osslsigncode:
osslsigncode remove-signature -in vtt.exe -out vtt.exe

Next we need to downgrade os.version PE header to 5.1 (XP). we can use editbin or pehdr-lite
pehdr-lite vtt.exe -osver 5.1 -subsysver 5.1

As a bonus step, we can use Microsoft mt to add xptheme manifest

That's it! Well of course this case is rather simpleton but still is a real-world case :)
heck some apps even simply set the higher os.version (due to never compiler default) so that it could spew stupid error message like "invalid win32 application"...

 

09 December 2015

How to repack Visual Studio 2010 Express for SVCPACK installation

VS 2010 is the last for XP so I want to have convenient up-to-date package that I can slipstream into XP iso.
Firstly this post http://www.itninja.com/question/visual-studio-2010-express have all the ingredient for us to cook. Lets go!

- Extract all Ixp*.exe file with 7zip (ignore the warning).
- Make admin installer from each extracted vs_setup.msi (msiexec /a)
- Edit each of administrative version of vs_setup.msi with Orca:
  - Remove CA*LaunchCondition in all Install*Sequence tables (to allow running and updating)
  - Remove *SETUP entries from all Feature* tables (to remove copy of the whole cabinet installer)
  - Remove entries with CSETUPMM directory from Component table
  - Replace PIDKEY in Property table with your serial (without hyphens)
  - In Registry table find "UninstallString" (on first occurrence) and replace value of "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[ProductName]" with "MsiExec.exe /X[ProductCode] "also remove its "UninstallPath" entry
- Save your edited vs_setup.msi
- Now you can remove all files in root except vs_setup.msi and remove CSETUPMM folder from "Program Files\Microsoft Visual Studio 10.0"
- Apply all applicable updates (SP1, etc) into vs_setup.msi (use the *msp file from VS10SP1*.exe )

Beware about your OS situation (.NET version, MSI, etc) cause after this you're on your own.

In my test compressing all (C++, C#, VB, Web Developer and its dependencies) with 7zip produce just about 150MB! Quite a saving eh

Edit:
- After merging patches we need to reset the package-code (Orca View > Summary) with the original one (and change the description as well if you wish)

06 October 2014

How to enable GCC i686-w64-mingw32 multilib

I always opt i686-w64-mingw32 multilib when building GCC. That mean 32bit by default and 64bit via -m64. in GCC 4.9 (or since GCC 4.8 SEH introduction) this configuration seems to be broken / unsupported. By common sense if x86_64 multilib is supported then the inverse should be possible too.

Here is the patch:

--- D:/Tarball/gcc49s/libgcc/config.host.bak Thu Mar 27 22:40:31 2014
+++ D:/Tarball/gcc49s/libgcc/config.host Sun Sep 28 14:24:20 2014
@@ -646,8 +646,20 @@
  if test x$enable_sjlj_exceptions = xyes; then
   tmake_eh_file="i386/t-sjlj-eh"
  else
-  tmake_eh_file="i386/t-dw2-eh"
-  md_unwind_header=i386/w32-unwind.h
+  case ${host} in
+    i[34567]86-w64-mingw*)
+      if [ "${enable_multilib}" = yes ]; then
+        tmake_eh_file="i386/t-seh-eh"
+      else
+        tmake_eh_file="i386/t-dw2-eh"
+        md_unwind_header=i386/w32-unwind.h
+      fi
+      ;;
+    i[34567]86-pc-mingw*)
+      tmake_eh_file="i386/t-dw2-eh"
+      md_unwind_header=i386/w32-unwind.h
+      ;;
+  esac
  fi
  # Shared libgcc DLL install dir depends on cross/native build.
  if test x${build} = x${host} ; then


Might be a bit ugly but still make sense and works! Overall that's just a naming/convention mess. With the patch we should have SJLJ in 32bit and SEH exception in 64bit mode by default (a.k.a no exception handling specified at configure).

05 November 2013

How to build PyGI AIO with Moluccas

Read about Moluccas first, its gcc has experimental CRT targeting for this guide.

MS CRT targeting initially laid by official mingw.org but still far incomplete. At first I thought it would be as easy as set cflag/cxxflag __MSVCRT_VERSION__=0x0900 and add -lmsvcr90 to GCC's specs file, well for a trivial program? yes it can but thats all it can get. As my experiment goes by there are many issues piling up (from incomplete msvcr implib to puzzled LFS/Y3K macros) that forcing me to modify mingw's crt and win32api files to allow a package completely linked to the new msvcrt dll. In the end I decided to add new GCC flags to simplify this: -vcr70 to -vcr110. The flags correspond msvcrt redist version bundled by each release of Visual C++. Even today it still far from complete.

What it has to do with this guide? there is an article wrote by win32 contributors of Gnome framework (or whatever you called it) that explain the concern. While my approach is far cry in comparison to use real thing (yeah I know MSVC has free express edition) it still useful in some cases at least for OSS zealot (even if they use Windoze).

This guide will focus on latest stable version of GTK-related (should be called GObject-related) libraries as this written. The main packages are Glib 2.38.1 + GTK 3.10.2 + GI 1.38.0 + PyGObject 3.10.1 and we are targeting python 3.3 (which use msvcr100.dll). I must tell you though, there is steady progress to support MSVC from upstream at least for major libraries including GI thingy.

If you don't need CRT targeting, you can use any GCC of your preference in moluccas by put it into moluccas root then switch over using setgcc [gcc folder name].

Download moluccas 0.8a, you need to download the following packages:

M08.exe
M08-basemsys.7z
M08-basetools.7z
M08-ccomp.7z and newer gcc
M08-tex.7z
  1. Saves all of them in the same folder,
  2. Run M08.exe and specify install path (it's a portable installation). Click OK. Correction: If you have conemu instance(s) already run you need to quit all before clicking OK, see Maximus comment.
  3. The installer dialog will vanish quickly to bootstrap conemu and continue with extraction. Due to the sheer number of files, the extraction (write to harddisk) will be way slower than what the CPU capable of.
  4. Once completed, run conemu.exe to start
  5. Moluccas will try to detect any presence of Visual C++ and try to integrate the latest version you have. During first run it also initialize Miktex installation
  6. In the end conemu panel will bring the <^> prompt
  7. Type spawn to start an instance of conemu. The panel will hide and still accessible via systray icon.
edit:

I will put latest patches and buildscript at https://github.com/tumagonx/pygi-mingw-patches

06 February 2013

How to get recent usp10.dll for your aging XP

According to wikipedia article about Uniscribe http://en.wikipedia.org/wiki/Uniscribe you can get (as this written) the latest usp10.dll from Office 2010 (the last Office to support XP) and slightly updated version 1.626.7600.20796 from its SP1, but you could get it in easier way:

- Download full installer of PowerPoint Viewer and install it  ( see comment below )
- or download the smaller PowerPoint Viewer 2010 SP1 then open powerpointviewer2010sp1-kb2460050-x86-fullfile-en-us.exe with 7-zip -> double click ppviewersp1-en-us.msp -> double click PATCH_CAB -> extract USP10.DLL_0002 and rename to usp10.dll. Install the file manually, now that's tricky

27 April 2012

Multiple Google Drive (Do It Yourself)

Google head to cloud! started with Google Drive, a 5GB (free) file synchronization service application based on Python 2.6 and wxWidget (similar to dropbox). If you haven't notice it, google drive during startup extract itself into temporary folder (_MEI???) where python do its stuff.

How? well not too dissimilar from dropbox trick:

Download it first (I hate to download a downloader that claiming as installer, screw it!)
one of mirror:
http://v2.nonxt6.c.pack.google.com/edgedl/drive/1.0.2891.6813/gsync.msi

Once it installed "silently" you will find it in %PROGRAMFILES%\Google\Drive
I believe that's what you get if you're administrator

Copy all files, make a folder [somewhere] and paste there

Copy following text into notepad:

@ECHO OFF
:: NOT FOR EXPLOITATION!
SET USERNAME=Tukul
SET USERPROFILE=%~dp0%USERNAME%
MD "%USERPROFILE%\AppData\Roaming">nul
MD "%USERPROFILE%\AppData\Local\Application Data">nul
MD "%USERPROFILE%\Application Data">nul
MD "%USERPROFILE%\Local Settings\Application Data">nul
MD "%USERPROFILE%\My Documents">nul
MD "%USERPROFILE%\Documents">nul
START googledrivesync


Save above as "gdloader.bat" (you may change "Tukul" to anything else, just be descriptive) in [somewhere]
Run gdloader.bat,  You know what to do next!

make another copies if you want another Google Drive (be sure name different %USERNAME%)


Notes:
- Apparently when google do shell registration (shortly after finishing folder setup), Google Drive will nuke current account like crazy (at least in my XP) but that's okay, no worries
- As usual only one account that get file markings (checked icon etc...)
- Tested in XP go try yourself on other Windows!

02 April 2012

Continued... PHP and nginx

Tonight I try to resume what I left yesterday: setting up php with nginx. I try to follow http://wiki.nginx.org/PHPFastCGIOnWindows, but since I have single exe php-cgi I would just copy it and php.ini into nginx folder. Thus use non-hardcoded path configuration:

Before that I have to comment about the RunHiddenConsole thing, in PE thingy this is just a matter of using -mwindows or -mconsole during compile. And there is a better tool called postw32 (from freepascal project, I included this in my mingw build) which could turn any console application into consoleless a.k.a "click and nothing seems to happened" (because it was already windowless) or vice versa (back to console again).

so inside conf\nginx.conf instead of:

root c:/www;

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9123;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}


I just need (merely replace /scripts with  $document_root  from stocked config):

location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}


Both configuration assumed we have virgin php.ini (doc_root has empty value, do not confuse with nginx's   $document_root  above which translate root declaration before it that is "html" which refer to html folder relative to where nginx.exe located). In short we have portable configuration.

Now talk about respawning thingy... in the bottom part of the wiki before describe how to make it run under SYSTEM account. Well let me tell you something:
AFAIK we (as admin) could impersonate to SYSTEM using "at" (scheduler) command then kill "explorer.exe" just before launched and bang Windows P4WN3D and CHR00T3D! no no not that old trick, actually the proper way is to use "sc" command see below:

C:\Users\Administrator>sc create --help
Creates a service entry in the registry and Service Database.
SYNTAX:
sc create [service name] [binPath= ] ...
CREATE OPTIONS:
NOTE: The option name includes the equal sign.
type= (default = own)
start= (default = demand)
error= (default = normal)
binPath=
group= 
tag=  
depend=
obj= (default = LocalSystem)
DisplayName=
password=


Extra Extremely Important Note: That is an empty space right after equal sign and before the actual value.

Now we could even make php as service too that depends on nginx service, or run them under different credential (a hidden user preferably, you know like postgresql way). Nginx already have respawning (parent - child) facility adding it to relaunching service will increase its reliability more too.

Hmm.. I will make my own stack installer one day maybe came up with tagline: "Install and run in 5 seconds yet takes only 10MB of space" Yeah whatever, but I really hope this will become a fine release and get it's own page in the main menu of my blog. Certainly need more testing


14 February 2012

How to perfectly mix 32bit and 64bit libraries in MinGW

Assuming you have multilib (dual 32bit/64bit) GCC and you have common libraries in /usr/local you could put all 32bit and 64bit in /usr/local/lib folder altogether.

How? I found out that GCC filename lookup for libraries (be it import lib or static lib) have the following order:
In case of -l[foo] getting parsed:
1. lib[foo].dll.a
2. [foo].dll.a
3. lib[foo].a
4. [foo].lib

The common convention is (1) as import library and (3) as static library however this may varied among makefiles. If you're willing to do a little renaming work or better more edit the libtool or makefiles. You could arrange them this way:

32bit import lib: lib[foo].dll.a
32bit static lib: lib[foo].a
64bit import lib: [foo].dll.a
64bit static lib: [foo].lib

This way, during compile gcc will look for all possibilities till found the matched bitness with import lib having higher priority than static lib. Huh lucky number 4 eh?

Hence the same -L/usr/local/lib and -lfoo for both 32 and 64bit hence single .pc (pkg-config) file too. Nice!

I use this convention in my MinGW toolchain

22 January 2012

Spidermonkey 1.8.5 MinGW

After tried Webkit's JSCore previously which is quite working despite unstable webkitgtk, I decide to compare it with Mozilla's offering: spidermonkey. Sadly neither it was new? (1.8.5) nor they provide win32 binary? Did they?

Anyway there is a VS build here www.kahusecurity.com/2010/spidermonkey-1-8-5-for-windows/
So why not MinGW?

Binaries and devel files (Mingw32 dwarf2 exceptions not MinGW-w64):
SpiderMonkey-1.8.5_mingw32.7z
The js.exe only depends on msvcrt.dll and libnspr4.dll, no WinSxS hell :-) Good, now I want to bind Gjs with python!

Build instructions:
Surprise, seems mozilla didn't care much about mingw (after seeking some pointers on their site)...
The source use autotooled configuration.. good :-) so does its dependencies: NSPR

1. To build it basically I just modify any line in configure that define CC/CXX as "cl" with gcc/g++ and remove all illegal options and flags such as -nologo and -mno-cygwin (GCC 4.6.2). Here is my configure for refenrence.

2. NSPR is easy to build: configure and make

3. For Spidermonkey be sure to define CC=gcc and CXX=g++ first, then I use: configure --with-nspr-prefix=[path to nspr] --with-windows-version=502 --disable-shared-js --enable-static

note:  --with-windows-version=502  needed to silence windres version error

4. Once completed, we will soon encounter infamous error WinMain thingy when compiling nsinstall, I already have this tool so I skip this and replace all $(INSTALL) occurrences with [path to nsinstall.exe]

5. Continuing, If we're unlucky there is an undeclared intptr_t in nanojit.h, just include wchar.h there

6. Build will resume smoothly, up to linking step where it complain invalid path (python not automatically turn "\" to "/"), So we have to edit libjs_static.a.fake file and replace all slashes

7. Continue make, and then make check which give me 2 errors: a math and a date test...

30 December 2011

How to make PyGimp Portable

There are become more and more plugins being implemented in python right?
This was explained two years ago in my older post here
Here is the small patch (applicable for gimp-2.7.4 too)

After build Gimp, we need to adjust the following files
lib\gimp\2.0\environ\default.env :
add the following line and remove any existing PATH declaration
#add binpath in non hardecoded way
PATH=${gimp_plug_in_dir}/../../../bin
PATH=${gimp_plug_in_dir}/../../../python

lib\gimp\2.0\environ\pygimp.env (there should be a blank line in the end) :
; PYTHONPATH=${gimp_plug_in_dir}/python

26 December 2011

OpenEXR with MinGW

I'm planning on updating my largest compile endeavor of err GTKGraphics Suite 2.0 however inkscape 0.49 seems take a bit more time (they are waiting for cairo 1.10.3?) obviously I'm reluctant to make inkscape 0.48.x build as it was the slowest before 0.49 (refactoring release). Then I'm thrilled that nip2 finally can directly open exr without crashing (no need to manually convert into .v image first).

However I wonder why openexr can't use pthreads under MinGW (note: I'm using pthread-win32 2.9) which I follow this build guide previously. Have a look at the following headers on IlmBase 1.0.1 (also in 1.0.2):
IlmThread.h, IlmThreadMutex.h, IlmThread and IlmThreadSemaphore.h

Clearly there is #ifdefs discrepancies..

13 December 2011

Yuk ngenet carane wong kere?

Piye tjuk lagi bokek? ra duwe duit? namung pengen fesbukan? Halah! ndeso...

Yen jenengan waos berita sa'niki, ngertos mboten soal "curi pulsa" sing tekan milyaran iku?
Nah iki dudu ngajari ben jenengan koyo ngono tjuk, cuma rada memper utawa "cara aluse"

Sa'umpamane jenengan kere mende tapi duwe kompie lan saged ngragati 'nggo tumbas modem cdma lan kertu perdana sing 7000an, kan kuwi ora larang banget tho tjuk? paling 'ntek satusan ewu ra nganti rongatus... Lah saiki jenengan pikir yen duit sakmono iso nggo ngenet sak puas'e?

30 October 2011

Building PyGTK for MyPaint

Continued from here. MyPaint require that PyGTK (GDK) to support numpy otherwise mypaint won't run. The debate is people said that the proper way to build python module is by using MSVC compiler since that's what python windows used with. While there is officially a library for GCC named libpythonXY.a some argue how stable a mixed build is.

IMHO gtk binding is bridging python and GTK, so what's the point using MSVC if GTK Runtime was build with GCC(MinGW)? Nah that's just my excuse because I don't know how to build it with MSVC :)

I've tested that I can use MinGW's pygtk with MSVC's pygobject with MinGW's GTK with MSVC's Python 2.6 and MinGW's MyPaint.... errr

Alright lets make it all MinGW's except for python shall we:

26 October 2011

Building GTK2 for MyPaint Windows

This post explain more detailed Windows port of MyPaint situation. I hope my english is understandable :)


MyPaint, the package

  • In windows mypaint use py2exe for bootstrapping and bundling with minor change in favor mypaint's builtin logging.
  • Mypaint is currently targeted only for win32, win64 is in experimental stage
  • Mypaint consist of a small portion of C++ library (which is why it need to be compiled) and the rest is in pure python. Mypaint require pygtk (with numpy support), numpy, GTK and optionally a particular version of psyco (a python accelerator)
  • Mypaint is squeezed! I kind of proud with this :) I have made mypaint stay around 8MB since version 0.7. All executable is packed with UPX at brute level. Furthermore brushes preview images have been pngcrush'ed.
  • Mypaint installer use NSIS with solid lzma compression. I believe this should be changed to msi

30 September 2011

SMS-an Gratis saka Gmail

Aku wis njajal sms-an nggo akun gmail, enak tjuk! pertama nganggo 'ntuk jatah 50 sms gratis, ra mung kuwi tapi yo 'ntuk nomer cantik cuma 'nem digit (rung ngerti yen iku di-share po ra sih).

Umpamane dewe'e sms sepisan (nomer Indonesia: indosat, telkomsel, three) jatahe kelong siji, yen dibales 'ntuk jatah 3, yen ra tau dibales nganti 'ntek jatahe dienteni ae 24jam (sedino) ngko bakal mbalek dadi 50 meneh. Enak tho? Namung yaiku kudu ol terus tjuk!

Citranipun ngene (saka perambah chrome):

29 September 2011

Some tips for downloading wiki using WinHTTrack

I'm on my way updating several chm release now: Sketchup 8, Blender 2.5 and others. I use WinHTTrack rather than wget to download more complex sites like wiki pages. Here some important scan rules to get relatively clean offline wiki site:

+*.css +*.js -ad.doubleclick.net/* -mime:application/foobar -*title=* -*Category:* -*Org:* -*Meta:* -*Talk:* -*User:* -*Special:* -*File:* -*action=* -*section=* -*Dev:* -*Help:* -*Template:*

It's important to make sure you don't have "+*.png" or any other image types scan rule! instead use "Get non-html files related to a link" option in links tab to get images. Wiki is known use fake link to image file which actually a html file which confuse the spider.

Edit: since we don't download the intermediate html file, a regex like this could be used to clean the broken link on all images:
 <a href="http://.*?>(<img.*?)</a>  replace with $1

29 August 2011

How To Try OpenVMS under ES40 Emulator

After reading some information about mainframe I'm directed to an opensource emulator for Alpha system called es40, which unfortunately halted. The main developer move to commercial project called Charon-AXP which also offer Personal Alpha (freeware but limited in performance). I'm quite interested with OpenVMS and it's possible similarities with Windows NT (remember Dave Cutler?). It would great to run this super reliable "relic" on plain XP :)

Steps:

1. Download es40 first here (you can pick last release or the snapshot in preferred variants)
2. Get your free DECUServe membership:
  - Start > Run > telnet (make sure you don't disable telnet service)
  - Inside telnet console, type decuserve.org and enter
  - You will greeted with username: prompt, now type REGISTRATION and enter

29 June 2011

How to enable DWG import in SketchUp 8 Free

As an architect living in Indonesia I (and many others) faced one same dreaded problem in my workflow: DWG dependency.
I've post list of applications that I use before, though I must share this info too (a bit too late actually).

So how to enable DWG Import in your Free SketchUp 8?

We all know Google stop supporting DWG Import feature starting from SketchUp 8 (free). The last one (7.1) have additional add-on http://dl.google.com/sketchup/gsu7/AllowDWGImportInSketchUp7.msi to enable it.

Then another way is: You can install SketchUp 8 Pro trial for 8 hours of usage if you want a temporary solution.

Or.. you can just stick with SketchUp 7.1 and ask your partners to downgrade save as sketchup 7 format for file exchange. Which is what I choose, after all there are not much important features in version 8.

Now.. do you know that actually there is no difference between both version?