Tuesday, July 28, 2009

The Boot optimization in Windows XP and performance issues


Windows XP Boot Optimization

BootOptimizeFunction

The following registry entries are located under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction.

"Enable"    

Accepted values for this entry are Y or N.

If the entry is set to Y, Windows automatically optimizes the file location for boot optimization. This optimization occurs automatically if the system is idle for 10 minutes. Boot optimization improves startup time by locating startup files in contiguous clusters on the volume, reducing the movement of the disk head when reading the volume.

A reflection : What might happen if we disable boot optimization.. I dont think anything harmful will happen..Since this is a performance optimization entry, it might lead to a performance degradation.

"LcnEndLocation"

Stores the logical cluster number (LCN) that specifies the end location of the files moved by Disk Defragmenter for boot optimization.

This is a dynamic value.

"LcnStartLocation"

Stores the LCN that specifies the starting location of the files moved by Disk Defragmenter for boot optimization.

This entry also is a dynamic number.

"OptimizeComplete"

Stores the value that indicates whether the optimize operation is complete.

"OptimizeError  "

Stores an error message if an error was encountered during the optimization process.

Ref: http://technet.microsoft.com/en-us/library/cc784391(WS.10).aspx


Lets listen about the Boot Optimization from Mark Russinovich  :-)

"For boot, the prefetcher by default traces from system start through the 30 seconds following the start of the user’s shell (typically Explorer) or, failing that, up through 60 seconds following Windows service initialization or through 120 seconds, whichever comes first."

Ref: Windows Internals 4th Edition.

This is an interesting point.. If boot optimization is enabled, then the prefetcher listens to all the file system operations and records the same.  This information is later used to create the layout.ini file and passed to the defragment utility once in three days to optimize the area.. Now the question is .. if we do not have the prefetch mechanism listening to and logging all the transaction during boot time and other wise, will that lead to a performance issue.. Ideally it shouldn't..


Now lets refer the documentation on "Windows Performance" on technet.

Ref: http://technet.microsoft.com/en-us/library/bb457057.aspx

Section: Defragmentation

"Once every three days, by default, Windows XP will perform a partial defragmentation and adjust the layout of the disk based upon current use. The files to be moved are written in the file Layout.ini (found in the Prefetch directory under the System Root directory)."

Now the file optimization is not done everyday..  Its done once in 3 days, when the system is idle.. One more interesting thing about this operation is that it does not perform a full defrag. It optimizes for files contained in the layout.ini file.

There are additional Prefetch related entries, which in turn are related to the Boot Optimization

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters

EnablePrefetcher

Possible Values are (0 = disabled, 1 = Application launch prefetching, 2 = Boot prefetching, 3 = Both prefetching).

Ref: http://www.tomshardware.com/forum/51893-45-boot-defrag


So you may decide either permenantly or for testing to opt for no prefetching, Boot Prefetching or both..

What if the prefetch folder is corrupt..  It can add to your worries slowing down your system further.. If in doubt, delete the prefetch folder once..

http://support.microsoft.com/kb/915163 




 

Friday, July 24, 2009

An insight into Windows Access Control and DACL


Its some time that I have written something.. I wouldn't say I was so busy that I couldn't  post even once.. Point No 1: a bit lazy these days :-) and point 2.. I was a bit busy.. :-)

This time around I will be discussing a bit on the Windows Access Control Entries...


Every securable object in windows do have a security descriptor associated with it. the object could be vary from file to a service.

The windows built in sc command has an option to list the security descriptor of the service..

Here is how you can do this..

cmd -> sc sdshow <service_name>

and example would be

sc sdshow wuauserv

Where wuauserv is the service name for windows update agent.

The output of the command would look like some thing like this..

D:(A;;CCLCSWRPLORC;;;AU)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;SY)


If you are sure what you are doing, you may set the security descriptor with the

sc sdset <service_name> <security_descriptor>

Note: do this if you are really sure what you are doing..

Now lets analyze the output of the sc sdshow wuauserv command.


Format

D:dacl_flags(string_ace1)(string_ace2)(string_ace3).....(string_acen)


D: -> DACL Entry ( other possibilities are S: -> SACL    O: -> Owner  G:   -> Primary Group  )


Format of (string_ace1)

(ace_type;ace_flags;rights;object_guid;inherit_object_guid;account_sid)
 

(string_ace1)

(A;;CCLCSWRPLORC;;;AU)

ace_type = A

A - SDDL_ACCESS_ALLOWED

ace_flags = blank here

rights : CCLCSWRPLORC

CC: SDDL_CREATE_CHILD
LC: SDDL_LIST_CHILDREN
SW: SDDL_SELF_WRITE
RP: SDDL_READ_PROPERTY
LO: SDDL _LIST_OBJECT
RC: READ_CONTROL

object_guid: blank in this case

inherit_object_guid : blank here


account_sid : AU

AU  - SDDL_AUTHENTICATED_USERS


(string_ace2)

(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)

ace_type = A

A - SDDL_ACCESS_ALLOWED

ace_flags = blank in this case

rights : CCDCLCSWRPWPDTLOCRSDRCWDWO

CC: SDDL_CREATE_CHILD
DC: SDDL_DELETE_CHILD
LC: SDDL_LIST_CHILDREN
SW: SDDL_SELF_WRITE
RP: SDDL_READ_PROPERTY
WP: SDDL_WRITE_PROPERTY
DT: SDDL_DELETE_TREE
LO: SDDL _LIST_OBJECT
CR: SDDL_CONTROL_ACCESS
SD: SDDL_STANDARD_DELETE
RC: SDDL_READ_CONTROL
WD: SDDL_WRITE_DAC
WO: SDDL_WRITE_OWNER

object_guid: blank in this case

inherit_object_guid : blank in this case

account_sid : BA

BA  - SDDL_BUILTIN_ADMINISTRATORS

(string_ace3)


(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;SY)


ace_type = A

A - SDDL_ACCESS_ALLOWED

ace_flags = blank in this case

rights : CCDCLCSWRPWPDTLOCRSDRCWDWO

CC: SDDL_CREATE_CHILD
DC: SDDL_DELETE_CHILD
LC: SDDL_LIST_CHILDREN
SW: SDDL_SELF_WRITE
RP: SDDL_READ_PROPERTY
WP: SDDL_WRITE_PROPERTY
DT: SDDL_DELETE_TREE
LO: SDDL _LIST_OBJECT
CR: SDDL_CONTROL_ACCESS
SD: SDDL_STANDARD_DELETE
RC: SDDL_READ_CONTROL
WD: SDDL_WRITE_DAC
WO: SDDL_WRITE_OWNER

object_guid: blank in this case

inherit_object_guid : blank in this case

account_sid : BA

BA  - SDDL_BUILTIN_ADMINISTRATOR


Its not so easy to decipher this always.. However we may write simple scripts to do the same.. :-) Not sure if I will be writing one..

Cheers guys.. Enjoy the weekend..

References: 

SID Strings : http://msdn.microsoft.com/en-us/library/aa379602(VS.85).aspx


Security Descriptor Definition Language:  http://msdn.microsoft.com/en-us/library/aa379567(VS.85).aspx

Security Descriptor String Format  : http://msdn.microsoft.com/en-us/library/aa379570(VS.85).aspx

ACE_HEADER Structure :  http://msdn.microsoft.com/en-us/library/aa374919(VS.85).aspx

ACE Strings: http://msdn.microsoft.com/en-us/library/aa374928(VS.85).aspx