chore: Apply code formatting on entire codebase for consistent style

This commit is contained in:
icex2
2023-04-06 15:39:53 +02:00
committed by icex2
parent a1a849aef3
commit 031836ef0e
186 changed files with 2446 additions and 1979 deletions
+50 -31
View File
@@ -1,5 +1,5 @@
#include <windows.h>
#include <unknwn.h>
#include <windows.h>
#include <assert.h>
#include <stdint.h>
@@ -8,63 +8,84 @@
#include "hook/com-proxy.h"
static void com_proxy_free(struct com_proxy *proxy);
static HRESULT STDMETHODCALLTYPE com_proxy_query_interface(
IUnknown *unk,
REFIID iid,
void **iface);
static HRESULT STDMETHODCALLTYPE
com_proxy_query_interface(IUnknown *unk, REFIID iid, void **iface);
static ULONG STDMETHODCALLTYPE com_proxy_addref(IUnknown *unk);
static ULONG STDMETHODCALLTYPE com_proxy_release(IUnknown *unk);
#ifdef __amd64
/***** 64-BIT TRAMPOLINE *****/
/***** 64-BIT TRAMPOLINE *****/
#define SLOT_OFFSET 0x0A
static const uint8_t com_proxy_tramp[] = {
/* mov rcx, [rcx+8] ; Get this->real */
0x48, 0x8B, 0x49, 0x08,
0x48,
0x8B,
0x49,
0x08,
/* mov rax, [rcx] ; Get this->vtbl */
0x48, 0x8B, 0x01,
0x48,
0x8B,
0x01,
/* mov rax, [rax+XX] ; Get vtbl->slot_XX */
0x48, 0x8B, 0x80, -1, -1, -1, -1,
0x48,
0x8B,
0x80,
-1,
-1,
-1,
-1,
/* jmp rax ; Continue to slot_XX */
0xFF, 0xE0,
0xFF,
0xE0,
};
#else
/***** 32-BIT TRAMPOLINE *****/
/***** 32-BIT TRAMPOLINE *****/
#define SLOT_OFFSET 0x0F
static const uint8_t com_proxy_tramp[] = {
/* mov eax, [esp+4] ; Get this */
0x8B, 0x44, 0x24, 0x04,
0x8B,
0x44,
0x24,
0x04,
/* mov eax, [eax+4] ; Get this->real */
0x8B, 0x40, 0x04,
0x8B,
0x40,
0x04,
/* mov [esp+4], eax ; Replace this with this->real on stack */
0x89, 0x44, 0x24, 0x04,
0x89,
0x44,
0x24,
0x04,
/* mov ecx, [eax] ; Get this->vtbl */
0x8B, 0x08,
0x8B,
0x08,
/* mov ecx, [ecx+XX] ; Get vtbl->slot_XX */
0x8B, 0x89, -1, -1, -1, -1,
0x8B,
0x89,
-1,
-1,
-1,
-1,
/* jmp ecx ; Continue to slot_XX */
0xFF, 0xE1
};
0xFF,
0xE1};
#endif
HRESULT com_proxy_wrap(
struct com_proxy **out,
void *real,
size_t vtbl_size)
HRESULT com_proxy_wrap(struct com_proxy **out, void *real, size_t vtbl_size)
{
struct com_proxy *proxy;
void **vtbl;
@@ -97,10 +118,10 @@ HRESULT com_proxy_wrap(
nslots = vtbl_size / sizeof(void *);
proxy->tramps = VirtualAlloc(
NULL,
sizeof(com_proxy_tramp) * nslots,
MEM_RESERVE | MEM_COMMIT,
PAGE_EXECUTE_READWRITE);
NULL,
sizeof(com_proxy_tramp) * nslots,
MEM_RESERVE | MEM_COMMIT,
PAGE_EXECUTE_READWRITE);
if (proxy->tramps == NULL) {
hr = E_OUTOFMEMORY;
@@ -119,7 +140,7 @@ HRESULT com_proxy_wrap(
/* Populate trampoline code for remaining vtbl entries */
for (i = 3 /* Skip IUnknown */ ; i < nslots ; i++) {
for (i = 3 /* Skip IUnknown */; i < nslots; i++) {
cur_tramp = proxy->tramps + i * sizeof(com_proxy_tramp);
/* Copy template */
@@ -160,10 +181,8 @@ static void com_proxy_free(struct com_proxy *proxy)
free(proxy);
}
static HRESULT STDMETHODCALLTYPE com_proxy_query_interface(
IUnknown *unk,
REFIID iid,
void **iface)
static HRESULT STDMETHODCALLTYPE
com_proxy_query_interface(IUnknown *unk, REFIID iid, void **iface)
{
struct com_proxy *proxy;
IUnknown *obj;