void check_path(string path) {
cout <<
"check_path: "
<<path<<
" , result: "
<< PathFileExistsA(path.c_str()) << endl;
}
int
main() {
char buf[MAX_PATH];
GetModuleFileName(NULL, buf, ARRAYSIZE(buf));
string cur_path
=
buf;
cout <<
"cur_path: "
<< cur_path << endl;
check_path(cur_path);
HMODULE base
=
GetModuleHandle(
"mov2.exe"
);
cout <<
"base: "
<< base << endl;
SECURITY_ATTRIBUTES sec
=
{
0
};
BOOL
ret
=
CreateDirectory(
"C:\\Users\\root\\AppData\\Local\\Temp\\1234567"
, &sec);
cout << ret << endl;
ret
=
CreateDirectory(
"C:\\Users\\root\\AppData\\Local\\Temp\\1234567\\....\\"
, &sec);
cout << ret << endl;
ret
=
MoveFile(cur_path.c_str(),
"C:\\Users\\root\\AppData\\Local\\Temp\\1234567\\....\\Temp"
);
cout << ret << endl;
ret
=
MoveFile(
"C:\\Users\\root\\AppData\\Local\\Temp\\1234567\\....\\", "
C:\\Users\\root\\AppData\\Local\\Temp\\
1234567
\\Temp");
cout << ret << endl;
cout <<
"------------check path 1 -----------"
<< endl;
GetModuleFileName(NULL, buf, ARRAYSIZE(buf));
cur_path
=
buf;
cout <<
"cur_path: "
<< cur_path << endl;
check_path(cur_path);
cout <<
"------------check path 2 -----------"
<< endl;
GetModuleFileNameEx(GetCurrentProcess(), NULL, buf, ARRAYSIZE(buf));
cur_path
=
buf;
cout <<
"cur_path: "
<< cur_path << endl;
check_path(cur_path);
cout <<
"------------check path 3 -----------"
<< endl;
char buf3[
1024
]
=
{
0
};
SIZE_T size
=
1024
;
NtQueryVirtualMemory(GetCurrentProcess(), base,
2
, buf3, size, &size);
UNICODE_STRING
*
us_str
=
(UNICODE_STRING
*
)buf3;
wcout << L
"cur_path: "
<< us_str
-
>
Buffer
<< endl;
return
0
;
}