Hi guys,
I have problem is that:
I want to kill virus called "Packed.Win32.Krap.ar" and this virus when being activated transfer itself to a random directory and random file name in "C:\Program Files". And this virus hide itself perfectly and no one can see this file even when you put your mouse on the directory the folder looks like it's empty, but the virus in there. And I have programmed a VB.net program to show this virus but it was not worked.
So, I have program in c++ win32 console application and this program get me the list of files in directory using "FindFirstFile & FindNextFile" functions, and this program works well, It gets me the virus name with full path.
So, I decided to make a c++/cli dll class library so I can call this function into the VB.net. But the dll It can't get me the List of files in that directory!!!!!!! why??
This is the code of c++ win32:
int _tmain(int argc, TCHAR *argv[])
{
WIN32_FIND_DATA ffd;
LARGE_INTEGER filesize;
HANDLE hFind = INVALID_HANDLE_VALUE;
DWORD dwError=0;
hFind = FindFirstFile(TEXT("C:\\Program Files\\YSxXeMcr\\*.*"), &ffd);
if (INVALID_HANDLE_VALUE == hFind)
{
DisplayErrorBox(TEXT("FindFirstFile"));
return dwError;
}
do
{
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
filesize.LowPart = ffd.nFileSizeLow;
filesize.HighPart = ffd.nFileSizeHigh;
_tprintf(TEXT(" %s %ld bytes\n"), ffd.cFileName, filesize.QuadPart);
}
else
{
_tprintf(TEXT(" %s <DIR>\n"), ffd.cFileName);
}
}
while (FindNextFile(hFind, &ffd) != 0);
dwError = GetLastError();
if (dwError != ERROR_NO_MORE_FILES)
{
DisplayErrorBox(TEXT("FindFirstFile"));
}
FindClose(hFind);
system("pause");
return dwError;
}
And this is the c++/cli dll code:
String^ ReadFirstFile(String^ Path)
{
WIN32_FIND_DATA FindFileData;
if (Path->Length == 3) Path +="*.*";
else Path += "\\*.*";
char* path = (char*) Marshal::StringToHGlobalAnsi(Path).ToPointer();
hFile = FindFirstFile(path, &FindFileData);
if (hFile == INVALID_HANDLE_VALUE)
{
String^ Error;
LPCTSTR E = GetTheError("FindFirstFile");
Error = gcnew String(reinterpret_cast<const char*>(E));
throw gcnew ReadStreamException(Error);
return "";
}
do
{
if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
String^ FileName;
FileName = gcnew String(reinterpret_cast<const char*>(FindFileData.cFileName ));
Path = Path->Replace("*.*",FileName);
return Path;
}
}
while (FindNextFile(hFile, &FindFileData) != 0);
return "";
}
Oh!, don't wary about the dll code it's just pring me the first file and then I call the FindNextFile.
I hope you understand my question...
And I hope you have answer.