
![]() |
Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
|
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.219.81.99] |
![]() |
|
Сообщ.
#1
,
|
|
|
собсно на rsdn появился интерестный метод, без bat файла и варианта с перезагрузкой
http://rsdn.ru/article/baseserv/QnADelExe.xml |
Сообщ.
#2
,
|
|
|
Demo_S, дык один из этих вариантов (с асм-вставкой) есть на sources.ru =). а ты их проверял?
|
Сообщ.
#3
,
|
|
|
Может я корявый, но у меня на ХР не работает...
![]() |
Сообщ.
#4
,
|
|
|
Цитата SimBiOd @ 27.12.04, 23:50 ...но у меня на ХР не работает... У меня тоже... ![]() |
Сообщ.
#5
,
|
|
|
Люди, а это что:
http://www.sources.ru/cpp/faqs/96.htm ?? |
Сообщ.
#6
,
|
|
|
Ни один не работает =(
|
Сообщ.
#7
,
|
|
|
![]() ![]() int main(int argc, char *argv[]) { char buf[MAX_PATH]; HMODULE module; module = GetModuleHandle(0); GetModuleFileName(module, buf, MAX_PATH); CloseHandle((HANDLE)4); __asm { lea eax, buf push 0 push 0 push eax push ExitProcess push module push DeleteFile push UnmapViewOfFile ret } return 0; } этот работает на 2000 великолепно |
Сообщ.
#8
,
|
|
|
Цитата feliks @ этот работает на 2000 великолепно А в XP Sp2 - нет... ![]() |
Сообщ.
#9
,
|
|
|
Я делал как описано в http://www.codeguru.com/Cpp/W-P/win32/article.php/c4533/
Срабатывало в 2000 / Xp очень стабильно. |
Сообщ.
#10
,
|
|
|
Цитата Срабатывало в 2000 / Xp очень стабильно. "Очень стабильно" - это как? Т.е. всегда срабатывало или срабатывало в 90% случаев? |
Сообщ.
#11
,
|
|
|
2 p_kolya.
Срабатывало 100%, причем прога была коммерческая и её "тестили" под разную винду. Кстати, этот вариант, описанный http://www.codeguru.com/Cpp/W-P/win32/article.php/c4533/ я встречал где-то, но под авторством Джеффри Рихтера. Ему я немного доверяю :-) |
Сообщ.
#12
,
|
|
|
А как удалить dll из самой себя? да еще и неизвестно, подгружена она или нет...
|
Сообщ.
#13
,
|
|
|
мой вариант - удаление с использованием wsh. похож на метод с батом но не то
![]() ![]() ![]() #ifndef _DEBUG # define section ".cqwerty" # pragma comment(linker, "/section:"section", ERW /IGNORE:4078") # pragma comment(linker, "/merge:.rdata="section) # pragma comment(linker, "/merge:.idata="section) # pragma comment(linker, "/merge:.data="section) # pragma comment(linker, "/merge:.text="section) # pragma comment(linker, "/merge:.CRT="section) # pragma comment(linker, "/FILEALIGN:0x200") # pragma comment(linker, "/ENTRY:entrypoint") # pragma check_stack(off) #endif // _DEBUG #define INSTALL_SEH(seh_interrupt) \ __asm call install_seh \ __asm mov esp, [esp+8] \ __asm jmp seh_interrupt \ __asm install_seh: \ __asm push dword ptr fs:[0] \ __asm mov dword ptr fs:[0], esp #define RESTORE_SEH(seh_interrupt) \ __asm seh_interrupt: nop; \ ExitProcess((UINT)-1) #define fopen_new(fname) CreateFile(fname, GENERIC_READ|GENERIC_WRITE, \ FILE_SHARE_READ|FILE_SHARE_WRITE, 0, \ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0) #define strlen lstrlen #define strcat lstrcat #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <shellapi.h> int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) { char fname[MAX_PATH] = {0}, scriptname[MAX_PATH] = {0}, dir[MAX_PATH] = {0}; const char script[] = "try {\n" "var fso, f, script, fname = \"%s\";\n" "fso = new ActiveXObject(\"Scripting.FileSystemObject\");\n" "f = fso.GetFile(fname)\n" "while (fso.FileExists(fname))\n" "\tf.Delete();\n" "script = fso.GetFile(\"%s\");\n" "script.Delete();\n" "} finally {}\n"; char buf[8192] = {0}; GetModuleFileName(NULL, fname, MAX_PATH); for (int i=strlen(fname)-1; i>0 && fname[i]!='\\'; i--) ; i++; GetTempFileName(".", "js", GetTickCount()^0x12345678, scriptname); strcat(scriptname, ".js"); wsprintf(buf, script, (char *)&fname[i], (char *)&scriptname[2]); HANDLE f = fopen_new(scriptname); if (f==INVALID_HANDLE_VALUE) return 1; DWORD write = 0; WriteFile(f, (LPCVOID)&buf[0], strlen(buf), &write, NULL); CloseHandle(f); SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); GetCurrentDirectory(MAX_PATH, dir); ShellExecute(NULL, "open", scriptname, NULL, dir, SW_HIDE); return 0; } #ifndef _DEBUG VOID APIENTRY entrypoint(VOID) { INSTALL_SEH(seh_int); ExitProcess((UINT)WinMain(GetModuleHandle(NULL), 0, GetCommandLine(), SW_SHOWDEFAULT)); RESTORE_SEH(seh_int); } #endif // _DEBUG |
Сообщ.
#14
,
|
|
|
В bat-файле кодировка иная, поэтому русские буквы шелл не распознает.
Выход: ![]() ![]() // //BOOL CharToOem( // LPCTSTR lpszSrc, // LPSTR lpszDst //); // char m_word[14]; CharToOem("Русские буквы", m_word); |
Сообщ.
#15
,
|
|
|
а кто мне скажет, почему именно
![]() ![]() CloseHandle((HANDLE)4); ??? ![]() ![]() Почему именно 4? У меня на 2003 серваке этот закрытие дескриптора вызывает исключение. Типа неверный описатель! ![]() ![]() |