当前位置: 首页>>代码示例>>C++>>正文


C++ readmem函数代码示例

本文整理汇总了C++中readmem函数的典型用法代码示例。如果您正苦于以下问题:C++ readmem函数的具体用法?C++ readmem怎么用?C++ readmem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了readmem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dump_binary

/*
 * dump the binary into the allocated buffer
 * we dump each segment and advance the buffer
 */
static void dump_binary(mach_vm_address_t address, pid_t pid, void *buffer)
{
#if DEBUG
    printf("[DEBUG] Executing %s\n", __FUNCTION__);
#endif
    vm_region_basic_info_data_64_t region_info;
    // allocate a buffer to read the header info
    struct mach_header header;
    readmem((mach_vm_offset_t*)&header, address, sizeof(struct mach_header), pid, &region_info);
    
    if (header.magic != MH_MAGIC && header.magic != MH_MAGIC_64)
    {
		printf("[ERROR] Target is not a mach-o binary!\n");
        exit(1);
    }
    
    mach_vm_address_t imagefilesize = 0;
    
    // read the header info to find the LINKEDIT
    uint8_t *loadcmds = malloc(header.sizeofcmds*sizeof(uint8_t));
    readmem((mach_vm_offset_t*)loadcmds, address+sizeof(struct mach_header), header.sizeofcmds, pid, &region_info);
    // process and retrieve address and size of linkedit
    uint8_t *loadCmdAddress = 0;
    // first load cmd address
    loadCmdAddress = (uint8_t*)loadcmds;
    struct load_command *loadCommand    = NULL;
    struct segment_command *segCmd      = NULL;
    struct segment_command_64 *segCmd64 = NULL;
    // process commands to find the info we need

    for (uint32_t i = 0; i < header.ncmds; i++)
    {
        loadCommand = (struct load_command*)loadCmdAddress;
        // 32bits and 64 bits segment commands
        // LC_LOAD_DYLIB to find the ordinal
        if (loadCommand->cmd == LC_SEGMENT)
        {
            segCmd = (struct segment_command*)loadCmdAddress;
            if (strcmp((char*)(segCmd->segname), "__PAGEZERO") != 0)
            {
                readmem(buffer, segCmd->vmaddr, segCmd->filesize, pid, &region_info);
            }
            buffer += segCmd->filesize;
        }
        else if (loadCommand->cmd == LC_SEGMENT_64)
        {
            segCmd64 = (struct segment_command_64*)loadCmdAddress;
            if (strcmp((char*)(segCmd64->segname), "__PAGEZERO") != 0)
            {
                imagefilesize += segCmd64->filesize;
            }
            buffer += segCmd->filesize;
        }
        // advance to next command
        loadCmdAddress += loadCommand->cmdsize;
    }
    free(loadcmds);
}
开发者ID:jcarlson23,项目名称:readmem,代码行数:62,代码来源:main.c

示例2: kvtop_xen_x86_64

/*
 * for Xen extraction
 */
unsigned long long
kvtop_xen_x86_64(unsigned long kvaddr)
{
	unsigned long long dirp, entry;

	if (!is_xen_vaddr(kvaddr))
		return NOT_PADDR;

	if (is_xen_text(kvaddr))
		return (unsigned long)kvaddr - XEN_VIRT_START + info->xen_phys_start;

	if (is_direct(kvaddr))
		return (unsigned long)kvaddr - DIRECTMAP_VIRT_START;

	if ((dirp = kvtop_xen_x86_64(SYMBOL(pgd_l4))) == NOT_PADDR)
		return NOT_PADDR;
	dirp += pml4_index(kvaddr) * sizeof(unsigned long long);
	if (!readmem(MADDR_XEN, dirp, &entry, sizeof(entry)))
		return NOT_PADDR;

	if (!(entry & _PAGE_PRESENT))
		return NOT_PADDR;

	dirp = entry & ENTRY_MASK;
	dirp += pgd_index(kvaddr) * sizeof(unsigned long long);
	if (!readmem(MADDR_XEN, dirp, &entry, sizeof(entry)))
		return NOT_PADDR;

	if (!(entry & _PAGE_PRESENT))
		return NOT_PADDR;

	dirp = entry & ENTRY_MASK;
	dirp += pmd_index(kvaddr) * sizeof(unsigned long long);
	if (!readmem(MADDR_XEN, dirp, &entry, sizeof(entry)))
		return NOT_PADDR;

	if (!(entry & _PAGE_PRESENT))
		return NOT_PADDR;

	if (entry & _PAGE_PSE) {
		entry = (entry & ENTRY_MASK) + (kvaddr & ((1UL << PMD_SHIFT) - 1));
		return entry;
	}
	dirp = entry & ENTRY_MASK;
	dirp += pte_index(kvaddr) * sizeof(unsigned long long);
	if (!readmem(MADDR_XEN, dirp, &entry, sizeof(entry)))
		return NOT_PADDR;

	if (!(entry & _PAGE_PRESENT)) {
		return NOT_PADDR;
	}

	entry = (entry & ENTRY_MASK) + (kvaddr & ((1UL << PTE_SHIFT) - 1));

	return entry;
}
开发者ID:karibou,项目名称:progit,代码行数:59,代码来源:x86_64.c

