mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-04 21:08:40 +00:00
moved getter for process start time w32
This commit is contained in:
@@ -29,5 +29,3 @@ internal String8Array os_data_from_file_path_parallel(TP_Context *tp, Arena *are
|
|||||||
internal String8List os_file_search(Arena *arena, String8List dir_list, String8 file_path);
|
internal String8List os_file_search(Arena *arena, String8List dir_list, String8 file_path);
|
||||||
internal B32 os_folder_path_exists(String8 path);
|
internal B32 os_folder_path_exists(String8 path);
|
||||||
|
|
||||||
internal U32 os_get_process_start_time_unix(void);
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,6 @@
|
|||||||
// Copyright (c) 2024 Epic Games Tools
|
// Copyright (c) 2024 Epic Games Tools
|
||||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||||
|
|
||||||
internal U32
|
|
||||||
w32_unix_time_from_file_time(FILETIME file_time)
|
|
||||||
{
|
|
||||||
U64 win32_time = ((U64)file_time.dwHighDateTime << 32) | file_time.dwLowDateTime;
|
|
||||||
U64 unix_time64 = ((win32_time - 0x19DB1DED53E8000ULL) / 10000000);
|
|
||||||
|
|
||||||
Assert(unix_time64 <= max_U32);
|
|
||||||
U32 unix_time32 = (U32)unix_time64;
|
|
||||||
|
|
||||||
return unix_time32;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal B32
|
internal B32
|
||||||
os_w32_has_path_volume_prefix(String8 path)
|
os_w32_has_path_volume_prefix(String8 path)
|
||||||
{
|
{
|
||||||
@@ -128,41 +116,3 @@ os_folder_path_exists(String8 path)
|
|||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal B32
|
|
||||||
os_set_large_pages(B32 toggle)
|
|
||||||
{
|
|
||||||
B32 is_ok = 0;
|
|
||||||
|
|
||||||
HANDLE token;
|
|
||||||
if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token))
|
|
||||||
{
|
|
||||||
LUID luid;
|
|
||||||
if(LookupPrivilegeValue(0, SE_LOCK_MEMORY_NAME, &luid))
|
|
||||||
{
|
|
||||||
TOKEN_PRIVILEGES priv;
|
|
||||||
priv.PrivilegeCount = 1;
|
|
||||||
priv.Privileges[0].Luid = luid;
|
|
||||||
priv.Privileges[0].Attributes = toggle ? SE_PRIVILEGE_ENABLED : SE_PRIVILEGE_REMOVED;
|
|
||||||
if (AdjustTokenPrivileges(token, 0, &priv, sizeof(priv), 0, 0) == ERROR_SUCCESS) {
|
|
||||||
is_ok = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CloseHandle(token);
|
|
||||||
}
|
|
||||||
return is_ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal U32
|
|
||||||
os_get_process_start_time_unix(void)
|
|
||||||
{
|
|
||||||
HANDLE handle = GetCurrentProcess();
|
|
||||||
FILETIME start_time = {0};
|
|
||||||
FILETIME exit_time;
|
|
||||||
FILETIME kernel_time;
|
|
||||||
FILETIME user_time;
|
|
||||||
if (GetProcessTimes(handle, &start_time, &exit_time, &kernel_time, &user_time)) {
|
|
||||||
return w32_unix_time_from_file_time(start_time);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -166,9 +166,10 @@ internal OS_Handle os_cmd_line_launchf(char *fmt, ...);
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: @os_hooks System/Process Info (Implemented Per-OS)
|
//~ rjf: @os_hooks System/Process Info (Implemented Per-OS)
|
||||||
|
|
||||||
internal OS_SystemInfo *os_get_system_info(void);
|
internal OS_SystemInfo *os_get_system_info(void);
|
||||||
internal OS_ProcessInfo *os_get_process_info(void);
|
internal OS_ProcessInfo *os_get_process_info(void);
|
||||||
internal String8 os_get_current_path(Arena *arena);
|
internal String8 os_get_current_path(Arena *arena);
|
||||||
|
internal U32 os_get_process_start_time_unix(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: @os_hooks Memory Allocation (Implemented Per-OS)
|
//~ rjf: @os_hooks Memory Allocation (Implemented Per-OS)
|
||||||
|
|||||||
@@ -90,6 +90,18 @@ os_w32_sleep_ms_from_endt_us(U64 endt_us)
|
|||||||
return sleep_ms;
|
return sleep_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal U32
|
||||||
|
os_w32_unix_time_from_file_time(FILETIME file_time)
|
||||||
|
{
|
||||||
|
U64 win32_time = ((U64)file_time.dwHighDateTime << 32) | file_time.dwLowDateTime;
|
||||||
|
U64 unix_time64 = ((win32_time - 0x19DB1DED53E8000ULL) / 10000000);
|
||||||
|
|
||||||
|
Assert(unix_time64 <= max_U32);
|
||||||
|
U32 unix_time32 = (U32)unix_time64;
|
||||||
|
|
||||||
|
return unix_time32;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Entity Functions
|
//~ rjf: Entity Functions
|
||||||
|
|
||||||
@@ -167,6 +179,21 @@ os_get_current_path(Arena *arena)
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal U32
|
||||||
|
os_get_process_start_time_unix(void)
|
||||||
|
{
|
||||||
|
HANDLE handle = GetCurrentProcess();
|
||||||
|
FILETIME start_time = {0};
|
||||||
|
FILETIME exit_time;
|
||||||
|
FILETIME kernel_time;
|
||||||
|
FILETIME user_time;
|
||||||
|
if(GetProcessTimes(handle, &start_time, &exit_time, &kernel_time, &user_time))
|
||||||
|
{
|
||||||
|
return os_w32_unix_time_from_file_time(start_time);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: @os_hooks Memory Allocation (Implemented Per-OS)
|
//~ rjf: @os_hooks Memory Allocation (Implemented Per-OS)
|
||||||
|
|
||||||
@@ -817,10 +844,8 @@ os_now_unix(void)
|
|||||||
{
|
{
|
||||||
FILETIME file_time;
|
FILETIME file_time;
|
||||||
GetSystemTimeAsFileTime(&file_time);
|
GetSystemTimeAsFileTime(&file_time);
|
||||||
U64 win32_time = ((U64)file_time.dwHighDateTime << 32) | file_time.dwLowDateTime;
|
U32 unix_time = os_w32_unix_time_from_file_time(file_time);
|
||||||
U64 unix_time64 = ((win32_time - 0x19DB1DED53E8000ULL) / 10000000);
|
return unix_time;
|
||||||
U32 unix_time32 = (U32)unix_time64;
|
|
||||||
return unix_time32;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal DateTime
|
internal DateTime
|
||||||
|
|||||||
Reference in New Issue
Block a user