1 ////////////////////////////////////////////////////////////////////
2 // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
3 // All rights reserved
4 // This file was released under the GPLv2 on June 2015.
5 ////////////////////////////////////////////////////////////////////
6 
7 /*************************************************************************
8 *
9 * File: user_lib.h
10 *
11 * Module: User-mode library header
12 *
13 * Description: common useful user-mode functions
14 *
15 * Author: Ivan
16 *
17 *************************************************************************/
18 
19 
20 #ifndef __USER_LIB_H__
21 #define __USER_LIB_H__
22 
23 #if defined DBG || defined PRINT_ALWAYS
24 #define ODS(sz) OutputDebugString(sz)
25 #else
26 #define ODS(sz) {}
27 #endif
28 
29 #define arraylen(a)     (sizeof(a)/sizeof(a[0]))
30 
31 /// CD/DVD-RW device types
32 typedef enum _JS_DEVICE_TYPE {
33     OTHER = 0,
34     CDR,
35     CDRW,
36     DVDROM,
37     DVDRAM,
38     DVDR,
39     DVDRW,
40     DVDPR,
41     DVDPRW,
42     DDCDROM,
43     DDCDR,
44     DDCDRW,
45     BDROM,
46     BDRE,
47     BUSY
48 } JS_DEVICE_TYPE;
49 
50 extern TCHAR* MediaTypeStrings[];
51 
52 /// Service state constants
53 typedef enum _JS_SERVICE_STATE {
54     JS_SERVICE_NOT_PRESENT, ///< Service not installed
55     JS_SERVICE_RUNNING,     ///< Service is running
56     JS_SERVICE_NOT_RUNNING, ///< Service installed, but not running
57     JS_ERROR_STATUS         ///< Errror while taking service status
58 } JS_SERVICE_STATE;
59 
60 void * __cdecl mymemchr (
61         const void * buf,
62         int chr,
63         size_t cnt
64         );
65 
66 char * __cdecl mystrrchr (
67         const char * string,
68         int ch
69         );
70 
71 char * __cdecl  mystrchr (
72         const char * string,
73         int ch
74         );
75 
76 int __cdecl Exist (
77         PCHAR path
78         );
79 
80 ULONG MyMessageBox(
81     HINSTANCE hInst,
82     HWND hWnd,
83     LPCSTR pszFormat,
84     LPCSTR pszTitle,
85     UINT fuStyle,
86     ...
87     );
88 
89 // simple win32 registry api wrappers
90 BOOL RegisterString (LPSTR pszKey, LPSTR pszValue, LPSTR pszData,BOOLEAN MultiSz,DWORD size);
91 BOOL
92 GetRegString (
93   LPSTR pszKey,
94   LPSTR pszValue,
95   LPSTR pszData,
96   DWORD dwBufSize
97   );
98 BOOL RegDelString   (LPSTR pszKey, LPSTR pszValue);
99 BOOL RegisterDword  (LPSTR pszKey, LPSTR pszValue, DWORD dwData);
100 BOOL
101 GetRegUlong (
102   LPSTR pszKey,
103   LPSTR pszValue,
104   LPDWORD pszData
105   );
106 
107 
108 JS_SERVICE_STATE
109 ServiceInfo(
110     LPCTSTR ServiceName
111     );
112 
113 BOOL
114 CheckCdrwFilter(
115     BOOL ReInstall
116     );
117 
118 BOOL
119 Privilege(
120     LPTSTR pszPrivilege,
121     BOOL bEnable
122     );
123 
124 BOOL IsWow64(VOID);
125 
126 #define         DW_GLOBAL_QUIT_EVENT_NAME   L"Global\\DwQuitEvent"
127 #define         DW_QUIT_EVENT_NAME   L"DwQuitEvent"
128 
129 HANDLE
130 CreatePublicEvent(
131     PWCHAR EventName
132     );
133 
134 ULONG
135 UDFPhSendIOCTL(
136     IN ULONG IoControlCode,
137     IN HANDLE DeviceObject,
138     IN PVOID InputBuffer ,
139     IN ULONG InputBufferLength,
140     OUT PVOID OutputBuffer ,
141     IN ULONG OutputBufferLength,
142     IN BOOLEAN OverrideVerify,
143     IN PVOID Dummy
144     );
145 
146 PCHAR
147 UDFGetDeviceName(
148     PCHAR szDeviceName
149     );
150 
151 BOOL
152 GetOptUlong(
153     PCHAR Path,
154     PCHAR OptName,
155     PULONG OptVal
156     );
157 
158 BOOL
159 SetOptUlong(
160     PCHAR Path,
161     PCHAR OptName,
162     PULONG OptVal
163     );
164 
165 #define UDF_OPTION_GLOBAL     1
166 #define UDF_OPTION_MEDIASPEC  10
167 #define UDF_OPTION_DEVSPEC    2
168 #define UDF_OPTION_DISKSPEC   3
169 #define UDF_OPTION_MAX_DEPTH  0xffffffff
170 
171 ULONG
172 UDFGetOptUlongInherited(
173     PCHAR Drive,
174     PCHAR OptName,
175     PULONG OptVal,
176     ULONG CheckDepth
177     );
178 
179 HANDLE
180 OpenOurVolume(
181     PCHAR szDeviceName
182     );
183 
184 ULONG
185 drv_letter_to_index(
186     WCHAR a
187     );
188 
189 DWORD
190 WINAPI
191 LauncherRoutine2(
192     LPVOID lpParameter
193     );
194 
195 #endif // __USER_LIB_H__
196