Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a$=Space(999) : GetModuleFileName_(0,@a$,999) : appname$=GetFilePart(a$)
  2. WinW=200 : WinH=100
  3.  
  4. ;UsePNGImageDecoder()
  5.  
  6. Global Image0
  7. Global AuthorizedModeDone = #False
  8. Global NewInstall = #False
  9. Global CurrentPassword$ = Reg_GetValue(#HKEY_CURRENT_USER,"Software\!flash","megasecret","")
  10.  
  11. If CurrentPassword$ = ""
  12.   NewInstall = #True
  13. EndIf  
  14.  
  15. Image0 = CatchImage(0, ?Image0)
  16.  
  17. DataSection
  18. Image0:
  19.   IncludeBinary "S:\misc\work\!flash\back.bmp"
  20. EndDataSection
  21.  
  22. Procedure AuthorizedMode()
  23.   FreeGadget(2)
  24.   AuthorizedModeDone = #True
  25.   SetGadgetText(1,"Блокирование флешек:")
  26.   SetGadgetText(3,"Ок")
  27.   BlockStatus$ = Reg_GetValue(#HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Services\USBSTOR","Start","")
  28.   CheckBoxGadget(4,30,35,14,14,"")
  29.   TextGadget(5,45,35,150,14,"Флешки заблокированы")
  30.   SetGadgetColor(5,#PB_Gadget_BackColor,#White)
  31.   If BlockStatus$ = "4"
  32.     SetGadgetState(4,#PB_Checkbox_Checked)
  33.   Else
  34.     SetGadgetState(4,#PB_Checkbox_Unchecked)
  35.   EndIf
  36. EndProcedure
  37.  
  38. If OpenWindow(0,200,200,WinW-1,WinH-1,"!flash",#PB_Window_Invisible|#PB_Window_ScreenCentered|#PB_Window_BorderLess)
  39.   CenterX = WindowX(0)
  40.   CenterY = WindowY(0)
  41.   SetWindowPos_(WindowID(0), 0, 0, 0, 0, 0, #SWP_HIDEWINDOW)
  42.   SetWindowLong_(WindowID(0),#GWL_EXSTYLE,#WS_EX_TOOLWINDOW)
  43.   SetWindowColor(0,#White)
  44.   ImageGadget(6, 0, 0, 30, 100, Image0)
  45.   Icon = ExtractIcon_(WindowID(0), appname$, 0)
  46.   AddSysTrayIcon(1, WindowID(0), Icon)
  47.   SysTrayIconToolTip(1, "!flash")
  48.   If CreatePopupMenu(0)
  49.     MenuItem(1,"!flash")
  50.     DisableMenuItem(0,1,1)
  51.     MenuBar()
  52.     MenuItem(2, "Выйти")
  53.   EndIf
  54.   Repeat
  55.     Event = WaitWindowEvent()
  56.     If Event = #PB_Event_SysTray And EventType() = #PB_EventType_LeftDoubleClick
  57.       regn.i$ = CreateRoundRectRgn_(0,0,200,100,50,50)
  58.       SetWindowRgn_(WindowID(0), regn.i$, #True)
  59.       SetWindowPos_(WindowID(0), 0, CenterX, CenterY, 0, 0, #SWP_SHOWWINDOW)
  60.       ResizeWindow(0,#PB_Ignore,#PB_Ignore,WinW,WinH) : ShowWindow_(WindowID(0),#SW_SHOW)
  61.       StickyWindow(0,1)
  62.       If NewInstall = #True
  63.         TextGadget(1,25,10,150,14,"Введите новый пароль:",#PB_Text_Center)
  64.       Else
  65.         TextGadget(1,25,10,150,14,"Введите пароль:",#PB_Text_Center)
  66.       EndIf  
  67.       StringGadget(2,60,35,80,14,"",#PB_String_Password|#PB_String_BorderLess)
  68.       If NewInstall = #True
  69.         ;ButtonColorGadget(3,50,60,100,30,"Ок",#Black,#White)
  70.         ButtonGadget(3,50,60,100,30,"Ок")
  71.       Else
  72.         ;ButtonColorGadget(3,50,60,100,30,"Отмена",#Black,#White)
  73.         ButtonGadget(3,50,60,100,30,"Отмена")
  74.       EndIf
  75.       AddKeyboardShortcut(0,#PB_Shortcut_Return,150)
  76.       SetGadgetColor(1,#PB_Gadget_BackColor,#White)
  77.       SetActiveWindow(0)
  78.       SetActiveGadget(2)
  79.       BringWindowToTop_(WindowID(0))  
  80.     EndIf
  81.     If EventGadget() = 6
  82.       SendMessage_(WindowID(0),#WM_NCLBUTTONDOWN, #HTCAPTION,0)
  83.     EndIf
  84.     If Event = #PB_Event_SysTray And EventType() = #PB_EventType_RightClick
  85.       DisplayPopupMenu(0, WindowID(0))
  86.     EndIf
  87.     If Event = #PB_Event_Menu And EventMenu() = 2
  88.       Event = #PB_Event_CloseWindow
  89.     EndIf
  90.     If (Event = #PB_Event_Gadget And EventGadget() = 3) Or EventMenu() = 150
  91.       If NewInstall = #True And Len(GetGadgetText(2)) > 1
  92.         NewPassword$ = GetGadgetText(2)
  93.         CurrentPassword$ = MD5Fingerprint(@NewPassword$,StringByteLength(NewPassword$))
  94.         If Reg_KeyExists(#HKEY_CURRENT_USER,"Software\!flash","")
  95.           If Reg_SetValue(#HKEY_CURRENT_USER,"Software\!flash","megasecret",CurrentPassword$,#REG_SZ,"")
  96.             NewInstall = #False
  97.             AuthorizedMode()
  98.           Else
  99.             MessageRequester("Еггог!","Что-то явно пошло не так :(")
  100.           EndIf
  101.         Else
  102.           If Reg_CreateKey(#HKEY_CURRENT_USER,"Software\!flash","") And Reg_SetValue(#HKEY_CURRENT_USER,"Software\!flash","megasecret",CurrentPassword$,#REG_SZ,"")
  103.             NewInstall = #False
  104.             AuthorizedMode()
  105.           Else
  106.             MessageRequester("Еггог!","Что-то явно пошло не так :(")
  107.           EndIf
  108.         EndIf
  109.       Else
  110.         If AuthorizedModeDone = #True
  111.           If GetGadgetState(4) = #PB_Checkbox_Checked
  112.             If Reg_SetValue(#HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Services\USBSTOR","Start","4",#REG_DWORD,"")
  113.               FreeGadget(4)
  114.               FreeGadget(5)
  115.               AuthorizedModeDone = #False
  116.               StickyWindow(0,0)
  117.               ResizeWindow(0,#PB_Ignore,#PB_Ignore,WinW,WinH) : ShowWindow_(WindowID(0),#SW_HIDE)
  118.             Else
  119.               MessageRequester("Еггог!","Что-то явно пошло не так :(")
  120.             EndIf
  121.           Else
  122.             If Reg_SetValue(#HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Services\USBSTOR","Start","3",#REG_DWORD,"")
  123.               FreeGadget(4)
  124.               FreeGadget(5)
  125.               AuthorizedModeDone = #False
  126.               StickyWindow(0,0)
  127.               ResizeWindow(0,#PB_Ignore,#PB_Ignore,WinW,WinH) : ShowWindow_(WindowID(0),#SW_HIDE)
  128.             Else
  129.               MessageRequester("Еггог!","Что-то явно пошло не так :(")
  130.             EndIf
  131.           EndIf
  132.         Else  
  133.           StickyWindow(0,0)
  134.           ResizeWindow(0,#PB_Ignore,#PB_Ignore,WinW,WinH) : ShowWindow_(WindowID(0),#SW_HIDE)
  135.         EndIf
  136.       EndIf    
  137.     EndIf
  138.     If Event = #PB_Event_Gadget And EventGadget() = 2 And EventType() = #PB_EventType_Change
  139.       If NewInstall = #False
  140.         InputPassword$ = GetGadgetText(2)
  141.         If MD5Fingerprint(@InputPassword$,StringByteLength(InputPassword$)) = CurrentPassword$
  142.           AuthorizedMode()
  143.         EndIf
  144.       EndIf
  145.     EndIf
  146.   Until Event=#PB_Event_CloseWindow
  147. EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement