Çözüldü 2 Farklı Dllmain boolu birleştiremiyorum

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;
}
 
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;
}
sorununu gptye attinmi?
 
Bu kullanıcıyla herhangi bir iş veya ticaret yapmak istiyorsanız, forumdan uzaklaştırıldığını sakın unutmayın.
#include <Windows.h>
#include <detours.h>
#include "hooks.h"

BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved) {
static HMODULE moduleHandle = nullptr; // moduleHandle bir kez başlatılacak

switch (reason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(handle);

// OpenGL işlevlerinin adreslerini alın
moduleHandle = GetModuleHandleW(L"OpenGL32.dll");
if (!moduleHandle) return FALSE;

pglEnable = reinterpret_cast<T_glEnable>(GetProcAddress(moduleHandle, "glEnable"));
pglDisable = reinterpret_cast<T_glDisable>(GetProcAddress(moduleHandle, "glDisable"));
pSwapBuffers = reinterpret_cast<T_SwapBuffers>(GetProcAddress(moduleHandle, "wglSwapBuffers"));
pglOrtho = reinterpret_cast<T_glOrtho>(GetProcAddress(moduleHandle, "glOrtho"));
pglScalef = reinterpret_cast<T_glScalef>(GetProcAddress(moduleHandle, "glScalef"));
pglTranslatef = reinterpret_cast<T_glTranslatef>(GetProcAddress(moduleHandle, "glTranslatef"));

// Hook işlemleri
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(reinterpret_cast<void**>(&pglEnable), myglEnable);
DetourAttach(reinterpret_cast<void**>(&pglDisable), myglDisable);
DetourAttach(reinterpret_cast<void**>(&pSwapBuffers), mySwapBuffersHook);
DetourAttach(reinterpret_cast<void**>(&pglOrtho), myglOrtho);
DetourAttach(reinterpret_cast<void**>(&pglScalef), myglScalef);
DetourAttach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
if (DetourTransactionCommit() != NO_ERROR) return FALSE;

break;

case DLL_PROCESS_DETACH:
// Hookları kaldırın
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(reinterpret_cast<void**>(&pglEnable), myglEnable);
DetourDetach(reinterpret_cast<void**>(&pglDisable), myglDisable);
DetourDetach(reinterpret_cast<void**>(&pSwapBuffers), mySwapBuffersHook);
DetourDetach(reinterpret_cast<void**>(&pglOrtho), myglOrtho);
DetourDetach(reinterpret_cast<void**>(&pglScalef), myglScalef);
DetourDetach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourTransactionCommit();

break;
}
return TRUE;
}




bide bunu dener misin
 
denedim ve s
#include <Windows.h>
#include <detours.h>
#include "hooks.h"

BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved) {
static HMODULE moduleHandle = nullptr; // moduleHandle bir kez başlatılacak

switch (reason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(handle);

// OpenGL işlevlerinin adreslerini alın
moduleHandle = GetModuleHandleW(L"OpenGL32.dll");
if (!moduleHandle) return FALSE;

pglEnable = reinterpret_cast<T_glEnable>(GetProcAddress(moduleHandle, "glEnable"));
pglDisable = reinterpret_cast<T_glDisable>(GetProcAddress(moduleHandle, "glDisable"));
pSwapBuffers = reinterpret_cast<T_SwapBuffers>(GetProcAddress(moduleHandle, "wglSwapBuffers"));
pglOrtho = reinterpret_cast<T_glOrtho>(GetProcAddress(moduleHandle, "glOrtho"));
pglScalef = reinterpret_cast<T_glScalef>(GetProcAddress(moduleHandle, "glScalef"));
pglTranslatef = reinterpret_cast<T_glTranslatef>(GetProcAddress(moduleHandle, "glTranslatef"));

// Hook işlemleri
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(reinterpret_cast<void**>(&pglEnable), myglEnable);
DetourAttach(reinterpret_cast<void**>(&pglDisable), myglDisable);
DetourAttach(reinterpret_cast<void**>(&pSwapBuffers), mySwapBuffersHook);
DetourAttach(reinterpret_cast<void**>(&pglOrtho), myglOrtho);
DetourAttach(reinterpret_cast<void**>(&pglScalef), myglScalef);
DetourAttach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
if (DetourTransactionCommit() != NO_ERROR) return FALSE;

break;

case DLL_PROCESS_DETACH:
// Hookları kaldırın
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(reinterpret_cast<void**>(&pglEnable), myglEnable);
DetourDetach(reinterpret_cast<void**>(&pglDisable), myglDisable);
DetourDetach(reinterpret_cast<void**>(&pSwapBuffers), mySwapBuffersHook);
DetourDetach(reinterpret_cast<void**>(&pglOrtho), myglOrtho);
DetourDetach(reinterpret_cast<void**>(&pglScalef), myglScalef);
DetourDetach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourTransactionCommit();

break;
}
return TRUE;
}




bide bunu dener misin
denedimve heralde aynı hatalar =
 

  Şuanda konuyu görüntüleyen kullanıcılar


Üst Alt