Çö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;
}
 
pek bilgim yok ama direk çat diye birlestirirsen 2 tane DllMain boolu olur ve hata verir. 2 tane olamaz
yok direk birleştirmiyom bak şöyle denedim kod aşağıda
----------------------------------------------------------------
typedef void(__stdcall* T_glEnable)(GLenum);
typedef void(__stdcall* T_glDisable)(GLenum);
typedef BOOL(__stdcall* T_SwapBuffers)(HDC);
typedef void(__stdcall* T_glOrtho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
typedef void(__stdcall* T_glScalef)(GLfloat, GLfloat, GLfloat);
typedef void(__stdcall* T_glTranslatef)(GLfloat, GLfloat, GLfloat);

T_glEnable pglEnable = nullptr;
T_glDisable pglDisable = nullptr;
T_SwapBuffers pSwapBuffers = nullptr;
T_glOrtho pglOrtho = nullptr;
T_glScalef pglScalef = nullptr;
T_glTranslatef pglTranslatef = nullptr;

void DetourSetup() {
HMODULE handle = GetModuleHandleW(L"OpenGL32.dll");

if (handle) {
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);
DetourTransactionCommit();
}
}

void DetourCleanup() {
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);
DetourTransactionCommit();
}

void MainThread(HINSTANCE instance) {
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);

FreeConsole();
fclose(stdout);
}

BOOL __stdcall DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
if (reason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(instance);

std::thread main_thread(MainThread, instance);
main_thread.detach();

std::thread detour_thread([] {
DetourSetup();
});
detour_thread.detach();
}
else if (reason == DLL_PROCESS_DETACH) {
DetourCleanup();
}

return TRUE;
}

2 farklı işlem parçacığında yaptırtmayı denedim ama beceremedim
 
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 <thread>
#include <detours.h>
#include <cstdio>

// Prototipler
void MainThread(HINSTANCE instance);
using T_glEnable = void(*)(GLenum);
using T_glDisable = void(*)(GLenum);
using T_SwapBuffers = BOOL(WINAPI*)(HDC);
using T_glOrtho = void(*)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
using T_glScalef = void(*)(GLfloat, GLfloat, GLfloat);
using T_glTranslatef = void(*)(GLfloat, GLfloat, GLfloat);

T_glEnable pglEnable = nullptr;
T_glDisable pglDisable = nullptr;
T_SwapBuffers pSwapBuffers = nullptr;
T_glOrtho pglOrtho = nullptr;
T_glScalef pglScalef = nullptr;
T_glTranslatef pglTranslatef = nullptr;

void myglEnable(GLenum cap) { /* Hook implementasyonu */ }
void myglDisable(GLenum cap) { /* Hook implementasyonu */ }
void mySwapBuffers(HDC hdc) { /* Hook implementasyonu */ }
void myglOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) { /* Hook implementasyonu */ }
void myglTranslatef(GLfloat x, GLfloat y, GLfloat z) { /* Hook implementasyonu */ }
void myglScalef(GLfloat x, GLfloat y, GLfloat z) { /* Hook implementasyonu */ }

BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(handle);

// İlk koddan alınan işlemler
HMODULE 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"));

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);
if (DetourTransactionCommit() != NO_ERROR) return FALSE;

// İkinci koddan alınan işlemler
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);

// Ana thread'i oluştur
static std::thread main_thread([handle] { MainThread(handle); });
if (main_thread.joinable())
main_thread.detach();

break;
}
case DLL_PROCESS_DETACH:
{
// İlk koddan alınan işlemler
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);
DetourTransactionCommit();

// İkinci koddan alınan işlemler
FreeConsole();
fclose(stdout);

break;
}
}
return TRUE;
}




Al birleştirdik
 
#include <Windows.h>
#include <thread>
#include <detours.h>
#include <cstdio>

// Prototipler
void MainThread(HINSTANCE instance);
using T_glEnable = void(*)(GLenum);
using T_glDisable = void(*)(GLenum);
using T_SwapBuffers = BOOL(WINAPI*)(HDC);
using T_glOrtho = void(*)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
using T_glScalef = void(*)(GLfloat, GLfloat, GLfloat);
using T_glTranslatef = void(*)(GLfloat, GLfloat, GLfloat);

T_glEnable pglEnable = nullptr;
T_glDisable pglDisable = nullptr;
T_SwapBuffers pSwapBuffers = nullptr;
T_glOrtho pglOrtho = nullptr;
T_glScalef pglScalef = nullptr;
T_glTranslatef pglTranslatef = nullptr;

void myglEnable(GLenum cap) { /* Hook implementasyonu */ }
void myglDisable(GLenum cap) { /* Hook implementasyonu */ }
void mySwapBuffers(HDC hdc) { /* Hook implementasyonu */ }
void myglOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) { /* Hook implementasyonu */ }
void myglTranslatef(GLfloat x, GLfloat y, GLfloat z) { /* Hook implementasyonu */ }
void myglScalef(GLfloat x, GLfloat y, GLfloat z) { /* Hook implementasyonu */ }

BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(handle);

// İlk koddan alınan işlemler
HMODULE 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"));

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);
if (DetourTransactionCommit() != NO_ERROR) return FALSE;

// İkinci koddan alınan işlemler
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);

// Ana thread'i oluştur
static std::thread main_thread([handle] { MainThread(handle); });
if (main_thread.joinable())
main_thread.detach();

break;
}
case DLL_PROCESS_DETACH:
{
// İlk koddan alınan işlemler
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);
DetourTransactionCommit();

// İkinci koddan alınan işlemler
FreeConsole();
fclose(stdout);

break;
}
}
return TRUE;
}




Al birleştirdik
@mokokolandiniz knk
void mySwapBuffers(HDC hdc) { /* Hook implementasyonu */ }
kısmına

yalnızca dönüş türleri farklı olan işlevler üzerinde aşırı yükleme yapılamıyor

hatası veriyorhaberin olsun
 
Bu kullanıcıyla herhangi bir iş veya ticaret yapmak istiyorsanız, forumdan uzaklaştırıldığını sakın unutmayın.
@mokokolandiniz knk
void mySwapBuffers(HDC hdc) { /* Hook implementasyonu */ }
kısmına

yalnızca dönüş türleri farklı olan işlevler üzerinde aşırı yükleme yapılamıyor

hatası veriyorhaberin olsun
#include <Windows.h>
#include <thread>
#include <detours.h>
#include <cstdio>

// Prototipler
void MainThread(HINSTANCE instance);
using T_glEnable = void(*)(GLenum);
using T_glDisable = void(*)(GLenum);
using T_SwapBuffers = BOOL(WINAPI*)(HDC);
using T_glOrtho = void(*)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
using T_glScalef = void(*)(GLfloat, GLfloat, GLfloat);
using T_glTranslatef = void(*)(GLfloat, GLfloat, GLfloat);

T_glEnable pglEnable = nullptr;
T_glDisable pglDisable = nullptr;
T_SwapBuffers pSwapBuffers = nullptr;
T_glOrtho pglOrtho = nullptr;
T_glScalef pglScalef = nullptr;
T_glTranslatef pglTranslatef = nullptr;

// Yeni isimle tanımlama
void mySwapBuffersHook(HDC hdc) {
// Hook işlevini buraya ekleyin
// Örnek: HDC ile özel bir işlem
OutputDebugStringA("mySwapBuffersHook çağrıldı\n");
}

void myglEnable(GLenum cap) { /* Hook implementasyonu */ }
void myglDisable(GLenum cap) { /* Hook implementasyonu */ }
void myglOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) { /* Hook implementasyonu */ }
void myglTranslatef(GLfloat x, GLfloat y, GLfloat z) { /* Hook implementasyonu */ }
void myglScalef(GLfloat x, GLfloat y, GLfloat z) { /* Hook implementasyonu */ }

BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(handle);

// İlk koddan alınan işlemler
HMODULE 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"));

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), mySwapBuffersHook); // Yeni isim kullanıldı
DetourAttach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourAttach(reinterpret_cast<void**>(&pglScalef), myglScalef);
if (DetourTransactionCommit() != NO_ERROR) return FALSE;

