Skip to main content

Posts

Deep Dive to Windows, Part 2

In this section, I’d like to disassemble our main function which we’ve written in series 1 and would like to see how it looks like. Also would like to see if we can see the string “Hello World”. I’ve launched my sample executable using WinDbg. Then Issued following command: x sample_hello!*main* *** WARNING: Unable to verify checksum for Sample_Hello.exe 00419048           Sample_Hello!__native_dllmain_reason = 0xffffffff 0041917c           Sample_Hello!mainret = 0n0 004114b0           Sample_Hello!wmain (int, wchar_t **) 004122b0           Sample_Hello!__tmainCRTStartup (void) 00412290           Sample_Hello!wmainCRTStartup (void) 00413592           Sample_Hello!__wgetmainargs ( ) 0041a3d8           Sample_Hello!_imp____wgetmainargs = Since we know my intended function is ‘main’ so I searched for it. The highlighted one is our main function. Then unassembled the function using following command: 0:000> uf Sample_Hello!wmain Sample_Hello!wmain

Deep Dive to Windows, Part 1

This part of the discussion will revolve more towards inside of Windows OS. I bet you’ll love the way it has been designed and evolved. Issues might be there while using the OS but it’s a matter of debate whether application has been designed the way windows expect etc. This is not the space for that debate. Also, it’s is a not aim to teach anyone about windows but some facts and figure and little bit stack analysis and more. This is the first attempt from my side to do little bit debugging (I’m not an experienced debugger without source code) for user mode. Note: Mark’s (Mark Russionovich, widely popular for his work in Windows Internals) work always been inspiring for me. Let’s start the journey : In this series target environment is x86. In this series, I’d like to cover: 1.        Thread Environment Block: It’s a data structure that stores info about the currently running thread of a process. 2.        How it looks and what’s the significance of it? Le

A programming puzzle

I'd like to share a programming puzzle that I've encountered recently. The requirement was interesting and I was thinking over it. Finally, I got a way to deal with these non-conventional requirements. The requirement is something like below: 1. I need a program, which will launch another program from the command line (I mean Windows command line). I know this is not a big deal. But this requirement has two parts, which forced me to think: 1a. Once the user double clicks on the software, then a command prompt will launch and execute another program say notepad, and the command prompt will not return until the program launched (notepad) is closed by the user. 1b. If the user launches the program from an already open command prompt, then the prompt will not open another command prompt but launch another program (in this case notepad) and will not return until the launched program/process is closed. This is a relationship of parent-child. The parent is looking afte

Still in a learning process, not better than a mediocre student

I've spent a good amount of time in this Industry. Learned how to write good simple program and trying to learn more to reach to intermediate level. Journey was mix of reward and hardwork. Met people with different dimension, different skill set and lately realized I'm not only the person who wants to excel truly by learning the system more and more. Anyway in few upcomming series, I'll reveal some good approaches which I've learned so far by introspection. Will look more into the digital system and will see how it similar to our daily concepts.

Playing with WebBrowser class (C#.net)

Over the period of time C# really became a mature programming language. Compared to other standard programming language it's new but it has already offered lots to the programmer and many more new features are being added in Framework 4.0. I was exploring today, how I can work with websites like "Gmail" through my program. This is not a hack but a standard way of logging into the website, to do our work and logout. In this section, I tried to show, using the C#.net 'web browser' class, how anyone can log in to the site by providing a username/password and logging out. In this section I've not shown any other operation, I'll try to cover that in the future. Add the WebBrowser control on a WinForm Add three Buttons, one for UserName/PWD, the second button for login, and the third button for logout from Gmail. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using Sy

ASCII Magic for Upper and Lower case

We've 26 alphabets in English and using ASCII code we're representing it in the computer system. As an example, 'A' is represented as 65 in decimal, and 'a' is represented as '97' in decimal. Now check the binary counterpart of 65 and 97. 65 = 01000001 97 = 01100001 From the above binary representation, it's quite clear that the upper case letter differs from the lower case letter in binary representation, exactly in a one-bit position. The above example shows these two codes differ in the 5th bit. This is true for all 26 English alphabets and can easily be deduced to an implementation in C++ to convert any lower-case English letter to an upper-case letter. The following code demonstrates it: #define toUpper(ch) ((ch >= 'a' && ch <='z') ? ch & 0x5f : ch) int _tmain(int argc, _TCHAR* argv[]) { printf("Upper case conversion: %c\n", toUpper('b')); return 0; } *Inspired by Great Peo

Exceptions of floating point normalization

Floating point normalization has a great usage for computing anything very near to accuracy. A floating point number is consists of: Mantissa or significand. Exponent. Say, I've a number 123.75. Its a floating point number. It has integer significand, 12375 and exponent -2. So arithmatic representation is 12375 x 10 -2 . How to normalize a floating point number? - By shifting the mantissa to left until a 1 appears in most significant bits(HO). Hence, the normalized representation will be 1.2375 x 10 +2 . Most of the time for normalized number this bit is hidden as it happens to be 1. This is hidden bit. Now the question when we can't normalize a floating point number? - There are two such situations: We can't normalize zero(0). The floating point representation of Zero doesn't contain any 1 bit. However, IEEE representation for +0 and -0 has different significance. We also can't normalize a floating point number whose most significant bits in mant