1 JMH Associates © 2004, All rights reserved Chapter 1 Getting Started with Win32/64.

Slides:



Advertisements
Similar presentations
MPI Message Passing Interface
Advertisements

An Overview Of Windows NT System Student: Yifan Yang Student ID:
COURSE: COMPUTER PLATFORMS
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Chorus and other Microkernels Presented by: Jonathan Tanner and Brian Doyle Articles By: Jon Udell Peter D. Varhol Dick Pountain.
Chap 2 System Structures.
Operating System Structure
1 Module 1 The Windows NT 4.0 Environment. 2  Overview The Microsoft Operating System Family Windows NT Architecture Overview Workgroups and Domains.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Lecture 2: OS Programming Interface T.Yang, CS
Course Overview Introduction Computer System Structures
INTRODUCTION OS/2 was initially designed to extend the capabilities of DOS by IBM and Microsoft Corporations. To create a single industry-standard operating.
Case Study: Windows 2000 Part I Will Richards CPSC 550 Spring 2001.
2: OS Structures 1 Jerry Breecher OPERATING SYSTEMS STRUCTURES.
Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 121 Today’s class Operating System Machine Level.
1 CE6130 現代作業系統核心 Modern Operating System Kernels 許 富 皓.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Chapter 8 Windows Outline Programming Windows 2000 System structure Processes and threads in Windows 2000 Memory management The Windows 2000 file.
Ceng Operating Systems
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 11 Case Study 2: Windows Vista Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Excellence Publication Co. Ltd. Volume Volume 1.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.
Assembly Language for x86 Processors 7th Edition
WEEK 1 COURSE INTRODUCTION INTRODUCTION TO OPERATING SYSTEMS OPERATING SYSTEM STRUCTURES Operating Systems CS3013 / CS502.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 2: Operating-System Structures Operating.
April 2000Dr Milan Simic1 Network Operating Systems Windows NT.
Windows XP. History Windows XP is based on the NT kernel developed in 1988 Windows XP is based on the NT kernel developed in 1988 XP was originally sold.
Windows 2000 Course Summary Computing Department, Lancaster University, UK.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures T.Yang, 2012 Partially based on the.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Windows NT Operating System. Windows NT Models Layered Model Client/Server Model Object Model Symmetric Multiprocessing.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Advanced Design and System Patterns The Microkernel Pattern.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Windows Environment History of Windows: Windows was announced by microsoft in november 1983 and was released in november Advantage: Windows 1.0.
Overview of Operating Systems Introduction to Operating Systems: Module 0.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS2: Operating System Principles 2.4. The Windows.
© Paradigm Publishing, Inc. 4-1 Chapter 4 System Software Chapter 4 System Software.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Chapter 2. System Structures
System Programming Course introduction Getting Started …
OPERATING SYSTEM BY KINSHUK RASTOGI. WHAT IS AN OPERATING SYSTEM? What is an operating system in the first place? An operating system is a software that.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
A+ Guide to Managing and Maintaining Your PC, 7e Chapter 2 Introducing Operating Systems.
Chapter 3: Windows7 Part 5.
Chapter 2: Operating-System Structures
Operating System & Application Software
CSE451 I/O Systems and the Full I/O Path Autumn 2002
Operating Systems: A Modern Perspective, Chapter 6
Unit OS2: Operating System Principles
CS490 Windows Internals Quiz 2 09/27/2013.
Chapter 3: Windows7 Part 1.
Chapter 3: Windows7 Part 2.
Chapter 3: Windows7 Part 5.
Windows Internals Brown-Bag Seminar Chapter 1 – Concepts and Tools
Windows APIs File Processing Copyright © 2016 Curt Hill.
Files in Windows API David Halbig Lopez.
Assembly Language for Intel-Based Computers
Chapter 3: Windows7 Part 2.
B.Ramamurthy Chapter 2 : Appendix
Units with – James tedder
Operating Systems : Overview
Operating Systems : Overview
Operating Systems : Overview
Operating Systems : Overview
Windows NT History Design Principles System Components
OPERATING SYSTEMS STRUCTURES
Operating Systems Structure
Presentation transcript:

1 JMH Associates © 2004, All rights reserved Chapter 1 Getting Started with Win32/64

