ReactOS  0.4.14-dev-52-g6116262
movefile.cpp File Reference
#include "windows.h"
#include <stdio.h>
#include <tchar.h>
#include "stdlib.h"
#include "string.h"
Include dependency graph for movefile.cpp:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 

Functions

void Usage ()
 
int ShowRegValue ()
 
int DeleteValue ()
 
int Generate ()
 
int Check ()
 
int _tmain (int argc, _TCHAR *argv[])
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 11 of file movefile.cpp.

Function Documentation

◆ _tmain()

int _tmain ( int  argc,
_TCHAR argv[] 
)

Definition at line 201 of file movefile.cpp.

202 {
203  if( argc<2 ) {
204  Usage();
205  return 1;
206  }
207 
208  if( 0 == strncmp(argv[1], "-g", 2) )
209  {
210  // generate test files and registry values
211  return Generate();
212  }
213  else if( 0 == strncmp(argv[1], "-c", 2) )
214  {
215  // check generated files
216  return Check();
217  }
218  else if( 0 == strncmp(argv[1], "-s", 2) )
219  {
220  //
221  return ShowRegValue();
222  }
223  else if( 0 == strncmp(argv[1], "-d", 2) )
224  {
225  return DeleteValue();
226  }
227  else
228  {
229  Usage();
230  return 1;
231  }
232 
233  return 0;
234 }
static int argc
Definition: ServiceArgs.c:12
int ShowRegValue()
Definition: movefile.cpp:28
void Usage()
Definition: movefile.cpp:19
#define argv
Definition: mplay32.c:18
int Check()
Definition: movefile.cpp:196
int DeleteValue()
Definition: movefile.cpp:60
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
int Generate()
Definition: movefile.cpp:81

◆ Check()

int Check ( )

Definition at line 196 of file movefile.cpp.

197 {
198  return 0;
199 }

Referenced by _tmain(), START_TEST(), UITOOLS95_DFC_ButtonCheckRadio(), and UpdateStatus().

◆ DeleteValue()

int DeleteValue ( )

Definition at line 60 of file movefile.cpp.

61 {
62  HKEY hKey;
63  LONG retValue;
64  // test registry entry
65  retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_SET_VALUE, &hKey);
66  if( ERROR_SUCCESS != retValue ) {
67  printf("RegOpenKeyEx err=%ld \n", retValue);
68  return 1;
69  }
70 
71  retValue = RegDeleteValue(hKey, "PendingFileRenameOperations");
72  if( ERROR_SUCCESS != retValue ) {
73  printf("RegDeleteValue err=%ld \n", retValue);
74  }
75 
76  RegCloseKey(hKey);
77 
78  return 0;
79 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define RegDeleteValue
Definition: winreg.h:508
#define RegOpenKeyEx
Definition: winreg.h:520
#define printf
Definition: config.h:203
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by _tmain().

◆ Generate()

int Generate ( )

Definition at line 81 of file movefile.cpp.

