21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

lpCommandLine<br />

Any command-line arguments to pass to the new program. If there are no arguments<br />

to pass, this argument may be specified as NULL, but lpApplicationName<br />

and lpCommandLine cannot both be NULL. IflpApplicationName is specified as NULL,<br />

the program to execute is taken from this argument. Everything up to the first<br />

space is interpreted as part of the filename of the program to execute. If the filename<br />

to execute has a space in its name, it must be quoted. If lpApplicationName<br />

is not specified as NULL, lpCommandLine should not contain the filename to execute,<br />

but instead contain only the arguments to pass to the program on its command<br />

line.<br />

By far, the biggest mistake that developers make when using CreateProcess( ) or<br />

CreateProcessAsUser( ) is to specify lpApplicationName as NULL and fail to enclose the<br />

program name portion of lpCommandLine in quotes. As a rule, you should never specify<br />

lpApplicationName as NULL. Always specify the filename of the program to execute<br />

in lpApplicationName rather than letting Windows try to figure out what you mean<br />

from lpCommandLine.<br />

1.9 Disabling Memory Dumps in the Event of a<br />

Crash<br />

<strong>Problem</strong><br />

Your application stores potentially sensitive data in memory, and you want to prevent<br />

this data from being written to disk if the program crashes, because local attackers<br />

might be able to examine a core dump and use that information nefariously.<br />

Solution<br />

On Unix systems, use setrlimit( ) to set the RLIMIT_CORE resource to zero, which will<br />

prevent the operating system from leaving behind a core file. On Windows, it is not<br />

possible to disable such behavior, but there is equally no guarantee that a memory<br />

dump will be performed. A system-wide setting that cannot be altered on a per-application<br />

basis controls what action Windows takes when an application crashes.<br />

A Windows feature called Dr. Watson, which is enabled by default, may cause the<br />

contents of a process’s address space to be written to disk in the event of a crash. If<br />

Microsoft Visual Studio is installed, the settings that normally cause Dr. Watson to<br />

run are changed to run the Microsoft Visual Studio debugger instead, and no dump<br />

will be generated. Other programs do similar things, so from system to system,<br />

there’s no telling what might happen if an application crashes.<br />

Disabling Memory Dumps in the Event of a Crash | 35<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!