2 JMH Associates © 2004, All rights reserved Chapter 1 OBJECTIVES Upon completion of this Chapter, you will be able to:  Describe the Windows API  Its role in Windows 2000, XP, 2003 (“NT5”)  And obsolete systems (9X, NT4)  Windows style and programming conventions  Develop Windows applications using Microsoft Visual C++  Develop and run a simple application  Use the basic debugger features  Use the online help to obtain additional information  Win64 migration and portability issues

3 JMH Associates © 2004, All rights reserved OVERVIEW (1 of 2) Windows 2000, XP, 2003 (“NT5”) as Operating Systems  Their roles as operating systems  The Windows API  Win64 migration and portability  Differences  Architecture

4 JMH Associates © 2004, All rights reserved OVERVIEW (2 of 2) Getting Started with Windows  Naming conventions  Programming conventions  Style  Sample program Lab: Use Visual C++ to build and run a sample application

5 JMH Associates © 2004, All rights reserved WINDOWS NT FAMILY AS OPERATING SYSTEMS Windows 32-bit operating systems have all the features required for desktop, departmental, and enterprise computing 64-bit systems are on the way Essential features include:  Memory: large, flat, virtual memory address space  File systems, console, and other I/O  Multitasking: processes and threads  Communication and synchronization  Single system and networked  Security

6 JMH Associates © 2004, All rights reserved THE Windows API Windows is the 32-bit API used by:  Windows 9X (95, 98, Me)  Windows NT  Windows CE (palmtops, embedded systems, etc.)  Win64 is very similar at the source level  Supported on Windows 2003 and Itanium processor family  Windows statements nearly always apply to Win64 There are several major subdivisions, including:  Windows Management  Graphics Device Interface (GDI)  System Services  Multimedia  Remote Procedure Calls

7 JMH Associates © 2004, All rights reserved SYSTEM SERVICES This course covers the System Services  The brains of Windows  System Services enable everything else  The Course Chapters cover the essential system service Repeat: Topics NOT covered  Device Drivers  OS internals  Graphical User Interface (GUI) programming  COM, DCOM, MFC,.net  Development environments – learn as you go

8 JMH Associates © 2004, All rights reserved WINDOWS NT 5 (1 of 2) All platforms use the Windows API, BUT there are differences:  Windows NT4 (and above) has full NSA “Orange Book” C2 security features.  “NT” means NT 4.0 and above (including all NT5)  Windows 9X only runs on Intel x86 architecture  Only NT supports SMP  Windows 2003 also runs on Itanium,...  Windows 2003 for Win64 migration Note: Windows CE also supports Windows on several processor architectures

9 JMH Associates © 2004, All rights reserved WINDOWS NT5 (2 of 2)  Windows NT uses UNICODE international character set throughout  Windows 9X limits asynchronous I/O to serial devices  Windows NT has a fully protected kernel  Windows NT supports the NTFS, a robust file system  Windows 9X and CE will not support as many resources  Open files, processes, etc.  Many Windows 9X Windows functions have restricted implementations In general, Windows programs are portable between platforms at both the source and, mostly, binary level

10 JMH Associates © 2004, All rights reserved THE WINDOWS NT ARCHITECTURE Windows is the dominant environment running on the NT (all versions) executive OS/2 and POSIX compatility modes are rarely used Historical interest only

11 JMH Associates © 2004, All rights reserved KERNEL HAL: Hardware Abstraction HARDWARE Process Manager Systems Services Virtual Memory Manager I/O Manager NT Executive Protected Subsystems Applications OS/2 Program Windows Program POSIX Program OS/2 Subsystem Windows Subsystem POSIX Subsystem

12 JMH Associates © 2004, All rights reserved GETTING STARTED: MINIMUM SYSTEM REQUIREMENTS System running Windows NT5  Other versions will run most, but not all, examples Intel Pentium CPU (or equivalent: AMD, 486,...)  Alternative: Itanium Memory and free disk space  As required by your development system C compiler and development system  Microsoft Visual C++ Version 6.0 (or higher) .net These requirements are easy to meet with current system prices and common configurations

