Wednesday, March 26, 2014

Kernal Objects

This post is the summarize of Ch3 "Kernal Objects" of Windows via C/C++, Fifth Edition Jeffrey Richter (Wintellect) Christophe Nasarre book.


What Is a Kernel Object ?

 Each kernel object is simply a memory block allocated by the kernel and is accessible only by the kernel. This memory block is a data structure whose members maintain information about the object. Some members (security descriptor, usage count, and so on) are the same across all object types, but most are specific to a particular object type. For example, a process object has a process ID, a base priority, and an exit code, whereas a file object has a byte offset, a sharing mode, and an open mode.

 Because the kernel object data structures are accessible only by the kernel, it is impossible for an application to locate these data structures in memory and directly alter their contents.

 Windows offers a set of functions that manipulate these structures in well-defined ways. These kernel objects are always accessible via these functions. When you call a function that creates a kernel object, the function returns a handle that identifies the object. Think of this handle as an opaque value that can be used by any thread in your process.

 To make the operating system robust, these handle values are process-relative. So if you were to pass this handle value to a thread in another process (using some form of interprocess communication), the calls that this other process would make using your process' handle value might fail or, even worse, they will create a reference to a totally different kernel object at the same index in your process handle table.

Tuesday, March 18, 2014

Working with Characters and Strings in Windows

This post is the summarize of Ch2 "Working with Characters and Strings" of Windows via C/C++, Fifth Edition Jeffrey Richter (Wintellect) Christophe Nasarre book.


Introduction & Some Definitions:
  • UTF : Unicode Transformation Format.
  • UTF-16 : encodes each character as 2 bytes (or 16 bits).

// Characters in C\C++
  • char   : data type to represent an 8-bit ANSI character.
  • wchar_t   : a built-in data type, which represents a 16-bit Unicode character.

// Characters in Windows Programming
  • CHAR   : An 8-bit character
  • WCHAR   : A 16-bit character

// Pointer to 8-bit character(s)
  • PCHAR : Pointer to CHAR (CHAR *)
  • PSTR : Pointer to CHAR (CHAR *)
  • PCSTR : Pointer to Constant CHAR (CONST CHAR *)

// Pointer to 16-bit character(s)
  • PWCHAR : Pointer to WCHAR (WCHAR *)
  • PWSTR : Pointer to WCHAR (WCHAR *)
  • PCWSTR : Pointer to Constant WCHAR(CONST WCHAR *)

// in Generic Case
// #ifdef UNICODE
  • TCHAR = WCHAR (Wide Character)
  • PTCHAR = PWCHAR (Pointer to Wide Character)
  • PTSTR = PWSTR (Pointer to Wide Character)
  • PCTSTR = PCWSTR (Pointer to Constant Wide Character)
// else
  • TCHAR = CHAR (Character) 
  • PTCHAR = PCHAR (Pointer to Character)
  • PTSTR = PSTR (Pointer to Character)
  • PCTSTR = PCSTR (Pointer to Constant Character)

// How to Use TCHAR (Generic case):
// #define __TEXT(quote) L##quote

TCHAR c = TEXT('A');
TCHAR szBuffer[100] = TEXT("A String");

_tcslen : wcslen (Unicode) = strlen (ANSII)

Monday, March 17, 2014

Error Handling

This post is the summarize of Ch1 "Error Handling" of Windows via C/C++, Fifth Edition Jeffrey Richter (Wintellect) Christophe Nasarre book.

Microsoft Windows is a complex operating system. It offers so many features and does so much that it's impossible for any one person to fully understand the entire system.This book teaches the reader about various Windows features and how to access them via the C and C++ programming languages. Although this book does not cover some Windows concepts such as the Component Object Model (COM). COM is built on top of basic building blocks such as processes, threads, memory management, DLLs, thread local storage, Unicode, and so on. If you know these basic building blocks, understanding COM is just a matter of understanding how the building blocks are used. 

64-Bit Windows:

 Machines based on these 64-bit CPU architectures are fast gaining acceptance. Microsoft has stated that Windows Server 2008 will be the last 32-bit version of Windows ever! For developers, now is the time to focus on making sure your applications run correctly on 64-bit Windows.

 The biggest advantage your application gets from a 64-bit address space is the ability to easily manipulate large amounts of data, because your process is no longer constrained to a 2-GB usable address space. Even if your application doesn't need all this address space, Windows itself takes advantage of the significantly larger address space (about 8 terabytes), allowing it to run faster.

Sunday, March 16, 2014

Windows via C/C++, Fifth Edition Book Summaries

Nowadays I started reading some chapters from Windows via C/C++, Fifth Edition Jeffrey Richter (Wintellect) Christophe Nasarre Book.

My goals from writing and publishing this summaries is:
  • Encourage myself to keep reading to increase my knowledge and improve my experience.
  • Help others.
  • Gain some money (Mostly indirect ways :D).

In this Post I will put links for all chapter summaries so it can easily reached.

Monday, February 17, 2014

How to crack "NTP Software" coding interview

 NTP Software is the worldwide leader in the management and control of unstructured data. It's a very good chance to developers in Egypt to work with, especially that NTP hire C++ developers which is very rare in Egypt.



 This Article will be useful for any candidate pass the HR interview and now prepare him\herself for coding one. The coding interview consist of 2 parts: face to face interview and task. If you pass the face to face interview the interviewer will assign a task to measure your skills. So to be ready for NTP you must prepare yourself by the following points.

Saturday, February 15, 2014

بسم الله نبدأ !! Hello World

بسم الله نبدأ :)
Hello World :)


After Break from writing for 2 years here we back :).
Back with new simple blog, to share simple experiences.

When I took my decision to continue "blogging" I have 2 choices, either continue with my old blog "هتكلم حتى إشعار أخر" or start a new simple one. I choose to start this one to reflect a new phase in my life and keep my old blog with all of it's posts, ideas and decisions as a great memories and a reference to my University days :).

I will Share My Life and Technical experiences. in Arabic and English. I aim to improve my English by writing and doing mistakes then fix them :).

Thanks :)