ReactOS 0.4.16-dev-122-g325d74c
user_lib.cpp File Reference
#include "user_lib.h"
Include dependency graph for user_lib.cpp:

Go to the source code of this file.

Macros

#define __USER_LIB_CPP__
 

Typedefs

typedef BOOL(WINAPILPFN_ISWOW64PROCESS) (HANDLE, PBOOL)
 

Functions

void *__cdecl mymemchr (const void *buf, int chr, size_t cnt)
 
char *__cdecl mystrrchr (const char *string, int ch)
 
char *__cdecl mystrchr (const char *string, int ch)
 
int __cdecl Exist (PCHAR path)
 
ULONG MyMessageBox (HINSTANCE hInst, HWND hWnd, LPCSTR pszFormat, LPCSTR pszTitle, UINT fuStyle,...)
 
JS_SERVICE_STATE ServiceInfo (LPCTSTR ServiceName)
 Return service status by service name.
 
BOOL CheckCdrwFilter (BOOL ReInstall)
 
BOOL RegisterString (LPSTR pszKey, LPSTR pszValue, LPSTR pszData, BOOLEAN MultiSz, DWORD size)
 
BOOL RegDelString (LPSTR pszKey, LPSTR pszValue)
 
BOOL GetRegString (LPSTR pszKey, LPSTR pszValue, LPSTR pszData, DWORD dwBufSize)
 Get string from registry by Key path and Value name.
 
BOOL RegisterDword (LPSTR pszKey, LPSTR pszValue, DWORD dwData)
 
BOOL GetRegUlong (LPSTR pszKey, LPSTR pszValue, PULONG pszData)
 
BOOL SetRegUlong (LPSTR pszKey, LPSTR pszValue, PULONG pszData)
 
BOOL Privilege (LPTSTR pszPrivilege, BOOL bEnable)
 
BOOL IsWow64 (VOID)
 
HANDLE CreatePublicEvent (PWCHAR EventName)
 
ULONG UDFPhSendIOCTL (IN ULONG IoControlCode, IN HANDLE DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN OverrideVerify, IN PVOID Dummy)
 Send Device IO Controls to undelaying level via handle.
 
PCHAR UDFGetDeviceName (PCHAR szDeviceName)
 
BOOL GetOptUlong (PCHAR Path, PCHAR OptName, PULONG OptVal)
 
BOOL SetOptUlong (PCHAR Path, PCHAR OptName, PULONG OptVal)
 
ULONG UDFGetOptUlongInherited (PCHAR Drive, PCHAR OptName, PULONG OptVal, ULONG CheckDepth)
 
HANDLE OpenOurVolume (PCHAR szDeviceName)
 
ULONG drv_letter_to_index (WCHAR a)
 
DWORD WINAPI LauncherRoutine2 (LPVOID lpParameter)
 Start app with desired parameters.
 

Variables

TCHARMediaTypeStrings []
 
CHAR RealDeviceName [MAX_PATH+1]
 

Macro Definition Documentation

◆ __USER_LIB_CPP__

#define __USER_LIB_CPP__

Definition at line 21 of file user_lib.cpp.

Typedef Documentation

◆ LPFN_ISWOW64PROCESS

typedef BOOL(WINAPI * LPFN_ISWOW64PROCESS) (HANDLE, PBOOL)

Definition at line 576 of file user_lib.cpp.

Function Documentation

◆ CheckCdrwFilter()

BOOL CheckCdrwFilter ( BOOL  ReInstall)

Definition at line 200 of file user_lib.cpp.

203{
204 char CdromUpperFilters[1024];
205 bool found = false;
206
207 if (LOBYTE(LOWORD(GetVersion())) < 5) {
208 return true;
209 }
210
211 if (GetRegString(CDROM_CLASS_PATH,REG_UPPER_FILTER_NAME,&CdromUpperFilters[0],arraylen(CdromUpperFilters))) {
212 char *token = &CdromUpperFilters[0];
213
214 while (*token) {
215 if (!strcmp(token,CDRW_SERVICE)) {
216 found = true;
217 break;
218 }
219 token += strlen(token)+1;
220 }
221 if (!found) {
223 *(token+sizeof(CDRW_SERVICE)) = '\0';
224 *(token+sizeof(CDRW_SERVICE)+1) = '\0';
225 if(ReInstall) {
226 RegisterString(CDROM_CLASS_PATH,REG_UPPER_FILTER_NAME,&CdromUpperFilters[0],TRUE,token-&CdromUpperFilters[0]+sizeof(CDRW_SERVICE)+1);
227 found = true;
228 }
229 }
230 } else {
231 memcpy(CdromUpperFilters,CDRW_SERVICE,sizeof(CDRW_SERVICE));
232 CdromUpperFilters[sizeof(CDRW_SERVICE)] = '\0';
233 CdromUpperFilters[sizeof(CDRW_SERVICE)+1] = '\0';
234 if(ReInstall) {
236 found = true;
237 }
238 }
239 return found;
240
241} // end CheckCdrwFilter()
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
#define LOBYTE(W)
Definition: jmemdos.c:487
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define LOWORD(l)
Definition: pedump.c:82
DWORD WINAPI GetVersion()
Definition: redirtest.c:5
#define CDROM_CLASS_PATH
Definition: udf_reg.h:28
#define CDRW_SERVICE
Definition: udf_reg.h:14
#define REG_UPPER_FILTER_NAME
Definition: udf_reg.h:29
BOOL GetRegString(LPSTR pszKey, LPSTR pszValue, LPSTR pszData, DWORD dwBufSize)
Get string from registry by Key path and Value name.
Definition: user_lib.cpp:338
BOOL RegisterString(LPSTR pszKey, LPSTR pszValue, LPSTR pszData, BOOLEAN MultiSz, DWORD size)
Definition: user_lib.cpp:244
#define arraylen(a)
Definition: user_lib.h:29

