分类 调试 下的文章

我想提供一些关于桌面堆的后续信息。在第一篇文章中,我没有讨论64位Windows、3GB或Vista上与桌面堆相关的内存范围的大小。所以,不用再多说了,下面是各种平台上的相关大小。

Windows XP (32-bit)

· 48 MB = SessionViewSize (default registry value, set for XP Professional, x86)

· 20 MB = SessionViewSize (if no registry value is defined)

· 3072 KB = Interactive desktop heap size (defined in the registry, SharedSection 2nd value)

· 512 KB = Non-interactive desktop heap size (defined in the registry, SharedSection 3nd value)

· 128 KB = Winlogon desktop heap size

· 64 KB = Disconnect desktop heap size

Windows Server 2003 (32-bit)

· 48 MB = SessionViewSize (default registry value)

· 20 MB = SessionViewSize (if no registry value is defined; this is the default for Terminal Servers)

· 3072 KB = Interactive desktop heap size (defined in the registry, SharedSection 2nd value)

· 512 KB = Non-interactive desktop heap size (defined in the registry, SharedSection 3nd value)

· 128 KB = Winlogon desktop heap size

· 64 KB = Disconnect desktop heap size

Windows Server 2003 booted with 3GB (32-bit)

· 20 MB = SessionViewSize (registry value has no effect)

· 3072 KB = Interactive desktop heap size (defined in the registry, SharedSection 2nd value)

· 512 KB = Non-interactive desktop heap size (defined in the registry, SharedSection 3nd value)

· 128 KB = Winlogon desktop heap size

· 64 KB = Disconnect desktop heap size

在运行3GB时,您还可能看到堆大小减小。在初始化窗口管理器期间,尝试保留足够的会话视图空间,以容纳给定会话的预期桌面堆数。如果在SharedSection注册表值中指定的堆大小已增大,则保留会话视图空间的尝试可能会失败。当这种情况发生时,窗口管理器会回到桌面堆的一对“安全”大小(交互式为512KB,非交互式为128KB),并再次尝试保留会话空间,使用这些较小的数字。这可以确保即使注册表值对于20MB会话视图空间来说太大,系统仍然能够引导。

Windows Server 2003 (64-bit)

· 104 MB = SessionViewSize (if no registry value is defined; which is the default)

· 20 MB = Interactive desktop heap size (defined in the registry, SharedSection 2nd value)

· 768 KB = Non-interactive desktop heap size (defined in the registry, SharedSection 3nd value)

· 192 KB = Winlogon desktop heap size

· 96 KB = Disconnect desktop heap size

Windows Vista RTM (32-bit)

· Session View space is now a dynamic kernel address range. The SessionViewSize registry value is no longer used.

· 3072 KB = Interactive desktop heap size (defined in the registry, SharedSection 2nd value)

· 512 KB = Non-interactive desktop heap size (defined in the registry, SharedSection 3nd value)

· 128 KB = Winlogon desktop heap size

· 64 KB = Disconnect desktop heap size

Windows Vista (64-bit) and Windows Server 2008 (64-bit)

· Session View space is now a dynamic kernel address range. The SessionViewSize registry value is no longer used.

· 20 MB = Interactive desktop heap size (defined in the registry, SharedSection 2nd value)

· 768 KB = Non-interactive desktop heap size (defined in the registry, SharedSection 3nd value)

· 192 KB = Winlogon desktop heap size

· 96 KB = Disconnect desktop heap size

 

Windows Vista SP1 (32-bit) and Windows Server 2008 (32-bit)

· Session View space is now a dynamic kernel address range. The SessionViewSize registry value is no longer used.

· 12288 KB = Interactive desktop heap size (defined in the registry, SharedSection 2nd value)

· 512 KB = Non-interactive desktop heap size (defined in the registry, SharedSection 3nd value)

· 128 KB = Winlogon desktop heap size

· 64 KB = Disconnect desktop heap size

windowsvista引入了一个新的公共API函数:CreateDesktopEx,它允许调用者指定桌面堆的大小。
此外,GetUserObjectInformation现在包含一个新的标志,用于检索桌面堆大小(UOI_HEAPSIZE)。

 

简介

DBG_PRINTEXCEPTION_C,代码0x40010006;DBG_PRINTEXCEPTION_WIDE_C,代码0x4001000A;在调试器的控制台窗口打印异常信息/调试信息。它定义在 ntstatus.h头文件里,如下:

//
// MessageId: DBG_PRINTEXCEPTION_C
//
// MessageText:
//
// Debugger printed exception on control C.
//
#define DBG_PRINTEXCEPTION_C             ((NTSTATUS)0x40010006L)    // winnt

 

//
// MessageId: DBG_PRINTEXCEPTION_WIDE_C
//
// MessageText:
//
// Debugger printed exception on control C.
//
#define DBG_PRINTEXCEPTION_WIDE_C        ((NTSTATUS)0x4001000AL)    // winnt

它们唯一的差别是,DBG_PRINTEXCEPTION_C是多字节版本的,DBG_PRINTEXCEPTION_WIDE_C是Unicode版本的。

触发条件