13 JMH Associates © 2004, All rights reserved GETTING STARTED: Windows PRINCIPLES (1 OF 2) Nearly every resource is an “object” identified and referenced by a “handle” of type HANDLE Kernel objects must be manipulated by WindowsAPIs HANDLE datatype objects include:  filespipes  processesmemory mapping  threadsevents, mutexes, semaphores Windows is rich and flexible  Many functions perform the same or similar operations  Each function has numerous parameters and flags

14 JMH Associates © 2004, All rights reserved GETTING STARTED: Windows PRINCIPLES (2 OF 2) Windows thread is the basic unit of execution, rather than a process  A process can contain one or more threads  Each process has its own code and data address space  Threads share the process address space  Threads are “lightweight” and more efficient than processes  Used for servers, asynchronous I/O,...

15 JMH Associates © 2004, All rights reserved Windows NAMING CONVENTIONS Long and descriptive  WaitForSingleObject WaitForMultipleObjects Predefined descriptive data types in upper case  BOOL, DWORD, LPDWORD,... Predefined types avoid the * operator and make distinctions:  LPTSTR (defined as TCHAR * ) and  LPCTSTR (defined as const TCHAR * ) Variable names in API descriptions use “Hungarian” notation - we’ll avoid this convention  lpFileName — long pointer [to a zero terminated string]

16 JMH Associates © 2004, All rights reserved Windows PROGRAMMING CONVENTIONS is always included All objects identified by variables of type HANDLE  CloseHandle function applies to (nearly) all objects Symbolic constants and flags which explain their meaning  INVALID_HANDLE_VALUE and GENERIC_READ ReadFile, WriteFile, and many other Windows functions return Boolean values System error codes obtained through GetLastError () C library always available  But you cannot fully exploit Windows with it

17 JMH Associates © 2004, All rights reserved EXAMPLE: Windows FILE COPY (1 of 3) /* Basic cp file copy program */ /* cp file1 file2: Copy file1 to file2 */ #include /* Always required for Windows */ #include #define BUF_SIZE 256 /* Increase for faster copy */ int main (int argc, LPTSTR argv []) { HANDLE hIn, hOut; /* Input and output handles */ DWORD nIn, nOut; /* Number bytes transferred */ CHAR Buffer [BUF_SIZE]; if (argc != 3) { printf ("Usage: cp file1 file2\n"); return 1; }

18 JMH Associates © 2004, All rights reserved EXAMPLE: Windows FILE COPY (2 of 3) /* Create handles for reading and writing. Many*/ /*default values are used */ hIn = CreateFile (argv [1], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hIn == INVALID_HANDLE_VALUE) { printf ("Cannot open input file\n"); return 2; } hOut = CreateFile (argv [2], GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hOut == INVALID_HANDLE_VALUE) { printf ("Cannot open output file\n"); return 3; }

19 JMH Associates © 2004, All rights reserved EXAMPLE: Windows FILE COPY (3 of 3) /*Input and output file handles are open.*/ /*Copy file. Note end-of-file detection */ while (ReadFile (hIn, Buffer, BUF_SIZE, &nIn, NULL) && nIn > 0) WriteFile (hOut, Buffer, nIn, &nOut, NULL); /*Deallocate resources, such as open handles */ CloseHandle (hIn); CloseHandle (hOut); return 0; }

20 JMH Associates © 2004, All rights reserved Getting Ready for Win64 Objectives:  Win32 binaries run in 64-bit environment  Source code can be recompiled for 64-bit environment Cautions:  Do not assume integers and pointers are same length  Win64 introduces 64-bit pointers New data types include  DWORD32, DWORD64  POINTER_32, POINTER_64  LONG32, LONG64

21 JMH Associates © 2004, All rights reserved LAB 1–A (1 of 2) Use the VC++ environment  Build, run, and test the Windows file copy program, cpW  Extend the program so that it prints the value of the error message in case of any failure  Obtained from GetLastError()  Don’t forget to test this error reporting capability The source code is in Chapter1\cpw.c

22 JMH Associates © 2004, All rights reserved LAB 1–A (2 of 2) The instructor will show you how to:  Create a console application under Microsoft Visual C++  Execute the application  Use Visual C++ to edit and rebuild the program  Use the Visual C++ debugger  Use the online help Note: wined3.htm contains many explanatory comments, examples, diagrams, and book errata