Where im failing on native dll?

Spectre

Интересующийся
Пользователь
Сообщения
23
Розыгрыши
0
Репутация
0
Реакции
3
Баллы
335
So im trying to make a native dll since im so bored to keep using a limited library for interface, at the moment this is the code:

C++:
#include "SpectrePrivate.h"


IMPLEMENT_PACKAGE(Spectre);


//extern "C" DLL_EXPORT TCHAR GPackage[];
//DLL_EXPORT TCHAR GPackage[] = TEXT("Spectre");


IMPLEMENT_CLASS(AUIEvents);


IMPLEMENT_FUNCTION(AUIEvents, -1, execgetNewLog);


void AUIEvents::execgetNewLog(FFrame& Stack, RESULT_DECL)
{
    guard(AUIEvents::execgetNewLog)
    P_FINISH;


    //G->Logf(TEXT("in new print log() "));
    GLog->Logf(TEXT("in new log() "));


    *(TCHAR**)Result = TEXT("Just a test");


    unguardexec;
}

At my mind it was normal but when i open L2 i get Critical Error:




Could anyone give me a light on it?
 

how are u trying to execute that dll with l2?
u added on l2.exe import ?
maybe doing via interface to open via a new super class?
 
Im trying to make new native functions with a new dll, so its nothing related to import on l2.exe
 
so the game will magically hook on a new dll? xd
 
Since its native, i guess its supposed he find the dll of the same name from .u file
 
So im trying to make a native dll since im so bored to keep using a limited library for interface, at the moment this is the code:

C++:
#include "SpectrePrivate.h"


IMPLEMENT_PACKAGE(Spectre);


//extern "C" DLL_EXPORT TCHAR GPackage[];
//DLL_EXPORT TCHAR GPackage[] = TEXT("Spectre");


IMPLEMENT_CLASS(AUIEvents);


IMPLEMENT_FUNCTION(AUIEvents, -1, execgetNewLog);


void AUIEvents::execgetNewLog(FFrame& Stack, RESULT_DECL)
{
    guard(AUIEvents::execgetNewLog)
    P_FINISH;


    //G->Logf(TEXT("in new print log() "));
    GLog->Logf(TEXT("in new log() "));


    *(TCHAR**)Result = TEXT("Just a test");


    unguardexec;
}

At my mind it was normal but when i open L2 i get Critical Error:




Could anyone give me a light on it?
You can use:

Don't forget post source code after release to help people who have same problems.
 
You can use:

Don't forget post source code after release to help people who have same problems.
i checked the post so what i got, is that you need to hook the Core with the Address of the function and pass the function itself, but how should i use this hookcore? make a dll entry? i made some kind of entry, but i couldnt get how it gonna work?

C++:
#include "stdafx.h"
#include "Core\Inc\Core.h"
#include "Engine\Inc\Engine.h"


#define RESULT_DECL void* const Result
typedef void(*NativeFunc)(FFrame& stack, RESULT_DECL);
typedef BYTE(__cdecl* GRegisterNative_fnType)(INT iNative, NativeFunc Func);
GRegisterNative_fnType volatile GRegisterNative_fn = NULL;

extern "C" DLL_EXPORT TCHAR GPackage[];
DLL_EXPORT TCHAR GPackage[] = TEXT("Spectre");

void hookCore();

