Monday, 27 July 2009

TCP for Windows Hackers (And a bit of TCP History)

A TCP connection is half-open when the station at one end of the connection has crashed or otherwise removed the socket without informing the other end.
An embryonic connection is a TCP connection which is in the process of being established.

In UDP you can just start sending packets, whereas in TCP, you need to establish a connection before you send packets. Establishing a connection in TCP is done via a three-way handshake: client sends SYN, server sends SYN-ACK, then client sends ACK back to the server. At this point, client and server both have an acknowledgement of the connection.

Another difference between TCP and UDP is retransmission of lost packets.

The big names in packet network protocols are "Father of the Internet" Vint Cerf and Bob Kahn (PhD Princeton). In 1974 they published an IEEE paper: "A Protocol for Packet Network Interconnection". A central part of this protocol was the Transmission Control Program, later to evoive into TCP.

Need to understand TCP connections well to understand DOS and DDOS attacks.

Tuesday, 21 July 2009

Evidence-Based Scheduling

New Joel Spolsky article. Includes tips on budgeting for interruptions and status meetings.

Thursday, 9 July 2009

Building Windows DLLs

Check out creating a DLL, MSDN Guide to DLLs (lo-bandwidth)

To build a DLL in MSVC Express, create a Win32 app, then reload the project as follows: File->New->Project from Existing Code. Eventually you will reach an option that lets you change the project type to DLL.

Wednesday, 8 July 2009

Dot Net Posters

Christmas has come early for C# programmers with the Visual C# 2008 Keybinding reference poster. Truly awesome shortcuts, such as Shift-F12 to "Find all references", and Cntrl-ML (to "expand/collapse all") will save you hundreds of thousands of mouse-clicks in the long-run.

When you open the pdf in Adobe Reader (mine is Version 8.0), hit Control-L1 to display the poster Actual Size and in full-screen mode.

There is a really AWESOME, voice-synthesis feature in Adobe Reader (click View->Read this Page Only).

Tuesday, 7 July 2009

NTVDM has encountered an illegal instruction

This comes up when you do something weird in a DOS window, and appears in a plain messagebox with title "16 bit MS-DOS Subsytem". Perhaps you are running a command that requires bash to be initialised? VDMs are run as applications rather than server processes. Subsystems are server processes, like Windows environment subsystem (csrss.exe -> Client/Server Runtime Subsystem).

ColumnChoosers and Such-Like

A C# dgv column chooser? is that too much to ask?

Infragistics have a solution, that works as follows:

(basically you need to set the RowSelectorHeaderStyle property on the DisplayLayout property of the grid.)

using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
this.ultraGrid1.DisplayLayout.Override.RowSelectorHeaderStyle =
RowSelectorHeaderStyle.ColumnChooserButton;


Telerik also have a solution via their winforms gridview:

http://www.telerik.com/help/winforms/telerik.wincontrols.gridview-telerik.wincontrols.ui.radgridview-columnchooser.html

Sunday, 5 July 2009

Legacy C#

System.Winforms (.NET 1.0) is now System.Windows.Forms. WinForms is key to knowing C#. C# 2.0 and beyond is a different beast to C# 1.0,1.1 so quite a leap is needed in terms of learning/adjusting to the new object model.

DataGrid --> DataGridView (DG -> DGV)

DGV has a new way of doing TableStyles. In the old datagrid, to hide a column we could just access the column width hierarchically, via the TableStyles and ColumnStyles properties e.g. grid.TableStyles[0].GridColumnStyles["myfield"].Width = 0 however the DGV has no concept of TableStyles. Features are directly exposed on the DGV control, the relevant one here being HeaderDefaultCellStyle. Read more on "styling a DGV" here. DGV is easier in a way, we can just to dgv.Columns[ColName].Visible=false.

ContextMenu --> ContextMenuStrip (CM->CMS)

CMS is typically displayed when user right-clicks a control. Many visible controls have a Control.ContextMenuStrip property. CMS can be shared between multiple controls. The principle is the same for CM as for CMS.

Wednesday, 1 July 2009

Dotfuscation

Aristo's Dilemma

"How does one obfuscate one's Dot net code?" asked the aristocratic programmer. "Why is such obfucation useful, even, dare one say it, necessaire?"

"Dude, Obfuscation, or should I say, Dotfuscation, is about scrambling radical code, data and symbols to thwart the reverse engineering of one's awesome Dot Net code," replied Bill, of Excellent Adventure fame.

"Oui, oui, but how does one achieve such, as you say it, Dotfuscation, or to paraphrase, obtain obfuscated statoos in one's programmatory creationarios?" insisted Monsignor Aristo. "I am most concernatoried with respect to tools like that dastardly Reflector being used to read my most excellent codified verbiage".

"Dude, if your verbiage is, like, on the server, then it's not an issue, man!!" ranted Bill, and Ted echoed. "Yeah, dude. For web scenarios, it's like, no problem".

Aristo was not satisfied. "This is a most pertinent issue for ISVs selling client applications containing 'les secretes' of trade".

"Ok, then!" said Bill. "Try Dotfuscator Community Edition, man". Said Ted, "Yeah, dude. Protect your dot net apps, dude".

"Dotfuscator? As in Dotfuscation?" inquired Aristo. "What other options do I have? Can one utilise open source libros well to achieve same end-goal? If answer is nein, can one develop one's own obfuscation software? What techniques can one use to achieve same end-goal?"

Dotfuscation Techniques