◆ CreatePublicEvent()

HANDLE CreatePublicEvent ( PWCHAR  EventName)

Definition at line 596 of file user_lib.cpp.

599{
600 SECURITY_DESCRIPTOR sdPublic;
601 SECURITY_ATTRIBUTES saPublic;
602
604 &sdPublic,
606 );
607
609 &sdPublic,
610 TRUE,
611 NULL,
612 FALSE
613 );
614
615 saPublic.nLength = sizeof(saPublic);
616 saPublic.lpSecurityDescriptor = &sdPublic;
617
618 return CreateEventW(
619 &saPublic,
620 TRUE,
621 FALSE,
622 EventName);
623
624} // end CreatePublicEvent()
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
LPVOID lpSecurityDescriptor
Definition: compat.h:193
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58

Referenced by FmtAcquireDrive_().

◆ drv_letter_to_index()

ULONG drv_letter_to_index ( WCHAR  a)

Definition at line 805 of file user_lib.cpp.

808{
809 if(a >= 'a' && a <= 'z') {
810 return a - 'a';
811 }
812 if(a >= 'A' && a <= 'Z') {
813 return a - 'A';
814 }
815 return -1;
816} // end drv_letter_to_index()
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ Exist()

int __cdecl Exist ( PCHAR  path)

Definition at line 94 of file user_lib.cpp.

97{
98 DWORD attr;
99
101 if (attr == 0xffffffff) {
102 return 0;
103 }
104
105 return 1;
106
107} // end Exist()
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: cookie.c:202
#define GetFileAttributes
Definition: winbase.h:3815
CHAR * LPTSTR
Definition: xmlstorage.h:192

◆ GetOptUlong()

BOOL GetOptUlong ( PCHAR  Path,
PCHAR  OptName,
PULONG  OptVal 
)

Definition at line 693 of file user_lib.cpp.

698{
699 if(!Path) {
700 return FALSE;
701 }
702 if(Path[0] && Path[1] == ':') {
703 CHAR SettingFile[MAX_PATH];
704 CHAR Setting[16];
705
706 sprintf(SettingFile, "%s\\%s", Path, UDF_CONFIG_STREAM_NAME);
707 GetPrivateProfileString("DiskSettings", OptName, "d", &Setting[0], 10, SettingFile);
708 Setting[15]=0;
709 if (Setting[0] != 'd') {
710 if(Setting[0] == '0' && Setting[1] == 'x') {
711 sscanf(Setting+2, "%x", OptVal);
712 } else {
713 sscanf(Setting, "%d", OptVal);
714 }
715 return TRUE;
716 }
717 return FALSE;
718 }
719 return GetRegUlong(Path, OptName, OptVal);
720} // end GetOptUlong()
PRTL_UNICODE_STRING_BUFFER Path
#define MAX_PATH
Definition: compat.h:34
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define UDF_CONFIG_STREAM_NAME
Definition: udfpubl.h:81
BOOL GetRegUlong(LPSTR pszKey, LPSTR pszValue, PULONG pszData)
Definition: user_lib.cpp:425
#define GetPrivateProfileString
Definition: winbase.h:3835
char CHAR
Definition: xmlstorage.h:175

Referenced by UDFGetOptUlongInherited().

◆ GetRegString()

BOOL GetRegString ( LPSTR  pszKey,
LPSTR  pszValue,
LPSTR  pszData,
DWORD  dwBufSize 
)

Get string from registry by Key path and Value name.

Definition at line 338 of file user_lib.cpp.