示例3: get_machdep_info_x86

int
get_machdep_info_x86(void)
{
	unsigned long vmlist, vmalloc_start;

	/* PAE */
	if ((vt.mem_flags & MEMORY_X86_PAE)
	    || ((SYMBOL(pkmap_count) != NOT_FOUND_SYMBOL)
	      && (SYMBOL(pkmap_count_next) != NOT_FOUND_SYMBOL)
	      && ((SYMBOL(pkmap_count_next)-SYMBOL(pkmap_count))/sizeof(int))
	      == 512)) {
		DEBUG_MSG("\n");
		DEBUG_MSG("PAE          : ON\n");
		vt.mem_flags |= MEMORY_X86_PAE;
		info->max_physmem_bits  = _MAX_PHYSMEM_BITS_PAE;
	} else {
		DEBUG_MSG("\n");
		DEBUG_MSG("PAE          : OFF\n");
		info->max_physmem_bits  = _MAX_PHYSMEM_BITS;
	}
	info->page_offset = __PAGE_OFFSET;

	if (SYMBOL(_stext) == NOT_FOUND_SYMBOL) {
		ERRMSG("Can't get the symbol of _stext.\n");
		return FALSE;
	}
	info->kernel_start = SYMBOL(_stext) & ~KVBASE_MASK;
	DEBUG_MSG("kernel_start : %lx\n", info->kernel_start);

	if (!remap_init())
		return FALSE;

	/*
	 * For the compatibility, makedumpfile should run without the symbol
	 * vmlist and the offset of vm_struct.addr if they are not necessary.
	 */
	if ((SYMBOL(vmlist) == NOT_FOUND_SYMBOL)
	    || (OFFSET(vm_struct.addr) == NOT_FOUND_STRUCTURE)) {
		return TRUE;
	}
	if (!readmem(VADDR, SYMBOL(vmlist), &vmlist, sizeof(vmlist))) {
		ERRMSG("Can't get vmlist.\n");
		return FALSE;
	}
	if (!readmem(VADDR, vmlist + OFFSET(vm_struct.addr), &vmalloc_start,
	    sizeof(vmalloc_start))) {
		ERRMSG("Can't get vmalloc_start.\n");
		return FALSE;
	}
	info->vmalloc_start = vmalloc_start;
	DEBUG_MSG("vmalloc_start: %lx\n", vmalloc_start);

	return TRUE;
}
开发者ID:karibou,项目名称:progit,代码行数:54,代码来源:x86.c

示例4: vtop_x86_PAE

unsigned long long
vtop_x86_PAE(unsigned long vaddr)
{
	unsigned long long page_dir, pgd_pte, pmd_paddr, pmd_pte;
	unsigned long long pte_paddr, pte;

	if (SYMBOL(swapper_pg_dir) == NOT_FOUND_SYMBOL) {
		ERRMSG("Can't get the symbol of swapper_pg_dir.\n");
		return NOT_PADDR;
	}

	page_dir  = SYMBOL(swapper_pg_dir);
	page_dir += pgd_index_PAE(vaddr) * sizeof(unsigned long long);
	if (!readmem(VADDR, page_dir, &pgd_pte, sizeof(pgd_pte))) {
		ERRMSG("Can't get pgd_pte (page_dir:%llx).\n", page_dir);
		return NOT_PADDR;
	}
	if (!(pgd_pte & _PAGE_PRESENT))
		return NOT_PADDR;

	if (info->vaddr_for_vtop == vaddr)
		MSG("  PGD : %16llx => %16llx\n", page_dir, pgd_pte);

	pmd_paddr  = pgd_pte & ENTRY_MASK;
	pmd_paddr += pmd_index(vaddr) * sizeof(unsigned long long);
	if (!readmem(PADDR, pmd_paddr, &pmd_pte, sizeof(pmd_pte))) {
		ERRMSG("Can't get pmd_pte (pmd_paddr:%llx).\n", pmd_paddr);
		return NOT_PADDR;
	}
	if (!(pmd_pte & _PAGE_PRESENT))
		return NOT_PADDR;

	if (info->vaddr_for_vtop == vaddr)
		MSG("  PMD : %16llx => %16llx\n", pmd_paddr, pmd_pte);

	if (pmd_pte & _PAGE_PSE)
		return (pmd_pte & ENTRY_MASK) + (vaddr & ((1UL << PMD_SHIFT) - 1));

	pte_paddr  = pmd_pte & ENTRY_MASK;
	pte_paddr += pte_index(vaddr) * sizeof(unsigned long long);
	if (!readmem(PADDR, pte_paddr, &pte, sizeof(pte)))
		return NOT_PADDR;

	if (!(pte & _PAGE_PRESENT))
		return NOT_PADDR;

	if (info->vaddr_for_vtop == vaddr)
		MSG("  PTE : %16llx => %16llx\n", pte_paddr, pte);

	return (pte & ENTRY_MASK) + (vaddr & ((1UL << PTE_SHIFT) - 1));
}
开发者ID:karibou,项目名称:progit,代码行数:51,代码来源:x86.c

示例5: get_xen_info_x86

int get_xen_info_x86(void)
{
	unsigned long frame_table_vaddr;
	unsigned long xen_end;
	int i;

	if (SYMBOL(pgd_l2) == NOT_FOUND_SYMBOL &&
	    SYMBOL(pgd_l3) == NOT_FOUND_SYMBOL) {
		ERRMSG("Can't get pgd.\n");
		return FALSE;
	}

	if (SYMBOL(pgd_l3) == NOT_FOUND_SYMBOL) {
		ERRMSG("non-PAE not support right now.\n");
		return FALSE;
	}

	if (SYMBOL(frame_table) == NOT_FOUND_SYMBOL) {
		ERRMSG("Can't get the symbol of frame_table.\n");
		return FALSE;
	}
	if (!readmem(VADDR_XEN, SYMBOL(frame_table), &frame_table_vaddr,
	    sizeof(frame_table_vaddr))) {
		ERRMSG("Can't get the value of frame_table.\n");
		return FALSE;
	}
	info->frame_table_vaddr = frame_table_vaddr;

	if (SYMBOL(xenheap_phys_end) == NOT_FOUND_SYMBOL) {
		ERRMSG("Can't get the symbol of xenheap_phys_end.\n");
		return FALSE;
	}
	if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
	    sizeof(xen_end))) {
		ERRMSG("Can't get the value of xenheap_phys_end.\n");
		return FALSE;
	}
	info->xen_heap_start = 0;
	info->xen_heap_end   = paddr_to_pfn(xen_end);

	/*
	 * pickled_id == domain addr for x86
	 */
	for (i = 0; i < info->num_domain; i++) {
		info->domain_list[i].pickled_id =
			info->domain_list[i].domain_addr;
	}

	return TRUE;
}
开发者ID:karibou,项目名称:progit,代码行数:50,代码来源:x86.c

示例6: get_rchan_buf

static void get_rchan_buf(int cpu, ulong rchan)
{
	ulong rchan_buf;
	struct per_cpu_data *pcd;

	pcd = &per_cpu[cpu];
	readmem(rchan + rchan_offsets.buf + sizeof(void*) * cpu,
		KVADDR, &rchan_buf, sizeof(void*),
		"rchan.buf", FAULT_ON_ERROR);
	readmem(rchan_buf + rchan_offsets.buf_start,
		KVADDR, &pcd->buf.start, sizeof(void*),
		"rchan.buf.start", FAULT_ON_ERROR);
	if (old_format == 1) {
		readmem(rchan_buf + rchan_offsets.buf_offset,
			KVADDR, &pcd->buf.offset, sizeof(unsigned),
			"rchan.buf.offset", FAULT_ON_ERROR);
		readmem(rchan_buf + rchan_offsets.buf_subbufs_produced,
			KVADDR, &pcd->buf.subbufs_produced, sizeof(int32_t),
			"rchan.buf.subbufs_produced", FAULT_ON_ERROR);
		readmem(rchan_buf + rchan_offsets.buf_padding,
			KVADDR, &pcd->buf.padding, sizeof(unsigned*),
			"rchan.buf.padding", FAULT_ON_ERROR);
	} else {
		readmem(rchan_buf + rchan_offsets.buf_offset,
			KVADDR, &pcd->buf.offset, sizeof(size_t),
			"rchan.buf.offset", FAULT_ON_ERROR);
		readmem(rchan_buf + rchan_offsets.buf_subbufs_produced,
			KVADDR, &pcd->buf.subbufs_produced, sizeof(size_t),
			"rchan.buf.subbufs_produced", FAULT_ON_ERROR);
		readmem(rchan_buf + rchan_offsets.buf_padding,
			KVADDR, &pcd->buf.padding, sizeof(size_t*),
			"rchan.buf.padding", FAULT_ON_ERROR);
	}
	return;
}
开发者ID:AMCScarface,项目名称:misc,代码行数:35,代码来源:staplog.c

