I forgot how to program in C++, I want my exutable to copy itself to another path. I found a code that do what I want to do but there are conversion error that I don't know how to resolve :
void Victim::replicate()
{
char filename[ MAX_PATH ];
char newLocation[]="C:\\Users\\myUsername\\Desktop\\";
BOOL stats=0;
DWORD size = GetModuleFileNameA( NULL, filename, MAX_PATH );
CopyFile(filename, newLocation, stats);
}
I got an error while using the CopyFile function, It expect LPCWSTR type for filename and newLocation But if I declare those variable as LPCWSTR, the GetModuleFileNameA function will not work anymore.
It seems your project is set to use the
Wversions of the API functions by default. You override that by calling theA(Ansi) version ofGetModuleFileName. Don't - or do, but then you also need to callCopyFileA.Forcing Ansi version usage:
Forcing Wide version usage:
Going with the project default: