Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split dllmain into several separate files to help with compile time. …
…Still more work to do... maybe.
- Loading branch information
1 parent
8208aa3
commit 45ecc50
Showing
10 changed files
with
178 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "stdafx.h" | ||
#include "Events.h" | ||
|
||
std::vector<ModEvent> modFrameEvents; | ||
std::vector<ModEvent> modInputEvents; | ||
|
||
DataPointer(short, word_3B2C464, 0x3B2C464); | ||
|
||
/** | ||
* Registers an event to the specified event list. | ||
* @param eventList The event list to add to. | ||
* @param module The module for the mod DLL. | ||
* @param name The name of the exported function from the module (i.e OnFrame) | ||
*/ | ||
void RegisterEvent(std::vector<ModEvent>& eventList, HMODULE module, const char* name) | ||
{ | ||
const ModEvent modEvent = (const ModEvent)GetProcAddress(module, name); | ||
|
||
if (modEvent != nullptr) | ||
eventList.push_back(modEvent); | ||
} | ||
|
||
void OnInput() | ||
{ | ||
RaiseEvents(modInputEvents); | ||
} | ||
|
||
void __declspec(naked) OnInput_MidJump() | ||
{ | ||
__asm | ||
{ | ||
inc word_3B2C464 | ||
pop esi | ||
jmp OnInput | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "SADXModLoader.h" | ||
#include <vector> | ||
|
||
extern std::vector<ModEvent> modFrameEvents; | ||
extern std::vector<ModEvent> modInputEvents; | ||
|
||
/** | ||
* Calls all registered events in the specified event list. | ||
* @param eventList The list of events to trigger. | ||
*/ | ||
inline void RaiseEvents(const std::vector<ModEvent>& eventList) | ||
{ | ||
for (auto &i : eventList) | ||
i(); | ||
} | ||
|
||
/** | ||
* Registers an event to the specified event list. | ||
* @param eventList The event list to add to. | ||
* @param module The module for the mod DLL. | ||
* @param name The name of the exported function from the module (i.e OnFrame) | ||
*/ | ||
void RegisterEvent(std::vector<ModEvent>& eventList, HMODULE module, const char * name); | ||
|
||
void __cdecl OnInput(); | ||
void __cdecl OnInput_MidJump(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "stdafx.h" | ||
#include "FileReplacement.h" | ||
|
||
// File replacement map. | ||
// NOTE: Do NOT mark this as static. | ||
// MediaFns.cpp needs to access the FileMap. | ||
FileMap sadx_fileMap; | ||
|
||
/** | ||
* CreateFileA() wrapper using _ReplaceFile(). | ||
* @param lpFileName | ||
* @param dwDesiredAccess | ||
* @param dwShareMode | ||
* @param lpSecurityAttibutes | ||
* @param dwCreationDisposition | ||
* @param dwFlagsAndAttributes | ||
* @param hTemplateFile | ||
* @return | ||
*/ | ||
HANDLE __stdcall MyCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) | ||
{ | ||
return CreateFileA(sadx_fileMap.replaceFile(lpFileName), dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); | ||
} | ||
|
||
/** | ||
* C wrapper to call sadx_fileMap.replaceFile() from asm. | ||
* @param lpFileName Filename. | ||
* @return Replaced filename, or original filename if not replaced by a mod. | ||
*/ | ||
const char *_ReplaceFile(const char *lpFileName) | ||
{ | ||
return sadx_fileMap.replaceFile(lpFileName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
#include "FileMap.hpp" | ||
|
||
extern FileMap sadx_fileMap; | ||
|
||
HANDLE __stdcall MyCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); | ||
const char * _ReplaceFile(const char * lpFileName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.