| Previous | Main | End | Site Index | Download | Disclaimer | Privacy |


 

 

 

Windows Process, thread and synchronization: Structures used in program examples of ModuleR, ModuleS, ModuleT, ModuleU, ModuleV and ModuleAA, wherever applicable.

 

To learn about structure you can jump to Module 11.

 

Index

 

STARTUPINFO

PROCESS_INFORMATION

SECURITY_ATTRIBUTES

GENERIC_MAPPING

PRIVILEGE_SET

LUID_AND_ATTRIBUTES

LUID

SECURITY_DESCRIPTOR

THREADENTRY32

PROCESSENTRY32

MODULEENTRY32

OVERLAPPED

SLIST_ENTRY

MSG

 

 

STARTUPINFO

 

Item

Description

Structure

STARTUPINFO.

Info

Is used with the CreateProcess(), CreateProcessAsUser(), and CreateProcessWithLogonW() functions to specify the window station, desktop, standard handles, and appearance of the main window for the new process.

Definition

typedef struct _STARTUPINFO {
  DWORD cb;
  LPTSTR lpReserved;
  LPTSTR lpDesktop;
  LPTSTR lpTitle;
  DWORD dwX;
  DWORD dwY;
  DWORD dwXSize;
  DWORD dwYSize;
  DWORD dwXCountChars;
  DWORD dwYCountChars;
  DWORD dwFillAttribute;
  DWORD dwFlags;
  WORD wShowWindow;
  WORD cbReserved2;
  LPBYTE lpReserved2;
  HANDLE hStdInput;
  HANDLE hStdOutput;
  HANDLE hStdError;

} STARTUPINFO,
*LPSTARTUPINFO;

Members

See below.

Header file

<windows.h>

Remark

Declared as Unicode and ANSI structures. For graphical user interface (GUI) processes, this information affects the first window created by the CreateWindow() function and shown by the ShowWindow() function. For console processes, this information affects the console window if a new console is created for the process. A process can use the GetStartupInfo() function to retrieve the STARTUPINFO structure specified when the process was created. If a GUI process is being started and neither STARTF_FORCEONFEEDBACK or STARTF_FORCEOFFFEEDBACK is specified, the process feedback cursor is used. A GUI process is one whose subsystem is specified as "windows".

 

Table 1.

 

Members

 

cb

Size of the structure, in bytes.

 

lpReserved

Reserved. Set this member to NULL before passing the structure to CreateProcess().

 

lpDesktop

Pointer to a null-terminated string that specifies either the name of the desktop or the name of both the desktop and window station for this process. A backslash in the string indicates that the string includes both the desktop and window station names.

For CreateProcess() and CreateProcessAsUser(), if this member is NULL, the new process inherits the desktop and window station of its parent process. If this member is an empty string, the process does not inherit the desktop and window station of its parent process; instead, the system determines if a new desktop and window station need to be created. If the impersonated user already has a desktop, the system uses the existing desktop.

For CreateProcessWithLogonW(), if this member is NULL or an empty string, the new process inherits the desktop and window station of its parent process. It is the responsibility of the application to add permission for the specified user account to the inherited window station and desktop, even for WinSta0\Default.

Windows Me/98/95:  Desktops and window stations are not supported.

 

lpTitle

For console processes, this is the title displayed in the title bar if a new console window is created. If NULL, the name of the executable file is used as the window title instead. This parameter must be NULL for GUI or console processes that do not create a new console window.

 

dwX

If dwFlags specifies STARTF_USEPOSITION, this member is the x offset of the upper left corner of a window if a new window is created, in pixels. Otherwise, this member is ignored.

The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow() to create an overlapped window if the x parameter of CreateWindow() is CW_USEDEFAULT.

 

dwY

If dwFlags specifies STARTF_USEPOSITION, this member is the y offset of the upper left corner of a window if a new window is created, in pixels. Otherwise, this member is ignored.

The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow() to create an overlapped window if the y parameter of CreateWindow() is CW_USEDEFAULT.

 

dwXSize

If dwFlags specifies STARTF_USESIZE, this member is the width of the window if a new window is created, in pixels. Otherwise, this member is ignored.

For GUI processes, this is used only the first time the new process calls CreateWindow() to create an overlapped window if the nWidth parameter of CreateWindow() is CW_USEDEFAULT.

 

dwYSize

If dwFlags specifies STARTF_USESIZE, this member is the height of the window if a new window is created, in pixels. Otherwise, this member is ignored.