BOOL APIENTRY UIEvents( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        hookCore();
        break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

//extern "C" DLL_EXPORT TCHAR GPackage[];
//DLL_EXPORT TCHAR GPackage[] = TEXT("Spectre");

void execgetNewLog(FFrame& Stack, RESULT_DECL)
{
    //guard(AUIEvents::getNewLog)
        //P_FINISH;

    *(const TCHAR**)Result = TEXT("Just a test");
    
    //unguardexec;
}

void hookCore()
{
    auto hCore = GetModuleHandleA("Core.dll");

    if (hCore) {
        GRegisterNative_fn = (GRegisterNative_fnType)GetProcAddress(hCore, "?GRegisterNative@@YAEHABQ8UObject@@AEXAAUFFrame@@QAX@Z@Z");

        if (GRegisterNative_fn)
        {
            GRegisterNative_fn(-1, &execgetNewLog);
        }
    }
}

atm this is the code and im getting the same error.
 
C++:
BOOL APIENTRY UIEvents( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        hookCore();
        break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}
What is UIEvents? maybe DllMain?
 
Последнее редактирование:
Spectre, what is UIEvents? maybe DllMain?
Well on my knowledge i guess it was supposed to connect to Spectre.UIEvents, where Spectre is the File and UIEvents is the class like on .u file, inside Spectre.u theres a class called UIEvents.uc, so i was thinking its the same for dll or was it my mistake?
 
Well on my knowledge i guess it was supposed to connect to Spectre.UIEvents, where Spectre is the File and UIEvents is the class like on .u file, inside Spectre.u theres a class called UIEvents.uc, so i was thinking its the same for dll or was it my mistake?
This code uses an entry point with an incorrect function name. I have provided a link to more detailed information above. This is if you are trying to connect your DLL and during its initialization get a reference to a certain function from the Core.dll
 
Works? Write post there with examples and sources + includes in zip. 🤔
 
I did the changes but i get the same error
 
I guess thats not the right way to make it work
you will have to inject the DLL anyway, otherwise it won't work

C++:
#include "stdafx.h"

extern "C" __declspec(dllexport)
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) // APIENTRY is alias WINAPI
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    {
        MessageBox(nullptr, L"DLL_PROCESS_ATTACH", L"DllMain", MB_OK);
        break;
    }
    case DLL_THREAD_ATTACH:
    {
        //MessageBox(nullptr, L"DLL_THREAD_ATTACH", L"DllMain", MB_OK);
        break;
    }
    case DLL_THREAD_DETACH:
    {
        //MessageBox(nullptr, L"DLL_THREAD_DETACH", L"DllMain", MB_OK);
        break;
    }
    case DLL_PROCESS_DETACH:
    {
        //MessageBox(nullptr, L"DLL_PROCESS_DETACH", L"DllMain", MB_OK);
        break;
    }
    }
    return TRUE;
}

1723715003987.png

1723715109843.png
 
Вы не правильно поняли автора темы он хочет вызывать нативные функции из своей dll, используя скрипт *.uc который лежит в своем пакете *.u
Хотелось бы тоже узнать как это сделать)
 
Вы не правильно поняли автора темы он хочет вызывать нативные функции из своей dll, используя скрипт *.uc который лежит в своем пакете *.u
Хотелось бы тоже узнать как это сделать)
thats what i first understood too, then i asked the author how he would do the hook the dll but he wants to do a native call, to do a native call you need to import through cff with a known original native dll
 
Вы не правильно поняли автора темы он хочет вызывать нативные функции из своей dll, используя скрипт *.uc который лежит в своем пакете *.u
Хотелось бы тоже узнать как это сделать)
Там пример есть, но что-то не то)
Хотелось бы не только вызывать код внутри dll, но и получать из dll например string с текстом.
Хорошо бы разобраться в этом и выложить готовые исходники с инклудами в ресурсы.
 
Там пример есть, но что-то не то)
Хотелось бы не только вызывать код внутри dll, но и получать из dll например string с текстом.
Хорошо бы разобраться в этом и выложить готовые исходники с инклудами в ресурсы.
Maybe this is not the case for the author of the post, but unfortunately the vast majority of people are only looking for solutions. When they find the solution to their problem, they simply disappear without trying to help others on the forum or in the future who are looking for something along the same lines.
 
Maybe this is not the case for the author of the post, but unfortunately the vast majority of people are only looking for solutions. When they find the solution to their problem, they simply disappear without trying to help others on the forum or in the future who are looking for something along the same lines.
Guess current author want only changes for future mods on client or interface.
Need anyway custom dll, but we miss anything in code.
Hope anyone do custom code with examples in uc and upload to resources there.
 
Назад
Сверху Снизу