344{
345
346 HKEY hKey;
347 DWORD dwDataSize = dwBufSize;
348 DWORD dwValueType = REG_SZ;
349
350 if(!dwBufSize)
351 return FALSE;
352
354 HKEY_LOCAL_MACHINE, // handle of open key
355 pszKey, // address of name of subkey to open
356 0, // reserved
357 KEY_QUERY_VALUE, // security access mask
358 &hKey // address of handle of open key
359 );
360
362 hKey, // handle of key to query
363 pszValue, // address of name of value to query
364 0, // reserved
365 &dwValueType, // address of buffer for value type
366 (BYTE *)pszData, // address of data buffer
367 &dwDataSize // address of data buffer size
368 )) return FALSE;
369
370 if (pszData[dwDataSize-1] != '\0')
371 pszData[dwDataSize-1] = '\0';
372
373 return TRUE;
374} // end GetRegString()
#define ERROR_SUCCESS
Definition: deptool.c:10
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegQueryValueEx
Definition: winreg.h:524
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CheckCdrwFilter(), and LauncherRoutine2().

◆ GetRegUlong()

BOOL GetRegUlong ( LPSTR  pszKey,
LPSTR  pszValue,
PULONG  pszData 
)

Definition at line 425 of file user_lib.cpp.

430{
431
432 HKEY hKey;
433 DWORD dwDataSize = 4;
434 DWORD dwValueType = REG_DWORD;
435 ULONG origValue = *pszData;
436
437 if(RegOpenKeyEx(
438 HKEY_LOCAL_MACHINE, // handle of open key
439 pszKey, // address of name of subkey to open
440 0, // reserved
441 KEY_QUERY_VALUE, // security access mask
442 &hKey // address of handle of open key
443 ) != ERROR_SUCCESS) {
444 (*pszData) = origValue;
445 return FALSE;
446 }
447
449 hKey, // handle of key to query
450 pszValue, // address of name of value to query
451 0, // reserved
452 &dwValueType,// address of buffer for value type
453 (BYTE *)pszData, // address of data buffer
454 &dwDataSize // address of data buffer size
455 ) != ERROR_SUCCESS) {
456 (*pszData) = origValue;
457 }
458
460
461 return TRUE;
462} // end GetRegUlong()
#define RegCloseKey(hKey)
Definition: registry.h:49
#define REG_DWORD
Definition: sdbapi.c:596
uint32_t ULONG
Definition: typedefs.h:59

Referenced by GetOptUlong().

◆ IsWow64()

BOOL IsWow64 ( VOID  )

Definition at line 579 of file user_lib.cpp.

580{
581 BOOL bIsWow64 = FALSE;
582 LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"),"IsWow64Process");
583
584 if (NULL != fnIsWow64Process)
585 {
586 if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
587 {
588 return FALSE;
589 }
590 }
591 return bIsWow64;
592} // end IsWow64()
#define GetProcAddress(x, y)
Definition: compat.h:753
#define GetCurrentProcess()
Definition: compat.h:759
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE, PBOOL)
Definition: user_lib.cpp:576
#define GetModuleHandle
Definition: winbase.h:3827

Referenced by Is64BitSystem(), START_TEST(), and Test_CombineTransform().

◆ LauncherRoutine2()

DWORD WINAPI LauncherRoutine2 ( LPVOID  lpParameter)

Start app with desired parameters.

Definition at line 821 of file user_lib.cpp.

