Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;---------------------------------------------
  2. ; uptime simple launcher
  3. ; Copyright (C) addhaloka
  4. ;---------------------------------------------
  5.  
  6. format PE GUI 5.0
  7. entry start
  8.  
  9. include 'win32w.inc'
  10.  
  11. SWP_NOOWNERZORDER       equ 200h
  12. HORIZONTAL_SIZE         equ 242
  13. VERTICAL_SIZE           equ 38
  14. BACKGROUND_RED          equ 40h
  15. FOREGROUND_RED          equ 4h
  16. FOREGROUND_BLUE         equ 1h
  17. FOREGROUND_GREEN        equ 2h
  18. FOREGROUND_INTENSITY    equ 8h
  19.  
  20. section '.text' code readable executable
  21. align 10h
  22. data import
  23.     library kernel32,'KERNEL32.DLL',\
  24.             user32,'USER32.DLL',\
  25.             shell32,'SHELL32.DLL'
  26.     include 'api/kernel32.inc'
  27.     include 'api/user32.inc'
  28.     include 'api/shell32.inc'
  29. end data
  30. align 10h
  31. sznoerr     du  'uptime.exe not found!',0Dh,0Ah,'Please check location',0Dh,0Ah,'of launch!',0
  32. szvarerr    du  'Unable to get %comspec% variable!',0Dh,0Ah,'Further work is impossible, bye :|',0
  33. szrunerr    du  'Unable to create process cmd.exe!',0Dh,0Ah,'Further work is impossible, bye :|',0
  34. exe32       du  'uptime.exe',0
  35. wndclass    du  'ConsoleWindowClass',0
  36. wndtitle    du  'uptime',0
  37. param       du  '" /c "@echo off & cls & (uptime -s) & echo. & (uptime -p) & echo. & pause >NUL"',0
  38. comspec     du  '%comspec%',0
  39. szquote     du  22h,0
  40. align 10h
  41.  
  42. nothing_error:
  43.     invoke  MessageBox,0,sznoerr,0,MB_ICONERROR
  44.     jmp     loc_exit
  45.  
  46. cmdvar_error:
  47.     invoke  MessageBox,0,szvarerr,0,MB_ICONERROR
  48.     jmp     loc_exit
  49.  
  50. running_error:
  51.     invoke  MessageBox,0,szrunerr,0,MB_ICONERROR
  52.     jmp     loc_exit
  53.  
  54. proc existW ucFileName:DWORD
  55.     local   ucwfd:WIN32_FIND_DATAW
  56.     lea     eax,[ucwfd]
  57.     invoke  FindFirstFileW,[ucFileName],eax
  58.     cmp     eax,-1
  59.     je      @F
  60.     invoke  FindClose,eax
  61.     dec     eax
  62.     @@:
  63.     inc     eax
  64.     ret
  65. endp
  66.  
  67. start:
  68.     invoke  GetModuleFileName,0,curdir,MAX_PATH*2
  69.     invoke  lstrlen,curdir
  70.     lea     edi,[eax*2+curdir]
  71.     @@:
  72.     cmp     word[edi],5Ch
  73.     je      @F
  74.     dec     edi
  75.     jmp     @B
  76.     @@:
  77.     mov     word[edi+2],0
  78.     invoke  SetCurrentDirectory,curdir
  79.     stdcall existW,exe32
  80.     test    eax,eax
  81.     je      nothing_error
  82.  
  83.     invoke  ExpandEnvironmentStrings,comspec,cmdexe,MAX_PATH*2
  84.     test    eax,eax
  85.     je      cmdvar_error
  86.  
  87.     invoke  lstrcpy,buffer,szquote
  88.     invoke  lstrcat,buffer,cmdexe
  89.     invoke  lstrcat,buffer,param
  90.  
  91.     mov     [sinfo.cb],sizeof.STARTUPINFO
  92.     mov     [sinfo.lpTitle],wndtitle
  93.     mov     dword[sinfo.dwFlags], STARTF_USEFILLATTRIBUTE or STARTF_USECOUNTCHARS or STARTF_USEPOSITION or STARTF_USESIZE
  94.     mov     dword[sinfo.dwXSize],HORIZONTAL_SIZE
  95.     mov     dword[sinfo.dwYSize],VERTICAL_SIZE
  96.     mov     dword[sinfo.dwXCountChars],30
  97.     mov     dword[sinfo.dwYCountChars],3
  98.     mov     dword[sinfo.dwFillAttribute],BACKGROUND_RED or FOREGROUND_RED or FOREGROUND_GREEN or FOREGROUND_BLUE or FOREGROUND_INTENSITY
  99.     invoke  GetDesktopWindow
  100.     invoke  GetWindowRect,eax,rct
  101.     test    eax,eax
  102.     je      @F
  103.     invoke  GetSystemMetrics,SM_CXFULLSCREEN
  104.     test    eax,eax
  105.     je      @F
  106.     mov     ecx,rct.right
  107.     sub     ecx,rct.left-HORIZONTAL_SIZE
  108.     sub     eax,ecx
  109.     shr     eax,1
  110.     mov     [sinfo.dwX],eax
  111.     invoke  GetSystemMetrics,SM_CYFULLSCREEN
  112.     test    eax,eax
  113.     je      @F
  114.     mov     ecx,rct.bottom
  115.     sub     ecx,rct.top-VERTICAL_SIZE
  116.     sub     eax,ecx
  117.     shr     eax,1
  118.     mov     [sinfo.dwY],eax
  119.     @@:
  120.     invoke  ShellExecute,0,0,0,0,0,0
  121.     invoke  CreateProcess,cmdexe,buffer,0,0,FALSE,0,0,curdir,sinfo,pinfo
  122.     test    eax,eax
  123.     je      running_error
  124.     invoke  WaitForInputIdle,[pinfo.hProcess],-1
  125.     @@:
  126.     invoke  FindWindow,wndclass,wndtitle
  127.     test    eax,eax
  128.     je      @B
  129.     mov     [hwnd],eax
  130.     invoke  SetWindowPos,eax,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE or SWP_NOMOVE or SWP_NOOWNERZORDER
  131.     invoke  SetForegroundWindow,[hwnd]
  132.     mov     esi,5
  133.     @@:
  134.     invoke  Sleep,3000
  135.     invoke  GetExitCodeProcess,[pinfo.hProcess],excode
  136.     cmp     [excode],STILL_ACTIVE
  137.     jne     @F
  138.     dec     esi
  139.     jne     @B
  140.     jmp     loc_close
  141.     @@:
  142.     invoke  CloseHandle,[pinfo.hProcess]
  143.     jmp     loc_exit
  144.     loc_close:
  145.     invoke  CloseHandle,[pinfo.hProcess]
  146.     invoke  PostMessage,[hwnd],WM_KEYDOWN,VK_SPACE,0
  147.  
  148.     loc_exit:
  149.     invoke  ExitProcess,0
  150.  
  151. section '.data' readable writeable
  152. hwnd        dd  ?
  153. excode      dd  ?
  154. buffer      du  1024 dup(?)
  155. curdir      du  MAX_PATH dup(?)
  156. cmdexe      du  MAX_PATH dup(?)
  157. rct         RECT
  158. sinfo       STARTUPINFO
  159. pinfo       PROCESS_INFORMATION
  160.  
  161. section '.rsrc' resource data readable
  162.  
  163.     directory RT_ICON,icons,\
  164.         RT_GROUP_ICON,group_icons,\
  165.         RT_VERSION,versions
  166.  
  167.     resource icons,\
  168.         1,409h,icon_data1,\
  169.         2,409h,icon_data2,\
  170.         3,409h,icon_data3,\
  171.         4,409h,icon_data4
  172.  
  173.     resource group_icons,\
  174.         100,409h,main_icon
  175.     resource versions,\
  176.         1,409h,version
  177.  
  178.     icon main_icon,\
  179.         icon_data1,'res/48x48.ico',\
  180.         icon_data2,'res/32x32.ico',\
  181.         icon_data3,'res/24x24.ico',\
  182.         icon_data4,'res/16x16.ico'
  183.  
  184.     versioninfo version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,409h,4B0h,\
  185.         'CompanyName','addhaloka',\
  186.         'FileDescription',<'PCL',27h,'s uptime launcher'>,\
  187.         'LegalCopyright',<0A9h,' 2017. No rights reserved.'>,\
  188.         'FileVersion','1.0.0.0'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement