首页
社区
课程
招聘
[分享]一个系统辅助工具源码
发表于: 2010-3-30 16:45 6545

[分享]一个系统辅助工具源码

2010-3-30 16:45
6545
sx-helper 系统全能辅助工具的源码 不意间找到的 这个软件只有8k 使用很方便的
还找了几个同类的软件在压缩包里

代码--作者--舒俊杰
.386

.model flat,stdcall

option casemap:none

include                windows.inc

include                user32.inc

include                gdi32.inc

include                kernel32.inc

include                shell32.inc

include                winmm.inc

include                advapi32.inc

include                masm32.inc



includelib        user32.lib

includelib        kernel32.lib

includelib        shell32.lib

includelib        winmm.lib

includelib        advapi32.lib

includelib        masm32.lib

includelib        gdi32.lib



WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD



.data

state                dd        0

ClassName        db        "LOVEXH",0

AppName                db        "托盘小助手v1.06",0



iconrc                db        'SX',0

menurc                db        'MENU',0



szCaption        db        'SX-Helper',0

szRepeat        db        '你不用开很多次的,已经够啦!',0

szWelcome        db        '程序设计:舒俊杰   QQ:369339353',0

szWebsite        db        'http://www.shuax.com',0

szResc                db        '分辨率设置失败,已经恢复默认设置',0

szExit                db        '你确认退出程序吗?',0

szOpen                db        'set CDAudio door open',0

szClose                db        'set CDAudio door closed',0

szAbout                db        '程序设计:舒俊杰',0dh,0ah

                db        '时间:2009年9月21日',0dh,0ah

                db        '点击确定后将会打开我的网站,您可以自行关闭。',0

szReg                db        'regedit.exe',0

szApp                db        'appwiz.cpl',0

szGpe                db        'gpedit.msc',0

szCmd                db        'cmd.exe',0

szTas                db        'taskmgr.exe',0

szDev                db        'devmgmt.msc',0

szCal                db        'calc.exe',0

SubKey                db        'Control Panel\\Desktop\\WindowMetrics',0

hkcon                db        'Shell Icon Size',0

taskb                db        'TaskbarCreated',0

bn                dd        100

SHUTDOWN_NAME        db "SeShutdownPrivilege",0

.data?

hInstance        dd        ?

note                NOTIFYICONDATA        <>



hMenu                dd        ?

buff                db        ?

hKey                dd        ?

GammaArray        db        3*1256 dup(0)

.code

start:

    invoke GetModuleHandle, NULL

    mov    hInstance,eax

    invoke WinMain, hInstance,NULL,NULL, SW_SHOWDEFAULT

    invoke ExitProcess,eax



ShowContextMenu PROC hWnd:HWND

        LOCAL pt:POINT

        

        invoke GetCursorPos,addr pt

        

        invoke LoadMenu,hInstance,addr menurc

        mov hMenu,eax

        invoke GetSubMenu,hMenu,0

        mov hMenu,eax

        

        invoke SetForegroundWindow,hWnd

        invoke TrackPopupMenu,hMenu,TPM_RIGHTALIGN,pt.x,pt.y,NULL,hWnd,NULL

        invoke PostMessage,hWnd,WM_NULL,0,0        

        ret



ShowContextMenu endp

iconC PROC

        LOCAL Iconw:DWORD

        invoke RegOpenKeyEx,HKEY_CURRENT_USER,addr SubKey, 0, KEY_ALL_ACCESS, addr hKey

        invoke GetSystemMetrics,SM_CXICON

        mov Iconw,eax

        

        invoke dw2a,Iconw - 1,addr buff

        invoke RegSetValueEx,hKey, addr hkcon, 0, REG_SZ, addr buff,sizeof buff

        invoke SendMessage,HWND_BROADCAST, WM_WININICHANGE, 0, 0

        invoke dw2a,Iconw - 1,addr buff

        invoke RegSetValueEx,hKey,addr hkcon, 0, REG_SZ, addr buff,sizeof buff

        invoke SendMessage,HWND_BROADCAST, WM_WININICHANGE, 0, 0

        

        ret



iconC endp

gamma proc BN:UINT

        ;LOCAL index:UINT

        ;LOCAL ArrayValue:UINT

        ;mov index,0

        

        ;.while index<256

        ;        mov ArrayValue,index*(256*BN)/100

        ;        .if ArrayValue > 65535        

        ;                mov ArrayValue,65535

        ;        .endif

        ;        

        ;        push ArrayValue

        ;        pop GammaArray[index]

        ;        

        ;        push ArrayValue

        ;        pop GammaArray[index+256]

        ;        push ArrayValue

        ;        pop GammaArray[index+512]

        ;        inc index

        ;.endw

        ;invoke SetDeviceGammaRamp,GetDC, addr GammaArray

        ret



gamma endp

Mode proc x:DWORD,y:DWORD



        LOCAL lpDevMode:DEVMODE

        mov lpDevMode.dmSize ,sizeof DEVMODE

        mov lpDevMode.dmDriverExtra,0

        mov lpDevMode.dmBitsPerPel,32

        push x

        pop lpDevMode.dmPelsWidth

        push y

        pop lpDevMode.dmPelsHeight

        mov lpDevMode.dmFields,DM_BITSPERPEL or DM_PELSWIDTH

        

        invoke ChangeDisplaySettings,addr lpDevMode,0

        .if eax==DISP_CHANGE_SUCCESSFUL

                invoke ChangeDisplaySettings,addr lpDevMode, CDS_UPDATEREGISTRY

        .else

                invoke ChangeDisplaySettings,NULL,0

                invoke MessageBox,NULL,addr szResc,addr szCaption,MB_OK + MB_ICONWARNING

            .endif

        ret

Mode endp

Shutdown proc op:UINT

        local    @hToken, @hCurrentProcess, @tkp:TOKEN_PRIVILEGES

        invoke    GetCurrentProcess

        mov    @hCurrentProcess,eax

        invoke    OpenProcessToken, @hCurrentProcess,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,addr @hToken

        invoke    LookupPrivilegeValue,NULL,addr SHUTDOWN_NAME,addr @tkp.Privileges[0].Luid

        mov    @tkp.PrivilegeCount,1

        mov    @tkp.Privileges[0].Attributes,SE_PRIVILEGE_ENABLED

        invoke    AdjustTokenPrivileges, @hToken,FALSE,addr @tkp,NULL,NULL,NULL

        .if op==1

                invoke ExitWindowsEx,EWX_SHUTDOWN or EWX_FORCE, 0

        .elseif op==2

                invoke ExitWindowsEx,EWX_REBOOT or EWX_FORCE, 0

        .elseif op==3

                invoke ExitWindowsEx,EWX_LOGOFF or EWX_FORCE, 0

        .elseif op==4

                invoke SetSystemPowerState,0,1

        .elseif op==5

                invoke SetSystemPowerState,1,0

        .endif

        ret

Shutdown    endp

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD

    LOCAL wc:WNDCLASSEX

    LOCAL msg:MSG

    LOCAL hwnd:HWND

    

    invoke FindWindow, NULL, ADDR AppName

        .if eax

                invoke MessageBox,NULL,addr szRepeat,addr szCaption,MB_OK + MB_ICONINFORMATION

                invoke ExitProcess, 0

    .endif

    mov   wc.cbSize,SIZEOF WNDCLASSEX

    mov   wc.style, CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS

    mov   wc.lpfnWndProc, OFFSET WndProc

    mov   wc.cbClsExtra,NULL

    mov   wc.cbWndExtra,NULL

    push  hInst

    pop   wc.hInstance

    mov   wc.hbrBackground,COLOR_APPWORKSPACE

    mov   wc.lpszMenuName,NULL

    mov   wc.lpszClassName,OFFSET ClassName

    invoke LoadIcon,NULL,IDI_APPLICATION

    mov   wc.hIcon,eax

    mov   wc.hIconSm,eax

    invoke LoadCursor,NULL,IDC_ARROW

    mov   wc.hCursor,eax

    invoke RegisterClassEx, addr wc

    invoke CreateWindowEx,WS_EX_TOOLWINDOW,ADDR ClassName,ADDR AppName,WS_POPUP,CW_USEDEFAULT,CW_USEDEFAULT,\

           CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInst,NULL

    mov   hwnd,eax



    .while TRUE

        invoke GetMessage, ADDR msg,NULL,0,0

        .BREAK .IF (!eax)

        invoke TranslateMessage, ADDR msg

        invoke DispatchMessage, ADDR msg

    .endw

    mov eax,msg.wParam

    ret

WinMain endp



WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

    .if uMsg==WM_CREATE

            ;注册热键

            invoke RegisterHotKey,hWnd, 10001, MOD_CONTROL, VK_RIGHT

            invoke RegisterHotKey,hWnd, 10002, MOD_CONTROL, VK_LEFT

            invoke RegisterHotKey,hWnd, 10003, MOD_CONTROL, VK_END

            

            invoke RegisterHotKey,hWnd, 10004, MOD_CONTROL, VK_UP

            invoke RegisterHotKey,hWnd, 10005, MOD_CONTROL, VK_DOWN

            invoke RegisterHotKey,hWnd, 10006, MOD_CONTROL, VK_HOME

            

            invoke RegisterHotKey,hWnd, 10007, MOD_CONTROL, VK_F12

            invoke RegisterHotKey,hWnd, 10008, MOD_SHIFT, VK_END

            

            invoke RegisterHotKey,hWnd, 10021, MOD_SHIFT, VK_INSERT

        ;启动图标

        mov note.cbSize,sizeof NOTIFYICONDATA

        push hWnd

        pop note.hwnd

        mov note.uID,1

        mov note.uFlags,NIF_ICON + NIF_MESSAGE + NIF_TIP

        mov note.uCallbackMessage,WM_USER

        invoke LoadIcon,hInstance,addr iconrc

        mov note.hIcon,eax

        invoke lstrcpy,addr note.szTip,addr szWelcome

        invoke Shell_NotifyIcon,NIM_ADD,addr note

        mov state,1

    .elseif uMsg==WM_DESTROY

            invoke DestroyMenu,hMenu

        push hWnd

        pop note.hwnd

        mov note.uID,1

        invoke Shell_NotifyIcon,NIM_DELETE,addr note

        invoke DestroyMenu,hMenu

        invoke PostQuitMessage,NULL

        

    .elseif uMsg== WM_COMMAND || uMsg==WM_HOTKEY

        ;音量控制    

            .if wParam==10001

                invoke SendMessage,hWnd, 793, 197266, 655360

        .elseif wParam==10002

                invoke SendMessage,hWnd, 793, 197266, 589824

        .elseif wParam==10003

                invoke SendMessage,hWnd, 793, 2100912, 524288

        ;屏幕亮度控制

        .elseif wParam==10004

                inc bn

                inc bn

                invoke gamma,bn

        .elseif wParam==10005

                DEC bn

                DEC bn

                invoke gamma,bn

        .elseif wParam==10006

                invoke gamma,100

        ;显示隐藏图标

        .elseif wParam==10007

                       push hWnd

                pop note.hwnd

                mov note.uID,1

                .if state == 0

                        mov note.uFlags,NIF_ICON + NIF_MESSAGE + NIF_TIP

                        mov note.uCallbackMessage,WM_USER

                        invoke LoadIcon,hInstance,addr iconrc

                        mov note.hIcon,eax

                        invoke lstrcpy,addr note.szTip,addr szWelcome

                        invoke Shell_NotifyIcon,NIM_ADD,addr note

                        mov state,1



                .else

                        invoke Shell_NotifyIcon,NIM_DELETE,addr note

                        mov state,0

                .endif

        ;系统工具

        .elseif wParam==10009

                invoke ShellExecute,0, NULL, addr szReg, NULL, NULL, SW_SHOWNORMAL

        .elseif wParam==10010

                invoke ShellExecute,0, NULL, addr szApp, NULL, NULL, SW_SHOWNORMAL

        .elseif wParam==10011

                invoke ShellExecute,0, NULL, addr szGpe, NULL, NULL, SW_SHOWNORMAL

        .elseif wParam==10012

                invoke ShellExecute,0, NULL, addr szCmd, NULL, NULL, SW_SHOWNORMAL

        .elseif wParam==10013

                invoke ShellExecute,0, NULL, addr szTas, NULL, NULL, SW_SHOWNORMAL

        .elseif wParam==10014

                invoke ShellExecute,0, NULL, addr szDev, NULL, NULL, SW_SHOWNORMAL

        .elseif wParam==10015

                invoke ShellExecute,0, NULL, addr szCal, NULL, NULL, SW_SHOWNORMAL

        ;光驱控制

        .elseif wParam==10016

                invoke mciSendString,addr szOpen, NULL, 0, 0

        .elseif wParam==10017

                invoke mciSendString,addr szClose, NULL, 0, 0

        ;显示桌面

        .elseif wParam==10018

                invoke keybd_event,VK_LWIN, 0, 0, 0

                invoke keybd_event,'D', 0, 0, 0

                invoke keybd_event,VK_LWIN, 0, KEYEVENTF_KEYUP, 0

                invoke keybd_event,'D', 0, KEYEVENTF_KEYUP, 0

        ;打开屏保

        .elseif wParam==10019

                invoke Sleep,200

                invoke SendMessage,HWND_BROADCAST, WM_SYSCOMMAND, SC_SCREENSAVE, 0

        ;重建图标缓存

        .elseif wParam==10020

                invoke iconC

        ;关闭显示器

        .elseif wParam==10021

                invoke Sleep,500

                invoke PostMessage,hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, 2

        ;设置屏幕分辨率

        .elseif wParam==10022

                invoke Mode,1024,768

        .elseif wParam==10023

                invoke Mode,1280,800

        .elseif wParam==10024

                invoke Mode,1440,900

        .elseif wParam==10025

                invoke Mode,1680,1050

        .elseif wParam==10026

                invoke Mode,1366,768

        .elseif wParam==10027

                invoke Mode,800,600

        ;关机、注销、重启、睡眠、休眠

        .elseif wParam==10028

                invoke Shutdown,1

        .elseif wParam==10029

                invoke Shutdown,2

        .elseif wParam==10030

                invoke Shutdown,3

        .elseif wParam==10031

                invoke Shutdown,4

        .elseif wParam==10032

                invoke Shutdown,5

        ;关于,退出

        .elseif wParam==10035

                invoke MessageBox,NULL,addr szAbout,addr szCaption,MB_OK

                invoke ShellExecute,0, NULL, addr szWebsite, NULL, NULL, SW_SHOWMAXIMIZED

        .elseif wParam==10008

                invoke MessageBox,NULL,addr szExit,addr szCaption,MB_YESNO + MB_ICONQUESTION

                .if eax==IDYES

                invoke SendMessage,hWnd, WM_DESTROY, wParam, lParam

                .endif

        .endif

    .elseif uMsg==WM_USER

        .if lParam==WM_LBUTTONDBLCLK

            invoke SendMessage,hWnd, WM_DESTROY, wParam, lParam

        .elseif lParam==WM_RBUTTONDOWN

            invoke ShowContextMenu,hWnd

        .endif

    .else

            invoke RegisterWindowMessage,addr taskb

            .if uMsg == eax

                    invoke SendMessage,hWnd, WM_CREATE, wParam, lParam

            .elseif

                invoke DefWindowProc,hWnd,uMsg,wParam,lParam

        .endif

        ret

    .endif

    xor eax,eax

    ret