For GUI processes, this is used only the first time the new process calls CreateWindow() to create an overlapped window if the nHeight parameter of CreateWindow() is CW_USEDEFAULT.

 

dwXCountChars

If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is created in a console process, this member specifies the screen buffer width, in character columns. Otherwise, this member is ignored.

 

dwYCountChars

If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is created in a console process, this member specifies the screen buffer height, in character rows. Otherwise, this member is ignored.

 

dwFillAttribute

If dwFlags specifies STARTF_USEFILLATTRIBUTE, this member is the initial text and background colors if a new console window is created in a console application. Otherwise, this member is ignored.

This value can be any combination of the following values: FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED, FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN, BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the following combination of values produces red text on a white background:

 

FOREGROUND_RED| BACKGROUND_RED| BACKGROUND_GREEN| BACKGROUND_BLUE

 

dwFlags

Bit field that determines whether certain STARTUPINFO members are used when the process creates a window. This member can be one or more of the following values.

 

Value

Meaning

STARTF_FORCEONFEEDBACK

Indicates that the cursor is in feedback mode for two seconds after CreateProcess() is called. The Working in Background cursor is displayed (see the Pointers tab in the Mouse control panel utility).

If during those two seconds the process makes the first GUI call, the system gives five more seconds to the process. If during those five seconds the process shows a window, the system gives five more seconds to the process to finish drawing the window.

The system turns the feedback cursor off after the first call to GetMessage(), regardless of whether the process is drawing.

STARTF_FORCEOFFFEEDBACK

Indicates that the feedback cursor is forced off while the process is starting. The Normal Select cursor is displayed.

STARTF_RUNFULLSCREEN

Indicates that the process should be run in full-screen mode, rather than in windowed mode.

This flag is only valid for console applications running on an x86 computer. For Windows Me/98/95:  This value is not supported.

STARTF_USECOUNTCHARS

If this value is not specified, the dwXCountChars and dwYCountChars members are ignored. For Windows Me/98/95:  This value is not supported.

STARTF_USEFILLATTRIBUTE

If this value is not specified, the dwFillAttribute member is ignored.

STARTF_USEPOSITION

If this value is not specified, the dwX and dwY members are ignored.

STARTF_USESHOWWINDOW

If this value is not specified, the wShowWindow member is ignored.

STARTF_USESIZE

If this value is not specified, the dwXSize and dwYSize members are ignored.

STARTF_USESTDHANDLES

Sets the standard input, standard output, and standard error handles for the process to the handles specified in the hStdInput, hStdOutput, and hStdError members of the STARTUPINFO structure. For this to work properly, the handles must be inheritable and the CreateProcess function's bInheritHandles parameter must be set to TRUE. If this value is not specified, the hStdInput, hStdOutput, and hStdError members of the STARTUPINFO structure are ignored.

 

Table 2

 

wShowWindow

If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of the SW_ constants defined in Winuser.h. Otherwise, this member is ignored.

For GUI processes, wShowWindow specifies the default value the first time ShowWindow() is called. The nCmdShow parameter of ShowWindow() is ignored. In subsequent calls to ShowWindow(), the wShowWindow member is used if the nCmdShow parameter of ShowWindow() is set to SW_SHOWDEFAULT.

 

cbReserved2

Reserved for use by the C Runtime; must be zero.

 

lpReserved2

Reserved for use by the C Runtime; must be NULL.

 

hStdInput

If dwFlags specifies STARTF_USESTDHANDLES, this member is a handle to be used as the standard input handle for the process. Otherwise, this member is ignored.

 

hStdOutput

If dwFlags specifies STARTF_USESTDHANDLES, this member is a handle to be used as the standard output handle for the process. Otherwise, this member is ignored.

 

hStdError

If dwFlags specifies STARTF_USESTDHANDLES, this member is a handle to be used as the standard error handle for the process. Otherwise, this member is ignored.

 

PROCESS_INFORMATION

 

Item

Description

Structure

PROCESS_INFORMATION.

Info

Is filled in by either the CreateProcess(), CreateProcessAsUser(), CreateProcessWithLogonW(), or CreateProcessWithTokenW() function with information about the newly created process and its primary thread.

Definition

typedef struct _PROCESS_INFORMATION {
  HANDLE hProcess;
  HANDLE hThread;
  DWORD dwProcessId;
  DWORD dwThreadId;

} PROCESS_INFORMATION;

Members

hProcess

Handle to the newly created process. The handle is used to specify the process in all functions that perform operations on the process object.

 

