попробовал примеры из статьи.
сработал только первый.
ассемблерный код на XPPro под VC.Net 2003 выдает exception на CloseHandle((HANDLE)4);
Здравствуйте, Leonid Troyanovsky, Вы писали:
LT> Alex Fedotov как-то приводил здесь ссылку на комментарий Gary Nebbet насчет XP.
здесь
Здравствуйте, Leonid Troyanovsky, Вы писали:
LT>> Alex Fedotov как-то приводил здесь ссылку на комментарий Gary Nebbet насчет XP.
LT>здесь
чтоб уж в одном месте:
От:Gary Nebbett (gary.nebbett@openlink.org)
Тема:Re: How to erase a running program's executable file?
Группы новостей:microsoft.public.win32.programmer.kernel
Дата:2002-01-19 06:53:14 PST
Hello Luc,
Unfortunately, this does not work under Windows XP. The kernel previously kept a handle reference to the section object for the main image, but under Windows XP this was changed to a pointer reference (which cannot easily be released from user mode).
My current best solution is to package the final stage of a deinstallation in a DLL callable from Rundll32 (i.e. a DLL that exports function(s) with suitable signatures). The kernel only keeps a reference to the main image section object (and not to DLL section objects), so the DLL can be deleted.
If the DLL was named deinstall.dll, it could be invoked by the command:
Rundll32 deinstall,Cleanup arg1 arg2 arg3
Gary
#include <windows.h>
#pragma comment(linker, "-export:CleanupA=_CleanupA@16")
extern "C"
void CALLBACK CleanupA(HWND, HINSTANCE, PSTR, int)
{
static MEMORY_BASIC_INFORMATION mbi;
VirtualQuery(&mbi, &mbi, sizeof mbi);
PVOID module = mbi.AllocationBase;
CHAR buf[MAX_PATH];
GetModuleFileName(HMODULE(module), buf, sizeof buf);
__asm {
lea eax, buf
push 0
push 0
push eax
push ExitProcess
push module
push DeleteFile
push FreeLibrary
ret
}
}
--------------------------------------------------------------------------------
Здравствуйте, Кодт, Вы писали:
К>Здравствуйте, Peter G Sakhno, Вы писали:
PGS>>ассемблерный код на XPPro под VC.Net 2003 выдает exception на CloseHandle((HANDLE)4);
К>И на Win2000 sp4 тоже.
Так и должно быть. В НТ хэндл секции образа действительно был первым в таблице, но начиная с 2к он "заменен" указателем на секцию, который теперь лежит в EPROCESS.
... << RSDN@Home 1.1.4 beta 7 rev. 447>>