46vj7p0zz4 发表于 2016-5-20 11:16:40

《深入理解Windows操作系统》笔记5

Windows全局标志保存在一个名为NtGlobalFlag的系统范围的全局变量中,此变量通过HKLM\SYSTEM\CurrentControlSet\Control\Sessionmanager\Globalflag来初始化的,默认值是0。使用gflag /?。
C:\Program Files\Support Tools>gflags /?

usage: GFLAGS [-r [<Flags>] |
            [-k [<Flags>]] |
            [-i <ImageFileName> [<Flags>]] |
            [-i <ImageFileName> -tracedb <SizeInMb>] |
            [-p <PageHeapOptions>] (use `-p ?' for help)

where: <Flags> is a 32 bit hex number (0x12345678) that specifies
       one or more global flags to set.
       -r operates on system registry settings.
       -k operates on kernel settings of the running system.
       -i operates on settings for a specific image file.

       If only the switch is specified, then current settings
       are displayed, not modified.If flags specified for -i
       option are FFFFFFFF, then registry entry for that image
       is deleted

The `-tracedb' option is used to set the size of the stack trace
database used to store runtime stack traces. The actual database
will be created if the `+ust' flag is set in a previous command.
`-tracedb 0' will revert to the default size for the database.

If no arguments are specified to GFLAGS then it displays
a dialog box that allows the user to modify the global
flag settings.

Flags may either be a single hex number that specifies all
32-bits of the GlobalFlags value, or it can be one or more
arguments, each beginning with a + or -, where the + means
to set the corresponding bit(s) in the GlobalFlags and a =
means to clear the corresponding bit(s).After the + or =
may be either a hex number or a three letter abbreviation
for a GlobalFlag.Valid abbreviations are:

    soe - Stop On Exception
    sls - Show Loader Snaps
    dic - Debug Initial Command
    shg - Stop on Hung GUI
    htc - Enable heap tail checking
    hfc - Enable heap free checking
    hpc - Enable heap parameter checking
    hvc - Enable heap validation on call
    vrf - Enable application verifier
    ptg - Enable pool tagging
    htg - Enable heap tagging
    ust - Create user mode stack trace database
    kst - Create kernel mode stack trace database
    otl - Maintain a list of objects for each type
    htd - Enable heap tagging by DLL
    dse - Disable stack extensions
    d32 - Enable debugging of Win32 Subsystem
    ksl - Enable loading of kernel debugger symbols
    dps - Disable paging of kernel stacks
    scb - Enable system critical breaks
    dhc - Disable Heap Coalesce on Free
    ece - Enable close exception
    eel - Enable exception logging
    eot - Enable object handle type tagging
    hpa - Enable page heap
    dwl - Debug WINLOGON
    ddp - Disable kernel mode DbgPrint output
    cse - Early critical section event creation
    ltd - Load DLLs top-down
    bhd - Enable bad handles detection
    dpd - Disable protected DLL verification

All images with ust enabled can be accessed in the
USTEnabled key under 'Image File Options'.

C:\Program Files\Support Tools>



本地调用过程LPC是一种用于高速传递消息的跨进程通信设施。并不是通过windows API直接可以使用,是一种内部机制,只能用于windows操作系统逐渐。用到LPC的地方:
使用了远程过程调用RPC的windows应用程序,如果他们指定了本地RPC,用于在同一个系统上的进程之间进行通讯
一些windows API要向windows子系统进程发送消息
Winlogon通过LPC与本地安全认证服务器进程LSASS进行通信
安全应用监视器使用LPC和LSASS进程进行通讯。

查看LPC端口对象:winobj程序


64bit的windows如何运行win32的程序,使用的wow64的DLL来实现的:
wow64.DLL:管理线程和进程的创建,钩子程序异常分发,和ntoskrnl导出的基本系统调用,实现了文件重定向,注册表重定向和反射
WOW64CPU.DLL:为每个正在WOW64内部运行的线程,管理他们的32位CPU环境
WOW64WIN.DLL:截取了win32K.SYS导出的GUI调用。
关系如下:

在注册表中为什么HKEY等根键都是以H开头而不是以ROOT开头?
因为:所以指向KEY是windows的句柄Handle,参考technical reference to the windows 2000 registry帮助文件。

在HKLM\HARDWARE\DESCRIPTION\SYSTEM\CENTRALPROCESSOR\0下的PROCESSORNAMESTRING 可以让我的电脑属性看为牛B的CPU。



可以使用regmon来实现监控注册表,regmon实际上依赖一个设备驱动程序
现在和filemon一起被procmon替代了。


注册表的内部机理:实现注册表的执行体子系统是配置管理器,配置管理器是如何组织指标表的磁盘文件的呢?是通过一个hive 存储巢穴来做到的。
对于本机来说对应关系如下:

系统修复和还原是通过regedit 的load hive来实现的。相当于恢复注册表

Hive的大小是有限制的。在XP和2003上,hive的最高达到200M,或者物理内存的1/4.
WINDOWS 2000中设计了换页池的概念,大小限制376M。而在XP和2003上,registry size中没有显示,因为配置管理器不适用换页池。
查看HIVE的内存使用量:

0: kd> !reg hivelist

-------------------------------------------------------------------------------------------------------------
| HiveAddr |Stable Length|Stable Map|Volatile Length|Volatile Map|MappedViews|PinnedViews|U(Cnt)| BaseBlock | FileName
-------------------------------------------------------------------------------------------------------------
| e270ab60 |      33000| e270abc0 |          0    |00000000|      0|       13|   0| e220e000| \Microsoft\Windows\UsrClass.dat
| e2571378 |   23f000| e222a000 |       1000    |e25714b4|       76|       24|   0| e220b000| s and Settings\jamin\ntuser.dat
| e21a0b60 |       1000| e21a0bc0 |          0    |00000000|      1|      0|   0| e227a000| \Microsoft\Windows\UsrClass.dat
| e22aa008 |      39000| e22aa068 |       1000    |e22aa144|       15|      0|   0| e22ad000| ettings\LocalService\ntuser.dat
| e20edb60 |       1000| e20edbc0 |          0    |00000000|      1|      0|   0| e2113000| \Microsoft\Windows\UsrClass.dat
| e2103558 |      39000| e21035b8 |       1000    |e2103694|       13|      2|   0| e1eaa000| tings\NetworkService\ntuser.dat
| e16b7b60 |    27df000| e16fe000 |       c000    |e16b7c9c|      256|      5|   0| e16b9000| emRoot\System32\Config\SOFTWARE
| e16bf008 |       7000| e16bf068 |          0    |00000000|      2|      0|   0| e16c1000| \SystemRoot\System32\Config\SAM
| e162e820 |       d000| e162e880 |       1000    |e162e95c|      4|      0|   0| e16ac000| emRoot\System32\Config\SECURITY
| e16bcb60 |      3d000| e16bcbc0 |          0    |00000000|       16|      0|   0| e16ae000| temRoot\System32\Config\DEFAULT
| e143d3c0 |       d000| e143d420 |       4000    |e143d4fc|      0|      0|   0| e1440000| <NONAME>
| e1036b60 |   3f7000| e1038000 |      26000    |e1036c9c|      141|       29|   0| e1037000| SYSTEM
| e1024b60 |       1000| e1024bc0 |       1000    |e1024c9c|      0|      0|   0| e102f000| <NONAME>
-------------------------------------------------------------------------------------------------------------
在Windows\SYSTEM32\CONFIG中有一个隐藏文件,system.SAV是SYSTEM的HIVE的一个版本,是初始拷贝,是从SETUP的ISO上拷贝来的。

在windows2000中相同路径,有一个非隐藏文件system.ALT是一个替补,在WINDOWS XP/2003后面没有

Windows服务类似于unix的守护进程,服务有3个部分组成:服务应用,服务控制程序SCP,服务控制管理器SCM
页: [1]
查看完整版本: 《深入理解Windows操作系统》笔记5