Microsoft Windows应用程序设计(英文)

Microsoft Windows应用程序设计(英文)
作 者: Microsoft公司著
出版社: 北京大学出版社
丛编项: 微软编程圣典丛书
版权说明: 本书为公共版权或经版权方授权,请支持正版图书
标 签: Windows
ISBN 出版时间 包装 开本 页数 字数
未知 暂无 暂无 未知 0 暂无

作者简介

暂缺《Microsoft Windows应用程序设计(英文)》作者简介

内容简介

本书是《微软编程圣典丛书(影印版)》之一,讲述如何利用各种高级特性和最新技巧开发32位和64位Windows应用程序,内容涉及Windows 2000中的各种特性,API和DLL,进程和线程,结构化异常情况处理等。为了增加本书的实用性,特以配套光盘的形式提供了丰富的程序实例以及本书的电子版。本书由微软公司组织专家编写,具有相当的技术深度,是中、高级程序员必备的参考书。

图书目录

PARTⅠ:REQUIRED READING

CHAPTER ONE ERROR HANDLING

You Can This Too

The ErrorShow Sample Application

CHAPTER TWO UNICODE

Character Sets

Single-Byte and Double-Byte Character Sets

Unicode:The Wide-Byte Character Set

Why You Should Use Unicode

Windows 2000 and Unicode

Windows 98 and Unicode

Windows CE and Unicode

Keeping Score

A Quick Word About COM

How to Write Unicode Source Code

Unicode Support in the C Run-Time Library

Unicode Data Types Defined by Windows

Unicode and ANSI Functions in Winodows

Windows String Functions

Making Your Application ANSI-and Unicode-Ready

Windows String Functions

Resources

Determining If Text Is ANSI or Unicode

Translating Strings Between Unicode and ANSI

CHAPTER THREE KERNEL OBJECTS

What Is a Kernel Object?

Usage Counting

Security

A Process’s Kernel Object Handle Table

Creating a Kernel Object

Closing a Kernel Object

Sharing Kernel Objects Across Process Boundaries

Object Handle Inheritance

Named Objects

Duplicating Object Handles

PARTⅡ:GETTING WORK DONE

CHAPTER FOUR PROCESSES

Writing Your First Windows Application

A Process’s Instance Handle

A Process’s Previous Instance Handle

A Process’s Command Line

A Process’s Environment Variables

A Process’s Affinity

A Process’s Error Mode

A Process’s Current Drive and Directory

The System Version

The CreateProcess Function

pszApplicationName and pszCommandLine

psaProcess,psaThread,and blnheritHandles

fdwCreate

pvEnvironment

pszCurDir

psiStartInfo

ppiProcInfo

Terminating a Process

The Primary Thread’s Entry-Point Function Returns

The ExitProcess Function

The TerminateProcess Function

When All the Threads in the Process Die

When a Process Terminates

Child Process

Running Detached Child Processes

Enumerating the Processes Running in the System

CHAPTER FIVE JOBS

Placing Restrictions on a Job’s Processes

Placing a Process in a Job

Terminating All Processes in a Job

Querying Job Statistics

Job Notifiacations

The JobLab Sample Application

CHAPTER SIX THREAD BASICS

When to Create a Thread

When Not to Create a Thread

Writing Your First Thread Function

The Create Thread Function

psa

cbStack

pfnStartAddr and pbParam

pdwThreadID

Terminating a Thread

The Thread Function Returns

The ExitThread Function

The Terminate Thread Function

When a Process Terminates

When a Thread Terminates

Some Thread Internals

C/C++ Run-Time Library Considerations

Oops—I Called CreateThread Instead of _beginthreadex by Mistake

C/C++ Run-Time Lbbrary Functions That You Should Never Call

Gaining a Sense of One’s Own Identity

Converting a Pseudo-Handle to a Real Handle

CHAPTER SEVER THREAD SCHEDULING,PRIORITIES,AND AFFINITIES

Suspending and Resuming a Thread

Suspending and Resuming a Process

Sleeping

Switching to Another Thread

A Thread’s Execution Times

Putting the Context in Context

Thread Priorities

An Abstract View of Priorities

Programming Priorities

Dynamically Boosting Thread Priority Levels

Tweaking the Scheduler for the Foreground Process

The Scheduling Lab Sample Application

Affinities

CHAPTER EIGHT THREAD SYNCHRONIZATION IN USER MODE

Atomic Access:The Interlocked Family fo Functions

Cache Lines

Advanced Thread Synchronization

A Technique to Avoid

Critical Sections

Critical Sections:The Fine Print

Critical Sections and Spinlocks

Critical Sections and Error Handing

Useful Tips and Techniques

CHAPTER NINE THREAD SYNCHRONIZATION WITH KERNEL OBJECTS

Wait Functions

Successful Wait Side Effects

Event Kernel Objects

The Handshake Sample Application

Waitable Timer Kernel Objects

Having Waitable Timers Queue APC Entries

Timer Loose Ends

Semaphore Kernel Objects

Mutex Kernel Objects

Abandonment Issues

Mutexes vs.Crivical Sections

The Queue Sample Application

