Cleaning up RtlTimeToTimeFields/TimeFieldsToTime. Needs a non-win32 impl.
This commit is contained in:
parent
8154d1dad6
commit
48d5d76882
|
@ -466,57 +466,60 @@ SHIM_CALL RtlLeaveCriticalSection_shim(PPCContext* ppc_context,
|
||||||
XThread::GetCurrentThread()->CheckApcs();
|
XThread::GetCurrentThread()->CheckApcs();
|
||||||
}
|
}
|
||||||
|
|
||||||
SHIM_CALL RtlTimeToTimeFields_shim(PPCContext* ppc_context,
|
struct X_TIME_FIELDS {
|
||||||
KernelState* kernel_state) {
|
xe::be<uint16_t> year;
|
||||||
uint32_t time_ptr = SHIM_GET_ARG_32(0);
|
xe::be<uint16_t> month;
|
||||||
uint32_t time_fields_ptr = SHIM_GET_ARG_32(1);
|
xe::be<uint16_t> day;
|
||||||
|
xe::be<uint16_t> hour;
|
||||||
|
xe::be<uint16_t> minute;
|
||||||
|
xe::be<uint16_t> second;
|
||||||
|
xe::be<uint16_t> milliseconds;
|
||||||
|
xe::be<uint16_t> weekday;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(X_TIME_FIELDS) == 16, "Must be LARGEINTEGER");
|
||||||
|
|
||||||
XELOGD("RtlTimeToTimeFields(%.8X, %.8X)", time_ptr, time_fields_ptr);
|
void RtlTimeToTimeFields(lpqword_t time_ptr,
|
||||||
|
pointer_t<X_TIME_FIELDS> time_fields_ptr) {
|
||||||
uint64_t time = SHIM_MEM_64(time_ptr);
|
// TODO(benvanik): replace with our own version.
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
ft.dwHighDateTime = time >> 32;
|
ft.dwHighDateTime = static_cast<uint32_t>(time_ptr.value() >> 32);
|
||||||
ft.dwLowDateTime = (uint32_t)time;
|
ft.dwLowDateTime = static_cast<uint32_t>(time_ptr.value());
|
||||||
|
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
FileTimeToSystemTime(&ft, &st);
|
FileTimeToSystemTime(&ft, &st);
|
||||||
|
|
||||||
SHIM_SET_MEM_16(time_fields_ptr + 0, st.wYear);
|
time_fields_ptr->year = st.wYear;
|
||||||
SHIM_SET_MEM_16(time_fields_ptr + 2, st.wMonth);
|
time_fields_ptr->month = st.wMonth;
|
||||||
SHIM_SET_MEM_16(time_fields_ptr + 4, st.wDay);
|
time_fields_ptr->day = st.wDay;
|
||||||
SHIM_SET_MEM_16(time_fields_ptr + 6, st.wHour);
|
time_fields_ptr->hour = st.wHour;
|
||||||
SHIM_SET_MEM_16(time_fields_ptr + 8, st.wMinute);
|
time_fields_ptr->minute = st.wMinute;
|
||||||
SHIM_SET_MEM_16(time_fields_ptr + 10, st.wSecond);
|
time_fields_ptr->second = st.wSecond;
|
||||||
SHIM_SET_MEM_16(time_fields_ptr + 12, st.wMilliseconds);
|
time_fields_ptr->milliseconds = st.wMilliseconds;
|
||||||
|
time_fields_ptr->weekday = st.wDayOfWeek;
|
||||||
}
|
}
|
||||||
|
DECLARE_XBOXKRNL_EXPORT(RtlTimeToTimeFields, ExportTag::kImplemented);
|
||||||
|
|
||||||
SHIM_CALL RtlTimeFieldsToTime_shim(PPCContext* ppc_context,
|
dword_result_t RtlTimeFieldsToTime(pointer_t<X_TIME_FIELDS> time_fields_ptr,
|
||||||
KernelState* kernel_state) {
|
lpqword_t time_ptr) {
|
||||||
uint32_t time_fields_ptr = SHIM_GET_ARG_32(0);
|
// TODO(benvanik): replace with our own version.
|
||||||
uint32_t time_ptr = SHIM_GET_ARG_32(1);
|
|
||||||
|
|
||||||
XELOGD("RtlTimeFieldsToTime(%.8X, %.8X)", time_fields_ptr, time_ptr);
|
|
||||||
|
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
st.wYear = SHIM_MEM_16(time_fields_ptr + 0);
|
st.wYear = time_fields_ptr->year;
|
||||||
st.wMonth = SHIM_MEM_16(time_fields_ptr + 2);
|
st.wMonth = time_fields_ptr->month;
|
||||||
st.wDay = SHIM_MEM_16(time_fields_ptr + 4);
|
st.wDay = time_fields_ptr->day;
|
||||||
st.wHour = SHIM_MEM_16(time_fields_ptr + 6);
|
st.wHour = time_fields_ptr->hour;
|
||||||
st.wMinute = SHIM_MEM_16(time_fields_ptr + 8);
|
st.wMinute = time_fields_ptr->minute;
|
||||||
st.wSecond = SHIM_MEM_16(time_fields_ptr + 10);
|
st.wSecond = time_fields_ptr->second;
|
||||||
st.wMilliseconds = SHIM_MEM_16(time_fields_ptr + 12);
|
st.wMilliseconds = time_fields_ptr->milliseconds;
|
||||||
|
st.wDayOfWeek = time_fields_ptr->weekday;
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
if (!SystemTimeToFileTime(&st, &ft)) {
|
if (!SystemTimeToFileTime(&st, &ft)) {
|
||||||
// set last error = ERROR_INVALID_PARAMETER
|
// set last error = ERROR_INVALID_PARAMETER
|
||||||
SHIM_SET_RETURN_32(0);
|
return 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t time = (uint64_t(ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
uint64_t time = (uint64_t(ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
||||||
SHIM_SET_MEM_64(time_ptr, time);
|
*time_ptr = time;
|
||||||
SHIM_SET_RETURN_32(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
DECLARE_XBOXKRNL_EXPORT(RtlTimeFieldsToTime, ExportTag::kImplemented);
|
||||||
|
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
@ -527,9 +530,6 @@ void xe::kernel::xboxkrnl::RegisterRtlExports(
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", RtlMultiByteToUnicodeN, state);
|
SHIM_SET_MAPPING("xboxkrnl.exe", RtlMultiByteToUnicodeN, state);
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", RtlUnicodeToMultiByteN, state);
|
SHIM_SET_MAPPING("xboxkrnl.exe", RtlUnicodeToMultiByteN, state);
|
||||||
|
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", RtlTimeToTimeFields, state);
|
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", RtlTimeFieldsToTime, state);
|
|
||||||
|
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", RtlInitializeCriticalSection, state);
|
SHIM_SET_MAPPING("xboxkrnl.exe", RtlInitializeCriticalSection, state);
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", RtlInitializeCriticalSectionAndSpinCount,
|
SHIM_SET_MAPPING("xboxkrnl.exe", RtlInitializeCriticalSectionAndSpinCount,
|
||||||
state);
|
state);
|
||||||
|
|
Loading…
Reference in New Issue