Skip to content

Instantly share code, notes, and snippets.

@p4yl0ad
Created February 11, 2022 10:58
Show Gist options
  • Save p4yl0ad/91a096b1d798b96a5b1aa48afb7498af to your computer and use it in GitHub Desktop.
Save p4yl0ad/91a096b1d798b96a5b1aa48afb7498af to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <windows.h>
/*
* Fuction to take char * & ULONGLONG and append to a linked list :3
* The reason why Ive posted this will reveal itself :3
*/
// linked list node to hold a function name and a ULONGLONG value holding the RVA to a function
struct node
{
char FuncName[_MAX_PATH];
ULONGLONG whereami;
struct node* next;
};
struct node* head = NULL;
void addLast(struct node** head, char * pVFuncName, ULONGLONG Vwhereami)
{
//create a new node
struct node* newNode;
if (!(newNode = (node*)malloc(sizeof(struct node))))
{
printf("fuckywucky\nif (!(newNode = (node*)malloc(sizeof(struct node))))");
exit(1);
}
int r = strcpy_s(newNode->FuncName, _MAX_PATH, pVFuncName);
//strcpy(newNode->FuncName, pVFuncName); //newNode->FuncName =
newNode->whereami = Vwhereami;
newNode->next = NULL;
//if head is NULL, it is an empty list
if (*head == NULL)
*head = newNode;
else
{
struct node* lastNode = *head;
//last node's next address will be NULL.
while (lastNode->next != NULL)
{
lastNode = lastNode->next;
}
//add the newNode at the end of the linked list
lastNode->next = newNode;
}
}
void printList(struct node* head)
{
struct node* temp = head;
//iterate the entire linked list and print the data
while (temp != NULL)
{
printf("%s->\n", temp->FuncName);
printf("%llu->\n", temp->whereami);
temp = temp->next;
}
printf("NULL\n");
}
int main()
{
struct node* head = NULL;
char fuck[_MAX_PATH] = "whatthefuck";
ULONGLONG fuck2 = 1234567;
char fuck3[_MAX_PATH] = "fuckthewhat";
ULONGLONG fuck4 = 7654321;
addLast(&head, fuck, fuck2);
addLast(&head, fuck3, fuck4);
printList(head);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment