2024-09-30 16:06:20 +00:00
|
|
|
// Copyright The Mumble Developers. All rights reserved.
|
2016-05-08 15:34:59 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license
|
|
|
|
// that can be found in the LICENSE file at the root of the
|
|
|
|
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
|
2009-03-13 16:21:41 +00:00
|
|
|
|
2013-01-13 00:14:44 +00:00
|
|
|
#ifndef MUMBLE_LIB_H_
|
|
|
|
#define MUMBLE_LIB_H_
|
2009-03-13 16:21:41 +00:00
|
|
|
|
|
|
|
#define _UNICODE
|
2016-08-21 11:45:04 +00:00
|
|
|
#ifdef _WIN32_WINNT
|
2020-09-11 16:29:33 +00:00
|
|
|
# undef _WIN32_WINNT
|
2016-08-21 11:45:04 +00:00
|
|
|
#endif
|
2020-09-11 16:29:33 +00:00
|
|
|
#define _WIN32_WINNT 0x0501
|
2009-03-13 16:21:41 +00:00
|
|
|
#include <windows.h>
|
2020-09-11 16:29:33 +00:00
|
|
|
#include "HardHook.h"
|
|
|
|
#include "ods.h"
|
|
|
|
#include "overlay.h"
|
|
|
|
#include <boost/optional.hpp>
|
2020-03-19 03:29:42 +00:00
|
|
|
#include <cmath>
|
2020-09-11 16:29:33 +00:00
|
|
|
#include <ctype.h>
|
2009-03-13 16:21:41 +00:00
|
|
|
#include <map>
|
2020-09-11 16:29:33 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
2009-03-13 16:21:41 +00:00
|
|
|
#include <string>
|
2020-09-11 16:29:33 +00:00
|
|
|
#include <vector>
|
2009-03-13 16:21:41 +00:00
|
|
|
|
2020-09-11 16:29:33 +00:00
|
|
|
#define lround(x) static_cast< long int >((x) + (((x) >= 0.0) ? 0.5 : -0.5))
|
2009-03-13 16:21:41 +00:00
|
|
|
|
2013-11-24 22:18:29 +00:00
|
|
|
#define ARRAY_SIZE_BYTES(x) sizeof(x)
|
2020-09-11 16:29:33 +00:00
|
|
|
#define ARRAY_NUM_ELEMENTS(x) (sizeof(x) / sizeof((x)[0]))
|
2013-11-24 22:18:29 +00:00
|
|
|
|
2009-03-13 16:21:41 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
void __cdecl ods(const char *format, ...);
|
|
|
|
|
2020-09-11 16:29:33 +00:00
|
|
|
const int MODULEFILEPATH_BUFLEN = 2048;
|
|
|
|
const int PROCNAMEFILEPATH_BUFLEN = 1024;
|
|
|
|
const int PROCNAMEFILEPATH_EXTENDED_EXTLEN = 64;
|
2013-11-16 12:28:17 +00:00
|
|
|
const int PROCNAMEFILEPATH_EXTENDED_BUFFER_BUFLEN = PROCNAMEFILEPATH_BUFLEN + PROCNAMEFILEPATH_EXTENDED_EXTLEN;
|
|
|
|
|
2009-03-13 16:21:41 +00:00
|
|
|
struct Direct3D9Data {
|
2013-11-16 12:28:17 +00:00
|
|
|
/// Filepath of the module the offsets are for.
|
|
|
|
wchar_t wcFileName[MODULEFILEPATH_BUFLEN];
|
2017-07-10 17:21:53 +00:00
|
|
|
size_t offsetCreate;
|
|
|
|
size_t offsetCreateEx;
|
2009-03-13 16:21:41 +00:00
|
|
|
};
|
|
|
|
|
2009-08-24 15:16:15 +00:00
|
|
|
struct DXGIData {
|
2013-11-16 12:28:17 +00:00
|
|
|
/// Filepath of the module the offsets are for.
|
|
|
|
wchar_t wcFileName[MODULEFILEPATH_BUFLEN];
|
2017-07-10 17:21:53 +00:00
|
|
|
size_t offsetPresent;
|
|
|
|
size_t offsetResize;
|
2013-11-16 12:28:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct D3D10Data {
|
|
|
|
/// Filepath of the module the offsets are for.
|
|
|
|
wchar_t wcFileName[MODULEFILEPATH_BUFLEN];
|
2017-07-10 17:21:53 +00:00
|
|
|
size_t offsetAddRef;
|
|
|
|
size_t offsetRelease;
|
2009-08-24 15:16:15 +00:00
|
|
|
};
|
|
|
|
|
2013-11-30 21:00:56 +00:00
|
|
|
struct D3D11Data {
|
|
|
|
/// Filepath of the module the offsets are for.
|
|
|
|
wchar_t wcFileName[MODULEFILEPATH_BUFLEN];
|
2017-07-10 17:21:53 +00:00
|
|
|
size_t offsetAddRef;
|
|
|
|
size_t offsetRelease;
|
2013-11-30 21:00:56 +00:00
|
|
|
};
|
|
|
|
|
2010-01-24 21:18:56 +00:00
|
|
|
struct SharedData {
|
|
|
|
bool bHooked;
|
|
|
|
};
|
|
|
|
|
2009-03-13 16:21:41 +00:00
|
|
|
class Mutex {
|
2020-09-11 16:29:33 +00:00
|
|
|
protected:
|
|
|
|
static CRITICAL_SECTION cs;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static void init();
|
|
|
|
Mutex();
|
|
|
|
~Mutex();
|
2009-03-13 16:21:41 +00:00
|
|
|
};
|
|
|
|
|
2010-01-24 16:17:07 +00:00
|
|
|
class Pipe {
|
2020-09-11 16:29:33 +00:00
|
|
|
private:
|
|
|
|
HANDLE hSocket;
|
|
|
|
HANDLE hMemory;
|
|
|
|
|
|
|
|
void release();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
unsigned int uiWidth, uiHeight;
|
|
|
|
unsigned int uiLeft, uiTop, uiRight, uiBottom;
|
|
|
|
unsigned char *a_ucTexture;
|
|
|
|
DWORD dwAlreadyRead;
|
|
|
|
OverlayMsg omMsg;
|
|
|
|
|
|
|
|
void checkMessage(unsigned int w, unsigned int h);
|
|
|
|
bool sendMessage(const OverlayMsg &m);
|
|
|
|
virtual void blit(unsigned int x, unsigned int y, unsigned int w, unsigned int h) = 0;
|
|
|
|
virtual void setRect() = 0;
|
|
|
|
virtual void newTexture(unsigned int w, unsigned int h) = 0;
|
|
|
|
Pipe();
|
|
|
|
virtual ~Pipe();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void disconnect();
|
2010-01-24 16:17:07 +00:00
|
|
|
};
|
|
|
|
|
2013-11-24 18:20:24 +00:00
|
|
|
// From lib.cpp
|
2013-11-16 12:28:17 +00:00
|
|
|
extern void checkHooks(bool preonly = false);
|
2013-11-24 18:20:24 +00:00
|
|
|
// From dxgi.cpp
|
2009-08-24 15:16:15 +00:00
|
|
|
extern void checkDXGIHook(bool preonly = false);
|
2013-11-24 18:20:24 +00:00
|
|
|
// From d3d10.cpp
|
2013-11-16 12:28:17 +00:00
|
|
|
extern void checkDXGI10Hook(bool preonly = false);
|
2013-11-30 21:00:56 +00:00
|
|
|
// From d3d11.cpp
|
|
|
|
extern void checkDXGI11Hook(bool preonly = false);
|
2013-11-24 18:20:24 +00:00
|
|
|
// From d3d9.cpp
|
2009-03-13 16:21:41 +00:00
|
|
|
extern void checkD3D9Hook(bool preonly = false);
|
2013-11-24 18:20:24 +00:00
|
|
|
// From opengl.cpp
|
2009-03-13 16:21:41 +00:00
|
|
|
extern void checkOpenGLHook();
|
|
|
|
|
2013-11-24 18:20:24 +00:00
|
|
|
// From d3d9.cpp
|
2009-03-13 16:21:41 +00:00
|
|
|
extern Direct3D9Data *d3dd;
|
2013-11-24 18:20:24 +00:00
|
|
|
// From dxgi.cpp
|
2009-08-24 15:16:15 +00:00
|
|
|
extern DXGIData *dxgi;
|
2013-11-24 18:20:24 +00:00
|
|
|
// From d3d10.cpp
|
2013-11-16 12:28:17 +00:00
|
|
|
extern D3D10Data *d3d10;
|
2013-11-30 21:00:56 +00:00
|
|
|
// From d3d11.cpp
|
|
|
|
extern D3D11Data *d3d11;
|
2013-11-24 18:20:24 +00:00
|
|
|
// From lib.cpp
|
2012-11-15 23:58:32 +00:00
|
|
|
extern BOOL bIsWin8;
|
2009-03-13 16:21:41 +00:00
|
|
|
|
2013-11-24 18:20:24 +00:00
|
|
|
// From lib.cpp
|
2013-11-16 12:28:17 +00:00
|
|
|
/// Checks if the module of the function pointer fnptr equals the module filepath
|
|
|
|
/// of refmodulepath.
|
|
|
|
///
|
|
|
|
/// @param fnptr
|
|
|
|
/// @param refmodulepath the module path to compare against
|
|
|
|
/// @param logPrefix Used for debug logging.
|
|
|
|
/// @param fnName name of the method fnptr points to. used for debug logging
|
|
|
|
/// @return true if the module filepath of the function pointer matches the reference one
|
2020-09-11 16:29:33 +00:00
|
|
|
extern bool IsFnInModule(voidFunc fnptr, wchar_t *refmodulepath, const std::string &logPrefix,
|
|
|
|
const std::string &fnName);
|
2013-11-16 12:28:17 +00:00
|
|
|
|
2013-11-24 18:20:24 +00:00
|
|
|
// From lib.cpp
|
2013-11-16 12:28:17 +00:00
|
|
|
/// Checks fnptr is in a loaded module with module path refmodulepath.
|
|
|
|
///
|
|
|
|
/// @return Offset as int or < 0 on failure.
|
2020-09-11 16:29:33 +00:00
|
|
|
extern boost::optional< size_t > GetFnOffsetInModule(voidFunc fnptr, wchar_t *refmodulepath,
|
|
|
|
unsigned int refmodulepathLen, const std::string &logPrefix,
|
|
|
|
const std::string &fnName);
|
2013-11-16 12:28:17 +00:00
|
|
|
|
2009-03-13 16:21:41 +00:00
|
|
|
#endif
|