Skip to content

Commit 10bdfd1

Browse files
committed
use owned SSTP when exec sakurascript
1 parent 7735783 commit 10bdfd1

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

ghost_terminal.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ namespace args_info {
2121
HWND ghost_hwnd=NULL;
2222
wstring command;
2323
wstring sakurascript;
24-
}
24+
} // namespace args_info
25+
wstring ghost_uid;
2526

2627
wstring&do_transfer(wstring &a) {
2728
replace_all(a, L"\\n", L"\n");
@@ -64,15 +65,21 @@ void terminal_login(){
6465
else if (!ghost_link_to.empty()) {
6566
for (auto& i : fmobj.info_map) {
6667
HWND tmp_hwnd = (HWND)wcstoll(i.second[L"hwnd"].c_str(), nullptr, 10);
67-
if (i.second[L"name"] == ghost_link_to || i.second[L"fullname"] == ghost_link_to)
68+
if(i.second[L"name"] == ghost_link_to || i.second[L"fullname"] == ghost_link_to) {
6869
ghost_hwnd = tmp_hwnd;
70+
ghost_uid = i.first;
71+
break;
72+
}
6973
else {
7074
linker.link_to_ghost(tmp_hwnd);
7175
auto names = linker.NOTYFY({ { L"Event", L"ShioriEcho.GetName" },
7276
{ L"Reference0", to_wstring(GT_VAR) } });
7377

74-
if (names[L"GhostName"] == ghost_link_to)
78+
if(names[L"GhostName"] == ghost_link_to) {
7579
ghost_hwnd = tmp_hwnd;
80+
ghost_uid = i.first;
81+
break;
82+
}
7683
else
7784
linker.link_to_ghost(NULL);
7885
}
@@ -144,6 +151,15 @@ void terminal_login(){
144151
exit(1);
145152
}
146153
}
154+
if(ghost_uid.empty()) {
155+
for(auto& i: fmobj.info_map) {
156+
HWND tmp_hwnd = (HWND)wcstoll(i.second[L"hwnd"].c_str(), nullptr, 10);
157+
if(ghost_hwnd == tmp_hwnd) {
158+
ghost_uid = i.first;
159+
break;
160+
}
161+
}
162+
}
147163
}
148164
else {
149165
wcerr << "Can\'t read FMO info, trying to use socket...\n";
@@ -170,7 +186,7 @@ void terminal_login(){
170186
need_end = 1;
171187
}
172188
if(!sakurascript.empty()){
173-
linker.SEND({ { L"Script",sakurascript } });
189+
linker.SEND({{L"ID", ghost_uid}, {L"Script", sakurascript}});
174190
need_end = 1;
175191
}
176192

0 commit comments

Comments
 (0)