Building OpenSSL with Visual Studio 2010 for x64 / Win64 causes error

visual-studio-2010-x64-cross-tools-command-prompt

Today I was trying to build the latest OpenSSL 1.0.1c with Visual Studio 2010. Following instructions form the INSTALL.W32, I was able to successfully build the 32-bit version. Trying the same with 64-bit (x64) version, again following the official instructions from INSTALL.W64.
To build for Win64/x64:
> perl Configure VC-WIN64A
> ms\do_win64a
> nmake -f ms\ntdll.mak
> cd out32dll
> ..\ms\test

The first line ‘perl Configure VC-WIN64A’ went without any errors:
Configuring for VC-WIN64A
no-ec_nistp_64_gcc_128 [default] OPENSSL_NO_EC_NISTP_64_GCC_128 (skip dir)
no-gmp [default] OPENSSL_NO_GMP (skip dir)
no-jpake [experimental] OPENSSL_NO_JPAKE (skip dir)
no-krb5 [krb5-flavor not specified] OPENSSL_NO_KRB5
no-md2 [default] OPENSSL_NO_MD2 (skip dir)
no-rc5 [default] OPENSSL_NO_RC5 (skip dir)
no-rfc3779 [default] OPENSSL_NO_RFC3779 (skip dir)
no-sctp [default] OPENSSL_NO_SCTP (skip dir)
no-shared [default]
no-store [experimental] OPENSSL_NO_STORE (skip dir)
no-zlib [default]
no-zlib-dynamic [default]
...
...
...
SIXTY_FOUR_BIT mode
DES_INT used
RC4_CHUNK is unsigned long long
Configured for VC-WIN64A.

The second line ‘ms\do_win64a’ always returned errors:
ml64 -c -Foms\uptable.obj ms\uptable.asm
Microsoft (R) Macro Assembler (x64) Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.

Assembling: ms\uptable.asm
ms\uptable.asm(356) : error A2088:END directive required at end of file
ms\uptable.asm(356) : fatal error A1010:unmatched block nesting : _lazy18

Luckily I found solution in cyber-lynx.livejournal.com
Translation from Russian:
To prevent this, need to change file ms\do_win64a.bat like this: instead of

perl ms\uplink-x86_64.pl masm > ms\uptable.asm
ml64 -c -Foms\uptable.obj ms\uptable.asm

write

perl ms\uplink-x86_64.pl masm > ms\uptable.asm
ping 127.0.0.1
ml64 -c -Foms\uptable.obj ms\uptable.asm

It seems like race condition to me. Command ‘ping 127.0.0.1’ just adds a pause between two commands.

Thanks to Белая рысь (cyber_lynx)! Source: http://cyber-lynx.livejournal.com/40001.html

Did you know that IP addresses (IPv4) can be written in shorter representations?

Did you know that IPv4 addresses can be written in shorter representations, like IPv6 addresses?

Everyone have seen form of IPv6 represented as “shorter form”:
Example from IPv6:

  • 2001::7334
  • ::1
  • ::

You can use our free tool ipv6-literal.com to convert these addresses to long form. The result is:

  • 2001:0000:0000:0000:0000:0000:0000:7334
  • 0000:0000:0000:0000:0000:0000:0000:0001
  • 0000:0000:0000:0000:0000:0000:0000:0000

What admins / programmers usually do not know, is that the same principle applies to IPv4 addresses:

  • 127.1
  • 1
  • 192.168.257
  • 192.168.65535
  • 192.168.65535
  • 192.168
  • 10.1

To test these, use built in ping command. I used ping in Windows 7 and Ubuntu 10, and the result addresses are:

  • 127.1 -> 127.0.0.1
  • 1 -> 0.0.0.1
  • 192.168.257 -> 192.168.1.1
  • 192.168.65535 -> 192.168.255.255
  • 192.168 -> 192.0.0.168
  • 10.1 -> 10.0.0.1

As a bonus, you can try to ping other IP address representations:

  • ping 0x7F000001 – hex
  • ping 010 – octal, does not work in Ubuntu
  • ping 2130706433 – decimal

Why it works this way? Because network funcions built into OS support a such behavior, for example:

Have a fun, and remember, that year of IPv6 is near.

C# / .NET MessageBox is hidden behind the Form

Imagine calling the following C# code:MessageBox.Show(this, "Some text...", "Title", MessageBoxButtons.OKCancel);

After executing this line, the Message Box is not visible, it seems like hidden behind your form, without input focus, mouse clicks cause default beeps, and it suddenly appears if you click Alt or F10 key.

It turns out I had a custom drawing routine for one of the form’s controls (OwnerDraw / OnPaint), and I was changing the property that was causing the redraw cycle. Make sure, that in your OnPaint / DrawItem / DrawSubitem / etc. you are not invalidating your Control.

Also, if you are using .NET ListView control, it has a bug.

Because of a bug in the underlying Win32 control, the DrawItem event occurs without accompanying DrawSubItem events once per row in the details view when the mouse pointer moves over the row, causing anything painted in a DrawSubItem event handler to be overpainted by a custom background drawn in a DrawItem event handler. See the example in the OwnerDraw reference topic for a workaround that invalidates each row when the extra event occurs. An alternative workaround is to put all your custom drawing code in a DrawSubItem event handler and paint the background for the entire item (including subitems) only when the DrawListViewSubItemEventArgs.ColumnIndex value is 0.

http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.drawitem%28v=vs.80%29.aspx

This is not limited to MessageBox using C# / .NET framework. This also happens very often, with Win32 & WinAPI, with a Form class, etc.: