mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
A Dashboard mode for the second screen of dual-screen handhelds (developed on a Retroid Pocket Duo), the default on dual-screen devices. It opens on Chat at each Steam start and switches to In-game stats when a game starts. - Downloads: Steam downloads and updates (SD-card libraries too), shader caches and DroidDeck store downloads. - Notifications: other apps' notifications once access is allowed, kept in memory only. - Screenshots: a game screenshot without the overlay, and a gallery of DroidDeck's and Steam's screenshots. - Chat & voice: mic and game volume buttons, and Steam's web chat signed in with the Steam client's own session. - In-game stats: FPS, CPU, GPU, RAM and battery plus the running game or Steam client type, and a racing dash from Codemasters, Forza and OutGauge games' data output, with War Thunder and Elite Dangerous layouts; speed in km/h or mph. - Send dashboard data: turns a Codemasters game's data output on for the dash (per game or Automatic) and keeps the original setting to put back. - DiRT 3 / DiRT Showdown: with their data output on they stop with error 10038 at race end; a ws2_32.dll stand-in (tools/dirt-ws2) is swapped into the prefix while the game runs, skipped on DroidDeck-Proton 11-11.10 which has the fix built in. Same behaviour as DiRTTelemetryErrorFix by RoccoC, based on Carsten Gottschling's fix. About "telemetry": here it means a racing game's own live driving data (speed, gear, rpm, pedals), not app analytics. For In-game stats no information leaves the device and nothing is shared: the game sends its data to 127.0.0.1 on the same device, DroidDeck only listens there while the page is open and keeps the numbers in memory just long enough to draw them. DroidDeck sends no data about the user or their use of the app; logs leave the device only when the user taps Share logs.
75 lines
3.2 KiB
Python
75 lines
3.2 KiB
Python
"""ws2_32 stand-in helpers.
|
|
|
|
gen.py generate SRC OUT writes OUT/thunks.c (one jump per export) and OUT/ws2_32.def from SRC/ws2_32-exports.txt.
|
|
gen.py verify SRC DLL checks that DLL exports exactly the ordinals and names in SRC/ws2_32-exports.txt.
|
|
"""
|
|
import struct
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def exports_list(src):
|
|
rows = []
|
|
for line in (Path(src) / 'ws2_32-exports.txt').read_text().splitlines():
|
|
ordinal, name = line.split()
|
|
rows.append((int(ordinal), name))
|
|
return rows
|
|
|
|
|
|
def generate(src, out):
|
|
rows = exports_list(src)
|
|
passed = [(o, n) for o, n in rows if n != 'sendto']
|
|
c = ['/* Generated by tools/dirt-ws2/gen.py. */',
|
|
'const unsigned short dirtfix_ordinals[%d] = {%s};' % (len(passed), ', '.join(str(o) for o, _ in passed)),
|
|
'const unsigned int dirtfix_count = %d;' % len(passed),
|
|
'void *dirtfix_real[%d];' % len(passed),
|
|
'__asm__(".text\\n"']
|
|
for i, (o, _) in enumerate(passed):
|
|
c.append(' ".globl _dirtfix_t%d\\n_dirtfix_t%d:\\n\\tjmp *_dirtfix_real+%d\\n"' % (o, o, 4 * i))
|
|
c.append(');')
|
|
(Path(out) / 'thunks.c').write_text('\n'.join(c) + '\n')
|
|
d = ['LIBRARY ws2_32.dll', 'EXPORTS']
|
|
d += [' %s=%s @%d' % (n, 'dirtfix_sendto@24' if n == 'sendto' else 'dirtfix_t%d' % o, o) for o, n in rows]
|
|
(Path(out) / 'ws2_32.def').write_text('\n'.join(d) + '\n')
|
|
|
|
|
|
def pe_exports(path):
|
|
data = Path(path).read_bytes()
|
|
pe = struct.unpack_from('<I', data, 0x3c)[0]
|
|
machine, sections = struct.unpack_from('<HH', data, pe + 4)
|
|
optional_size = struct.unpack_from('<H', data, pe + 20)[0]
|
|
optional = pe + 24
|
|
export_rva = struct.unpack_from('<I', data, optional + 96)[0]
|
|
table = [struct.unpack_from('<IIII', data, optional + optional_size + 40 * i + 8) for i in range(sections)]
|
|
|
|
def offset(rva):
|
|
for size, address, raw_size, raw in table:
|
|
if address <= rva < address + max(size, raw_size):
|
|
return rva - address + raw
|
|
raise ValueError('RVA %#x outside the sections' % rva)
|
|
|
|
base, functions, names, function_rva, name_rva, ordinal_rva = struct.unpack_from('<IIIIII', data, offset(export_rva) + 16)
|
|
named = {}
|
|
for i in range(names):
|
|
text = struct.unpack_from('<I', data, offset(name_rva) + 4 * i)[0]
|
|
index = struct.unpack_from('<H', data, offset(ordinal_rva) + 2 * i)[0]
|
|
named[index] = data[offset(text):].split(b'\0')[0].decode()
|
|
result = [(base + i, named.get(i)) for i in range(functions) if struct.unpack_from('<I', data, offset(function_rva) + 4 * i)[0]]
|
|
return machine, result
|
|
|
|
|
|
def verify(src, dll):
|
|
machine, found = pe_exports(dll)
|
|
if machine != 0x14c:
|
|
sys.exit('%s is not a 32-bit x86 DLL (machine %#x)' % (dll, machine))
|
|
expected = exports_list(src)
|
|
if found != expected:
|
|
sys.exit('%s exports differ from ws2_32-exports.txt: %d found, %d expected' % (dll, len(found), len(expected)))
|
|
if b'droiddeck-dirt-ws2_32' not in Path(dll).read_bytes():
|
|
sys.exit('%s lacks the stand-in marker' % dll)
|
|
print('%s: %d exports match, marker present' % (dll, len(found)))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
{'generate': generate, 'verify': verify}[sys.argv[1]](sys.argv[2], sys.argv[3])
|