1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
-
|
|
!
-
|
|
-
|
|
|
!
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
-
|
|
!
!
|
|
|
|
|
-
|
|
!
-
|
|
|
|
|
|
|
|
|
-
|
|
!
-
|
-
|
!
-
|
!
| #packopt name "hsed_hsm"
#packopt hide 1
#include "user32.as"
#include "kernel32.as"
#include "comdlg32.as"
#include "hsedsdk.as"
#uselib "psapi.dll"
#func EnumProcessModules "EnumProcessModules" int, sptr, int, sptr
#func GetModuleFileNameEx "GetModuleFileNameExA" int, int, sptr, int
#define ctype IsSJIS1st(%1) (($81<=%1 & %1<=$9f)|($e0<=%1 & %1<=$fc)) #const OFN_FILEMUSTEXIST $00001000
#const OFN_OVERWRITEPROMPT $00000002
#const TCM_FIRST $1300
#const TCM_GETITEMCOUNT TCM_FIRST + 4
#const TCM_GETITEM TCM_FIRST + 5
#const TCIF_PARAM $0008
#const PROCESS_VM_OPERATION $0008
#const PROCESS_VM_READ $0010
#const PROCESS_VM_WRITE $0020
#const MEM_COMMIT $1000
#const MEM_RELEASE $8000
#const MEM_RESERVE $2000
#const PAGE_READWRITE 4
#const PROCESS_ALL_ACCESS $000F0000|$00100000|$FFF
#const MAX_PATH 260
#const VER_PLATFORM_WIN32_NT 2
msg = "", ""
hsed_exist: if stat=0{
msg = "エディタ(hsed3.exe)が起動していません。", "中断"
goto *exit
}
hsed_getwnd hMain, HGW_MAIN hsed_getwnd hTab, HGW_TAB
dim osinf, 5+32: osinf = (5+32)*4
GetVersionEx varptr(osinf)
if( osinf.4 = VER_PLATFORM_WIN32_NT && osinf.1 > 3 ){
winNT = 1
}else{
msg = "NT(4.0)/2000/XP以外には現在、未対応です。","中断"
goto *exit
}
sdim ofnFILE, MAX_PATH: ofnFILE = "ファイル名を入力してください"
ofnEXT = "hsm"
ofnFILTER = "Hsp Script Manager (*.hsm)@*.hsm@"
repeat
c = peek( ofnFILTER, cnt)
if c=0: break
if IsSJIS1st(c): continue cnt+2
if c='@': poke ofnFILTER, cnt, 0
loop
GetWindowLong hMain, -6: hsed_inst = stat
dim ofn, 19
ofn = 19*4, hMain, hsed_inst, varptr(ofnFILTER), 0, 0, 1, varptr(ofnFILE), MAX_PATH
ofn.15 = varptr(ofnEXT)
if dir_cmdline = "/s": goto *save
if dir_cmdline = "/o": goto *open
msg = "起動方法を確認してください。", "中断"
goto *exit
*save
dim tci, 7: tci.0 = TCIF_PARAM
sendmsg hTab, TCM_GETITEMCOUNT, 0, 0: nDocs = stat
sdim openDocs, MAX_PATH * nDocs
sdim tciText, MAX_PATH
if winNT{
GetWindowThreadProcessId hTab, varptr(dwPid)
OpenProcess PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE, 0, dwPid
hTabProc = stat
VirtualAllocEx hTabProc, 0, 4*7, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE
lpTCI = stat
WriteProcessMemory hTabProc, lpTCI, varptr(tci), 4*7, 0
repeat nDocs
sendmsg hTab, TCM_GETITEM, cnt, lpTCI
if stat=0: continue
if winNT{
ReadProcessMemory hTabProc, lpTCI, varptr(tci), 4*7, 0
if tci.6!0{
ReadProcessMemory hTabProc, tci.6, varptr(tciText), MAX_PATH, 0
if tciText!"": openDocs = tciText + "\n" + openDocs
}
}
loop
VirtualFreeEx hTabProc, lpTCI, 0, MEM_RELEASE
CloseHandle hTabProc
}else{
}
ofn.13 = OFN_FILEMUSTEXIST
GetSaveFileName varptr(ofn)
if stat: bsave ofnFILE, openDocs
goto *exit
*open
if winNT{
GetWindowThreadProcessId hMain, varptr(dwPid)
OpenProcess PROCESS_ALL_ACCESS, 0, dwPid: hProc = stat
EnumProcessModules hProc, varptr(module), 4, varptr(retSize)
sdim dir_hsed, MAX_PATH
GetModuleFileNameEx hProc, module, varptr(dir_hsed), MAX_PATH
CloseHandle hProc
}else{
}
ofn.13 = OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST
GetOpenFileName varptr(ofn)
if stat=0: goto *exit
exist ofnFILE: hsmsize = strsize
sdim openDocs, hsmsize+1
sdim fname, 260
bload ofnFILE, openDocs, hsmsize
repeat
getstr fname, openDocs, cnt: sz = strsize
if sz=0: break
exist fname
if strsize=-1{
msg = fname + "\n"
}else{
exec dir_hsed + " " + fname
}
continue cnt+sz
loop
if msg!""{
msg = "以下のファイルは読み込めませんでした。\n\n"+msg, "レポート"
}
goto *exit
*exit
if msg!"": MessageBox hMain, msg(0), msg(1), $30
end
|