示例7: memset

void VZ89::readRaw(uint8_t rawData[6]) {
	static uint8_t buff[6];
	memset(buff, 0, sizeof(buff));

	//read raw temperature
	readmem(VZ89_CMD_GETSTATUS, rawData, 6);
}
开发者ID:radhoo,项目名称:mics_vz_89t,代码行数:7,代码来源:vz89.cpp

示例8: cmd_readmem_run

static int
cmd_readmem_run( chain_t *chain, char *params[] )
{
	uint32_t adr;
	uint32_t len;
	FILE *f;

	if (cmd_params( params ) != 4)
		return -1;

	if (!bus) {
		printf( _("Error: Bus driver missing.\n") );
		return 1;
	}

	if (cmd_get_number( params[1], &adr) || cmd_get_number( params[2], &len))
		return -1;

	f = fopen( params[3], "w" );
	if (!f) {
		printf( _("Unable to create file `%s'!\n"), params[3] );
		return 1;
	}
	readmem( bus, f, adr, len );
	fclose( f );

	return 1;
}
开发者ID:dihmuzikien,项目名称:ECE473,代码行数:28,代码来源:readmem.c

示例9: readmem

void ADXL345::readAccRaw(int *_AccX, int *_AccY, int *_AccZ)
{
  readmem(DATAX0, 6, &_buff[0]);
  *_AccX = _buff[1] << 8 | _buff[0];
  *_AccY = _buff[3] << 8 | _buff[2];
  *_AccZ = _buff[5] << 8 | _buff[4];
}
开发者ID:neic,项目名称:Swagway,代码行数:7,代码来源:ADXL345.cpp

示例10: get_xen_basic_info_x86

int get_xen_basic_info_x86(void)
{
	if (SYMBOL(pgd_l2) == NOT_FOUND_SYMBOL &&
	    SYMBOL(pgd_l3) == NOT_FOUND_SYMBOL) {
		ERRMSG("Can't get pgd.\n");
		return FALSE;
	}

	if (SYMBOL(pgd_l3) == NOT_FOUND_SYMBOL) {
		ERRMSG("non-PAE not support right now.\n");
		return FALSE;
	}

	if (SYMBOL(frame_table) != NOT_FOUND_SYMBOL) {
		unsigned long frame_table_vaddr;

		if (!readmem(VADDR_XEN, SYMBOL(frame_table),
		    &frame_table_vaddr, sizeof(frame_table_vaddr))) {
			ERRMSG("Can't get the value of frame_table.\n");
			return FALSE;
		}
		info->frame_table_vaddr = frame_table_vaddr;
	} else
		info->frame_table_vaddr = FRAMETABLE_VIRT_START;

	if (!info->xen_crash_info.com ||
	    info->xen_crash_info.com->xen_major_version < 4) {
		unsigned long xen_end;

		if (SYMBOL(xenheap_phys_end) == NOT_FOUND_SYMBOL) {
			ERRMSG("Can't get the symbol of xenheap_phys_end.\n");
			return FALSE;
		}
		if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
		    sizeof(xen_end))) {
			ERRMSG("Can't get the value of xenheap_phys_end.\n");
			return FALSE;
		}
		info->xen_heap_start = 0;
		info->xen_heap_end   = paddr_to_pfn(xen_end);
	}

	return TRUE;
}
开发者ID:chitranshi,项目名称:makedumpfile,代码行数:44,代码来源:x86.c

示例11: remap_init

