OldSchoolHack

Registrieren / Anmelden Deutsch

OSHGUI D3D8 Injection

icon Thema: [Help] OSHGUI D3D8 Injection

Anmeldungsdatum: Jan 2011

Beiträge: 3

hey community!

i have a question oshgui related please.
i just compiled the .lib and sample projects and everything works fine, but im struggling to create a basic menu via DLL injection since the sample projects are exe files creating test 3D3 environments. i want to inject in a D3D8 game..


TEXT Code:
  1.  
  2. /*    Direct3D8 Device */
  3. #define NOMINMAX
  4. #include <windows.h>
  5. #include "main.h"
  6. #include "d3d8.h"
  7. #include <OSHGui.hpp>
  8. #include "Input/WindowsMessage.hpp"
  9. #include "Drawing/Direct3D8/Direct3D8Renderer.hpp"
  10.  
  11. #define D3DHOOK_TEXTURES //comment this to disable texture hooking
  12.  
  13. using namespace OSHGui;
  14. using namespace OSHGui::Drawing;
  15.  
  16. FontPtr font;
  17. //Application &app;
  18.  
  19. HRESULT CD3DManager::Initialize()
  20. {
  21.     /*
  22.     initialize Resources such as textures
  23.     (managed and unmanaged [D3DPOOL]),
  24.     vertex buffers, and other D3D rendering resources
  25.     ...
  26.     m_pD3Ddev->CreateTexture(..., ..., &m_pD3Dtexture);
  27.     */
  28.  
  29.     std::unique_ptr<Direct3D8Renderer> renderer(new Direct3D8Renderer(m_pD3Ddev));
  30.  
  31.     Application::Initialize(std::move(renderer));
  32.  
  33.     auto &app = Application::Instance();
  34.  
  35.     //3. create a font which will be used by the OSHGui
  36.     font = FontManager::LoadFont("Arial", 8.0f, false); //Arial, 8PT, no anti-aliasing
  37.     app.SetDefaultFont(font);
  38.  
  39.     //4. create our form
  40.     auto form = std::make_shared<Form>();
  41.     form->SetText("Test");
  42.  
  43.     //5. set this form as our mainform
  44.     app.Run(form);
  45.  
  46.     //optional: enable the OSHGui drawing
  47.     app.Enable();
  48.  
  49.     //optional: register a Hotkey with which we can toggle the OSHGui drawing
  50.     app.RegisterHotkey(Hotkey(Key::Insert, []
  51.     {
  52.         Application::Instance().Toggle();
  53.     }));
  54.  
  55.     return S_OK;
  56. }
  57.  
  58. HRESULT APIENTRY hkIDirect3DDevice8::EndScene(void)
  59. {
  60.     auto &renderer = Application::Instance().GetRenderer();
  61.  
  62.     //1. let our renderer begin its work
  63.     renderer.BeginRendering();
  64.  
  65.     //2. render the OSHGui
  66.     Application::Instance().Render();
  67.  
  68.     //3. end the rendering
  69.     renderer.EndRendering();
  70.  
  71.     return m_pD3Ddev->EndScene();
  72. }
  73.  



my DLLMain:


TEXT Code:
  1. bool WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved)
  2. {
  3.     if(dwReason == DLL_PROCESS_ATTACH)
  4.     {
  5.         DisableThreadLibraryCalls(hDll);
  6.  
  7.         GetModuleFileName(hDll, dlldir, 512);
  8.         for(int i = strlen(dlldir); i > 0; i--) { if(dlldir == '\\') { dlldir[i+1] = 0; break; } }
  9.  
  10.  
  11.         HMODULE hMod = LoadLibrary("d3d8.dll");       
  12.    
  13.         oDirect3DCreate8 = (tDirect3DCreate8)DetourFunc(
  14.             (BYTE*)GetProcAddress(hMod, "Direct3DCreate8"),
  15.             (BYTE*)hkDirect3DCreate8,
  16.             5);
  17.  
  18.         return true;
  19.     }
  20.  
  21.     else if(dwReason == DLL_PROCESS_DETACH)
  22.     {
  23.        
  24.     }
  25.  
  26.     return false;
  27. }
  28.  


i have the oshgui files and the sdk in my includes, the sdk and .lib from osh i compiled in my libraryincludes.
oshgui.lib is also linked as additional dependencys.
also added cpp's/header from \Drawing\Direct3D8 to my project.

it compiles fine but the testwindow from the gui dont show up and the game also dont crash, it just nothing happens.
if you can point me in the right direction i would be glad..thanks.

i tried to solve it with the DLL example code from here but it seems its for an older oshgui version:
[Source] Beispielcode für eine Hack-DLL

best regards