A Handy Thread Synchronization Object Chart

Other Thread Synchronization Functions

Asynchronous Device I/O

WartForInputIdle

MsgWaitForMultipleObjects(Ex)

WaitForDebugEvent

SignalObjectAndWait

CHAPTER TEN THREAD SYNCHRONIZATION TOOLKIT

Implementing a Critical Section:The Optex

The Optex Sample Application

Creating Thread-Safe Datatypes and Inverse Semaphores

The InterlockedType Sample Application

The Single Writer/Multiple Reader Guard(SWMRG)

The SWMRG Sample Application

Implementing a WaitForMultipleExpressions Function

The WaitForMultipleExpressions Sample Application

CHAPTER ELEVER THREAD POOLING

Scenario1:Call Functions Asynchronously

Scenario2:Call Functions at Timed Intervals

The TimedMsgBox Sample Application

Scenario3:Call Functions When Single Kernel Objects Become Signaled

Scenario4:Call Functions When Asynchronous I/O Requests Complete

CHAPTER TWELVE FIBERS

Working with Fibers

The Counter Sample Application

PARTⅢ:MEMORY MANAGEMENT

CHAPTER THIRTEEN WINDOWS MEMORY ARCHITECTURE

A Process’s Virtual Address Space How a Virtual Address Space Is Partitioned

Null-Pointer Assignment Partition(Windows 2000 and Windows 98)

MS-DOS/16-Bit Windows Application Compatibility Partition(Windows 98 Only)

User-Mode Partition (Windows 2000 and Windows 98)

64-KB Off-Limits Partition(Windows 2000 Only)

Shared MMF Partition(Windows 98 Only)

Kernel-Mode Partition(Windows 2000 and Windows 98)

Regions in an Address Space

Committing Physical Storage Within a Region

Physical Storage and the Paging File

Physical Storage Not Maintained in the Paging File

Protection Attributes

Copy-On-Write Access

Special Access Protection Attribute Flags

Bringing It All Home

Inside the Regions

Address Space Differences for Windows 98

The Importance of Data Alignment

CHAPTER FOURTEEN EXPLORING VIRTUAL MEMORY

System Information

The System Information Sample Application

Virtual Memory Status

The Virtual Memory Status Sample Application

Determining the State of an Address Space

The VMQuery Function

The Virtual Memory Map Sample Application

CHAPTER FIFTEEN USING VIRTUAL MEMORY IN YOUR OWN APPLICATIONS

Reserving a Region in an Address Space

Committing Storage in a Reserved Region

Reserving a Region and Committing Storage Simultaneously

When to Commit Physical Storage

Decommitting Physical Storage and Releasing a Region

When to Decommit Physical Storage

The Virtual Memory Allocation Sample Application

Changing Protection Attributes

Resetting the Contents of Physical Storage

The MemReset Sample Application

Address Windowing Extensions(Windows 2000 only)

The AWE Sample Application

CHAPTER SIXTEEN A THREAD’S STACK

A Thread’s Stack Under Window 98

The C/C++Run-Time Library’s Stack-Checking Function

The Summation Sample Application

CHAPTER SEVENTEEN MEMORY-MAPPED FILES

Memory-Mapped Executables and DLLS

Static Data Is Not Shared by Multiple Instances of an Executable or a DLL

Sharing Static Data Across Multiple Instances of an Executable or a DLL

The AppInst Sample Application

Memory-Mapped Data Files

Method1:One File,One Buffer

Method2:Two File,One Buffer

Method3:One File,Two Buffer

Method4:One File,Zero Buffers

Using Memory-Mapped Files

Step1:Creating or Opening a File Kernel Object

Step2:Creating a File-Mapping Kernel Object

Step3:Mapping the File’s Data into the Process’s Address Space

Step4:Unmapping the File’s Data from the Process’s Address Space

Step5 and 6:Closing the File-Mapping Object and the File Object

The File Reverse Sample Application

Processing a Big File Using Memory-Mapped Files

Memory-Mapped Files and Coherence

Specifying the Base Address of a Memory-Mapped File

Implementation Details of Memory-Mapped Files

Using Memory-Mapped Files to Shore Data Among Processes

Memory-Mapped Files Backed by the Paging File

The Memory-Mapped File Sharing Sample Application

Sparsely Committed Memory-Mapped Files

The Sparse Memory-Mapped File Sample Application

CHAPTER EIGHTEEN HEAPS

A Proess’s Default Heap

Reasons to Create Additional Heaps

Component Protection

More Efficient Memory Management

Local Access

Avoiding Thread Synchronization Overhead

Quick Free

How to Create an Additional Heap

Allocating a Block of Memory from a Heap

Changing the Size of a Block

Obtaining the Size of a Block

Freeing a Block

Destroying a Heap

Using Heaps with C++

PARTⅣ:DYNAMIC-LINK LIBRARIES

CHAPTER NINETEEN DLL BASICS

DLLs and a Process’s Address Space

The Overall Picture

Building the DLL Module

What Exporting Really Means

Creating DLLs for Use with Non-Visual C++ Tools

Building the Executable Module

What Importing Really Means

