Skip to content

Commit

Permalink
Rename api
Browse files Browse the repository at this point in the history
  • Loading branch information
ritsuwastaken committed Jul 30, 2024
1 parent 29c73ad commit 240db60
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ MH_STATUS QueueEnableHookApi(LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDeto
return MH_QueueEnableHook(ppOriginal);
}

void detours::ApplyAll()
void detours::ApplyQueued()
{
MH_ApplyQueued();
}
Expand Down Expand Up @@ -76,7 +76,7 @@ inline void LoadLibraryCallback(HMODULE hModule)
MH_QueueDisableHook(OriginalLoadLibraryExW);
}

detours::ApplyAll();
detours::ApplyQueued();
}
}

Expand Down Expand Up @@ -108,7 +108,7 @@ HMODULE WINAPI DetourLoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD d
return hModule;
}

void detours::Create(LPCWSTR lpLibFileName, LPCSTR lpProcName, LPVOID lpDetour, LPVOID *lpOriginal)
void detours::Queue(LPCWSTR lpLibFileName, LPCSTR lpProcName, LPVOID lpDetour, LPVOID *lpOriginal)
{
if (MH_STATUS status = MH_Initialize(); status != MH_OK && status != MH_ERROR_ALREADY_INITIALIZED)
return;
Expand All @@ -120,7 +120,7 @@ void detours::Create(LPCWSTR lpLibFileName, LPCSTR lpProcName, LPVOID lpDetour,
QueueEnableHookApi(L"kernel32.dll", "LoadLibraryExA", DetourLoadLibraryExA, (LPVOID *)&OriginalLoadLibraryExA);
QueueEnableHookApi(L"kernel32.dll", "LoadLibraryExW", DetourLoadLibraryExW, (LPVOID *)&OriginalLoadLibraryExW);
QueueEnableHookApi(L"kernel32.dll", "LoadLibraryW", DetourLoadLibraryW, (LPVOID *)&OriginalLoadLibraryW);
detours::ApplyAll();
detours::ApplyQueued();

{
const std::unique_lock<std::shared_mutex> lock(detoursMutex);
Expand Down
4 changes: 2 additions & 2 deletions src/detours.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace detours
{
void Create(LPCWSTR lpLibFileName, LPCSTR lpProcName, LPVOID lpDetour, LPVOID *lpOriginal);
void Queue(LPCWSTR lpLibFileName, LPCSTR lpProcName, LPVOID lpDetour, LPVOID *lpOriginal);
void ApplyQueued();
void RemoveAll();
void ApplyAll();
}

#endif // DETOURS_H
4 changes: 2 additions & 2 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}
}

detours::Create(L"user32.dll", "MessageBoxW", DetourMessageBoxW, (LPVOID *)&OriginalMessageBoxW);
detours::Create(L"gdi32.dll", "SetDeviceGammaRamp", DetourSetDeviceGammaRamp, (LPVOID *)&OriginalSetDeviceGammaRamp);
detours::Queue(L"user32.dll", "MessageBoxW", DetourMessageBoxW, (LPVOID *)&OriginalMessageBoxW);
detours::Queue(L"gdi32.dll", "SetDeviceGammaRamp", DetourSetDeviceGammaRamp, (LPVOID *)&OriginalSetDeviceGammaRamp);
detours::ApplyAll();

break;
Expand Down

0 comments on commit 240db60

Please sign in to comment.