KN4CK3R / OSHGui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unresolved external symbol for Drawing::Direct3D9Renderer

sharky1001 opened this issue · comments

I'm new to OSHGui. I'm trying to follow the examples in your website.
I first compiled all external dependencies. Then I compiled the static library.
Then I included the source files and linked the library to my project.

Some class and function names seem to be changed with current lib, compared to the examples on your website. I've (hopefully) fixed these correctly. All compiler errors are gone in Visual Studio. However I still can't compile, im getting this linker error.

Screenshot_2

Screenshot_1

Thanks in advance

Because of the different dependencies of every renderer they are not included in the library build. If your project needs the D3D9 renderer you have to manually add the cpp files from /Drawing/Direct3D9 to your project. Then the linker error should be gone.

<ClCompile Include="..\..\Drawing\Direct3D9\Direct3D9GeometryBuffer.cpp" />
<ClCompile Include="..\..\Drawing\Direct3D9\Direct3D9Renderer.cpp" />
<ClCompile Include="..\..\Drawing\Direct3D9\Direct3D9Texture.cpp" />
<ClCompile Include="..\..\Drawing\Direct3D9\Direct3D9TextureTarget.cpp" />
<ClCompile Include="..\..\Drawing\Direct3D9\Direct3D9ViewportTarget.cpp" />
<ClCompile Include="..\..\Input\WindowsMessage.cpp" />

Don't forget to link to the D3D9 runtime files too.

<AdditionalDependencies>oshgui_d.lib;d3d9.lib;d3dx9.lib;%(AdditionalDependencies)</AdditionalDependencies>

Where i can take "oshgui_d.lib"?

After compiling the OSHGui_StaticLibrary.vcxproj project you get the static library to link against.

Create VS2019 version. Too much errors with VS2017

@KN4CK3R thanks alot, that fixed it!

So I managed to show the form ingame, using your examples. However, only oshgui form shows, ingame graphics don't render. I believe this is because with the while(true) loop, we're rendering our own stuff, and then calling BeginScene, EndScene and Present functions ourselves and causing game to not be able to render itself.
Is this by any means correct or am I making up?

With this thought, I created a small hook for EndScene. First I call the original code where I placed my hook. Then I'm calling my own function, which basically just does BeginRendering/Render/EndRendering. Then i am jumping back to original EndScene. And like this, only game will render, no oshgui form anywhere.

I'm really sorry for asking like this, I can't find much to follow about oshgui :/

Could you show the code of your hooked method? There shouldn't be a while loop for the gui.

It's pretty much the Render function in your sample application, except it doesn't call directx functions from the vtable.

Screenshot_1

In your sample app, there is a while loop in WinMain that calls Render() until the loop breaks.

I compile VS2017 static library HELP!
image

@CovERUshKA
go to Dependencies\Source, open the solution and compile the dependencies first. Then you can compile the static library.

Oh my God. This is a real quest! Thanks!

Two more errors(in my project)
image

@CovERUshKA Please make a new issue if you don't have the same problem as sharky1001.

@sharky1001 How do you initialize the gui? This pseudo code shows how I use it in my hacks:

EndScene_Hooked(D3D9Device device)
{
	once
	{
		renderer = new Direct3D9Renderer(device)
		Application.Initialize(renderer);

		font = FontManager.LoadFont(...);
		Application.SetDefaultFont(font);

		Application.RegisterHotkey(Hotkey(Key::Insert, []()
		{
			Application.Toggle();
		}));

		form = new MainForm();
		Application.Run(form);
	}

	input.PopulateMessages();

	renderer = Application.GetRenderer();
	renderer.BeginRendering();

	Application.Render();

	renderer.EndRendering();

	EndScene_Original(device);
}

As input I often use a GWLP_WNDPROC hook.

No changes again, pretty much out of the box code.
So InitalizeOSHGui is called once, then I place my hook.

Screenshot_3

Screenshot_4

Just to be sure, your endscene hook works? A simple test would be a device->Clear rectangle.

Im adding a messagebox to the function and it spams like crazy.
The endscene hooked function has this:
deviceAddr->Clear(0, 0, D3DCLEAR_TARGET, 0, 1.0f, 0);

What you mean by clear rectangle? Should I pass a D3DRECT pointer to this function?

Could you let me see your code? If it is not public you may send it to me in private on admin [at] oldschoolhack [dot] me.

Hey again,
So I felt like I should keep trying more before I sent you the code, so I finally achieved it. It was the DirectX pointer I passed to the Application::Initalize(), it was wrong. Ever since I fixed it yesterday, I'm struggling with handling the input... I've literally checked every source available using OSH, and I feel like im not missing anything:

Screenshot_5
Screenshot_6
(I've also cleaned my hooks a little)

The window will render just fine ingame, but input.ProcessMessage() always returns false.
The return comes from return InjectMouseMessage(MouseMessage(state, button, location, delta));.

It's like the window doesn't exist, even my inputs on the window are passed to the game.

Did you debug one layer deeper to see where in Application.ProcessMouseMessage the return false occurs?

SetWindowLongA returns a function pointer you should use in your WndProcHook to call the original function.

Okay, I changed my method of calling original WndProc, I now store the function pointer returned by SetWindowLongA and call it in my hook.

So upon debugging one layer deeper, i see it immediately returns false at the beginning:

if (!isEnabled_) { return false; }

I don't understand why it's like that, I do enable the application instance within my InitalizeOSHGui function.

So I commented it and it passed the if (formManager_.GetFormCount() > 0) check, and it returned false at the of the function.

Then I don't know what you do. 😄 I have added a sample project which hooks D3D9 and draws the gui.

https://github.com/KN4CK3R/OSHGui/blob/master/Projects/Code/OSHGui_Hook_Sample.cpp

Actually, doesn't look very different from mine... I'll test and report back, thanks for the sample!
Edit. Btw I'm not hooking Reset function, is this compulsory for input parsing?

No, Reset is only needed for drawing. If you minimize a full screen app the render needs to reinitialize all objects.

Just before I lost my mind, I noticed my wParam and lParam are flipped... as you can see in #12 (comment) ...

Thank you alot again and sorry for wasting your time with a stupid thing like this :(

Hey again @KN4CK3R , didn't want to create a new issue for such a small thing.
I can't handle the MouseScrollEvent for some controls I need (PictureBox, Panel). I could only get it working with ListBox, which has a scroll event handler by default, i think that's why.
Is this intended behaviour or how can I fix this?

Edit:
I just found out that I can set a control's _isFocusable = true and then I will get messages for scrolling...
Must be a really bad practice though...

Some controls are just not focusable, so they don't receive all events. If you need them to be focusable you could derive from the control and set _isFocusable = true; or just change it in the original code. The OSHGui logic is inspired by MS WinForms. There you need to enable this feature with a workaround too (https://stackoverflow.com/questions/3562235/panel-not-getting-focus)

i have the same issue even though have linked the required dependencies

see the first reply