824{
825 PCHAR ParamStr = (PCHAR)lpParameter;
826 STARTUPINFO proc_startup_info;
827 PROCESS_INFORMATION proc_info;
828 CHAR szLaunchPath[MAX_PATH],ErrMes[50];
829 INT index;
830 ULONG MkUdfRetCode;
831 CHAR szTemp[256];
832
833 GetRegString(UDF_KEY,"ToolsPath",szLaunchPath, sizeof(szLaunchPath));
834 SetCurrentDirectory(szLaunchPath);
835
836 strcat(szLaunchPath,"\\");
837 //strcat(szLaunchPath,UDFFMT);
838 strcat(szLaunchPath,ParamStr);
839
840 //strcpy(MkUdfStatus,"");
841
842#ifndef TESTMODE
843 proc_startup_info.cb = sizeof(proc_startup_info);
844 proc_startup_info.lpReserved = 0;
845 proc_startup_info.lpReserved2 = 0;
846 proc_startup_info.cbReserved2 = 0;
847 proc_startup_info.lpDesktop = 0;
848 proc_startup_info.lpTitle = 0;
849 proc_startup_info.dwFlags = 0;
850
851 proc_startup_info.hStdInput = NULL;
852 proc_startup_info.hStdOutput = NULL;
853 proc_startup_info.hStdError = NULL;
854
856 0,0, &proc_startup_info, &proc_info)) {
857
858 //hFmtProc[i] = proc_info.hProcess;
859 WaitForSingleObject(proc_info.hProcess, -1);
860 GetExitCodeProcess(proc_info.hProcess, &MkUdfRetCode);
861 index=0;
862/*
863 while (mkudf_err_msg[index].err_code != 0xffffffff){
864 if (mkudf_err_msg[index].err_code == MkUdfRetCode) break;
865 index++;
866 }
867*/
868 //strcpy(MkUdfStatus,mkudf_err_msg[index].err_msg);
869
870 CloseHandle(proc_info.hThread);
871 CloseHandle(proc_info.hProcess);
872 } else {
873 strcpy(ErrMes,"Stop: Cannot launch ");
874 strcat(ErrMes,szLaunchPath);
875 sprintf(szTemp," error %d",GetLastError());
876 strcat(ErrMes,szTemp);
877 MessageBox(NULL,ErrMes,"UDFFormat",MB_OK | MB_ICONHAND);
878
879 }
880#else
881 MessageBox(NULL,szLaunchPath,"Message",MB_OK);
882 Sleep(500);
883 MkUdfRetCode = MKUDF_OK;
884// MkUdfRetCode = MKUDF_FORMAT_REQUIRED;
885// MkUdfRetCode = MKUDF_CANT_BLANK;
886
887 index = 0;
888 while (mkudf_err_msg[index].err_code != 0xffffffff){
889 if (mkudf_err_msg[index].err_code == MkUdfRetCode) break;
890 index++;
891 }
892 //strcpy(MkUdfStatus,mkudf_err_msg[index].err_msg);
893
894#endif
895 return MkUdfRetCode;
896} // end LauncherRoutine2()
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define index(s, c)
Definition: various.h:29
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
GLuint index
Definition: glext.h:6031
#define PCHAR
Definition: match.c:90
HANDLE hStdOutput
Definition: winbase.h:847
LPSTR lpTitle
Definition: winbase.h:834
HANDLE hStdError
Definition: winbase.h:848
DWORD dwFlags
Definition: winbase.h:842
DWORD cb
Definition: winbase.h:831
LPSTR lpReserved
Definition: winbase.h:832
HANDLE hStdInput
Definition: winbase.h:846
WORD cbReserved2
Definition: winbase.h:844
PBYTE lpReserved2
Definition: winbase.h:845
LPSTR lpDesktop
Definition: winbase.h:833
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
int32_t INT
Definition: typedefs.h:58
char * PCHAR
Definition: typedefs.h:51
#define UDF_KEY
Definition: udf_reg.h:16
struct err_msg_item mkudf_err_msg[]
Definition: udferr_usr.cpp:8
#define MKUDF_OK
Definition: udferr_usr.h:12
#define CreateProcess
Definition: winbase.h:3758
#define NORMAL_PRIORITY_CLASS
Definition: winbase.h:181
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SetCurrentDirectory
Definition: winbase.h:3903
#define CREATE_NO_WINDOW
Definition: winbase.h:195
#define MB_ICONHAND
Definition: winuser.h:791
#define MB_OK
Definition: winuser.h:793
#define MessageBox
Definition: winuser.h:5834

◆ mymemchr()

void *__cdecl mymemchr ( const void buf,
int  chr,
size_t  cnt 
)

Definition at line 45 of file user_lib.cpp.

50{
51 while ( cnt && (*(unsigned char *)buf != (unsigned char)chr) ) {
52 buf = (unsigned char *)buf + 1;
53 cnt--;
54 }
55
56 return(cnt ? (void *)buf : NULL);
57} // end mymemchr()
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

◆ MyMessageBox()

ULONG MyMessageBox ( HINSTANCE  hInst,
HWND  hWnd,
LPCSTR  pszFormat,
LPCSTR  pszTitle,
UINT  fuStyle,
  ... 
)

Definition at line 110 of file user_lib.cpp.

118{
119 CHAR szTitle[80];
120 CHAR szFormat[1024];
121 LPSTR pszMessage;
122 BOOL fOk;
123 int result;
124 va_list ArgList;
125
126 if (!HIWORD(pszTitle)) {
127 LoadString(hInst, LOWORD(pszTitle), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
128 pszTitle = szTitle;
129 }
130
131 if (!HIWORD(pszFormat)) {
132 // Allow this to be a resource ID
133 LoadString(hInst, LOWORD(pszFormat), szFormat, sizeof(szFormat)/sizeof(szFormat[0]));
134 pszFormat = szFormat;
135 }
136
137 va_start(ArgList, fuStyle);
140 pszFormat, 0, 0, (LPTSTR)&pszMessage, 0, &ArgList);
141
142 va_end(ArgList);
143
144 if (fOk && pszMessage) {
145 result = MessageBox(hWnd, pszMessage, pszTitle, fuStyle | MB_SETFOREGROUND);
146 LocalFree(pszMessage);
147 } else {
148 return -1;
149 }
150
151 return result;
152} // end MyMessageBox()
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
HWND hWnd
Definition: settings.c:17
HINSTANCE hInst
Definition: dxdiag.c:13
GLuint64EXT * result
Definition: glext.h:11304
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define HIWORD(l)
Definition: typedefs.h:247
#define FormatMessage
Definition: winbase.h:3795
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:421
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419
#define MB_SETFOREGROUND
Definition: winuser.h:817
#define LoadString
Definition: winuser.h:5831
char * LPSTR
Definition: xmlstorage.h:182