Running the Executable Module

CHAPTER TWENTY DLL ADVANCED TECHNIQUES

Explicit DLL Module Loading and Symbol Linking

Explicitly Loading the DLL Module

Explicitly Unloading the DLL Module

Explicitly Linking to an Exported Symbol

The DLL’s Entry-Point Function

The DLL_PROCESS_ATTACH Notification

The DLL_PROCESS_DETCH Notification

The DLL_THREAD_ATTACH Notification

The DLL_THREAD_DETACH Notification

Serialized Calls to D//Main

D//Main and the C/C++ Run-Time Library

Delay-Loading a DLL

The DelayLoadApp Sample Application

Function Forwarders

Known DLLs

DLL Redirection

Rebasing Modules

Bind Modules

CHAPTER TWENTY-ONE THREAD-LOCAL STORAGE

Dynamic TLS

Using Dynamic TLS

Static TLS

CHAPTER TWENTY-TWO DLL INJECTION AND API HOOKING

DLL Injection:An Example

Injecting a DLL Using the Rgistry

Injecting a DLL Using Windows Hooks

The Desktop Item Position Saver(DIPS)Utility

Injecting a DLL Using Remote Threads

The Inject Library Sample Application

The Image Walk DLL

Injecting a DLL with a Trojan DLL

Injecting a DLL as a Debugger

Injecting Code with a Memory-Mapped File on Windows 98

Injecting Code with CreateProcess

API Hooking:An Example

API Hooking by Overwriting Code

API Hooking by Module’s Import Section

The LastMsgBoxInfo Sample Application

PARTⅤ:STRUCTURED EXCEPTION HANDLING

CHAPTER TWENTY-THREE TERMINATION HANDLERS

Understanding Termination Handlers by Example

Funcenstein1

Funcenstein2

Funcenstein3

Funcfurter1

Pop Quiz Time:FuncaDoodleDoo

Funcenstein4

Funcarama1

Funcarama2

Funcarama3

Funcarama4:The Final Frontier

Notes About the finally Block

Funcfurter2

The SEH Termination Sample Application

CHAPTER TWENTY-FOUR EXCEPTION HANDLERS AND SOFTWARE EXCEPTIONS

Understanding Exception Filters and Exception Handlers by Example

Funcmeister1

Funcmeister2

EXCEPTION_EXECUTE_HANDLER

Some Useful Examples

Golbal Unwinds

Halting Golbal Unwinds

EXCEPTION_CONTINUE_EXECUTION

Use EXCEPTION_CONTINUE_EXECUTION with Caution

EXCEPTION_CONTINUE_SEARCH

GetExceptinCode

Memory-Related Exceptions

Exception-Related Exceptions

Debugging-Related Exceptions

Integer-Related Exceptions

Floating Point-Related Exceptions

GetExceptionInfomation

Software Exceptions

CHAPTER TWENTY-FIVE NUHANDLED EXCEPTIONS AND C++ EXCEPTIONS

Just-In-Time Debugging

Turning off the Exception Message Box

Forcing the Process to Die

Wrapping a Thread Function

Wrapping All Thread Functions

Automatically Invoking the Debugger

Calling UnhandledExceptionFilter Yourself

Inside the UnhandledExceptionFilter Function

Exceptions and the Debugger

The Spreadsheet Sample Application

C++ Exceptions Versus Structured Exceptions

Catching Structured Exceptions with C++

PARTⅥ:WINDOWING

CHAPTER TWENTY-SIX WINDOW MESSAGING

A Thread’s Message Queue

Posting Messages to a Thread’s Message Queue

Sending Messages to a Window

Waking a Thread

The Queue Status Flags

The Algorithm for Extracting Messages from a Thread’s Queue

Waking a Thread with Kernel Objects or with Queue Status Flags

Sending Data with Messages

The CopyData Sample Application

How Windows Handle ANSI/Unicode Characters and Strings

CHAPTER TWENTY-SEVEN THE HARDWARE INPUT MODEL AND LOCAL INPUT STATE

The Raw Input Thread

Local Input State

Keyboard Input and Focus

Mouse Cursor Management

Attaching Virtualized Input Queues and Local Input State Together

The Local Input State Laboratory(LISLab) Sample Application

The Local Input State Watch(LISWatch)Sample Application

APPENDIX A THE BUILD ENVIRONMENT

The CmnHdr.h Header File

Windows Version Build Option

Unicode Build Option

Windows Definitions and Warning Level 4

The Pragma Message Helper Macro

The chINRANGE and chDIMOF Macros

The chBEGINTHREADEX Macro

DebugBreak Improvement for 86 Platforms

Creating Software Exception Codes

The chMB Macro

The chASSERT and chVERIFY Macros

The chHANDLE_DLGMSG Macro

The chSETDLGICONS Macro

The OS Version Check Inline Finctions

Making Sure the Host System Supports Unicode

Forcing the Linker to Look for a(w)WinMain Entry-Point Function

APPENDIX B MESSAGE CRACKERS,CHILD CONTROL MACROS,AND API MACROS

Message Crackers

Child Control Macros

API Macros

Index