aboutsummaryrefslogtreecommitdiff
path: root/TestDLL
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2019-11-18 21:31:02 +0100
committerToni Uhlig <matzeton@googlemail.com>2019-11-18 21:31:02 +0100
commit01384e8415729b0522553bc5550ef0f8a1969531 (patch)
treedd79b90485694c0e1313d5b819d7f8f42bb6d6e8 /TestDLL
parentfa663d1fb556fd4ca0a367e920b8c02da8238227 (diff)
removed unused code regarding manual dll import resolving, added new radar_entity angle line length value
Diffstat (limited to 'TestDLL')
-rw-r--r--TestDLL/dllmain.cpp174
1 files changed, 5 insertions, 169 deletions
diff --git a/TestDLL/dllmain.cpp b/TestDLL/dllmain.cpp
index 539970f..d6af3d5 100644
--- a/TestDLL/dllmain.cpp
+++ b/TestDLL/dllmain.cpp
@@ -12,171 +12,6 @@
EXTERN_C BOOL WINAPI _CRT_INIT(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);
-#if 0
-struct ResolvedDllEntry {
- const char * const baseDllName;
- const char * const functionName;
-
- HMODULE moduleBase;
- FARPROC resolvedProc;
-};
-
-#define DLL_ENTRY(dll_name, function_name) \
- { dll_name, function_name, NULL, NULL }
-#define MSVCRT_ENTRY(function_name) DLL_ENTRY("msvcrt.dll", function_name)
-
-static struct ResolvedDllEntry resolved_smybols[] = {
- MSVCRT_ENTRY("_errno"),
- MSVCRT_ENTRY("malloc"), MSVCRT_ENTRY("free"), MSVCRT_ENTRY("_callnewh"),
- MSVCRT_ENTRY("_invalid_parameter_noinfo_noreturn"),
- MSVCRT_ENTRY("abort"), MSVCRT_ENTRY("calloc"), MSVCRT_ENTRY("frexp"),
- MSVCRT_ENTRY("islower"), MSVCRT_ENTRY("isspace"), MSVCRT_ENTRY("isupper"),
- MSVCRT_ENTRY("tolower"),
- MSVCRT_ENTRY("ldexp"), MSVCRT_ENTRY("localeconv"), MSVCRT_ENTRY("__pctype_func"),
- MSVCRT_ENTRY("___lc_locale_name_func"), MSVCRT_ENTRY("___lc_codepage_func"),
- MSVCRT_ENTRY("setlocale"),
- MSVCRT_ENTRY("_wcsdup"), MSVCRT_ENTRY("wcslen"), MSVCRT_ENTRY("wcsnlen")
-};
-static const SIZE_T resolved_symbols_size =
-sizeof(resolved_smybols) / sizeof(resolved_smybols[0]);
-
-enum SymbolIndex {
- SYM_ERRNO,
- SYM_MALLOC, SYM_FREE, SYM_CALLNEWH,
- SYM_INVALID_PARAMETER_NOINFO_NORETURN,
- SYM_ABORT, SYM_CALLOC, SYM_FREXP,
- SYM_ISLOWER, SYM_ISSPACE, SYM_ISUPPER,
- SYM_TOLOWER,
- SYM_LDEXP, SYM_LOCALECONV, SYM_PCTYPE,
- SYM_LC_LOCALE_NAME, SYM_LC_CODEPAGE,
- SYM_SETLOCALE,
- SYM_WCSDUP, SYM_WCSLEN, SYM_WCSNLEN,
- NUMBER_OF_SYMBOLS
-};
-
-static_assert(NUMBER_OF_SYMBOLS == resolved_symbols_size, "Invalid number of Symbols in the table/enum");
-
-#define WRAPPER_FUNCTION(symbol_index, linker_function_name, return_type, ...) \
- typedef return_type (* symbol_index ## _FN)(__VA_ARGS__); \
- extern "C" \
- return_type linker_function_name(__VA_ARGS__)
-#define RUN_REAL_FN(symbol_index, ...) \
- (((symbol_index ## _FN)resolved_smybols[symbol_index].resolvedProc)(__VA_ARGS__))
-
-int* __cdecl _errno(void) {
- typedef int*(*SYM_ERRNO_FN)();
- return (((SYM_ERRNO_FN)resolved_smybols[SYM_ERRNO].resolvedProc)());
-}
-WRAPPER_FUNCTION(SYM_MALLOC, malloc, void *, size_t n) {
- return RUN_REAL_FN(SYM_MALLOC, n);
-}
-WRAPPER_FUNCTION(SYM_FREE, free, void, void *p) {
- RUN_REAL_FN(SYM_FREE, p);
-}
-WRAPPER_FUNCTION(SYM_CALLNEWH, _callnewh, int, size_t n) {
- return RUN_REAL_FN(SYM_CALLNEWH, n);
-}
-WRAPPER_FUNCTION(SYM_INVALID_PARAMETER_NOINFO_NORETURN,
- _invalid_parameter_noinfo_noreturn, void, void) {
- ExitProcess(1);
-}
-WRAPPER_FUNCTION(SYM_ABORT, abort, void, void) {
- RUN_REAL_FN(SYM_ABORT);
-}
-WRAPPER_FUNCTION(SYM_CALLOC, calloc, void *, size_t n, size_t s) {
- return RUN_REAL_FN(SYM_CALLOC, n, s);
-}
-WRAPPER_FUNCTION(SYM_FREXP, frexp, double, double x, int *expptr) {
- return RUN_REAL_FN(SYM_FREXP, x, expptr);
-}
-WRAPPER_FUNCTION(SYM_ISLOWER, islower, int, int c) {
- return RUN_REAL_FN(SYM_ISLOWER, c);
-}
-WRAPPER_FUNCTION(SYM_ISSPACE, isspace, int, int c) {
- return RUN_REAL_FN(SYM_ISSPACE, c);
-}
-WRAPPER_FUNCTION(SYM_ISUPPER, isupper, int, int c) {
- return RUN_REAL_FN(SYM_ISUPPER, c);
-}
-WRAPPER_FUNCTION(SYM_TOLOWER, tolower, int, int c) {
- return RUN_REAL_FN(SYM_TOLOWER, c);
-}
-WRAPPER_FUNCTION(SYM_LDEXP, ldexp, double, double x, int exp) {
- return RUN_REAL_FN(SYM_LDEXP, x, exp);
-}
-WRAPPER_FUNCTION(SYM_LOCALECONV, localeconv, struct lconv *, void) {
- return RUN_REAL_FN(SYM_LOCALECONV);
-}
-WRAPPER_FUNCTION(SYM_PCTYPE, __pctype_func, const unsigned short *, void) {
- return RUN_REAL_FN(SYM_PCTYPE);
-}
-WRAPPER_FUNCTION(SYM_LC_LOCALE_NAME, ___lc_locale_name_func, wchar_t **, void) {
- return RUN_REAL_FN(SYM_LC_LOCALE_NAME);
-}
-WRAPPER_FUNCTION(SYM_LC_CODEPAGE, ___lc_codepage_func, UINT, void) {
- return RUN_REAL_FN(SYM_LC_CODEPAGE);
-}
-WRAPPER_FUNCTION(SYM_SETLOCALE, setlocale, char *, int category, const char *locale) {
- return RUN_REAL_FN(SYM_SETLOCALE, category, locale);
-}
-WRAPPER_FUNCTION(SYM_WCSDUP, _wcsdup, wchar_t *, const wchar_t *src) {
- return RUN_REAL_FN(SYM_WCSDUP, src);
-}
-WRAPPER_FUNCTION(SYM_WCSLEN, _wcslen, size_t, const wchar_t *str) {
- return RUN_REAL_FN(SYM_WCSLEN, str);
-}
-WRAPPER_FUNCTION(SYM_WCSNLEN, wcsnlen, size_t, const wchar_t *str, size_t n) {
- return RUN_REAL_FN(SYM_WCSNLEN, str, n);
-}
-
-extern "C"
-void __vcrt_initialize() {}
-extern "C"
-void __vcrt_uninitialize() {}
-extern "C"
-void __vcrt_uninitialize_critical() {}
-extern "C"
-void __vcrt_thread_attach() {}
-extern "C"
-void __vcrt_thread_detach() {}
-extern "C"
-void __acrt_initialize() {}
-extern "C"
-void __acrt_uninitialize() {}
-extern "C"
-void __acrt_uninitialize_critical() {}
-extern "C"
-void __acrt_thread_attach() {}
-extern "C"
-void __acrt_thread_detach() {}
-
-extern "C"
-static bool resolve_all_symbols(void) {
- bool result = true;
-
- for (SIZE_T i = 0; i < 3; ++i) {
- if (resolved_smybols[i].moduleBase) {
- result = false;
- }
- resolved_smybols[i].moduleBase = LoadLibraryA(resolved_smybols[i].baseDllName);
- if (!resolved_smybols[i].moduleBase) {
- result = false;
- continue;
- }
- if (resolved_smybols[i].resolvedProc) {
- result = false;
- }
- resolved_smybols[i].resolvedProc = GetProcAddress(resolved_smybols[i].moduleBase,
- resolved_smybols[i].functionName);
- if (!resolved_smybols[i].resolvedProc) {
- result = false;
- }
- }
-
- return result;
-}
-#endif
-
static gdi_radar_context * ctx = NULL;
static UINT64 pEntSys = 0x0;
static IEntitySystem * iEnt = NULL;
@@ -374,9 +209,6 @@ void APIENTRY LibEntry(struct HuntCtx * HuntCtx)
if (pEnt->GetFlags() & ENTITY_FLAG_LOCAL_PLAYER) {
entCol = entity_color::EC_BLUE;
}
- else if ((pEnt->GetFlags() & ENTITY_ENEMY_CHECK) == 0) {
- entCol = entity_color::EC_BLACK;
- }
Vec3 entPos = pEnt->GetPos();
entPos.x -= 500.0f;
@@ -385,7 +217,11 @@ void APIENTRY LibEntry(struct HuntCtx * HuntCtx)
float entAngle = pEnt->GetWorldAngles().z;
entAngle *= -1.0f;
entAngle -= 1.5707963267948966192313216916398f; /* pi/2 == 90deg */
- entity radar_entity{ (int)entPos.x, (int)entPos.y, entAngle, 100.0f, entCol, "test" };
+ entity radar_entity{
+ (int)entPos.x, (int)entPos.y, entAngle,
+ (entCol == entity_color::EC_BLUE ? 60 : 0),
+ 100.0f, entCol, "test"
+ };
gdi_radar_add_entity(ctx, &radar_entity);
i++;