Akirayla
Silver Üye
- Katılım
- 16 Mar 2024
- Mesajlar
- 64
- Beğeniler
- 3
Merhaba şimdi bendeki kodda dllmain boolunda şöyle bi kod var. Bide bana lazım olan bi tane daha dllmain kodu var. Bunları ne yaptıysam birleştiremedim. Sürekli hata verdirtiyo birleştirince. Bilgisi olan arkadaşlardan ricam olur lütfen yardım edin. Bunları nasıl birleştircem? (c++ kodudur proje .dll projesidir.)
1. KOD
--------------------------------------------------------------------------------------------
BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
{
HMODULE handle = GetModuleHandleW(L"OpenGL32.dll");
if (!handle)
{
return FALSE;
}
pglEnable = reinterpret_cast<T_glEnable>(GetProcAddress(handle, "glEnable"));
pglDisable = reinterpret_cast<T_glDisable>(GetProcAddress(handle, "glDisable"));
pSwapBuffers = reinterpret_cast<T_SwapBuffers>(GetProcAddress(handle, "wglSwapBuffers"));
pglOrtho = reinterpret_cast<T_glOrtho>(GetProcAddress(handle, "glOrtho"));
pglScalef = reinterpret_cast<T_glScalef>(GetProcAddress(handle, "glScalef"));
pglTranslatef = reinterpret_cast<T_glTranslatef>(GetProcAddress(handle, "glTranslatef"));
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(reinterpret_cast<void**>(&pglEnable), myglEnable);
DetourAttach(reinterpret_cast<void**>(&pglDisable), myglDisable);
DetourAttach(reinterpret_cast<void**>(&pglOrtho), myglOrtho);
DetourAttach(reinterpret_cast<void**>(&pSwapBuffers), mySwapBuffers);
DetourAttach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourAttach(reinterpret_cast<void**>(&pglScalef), myglScalef);
return DetourTransactionCommit() == NO_ERROR;
}
break;
case DLL_PROCESS_DETACH:
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(reinterpret_cast<void**>(&pglEnable), myglEnable);
DetourDetach(reinterpret_cast<void**>(&pglDisable), myglDisable);
DetourDetach(reinterpret_cast<void**>(&pglOrtho), myglOrtho);
DetourDetach(reinterpret_cast<void**>(&pSwapBuffers), mySwapBuffers);
DetourDetach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourDetach(reinterpret_cast<void**>(&pglScalef), myglScalef);
return DetourTransactionCommit() == NO_ERROR;
}
}
return TRUE;
}
2. KOD
---------------------------------------------------------------------------
bool __stdcall DllMain(HINSTANCE instance, DWORD reason, LPVOID p_reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(instance);
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
/* Create, join and detach thread */
if (static std::thread main_thread([instance] { MainThread(instance); }); main_thread.joinable())
main_thread.detach();
}
else if (reason == DLL_PROCESS_DETACH)
{
FreeConsole();
fclose(stdout);
}
return true;
}
1. KOD
--------------------------------------------------------------------------------------------
BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
{
HMODULE handle = GetModuleHandleW(L"OpenGL32.dll");
if (!handle)
{
return FALSE;
}
pglEnable = reinterpret_cast<T_glEnable>(GetProcAddress(handle, "glEnable"));
pglDisable = reinterpret_cast<T_glDisable>(GetProcAddress(handle, "glDisable"));
pSwapBuffers = reinterpret_cast<T_SwapBuffers>(GetProcAddress(handle, "wglSwapBuffers"));
pglOrtho = reinterpret_cast<T_glOrtho>(GetProcAddress(handle, "glOrtho"));
pglScalef = reinterpret_cast<T_glScalef>(GetProcAddress(handle, "glScalef"));
pglTranslatef = reinterpret_cast<T_glTranslatef>(GetProcAddress(handle, "glTranslatef"));
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(reinterpret_cast<void**>(&pglEnable), myglEnable);
DetourAttach(reinterpret_cast<void**>(&pglDisable), myglDisable);
DetourAttach(reinterpret_cast<void**>(&pglOrtho), myglOrtho);
DetourAttach(reinterpret_cast<void**>(&pSwapBuffers), mySwapBuffers);
DetourAttach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourAttach(reinterpret_cast<void**>(&pglScalef), myglScalef);
return DetourTransactionCommit() == NO_ERROR;
}
break;
case DLL_PROCESS_DETACH:
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(reinterpret_cast<void**>(&pglEnable), myglEnable);
DetourDetach(reinterpret_cast<void**>(&pglDisable), myglDisable);
DetourDetach(reinterpret_cast<void**>(&pglOrtho), myglOrtho);
DetourDetach(reinterpret_cast<void**>(&pSwapBuffers), mySwapBuffers);
DetourDetach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourDetach(reinterpret_cast<void**>(&pglScalef), myglScalef);
return DetourTransactionCommit() == NO_ERROR;
}
}
return TRUE;
}
2. KOD
---------------------------------------------------------------------------
bool __stdcall DllMain(HINSTANCE instance, DWORD reason, LPVOID p_reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(instance);
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
/* Create, join and detach thread */
if (static std::thread main_thread([instance] { MainThread(instance); }); main_thread.joinable())
main_thread.detach();
}
else if (reason == DLL_PROCESS_DETACH)
{
FreeConsole();
fclose(stdout);
}
return true;
}