Skip to content

Instantly share code, notes, and snippets.

@vay3t
Last active February 7, 2018 21:34
Show Gist options
  • Save vay3t/790b2574fb2ba0b5cfd848cb1f3ed0a6 to your computer and use it in GitHub Desktop.
Save vay3t/790b2574fb2ba0b5cfd848cb1f3ed0a6 to your computer and use it in GitHub Desktop.
      +  +-------------------------+
      |  | +---------------------+ |
      |  | | Stack Frame Previo  | |
      |  | +---------------------+ |
      |  | +---------------------+ |
      |  | |     Argumentos      | |
      |  | +---------------------+ |
      |  | +---------------------+ |
      |  | | Direccion de Retorno| |
      |  | |      EIP o RET      | |
      |  | +---------------------+ |
      |  | +---------------------+ |
      |  | |Puntero Base Guardado| |
      |  | |         EBP         | |
STACK |  | +---------------------+ |     EBP
      |  | +---------------------+ |  <-------+
      |  | |                     | |
      |  | |                     | |
      |  | |                     | |
      |  | |     char buf[32]    | |
      |  | |                     | |
      |  | |                     | |
      |  | |                     | |     ESP
      |  | +---------------------+ |  <-------+
      |  | +---------------------+ |
      |  | |      Espacio no     | |
      |  | |  no reservado del   | |
      |  | |        STACK        | |
      |  | |         ...         | |
      |  | +---------------------+ |
      v  +-------------------------+

#include <string.h>
#include <stdio.h>

void func(char *arg){
	char nombre[32];
	strcpy(nombre, arg);
	printf("Welcome to the jungle %s \n",nombre);
}

int main(int argc, char *argv[]){
	if(argc != 2){
		printf("Uso: %s NOMBRE\n", argv[0]);
		return 1;
	}
	func(argv[1]);
	printf("Fin del programa\n");
	return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment