Superior way to dynamically open beatmaps

Posts 12 of 2 · Page 1 of 1
Superior way to dynamically open beatmaps
The only way i've seen people automatically read and parse beatmap files is by doing this:
1. Continually reading the window title of the game.
2. Parsing the osu!.db file.
3. Using the above 2 to open a handle to the beatmap.

This is sloppy because downloading a new beatmap isn't updated in the .db file, and reading the window title constantly is expensive. So here's a better alternative that loads the file the moment a handle is opened to the file from the game in the song selection menu. It's also very simple with only a few lines of code. Hook CreateFileW, check for .osu in lpFileName inside the hook using wcsstr. If it's found, open and parse the file.

Code:
typedef HANDLE(WINAPI *tCreateFileW)(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
tCreateFileW oCreateFileW = NULL;

std::ifstream osuBeatFile;
HANDLE WINAPI DetourCreateFileW(LPCWSTR lpFileName, DWORD dwDesireAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
	if (wcsstr(lpFileName, L".osu"))
	{
		osuBeatFile.open(lpFileName, std::ios::in);
		//Parse Beatmap here
		osuBeatFile.close();
	}
	return oCreateFileW(lpFileName, dwDesireAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
}

void InstallHooks()
{
	// Install CreateFileW hook here.
}
Quote Originally Posted by sunkist0 View Post
-snip-
isn't this common knowledge?
something better than this is just reading the objects from memory as well, so take a look at that
Posts 12 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?