static int
remap_init(void)
{
	int n;

	if (SYMBOL(node_remap_start_vaddr) == NOT_FOUND_SYMBOL)
		return TRUE;
	if (SYMBOL(node_remap_end_vaddr) == NOT_FOUND_SYMBOL)
		return TRUE;
	if (SYMBOL(node_remap_start_pfn) == NOT_FOUND_SYMBOL)
		return TRUE;
	if (ARRAY_LENGTH(node_remap_start_pfn) == NOT_FOUND_STRUCTURE)
		return TRUE;

	n = ARRAY_LENGTH(node_remap_start_pfn);
	remap_start_vaddr = calloc(3 * n, sizeof(unsigned long));
	if (!remap_start_vaddr) {
		ERRMSG("Can't allocate remap allocator info.\n");
		return FALSE;
	}
	remap_end_vaddr = remap_start_vaddr + n;
	remap_start_pfn = remap_end_vaddr + n;

	if (!readmem(VADDR, SYMBOL(node_remap_start_vaddr), remap_start_vaddr,
		     n * sizeof(unsigned long))) {
		ERRMSG("Can't get node_remap_start_vaddr.\n");
		return FALSE;
	}
	if (!readmem(VADDR, SYMBOL(node_remap_end_vaddr), remap_end_vaddr,
		     n * sizeof(unsigned long))) {
		ERRMSG("Can't get node_remap_end_vaddr.\n");
		return FALSE;
	}
	if (!readmem(VADDR, SYMBOL(node_remap_start_pfn), remap_start_pfn,
		     n * sizeof(unsigned long))) {
		ERRMSG("Can't get node_remap_start_pfn.\n");
		return FALSE;
	}

	max_numnodes = n;
	return TRUE;
}
开发者ID:chitranshi,项目名称:makedumpfile,代码行数:42,代码来源:x86.c

示例12: readnum

/* Read a num/string to user mode, accounting for offset.  Not a huge fan of the
 * 'size' parameter (the old plan9 users just picked NUMSIZE (12), though they
 * seem to want to limit it).  */
int readnum(unsigned long off, char *buf, unsigned long n, unsigned long val,
            size_t size)
{
    char tmp[64];
    size = MIN(sizeof(tmp), size);
    /* we really need the %* format. */
    size = snprintf(tmp, size, "%lu", val);
    /* size is now strlen, so the rest of this is just like readstr. */
    /* always include the \0 */
    return readmem(off, buf, n, tmp, size + 1);
}
开发者ID:mtaufen,项目名称:akaros,代码行数:14,代码来源:util.c

示例13: ver_emit_nlstr

static long ver_emit_nlstr(char *dest, const char *src, long size,
						   long offset)
{
	long n, slen = strlen(src);
	char *buf = kmalloc(slen + 1, MEM_WAIT);

	snprintf(buf, slen + 1, "%s", src);
	n = readmem(offset, dest, size, buf, slen + 1);
	kfree(buf);

	return n;
}
开发者ID:brho,项目名称:akaros,代码行数:12,代码来源:version.c

示例14: get_machdep_info_ppc

int
get_machdep_info_ppc(void)
{
	unsigned long vmlist, vmalloc_start;

	info->section_size_bits = _SECTION_SIZE_BITS;
	info->max_physmem_bits  = _MAX_PHYSMEM_BITS;
	info->page_offset = __PAGE_OFFSET;

	if (SYMBOL(_stext) != NOT_FOUND_SYMBOL)
		info->kernel_start = SYMBOL(_stext);
	else {
		ERRMSG("Can't get the symbol of _stext.\n");
		return FALSE;
	}
		
	DEBUG_MSG("kernel_start : %lx\n", info->kernel_start);

	/*
	 * For the compatibility, makedumpfile should run without the symbol
	 * vmlist and the offset of vm_struct.addr if they are not necessary.
	 */
	if ((SYMBOL(vmlist) == NOT_FOUND_SYMBOL)
	    || (OFFSET(vm_struct.addr) == NOT_FOUND_STRUCTURE)) {
		return TRUE;
	}
	if (!readmem(VADDR, SYMBOL(vmlist), &vmlist, sizeof(vmlist))) {
		ERRMSG("Can't get vmlist.\n");
		return FALSE;
	}
	if (!readmem(VADDR, vmlist + OFFSET(vm_struct.addr), &vmalloc_start,
	    sizeof(vmalloc_start))) {
		ERRMSG("Can't get vmalloc_start.\n");
		return FALSE;
	}
	info->vmalloc_start = vmalloc_start;
	DEBUG_MSG("vmalloc_start: %lx\n", vmalloc_start);

	return TRUE;
}
开发者ID:chitranshi,项目名称:makedumpfile,代码行数:40,代码来源:ppc.c

示例15: check_global_buffer

static int check_global_buffer(ulong rchan)
{
	int cpu;
	ulong rchan_buf[2];

	for (cpu = 0; cpu < 2; cpu++) {
		readmem(rchan + rchan_offsets.buf + sizeof(void*) * cpu,
			KVADDR, &rchan_buf[cpu], sizeof(void*),
			"rchan.buf", FAULT_ON_ERROR);
	}
	if (rchan_buf[0] == rchan_buf[1])
		return 1;
	return 0;
}
开发者ID:AMCScarface,项目名称:misc,代码行数:14,代码来源:staplog.c


注:本文中的readmem函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。