mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:32:56 +00:00
Dmitriy Philippov (shedon@mail.ru): Add test application for move file after reboot function of smss.exe / kernel32.dll
svn path=/trunk/; revision=23536
This commit is contained in:
parent
3be6aa3601
commit
46d49263c2
5 changed files with 223 additions and 0 deletions
193
reactos/base/applications/testsets/smss/movefile/movefile.cpp
Normal file
193
reactos/base/applications/testsets/smss/movefile/movefile.cpp
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS Test applications
|
||||||
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
|
* FILE: base/applications/testsets/smss/movefile.cpp
|
||||||
|
* PURPOSE: Provides testing for the "move file after reboot"
|
||||||
|
* function of smss.exe/kernel32.dll
|
||||||
|
* PROGRAMMERS: Dmitriy Philippov (shedon@mail.ru)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
#include "windows.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include "stdlib.h"
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
|
|
||||||
|
void Usage()
|
||||||
|
{
|
||||||
|
printf(" Usage: smssTest.exe -g|c|s|d \n \
|
||||||
|
g - generate test files \n \
|
||||||
|
c - check files after reboot \n \
|
||||||
|
s - show registry entry \n \
|
||||||
|
d - delete registry value \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int ShowRegValue()
|
||||||
|
{
|
||||||
|
BYTE lpBuff[255];
|
||||||
|
memset(lpBuff, 0, sizeof(lpBuff));
|
||||||
|
|
||||||
|
DWORD lSize = sizeof(lpBuff);
|
||||||
|
HKEY hKey;
|
||||||
|
LONG retValue;
|
||||||
|
// test registry entry
|
||||||
|
retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_QUERY_VALUE, &hKey);
|
||||||
|
if( ERROR_SUCCESS != retValue ) {
|
||||||
|
printf("RegOpenKeyEx err=%ld \n", retValue);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
retValue = RegQueryValueEx(hKey, "PendingFileRenameOperations", NULL, NULL, lpBuff, &lSize);
|
||||||
|
if( ERROR_SUCCESS != retValue ) {
|
||||||
|
printf("RegQueryValueEx err=%ld \n", retValue);
|
||||||
|
lSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("reg data: \n");
|
||||||
|
for(UINT i=0; i<lSize; i++) {
|
||||||
|
printf("%c", lpBuff[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DeleteValue()
|
||||||
|
{
|
||||||
|
HKEY hKey;
|
||||||
|
LONG retValue;
|
||||||
|
// test registry entry
|
||||||
|
retValue = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager", 0, KEY_SET_VALUE, &hKey);
|
||||||
|
if( ERROR_SUCCESS != retValue ) {
|
||||||
|
printf("RegOpenKeyEx err=%ld \n", retValue);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
retValue = RegDeleteValue(hKey, "PendingFileRenameOperations");
|
||||||
|
if( ERROR_SUCCESS != retValue ) {
|
||||||
|
printf("RegDeleteValue err=%ld \n", retValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Generate()
|
||||||
|
{
|
||||||
|
char sBuf[255];
|
||||||
|
DWORD dwSize;
|
||||||
|
HANDLE hFile = NULL;
|
||||||
|
|
||||||
|
char *szxMovedFile = "c:\\testFileShouldBeMoved";
|
||||||
|
char *szxNewMovedFile = "c:\\testFileIsMoved";
|
||||||
|
|
||||||
|
char *szxDeletedFile = "c:\\testFileShouldBeDeleted";
|
||||||
|
|
||||||
|
memset(sBuf, 0xaa, sizeof(sBuf));
|
||||||
|
|
||||||
|
// create the first file for moving
|
||||||
|
hFile = CreateFile(
|
||||||
|
szxMovedFile,
|
||||||
|
FILE_ALL_ACCESS,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
CREATE_ALWAYS,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL);
|
||||||
|
if(NULL == hFile) {
|
||||||
|
printf("Can't create the %s file, err=%ld \n", szxMovedFile, GetLastError());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
|
||||||
|
CloseHandle(hFile);
|
||||||
|
|
||||||
|
// create the second file for removing
|
||||||
|
hFile = CreateFile(
|
||||||
|
szxDeletedFile,
|
||||||
|
FILE_ALL_ACCESS,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
CREATE_ALWAYS,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL);
|
||||||
|
if(NULL == hFile) {
|
||||||
|
printf("Can't create the %s file, err=%ld \n", szxDeletedFile, GetLastError());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
WriteFile(hFile, sBuf, sizeof(sBuf), &dwSize, NULL);
|
||||||
|
CloseHandle(hFile);
|
||||||
|
|
||||||
|
|
||||||
|
BOOL fReturnValue;
|
||||||
|
|
||||||
|
fReturnValue = MoveFileEx(
|
||||||
|
szxDeletedFile,
|
||||||
|
NULL,
|
||||||
|
MOVEFILE_DELAY_UNTIL_REBOOT);
|
||||||
|
if( !fReturnValue ) {
|
||||||
|
printf("Can't move the %s file, err=%ld \n", szxMovedFile, GetLastError());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowRegValue();
|
||||||
|
|
||||||
|
fReturnValue = MoveFileEx(
|
||||||
|
szxMovedFile,
|
||||||
|
szxNewMovedFile,
|
||||||
|
MOVEFILE_DELAY_UNTIL_REBOOT);
|
||||||
|
if( !fReturnValue ) {
|
||||||
|
printf("Can't move the %s file, err=%ld \n", szxMovedFile, GetLastError());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowRegValue();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Check()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _tmain(int argc, _TCHAR* argv[])
|
||||||
|
{
|
||||||
|
if( argc<2 ) {
|
||||||
|
Usage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( 0 == strncmp(argv[1], "-g", 2) )
|
||||||
|
{
|
||||||
|
// generate test files and registry values
|
||||||
|
return Generate();
|
||||||
|
}
|
||||||
|
else if( 0 == strncmp(argv[1], "-c", 2) )
|
||||||
|
{
|
||||||
|
// check generated files
|
||||||
|
return Check();
|
||||||
|
}
|
||||||
|
else if( 0 == strncmp(argv[1], "-s", 2) )
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return ShowRegValue();
|
||||||
|
}
|
||||||
|
else if( 0 == strncmp(argv[1], "-d", 2) )
|
||||||
|
{
|
||||||
|
return DeleteValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Usage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<module name="movefile" type="win32cui" installbase="system32" installname="movefiletest.exe">
|
||||||
|
<include base="movefile">.</include>
|
||||||
|
<define name="__USE_W32API" />
|
||||||
|
<define name="_WIN32_IE">0x0500</define>
|
||||||
|
<define name="_WIN32_WINNT">0x0600</define>
|
||||||
|
<define name="WINVER">0x0600</define>
|
||||||
|
<library>kernel32</library>
|
||||||
|
<library>user32</library>
|
||||||
|
<file>movefile.cpp</file>
|
||||||
|
<file>movefile.rc</file>
|
||||||
|
</module>
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include <windows.h>
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Move File after reboot test\0"
|
||||||
|
#define REACTOS_STR_INTERNAL_NAME "movefiletest\0"
|
||||||
|
#define REACTOS_STR_ORIGINAL_FILENAME "movefiletest.exe\0"
|
||||||
|
#include <reactos/version.rc>
|
||||||
|
|
||||||
|
|
7
reactos/base/applications/testsets/smss/smss.rbuild
Normal file
7
reactos/base/applications/testsets/smss/smss.rbuild
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||||
|
<group>
|
||||||
|
<directory name="movefile">
|
||||||
|
<xi:include href="movefile/movefile.rbuild" />
|
||||||
|
</directory>
|
||||||
|
</group>
|
|
@ -1,6 +1,9 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||||
<group>
|
<group>
|
||||||
|
<directory name="smss">
|
||||||
|
<xi:include href="smss/smss.rbuild" />
|
||||||
|
</directory>
|
||||||
<directory name="user32">
|
<directory name="user32">
|
||||||
<xi:include href="user32/user32.rbuild" />
|
<xi:include href="user32/user32.rbuild" />
|
||||||
</directory>
|
</directory>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue