Jungo WinDriver  
Official Documentation
utils.h
Go to the documentation of this file.
1 /* @JUNGO_COPYRIGHT@ */
2 
3 #ifndef _WD_UTILS_H_
4 #define _WD_UTILS_H_
5 
6 #if defined(__KERNEL__)
7  #include "kpstdlib.h"
8 #else
9  #include <stdio.h>
10 #endif
11 
12 #include "windrvr.h"
13 
14 #if defined(__cplusplus)
15 extern "C" {
16 #endif
17 
18 #if !defined(MAX_PATH)
19  #define MAX_PATH 4096
20 #endif
21 
22 #if defined(WIN32)
23  #define snprintf _snprintf
24  #if !defined(vsnprintf)
25  #define vsnprintf _vsnprintf
26  #endif
27 #endif
28 
29 typedef void (DLLCALLCONV *HANDLER_FUNC)(void *pData);
30 
31 #if !defined(WIN32) || defined(_MT)
32 
48 DWORD DLLCALLCONV ThreadStart(_Outptr_ HANDLE *phThread,
49  _In_ HANDLER_FUNC pFunc,
50  _In_ void *pData);
51 
61 void DLLCALLCONV ThreadWait(_In_ HANDLE hThread);
62 #endif
63 
75 DWORD DLLCALLCONV OsEventCreate(_Outptr_ HANDLE *phOsEvent);
76 
86 void DLLCALLCONV OsEventClose(_In_ HANDLE hOsEvent);
87 
102 DWORD DLLCALLCONV OsEventWait(_In_ HANDLE hOsEvent, _In_ DWORD dwSecTimeout);
103 
114 DWORD DLLCALLCONV OsEventSignal(_In_ HANDLE hOsEvent);
115 
126 DWORD DLLCALLCONV OsEventReset(_In_ HANDLE hOsEvent);
127 
139 DWORD DLLCALLCONV OsMutexCreate(_Outptr_ HANDLE *phOsMutex);
140 
150 void DLLCALLCONV OsMutexClose(_In_ HANDLE hOsMutex);
151 
162 DWORD DLLCALLCONV OsMutexLock(_In_ HANDLE hOsMutex);
163 
174 DWORD DLLCALLCONV OsMutexUnlock(_In_ HANDLE hOsMutex);
175 
185 void DLLCALLCONV SleepWrapper(_In_ DWORD dwMicroSecs);
186 
187 #if defined(UNIX)
188  #define OsMemoryBarrier() __sync_synchronize()
189 #elif defined(WIN32)
190  #define OsMemoryBarrier() MemoryBarrier()
191 #endif
192 
193 #if !defined(__KERNEL__)
194 
195 
196 int print2wstr(wchar_t *buffer, size_t count, const wchar_t *format , ...);
197 
217 void DLLCALLCONV vPrintDbgMessage(_In_ DWORD dwLevel, _In_ DWORD dwSection,
218  _In_ const char *format, _In_ va_list ap);
219 
239 void DLLCALLCONV PrintDbgMessage(DWORD dwLevel, DWORD dwSection,
240  const char *format, ...);
241 
250 
259 
272 BOOL DLLCALLCONV UtilGetFileSize(_In_ const PCHAR sFileName,
273  _Outptr_ DWORD *pdwFileSize, _In_ PCHAR sErrString);
274 
292  _In_ DWORD dwSizeStr, _In_ const CHAR *pcInputText,
293  _In_ const CHAR *pcDefaultString);
294 
295 
310 DWORD DLLCALLCONV UtilGetFileName(_Out_ PCHAR pcFileName,
311  _In_ DWORD dwFileNameSize, _In_ const CHAR *pcDefaultFileName);
312 #endif
313 
314 #if defined(UNIX)
315  #if !defined(stricmp)
316  #define stricmp strcasecmp
317  #endif
318  #if !defined(strnicmp)
319  #define strnicmp strncasecmp
320  #endif
321 #endif
322 
323 #if !defined(INFINITE)
324  #define INFINITE 0xffffffff
325 #endif
326 
327 #ifdef __cplusplus
328 }
329 #endif
330 
331 #endif /* _WD_UTILS_H_ */
332 
int print2wstr(wchar_t *buffer, size_t count, const wchar_t *format,...)
void DLLCALLCONV vPrintDbgMessage(_In_ DWORD dwLevel, _In_ DWORD dwSection, _In_ const char *format, _In_ va_list ap)
Sends debug messages to the Debug Monitor.
void DLLCALLCONV PrintDbgMessage(DWORD dwLevel, DWORD dwSection, const char *format,...)
Sends debug messages to the Debug Monitor.
void DLLCALLCONV OsMutexClose(_In_ HANDLE hOsMutex)
Closes a handle to a mutex object.
DWORD DLLCALLCONV OsEventReset(_In_ HANDLE hOsEvent)
Resets the specified event object to the non-signaled state.
DWORD DLLCALLCONV OsEventSignal(_In_ HANDLE hOsEvent)
Sets the specified event object to the signaled state.
DWORD DLLCALLCONV OsMutexCreate(_Outptr_ HANDLE *phOsMutex)
Creates a mutex object.
void(DLLCALLCONV * HANDLER_FUNC)(void *pData)
Definition: utils.h:29
DWORD DLLCALLCONV UtilGetStringFromUser(_Out_ PCHAR pcString, _In_ DWORD dwSizeStr, _In_ const CHAR *pcInputText, _In_ const CHAR *pcDefaultString)
Gets a string from user input and out it in pcString.
void DLLCALLCONV SleepWrapper(_In_ DWORD dwMicroSecs)
Wrapper to WD_Sleep, Sleeps dwMicroSecs microseconds.
BOOL DLLCALLCONV UtilGetFileSize(_In_ const PCHAR sFileName, _Outptr_ DWORD *pdwFileSize, _In_ PCHAR sErrString)
Writes the file size with name sFileName in dwFileSize.
DWORD DLLCALLCONV UtilGetFileName(_Out_ PCHAR pcFileName, _In_ DWORD dwFileNameSize, _In_ const CHAR *pcDefaultFileName)
Gets a file name from user input and out it in pcFileName.
DWORD DLLCALLCONV OsMutexLock(_In_ HANDLE hOsMutex)
Locks the specified mutex object.
int DLLCALLCONV GetNumberOfProcessors(void)
Returns the number of processors currently online (available)
int DLLCALLCONV GetPageSize(void)
Returns the page size in the OS.
DWORD DLLCALLCONV OsEventWait(_In_ HANDLE hOsEvent, _In_ DWORD dwSecTimeout)
Waits until a specified event object is in the signaled state or the time-out interval elapses.
void DLLCALLCONV OsEventClose(_In_ HANDLE hOsEvent)
Closes a handle to an event object.
DWORD DLLCALLCONV OsMutexUnlock(_In_ HANDLE hOsMutex)
Releases (unlocks) a locked mutex object.
DWORD DLLCALLCONV OsEventCreate(_Outptr_ HANDLE *phOsEvent)
Creates an event object.
#define _Outptr_
Definition: windrvr.h:40
#define _Out_
Definition: windrvr.h:39
#define _In_
Definition: windrvr.h:37
#define DLLCALLCONV
Definition: windrvr.h:32