summaryrefslogtreecommitdiffhomepage
path: root/src/section/ntapi_tt_get_section_name.c
blob: d19b078c403e7e3914926a58fb6f12bc9575d33f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/********************************************************/
/*  ntapi: Native API core library                      */
/*  Copyright (C) 2013--2021  Z. Gilboa                 */
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
/********************************************************/

#include <psxtypes/psxtypes.h>
#include <ntapi/nt_memory.h>
#include <ntapi/nt_section.h>
#include <ntapi/ntapi.h>
#include "ntapi_impl.h"

int32_t __stdcall __ntapi_tt_get_section_name(
	__in	void *			addr,
	__out	nt_mem_sec_name *	buffer,
	__in	uint32_t		buffer_size)
{
	size_t len;

	/* init buffer */
	buffer->section_name.strlen = 0;
	buffer->section_name.maxlen = (uint16_t)(buffer_size - sizeof(nt_unicode_string));
	buffer->section_name.buffer = buffer->section_name_buffer;

	return __ntapi->zw_query_virtual_memory(
		NT_CURRENT_PROCESS_HANDLE,
		addr,
		NT_MEMORY_SECTION_NAME,
		buffer,
		buffer_size,
		&len);
}