#Include <ColorPicker.au3> #Include <WinAPI.au3> ;Opt('MustDeclareVars', 1) ;$Picker1, $Picker2, $Picker3, $Picker4, $Picker5, $Picker6, $Picker7, $Picker8, $Picker9, $Picker10, $Picker11, $Picker12, $Picker13, $Picker14, $Picker15, $Picker16, $hForm, $Msg, $re Global $Label, $Data, $hInstance, $hCursor $hForm = GUICreate('Color Picker', 650, 490,20,22) $re=GUICtrlCreateButton ("R", 623,2,22,22) GUICtrlSetTip(-1, "Перезапуск программки"&@CRLF&"после редактирования") GUICtrlCreateTab (0,2, 650,488) ; размер вкладки GUICtrlCreateTabitem ("Цвет") ; имя вкладки GUICtrlCreateGroup("Палитра", 15, 35, 150, 310) $OpenPal = GUICtrlCreateButton ("Открыть палитру", 30,190,120,25) $SavePal = GUICtrlCreateButton ("Сохранить палитру", 30,220,120,25) $ReadEXE= GUICtrlCreateButton ("Прочитать из EXE", 30,250,120,25) $SaveEXE = GUICtrlCreateButton ("Записать в EXE", 30,280,120,25) $ReadBMP = GUICtrlCreateButton ("Прочитать из BMP", 30,310,120,25) ; Load cursor $hInstance = _WinAPI_LoadLibrary(@SystemDir & '\mspaint.exe') $hCursor = DllCall('user32.dll', 'ptr', 'LoadCursor', 'ptr', $hInstance, 'dword', 1204) $hCursor = $hCursor[0] _WinAPI_FreeLibrary($hInstance) ; Create Picker1 with custom cursor $x=0 For $d = 1 to 4 For $i = 1 to 4 Assign('Picker'&$i+$x, _GUIColorPicker_Create('', $i*30, $d*30+30, 28, 28, '', BitOR($CP_FLAG_DEFAULT, $CP_FLAG_CHOOSERBUTTON), 0, -1, -1, $hCursor, 'Simple Text')) Next $x+=4 Next ; Free cursor DllCall('user32.dll', 'int', 'DestroyCursor', 'ptr', $hCursor) ; Create custom (4 x 5) color palette Dim $aPalette[20] = _ [0xFFFFFF, 0x000000, 0xC0C0C0, 0x808080, _ 0xFF0000, 0x800000, 0xFFFF00, 0x808000, _ 0x00FF00, 0x008000, 0x00FFFF, 0x008080, _ 0x0000FF, 0x000080, 0xFF00FF, 0x800080, _ 0xC0DCC0, 0xA6CAF0, 0xFFFBF0, 0xA0A0A4] GUICtrlCreateTabitem ("") ; конец вкладок GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg ; Color Picker sends the message that the color is selected Case - 3 ExitLoop Case $ReadEXE $file_open = FileOpenDialog("Открыть файл ntoskrnl.exe", @ScriptDir & "", "ntoskrnl.exe (*.exe)", 1 + 4 ) If @error Then ContinueLoop $file = FileOpen($file_open, 16) If $file = -1 Then MsgBox(0, "Ошибка", "Невозможно открыть файл.") ContinueLoop EndIf $sTmp = FileRead($file) FileClose($file) $krnl=StringRegExpReplace($file_open, "(^.*)\\(.*)$", '\2') $ofset='' Switch $krnl ; Color Picker sends the message that the color is selected Case $krnl='ntoskrnl.exe' $ofset=480901 Case $krnl='ntkrnlmp.exe' $ofset=498693 Case Else $ofset=480901 EndSwitch For $i = 1 to 16 _GUIColorPicker_SetColor(Eval('Picker'&$i), BinaryMid($sTmp, $i*4+$ofset, 3)) Next Case $SaveEXE $file_save = FileOpenDialog( "Сохранить палитру в ntoskrnl.exe", @ScriptDir & "", "ntoskrnl.exe (*.exe)", 24) If @error Then ContinueLoop $size=FileGetSize ( $file_save ) If FileGetSize ( $file_save )>'3000000' or FileGetSize ( $file_save )<'1000000' Then MsgBox(0, "Ошибка", "Файл не не соответствует размеру.") ContinueLoop EndIf $file = FileOpen($file_save, 16) If $file = -1 Then MsgBox(0, "Ошибка", "Невозможно открыть файл.") ContinueLoop EndIf $sTmp = FileRead($file) FileClose($file) $krnl=StringRegExp($file_save, "(^.*)\\(.*)\.(.*)$", 3) $ofset='' Switch $krnl ; Color Picker sends the message that the color is selected Case $krnl[1]='ntoskrnl' $ofset=480901 Case $krnl='ntkrnlmp' $ofset=498693 Case Else $ofset=480901 EndSwitch $pal='' For $i = 1 to 16 $ColorTmp= _GUIColorPicker_GetColor(Eval('Picker'&$i)) $pal&= BinaryToString(BinaryMid($ColorTmp, 1, 3)) &BinaryToString(BinaryMid('0x00', 1)) Next $file = FileOpen($krnl[0]&'\'&$krnl[1]&'_NEW.'&$krnl[2], 18) If $file = -1 Then MsgBox(0, "Ошибка", "Невозможно открыть файл.") ContinueLoop EndIf FileWrite($file, BinaryToString(BinaryMid($sTmp, 1, $ofset-3))&$pal& BinaryToString(BinaryMid($sTmp, $ofset+64))) FileClose($file) Case $SavePal $file_save = FileSaveDialog( "Сохранить палитру", @ScriptDir & "", "Файл палитры (*.pal)", 24) If @error Then ContinueLoop If StringRight($file_save, 4 )<>'.pal' Then $file_save&='.pal' $file = FileOpen($file_save, 18) If $file = -1 Then MsgBox(0, "Ошибка", "Невозможно открыть файл.") ContinueLoop EndIf $pal='' For $i = 1 to 16 $ColorTmp= _GUIColorPicker_GetColor(Eval('Picker'&$i)) $pal&= BinaryToString(BinaryMid($ColorTmp, 3, 1)&BinaryMid($ColorTmp, 2, 1)&BinaryMid($ColorTmp, 1, 1)) &BinaryToString(BinaryMid('0x00', 1)) Next $pal = BinaryToString(BinaryMid('0x524946465000000050414C20646174614400000000031000', 1))&$pal FileWrite($file, $pal) FileClose($file) Case $OpenPal $file_open = FileOpenDialog("Открыть файл палитры", @ScriptDir & "", "Файл палитры (*.pal)", 1 + 4 ) If @error Then ContinueLoop $file = FileOpen($file_open, 16) If $file = -1 Then MsgBox(0, "Ошибка", "Невозможно открыть файл.") ContinueLoop EndIf $sTmp = FileRead($file) FileClose($file) ;$sTmp1 = BinaryToString(BinaryMid($sTmp, 24, 3)) For $i = 1 to 16 _GUIColorPicker_SetColor(Eval('Picker'&$i), BinaryMid($sTmp, $i*4+23, 1)&BinaryMid($sTmp, $i*4+22, 1)&BinaryMid($sTmp,$i*4+21, 1)) Next Case $re _re() ; Case $Picker1, $Picker2, $Picker3, $Picker4, $Picker5, $Picker6, $Picker7, $Picker8, $Picker9, $Picker10, $Picker11, $Picker12, $Picker13, $Picker14, $Picker15, $Picker16 EndSwitch WEnd Func _re() Local $sAutoIt_File = @TempDir & "\~Au3_ScriptRestart_TempFile.au3" Local $sRunLine, $sScript_Content, $hFile $sRunLine = @ScriptFullPath If Not @Compiled Then $sRunLine = @AutoItExe & ' /AutoIt3ExecuteScript ""' & $sRunLine & '""' If $CmdLine[0] > 0 Then $sRunLine &= ' ' & $CmdLineRaw $sScript_Content &= '#NoTrayIcon' & @CRLF & _ 'While ProcessExists(' & @AutoItPID & ')' & @CRLF & _ ' Sleep(10)' & @CRLF & _ 'WEnd' & @CRLF & _ 'Run("' & $sRunLine & '")' & @CRLF & _ 'FileDelete(@ScriptFullPath)' & @CRLF $hFile = FileOpen($sAutoIt_File, 2) FileWrite($hFile, $sScript_Content) FileClose($hFile) Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sAutoIt_File & '"', @ScriptDir, @SW_HIDE) Sleep(1000) Exit EndFunc ;==>_re |