dsh-snowbreak-heimdall 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +29 -0
- package/README.md +175 -0
- package/SHA256SUMS.txt +61 -0
- package/TEST-REPORT.md +96 -0
- package/assets/icons/app-512.png +0 -0
- package/assets/icons/app-light-512.png +0 -0
- package/assets/icons/app.ico +0 -0
- package/assets/icons/apple-touch-icon.png +0 -0
- package/assets/icons/favicon-dark.svg +5 -0
- package/assets/icons/favicon.svg +5 -0
- package/assets/icons/icon-192.png +0 -0
- package/assets/icons/icon-512.png +0 -0
- package/assets/icons/icon-maskable-512.png +0 -0
- package/assets/icons/icon.svg +5 -0
- package/assets/icons/res-icon.png +0 -0
- package/assets/icons/tray.ico +0 -0
- package/assets/previews/assets/hm-mark-blue.png +0 -0
- package/assets/previews/brand-fix.png +0 -0
- package/assets/previews/exe-icon-test.png +0 -0
- package/assets/previews/loading-dark.html +443 -0
- package/assets/previews/loading-dark.png +0 -0
- package/assets/previews/loading-fallback.html +443 -0
- package/assets/previews/loading-fallback.png +0 -0
- package/assets/previews/loading-handoff.html +457 -0
- package/assets/previews/loading-light.html +443 -0
- package/assets/previews/loading-light.png +0 -0
- package/assets/previews/mask-test.png +0 -0
- package/assets/previews/progress-winforms-complete.png +0 -0
- package/assets/previews/progress-winforms.png +0 -0
- package/assets/previews/ui-chrome.html +24 -0
- package/assets/previews/ui-chrome.png +0 -0
- package/assets/source/brand-client.js +95 -0
- package/assets/source/client-template.js +217 -0
- package/assets/source/hm-mark-blue.png +0 -0
- package/assets/source/hm-mark-ink.png +0 -0
- package/assets/source/hm-mark-light.png +0 -0
- package/assets/source/loading.css +373 -0
- package/assets/source/loading.html +58 -0
- package/assets/source/logo.webp +0 -0
- package/assets/source/mark-alpha.png +0 -0
- package/assets/source/mark-color.png +0 -0
- package/assets/source/progress.ps1 +312 -0
- package/assets/source/shell.css +475 -0
- package/assets/source/shell.js +293 -0
- package/assets/source/update.css +47 -0
- package/assets/source/watermark-soft.png +0 -0
- package/assets/source/welcome-brand.svg +18 -0
- package/assets/source/welcome-mark-ink.png +0 -0
- package/assets/source/welcome-mark-light.png +0 -0
- package/assets/source/welcome.css +121 -0
- package/cordis.patch.yml +4 -0
- package/icon.svg +5 -0
- package/lib/client.js +217 -0
- package/lib/index.js +239 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +47 -0
- package/patch/asar.py +237 -0
- package/patch/patcher.py +1307 -0
- package/tools/build_assets.py +206 -0
- package/tools/build_client.py +21 -0
- package/tools/test_lock.py +28 -0
- package/tools/test_progress_launch.py +44 -0
- package/tools/test_progress_ps1.py +38 -0
- package/tools/test_progress_ps1_complete.py +38 -0
- package/vendor/rcedit/LICENSE +20 -0
- package/vendor/rcedit/README.md +51 -0
- package/vendor/rcedit/rcedit-x64.exe +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Build the Snowbreak Heimdall skin icon set from the supplied artwork.
|
|
3
|
+
|
|
4
|
+
The source image is the only brand input. White paper and the four light grey
|
|
5
|
+
corner registration marks are removed by an alpha ramp, so the remaining mark
|
|
6
|
+
keeps its original blue anti-aliased edges.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import base64
|
|
11
|
+
import io
|
|
12
|
+
import os
|
|
13
|
+
|
|
14
|
+
from PIL import Image, ImageDraw
|
|
15
|
+
|
|
16
|
+
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
17
|
+
SOURCE = os.path.join(ROOT, "assets", "source", "logo.webp")
|
|
18
|
+
OUT = os.path.join(ROOT, "assets", "icons")
|
|
19
|
+
os.makedirs(OUT, exist_ok=True)
|
|
20
|
+
|
|
21
|
+
DARK_TOP = (10, 15, 22, 255)
|
|
22
|
+
DARK_BOTTOM = (5, 8, 12, 255)
|
|
23
|
+
SNOW = (218, 234, 246, 255)
|
|
24
|
+
BLUE = (98, 151, 184, 255)
|
|
25
|
+
LINE = (70, 99, 121, 255)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def clamp01(v: float) -> float:
|
|
29
|
+
return 0.0 if v < 0.0 else (1.0 if v > 1.0 else v)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def smoothstep(a: float, b: float, v: float) -> float:
|
|
33
|
+
t = clamp01((v - a) / (b - a))
|
|
34
|
+
return t * t * (3.0 - 2.0 * t)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def extract_mark() -> Image.Image:
|
|
38
|
+
src = Image.open(SOURCE).convert("RGB")
|
|
39
|
+
w, h = src.size
|
|
40
|
+
out = Image.new("RGBA", (w, h), (0, 0, 0, 0))
|
|
41
|
+
sp = src.load()
|
|
42
|
+
op = out.load()
|
|
43
|
+
for y in range(h):
|
|
44
|
+
for x in range(w):
|
|
45
|
+
r, g, b = sp[x, y]
|
|
46
|
+
# Distance from paper white. Grey corner marks stop around 0.25,
|
|
47
|
+
# the blue mark and its AA edge start around 0.35.
|
|
48
|
+
dist = (255 - min(r, g, b)) / 255.0
|
|
49
|
+
a = smoothstep(0.30, 0.62, dist)
|
|
50
|
+
if a <= 0.004:
|
|
51
|
+
continue
|
|
52
|
+
# Unpremultiply the observed colour from a white field.
|
|
53
|
+
rr = clamp01(((r - 255.0 * (1.0 - a)) / 255.0) / a)
|
|
54
|
+
gg = clamp01(((g - 255.0 * (1.0 - a)) / 255.0) / a)
|
|
55
|
+
bb = clamp01(((b - 255.0 * (1.0 - a)) / 255.0) / a)
|
|
56
|
+
op[x, y] = (round(rr * 255), round(gg * 255), round(bb * 255), round(a * 255))
|
|
57
|
+
bbox = out.getchannel("A").getbbox()
|
|
58
|
+
if bbox is None:
|
|
59
|
+
raise SystemExit("no mark found in source image")
|
|
60
|
+
return out.crop(bbox)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
MARK = extract_mark()
|
|
64
|
+
MARK.save(os.path.join(ROOT, "assets", "source", "mark-color.png"), "PNG", optimize=True)
|
|
65
|
+
ALPHA = MARK.getchannel("A")
|
|
66
|
+
# CSS masks read the alpha channel. Saving the L-mode channel directly would
|
|
67
|
+
# produce an opaque greyscale rectangle, so keep an explicit RGBA alpha mask.
|
|
68
|
+
MASK = Image.new("RGBA", MARK.size, (255, 255, 255, 0))
|
|
69
|
+
MASK.putalpha(ALPHA)
|
|
70
|
+
MASK.save(os.path.join(ROOT, "assets", "source", "mark-alpha.png"), "PNG", optimize=True)
|
|
71
|
+
print("mark", MARK.size)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def tint(mark: Image.Image, color: tuple[int, int, int, int]) -> Image.Image:
|
|
75
|
+
solid = Image.new("RGBA", mark.size, color)
|
|
76
|
+
alpha = mark if mark.mode == "L" else mark.getchannel("A")
|
|
77
|
+
solid.putalpha(alpha)
|
|
78
|
+
return solid
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
tint(ALPHA, (214, 231, 243, 255)).save(
|
|
82
|
+
os.path.join(ROOT, "assets", "source", "hm-mark-light.png"), "PNG", optimize=True)
|
|
83
|
+
tint(ALPHA, (118, 166, 196, 255)).save(
|
|
84
|
+
os.path.join(ROOT, "assets", "source", "hm-mark-blue.png"), "PNG", optimize=True)
|
|
85
|
+
tint(ALPHA, (22, 48, 68, 255)).save(
|
|
86
|
+
os.path.join(ROOT, "assets", "source", "hm-mark-ink.png"), "PNG", optimize=True)
|
|
87
|
+
tint(ALPHA, (214, 231, 243, 255)).save(
|
|
88
|
+
os.path.join(ROOT, "assets", "source", "welcome-mark-light.png"), "PNG", optimize=True)
|
|
89
|
+
tint(ALPHA, (22, 48, 68, 255)).save(
|
|
90
|
+
os.path.join(ROOT, "assets", "source", "welcome-mark-ink.png"), "PNG", optimize=True)
|
|
91
|
+
|
|
92
|
+
# Very faint watermark for the WinForms WS_POPUP progress form.
|
|
93
|
+
wm = tint(MARK.resize((520, 324), Image.LANCZOS), (127, 178, 208, 255))
|
|
94
|
+
wm_alpha = wm.getchannel("A").point(lambda v: int(v * 0.08))
|
|
95
|
+
wm.putalpha(wm_alpha)
|
|
96
|
+
wm.save(os.path.join(ROOT, "assets", "source", "watermark-soft.png"), "PNG", optimize=True)
|
|
97
|
+
print("wrote watermark-soft.png")
|
|
98
|
+
|
|
99
|
+
# Welcome lockup (472x40, the size the shipped welcome window reserves). The
|
|
100
|
+
# two same-origin PNGs avoid a data: URL under the welcome page's img-src CSP.
|
|
101
|
+
welcome_svg = '''<svg width="472" height="40" viewBox="0 0 472 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
102
|
+
<style>
|
|
103
|
+
.hm-svg-cn{fill:#E6EEF5} .hm-svg-en{fill:#7FB2D0}
|
|
104
|
+
.hm-svg-rule{stroke:#D97745} .hm-svg-sep{stroke:#334553}
|
|
105
|
+
.hm-mark-light{display:none}
|
|
106
|
+
@media (prefers-color-scheme: light){
|
|
107
|
+
.hm-svg-cn{fill:#101820} .hm-svg-en{fill:#2F6A8E}
|
|
108
|
+
.hm-svg-rule{stroke:#A9481F} .hm-svg-sep{stroke:#C8D3DD}
|
|
109
|
+
.hm-mark-dark{display:none} .hm-mark-light{display:inline}
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
112
|
+
<image class="hm-mark-dark" x="10" y="0" width="64" height="40" preserveAspectRatio="xMidYMid meet" href="welcome-mark-light.png"/>
|
|
113
|
+
<image class="hm-mark-light" x="10" y="0" width="64" height="40" preserveAspectRatio="xMidYMid meet" href="welcome-mark-ink.png"/>
|
|
114
|
+
<path d="M86 7V33" class="hm-svg-sep" stroke-width="1"/>
|
|
115
|
+
<path d="M104 14H132" class="hm-svg-rule" stroke-width="1"/>
|
|
116
|
+
<text x="104" y="27" class="hm-svg-cn" font-family="Noto Sans SC, Microsoft YaHei UI, sans-serif" font-size="19" font-weight="600" letter-spacing="4">海姆达尔终端</text>
|
|
117
|
+
<text x="106" y="36" class="hm-svg-en" font-family="Bahnschrift, Segoe UI, sans-serif" font-size="6.5" font-weight="500" letter-spacing="2.2">HEIMDALL TACTICAL TERMINAL // HM-04</text>
|
|
118
|
+
</svg>
|
|
119
|
+
'''
|
|
120
|
+
with open(os.path.join(ROOT, "assets", "source", "welcome-brand.svg"), "w", encoding="utf-8", newline="\n") as f:
|
|
121
|
+
f.write(welcome_svg)
|
|
122
|
+
print("wrote welcome-brand.svg")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def gradient(size: int) -> Image.Image:
|
|
126
|
+
im = Image.new("RGBA", (size, size), DARK_TOP)
|
|
127
|
+
px = im.load()
|
|
128
|
+
for y in range(size):
|
|
129
|
+
t = y / max(1, size - 1)
|
|
130
|
+
px_row = tuple(round(DARK_TOP[i] + (DARK_BOTTOM[i] - DARK_TOP[i]) * t) for i in range(3)) + (255,)
|
|
131
|
+
for x in range(size):
|
|
132
|
+
px[x, y] = px_row
|
|
133
|
+
return im
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def rounded(size: int, radius: int) -> Image.Image:
|
|
137
|
+
mask = Image.new("L", (size, size), 0)
|
|
138
|
+
ImageDraw.Draw(mask).rounded_rectangle((0, 0, size - 1, size - 1), radius=radius, fill=255)
|
|
139
|
+
return mask
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def icon(size: int, pad: float = 0.18, light: bool = False) -> Image.Image:
|
|
143
|
+
im = gradient(size) if not light else Image.new("RGBA", (size, size), (239, 243, 247, 255))
|
|
144
|
+
im.putalpha(rounded(size, max(2, round(size * 0.006))))
|
|
145
|
+
inner = int(size * (1 - pad * 2))
|
|
146
|
+
ratio = MARK.width / MARK.height
|
|
147
|
+
w = inner
|
|
148
|
+
h = max(1, round(w / ratio))
|
|
149
|
+
if h > inner:
|
|
150
|
+
h = inner
|
|
151
|
+
w = max(1, round(h * ratio))
|
|
152
|
+
mark = tint(MARK.resize((w, h), Image.LANCZOS), SNOW if not light else (18, 36, 52, 255))
|
|
153
|
+
im.alpha_composite(mark, ((size - w) // 2, (size - h) // 2))
|
|
154
|
+
d = ImageDraw.Draw(im)
|
|
155
|
+
inset = max(2, round(size * 0.014))
|
|
156
|
+
d.rounded_rectangle((inset, inset, size - 1 - inset, size - 1 - inset),
|
|
157
|
+
radius=max(1, round(size * 0.004)),
|
|
158
|
+
outline=(LINE[0], LINE[1], LINE[2], 150 if not light else 110),
|
|
159
|
+
width=max(1, round(size / 512)))
|
|
160
|
+
return im
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
for size, name, pad, light in [
|
|
164
|
+
(512, "app-512.png", 0.18, False),
|
|
165
|
+
(512, "icon-512.png", 0.18, False),
|
|
166
|
+
(512, "icon-maskable-512.png", 0.27, False),
|
|
167
|
+
(192, "icon-192.png", 0.18, False),
|
|
168
|
+
(180, "apple-touch-icon.png", 0.18, False),
|
|
169
|
+
(256, "res-icon.png", 0.18, False),
|
|
170
|
+
(512, "app-light-512.png", 0.18, True),
|
|
171
|
+
]:
|
|
172
|
+
icon(size, pad, light).save(os.path.join(OUT, name), "PNG", optimize=True)
|
|
173
|
+
print("wrote", name)
|
|
174
|
+
|
|
175
|
+
tray = Image.new("RGBA", (256, 256), (0, 0, 0, 0))
|
|
176
|
+
inner = int(256 * 0.82)
|
|
177
|
+
w = inner
|
|
178
|
+
h = round(w / (MARK.width / MARK.height))
|
|
179
|
+
if h > inner:
|
|
180
|
+
h = inner
|
|
181
|
+
w = round(h * (MARK.width / MARK.height))
|
|
182
|
+
tray.alpha_composite(tint(MARK.resize((w, h), Image.LANCZOS), SNOW),
|
|
183
|
+
((256 - w) // 2, (256 - h) // 2))
|
|
184
|
+
tray.save(os.path.join(OUT, "tray.ico"), format="ICO",
|
|
185
|
+
sizes=[(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (256, 256)])
|
|
186
|
+
print("wrote tray.ico")
|
|
187
|
+
|
|
188
|
+
app = icon(256, 0.16, False)
|
|
189
|
+
app.save(os.path.join(OUT, "app.ico"), format="ICO",
|
|
190
|
+
sizes=[(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (256, 256)])
|
|
191
|
+
print("wrote app.ico")
|
|
192
|
+
|
|
193
|
+
fav = icon(128, 0.16, False)
|
|
194
|
+
buf = io.BytesIO()
|
|
195
|
+
fav.save(buf, "PNG", optimize=True)
|
|
196
|
+
b64 = base64.b64encode(buf.getvalue()).decode("ascii")
|
|
197
|
+
svg = f'''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
|
|
198
|
+
<rect width="128" height="128" rx="2" fill="#070A0F"/>
|
|
199
|
+
<rect x="3.5" y="3.5" width="121" height="121" rx="1" fill="none" stroke="#6F8DA3" stroke-opacity=".85"/>
|
|
200
|
+
<image width="128" height="128" href="data:image/png;base64,{b64}"/>
|
|
201
|
+
</svg>
|
|
202
|
+
'''
|
|
203
|
+
for name in ("favicon.svg", "favicon-dark.svg", "icon.svg"):
|
|
204
|
+
with open(os.path.join(OUT, name), "w", encoding="utf-8", newline="\n") as f:
|
|
205
|
+
f.write(svg)
|
|
206
|
+
print("wrote", name)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Inject the alpha mark into the client startup-animation template."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import base64
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
9
|
+
template = os.path.join(ROOT, "assets", "source", "client-template.js")
|
|
10
|
+
mark = os.path.join(ROOT, "assets", "source", "mark-alpha.png")
|
|
11
|
+
out = os.path.join(ROOT, "lib", "client.js")
|
|
12
|
+
|
|
13
|
+
with open(template, "r", encoding="utf-8") as handle:
|
|
14
|
+
source = handle.read()
|
|
15
|
+
with open(mark, "rb") as handle:
|
|
16
|
+
encoded = base64.b64encode(handle.read()).decode("ascii")
|
|
17
|
+
if "__MARK_B64__" not in source:
|
|
18
|
+
raise SystemExit("client template marker missing")
|
|
19
|
+
with open(out, "w", encoding="utf-8", newline="\n") as handle:
|
|
20
|
+
handle.write(source.replace("__MARK_B64__", encoded))
|
|
21
|
+
print("wrote", out, os.path.getsize(out), "bytes")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
import sys
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
sys.path.insert(0, r"C:\Users\NZH\.dsh\snowbreak-heimdall\patch")
|
|
7
|
+
import patcher
|
|
8
|
+
|
|
9
|
+
work = r"C:\Users\NZH\.dsh\work\lock-test"
|
|
10
|
+
os.makedirs(work, exist_ok=True)
|
|
11
|
+
target = r"C:\Users\NZH\AppData\Local\Programs\DeepSeek Harness\resources\app.asar"
|
|
12
|
+
state = os.path.join(work, "state")
|
|
13
|
+
|
|
14
|
+
if len(sys.argv) > 1 and sys.argv[1] == "hold":
|
|
15
|
+
patcher.configure(target, state, "", True)
|
|
16
|
+
print("hold", patcher.acquire_sync_lock(), flush=True)
|
|
17
|
+
time.sleep(3)
|
|
18
|
+
sys.exit(0)
|
|
19
|
+
|
|
20
|
+
if os.path.exists(os.path.join(state, "sync.lock")):
|
|
21
|
+
os.remove(os.path.join(state, "sync.lock"))
|
|
22
|
+
child = subprocess.Popen([sys.executable, __file__, "hold"], stdout=subprocess.PIPE, text=True)
|
|
23
|
+
time.sleep(1.2)
|
|
24
|
+
patcher.configure(target, state, "", True)
|
|
25
|
+
print("second-acquire", patcher.acquire_sync_lock())
|
|
26
|
+
print("holder", child.stdout.readline().strip())
|
|
27
|
+
child.wait()
|
|
28
|
+
print("rc", child.returncode)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import os
|
|
3
|
+
import subprocess
|
|
4
|
+
import time
|
|
5
|
+
from ctypes import wintypes
|
|
6
|
+
|
|
7
|
+
root = r"C:\Users\NZH\.dsh\snowbreak-heimdall"
|
|
8
|
+
work = os.path.join(root, "work-ps-test")
|
|
9
|
+
os.makedirs(work, exist_ok=True)
|
|
10
|
+
progress = os.path.join(work, "progress.txt")
|
|
11
|
+
with open(progress, "w", encoding="utf-16-le", newline="\n") as f:
|
|
12
|
+
f.write("\ufeffpct=50\nstage=PACK\ntext=测试进度窗\nerror=\ndone=0\nmode=apply\n")
|
|
13
|
+
template = open(os.path.join(root, "assets", "source", "progress.ps1"), encoding="utf-8").read()
|
|
14
|
+
script = (template.replace("__PROGRESS_PATH__", progress)
|
|
15
|
+
.replace("__LOGO_PATH__", os.path.join(root, "assets", "source", "hm-mark-light.png"))
|
|
16
|
+
.replace("__APP_EXE__", r"C:\Windows\System32\where.exe"))
|
|
17
|
+
path = os.path.join(work, "progress.ps1")
|
|
18
|
+
with open(path, "w", encoding="utf-8-sig", newline="\n") as f:
|
|
19
|
+
f.write(script)
|
|
20
|
+
powershell = os.path.join(os.environ.get("SystemRoot", r"C:\Windows"), "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
|
|
21
|
+
child = subprocess.Popen(
|
|
22
|
+
[powershell, "-NoProfile", "-NonInteractive", "-STA", "-ExecutionPolicy", "Bypass", "-File", path],
|
|
23
|
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, creationflags=0x08000000,
|
|
24
|
+
)
|
|
25
|
+
time.sleep(3)
|
|
26
|
+
found = []
|
|
27
|
+
EnumWindows = ctypes.windll.user32.EnumWindows
|
|
28
|
+
GetWindowTextW = ctypes.windll.user32.GetWindowTextW
|
|
29
|
+
GetWindowThreadProcessId = ctypes.windll.user32.GetWindowThreadProcessId
|
|
30
|
+
EnumWindowsProc = ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)
|
|
31
|
+
|
|
32
|
+
def callback(hwnd, lparam):
|
|
33
|
+
pid = wintypes.DWORD()
|
|
34
|
+
GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
|
|
35
|
+
if pid.value == child.pid:
|
|
36
|
+
buffer = ctypes.create_unicode_buffer(512)
|
|
37
|
+
GetWindowTextW(hwnd, buffer, 512)
|
|
38
|
+
found.append((buffer.value, hwnd))
|
|
39
|
+
return True
|
|
40
|
+
|
|
41
|
+
EnumWindows(EnumWindowsProc(callback), 0)
|
|
42
|
+
print("pid", child.pid, "running", child.poll() is None, "windows", found)
|
|
43
|
+
if child.poll() is None:
|
|
44
|
+
child.terminate()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
root = r"C:\Users\NZH\.dsh\snowbreak-heimdall"
|
|
6
|
+
work = os.path.join(root, "work-ps-test")
|
|
7
|
+
os.makedirs(work, exist_ok=True)
|
|
8
|
+
progress = os.path.join(work, "progress.txt")
|
|
9
|
+
with open(progress, "w", encoding="utf-16-le", newline="\n") as f:
|
|
10
|
+
f.write("\ufeffpct=84\nstage=PACK\ntext=正在重打包源码层…\nerror=\ndone=0\nmode=apply\n")
|
|
11
|
+
snapshot = os.path.join(root, "assets", "previews", "progress-winforms.png")
|
|
12
|
+
template = open(os.path.join(root, "assets", "source", "progress.ps1"), encoding="utf-8").read()
|
|
13
|
+
script = (template.replace("__PROGRESS_PATH__", progress)
|
|
14
|
+
.replace("__LOGO_PATH__", os.path.join(root, "assets", "source", "hm-mark-light.png"))
|
|
15
|
+
.replace("__APP_EXE__", r"C:\Windows\System32\where.exe"))
|
|
16
|
+
path = os.path.join(work, "progress.ps1")
|
|
17
|
+
with open(path, "w", encoding="utf-8-sig", newline="\n") as f:
|
|
18
|
+
f.write(script)
|
|
19
|
+
powershell = os.path.join(os.environ.get("SystemRoot", r"C:\Windows"), "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
|
|
20
|
+
env = os.environ.copy()
|
|
21
|
+
env["HEIMDALL_TEST_UI_OFFSCREEN"] = "1"
|
|
22
|
+
env["HEIMDALL_TEST_UI_SNAPSHOT"] = snapshot
|
|
23
|
+
if os.path.exists(snapshot):
|
|
24
|
+
os.remove(snapshot)
|
|
25
|
+
proc = subprocess.Popen([powershell, "-NoProfile", "-NonInteractive", "-STA", "-WindowStyle", "Hidden",
|
|
26
|
+
"-ExecutionPolicy", "Bypass", "-File", path],
|
|
27
|
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=env)
|
|
28
|
+
for _ in range(12):
|
|
29
|
+
time.sleep(0.5)
|
|
30
|
+
if proc.poll() is not None:
|
|
31
|
+
break
|
|
32
|
+
print("running", proc.poll() is None)
|
|
33
|
+
print("snapshot", os.path.exists(snapshot), os.path.getsize(snapshot) if os.path.exists(snapshot) else 0)
|
|
34
|
+
log = os.path.join(work, "ui.log")
|
|
35
|
+
if os.path.exists(log):
|
|
36
|
+
print("log", open(log, encoding="utf-8-sig").read().encode("unicode_escape").decode())
|
|
37
|
+
if proc.poll() is None:
|
|
38
|
+
proc.terminate()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
root = r"C:\Users\NZH\.dsh\snowbreak-heimdall"
|
|
6
|
+
work = os.path.join(root, "work-ps-test")
|
|
7
|
+
os.makedirs(work, exist_ok=True)
|
|
8
|
+
progress = os.path.join(work, "progress.txt")
|
|
9
|
+
with open(progress, "w", encoding="utf-16-le", newline="\n") as f:
|
|
10
|
+
f.write("\ufeffpct=100\nstage=READY\ntext=覆盖完成\nerror=\ndone=1\nmode=apply\n")
|
|
11
|
+
snapshot = os.path.join(root, "assets", "previews", "progress-winforms-complete.png")
|
|
12
|
+
template = open(os.path.join(root, "assets", "source", "progress.ps1"), encoding="utf-8").read()
|
|
13
|
+
script = (template.replace("__PROGRESS_PATH__", progress)
|
|
14
|
+
.replace("__LOGO_PATH__", os.path.join(root, "assets", "source", "hm-mark-light.png"))
|
|
15
|
+
.replace("__APP_EXE__", r"C:\Windows\System32\where.exe"))
|
|
16
|
+
path = os.path.join(work, "progress.ps1")
|
|
17
|
+
with open(path, "w", encoding="utf-8-sig", newline="\n") as f:
|
|
18
|
+
f.write(script)
|
|
19
|
+
powershell = os.path.join(os.environ.get("SystemRoot", r"C:\Windows"), "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
|
|
20
|
+
env = os.environ.copy()
|
|
21
|
+
env["HEIMDALL_TEST_UI_OFFSCREEN"] = "1"
|
|
22
|
+
env["HEIMDALL_TEST_UI_SNAPSHOT"] = snapshot
|
|
23
|
+
if os.path.exists(snapshot):
|
|
24
|
+
os.remove(snapshot)
|
|
25
|
+
proc = subprocess.Popen([powershell, "-NoProfile", "-NonInteractive", "-STA", "-WindowStyle", "Hidden",
|
|
26
|
+
"-ExecutionPolicy", "Bypass", "-File", path],
|
|
27
|
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=env)
|
|
28
|
+
for _ in range(12):
|
|
29
|
+
time.sleep(0.5)
|
|
30
|
+
if proc.poll() is not None:
|
|
31
|
+
break
|
|
32
|
+
print("running", proc.poll() is None)
|
|
33
|
+
print("snapshot", os.path.exists(snapshot), os.path.getsize(snapshot) if os.path.exists(snapshot) else 0)
|
|
34
|
+
log = os.path.join(work, "ui.log")
|
|
35
|
+
if os.path.exists(log):
|
|
36
|
+
print("log", open(log, encoding="utf-8-sig").read().encode("unicode_escape").decode())
|
|
37
|
+
if proc.poll() is None:
|
|
38
|
+
proc.terminate()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 GitHub, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# node-rcedit
|
|
2
|
+
|
|
3
|
+
[](https://github.com/electron/node-rcedit/actions/workflows/test.yml)
|
|
4
|
+
[](https://npm.im/rcedit)
|
|
5
|
+
|
|
6
|
+
Node module to edit resources of Windows executables.
|
|
7
|
+
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
On platforms other than Windows, you will need to have [Wine](https://winehq.org)
|
|
11
|
+
1.6 or later installed and in the system path.
|
|
12
|
+
|
|
13
|
+
> [!NOTE]
|
|
14
|
+
> Under the hood, this package relies on the [electron/rcedit](https://github.com/electron/rcedit)
|
|
15
|
+
> binary to perform operations. A vendored executable is in the `/bin/` folder of the source code.
|
|
16
|
+
> The latest version of this package uses `rcedit@2.0.0`.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
import { rcedit } from 'rcedit'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### `async rcedit(exePath, options)`
|
|
25
|
+
|
|
26
|
+
`exePath` is the path to the Windows executable to be modified.
|
|
27
|
+
|
|
28
|
+
`options` is an object that can contain following fields:
|
|
29
|
+
|
|
30
|
+
* `version-string` - An object containing properties to change the `exePath`'s
|
|
31
|
+
version string.
|
|
32
|
+
* `file-version` - File's version to change to.
|
|
33
|
+
* `product-version` - Product's version to change to.
|
|
34
|
+
* `icon` - Path to the icon file (`.ico`) to set as the `exePath`'s default icon.
|
|
35
|
+
* `requested-execution-level` - Requested execution level to change to, must be
|
|
36
|
+
either `asInvoker`, `highestAvailable`, or `requireAdministrator`. See
|
|
37
|
+
[requestedExecutionLevel](https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/deployment/trustinfo-element-clickonce-application?view=vs-2015#requestedexecutionlevel) for
|
|
38
|
+
more details.
|
|
39
|
+
* `application-manifest` - String path to a local manifest file to use.
|
|
40
|
+
See [Application manifest](https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests)
|
|
41
|
+
for more details.
|
|
42
|
+
* `resource-string` - An object in the form of `{ [id]: value }` to add to the
|
|
43
|
+
[string table](https://docs.microsoft.com/en-us/windows/win32/menurc/stringtable-resource).
|
|
44
|
+
|
|
45
|
+
Returns a `Promise` with no value.
|
|
46
|
+
|
|
47
|
+
## Building
|
|
48
|
+
|
|
49
|
+
* Clone the repository
|
|
50
|
+
* Run `yarn install`
|
|
51
|
+
* Run `yarn test` to run the tests
|
|
Binary file
|