Skip to content

Instantly share code, notes, and snippets.

View MurylloEx's full-sized avatar
💨
Studying

Muryllo Pimenta MurylloEx

💨
Studying
View GitHub Profile
@MurylloEx
MurylloEx / allocator.cpp
Created April 21, 2024 19:35
This function allocate a space near of a memory block that could be used by a trampoline function in hooking libraries.
#include <Windows.h>
#define MAX_MEMORY_RANGE 0x40000000
#define IS_POINTER_BETWEEN(P, MAX, MIN) (((ULONG_PTR)P < (ULONG_PTR)MAX) && ((ULONG_PTR)P > (ULONG_PTR)MIN))
#define PAGE_EXECUTE_FLAGS \
PAGE_EXECUTE | \
PAGE_EXECUTE_READ | \
PAGE_EXECUTE_READWRITE | \
PAGE_EXECUTE_WRITECOPY
@MurylloEx
MurylloEx / win32-heap-alloc.cpp
Created January 20, 2024 19:38
Load an arbitrary file to memory using a combination of CreateFileW + ReadFile + HeapAlloc + HeapFree
BOOL GetFileBufferInMemory(
LPCWSTR lpFileName,
LPVOID* pDestBuffer
) {
HANDLE FileHandle = CreateFileW(lpFileName, GENERIC_READ, NULL, NULL, OPEN_EXISTING, NULL, NULL);
if (FileHandle == INVALID_HANDLE_VALUE) {
printf_s("CreateFileW failed to retrieve the file handle.");
return FALSE;
}
@MurylloEx
MurylloEx / crud-repository.interface.ts
Last active July 25, 2023 17:30
Sample of CRUD Repository and Paging Repository Pattern based on Spring Framework repository abstraction layers (CRUD, PagingAndSorting, Jpa). It was designated to work with Sequelize Typescript.
import { Model } from 'sequelize-typescript';
import { MakeNullishOptional } from 'sequelize/types/utils';
import { DestroyOptions, FindOptions, UpdateOptions } from 'sequelize';
export type RepoPrimaryKey = string | number | bigint;
export type RepoDelete<TAttributes extends object> = DestroyOptions<TAttributes>;
export type RepoUpdate<TAttributes extends object> = UpdateOptions<TAttributes>;
export type RepoFetch<TAttributes extends object> = FindOptions<TAttributes>;
export type RepoCreate<TAttributes extends object> = MakeNullishOptional<TAttributes>;
@MurylloEx
MurylloEx / electrodb-repository-pattern.ts
Created April 16, 2023 02:50
A sample of Repository design pattern in DynamoDB using ElectroDB as library to access the AWS DynamoDB.
import { v4 as uuid } from 'uuid';
import { generate } from 'randomstring';
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
import {
Schema,
Entity,
Item,
AllTableIndexCompositeAttributes,
PutItem
@MurylloEx
MurylloEx / If.tsx
Last active March 7, 2023 01:12
[React] If Conditional Render
import { Fragment, FunctionComponent, ReactElement, useCallback } from 'react';
import { IfElse } from './IfElse';
import { IfThen } from './IfThen';
import { IfElseIf } from './IfElseIf';
type CompoundComponent<T, K> = FunctionComponent<T> & K;
type IfThenType = typeof IfThen;
type IfElseType = typeof IfElse;
type IfElseIfType = typeof IfElseIf;