Skip to content

Commit 8420eaf

Browse files
authored
added some info
1 parent 2ce3155 commit 8420eaf

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,53 @@
11
# d3d9_wrapper
22

3+
[![Build status](https://ci.appveyor.com/api/projects/status/4dxo5hw1sq6p67lx?svg=true)](https://ci.appveyor.com/project/megai2/d3d9-wrapper)
4+
35
Wrapper for d3d9 API that includes hooking and custom d3d9 loading
46

7+
## How API functions are hooked?
8+
9+
API functions is wrapped around with event triggers this way:
10+
11+
```
12+
wrapped_API_function(params) {
13+
trigger_event(API_function_pre, params);
14+
ret = API_function(params)
15+
trigger_event(API_function_post, params, ret);
16+
}
17+
```
18+
19+
Currently only IDirect3D9 and IDirect3DDevice9 calls are wrapped.
20+
21+
## How to work with this?
22+
23+
Here is quick sample on how to draw something before Present call
24+
25+
```
26+
#include "gw2al_d3d9_wrapper.h"
27+
#include "gw2al_api.h"
28+
29+
gw2al_api_ret gw2addon_load(gw2al_core_vtable* core_api)
30+
{
31+
//get loader api
32+
gw2al_core_vtable* gAPI = core_api;
33+
34+
//get d3d9 wrapper enable_event function
35+
D3D9_wrapper d3d9_wrap;
36+
d3d9_wrap.enable_event = (pD3D9_wrapper_enable_event)gAPI->query_function(gAPI->hash_name((wchar_t*)D3D9_WRAPPER_ENABLE_EVENT_FNAME));
37+
38+
//enable IDirect3DDevice9::Present pre API-call event
39+
d3d9_wrap.enable_event(METH_DEV_Present, WRAP_CB_PRE);
40+
41+
//watch for this event with OnDevPrePresent callback
42+
D3D9_WRAPPER_WATCH_EVENT(L"change_me", L"D3D9_PRE_DEV_Present", DrawSomethingBeforePresent, 0);
43+
}
44+
45+
void DrawSomethingBeforePresent(D3D9_wrapper_event_data* evd)
46+
{
47+
//evd contains pointers to API return data and original call stack pointer
48+
//TODO: draw something
49+
}
50+
51+
```
552

6-
Look include/gw2al_d3d9_wrapper.h for details for now.
53+
Look include/gw2al_d3d9_wrapper.h for details.

0 commit comments

Comments
 (0)