| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| int32_t __stdcall __ntapi_tt_get_system_info_snapshot( |
| __in_out nt_system_information_snapshot * sys_info_snapshot) |
| { |
| int32_t status; |
| |
| |
| if (sys_info_snapshot->buffer) |
| status = __ntapi->zw_query_system_information( |
| sys_info_snapshot->sys_info_class, |
| sys_info_snapshot->buffer, |
| sys_info_snapshot->max_len, |
| &sys_info_snapshot->info_len); |
| else { |
| |
| sys_info_snapshot->max_len = NT_ALLOCATION_GRANULARITY; |
| |
| |
| status = __ntapi->zw_allocate_virtual_memory( |
| NT_CURRENT_PROCESS_HANDLE, |
| (void **)&sys_info_snapshot->buffer, |
| 0, |
| &sys_info_snapshot->max_len, |
| NT_MEM_COMMIT, |
| NT_PAGE_READWRITE); |
| |
| |
| if (status != NT_STATUS_SUCCESS) |
| return status; |
| |
| |
| while ((status = __ntapi->zw_query_system_information( |
| sys_info_snapshot->sys_info_class, |
| sys_info_snapshot->buffer, |
| sys_info_snapshot->max_len, |
| &sys_info_snapshot->info_len)) |
| == NT_STATUS_INFO_LENGTH_MISMATCH) { |
| |
| |
| status = __ntapi->zw_free_virtual_memory( |
| NT_CURRENT_PROCESS_HANDLE, |
| (void **)&sys_info_snapshot->buffer, |
| &sys_info_snapshot->max_len, |
| NT_MEM_RELEASE); |
| |
| |
| if (status != NT_STATUS_SUCCESS) |
| return status; |
| |
| |
| sys_info_snapshot->buffer = (nt_system_information_buffer *)0; |
| sys_info_snapshot->max_len += NT_ALLOCATION_GRANULARITY; |
| |
| |
| status = __ntapi->zw_allocate_virtual_memory( |
| NT_CURRENT_PROCESS_HANDLE, |
| (void **)&sys_info_snapshot->buffer, |
| 0, |
| &sys_info_snapshot->max_len, |
| NT_MEM_COMMIT, |
| NT_PAGE_READWRITE); |
| |
| |
| if (status != NT_STATUS_SUCCESS) |
| return status; |
| } |
| } |
| |
| |
| if (status == NT_STATUS_SUCCESS) { |
| sys_info_snapshot->pcurrent = &sys_info_snapshot->buffer->mark; |
| return NT_STATUS_SUCCESS; |
| } else { |
| sys_info_snapshot->pcurrent = (void *)0; |
| return status; |
| } |
| } |