B.8 User-Mode Utility Functions
This section describes a number of user-mode utility functions you
will find useful for implementing various tasks. These utility functions are
multi-platform, implemented on all operating systems supported by WinDriver.
PURPOSE
• Retrieves the status string that corresponds to a status code.
PROTOTYPE
const char *Stat2Str(DWORD dwStatus);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns the verbal status description (string) that corresponds to the
specified numeric status code.
REMARKS
See section
B.9 for a complete list of status
codes and strings.
PURPOSE
• Retrieves the type of the operating system.
PROTOTYPE
OS_TYPE get_os_type(void);
RETURN VALUE
Returns the type of the operating system.
If the operating system type is not detected, returns
OS_CAN_NOT_DETECT.
PURPOSE
• Creates a thread.
PROTOTYPE
DWORD ThreadStart(
HANDLE *phThread,
HANDLER_FUNC pFunc,
void *pData);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
PURPOSE
• Waits for a thread to exit.
PROTOTYPE
void ThreadWait(HANDLE hThread);
PARAMETERS
DESCRIPTION
RETURN VALUE
None
PURPOSE
• Creates an event object.
PROTOTYPE
DWORD OsEventCreate(HANDLE *phOsEvent);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
PURPOSE
• Closes a handle to an event object.
PROTOTYPE
void OsEventClose(HANDLE hOsEvent);
PARAMETERS
DESCRIPTION
RETURN VALUE
None
PURPOSE
• Waits until a specified event object is in the signaled state or
the time-out interval elapses.
PROTOTYPE
DWORD OsEventWait(
HANDLE hOsEvent,
DWORD dwSecTimeout);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
PURPOSE
• Sets the specified event object to the signaled state.
PROTOTYPE
DWORD OsEventSignal(HANDLE hOsEvent);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
PURPOSE
• Resets the specified event object to the non-signaled state.
PROTOTYPE
DWORD OsEventReset(HANDLE hOsEvent);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
PURPOSE
• Creates a mutex object.
PROTOTYPE
DWORD OsMutexCreate(HANDLE *phOsMutex);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
PURPOSE
• Closes a handle to a mutex object.
PROTOTYPE
void OsMutexClose(HANDLE hOsMutex);
PARAMETERS
DESCRIPTION
RETURN VALUE
None
PURPOSE
• Locks the specified mutex object.
PROTOTYPE
DWORD OsMutexLock(HANDLE hOsMutex);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
PURPOSE
• Releases (unlocks) a locked mutex object.
PROTOTYPE
DWORD OsMutexUnlock(HANDLE hOsMutex);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
PURPOSE
• Sends debug messages to the Debug Monitor.
PROTOTYPE
void PrintDbgMessage(
DWORD dwLevel,
DWORD dwSection,
const char *format
[, argument]...);
PARAMETERS
DESCRIPTION
RETURN VALUE
None
PURPOSE
• Opens a log file.
PROTOTYPE
DWORD WD_LogStart(
const char *sFileName,
const char *sMode);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
REMARKS
-
Once a log file is opened, all API calls are logged in this file.
You may add your own printouts to the log file by calling
WD_LogAdd [B.8.17].
EXAMPLE
PURPOSE
• Closes a log file.
PROTOTYPE
VOID WD_LogStop(void);
RETURN VALUE
None
EXAMPLE
PURPOSE
• Adds user printouts into log file.
PROTOTYPE
VOID DLLCALLCONV WD_LogAdd(
const char *sFormat
[, argument ]...);
PARAMETERS
DESCRIPTION
RETURN VALUE
Returns
WD_STATUS_SUCCESS(0) on success, or
an appropriate error code otherwise [
B.9].
EXAMPLE