Información

Autor(es) Maxime Mawait
Fecha de entrega Sin fecha de envío
Tiempo límite de envío Sin límite de envío
Etiquetas de categoría s3, category_pointer, level2

Etiquetas

Inicia sesión

[S3] Pointer arithmetic

A hacker wanted to challenge you and encrypted your hard drive. To unlock your drive, he gave you a function get_key(int a, char b, int c) which returns the decryption key if the correct parameters are given.

He then hid the parameters a, b and c in memory, and gave you a pointer from which you can retrieve these parameters.


Pregunta 1: First argument

You found a hint from the hacker, telling the first parameter is located at the 12th byte after ptr. An int is guaranteed to be 4 bytes long.

Write the body of the function first which returns the integer at that position in memory.

int first(void *ptr) {
Pregunta 2: Second argument

The second parameter is a char located 6 bytes after ptr.

Write the body of the function second which returns the char at that position in memory.

char second(void *ptr) {
Pregunta 3: Third argument

The third parameter is an int located 45 bytes after ptr.

Write the body of the function third which returns the int at that position in memory.

int third(void *ptr) {