;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 判断游戏进程是否存在
; 返回值:
; eax = TRUE,存在
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IsExistGameProcess proc uses edx esi edi ecx
local _exitCde: DWORD
invoke GetExitCodeProcess, g_ZTProcess, addr _exitCde
test eax, eax
jz _process_not_exist
cmp _exitCde,STILL_ACTIVE
jne _process_not_exist
mov eax, TRUE
ret
_process_not_exist:
xor eax, eax
ret
IsExistGameProcess endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 枚举窗口
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EnumWindowProc proc hWnd: DWORD, lParam: DWORD
local _buffer[255]: byte
local _pid: DWORD
mov _pid, NULL
invoke GetWindowText, hWnd, addr _buffer,255
test eax, eax
jz _next_window
; invoke IsWindowVisible, hWnd
; test eax, eax
; jz _next_window
invoke GetWindowThreadProcessId, hWnd, addr _pid
mov eax, _pid
cmp eax, g_ZTCurPID
jne _next_window
push hWnd
pop g_ZTCurWnd
mov eax, FALSE
ret
_next_window:
mov eax, TRUE
ret
EnumWindowProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 显示托盘图标信息 timer过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ShowTrayTimerProc proc hWnd: DWORD, uMsg: DWORD, idEvent: DWORD, dwTimer: DWORD
LOCAL _buf[255]: byte
pushad
invoke IsDlgButtonChecked, g_MainWnd, IDC_CHECK_CLOSE_TRAYINFO
cmp eax, BST_CHECKED
je _exit_timer_proc
invoke RtlZeroMemory, addr _buf, 255
invoke GetWindowLong, g_MainWnd, GWL_STYLE
and eax, WS_MINIMIZE
JNZ _show_notifyicon
and eax, WS_VISIBLE
JZ _show_notifyicon
jmp _exit_timer_proc
_show_notifyicon:
mov g_stNIF.dwInfoFlags, NIIF_INFO
mov g_stNIF.uTimeout, 3000
invoke lstrcpy, addr g_stNIF.szTip, addr g_SelfName
;'%s', 0DH, 0AH, '经验:%ld/%ld', 0DH, 0AH, '生命:%ld/%ld', 0DH, 0AH, '法力:%ld/%ld', 0DH, 0AH,'位置:%s', 0DH,0AH '坐标:(%ld,%ld)',0
invoke wsprintf, addr _buf, addr g_ShowTrayInfo, \
addr g_SelfName, DWORD ptr g_SelfCurExp, DWORD ptr g_SelfMaxExp, \
g_SelfCurLife, g_SelfMaxLife, g_SelfCurMagic, g_SelfMaxMagic, \
addr g_SelfMapName, g_SelfPosX, g_SelfPosY, g_ExpSpeed, g_ExpUpdateTimeI, \
g_ExpUpdateTimeF, addr g_ObjectName
invoke lstrcpy, addr g_stNIF.szInfo, addr _buf
;invoke ShowWindow, g_MainWnd, SW_HIDE
.if lpShell_NotifyIcon != NULL
invoke lpShell_NotifyIcon, NIM_MODIFY, addr g_stNIF
.endif
_exit_timer_proc:
popad
ret
ShowTrayTimerProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 自动捡起垃圾过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PickupTimerProc proc hWnd: DWORD, uMsg: DWORD, idEvent: DWORD, dwTimer: DWORD
pushad
cmp g_AutoPickupState, TRUE
jne _exit_pickup_time_proc
invoke GetForegroundWindow
cmp eax, g_ZTCurWnd
jne _exit_pickup_time_proc
invoke PostMessage, g_ZTCurWnd, WM_KEYDOWN, 0C0H, 0
invoke Sleep, 100
invoke PostMessage, g_ZTCurWnd, WM_KEYUP, 0C0H, 0
_exit_pickup_time_proc:
popad
ret
PickupTimerProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 窗口过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DialogProc proc uses ebx edi esi hWnd: DWORD, wMsg: DWORD, wParam: DWORD, lParam: DWORD
local _stPS:PAINTSTRUCT
local _stPT:POINT
local _curExp: DWORD, _maxExp: DWORD
mov eax,wMsg
; 窗体刷新
;********************************************************************
.if eax == WM_PAINT
invoke BeginPaint, hWnd, addr _stPS
invoke CreateBarGround, IDC_STATIC_LIFE_BAR
invoke DrawBar, g_SelfCurLife, g_SelfMaxLife, IDC_STATIC_LIFE_BAR, BMP_LIFE
invoke CreateBarGround, IDC_STATIC_MAGIC_BAR
invoke DrawBar, g_SelfCurMagic, g_SelfMaxMagic, IDC_STATIC_MAGIC_BAR, BMP_MAGIC
mov eax, DWORD ptr g_SelfCurExp
mov _curExp, eax
mov eax, DWORD ptr g_SelfMaxExp
mov _maxExp, eax
invoke CreateBarGround, IDC_STATIC_EXP_BAR
invoke DrawBar, _curExp, _maxExp, IDC_STATIC_EXP_BAR, BMP_EXP
invoke EndPaint, hWnd, addr _stPS
; 按钮菜单等相关操作
;********************************************************************
.elseif eax == WM_COMMAND
mov eax, wParam
; 启动按钮
;********************************************************************
.if ax == IDC_BUTTON_APPLY
.if g_HelpStop
; 创建信息获取线程
;********************************************************************
invoke InitEventQueue, offset g_EvtQueue
mov g_SkillAssoilState, 00000000H
mov g_HelpStop, FALSE
invoke CreateThread, NULL, 0, addr ShowInfoThreadProc, NULL, NULL, NULL
.if eax
invoke CloseHandle, eax
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke SetWindowText, eax, _T('停止(&S)')
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_SEARCH
invoke EnableWindow, eax, FALSE
invoke CreateThread, NULL, 0, addr HelpThreadProc, NULL, NULL, NULL
.if eax
invoke CloseHandle, eax
.endif
invoke CreateThread, NULL, 0, addr EventThreadProc, NULL, NULL, NULL
.if eax
invoke CloseHandle, eax
.endif
invoke SetTimer, g_MainWnd, IDI_PICKUP_TIME, 3000, addr PickupTimerProc
.else
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke EnableWindow, eax, FALSE
.endif
.else
mov g_HelpStop, TRUE
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke SetWindowText, eax, _T('启动(&P)')
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_SEARCH
invoke EnableWindow, eax, TRUE
.endif
; 退出按钮
;********************************************************************
.elseif ax == IDC_BUTTON_EXIT
jmp _close_main
; 隐藏游戏复选框
;********************************************************************
.elseif ax == IDC_CHECK_HIDE_GAME_WINDOW
_show_or_hide_game:
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_HIDE_GAME_WINDOW
.if eax == BST_CHECKED
invoke IsWindowVisible, g_ZTCurWnd
.if eax
invoke ShowWindow, g_ZTCurWnd, SW_HIDE
invoke CheckMenuRadioItem, g_PopupMenu, ID_POPUP_ITEM_SHOW_GAME,\
ID_POPUP_ITEM_HIDE_GAME, ID_POPUP_ITEM_HIDE_GAME, MF_BYCOMMAND
.endif
.elseif eax == BST_UNCHECKED
invoke IsWindowVisible, g_ZTCurWnd
.if ! eax
invoke ShowWindow, g_ZTCurWnd, SW_SHOW
invoke CheckMenuRadioItem, g_PopupMenu, ID_POPUP_ITEM_SHOW_GAME,\
ID_POPUP_ITEM_HIDE_GAME, ID_POPUP_ITEM_SHOW_GAME, MF_BYCOMMAND
.endif
.endif
; 仙挂机辅助复选框
;********************************************************************
.elseif ax == IDC_CHECK_XIAN_HELPER
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_XIAN_HELPER
.if eax == BST_UNCHECKED
mov g_SSAssoiled, FALSE
mov g_ZSAssoiled, FALSE
mov g_SS_sTime, 0
mov g_ZS_sTime, 0
.endif
; 本窗体最前复选框
;********************************************************************
.elseif ax == IDC_CHECK_SELF_SETTOP
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_SELF_SETTOP
.if eax == BST_CHECKED
invoke SetWindowPos, hWnd, HWND_TOPMOST, 0, 0, 0, 0, \
SWP_NOMOVE or SWP_NOSIZE
.elseif eax == BST_UNCHECKED
invoke SetWindowPos, hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, \
SWP_NOMOVE or SWP_NOSIZE
.endif
; 自动释放技能复选框
;********************************************************************
.elseif ax == IDC_CHECK_AUTO_SKILL_1
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_AUTO_SKILL_1
.if eax == BST_UNCHECKED
mov g_Skill_Interval_1, 0
mov g_Skill_Assoil_1, FALSE
invoke SendDlgItemMessage, g_MainWnd, IDC_STATIC_AUTO_SKILL_TIME_1, \
WM_SETTEXT, 0, _T( "0")
.endif
.elseif ax == IDC_CHECK_AUTO_SKILL_2
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_AUTO_SKILL_2
.if eax == BST_UNCHECKED
mov g_Skill_Interval_2, 0
mov g_Skill_Assoil_2, FALSE
invoke SendDlgItemMessage, g_MainWnd, IDC_STATIC_AUTO_SKILL_TIME_2, \
WM_SETTEXT, 0, _T( "0")
.endif
.elseif ax == IDC_CHECK_AUTO_SKILL_3
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_AUTO_SKILL_3
.if eax == BST_UNCHECKED
mov g_Skill_Interval_3, 0
mov g_Skill_Assoil_3, FALSE
invoke SendDlgItemMessage, g_MainWnd, IDC_STATIC_AUTO_SKILL_TIME_3, \
WM_SETTEXT, 0, _T( "0")
.endif
.elseif ax == IDC_CHECK_AUTO_SKILL_4
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_AUTO_SKILL_4
.if eax == BST_UNCHECKED
mov g_Skill_Interval_4, 0
mov g_Skill_Assoil_4, FALSE
invoke SendDlgItemMessage, g_MainWnd, IDC_STATIC_AUTO_SKILL_TIME_4, \
WM_SETTEXT, 0, _T( "0")
.endif
; ; 关闭托盘信息显示复选框
; ;********************************************************************
; .elseif ax == IDC_CHECK_CLOSE_TRAYINFO
; invoke IsDlgButtonChecked, hWnd, IDC_CHECK_CLOSE_TRAYINFO
; .if eax == BST_CHECKED
; .if g_Timer
; invoke KillTimer, g_MainWnd, IDI_SHOWTRAYINFO_TIME
; mov g_Timer, 0
; .endif
; .endif
; 显示主窗体弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_SHOW_MAIN
invoke SendMessage, hWnd, WM_SIZE, SIZE_RESTORED, 0
; 显示游戏窗体弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_SHOW_GAME
invoke SendDlgItemMessage, hWnd, IDC_CHECK_HIDE_GAME_WINDOW, \
BM_SETCHECK, BST_UNCHECKED, 0
jmp _show_or_hide_game
; 隐藏游戏窗体弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_HIDE_GAME
invoke SendDlgItemMessage, hWnd, IDC_CHECK_HIDE_GAME_WINDOW, \
BM_SETCHECK, BST_CHECKED, 0
jmp _show_or_hide_game
; 自动捡取垃圾弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_AUTO_PICKUP
invoke GetMenuState, g_PopupMenu, ID_POPUP_ITEM_AUTO_PICKUP, \
MF_BYCOMMAND
.if eax == MF_UNCHECKED
mov g_AutoPickupState, TRUE
mov eax, MF_CHECKED
.else
mov g_AutoPickupState, FALSE
mov eax, MF_UNCHECKED
.endif
invoke CheckMenuItem, g_PopupMenu, ID_POPUP_ITEM_AUTO_PICKUP, eax
; 退出本工具弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_EXIT_APP
jmp _close_main
.endif
; 托盘图标
;********************************************************************
.elseif eax == WM_SHELLNOTIFY
.if lParam == WM_LBUTTONDBLCLK
invoke SendMessage, hWnd, WM_SIZE, SIZE_RESTORED, 0
.elseif lParam == WM_RBUTTONDOWN
invoke GetCursorPos, addr _stPT
invoke TrackPopupMenu, g_PopupMenu, TPM_RIGHTALIGN, _stPT.x, _stPT.y, NULL, hWnd, NULL
.endif
; 窗体形态发生改变
;********************************************************************
.elseif eax == WM_SIZE
.if wParam == SIZE_MINIMIZED
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_SYS_NOTIFY
.if eax == BST_CHECKED
mov g_stNIF.dwInfoFlags, NIIF_WARNING
mov g_stNIF.uTimeout, 0BB8H
invoke lstrcpy, addr g_stNIF.szTip, addr g_SelfName
;invoke lstrcpy, addr g_stNIF.szInfo, _T('我现在在这里了!')
invoke ShowWindow, hWnd, SW_HIDE
.if lpShell_NotifyIcon != NULL
invoke lpShell_NotifyIcon, NIM_ADD, addr g_stNIF
.endif
; invoke SetTimer,hWnd, IDI_SHOWTRAYINFO_TIME, 10000, addr ShowTrayTimerProc
; mov g_Timer, eax
.endif
.elseif wParam == SIZE_RESTORED
invoke ShowWindow, hWnd, SW_RESTORE
.if lpShell_NotifyIcon != NULL
invoke lpShell_NotifyIcon, NIM_DELETE, addr g_stNIF
.endif
.if g_Timer
; invoke KillTimer, g_MainWnd, IDI_SHOWTRAYINFO_TIME
; mov g_Timer, 0
.endif
.endif
; 辅助工具初始化
;********************************************************************
.elseif eax == WM_INITDIALOG
push hWnd
pop g_MainWnd
mov g_AutoPickupState, FALSE
invoke CreatePopupMenu
mov g_PopupMenu, eax
invoke AppendMenu, g_PopupMenu, MF_STRING or MF_DEFAULT,ID_POPUP_ITEM_SHOW_MAIN, addr g_PITEM_SM
invoke AppendMenu, g_PopupMenu, MF_SEPARATOR, 0, NULL
invoke AppendMenu, g_PopupMenu, MF_STRING, ID_POPUP_ITEM_SHOW_GAME, addr g_PITEM_SG
invoke AppendMenu, g_PopupMenu, MF_STRING, ID_POPUP_ITEM_HIDE_GAME, addr g_PITEM_HG
invoke AppendMenu, g_PopupMenu, MF_SEPARATOR, 0, NULL
invoke AppendMenu, g_PopupMenu, MF_STRING, ID_POPUP_ITEM_AUTO_PICKUP, addr g_PITEM_AP
invoke AppendMenu, g_PopupMenu, MF_SEPARATOR, 0, NULL
invoke AppendMenu, g_PopupMenu, MF_STRING, ID_POPUP_ITEM_EXIT_APP, addr g_PITEM_EA
; 提升进程本身权限
;********************************************************************
invoke _EnablePrivilege, offset mySE_DEBUG_NAME, TRUE
;托盘
;********************************************************************
invoke LoadLibrary, _T('shell32.dll')
.if eax
mov g_lpShellNotifyDll, eax
invoke GetProcAddress, g_lpShellNotifyDll, \
_T('Shell_NotifyIcon')
mov lpShell_NotifyIcon, eax
.endif
invoke LoadLibrary, _T('MyGetKeyState.dll')
.if eax
mov g_lpInstallApiHookDll, eax
invoke GetProcAddress, g_lpInstallApiHookDll, \
_T('InstallMyKeyMouseApiHook')
mov lpInstallApiHook, eax
invoke GetProcAddress, g_lpInstallApiHookDll, \
_T('SetKeyData')
mov lpSetKeyData, eax
.endif
invoke RtlZeroMemory, addr g_stNIF, sizeof NEWNOTIFYICONDATA
mov g_stNIF.cbSize, sizeof NEWNOTIFYICONDATA
push hWnd
pop g_stNIF.hWnd
;mov g_stNIF.uID, IDI_TRAY
mov g_stNIF.uFlags, NIF_ICON + NIF_MESSAGE + NIF_TIP + NIF_INFO
mov g_stNIF.uCallbackMessage, WM_SHELLNOTIFY
invoke LoadIcon, g_InstanceHandle, ICO_MAIN
mov g_stNIF.hIcon, eax
mov g_stNIF.dwInfoFlags, NIIF_WARNING
invoke lstrcpy, addr g_stNIF.szInfoTitle, _T('Journey Helper')
;invoke lpShell_NotifyIcon, NIM_ADD, addr g_stNIF
; 创建状态栏
;********************************************************************
call CreateStatusBar
call ReSize
; 初始化快捷键列表
;********************************************************************
call InitKeyList
; 窗体是否最前
;********************************************************************
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_SELF_SETTOP
.if eax == BST_CHECKED
invoke SetWindowPos, hWnd, HWND_TOPMOST, 0, 0, 0, 0, \
SWP_NOMOVE or SWP_NOSIZE
.elseif eax == BST_UNCHECKED
invoke SetWindowPos, hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, \
SWP_NOMOVE or SWP_NOSIZE
.endif
; 设置标题栏图标
;********************************************************************
invoke LoadIcon, g_InstanceHandle, ICO_MAIN
invoke SendMessage, hWnd, WM_SETICON, ICON_BIG, eax
; 搜索进程
;********************************************************************
invoke SearchGameProcess, addr g_ZTProcessName, addr g_PidFilter
.if g_ZTCurPID != 0
; 如果找到了进程,则对其进行操作
;********************************************************************
invoke OpenProcess, PROCESS_QUERY_INFORMATION or PROCESS_VM_READ or \
PROCESS_TERMINATE, FALSE, g_ZTCurPID
test eax, eax
jz _error_ret
mov g_ZTProcess, eax
; 从基地址获取相关地址
;********************************************************************
call GetSelfAddr
.if ! eax
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke EnableWindow, eax, FALSE
jz _error_ret
.endif
call GetObjectAddr
.if ! eax
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke EnableWindow, eax, FALSE
jz _error_ret
.endif
; 置映射文件
;********************************************************************
push esi
mov eax, sizeof GAME_PROCESS_INFO
mul g_IndexOfMapFile
mov esi, g_MapFileMemoryAddr
add esi, eax
assume esi: ptr GAME_PROCESS_INFO
push g_ZTCurPID
pop [ esi].PID
mov [ esi].IsRunning, TRUE
assume esi:nothing
pop esi
;********************************************************************
; 查找游戏窗口
;********************************************************************
invoke EnumWindows, addr EnumWindowProc, NULL
.if g_ZTCurWnd == 0
invoke GetDlgItem, hWnd, IDC_CHECK_HIDE_GAME_WINDOW
invoke EnableWindow, eax, FALSE
invoke EnableMenuItem, g_PopupMenu, ID_POPUP_ITEM_SHOW_GAME, FALSE
invoke EnableMenuItem, g_PopupMenu, ID_POPUP_ITEM_HIDE_GAME, FALSE
.else
invoke CheckMenuRadioItem, g_PopupMenu, ID_POPUP_ITEM_SHOW_GAME,\
ID_POPUP_ITEM_HIDE_GAME, ID_POPUP_ITEM_SHOW_GAME, MF_BYCOMMAND
.endif
invoke lpInstallApiHook, TRUE, g_ZTCurPID
.else
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke EnableWindow, eax, FALSE
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_SEARCH
invoke EnableWindow, eax, FALSE
.endif
; 载入设置
;********************************************************************
call LoadOption
; 初始化代码段
;********************************************************************
invoke InitializeCriticalSection, addr g_stCS
; 初始化队列
;********************************************************************
invoke InitEventQueue, offset g_EvtQueue
; 创建事件执行互斥体
;********************************************************************
mov g_hMutex, NULL
invoke CreateMutex,NULL, FALSE, _T( "EVENT_EXECUTE_MUTEX")
mov g_hMutex, eax
invoke GetLastError
.if eax != ERROR_SUCCESS
.if eax != ERROR_ALREADY_EXISTS
invoke SendMessage, hWnd, WM_CLOSE, TRUE, 0
.endif
.endif
; 窗体关闭
;********************************************************************
.elseif eax == WM_CLOSE
cmp wParam, TRUE
je _close_main
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_SYS_NOTIFY
.if eax == BST_CHECKED
invoke SendMessage, hWnd, WM_SIZE, SIZE_MINIMIZED, 0
.else
_close_main:
mov g_HelpStop, TRUE
call SaveOption
invoke IsWindowVisible, g_ZTCurWnd
.if ! eax
invoke ShowWindow, g_ZTCurWnd, SW_SHOW
.endif
.if lpShell_NotifyIcon
invoke lpShell_NotifyIcon, NIM_DELETE, addr g_stNIF
.endif
.if g_lpShellNotifyDll
invoke FreeLibrary, g_lpShellNotifyDll
.endif
.if lpInstallApiHook
invoke lpInstallApiHook, FALSE, g_ZTCurPID
.endif
.if g_lpInstallApiHookDll
invoke FreeLibrary, g_lpInstallApiHookDll
.endif
;清映射文件中的标志
;********************************************************************
push esi
mov eax, sizeof GAME_PROCESS_INFO
mul g_IndexOfMapFile
mov esi, g_MapFileMemoryAddr
add esi, eax
assume esi: ptr GAME_PROCESS_INFO
mov [ esi].PID, 0
;invoke MemSet, addr [esi].FairyName, NULL, 32
mov [ esi].IsRunning, FALSE
assume esi:nothing
pop esi
invoke DeleteCriticalSection, addr g_stCS
invoke DestroyMenu, g_PopupMenu
.if g_hMutex != NULL
invoke ReleaseMutex, g_hMutex
invoke CloseHandle, g_hMutex
.endif
invoke EndDialog, hWnd, NULL
.endif
.else
_error_ret:
xor eax, eax
ret
.endif
mov eax, TRUE
ret
DialogProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 初始化GAME_PROCESS_INFO
; 返回值:
; exa=0 失败
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
InitGPIMap proc uses edi esi edx
;是否存在映射文件GAME_PROCESS_INFO
invoke OpenFileMapping, FILE_MAP_READ or FILE_MAP_WRITE, 0, addr g_GPIMapFile
mov g_GPIHandle, eax
test eax, eax
jnz _return_initGPI
;否,创建映射文件
invoke CreateFileMapping, -1, NULL, PAGE_READWRITE, 0, \
GPI_MAPFILE_SIZE, addr g_GPIMapFile
test eax, eax
jz _close_GPIMapping
mov g_GPIHandle, eax
ret
_close_GPIMapping:
call CloseGPI
xor eax, eax
_return_initGPI:
ret
InitGPIMap endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 读取GAME_PROCESS_INFO
; 返回值:
; 无
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ReadGPI proc uses edi esi edx
invoke MapViewOfFile, g_GPIHandle, FILE_MAP_READ or FILE_MAP_WRITE, 0, 0, 0
test eax, eax
jz _read_GPIError
mov g_MapFileMemoryAddr, eax
;读取映射文件内容
mov ecx, MAX_GAME_PROCESS_INFO
push esi
mov esi, g_MapFileMemoryAddr
mov edi, offset g_PidFilter
assume esi: ptr GAME_PROCESS_INFO
_read_GPI_loop:
mov eax, [ esi].PID
push eax
.if eax == 0 && g_IndexOfMapFile == 0FFFFFFFFH
mov eax, MAX_GAME_PROCESS_INFO
sub eax, ecx
mov g_IndexOfMapFile, eax
.endif
pop eax
mov [ edi], eax
add esi, sizeof GAME_PROCESS_INFO
add edi, 4
loop _read_GPI_loop
assume esi:nothing
pop esi
xor eax, eax
ret
_read_GPIError:
call CloseGPI
xor eax, eax
ret
ReadGPI endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 关闭GAME_PROCESS_INFO
; 返回值:
; 无
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CloseGPI proc uses edi esi edx
;关闭映射文件
cmp g_GPIHandle, NULL
je _return_close_GPI
;查询当前是否仍有辅助程序在使用映射文件
mov ecx, MAX_GAME_PROCESS_INFO
mov esi, g_MapFileMemoryAddr
assume esi: ptr GAME_PROCESS_INFO
_query_GPI:
mov eax, [ esi].IsRunning
mov g_IsRunning, eax
cmp eax, TRUE ; 是否还有其他辅助程序在使用此内存,仍在使用 不关闭
je @F
add esi, sizeof GAME_PROCESS_INFO
loop _query_GPI
assume esi:nothing
invoke CloseHandle, g_GPIHandle
mov g_GPIHandle, NULL
jmp _return_close_GPI
@@:
assume esi:nothing
_return_close_GPI:
xor eax, eax
ret
CloseGPI endp
;程序入口
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
START:
invoke InitCommonControls
invoke GetModuleHandle,NULL
mov g_InstanceHandle, eax
call InitGPIMap
test eax, eax
jz _exit_process
call ReadGPI
invoke DialogBoxParam,g_InstanceHandle,DLG_MAIN,NULL, offset DialogProc,NULL
_exit_process:
call CloseGPI
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end START
; 判断游戏进程是否存在
; 返回值:
; eax = TRUE,存在
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IsExistGameProcess proc uses edx esi edi ecx
local _exitCde: DWORD
invoke GetExitCodeProcess, g_ZTProcess, addr _exitCde
test eax, eax
jz _process_not_exist
cmp _exitCde,STILL_ACTIVE
jne _process_not_exist
mov eax, TRUE
ret
_process_not_exist:
xor eax, eax
ret
IsExistGameProcess endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 枚举窗口
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EnumWindowProc proc hWnd: DWORD, lParam: DWORD
local _buffer[255]: byte
local _pid: DWORD
mov _pid, NULL
invoke GetWindowText, hWnd, addr _buffer,255
test eax, eax
jz _next_window
; invoke IsWindowVisible, hWnd
; test eax, eax
; jz _next_window
invoke GetWindowThreadProcessId, hWnd, addr _pid
mov eax, _pid
cmp eax, g_ZTCurPID
jne _next_window
push hWnd
pop g_ZTCurWnd
mov eax, FALSE
ret
_next_window:
mov eax, TRUE
ret
EnumWindowProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 显示托盘图标信息 timer过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ShowTrayTimerProc proc hWnd: DWORD, uMsg: DWORD, idEvent: DWORD, dwTimer: DWORD
LOCAL _buf[255]: byte
pushad
invoke IsDlgButtonChecked, g_MainWnd, IDC_CHECK_CLOSE_TRAYINFO
cmp eax, BST_CHECKED
je _exit_timer_proc
invoke RtlZeroMemory, addr _buf, 255
invoke GetWindowLong, g_MainWnd, GWL_STYLE
and eax, WS_MINIMIZE
JNZ _show_notifyicon
and eax, WS_VISIBLE
JZ _show_notifyicon
jmp _exit_timer_proc
_show_notifyicon:
mov g_stNIF.dwInfoFlags, NIIF_INFO
mov g_stNIF.uTimeout, 3000
invoke lstrcpy, addr g_stNIF.szTip, addr g_SelfName
;'%s', 0DH, 0AH, '经验:%ld/%ld', 0DH, 0AH, '生命:%ld/%ld', 0DH, 0AH, '法力:%ld/%ld', 0DH, 0AH,'位置:%s', 0DH,0AH '坐标:(%ld,%ld)',0
invoke wsprintf, addr _buf, addr g_ShowTrayInfo, \
addr g_SelfName, DWORD ptr g_SelfCurExp, DWORD ptr g_SelfMaxExp, \
g_SelfCurLife, g_SelfMaxLife, g_SelfCurMagic, g_SelfMaxMagic, \
addr g_SelfMapName, g_SelfPosX, g_SelfPosY, g_ExpSpeed, g_ExpUpdateTimeI, \
g_ExpUpdateTimeF, addr g_ObjectName
invoke lstrcpy, addr g_stNIF.szInfo, addr _buf
;invoke ShowWindow, g_MainWnd, SW_HIDE
.if lpShell_NotifyIcon != NULL
invoke lpShell_NotifyIcon, NIM_MODIFY, addr g_stNIF
.endif
_exit_timer_proc:
popad
ret
ShowTrayTimerProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 自动捡起垃圾过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PickupTimerProc proc hWnd: DWORD, uMsg: DWORD, idEvent: DWORD, dwTimer: DWORD
pushad
cmp g_AutoPickupState, TRUE
jne _exit_pickup_time_proc
invoke GetForegroundWindow
cmp eax, g_ZTCurWnd
jne _exit_pickup_time_proc
invoke PostMessage, g_ZTCurWnd, WM_KEYDOWN, 0C0H, 0
invoke Sleep, 100
invoke PostMessage, g_ZTCurWnd, WM_KEYUP, 0C0H, 0
_exit_pickup_time_proc:
popad
ret
PickupTimerProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 窗口过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DialogProc proc uses ebx edi esi hWnd: DWORD, wMsg: DWORD, wParam: DWORD, lParam: DWORD
local _stPS:PAINTSTRUCT
local _stPT:POINT
local _curExp: DWORD, _maxExp: DWORD
mov eax,wMsg
; 窗体刷新
;********************************************************************
.if eax == WM_PAINT
invoke BeginPaint, hWnd, addr _stPS
invoke CreateBarGround, IDC_STATIC_LIFE_BAR
invoke DrawBar, g_SelfCurLife, g_SelfMaxLife, IDC_STATIC_LIFE_BAR, BMP_LIFE
invoke CreateBarGround, IDC_STATIC_MAGIC_BAR
invoke DrawBar, g_SelfCurMagic, g_SelfMaxMagic, IDC_STATIC_MAGIC_BAR, BMP_MAGIC
mov eax, DWORD ptr g_SelfCurExp
mov _curExp, eax
mov eax, DWORD ptr g_SelfMaxExp
mov _maxExp, eax
invoke CreateBarGround, IDC_STATIC_EXP_BAR
invoke DrawBar, _curExp, _maxExp, IDC_STATIC_EXP_BAR, BMP_EXP
invoke EndPaint, hWnd, addr _stPS
; 按钮菜单等相关操作
;********************************************************************
.elseif eax == WM_COMMAND
mov eax, wParam
; 启动按钮
;********************************************************************
.if ax == IDC_BUTTON_APPLY
.if g_HelpStop
; 创建信息获取线程
;********************************************************************
invoke InitEventQueue, offset g_EvtQueue
mov g_SkillAssoilState, 00000000H
mov g_HelpStop, FALSE
invoke CreateThread, NULL, 0, addr ShowInfoThreadProc, NULL, NULL, NULL
.if eax
invoke CloseHandle, eax
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke SetWindowText, eax, _T('停止(&S)')
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_SEARCH
invoke EnableWindow, eax, FALSE
invoke CreateThread, NULL, 0, addr HelpThreadProc, NULL, NULL, NULL
.if eax
invoke CloseHandle, eax
.endif
invoke CreateThread, NULL, 0, addr EventThreadProc, NULL, NULL, NULL
.if eax
invoke CloseHandle, eax
.endif
invoke SetTimer, g_MainWnd, IDI_PICKUP_TIME, 3000, addr PickupTimerProc
.else
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke EnableWindow, eax, FALSE
.endif
.else
mov g_HelpStop, TRUE
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke SetWindowText, eax, _T('启动(&P)')
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_SEARCH
invoke EnableWindow, eax, TRUE
.endif
; 退出按钮
;********************************************************************
.elseif ax == IDC_BUTTON_EXIT
jmp _close_main
; 隐藏游戏复选框
;********************************************************************
.elseif ax == IDC_CHECK_HIDE_GAME_WINDOW
_show_or_hide_game:
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_HIDE_GAME_WINDOW
.if eax == BST_CHECKED
invoke IsWindowVisible, g_ZTCurWnd
.if eax
invoke ShowWindow, g_ZTCurWnd, SW_HIDE
invoke CheckMenuRadioItem, g_PopupMenu, ID_POPUP_ITEM_SHOW_GAME,\
ID_POPUP_ITEM_HIDE_GAME, ID_POPUP_ITEM_HIDE_GAME, MF_BYCOMMAND
.endif
.elseif eax == BST_UNCHECKED
invoke IsWindowVisible, g_ZTCurWnd
.if ! eax
invoke ShowWindow, g_ZTCurWnd, SW_SHOW
invoke CheckMenuRadioItem, g_PopupMenu, ID_POPUP_ITEM_SHOW_GAME,\
ID_POPUP_ITEM_HIDE_GAME, ID_POPUP_ITEM_SHOW_GAME, MF_BYCOMMAND
.endif
.endif
; 仙挂机辅助复选框
;********************************************************************
.elseif ax == IDC_CHECK_XIAN_HELPER
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_XIAN_HELPER
.if eax == BST_UNCHECKED
mov g_SSAssoiled, FALSE
mov g_ZSAssoiled, FALSE
mov g_SS_sTime, 0
mov g_ZS_sTime, 0
.endif
; 本窗体最前复选框
;********************************************************************
.elseif ax == IDC_CHECK_SELF_SETTOP
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_SELF_SETTOP
.if eax == BST_CHECKED
invoke SetWindowPos, hWnd, HWND_TOPMOST, 0, 0, 0, 0, \
SWP_NOMOVE or SWP_NOSIZE
.elseif eax == BST_UNCHECKED
invoke SetWindowPos, hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, \
SWP_NOMOVE or SWP_NOSIZE
.endif
; 自动释放技能复选框
;********************************************************************
.elseif ax == IDC_CHECK_AUTO_SKILL_1
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_AUTO_SKILL_1
.if eax == BST_UNCHECKED
mov g_Skill_Interval_1, 0
mov g_Skill_Assoil_1, FALSE
invoke SendDlgItemMessage, g_MainWnd, IDC_STATIC_AUTO_SKILL_TIME_1, \
WM_SETTEXT, 0, _T( "0")
.endif
.elseif ax == IDC_CHECK_AUTO_SKILL_2
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_AUTO_SKILL_2
.if eax == BST_UNCHECKED
mov g_Skill_Interval_2, 0
mov g_Skill_Assoil_2, FALSE
invoke SendDlgItemMessage, g_MainWnd, IDC_STATIC_AUTO_SKILL_TIME_2, \
WM_SETTEXT, 0, _T( "0")
.endif
.elseif ax == IDC_CHECK_AUTO_SKILL_3
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_AUTO_SKILL_3
.if eax == BST_UNCHECKED
mov g_Skill_Interval_3, 0
mov g_Skill_Assoil_3, FALSE
invoke SendDlgItemMessage, g_MainWnd, IDC_STATIC_AUTO_SKILL_TIME_3, \
WM_SETTEXT, 0, _T( "0")
.endif
.elseif ax == IDC_CHECK_AUTO_SKILL_4
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_AUTO_SKILL_4
.if eax == BST_UNCHECKED
mov g_Skill_Interval_4, 0
mov g_Skill_Assoil_4, FALSE
invoke SendDlgItemMessage, g_MainWnd, IDC_STATIC_AUTO_SKILL_TIME_4, \
WM_SETTEXT, 0, _T( "0")
.endif
; ; 关闭托盘信息显示复选框
; ;********************************************************************
; .elseif ax == IDC_CHECK_CLOSE_TRAYINFO
; invoke IsDlgButtonChecked, hWnd, IDC_CHECK_CLOSE_TRAYINFO
; .if eax == BST_CHECKED
; .if g_Timer
; invoke KillTimer, g_MainWnd, IDI_SHOWTRAYINFO_TIME
; mov g_Timer, 0
; .endif
; .endif
; 显示主窗体弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_SHOW_MAIN
invoke SendMessage, hWnd, WM_SIZE, SIZE_RESTORED, 0
; 显示游戏窗体弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_SHOW_GAME
invoke SendDlgItemMessage, hWnd, IDC_CHECK_HIDE_GAME_WINDOW, \
BM_SETCHECK, BST_UNCHECKED, 0
jmp _show_or_hide_game
; 隐藏游戏窗体弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_HIDE_GAME
invoke SendDlgItemMessage, hWnd, IDC_CHECK_HIDE_GAME_WINDOW, \
BM_SETCHECK, BST_CHECKED, 0
jmp _show_or_hide_game
; 自动捡取垃圾弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_AUTO_PICKUP
invoke GetMenuState, g_PopupMenu, ID_POPUP_ITEM_AUTO_PICKUP, \
MF_BYCOMMAND
.if eax == MF_UNCHECKED
mov g_AutoPickupState, TRUE
mov eax, MF_CHECKED
.else
mov g_AutoPickupState, FALSE
mov eax, MF_UNCHECKED
.endif
invoke CheckMenuItem, g_PopupMenu, ID_POPUP_ITEM_AUTO_PICKUP, eax
; 退出本工具弹出菜单项
;********************************************************************
.elseif ax == ID_POPUP_ITEM_EXIT_APP
jmp _close_main
.endif
; 托盘图标
;********************************************************************
.elseif eax == WM_SHELLNOTIFY
.if lParam == WM_LBUTTONDBLCLK
invoke SendMessage, hWnd, WM_SIZE, SIZE_RESTORED, 0
.elseif lParam == WM_RBUTTONDOWN
invoke GetCursorPos, addr _stPT
invoke TrackPopupMenu, g_PopupMenu, TPM_RIGHTALIGN, _stPT.x, _stPT.y, NULL, hWnd, NULL
.endif
; 窗体形态发生改变
;********************************************************************
.elseif eax == WM_SIZE
.if wParam == SIZE_MINIMIZED
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_SYS_NOTIFY
.if eax == BST_CHECKED
mov g_stNIF.dwInfoFlags, NIIF_WARNING
mov g_stNIF.uTimeout, 0BB8H
invoke lstrcpy, addr g_stNIF.szTip, addr g_SelfName
;invoke lstrcpy, addr g_stNIF.szInfo, _T('我现在在这里了!')
invoke ShowWindow, hWnd, SW_HIDE
.if lpShell_NotifyIcon != NULL
invoke lpShell_NotifyIcon, NIM_ADD, addr g_stNIF
.endif
; invoke SetTimer,hWnd, IDI_SHOWTRAYINFO_TIME, 10000, addr ShowTrayTimerProc
; mov g_Timer, eax
.endif
.elseif wParam == SIZE_RESTORED
invoke ShowWindow, hWnd, SW_RESTORE
.if lpShell_NotifyIcon != NULL
invoke lpShell_NotifyIcon, NIM_DELETE, addr g_stNIF
.endif
.if g_Timer
; invoke KillTimer, g_MainWnd, IDI_SHOWTRAYINFO_TIME
; mov g_Timer, 0
.endif
.endif
; 辅助工具初始化
;********************************************************************
.elseif eax == WM_INITDIALOG
push hWnd
pop g_MainWnd
mov g_AutoPickupState, FALSE
invoke CreatePopupMenu
mov g_PopupMenu, eax
invoke AppendMenu, g_PopupMenu, MF_STRING or MF_DEFAULT,ID_POPUP_ITEM_SHOW_MAIN, addr g_PITEM_SM
invoke AppendMenu, g_PopupMenu, MF_SEPARATOR, 0, NULL
invoke AppendMenu, g_PopupMenu, MF_STRING, ID_POPUP_ITEM_SHOW_GAME, addr g_PITEM_SG
invoke AppendMenu, g_PopupMenu, MF_STRING, ID_POPUP_ITEM_HIDE_GAME, addr g_PITEM_HG
invoke AppendMenu, g_PopupMenu, MF_SEPARATOR, 0, NULL
invoke AppendMenu, g_PopupMenu, MF_STRING, ID_POPUP_ITEM_AUTO_PICKUP, addr g_PITEM_AP
invoke AppendMenu, g_PopupMenu, MF_SEPARATOR, 0, NULL
invoke AppendMenu, g_PopupMenu, MF_STRING, ID_POPUP_ITEM_EXIT_APP, addr g_PITEM_EA
; 提升进程本身权限
;********************************************************************
invoke _EnablePrivilege, offset mySE_DEBUG_NAME, TRUE
;托盘
;********************************************************************
invoke LoadLibrary, _T('shell32.dll')
.if eax
mov g_lpShellNotifyDll, eax
invoke GetProcAddress, g_lpShellNotifyDll, \
_T('Shell_NotifyIcon')
mov lpShell_NotifyIcon, eax
.endif
invoke LoadLibrary, _T('MyGetKeyState.dll')
.if eax
mov g_lpInstallApiHookDll, eax
invoke GetProcAddress, g_lpInstallApiHookDll, \
_T('InstallMyKeyMouseApiHook')
mov lpInstallApiHook, eax
invoke GetProcAddress, g_lpInstallApiHookDll, \
_T('SetKeyData')
mov lpSetKeyData, eax
.endif
invoke RtlZeroMemory, addr g_stNIF, sizeof NEWNOTIFYICONDATA
mov g_stNIF.cbSize, sizeof NEWNOTIFYICONDATA
push hWnd
pop g_stNIF.hWnd
;mov g_stNIF.uID, IDI_TRAY
mov g_stNIF.uFlags, NIF_ICON + NIF_MESSAGE + NIF_TIP + NIF_INFO
mov g_stNIF.uCallbackMessage, WM_SHELLNOTIFY
invoke LoadIcon, g_InstanceHandle, ICO_MAIN
mov g_stNIF.hIcon, eax
mov g_stNIF.dwInfoFlags, NIIF_WARNING
invoke lstrcpy, addr g_stNIF.szInfoTitle, _T('Journey Helper')
;invoke lpShell_NotifyIcon, NIM_ADD, addr g_stNIF
; 创建状态栏
;********************************************************************
call CreateStatusBar
call ReSize
; 初始化快捷键列表
;********************************************************************
call InitKeyList
; 窗体是否最前
;********************************************************************
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_SELF_SETTOP
.if eax == BST_CHECKED
invoke SetWindowPos, hWnd, HWND_TOPMOST, 0, 0, 0, 0, \
SWP_NOMOVE or SWP_NOSIZE
.elseif eax == BST_UNCHECKED
invoke SetWindowPos, hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, \
SWP_NOMOVE or SWP_NOSIZE
.endif
; 设置标题栏图标
;********************************************************************
invoke LoadIcon, g_InstanceHandle, ICO_MAIN
invoke SendMessage, hWnd, WM_SETICON, ICON_BIG, eax
; 搜索进程
;********************************************************************
invoke SearchGameProcess, addr g_ZTProcessName, addr g_PidFilter
.if g_ZTCurPID != 0
; 如果找到了进程,则对其进行操作
;********************************************************************
invoke OpenProcess, PROCESS_QUERY_INFORMATION or PROCESS_VM_READ or \
PROCESS_TERMINATE, FALSE, g_ZTCurPID
test eax, eax
jz _error_ret
mov g_ZTProcess, eax
; 从基地址获取相关地址
;********************************************************************
call GetSelfAddr
.if ! eax
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke EnableWindow, eax, FALSE
jz _error_ret
.endif
call GetObjectAddr
.if ! eax
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke EnableWindow, eax, FALSE
jz _error_ret
.endif
; 置映射文件
;********************************************************************
push esi
mov eax, sizeof GAME_PROCESS_INFO
mul g_IndexOfMapFile
mov esi, g_MapFileMemoryAddr
add esi, eax
assume esi: ptr GAME_PROCESS_INFO
push g_ZTCurPID
pop [ esi].PID
mov [ esi].IsRunning, TRUE
assume esi:nothing
pop esi
;********************************************************************
; 查找游戏窗口
;********************************************************************
invoke EnumWindows, addr EnumWindowProc, NULL
.if g_ZTCurWnd == 0
invoke GetDlgItem, hWnd, IDC_CHECK_HIDE_GAME_WINDOW
invoke EnableWindow, eax, FALSE
invoke EnableMenuItem, g_PopupMenu, ID_POPUP_ITEM_SHOW_GAME, FALSE
invoke EnableMenuItem, g_PopupMenu, ID_POPUP_ITEM_HIDE_GAME, FALSE
.else
invoke CheckMenuRadioItem, g_PopupMenu, ID_POPUP_ITEM_SHOW_GAME,\
ID_POPUP_ITEM_HIDE_GAME, ID_POPUP_ITEM_SHOW_GAME, MF_BYCOMMAND
.endif
invoke lpInstallApiHook, TRUE, g_ZTCurPID
.else
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_APPLY
invoke EnableWindow, eax, FALSE
invoke GetDlgItem, g_MainWnd, IDC_BUTTON_SEARCH
invoke EnableWindow, eax, FALSE
.endif
; 载入设置
;********************************************************************
call LoadOption
; 初始化代码段
;********************************************************************
invoke InitializeCriticalSection, addr g_stCS
; 初始化队列
;********************************************************************
invoke InitEventQueue, offset g_EvtQueue
; 创建事件执行互斥体
;********************************************************************
mov g_hMutex, NULL
invoke CreateMutex,NULL, FALSE, _T( "EVENT_EXECUTE_MUTEX")
mov g_hMutex, eax
invoke GetLastError
.if eax != ERROR_SUCCESS
.if eax != ERROR_ALREADY_EXISTS
invoke SendMessage, hWnd, WM_CLOSE, TRUE, 0
.endif
.endif
; 窗体关闭
;********************************************************************
.elseif eax == WM_CLOSE
cmp wParam, TRUE
je _close_main
invoke IsDlgButtonChecked, hWnd, IDC_CHECK_SYS_NOTIFY
.if eax == BST_CHECKED
invoke SendMessage, hWnd, WM_SIZE, SIZE_MINIMIZED, 0
.else
_close_main:
mov g_HelpStop, TRUE
call SaveOption
invoke IsWindowVisible, g_ZTCurWnd
.if ! eax
invoke ShowWindow, g_ZTCurWnd, SW_SHOW
.endif
.if lpShell_NotifyIcon
invoke lpShell_NotifyIcon, NIM_DELETE, addr g_stNIF
.endif
.if g_lpShellNotifyDll
invoke FreeLibrary, g_lpShellNotifyDll
.endif
.if lpInstallApiHook
invoke lpInstallApiHook, FALSE, g_ZTCurPID
.endif
.if g_lpInstallApiHookDll
invoke FreeLibrary, g_lpInstallApiHookDll
.endif
;清映射文件中的标志
;********************************************************************
push esi
mov eax, sizeof GAME_PROCESS_INFO
mul g_IndexOfMapFile
mov esi, g_MapFileMemoryAddr
add esi, eax
assume esi: ptr GAME_PROCESS_INFO
mov [ esi].PID, 0
;invoke MemSet, addr [esi].FairyName, NULL, 32
mov [ esi].IsRunning, FALSE
assume esi:nothing
pop esi
invoke DeleteCriticalSection, addr g_stCS
invoke DestroyMenu, g_PopupMenu
.if g_hMutex != NULL
invoke ReleaseMutex, g_hMutex
invoke CloseHandle, g_hMutex
.endif
invoke EndDialog, hWnd, NULL
.endif
.else
_error_ret:
xor eax, eax
ret
.endif
mov eax, TRUE
ret
DialogProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 初始化GAME_PROCESS_INFO
; 返回值:
; exa=0 失败
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
InitGPIMap proc uses edi esi edx
;是否存在映射文件GAME_PROCESS_INFO
invoke OpenFileMapping, FILE_MAP_READ or FILE_MAP_WRITE, 0, addr g_GPIMapFile
mov g_GPIHandle, eax
test eax, eax
jnz _return_initGPI
;否,创建映射文件
invoke CreateFileMapping, -1, NULL, PAGE_READWRITE, 0, \
GPI_MAPFILE_SIZE, addr g_GPIMapFile
test eax, eax
jz _close_GPIMapping
mov g_GPIHandle, eax
ret
_close_GPIMapping:
call CloseGPI
xor eax, eax
_return_initGPI:
ret
InitGPIMap endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 读取GAME_PROCESS_INFO
; 返回值:
; 无
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ReadGPI proc uses edi esi edx
invoke MapViewOfFile, g_GPIHandle, FILE_MAP_READ or FILE_MAP_WRITE, 0, 0, 0
test eax, eax
jz _read_GPIError
mov g_MapFileMemoryAddr, eax
;读取映射文件内容
mov ecx, MAX_GAME_PROCESS_INFO
push esi
mov esi, g_MapFileMemoryAddr
mov edi, offset g_PidFilter
assume esi: ptr GAME_PROCESS_INFO
_read_GPI_loop:
mov eax, [ esi].PID
push eax
.if eax == 0 && g_IndexOfMapFile == 0FFFFFFFFH
mov eax, MAX_GAME_PROCESS_INFO
sub eax, ecx
mov g_IndexOfMapFile, eax
.endif
pop eax
mov [ edi], eax
add esi, sizeof GAME_PROCESS_INFO
add edi, 4
loop _read_GPI_loop
assume esi:nothing
pop esi
xor eax, eax
ret
_read_GPIError:
call CloseGPI
xor eax, eax
ret
ReadGPI endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 关闭GAME_PROCESS_INFO
; 返回值:
; 无
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CloseGPI proc uses edi esi edx
;关闭映射文件
cmp g_GPIHandle, NULL
je _return_close_GPI
;查询当前是否仍有辅助程序在使用映射文件
mov ecx, MAX_GAME_PROCESS_INFO
mov esi, g_MapFileMemoryAddr
assume esi: ptr GAME_PROCESS_INFO
_query_GPI:
mov eax, [ esi].IsRunning
mov g_IsRunning, eax
cmp eax, TRUE ; 是否还有其他辅助程序在使用此内存,仍在使用 不关闭
je @F
add esi, sizeof GAME_PROCESS_INFO
loop _query_GPI
assume esi:nothing
invoke CloseHandle, g_GPIHandle
mov g_GPIHandle, NULL
jmp _return_close_GPI
@@:
assume esi:nothing
_return_close_GPI:
xor eax, eax
ret
CloseGPI endp
;程序入口
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
START:
invoke InitCommonControls
invoke GetModuleHandle,NULL
mov g_InstanceHandle, eax
call InitGPIMap
test eax, eax
jz _exit_process
call ReadGPI
invoke DialogBoxParam,g_InstanceHandle,DLG_MAIN,NULL, offset DialogProc,NULL
_exit_process:
call CloseGPI
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end START