◆ mystrchr()

char *__cdecl mystrchr ( const char string,
int  ch 
)

Definition at line 77 of file user_lib.cpp.

81{
82 while (*string != (char)ch && *string != '\0' ) {
83 string++;
84 }
85
86 if (*string == (char)ch) {
87 return( (char *)string );
88 }
89
90 return(NULL);
91} // end mystrchr()

◆ mystrrchr()

char *__cdecl mystrrchr ( const char string,
int  ch 
)

Definition at line 59 of file user_lib.cpp.

63{
64 char *start = (char *)string;
65
66 while (*string++) {;}
67
68 while (--string != start && *string != (char)ch) {;}
69
70 if (*string == (char)ch) {
71 return( (char *)string );
72 }
73
74 return(NULL);
75} // end mystrrchr()
GLuint start
Definition: gl.h:1545
char string[160]
Definition: util.h:11

◆ OpenOurVolume()

HANDLE OpenOurVolume ( PCHAR  szDeviceName)

Definition at line 780 of file user_lib.cpp.

783{
784 HANDLE hDevice;
785
786 // Open device volume
789 NULL,
792
793 if (hDevice == ((HANDLE)-1)) {
796 NULL,
799
800 }
801 return hDevice;
802} // end OpenOurVolume()
static const WCHAR szDeviceName[]
Definition: provider.c:56
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define CreateFile
Definition: winbase.h:3749

Referenced by CheckCDType().

◆ Privilege()

BOOL Privilege ( LPTSTR  pszPrivilege,
BOOL  bEnable 
)

Definition at line 531 of file user_lib.cpp.

535{
536
537 HANDLE hToken;
539
540 //
541 // obtain the token, first check the thread and then the process
542 //
544 if (GetLastError() == ERROR_NO_TOKEN) {
546 return FALSE;
547 }
548 else return FALSE;
549 }
550
551 //
552 // get the luid for the privilege
553 //
554 if (!LookupPrivilegeValue(NULL, pszPrivilege, &tp.Privileges[0].Luid))
555 return FALSE;
556
557 tp.PrivilegeCount = 1;
558
559 if (bEnable)
560 tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
561 else
562 tp.Privileges[0].Attributes = 0;
563
564 //
565 // enable or disable the privilege
566 //
567 if (!AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0))
568 return FALSE;
569
570 if (!CloseHandle(hToken))
571 return FALSE;
572
573 return TRUE;
574} // end Privilege()
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI OpenThreadToken(HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, HANDLE *TokenHandle)
Definition: security.c:336
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
#define LookupPrivilegeValue
Definition: winbase.h:3870
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
_In_ BOOL bEnable
Definition: winddi.h:3426
#define ERROR_NO_TOKEN
Definition: winerror.h:587
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by AccessCheckEmptyMappingTest(), AccessGrantedMultipleObjectsTests(), AccessGrantedNoDaclTests(), AccessGrantedTests(), BasepIsRealtimeAllowed(), DenyAccessTests(), Ext2InvalidateVolumes(), FilterToken(), GrantedAccessTests(), HasPrivilege(), IsPrivilegeEnabled(), LsapAddPrivilegeToTokenPrivileges(), my_open(), NtOpenObjectAuditAlarm(), NtPrivilegeCheck(), NtPrivilegedServiceAuditAlarm(), ParamsValidationTests(), ParamValidationNoObjsList(), RtlAcquirePrivilege(), RtlAdjustPrivilege(), RtlRemovePrivileges(), SePrivilegePolicyCheck(), SepSinglePrivilegeCheck(), SeReleaseLuidAndAttributesArray(), SetInformationJobObject(), SetLocalTime(), SetProcessWorkingSetSizeEx(), SetSystemTime(), SmpAcquirePrivilege(), START_TEST(), test_AccessCheck(), test_impersonation_level(), and test_pack_PRIVILEGE_SET().

◆ RegDelString()

BOOL RegDelString ( LPSTR  pszKey,
LPSTR  pszValue 
)

Definition at line 294 of file user_lib.cpp.

298{
299
300 HKEY hKey;
301 DWORD dwDisposition;
302
303 // Create the key, if it exists it will be opened
304 if (ERROR_SUCCESS !=
306 HKEY_LOCAL_MACHINE, // handle of an open key
307 pszKey, // address of subkey name
308 0, // reserved
309 NULL, // address of class string
310 REG_OPTION_NON_VOLATILE, // special options flag
311 KEY_ALL_ACCESS, // desired security access
312 NULL, // address of key security structure
313 &hKey, // address of buffer for opened handle
314 &dwDisposition)) // address of disposition value buffer
315 {
316 return FALSE;
317 }
318
319 // Write the value and it's data to the key
320 if (ERROR_SUCCESS !=
322 hKey, // handle of key to set value for
323 pszValue))
324 {
325
327 return FALSE;
328 }
329
330 // Close the key
332
333 return TRUE;
334} // end RegDelString()
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define RegCreateKeyEx
Definition: winreg.h:501
#define RegDeleteValue
Definition: winreg.h:508

