Skip to content

Commit 54f30c7

Browse files
authored
Added Code Injection
Added direct code execution for a specific thread. Limitation: exec function is synchronous; will pause the main thread until it returns.
1 parent 87c815b commit 54f30c7

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

src/Lib/fileList.ahk

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class fileList {
2-
quitTimeout:=30000
3-
scripts:=[]
42

53
__new(sini){
4+
this.quitTimeout:=30000
5+
this.scripts:=[]
66
this.sini:=sini
77
this.loadDlls()
88
}
@@ -75,9 +75,17 @@
7575
}
7676

7777
closeAll(){
78+
global debug
7879
for i,a in this.scripts {
80+
if(debug)
81+
tooltip,% "Closing " . a.name
7982
this.close(a.name)
8083
}
84+
toolTip
85+
}
86+
87+
exec(scriptName,code){
88+
this.scripts[scriptName].thread.exec(code)
8189
}
8290

8391
reload(scriptName){
@@ -89,7 +97,8 @@
8997
if(this.scripts[scriptName].dll="Mini")
9098
msgbox,,Limitation Error,Mini DLL doesn't support ListLines.
9199
else
92-
this.scripts[scriptName].thread.exec("ListLines")
100+
this.exec(scriptName,"ListLines")
101+
;this.scripts[scriptName].thread.exec("ListLines")
93102
}
94103

95104
pause(scriptName){

src/Lib/guis.ahk

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ gui,addScript:add,ddl,w50 vdllType ys,Std||Mini
2323
gui,addScript:add,button,gaddScriptFinal xm,Add
2424

2525
; gui: about
26-
gui,about:+ownermain
26+
gui,about:+ownermain +hwndghwnd3
2727
gui,about:font,s12,arial
2828
gui,about:add,text,section,Written by
2929
gui,about:font,cBlue underline
@@ -36,6 +36,14 @@ gui,about:margin,15,9
3636
gui,about:font,s9 cBlack
3737
gui,about:add,button,xm gaboutGuiClose w40,Ok
3838

39+
; gui: execCode
40+
gui,execCode:+ownermain +hwndghwnd4
41+
gui,execCode:font,,courier new
42+
gui,execCode:add,edit,vexecCodeCode w500 r10
43+
gui,execCode:font,s12,arial
44+
gui,execCode:add,button,gexecScriptCode w500,Execute Code
45+
;gui,execCode:
46+
3947
; menu: main
4048
menu,actions,add,Reload all Scripts,reloadScripts
4149
menu,actions,add,Refresh list,refreshList
@@ -61,4 +69,5 @@ menu,cmain,add,Reload,reloadScript
6169
menu,cmain,add,Pause,pauseScript
6270
menu,cmain,add,Suspend,suspendScript
6371
menu,cmain,add,Open ListLines,listlinesScript
64-
menu,cmain,add,Remove,removeScript
72+
menu,cmain,add,Remove,removeScript
73+
menu,cmain,add,Execute Code,execScript

src/ScriptUp.ahk

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
menu,tray,tip,ScriptUp
77

88
; setup config
9-
debug:=0
9+
debug:=1
1010
sini:=(siniD:=a_appData . "\..\Local\ScriptUp") . "\config.ini"
1111
lvw:=500
1212
lvo:=" -LV0x10 -multi +sort"
@@ -138,6 +138,20 @@ lv_delete()
138138
gosub refreshList
139139
return
140140

141+
execScript:
142+
gui,main:default
143+
lv_getText(execScript,selectedRow)
144+
gui,execCode:default
145+
guiControl,,execCodeCode,
146+
gui,show,,% "Execute code on thread: " . execScript
147+
return
148+
149+
execScriptCode:
150+
gui,execCode:default
151+
gui,submit,nohide
152+
sList.exec(execScript,execCodeCode)
153+
return
154+
141155
reloadScripts:
142156
sList.reloadAll()
143157
gosub checkStates
@@ -225,6 +239,6 @@ return
225239

226240
isMoving(wparam,lparam,msg,hwnd){
227241
global stateUpInt,ghwnd
228-
if(hwnd=ghwnd)
242+
if(hwnd=ghwnd || hwnd=ghwnd2 || hwnd=ghwnd3 || hwnd=ghwnd4)
229243
setTimer,checkStates,% getKeyState("LButton","P")?"Off":stateUpInt
230244
}

0 commit comments

Comments
 (0)