Implement RtlRandom (which despite its name is located in Xam, not xboxkrnl, which is why its not in xboxkrnl_rtl)

Stub XamVoiceSubmitPacket
Stubs for __CAP_Start_Profiling/End_Profiling/Enter_Function/Exit_Function
add a note about io_status_block in NtDeviceIoControlFile, change the param's type
move the X_IOCTL_ constants from NtDeviceIoControlFile's body into xbox.h
add X_STATUS_INVALID_IMAGE_FORMAT to xbox.h
Implement XexLoadImageHeaders
Much more correct version of IoCreateDevice, properly initializes/allocates device extension data
Stub version of IoDeleteDevice
Open the quickstart guide in the browser the first time a user opens the emulator
Add some persistent flags that are stored in the registry on windows, not in the config. These are just used to indicate whether one-time tasks have run, like showing the quickstart guide. On non-windows platforms a default value is returned that skips any of these tasks so they don't run every single time.

If the user opens a .iso file, show a warning telling them that we do not condone or support piracy. If the user closes the messagebox within two seconds set a sticky flag that will show them the warning every time instead. Otherwise the warning is never shown again. The Beep function is used to spook them a bit, to hopefully make them less likely to skip the message
If a user opens an archive file, which we do not support, explain to them that they're dumb.

Removed messages intended to "catch" pirates.  If they're out there, we don't want to know about them. A huge chunk of the discourse on our discord is now about piracy. Hopefully these changes will deter them from coming to us for now, but some of these messages may backfire
This commit is contained in:
chris
2023-07-23 14:26:10 -04:00
parent ba936e8038
commit afef35c1c0
10 changed files with 393 additions and 42 deletions

View File

@@ -616,6 +616,55 @@ dword_result_t XamIsCurrentTitleDash_entry(const ppc_context_t& ctx) {
}
DECLARE_XAM_EXPORT1(XamIsCurrentTitleDash, kNone, kImplemented);
dword_result_t XGetAudioFlags_entry() { return 65537; }
DECLARE_XAM_EXPORT1(XGetAudioFlags, kNone, kStub);
/*
todo: this table should instead be pointed to by a member of kernel state and initialized along with the process
*/
static int32_t XamRtlRandomTable[128] = {
1284227242, 1275210071, 573735546, 790525478, 2139871995, 1547161642,
179605362, 789336058, 688789844, 1801674531, 1563985344, 1957994488,
1364589140, 1645522239, 287218729, 606747145, 1972579041, 1085031214,
1425521274, 1482476501, 1844823847, 57989841, 1897051121, 1935655697,
1078145449, 1960408961, 1682526488, 842925246, 1500820517, 1214440339,
1647877149, 682003330, 261478967, 2052111302, 162531612, 583907252,
1336601894, 1715567821, 413027322, 484763869, 1383384898, 1004336348,
764733703, 854245398, 651377827, 1614895754, 838170752, 1757981266,
602609370, 1644491937, 926492609, 220523388, 115176313, 725345543,
261903793, 746137067, 920026266, 1123561945, 1580818891, 1708537768,
616249376, 1292428093, 562591055, 343818398, 1788223648, 1659004503,
2077806209, 299502267, 1604221776, 602162358, 630328440, 1606980848,
1580436667, 1078081533, 492894223, 839522115, 1979792683, 117609710,
1767777339, 1454471165, 1965331169, 1844237615, 308236825, 329068152,
412668190, 796845957, 1303643608, 436374069, 1677128483, 527237240,
813497703, 1060284298, 1770027372, 1177238915, 884357618, 1409082233,
1958367476, 448539723, 1592454029, 861567501, 963894560, 73586283,
362288127, 507921405, 113007714, 823518204, 152049171, 1202660629,
1326574676, 2025429265, 1035525444, 515967899, 1532298954, 2000478354,
1450960922, 1417001333, 2049760794, 1229272821, 879983540, 1993962763,
706699826, 776561741, 2111687655, 1343024091, 1637723038, 1220945662,
484061587, 1390067357};
/*
Follows xam exactly, the updates to the random table are probably racy.
*/
dword_result_t RtlRandom_entry(lpdword_t seed_out) {
int32_t table_seed_new = (0x7FFFFFED * *seed_out + 0x7FFFFFC3) % 0x7FFFFFFF;
*seed_out = table_seed_new;
uint32_t param_seed_new =
(0x7FFFFFED * table_seed_new + 0x7FFFFFC3) % 0x7FFFFFFFu;
*seed_out = param_seed_new;
int32_t* update_table_position = &XamRtlRandomTable[param_seed_new & 0x7F];
int32_t result = *update_table_position;
*update_table_position = table_seed_new;
return result;
}
DECLARE_XAM_EXPORT1(RtlRandom, kNone, kImplemented);
} // namespace xam
} // namespace kernel
} // namespace xe

View File

@@ -38,6 +38,13 @@ DECLARE_XAM_EXPORT1(XamVoiceClose, kNone, kStub);
dword_result_t XamVoiceHeadsetPresent_entry(lpunknown_t voice_ptr) { return 0; }
DECLARE_XAM_EXPORT1(XamVoiceHeadsetPresent, kNone, kStub);
dword_result_t XamVoiceSubmitPacket_entry(lpdword_t unk1, dword_t unk2,
lpdword_t unk3) {
// also may return 0xD000009D
return 0x800700AA;
}
DECLARE_XAM_EXPORT1(XamVoiceSubmitPacket, kNone, kStub);
} // namespace xam
} // namespace kernel
} // namespace xe