◆ RegisterDword()

BOOL RegisterDword ( LPSTR  pszKey,
LPSTR  pszValue,
DWORD  dwData 
)

Definition at line 377 of file user_lib.cpp.

382{
383
384 HKEY hKey;
385 DWORD dwDisposition;
386
387 // Create the key, if it exists it will be opened
388 if (ERROR_SUCCESS !=
390 HKEY_LOCAL_MACHINE, // handle of an open key
391 pszKey, // address of subkey name
392 0, // reserved
393 NULL, // address of class string
394 REG_OPTION_NON_VOLATILE, // special options flag
395 KEY_ALL_ACCESS, // desired security access
396 NULL, // address of key security structure
397 &hKey, // address of buffer for opened handle
398 &dwDisposition)) // address of disposition value buffer
399 {
400 return FALSE;
401 }
402
403 // Write the value and it's data to the key
404 if (ERROR_SUCCESS !=
406 hKey, // handle of key to set value for
407 pszValue, // address of value to set
408 0, // reserved
409 REG_DWORD, // flag for value type
410 (CONST BYTE *)&dwData, // address of value data
411 4 )) // size of value data
412 {
413
415 return FALSE;
416 }
417
418 // Close the key
420
421 return TRUE;
422} // end RegisterDword()
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define CONST
Definition: pedump.c:81
#define RegSetValueEx
Definition: winreg.h:533

◆ RegisterString()

BOOL RegisterString ( LPSTR  pszKey,
LPSTR  pszValue,
LPSTR  pszData,
BOOLEAN  MultiSz,
DWORD  size 
)

Definition at line 244 of file user_lib.cpp.

251{
252
253 HKEY hKey;
254 DWORD dwDisposition;
255
256 // Create the key, if it exists it will be opened
257 if (ERROR_SUCCESS !=
259 HKEY_LOCAL_MACHINE, // handle of an open key
260 pszKey, // address of subkey name
261 0, // reserved
262 NULL, // address of class string
263 REG_OPTION_NON_VOLATILE, // special options flag
264 KEY_ALL_ACCESS, // desired security access
265 NULL, // address of key security structure
266 &hKey, // address of buffer for opened handle
267 &dwDisposition)) // address of disposition value buffer
268 {
269 return FALSE;
270 }
271
272 // Write the value and it's data to the key
273 if (ERROR_SUCCESS !=
275 hKey, // handle of key to set value for
276 pszValue, // address of value to set
277 0, // reserved
278 MultiSz ? REG_MULTI_SZ : REG_SZ, // flag for value type
279 (CONST BYTE *)pszData, // address of value data
280 MultiSz ? size : strlen(pszData) )) // size of value data
281 {
282
284 return FALSE;
285 }
286
287 // Close the key
289
290 return TRUE;
291} // end RegisterString()
GLsizeiptr size
Definition: glext.h:5919
#define REG_MULTI_SZ
Definition: nt_native.h:1501

Referenced by CheckCdrwFilter().

◆ ServiceInfo()

JS_SERVICE_STATE ServiceInfo ( LPCTSTR  ServiceName)

Return service status by service name.

Definition at line 157 of file user_lib.cpp.