// İkinci koddan alınan işlemler
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);

// Ana thread'i oluştur
static std::thread main_thread([handle] { MainThread(handle); });
if (main_thread.joinable())
main_thread.detach();

break;
}
case DLL_PROCESS_DETACH:
{
// İlk koddan alınan işlemler
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), mySwapBuffersHook); // Yeni isim kullanıldı
DetourDetach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourDetach(reinterpret_cast<void**>(&pglScalef), myglScalef);
DetourTransactionCommit();

// İkinci koddan alınan işlemler
FreeConsole();
fclose(stdout);

break;
}
}
return TRUE;
}




düzenlendi
 
#include <Windows.h>
#include <thread>
#include <detours.h>
#include <cstdio>

// Prototipler
void MainThread(HINSTANCE instance);
using T_glEnable = void(*)(GLenum);
using T_glDisable = void(*)(GLenum);
using T_SwapBuffers = BOOL(WINAPI*)(HDC);
using T_glOrtho = void(*)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
using T_glScalef = void(*)(GLfloat, GLfloat, GLfloat);
using T_glTranslatef = void(*)(GLfloat, GLfloat, GLfloat);

T_glEnable pglEnable = nullptr;
T_glDisable pglDisable = nullptr;
T_SwapBuffers pSwapBuffers = nullptr;
T_glOrtho pglOrtho = nullptr;
T_glScalef pglScalef = nullptr;
T_glTranslatef pglTranslatef = nullptr;

// Yeni isimle tanımlama
void mySwapBuffersHook(HDC hdc) {
// Hook işlevini buraya ekleyin
// Örnek: HDC ile özel bir işlem
OutputDebugStringA("mySwapBuffersHook çağrıldı\n");
}

void myglEnable(GLenum cap) { /* Hook implementasyonu */ }
void myglDisable(GLenum cap) { /* Hook implementasyonu */ }
void myglOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) { /* Hook implementasyonu */ }
void myglTranslatef(GLfloat x, GLfloat y, GLfloat z) { /* Hook implementasyonu */ }
void myglScalef(GLfloat x, GLfloat y, GLfloat z) { /* Hook implementasyonu */ }

BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(handle);

// İlk koddan alınan işlemler
HMODULE 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"));

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), mySwapBuffersHook); // Yeni isim kullanıldı
DetourAttach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourAttach(reinterpret_cast<void**>(&pglScalef), myglScalef);
if (DetourTransactionCommit() != NO_ERROR) return FALSE;

// İkinci koddan alınan işlemler
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);

// Ana thread'i oluştur
static std::thread main_thread([handle] { MainThread(handle); });
if (main_thread.joinable())
main_thread.detach();

break;
}
case DLL_PROCESS_DETACH:
{
// İlk koddan alınan işlemler
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), mySwapBuffersHook); // Yeni isim kullanıldı
DetourDetach(reinterpret_cast<void**>(&pglTranslatef), myglTranslatef);
DetourDetach(reinterpret_cast<void**>(&pglScalef), myglScalef);
DetourTransactionCommit();

// İkinci koddan alınan işlemler
FreeConsole();
fclose(stdout);

break;
}
}
return TRUE;
}




düzenlendi
denedim normaldehata yok buildlerken fotoğraftaki hatalar var =
 
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 <thread>
#include "hooks.h"

BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved) {
switch (reason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(handle);

// OpenGL işlevlerinin adreslerini alın
HMODULE 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;
}




düzenlendi tekrardan
 
#include <Windows.h>
#include <detours.h>
#include <thread>
#include "hooks.h"

BOOL __stdcall DllMain(HINSTANCE handle, DWORD reason, LPVOID reserved) {
switch (reason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(handle);

// OpenGL işlevlerinin adreslerini alın
HMODULE 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;
}




düzenlendi tekrardan
denedim fotodaki hatalar var =
 
Bu kullanıcıyla herhangi bir iş veya ticaret yapmak istiyorsanız, forumdan uzaklaştırıldığını sakın unutmayın.
discord ekler misin dc:reis60
 

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


Üst Alt