/*
 *  Copyright (C) 2015 - Preacher
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

unsigned long int get_chunk_size(unsigned long int size);

int main(int argc, char **argv)
{
	unsigned long int addr = 0;
	unsigned long int size = 0;
	unsigned long int actual_size = 0;

	if(argc != 3)
	{
		printf("[!] Usage: %s <addr> <size>\n", *argv);
		return -1;
	}

	sscanf(argv[1], "%i", &addr);
	sscanf(argv[2], "%i", &size);

	actual_size = get_chunk_size(size);

	printf("0x%08X -> 0x%08X (0x%X bytes)\n", addr, addr + actual_size, actual_size);

	return 0;
}

unsigned long int get_chunk_size(unsigned long int size)
{
	size += sizeof(int *);
	for(; (size%(sizeof(int *)*2)); size++);

	return size;
}