WndProc endp



end start


资源文件
1 24 "xp.bin"



SX ICON DISCARDABLE "sx.ico"



MENU MENU

BEGIN

  POPUP "我爱肖虹"

  BEGIN

    POPUP "热键功能(&U)"

    BEGIN

      MENUITEM "加大音量\tCtrl+→",10001

      MENUITEM "减小音量\tCtrl+←",10002

      MENUITEM "静音\tCtrl+End",10003

      MENUITEM SEPARATOR

      MENUITEM "加大亮度\tCtrl+↑",10004,GRAYED

      MENUITEM "减小亮度\tCtrl+↓",10005,GRAYED

      MENUITEM "默认亮度\tCtrl+Home",10006,GRAYED

      MENUITEM SEPARATOR

      MENUITEM "隐藏/显示程序\tCtrl+F12",10007

      MENUITEM "退出程序\tShift+End",10008

    END

    POPUP "系统工具(&T)"

    BEGIN

      MENUITEM "注册表编辑器(&R)",10009

      MENUITEM "添加删除程序",10010

      MENUITEM "组策略编辑器",10011

      MENUITEM "命令提示符",10012

      MENUITEM "任务管理器(&T)",10013

      MENUITEM "设备管理器",10014

      MENUITEM "计算器(&C)",10015

    END

    POPUP "系统控制(&C)"

    BEGIN

      MENUITEM "打开光驱",10016

      MENUITEM "关闭光驱",10017

      MENUITEM SEPARATOR

      MENUITEM "显示桌面",10018

      MENUITEM "启动屏保",10019

      MENUITEM "重建图标缓存",10020

      MENUITEM "关闭显示器\tShift+Insert",10021

      POPUP "分辨率设置(&F)"

      BEGIN

        MENUITEM "1024×768",10022

        MENUITEM "1280×800",10023

        MENUITEM "1440×900",10024

        MENUITEM "1680×1050",10025

        MENUITEM "1366×768",10026

        MENUITEM "800×600",10027

      END

      MENUITEM SEPARATOR

      MENUITEM "关机",10028

      MENUITEM "重启",10029

      MENUITEM "注销",10030

      MENUITEM "睡眠",10031

      MENUITEM "休眠",10032

    END

    MENUITEM SEPARATOR

    POPUP "即将推出"

    BEGIN

      MENUITEM "桌面便签...",10033,GRAYED

      MENUITEM "定时关机...",10034,GRAYED

    END

    MENUITEM SEPARATOR

    MENUITEM "关于",10035

    MENUITEM "退出(&E)",10008

  END

END

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

上传的附件:
收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 216
活跃值: (21)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
顶顶,学习中。
2010-4-22 23:00
0
游客
登录 | 注册 方可回帖
返回
//