lundi 24 mars 2014

C++ DLL Injection: path with special characters


Vote count:

0




I'm trying to solve this situation. I have win32 program, that waiting until specific process is started "Example.exe", then the program inject "my.dll" intro process "Example.exe"


It works fine until the user have program under folder with specific, but allowed characters, for example in my country default folder name is "Nová složka" (New folder)


I tried to use relative path



"//my.dll"
"/my.dll"
"\\my.dll"
"\my.dll"


unsuccessfully... Also I tried different ways to convert string(QString) to char array.


Developed in Qt 5.1.1


Here is code where the program finding path of .dll



QString actualPath(QDir::currentPath() + "/my.dll");
ui->lblDebug->setText(actualPath);
const char* myChar = QString(actualPath.toUtf8()).toStdString().c_str();
QString q = QString::fromStdString(myChar);
ui->lblDebug->setText(q);


Here is the injection part



hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PE32.th32ProcessID);
hModule = (LPVOID)VirtualAllocEx(hProcess, NULL, 512, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(hProcess, hModule, (LPVOID)myChar, 512, NULL);
CreateRemoteThread(hProcess, NULL, NULL, (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle(L"kernel32"), "LoadLibraryA"), hModule, NULL, NULL);
CloseHandle(hProcess);
CloseHandle(hSnapshot);
qDebug() << "INJECT:DONE!";
return true; ExitProcess(0);
break;


Do you have any ideas, thanks?



asked 38 secs ago






Aucun commentaire:

Enregistrer un commentaire