hThread

Handle to the primary thread of the newly created process. The handle is used to specify the thread in all functions that perform operations on the thread object.

 

dwProcessId

Value that can be used to identify a process. The value is valid from the time the process is created until the time the process is terminated.

 

dwThreadId

Value that can be used to identify a thread. The value is valid from the time the thread is created until the time the thread is terminated.

Header file

<windows.h>

Remark

If the function succeeds, be sure to call the CloseHandle() function to close the hProcess and hThread handles when you are finished with them. Otherwise, when the child process exits, the system cannot clean up these handles because the parent process did not close them. However, the system will close these handles when the parent process terminates, so they would be cleaned up at this point.

 

Table 3.

 

SECURITY_ATTRIBUTES

 

Item

Description

Structure

SECURITY_ATTRIBUTES.

Info

Contains the security descriptor for an object and specifies whether the handle retrieved by specifying this structure is inheritable. This structure provides security settings for objects created by various functions, such as CreateFile(), CreatePipe(), CreateProcess(), RegCreateKeyEx(), or RegSaveKeyEx().

Definition

typedef struct _SECURITY_ATTRIBUTES {
  DWORD nLength;
  LPVOID lpSecurityDescriptor;
  BOOL bInheritHandle;

} SECURITY_ATTRIBUTES,
*PSECURITY_ATTRIBUTES;

Members

nLength

Specifies the size, in bytes, of this structure. Set this value to the size of the SECURITY_ATTRIBUTES structure.

 

lpSecurityDescriptor

Pointer to a security descriptor for the object that controls the sharing of it. If NULL is specified for this member, the object is assigned the default security descriptor of the calling process. This is not the same as granting access to everyone by assigning a NULL DACL. The default security descriptor is based on the default DACL of the access token belonging to the calling process. By default, the default DACL in the access token of a process allows access only to the user represented by the access token. If other users must access the object, you can either create a security descriptor with the appropriate access, or add ACEs to the DACL that grants access to a group of users. For Windows 95/98/Me: The lpSecurityDescriptor member of this structure is ignored.

 

bInheritHandle

Specifies whether the returned handle is inherited when a new process is created. If this member is TRUE, the new process inherits the handle.

Header file

<windows.h>

Remark

-

 

Table 4.

 

GENERIC_MAPPING

 

Item

Description

Structure

GENERIC_MAPPING.

Info

Defines the mapping of generic access rights to specific and standard access rights for an object. When a client application requests generic access to an object, that request is mapped to the access rights defined in this structure.

Definition

typedef struct _GENERIC_MAPPING {
  ACCESS_MASK GenericRead;
  ACCESS_MASK GenericWrite;
  ACCESS_MASK GenericExecute;
  ACCESS_MASK GenericAll;

} GENERIC_MAPPING;

Members

GenericRead

Specifies an access mask defining read access to an object.

 

GenericWrite

Specifies an access mask defining write access to an object.

 

GenericExecute

Specifies an access mask defining execute access to an object.

 

GenericAll

Specifies an access mask defining all possible types of access to an object.

Header file

<windows.h>

Remark

-

 

Table 5.

 

PRIVILEGE_SET

 

Item

Description

Structure

PRIVILEGE_SET.

Info

Specifies a set of privileges. It is also used to indicate which, if any, privileges are held by a user or group requesting access to an object.

Definition

typedef struct _PRIVILEGE_SET {
  DWORD PrivilegeCount;
  DWORD Control;
  LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];

} PRIVILEGE_SET,
*PPRIVILEGE_SET;

Members

PrivilegeCount

Specifies the number of privileges in the privilege set.

 

Control

Specifies a control flag related to the privileges. The PRIVILEGE_SET_ALL_NECESSARY control flag is currently defined. It indicates that all of the specified privileges must be held by the process requesting access. If this flag is not set, the presence of any privileges in the user's access token grants the access.

 

Privilege

Specifies an array of LUID_AND_ATTRIBUTES structures describing the set's privileges. The following attributes are defined for privileges:

 

SE_PRIVILEGE_ENABLED_BY_DEFAULT - The privilege is enabled by default.

SE_PRIVILEGE_ENABLED - The privilege is enabled.

SE_PRIVILEGE_USED_FOR_ACCESS - The privilege was used to gain access to an object or service. This flag is used to identify the relevant privileges in a set passed by a client application that may contain unnecessary privileges.

Header file

<windows.h>

Remark

