#include #this is the uninstall program.it reads the epsetup.log file created by #the setup program and deletes all the files listed in it and also the shortcuts. #it creates a file in the designated temp directory holding the path #of the install dir. This file is also named epsetup.log. #it then copies itself to the temp dir ,launches the copied uninst.exe and #exits. #the copied uninst.exe now reads the epsetup.log, finds the original install #dir and deletes the original uninst.exe, the epsetup.log file ,removes the #install dir if possible and exits with a message. #the copied uninst.exe remains on the system in the temp dir.I stopped here #but i suppose one approach #to remove this also is to create a batch file which deletes it on reboot. #the last instruction in this batch file would delete itself. #i think it's possible to acheive this without rebooting with a very #carefully synchronized launch so that the batch file does not try #to delete uninst.exe before it exits. #Please drop me an email for any clarifications,suggestions,comments begin imports #many frequently used functions are here [Kernel32.dll] InitializeCriticalSection EnterCriticalSection LeaveCriticalSection TerminateProcess DeleteFileA GetWindowsDirectoryA RemoveDirectoryA GetCurrentDirectoryA CopyFileA GetTempPathA GetModuleHandleA GetCommandLineA LoadLibraryA ExitProcess GlobalAlloc GlobalSize GlobalFree GlobalReAlloc Sleep CreateFileA ReadFile WriteFile CloseHandle GetFileSize CreateThread CreateProcessA SuspendThread ResumeThread ExitThread TerminateThread WaitForSingleObject [user32.dll] RegisterClassExA CreateWindowExA ShowWindow UpdateWindow DefWindowProcA GetMessageA TranslateMessage DispatchMessageA SendMessageA LoadCursorA LoadIconA LoadMenuA BeginPaint EndPaint DrawTextA GetClientRect PostQuitMessage MessageBoxA SetForegroundWindow SetActiveWindow BringWindowToTop FindWindowA DestroyWindow PostMessageA CreatePopupMenu AppendMenuA SetMenu CreateMenu GetCursorPos TrackPopupMenu SetFocus [gdi32.dll] CreateFontIndirectA Rectangle CreateSolidBrush SelectObject SetBkMode ExtFloodFill CreatePen SetTextColor [comctl32.dll] InitCommonControls [comdlg32.dll] GetOpenFileNameA GetSaveFileNameA [shell32.dll] ShellExecuteA [crtdll.dll] strcmp fopen fclose fgets fputs fgetc fputc feof malloc realloc free fread fwrite fprintf fscanf _itoa memcpy memcmp memmove memset sprintf atoi strcpy strstr strncat end imports #-----------------Constants---------------------------------------------- begin const #many commonly used constants are here SW_HIDE 0 SW_SHOW 5 WS_CHILD 1073741824 WS_VISIBLE 268435456 WS_BORDER 8388608 WS_HSCROLL 1048576 WS_VSCROLL 2097152 WS_CAPTION 12582912 WS_CHILDWINDOW 1073741824 WS_OVERLAPPEDWINDOW 13565952 WS_POPUPWINDOW 2156396544 WS_SYSMENU 524288 WS_CLIENTEDGE 512 WS_MINIMIZEBOX 131072 WS_MAXIMIZEBOX 65536 WM_CREATE 1 WM_COPY 769 WM_CUT 768 WM_PASTE 770 WM_CLOSE 16 WM_COMMAND 273 WM_DESTROY 2 WM_ENABLE 10 WM_GETTEXT 13 WM_GETTEXTLENGTH 14 WM_INITDIALOG 272 WM_INITMENU 278 WM_KEYDOWN 256 WM_KEYUP 257 WM_KILLFOCUS 8 WM_LBUTTONDBLCLK 515 WM_LBUTTONDOWN 513 WM_LBUTTONUP 514 WM_MOVE 3 WM_NOTIFY 78 WM_PAINT 15 WM_ACTIVATE 6 WM_QUIT 18 WM_RBUTTONDBLCLK 518 WM_RBUTTONDOWN 516 WM_RBUTTONUP 517 WM_SETFOCUS 7 WM_SETFONT 48 WM_SETTEXT 12 WM_SIZE 5 WM_TIMER 275 WM_UNDO 772 LB_ADDSTRING 384 LB_RESETCONTENT 388 LB_SELECTSTRING 396 LB_SETTOPINDEX 407 LBS_HASSTRINGS 64 DT_SINGLELINE 32 DT_CENTER 1 DT_VCENTER 4 DT_BOTTOM 8 IDI_APPLICATION 32512 IDC_CROSS 32515 ES_AUTOVSCROLL 64 ES_AUTOHSCROLL 128 ES_MULTILINE 4 ES_WANTRETURN 4096 ES_LEFT 0 ES_NOHIDESEL 256 EN_MSGFILTER 1792 EN_CHANGE 768 ENM_MOUSEEVENTS 131072 ENM_SELCHANGE 524288 ENM_PROTECTED 2097152 ENM_KEYEVENTS 65536 ENM_UPDATE 2 ENM_SCROLL 4 ENM_CHANGE 1 EM_STREAMIN 1097 EM_STREAMOUT 1098 EM_GETFIRSTVISIBLELINE 206 EM_FINDTEXTEX 1103 EM_LINEFROMCHAR 201 EM_LINESCROLL 182 EM_SETLIMITTEXT 197 EM_SETEVENTMASK 1093 MF_ENABLED 0 MF_BYPOSITION 1024 MF_SEPARATOR 2048 MF_STRING 0 MF_POPUP 16 MF_DISABLED 2 MF_BYCOMMAND 0 GENERIC_READ 2147483648 GENERIC_WRITE 1073741824 OPEN_EXISTING 3 FILE_ATTRIBUTE_NORMAL 128 GMEM_ZEROINIT 64 SFF_SELECTION 32768 SFF_PLAINRTF 16384 SF_TEXT 1 SF_RTF 2 CB_ADDSTRING 323 CB_DELETESTRING 324 CB_GETCOUNT 326 CB_GETLBTEXT 328 CB_GETLBTEXTLEN 329 CB_INSERTSTRING 330 CB_RESETCONTENT 331 CB_GETCURSEL 327 CB_SETCURSEL 334 CB_FINDSTRINGEXACT 344 CBS_DROPDOWN 2 CBS_DROPDOWNLIST 3 CBS_HASSTRINGS 512 CBS_SORT 256 CBS_SIMPLE 1 CBN_DROPDOWN 7 CBN_SELENDOK 9 CBN_SELCHANGE 1 CBN_CLOSEUP 8 OFN_EXPLORER 524288 OFN_HIDEREADONLY 4 OFN_LONGNAMES 2097152 OFN_PATHMUSTEXIST 2048 IDNO 7 MB_ICONASTERISK 64 end const #-----------------Data Section------------------------------------------- #some useful predefined variables are here begin data dword hwndMain 0 string Class Window dword hInstance 0 string ClassName WinClass string AppName Windows Template ! string MenuName Menu string btn button string text Edit string combo combobox string list listbox string mess1 Do you want to uninstall EP ? Really remove it from your system ? string mess2 EP has been successfully uninstalled ! string mess3 EP has been successfully uninstalled ! However there were some files in your install directory which were not part of the install. These files and this directory will therefore have to removed manually . Bye ! string mess4 The uninstall log file epsetup.log is missing . Uninstall cannot proceed ! string lnkpath1 \start menu\programs\empowered programmer 1.0\empowered programmer 1.0.lnk string lnkpath2 \start menu\programs\empowered programmer 1.0\ep help.lnk string lnkpath3 \start menu\programs\empowered programmer 1.0\ep uninstall.lnk string lnkdir \start menu\programs\empowered programmer 1.0 string uninstExe uninst.exe string suninst \uninst.exe string logfile epsetup.log string slash \ string recfile rec.dat sequence tmpdir 256 sequence curdir 256 sequence windir 256 string colon : dword quit 0 string read r string write w string readb rb string writeb wb string WindowCaption Basic Windows Template ! string ab EmPowered Programmer Uninstall string ab1 MyApp Version 1.0 string ab2 by .... string ab3 ---------------------------------------------------- sequence buffer 256 sequence buf 48 sequence listbuf 48 sequence icobuf 24 sequence pt 8 sequence blank 1 dword CommandLine 0 dword hmem 0 sequence wndclass 16 sequence msg 28 sequence ibuf 32 dword mem 0 dword start 0 dword dataend 4294967295 end data #------------------------------------------------------------------------- begin code #the real code begin here ! proc tolower dword addr dword n 0 push ebp mov ebp esp add esp -48 edi=addr eax=1 while eax <> 0 eax=0 al=[edi] if eax = 0 jmp tl_exit endif if eax > 64 if eax < 91 add eax 32 [edi]=al endif endif inc edi endw tl_exit: leave ret 4 endp #------------------------------------------------------------------------ proc strlen dword q push ebp mov ebp esp mov edi [q] mov eax 0 mov ecx 0 cld search_loop: inc ecx scasb jne search_loop dec ecx mov eax ecx leave ret 4 endp #------------------------------------------------------------------------ proc strcat dword s1 dword s2 dword len1 0 dword len2 0 dword addr 0 dword len 0 push ebp mov ebp esp add esp -48 invoke strlen s1 mov len1 eax invoke strlen s2 mov len2 eax add eax len1 inc eax len = eax invoke malloc eax invoke memset eax 0 len mov addr eax mov edi eax mov ecx len1 mov esi s1 rep_movsb mov ecx len2 mov esi s2 rep_movsb mov eax addr leave ret 8 endp #------------------------------------------------------------------------ proc WndProc dword hwnd dword msg dword wparam dword lparam dword fn 0 dword hdc 4 sequence ps 64 sequence rect 16 dword ordata 0 dword n 0 dword m 0 dword st1 0 dword st 0 push ebp mov ebp esp add esp -180 cmp msg {WM_CREATE} je wmcreate cmp msg {WM_PAINT} je wmpaint cmp msg {WM_COMMAND} je wmcommand cmp msg {WM_DESTROY} jne default push 0 call PostQuitMessage jmp exit wmcreate: invoke GetWindowsDirectoryA windir 256 invoke GetCurrentDirectoryA 256 curdir invoke GetTempPathA 256 tmpdir invoke GetTempPathA 256 buffer invoke tolower buffer invoke tolower curdir invoke strncat curdir slash invoke strcmp curdir buffer if eax <> 0 invoke MessageBoxA hwnd mess1 ab 4 if eax={IDNO} invoke SendMessageA hwnd {WM_DESTROY} 0 0 jmp exit endif st=strcat curdir logfile fn = fopen st read if fn=0 invoke MessageBoxA hwnd mess4 ab 0 invoke SendMessageA hwnd {WM_DESTROY} 0 0 jmp exit endif fnloop: invoke memset buffer 0 256 invoke fgets buffer 256 fn invoke feof fn cmp eax 0 jne closefname edi=buffer eax=1 while eax <> 0 eax=0 al=[edi] if eax <> 0 inc edi endif endw dec edi eax=0 [edi]=0 dec edi [edi]=0 invoke DeleteFileA buffer jmp fnloop closefname: invoke fclose fn invoke free st st=strcat curdir logfile invoke DeleteFileA st invoke free st st=strcat curdir recfile invoke DeleteFileA st invoke free st st=strcat windir lnkpath1 invoke DeleteFileA st invoke free st st=strcat windir lnkpath2 invoke DeleteFileA st invoke free st st=strcat windir lnkpath3 invoke DeleteFileA st invoke free st st=strcat windir lnkdir invoke RemoveDirectoryA st invoke free st st=strcat tmpdir logfile fn = fopen st write invoke fputs curdir fn invoke fclose fn invoke free st st=strcat curdir uninstExe st1=strcat tmpdir uninstExe invoke CopyFileA st st1 0 invoke ShellExecuteA 0 0 st1 0 tmpdir 1 invoke free st invoke free st1 invoke ExitProcess 0 jmp exit endif if eax =0 invoke memset buffer 0 256 st=strcat curdir logfile fn = fopen st read invoke fgets buffer 256 fn invoke fclose fn st1=strcat buffer uninstExe invoke DeleteFileA st1 invoke DeleteFileA st invoke RemoveDirectoryA buffer if eax=1 invoke MessageBoxA hwnd mess2 ab 0 endif if eax=0 invoke MessageBoxA hwnd mess3 ab 0 endif invoke ExitProcess 0 jmp exit endif jmp exit wmpaint: lea eax ps invoke BeginPaint hwnd eax mov hdc eax lea eax ps invoke EndPaint hwnd eax jmp exit wmcommand: default: invoke DefWindowProcA hwnd msg wparam lparam leave ret 16 exit: xor eax eax leave ret 16 endp #------------------------------------------------------------------------ proc WinMain dword hinst dword previnst dword comline dword cmdshow sequence wc 48 dword ordata 0 dword len 0 dword topmenu 0 dword dropmenu 0 dword sepmenu 0 push ebp mov ebp esp add esp -80 [wc]= 48 [wc+4] =3 [wc+8]= WndProc [wc+12]= 0 [wc+16] =0 eax =hInstance [wc+20]= eax push 1 push hInstance call LoadIconA [wc+24]= eax [wc+44]= eax push {IDC_CROSS} push 0 call LoadCursorA [wc+28] =eax [wc+32]= 16 [wc+36]= 0 [wc+40]= ClassName lea eax wc invoke RegisterClassExA eax or eax {WS_SYSMENU} ordata=eax invoke CreateWindowExA {WS_CLIENTEDGE} ClassName WindowCaption ordata 0 0 0 0 0 0 hInstance 0 hwndMain= eax #this is old style before the advent of invoke push 0 #hide push hwndMain call ShowWindow push hwndMain call UpdateWindow MsgLoop: invoke GetMessageA msg 0 0 0 cmp eax 0 je exitprocess invoke TranslateMessage msg invoke DispatchMessageA msg jmp MsgLoop exitprocess: mov eax [msg+8] leave ret 16 endp #------------------------------------------------------------------------ EntryPoint #this is old style before the advent of invoke push 0 call GetModuleHandleA mov hInstance eax call GetCommandLineA mov CommandLine eax eax=[eax] invoke WinMain hInstance 0 CommandLine 10 push eax call ExitProcess end code #-----------------Resources--------------------------------------- begin resources icon emp.ico end resources