160{
161 SC_HANDLE schService;
162 DWORD RC;
164 JS_SERVICE_STATE return_value;
165 SC_HANDLE schSCManager;
166
167 schSCManager = OpenSCManager(
168 NULL, // machine (NULL == local)
169 NULL, // database (NULL == default)
170 SC_MANAGER_ALL_ACCESS // access required
171 );
172 if (!schSCManager) {
173 schSCManager = OpenSCManager(
174 NULL, // machine (NULL == local)
175 NULL, // database (NULL == default)
176 SC_MANAGER_CONNECT // access required
177 );
178 }
179 if (!schSCManager)
180 return JS_ERROR_STATUS;
181 schService = OpenService(schSCManager, ServiceName, SERVICE_QUERY_STATUS);
182 if (!schService) {
183 RC = GetLastError();
184 CloseServiceHandle(schSCManager);
186 else return JS_ERROR_STATUS;
187 }
188 QueryServiceStatus(schService, &ssStatus);
190 return_value = JS_SERVICE_RUNNING;
191 } else {
192 return_value = JS_SERVICE_NOT_RUNNING;
193 }
194 CloseServiceHandle(schService);
195 CloseServiceHandle(schSCManager);
196 return return_value;
197} // end ServiceInfo()
static WCHAR ServiceName[]
Definition: browser.c:19
SERVICE_STATUS ssStatus
Definition: service.c:34
BOOL WINAPI QueryServiceStatus(SC_HANDLE hService, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:2845
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
DWORD dwCurrentState
Definition: winsvc.h:100
enum _JS_SERVICE_STATE JS_SERVICE_STATE
Service state constants.
@ JS_SERVICE_RUNNING
Service is running.
Definition: user_lib.h:55
@ JS_SERVICE_NOT_PRESENT
Service not installed.
Definition: user_lib.h:54
@ JS_SERVICE_NOT_RUNNING
Service installed, but not running.
Definition: user_lib.h:56
@ JS_ERROR_STATUS
Errror while taking service status.
Definition: user_lib.h:57
#define ERROR_SERVICE_DOES_NOT_EXIST
Definition: winerror.h:611
#define SERVICE_QUERY_STATUS
Definition: winsvc.h:55
#define OpenSCManager
Definition: winsvc.h:575
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SC_MANAGER_ALL_ACCESS
Definition: winsvc.h:13
#define OpenService
Definition: winsvc.h:576

Referenced by Create(), and SetConfig().

◆ SetOptUlong()

BOOL SetOptUlong ( PCHAR  Path,
PCHAR  OptName,
PULONG  OptVal 
)

Definition at line 723 of file user_lib.cpp.

728{
729 if(!Path) {
730 return FALSE;
731 }
732 if(Path[0] && Path[1] == ':') {
733 CHAR SettingFile[MAX_PATH];
734 CHAR Setting[16];
735 if(Path[2] != '\\') {
736 sprintf(SettingFile, "%s\\%s", Path, UDF_CONFIG_STREAM_NAME);
737 } else {
738 sprintf(SettingFile, "%s%s", Path, UDF_CONFIG_STREAM_NAME);
739 }
740 sprintf(Setting, "%d\n", (*OptVal));
741 return WritePrivateProfileString("DiskSettings", OptName, Setting, SettingFile);
742 }
743 return SetRegUlong(Path, OptName, OptVal);
744} // end SetOptUlong()
BOOL SetRegUlong(LPSTR pszKey, LPSTR pszValue, PULONG pszData)
Definition: user_lib.cpp:465
#define WritePrivateProfileString
Definition: winbase.h:3923

◆ SetRegUlong()

BOOL SetRegUlong ( LPSTR  pszKey,
LPSTR  pszValue,
PULONG  pszData 
)

Definition at line 465 of file user_lib.cpp.

470{
471
472 HKEY hKey;
473 DWORD dwDataSize = 4;
474 DWORD dwValueType = REG_DWORD;
475 LPVOID lpMsgBuf;
476 LONG RC;
477
478 if (!(ERROR_SUCCESS == (RC = RegOpenKeyEx(
479 HKEY_LOCAL_MACHINE, // handle of open key
480 pszKey, // address of name of subkey to open
481 0, // reserved
482 KEY_ALL_ACCESS , // security access mask
483 &hKey // address of handle of open key
484 )))) {
487 NULL,
488 RC,
489 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
490 (LPTSTR) &lpMsgBuf,
491 0,
492 NULL);
493
494 // Display the string.
495 MessageBox( NULL, (CCHAR*)lpMsgBuf, "Error", MB_OK|MB_ICONHAND );
496
497 // Free the buffer.
498 LocalFree( lpMsgBuf );
499 return FALSE;
500 }
501
502 if (!(ERROR_SUCCESS == (RC = RegSetValueEx(
503 hKey, // handle of key to query
504 pszValue, // address of name of value to query
505 0, // reserved
506 REG_DWORD,// address of buffer for value type
507 (BYTE *)pszData, // address of data buffer
508 sizeof(ULONG) // data buffer size
509 )))) {
512 NULL,
513 RC,
514 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
515 (LPTSTR) &lpMsgBuf,
516 0,
517 NULL);
518
519 // Display the string.
520 MessageBox( NULL, (CCHAR*)lpMsgBuf, "Error", MB_OK|MB_ICONHAND );
521
522 // Free the buffer.
523 LocalFree( lpMsgBuf );
524
525 }
527 return TRUE;
528} // end SetRegUlong()
long LONG
Definition: pedump.c:60
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
char CCHAR
Definition: typedefs.h:51
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423

Referenced by SetOptUlong().

◆ UDFGetDeviceName()

PCHAR UDFGetDeviceName ( PCHAR  szDeviceName)

Definition at line 656 of file user_lib.cpp.