A privilege is used to control access to an object or service more strictly than is typical with discretionary access control. A system manager uses privileges to control which users are able to manipulate system resources. An application uses privileges when it changes a system-wide resource, such as when it changes the system time or shuts down the system.

 

Table 6.

 

LUID_AND_ATTRIBUTES

 

Item

Description

Structure

LUID_AND_ATTRIBUTES.

Info

Represents a locally unique identifier (LUID) and its attributes.

Definition

typedef struct _LUID_AND_ATTRIBUTES {
  LUID Luid;
  DWORD Attributes;

} LUID_AND_ATTRIBUTES,
*PLUID_AND_ATTRIBUTES;

Members

Luid

Specifies an LUID value.

 

Attributes

Specifies attributes of the LUID. This value contains up to 32 one-bit flags. Its meaning is dependent on the definition and use of the LUID.

Header file

<windows.h>

Remark

An LUID_AND_ATTRIBUTES structure can represent an LUID whose attributes change frequently, such as when the LUID is used to represent privileges in the PRIVILEGE_SET structure. Privileges are represented by LUIDs and have attributes indicating whether they are currently enabled or disabled.

 

Table 7.

 

LUID

 

Item

Description

Structure

LUID.

Info

Is a 64-bit value guaranteed to be unique only on the system on which it was generated. The uniqueness of a locally unique identifier (LUID) is guaranteed only until the system is restarted. An LUID is not for direct manipulation. Applications are to use functions and structures to manipulate LUID values.

Definition

typedef struct _LUID {
  DWORD LowPart;
  LONG HighPart;

} LUID,
*PLUID;

Members

LowPart

Low order bits.

 

HighPart

High order bits.

Header file

<windows.h>

Remark

-

 

Table 8.

 

SECURITY_DESCRIPTOR

 

Item

Description

Structure

SECURITY_DESCRIPTOR.

Info

Contains the security information associated with an object. Applications use this structure to set and query an object's security status. Because the internal format of a security descriptor can vary, applications are not to modify the SECURITY_DESCRIPTOR structure directly.

Definition

typedef struct SECURITY_DESCRIPTOR {

  ...

} SECURITY_DESCRIPTOR,
*PISECURITY_DESCRIPTOR,
PSECURITY_DESCRIPTOR;

Members

User defined.

Header file

<windows.h>

Remark

A security descriptor includes information that specifies the following components of an object's security:

 

          An owner (SID).

          A primary group (SID).

          A discretionary ACL.

          A system ACL.

          Qualifiers for the preceding items.

 

Several functions that use the SECURITY_DESCRIPTOR structure require that this structure be on a valid pointer boundary in memory. These boundaries vary depending on the type of processor used. Memory allocation functions, such as malloc and LocalAlloc(), return properly aligned pointers.

 

Table 9.

 

THREADENTRY32

 

Item

Description

Structure

THREADENTRY32.

Info

Describes an entry from a list that enumerates the threads executing in the system when a snapshot was taken.

Definition

typedef struct tagTHREADENTRY32 {
  DWORD dwSize;
  DWORD cntUsage;
  DWORD th32ThreadID;
  DWORD th32OwnerProcessID;
  LONG tpBasePri;
  LONG tpDeltaPri;
  DWORD dwFlags;

} THREADENTRY32,
*PTHREADENTRY32;

Members

See below.

Header file

<tlhelp32.h>

Remark

-

 

Table 10.

 

Members

 

dwSize

Size of the structure, in bytes. Before calling the Thread32First() function, set this member to sizeof(THREADENTRY32). If you do not initialize dwSize, Thread32First() fails.

 

cntUsage

This member is no longer used and is always set to zero.

 

th32ThreadID

Win32 thread identifier, compatible with the thread identifier returned by the CreateProcess() function.

 

th32OwnerProcessID

Identifier of the process that created the thread.

 

tpBasePri

Initial priority level assigned to a thread. This member can be one of the following values (defined in winbase.h and winnt.h):

 

Value

Meaning

THREAD_PRIORITY_IDLE

Indicates a base priority level of 1 for IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS processes, and a base priority level of 16 for REALTIME_PRIORITY_CLASS processes.

THREAD_PRIORITY_LOWEST

Indicates 2 points below normal priority for the priority class.

THREAD_PRIORITY_BELOW_NORMAL

Indicates one point below normal priority for the priority class.

THREAD_PRIORITY_NORMAL

Indicates normal priority for the priority class.

THREAD_PRIORITY_ABOVE_NORMAL