82 {
83  char sBuf[255];
84  DWORD dwSize;
85  HANDLE hFile = NULL;
86  BOOL fReturnValue;
87 
88  const char szxReplacedFile[] = "c:\\testFileIsReplaced";
89  const char szxMovedFileWithRepl[] = "c:\\testFileShouldBeMovedW";
90  const char szxMovedFile[] = "c:\\testFileShouldBeMoved";
91  const char szxNewMovedFile[] = "c:\\testFileIsMoved";
92  const char szxDeletedFile[] = "c:\\testFileShouldBeDeleted";
93 
94  memset(sBuf, 0xaa, sizeof(sBuf));
95 
96  // create the first file for moving
97  hFile = CreateFile(
98  szxMovedFile,
100  0,
101  NULL,
104  NULL);
105  if(NULL == hFile) {
106  printf("Can't create the %s file, err=%ld \n", szxMovedFile, GetLastError());
107  return 1;
108  }
109  WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
111 
112  // create the second file for removing
113  hFile = CreateFile(
114  szxDeletedFile,
116  0,
117  NULL,
120  NULL);
121  if(NULL == hFile) {
122  printf("Can't create the %s file, err=%ld \n", szxDeletedFile, GetLastError());
123  return 1;
124  }
125  WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
127 
128  hFile = CreateFile(
129  szxReplacedFile,
131  0,
132  NULL,
135  NULL);
136  if(NULL == hFile) {
137  printf("Can't create the %s file, err=%ld \n", szxReplacedFile, GetLastError());
138  return 1;
139  }
140  WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
142 
143 
144  hFile = CreateFile(
145  szxMovedFileWithRepl,
147  0,
148  NULL,
151  NULL);
152  if(NULL == hFile) {
153  printf("Can't create the %s file, err=%ld \n", szxMovedFileWithRepl, GetLastError());
154  return 1;
155  }
156  WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
158 
159 
160  fReturnValue = MoveFileEx(
161  szxDeletedFile,
162  NULL,
164  if( !fReturnValue ) {
165  printf("Can't move the %s file, err=%ld \n", szxDeletedFile, GetLastError());
166  return 1;
167  }
168 
169  ShowRegValue();
170 
171  fReturnValue = MoveFileEx(
172  szxMovedFile,
173  szxNewMovedFile,
175  if( !fReturnValue ) {
176  printf("Can't move the %s file, err=%ld \n", szxMovedFile, GetLastError());
177  return 1;
178  }
179 
180  ShowRegValue();
181 
182  fReturnValue = MoveFileEx(
183  szxMovedFileWithRepl,
184  szxReplacedFile,
186  if( !fReturnValue ) {
187  printf("Can't move the %s file, err=%ld \n", szxMovedFileWithRepl, GetLastError());
188  return 1;
189  }
190 
191  ShowRegValue();
192 
193  return 0;
194 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
int ShowRegValue()
Definition: movefile.cpp:28
#define CloseHandle
Definition: compat.h:398
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
#define MOVEFILE_REPLACE_EXISTING
Definition: filesup.h:28
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define MoveFileEx
Definition: winbase.h:3695
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define MOVEFILE_DELAY_UNTIL_REBOOT
Definition: winbase.h:381
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define memset(x, y, z)
Definition: compat.h:39
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define printf
Definition: config.h:203

Referenced by _tmain().

◆ ShowRegValue()

int ShowRegValue ( )

Definition at line 28 of file movefile.cpp.

29 {
30  BYTE lpBuff[255];
31  memset(lpBuff, 0, sizeof(lpBuff));
32 
33  DWORD lSize = sizeof(lpBuff);
34  HKEY hKey;
35  LONG retValue;
36  // test registry entry
37  retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_QUERY_VALUE, &hKey);
38  if( ERROR_SUCCESS != retValue ) {
39  printf("RegOpenKeyEx err=%ld \n", retValue);
40  return 1;
41  }
42 
43  retValue = RegQueryValueEx(hKey, "PendingFileRenameOperations", NULL, NULL, lpBuff, &lSize);
44  if( ERROR_SUCCESS != retValue ) {
45  printf("RegQueryValueEx err=%ld \n", retValue);
46  lSize = 0;
47  }
48 
49  printf("reg data: \n");
50  for(UINT i=0; i<lSize; i++) {
51  printf("%c", lpBuff[i]);
52  }
53  printf("\n");
54 
55  RegCloseKey(hKey);
56 
57  return 0;
58 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
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 GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
#define RegOpenKeyEx
Definition: winreg.h:520
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
unsigned int UINT
Definition: ndis.h:50
#define memset(x, y, z)
Definition: compat.h:39
#define printf
Definition: config.h:203
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by _tmain(), and Generate().

◆ Usage()

void Usage ( void  )

Definition at line 19 of file movefile.cpp.

20 {
21  printf(" Usage: smssTest.exe -g|c|s|d \n \
22  g - generate test files \n \
23  c - check files after reboot \n \
24  s - show registry entry \n \
25  d - delete registry value \n");
26 }
#define printf
Definition: config.h:203

Referenced by _tmain().