Osu! AOB's
someone know the osu! time aob?

//paternscan.c
#include "patternscan.h"
/*
* 2018-26-01 removed permission change (VirtualProtectEx call)
* 2019-26-01 added a check for page read/write permissions (42 - 50)
*/
#define true 1
#define false 0
typedef int bool;
DWORD get_process_id(const char* name) {
// store process ID in here to return later.
DWORD process_id = 0;
HANDLE process_list = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 entry = {0};
entry.dwSize = sizeof (PROCESSENTRY32);
if (Process32First(process_list, &entry)) {
while (Process32Next(process_list, &entry)) {
if (strcmp(entry.szExeFile, name) == 0) {
process_id = entry.th32ProcessID;
}
}
}
CloseHandle(process_list);
return process_id;
}
//Get ModuleEntry from module name, using toolhelp32snapshot
MODULEENTRY32 GetModule(DWORD dwProcID, const char * moduleName)
{
MODULEENTRY32 modEntry = { 0 };
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, dwProcID);
if (hSnapshot != INVALID_HANDLE_VALUE)
{
MODULEENTRY32 curr = { 0 };
curr.dwSize = sizeof(MODULEENTRY32);
if (Module32First(hSnapshot, &curr))
{
do
{
if (!strcmp(curr.szModule, moduleName))
{
modEntry = curr;
break;
}
} while (Module32Next(hSnapshot, &curr));
}
CloseHandle(hSnapshot);
}
return modEntry;
}
//Internal Pattern Scan
void * PatternScan(char* base, size_t size, const char* pattern, const char* mask)
{
size_t patternLength = strlen(mask);
for (unsigned int i = 0; i < size - patternLength; i++)
{
bool found = true;
for (unsigned int j = 0; j < patternLength; j++)
{
if (mask[j] != '?' && pattern[j] != *(base + i + j))
{
found = false;
break;
}
}
if (found)
{
return (void*)(base + i);
}
}
return NULL;
}
//External Wrapper
void * PatternScanEx(HANDLE hProcess, uintptr_t begin, uintptr_t end, const char* pattern, const char* mask)
{
uintptr_t currentChunk = begin;
SIZE_T bytesRead;
MEMORY_BASIC_INFORMATION memInfo = {0};
while (currentChunk < end)
{
char buffer[4096];
DWORD oldprotect;
//checking page permisions
if (VirtualQueryEx(hProcess, (void*)currentChunk, &memInfo, sizeof(MEMORY_BASIC_INFORMATION)) == 0)
break;
#define WRITABLE (PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)
if (!(memInfo.Protect && WRITABLE) && (memInfo.State == MEM_COMMIT))
{
//ignore memory pages
currentChunk = currentChunk + memInfo.RegionSize;
continue;
}
/* VirtualProtectEx(hProcess, (void*)currentChunk, sizeof(buffer), PAGE_EXECUTE_READWRITE, &oldprotect); */
ReadProcessMemory(hProcess, (void*)currentChunk, &buffer, sizeof(buffer), &bytesRead);
/* VirtualProtectEx(hProcess, (void*)currentChunk, sizeof(buffer), oldprotect, &oldprotect); */
if (bytesRead == 0)
{
return NULL;
}
void* internalAddress = PatternScan((char*)&buffer, bytesRead, pattern, mask);
if (internalAddress != NULL)
{
//calculate from internal to external
uintptr_t offsetFromBuffer = (uintptr_t)internalAddress - (uintptr_t)&buffer;
return (void*)(currentChunk + offsetFromBuffer);
}
else
{
//advance to next chunk
currentChunk = currentChunk + bytesRead;
}
}
return NULL;
}
void * find_pattern(const char* process_name, const char* pattern, const char* mask){
DWORD process_id = get_process_id(process_name);
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, process_id);
MODULEENTRY32 modEntry = GetModule(process_id, process_name);
//if module not found
if (!modEntry.th32ModuleID)
return NULL;
//maybe this is wrong?
uintptr_t begin = (uintptr_t)modEntry.modBaseAddr;
uintptr_t end = begin + modEntry.modBaseSize;
return PatternScanEx(hProcess, begin, end, pattern, mask);
}
//paternscan.h #pragma once #include <windows.h> #include <tlhelp32.h> #include <stdint.h> #include <string.h> DWORD get_process_id(const char* name); MODULEENTRY32 GetModule(DWORD dwProcID, const char * moduleName); //Internal Pattern Scan void * PatternScan(char* base, size_t size, const char* pattern, const char* mask); //External Wrapper void * PatternScanEx(HANDLE hProcess, uintptr_t begin, uintptr_t end, const char* pattern, const char* mask); void * find_pattern(const char* process_name, const char* pattern, const char* mask);
//main.c
#include <stdio.h>
#include "patternscan.h"
int main(int argc, char** argv){
//A3 00 00 00 00 8B 35 00 00 00 00 85 F6
void * address = find_pattern("osu!.exe",
"\xA3\x00\x00\x00\x00\x8B\x35\x00\x00\x00\x00\x85\xF6",
"x????xx????xx");
printf("%p", address); //prints 0
}