OutputDebugString和其他类似的函数能有效地导致引发Windows异常(DBG_PRINTEXCEPTION_C或DBG_PRINTEXCEPTION_WIDE_C)。附加调试器后,Windows将接收异常并通知调试器。如果没有附加调试器,则将异常传递给程序(作为可继续的错误)。如果程序没有处理异常的处理程序,则继续生活。如果程序执行了,则调用该异常处理程序。,因为通常没有理由当OutputDebugString没有要打印到的调试器时,程序处理该事件。

异常结构填充

ExceptionAddress: 0xXXXXXXXX
ExceptionCode: 40010006/4001000A//错误代码
ExceptionFlags: 00000001
NumberParameters: 2//附加参数个数,一般为2个
Parameter[0]: //信息字符串长度
Parameter[1]://字符串指针

桌面堆可能不是你花很多时间考虑的事情,这是件好事。但是,有时您可能会遇到由于桌面堆耗尽而导致的问题,然后了解此资源会有所帮助。让我先说一下,在Vista中,内核地址空间的情况发生了显著的变化,而我今天所说的大部分内容并不适用于Vista。

最近在调试几个问题时,发现跟abort函数有关,以前只是简单使用,现在却发现不简单,就多留意了下。

简介

abort中止当前进程并返回错误代码。异常终止一个进程。中止当前进程,返回一个错误代码。错误代码的缺省值是3。

代码

/***
*abort.c - abort a program by raising SIGABRT
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines abort() - print a message and raise SIGABRT.
*
******************************************************************************
*/#include<cruntime.h>#include<stdlib.h>#include<internal.h>#include<awint.h>#include<rterr.h>#include<signal.h>#include<oscalls.h>#include<mtdll.h>#include<dbgint.h>#ifdef _DEBUG#define _INIT_ABORT_BEHAVIOR _WRITE_ABORT_MSG #else /* _DEBUG */ #define _INIT_ABORT_BEHAVIOR _CALL_REPORTFAULT #endif /* _DEBUG */unsignedint __abort_behavior =_INIT_ABORT_BEHAVIOR;/***
*void abort() - abort the current program by raising SIGABRT
*
*Purpose:
* print out an abort message and raise the SIGABRT signal. If the user
* hasn't defined an abort handler routine, terminate the program
* with exit status of 3 without cleaning up.
*
* Multi-thread version does not raise SIGABRT -- this isn't supported
* under multi-thread.
*
*Entry:
* None.
*
*Exit:
* Does not return.
*
*Uses:
*
*Exceptions:
*
******************************************************************************
*/ void__cdecl abort (void)
{
_PHNDLR sigabrt_act
=SIG_DFL;

#ifdef _DEBUG
if (__abort_behavior &_WRITE_ABORT_MSG)
{
/*write the abort message*/_NMSG_WRITE(_RT_ABORT);
}
#endif /* _DEBUG */ /*Check if the user installed a handler for SIGABRT.
* We need to read the user handler atomically in the case
* another thread is aborting while we change the signal
* handler.
*/sigabrt_act=__get_sigabrt();if (sigabrt_act !=SIG_DFL)
{
raise(SIGABRT);
}
/*If there is no user handler for SIGABRT or if the user
* handler returns, then exit from the program anyway
*/ if (__abort_behavior &_CALL_REPORTFAULT)
{
#if defined (_M_ARM) || defined (_CRT_APP)__fastfail(FAST_FAIL_FATAL_APP_EXIT);#else /* defined (_M_ARM) || defined (_CRT_APP) */ if(IsProcessorFeaturePresent(PF_FASTFAIL_AVAILABLE))
__fastfail(FAST_FAIL_FATAL_APP_EXIT);

_call_reportfault(_CRT_DEBUGGER_ABORT, STATUS_FATAL_APP_EXIT, EXCEPTION_NONCONTINUABLE);
#endif /* defined (_M_ARM) || defined (_CRT_APP) */}/*If we don't want to call ReportFault, then we call _exit(3), which is the
* same as invoking the default handler for SIGABRT
*/_exit(3);
}
/***
*unsigned int _set_abort_behavior(unsigned int, unsigned int) - set the behavior on abort
*
*Purpose:
*
*Entry:
* unsigned int flags - the flags we want to set
* unsigned int mask - mask the flag values
*
*Exit:
* Return the old behavior flags
*
*Exceptions:
* None
*
******************************************************************************
*/unsignedint __cdecl _set_abort_behavior(unsigned int flags, unsigned intmask)
{
unsigned
int oldflags =__abort_behavior;
__abort_behavior
= oldflags & (~mask) | flags &mask;returnoldflags;
}

为了开始调试工作,我想向您提供一个工具列表。

以下工具是“Debugging Tools for Windows”的一部分–您肯定需要这些工具:

· windbg

· cdb

· ntsd

· tlist

· gflags

· adplus

· UMDH

· symcheck

Sysinternals提供了一些我们需要的优秀工具:

· Process Explorer

· Process Monitor

· Regmon

· Filemon

· DbgView

· Handle.exe

· Tcpview

· LiveKD

· AutoRuns

· WinObj

“MPS Reports”(MPSRPT_SETUPPerf.EXE)中包含许多工具,但我在这里专门列出Checksym

· Checksym

“WindowsServer2003ResourceKitTools”是另一个很棒的工具集。