659{
660 HANDLE hDevice;
662 ULONG RC;
663
664 ODS(" UDFGetDeviceName\r\n");
667 NULL,
670
671 if (hDevice == ((HANDLE)-1)) {
673 return (PCHAR)&RealDeviceName;
674 }
675
677 &DeviceName,(MAX_PATH+1)*sizeof(WCHAR),
678 &DeviceName,(MAX_PATH+1)*sizeof(WCHAR), FALSE,NULL);
679
680 if(RC == 1) {
682 RealDeviceName[(USHORT)DeviceName[0]/sizeof(USHORT)] = '\0';
683 } else {
685 }
686
687 CloseHandle(hDevice);
688
689 return (PCHAR)(strrchr(RealDeviceName, '\\')+1);
690} // end UDFGetDeviceName()
#define IOCTL_CDRW_GET_DEVICE_NAME
Definition: cdrw_usr.h:121
size_t __cdecl wcstombs(_Out_writes_opt_z_(_MaxCount) char *_Dest, _In_z_ const wchar_t *_Source, _In_ size_t _MaxCount)
unsigned short USHORT
Definition: pedump.c:61
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
ULONG UDFPhSendIOCTL(IN ULONG IoControlCode, IN HANDLE DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN OverrideVerify, IN PVOID Dummy)
Send Device IO Controls to undelaying level via handle.
Definition: user_lib.cpp:628
CHAR RealDeviceName[MAX_PATH+1]
Definition: user_lib.cpp:653
#define ODS(sz)
Definition: user_lib.h:26
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by UDFGetOptUlongInherited().

◆ UDFGetOptUlongInherited()

ULONG UDFGetOptUlongInherited ( PCHAR  Drive,
PCHAR  OptName,
PULONG  OptVal,
ULONG  CheckDepth 
)

Definition at line 747 of file user_lib.cpp.

753{
754 CHAR LocalPath[1024];
755 ULONG retval = 0;
756
757 ODS(" UDFGetOptUlongInherited\r\n");
758
759 if(GetOptUlong(UDF_SERVICE_PARAM_PATH, OptName, OptVal)) {
760 retval = UDF_OPTION_GLOBAL;
761 }
762 if(CheckDepth <= UDF_OPTION_GLOBAL) {
763 return retval;
764 }
766 strcat(LocalPath,"\\");
767 strcat(LocalPath,UDFGetDeviceName(Drive));
768 if(GetOptUlong(LocalPath, OptName, OptVal)) {
769 retval = UDF_OPTION_DEVSPEC;
770 }
771 if(CheckDepth <= UDF_OPTION_DEVSPEC) {
772 return retval;
773 }
774 if(GetOptUlong(Drive, OptName, OptVal))
775 retval = UDF_OPTION_DISKSPEC;
776 return retval;
777} // end UDFGetOptUlongInherited()
PWCHAR Drive
Definition: chkdsk.c:73
#define UDF_SERVICE_PARAM_PATH
Definition: udf_reg.h:22
PCHAR UDFGetDeviceName(PCHAR szDeviceName)
Definition: user_lib.cpp:656
BOOL GetOptUlong(PCHAR Path, PCHAR OptName, PULONG OptVal)
Definition: user_lib.cpp:693
#define UDF_OPTION_GLOBAL
Definition: user_lib.h:165
#define UDF_OPTION_DISKSPEC
Definition: user_lib.h:168
#define UDF_OPTION_DEVSPEC
Definition: user_lib.h:167

◆ UDFPhSendIOCTL()

ULONG UDFPhSendIOCTL ( IN ULONG  IoControlCode,
IN HANDLE  DeviceObject,
IN PVOID  InputBuffer,
IN ULONG  InputBufferLength,
OUT PVOID  OutputBuffer,
IN ULONG  OutputBufferLength,
IN BOOLEAN  OverrideVerify,
IN PVOID  Dummy 
)

Send Device IO Controls to undelaying level via handle.

Definition at line 628 of file user_lib.cpp.

638{
639 ULONG real_read;
640 ULONG ret;
641 LONG offh=0;
645 &real_read,NULL);
646
647 if (!RC) {
648 ret = GetLastError();
649 }
650 return RC ? 1 : -1;
651} // end UDFPhSendIOCTL()
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
int ret
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953

Referenced by UDFGetDeviceName().

Variable Documentation

◆ MediaTypeStrings

TCHAR* MediaTypeStrings[]
Initial value:
=
{
"CD-ROM" ,
"CD-R" ,
"CD-RW" ,
"DVD-ROM" ,
"DVD-RAM" ,
"DVD-R" ,
"DVD-RW" ,
"DVD+R" ,
"DVD+RW" ,
"DD CD-ROM" ,
"DD CD-R" ,
"DD CD-RW" ,
"BD-ROM" ,
"BD-RE" ,
"[BUSY]" ,
"Unknown"
}

Definition at line 25 of file user_lib.cpp.

Referenced by InitDeviceList().

◆ RealDeviceName

CHAR RealDeviceName[MAX_PATH+1]

Definition at line 653 of file user_lib.cpp.

Referenced by UDFGetDeviceName().