From 8ae1c4e9ebab6ec4f2a1d195f540f32e8c0b3aa4 Mon Sep 17 00:00:00 2001 From: Attila Body Date: Mon, 8 Apr 2024 15:40:31 +0200 Subject: [PATCH] Initial commit --- .clang-format | 32 +++++++++++ .cproject | 123 +++++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++ .project | 27 ++++++++++ src/hooking_test.cpp | 33 ++++++++++++ 5 files changed, 218 insertions(+) create mode 100644 .clang-format create mode 100644 .cproject create mode 100644 .gitignore create mode 100644 .project create mode 100644 src/hooking_test.cpp diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..10b1ece --- /dev/null +++ b/.clang-format @@ -0,0 +1,32 @@ +BasedOnStyle: LLVM +UseTab: Never +IndentWidth: 4 +TabWidth: 4 +BreakBeforeBraces: Custom +AllowShortFunctionsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLambdasOnASingleLine: true +AllowAllArgumentsOnNextLine: true +IndentCaseLabels: true +AccessModifierOffset: -4 +NamespaceIndentation: All +FixNamespaceComments: false +PackConstructorInitializers: Never +AlignAfterOpenBracket: AlwaysBreak +BraceWrapping: + AfterClass: true # false + AfterControlStatement: false + AfterEnum: true # false + AfterFunction: true # false + AfterNamespace: true # false + AfterObjCDeclaration: true # false + AfterStruct: true # false + AfterUnion: true # false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +ColumnLimit: 140 diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..a76c5d7 --- /dev/null +++ b/.cproject @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b8b9e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.settings/ +/Debug/ +/Release/ \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..4fb6dea --- /dev/null +++ b/.project @@ -0,0 +1,27 @@ + + + hooking_test + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/src/hooking_test.cpp b/src/hooking_test.cpp new file mode 100644 index 0000000..74c8f60 --- /dev/null +++ b/src/hooking_test.cpp @@ -0,0 +1,33 @@ +//============================================================================ +// Name : hooking_test.cpp +// Author :Attila Body +//============================================================================ +#include + +#include + +using namespace std; + +class C +{ +public: + void foo(int bar) + { + cout << reinterpret_cast(this) << " -> " << bar << endl; + } +}; + +typedef void (C::*cvifptr_t)(int); +typedef void (*vifptr_t)(int, int); + +int main(int argc, char **argv) +{ + C c; + cvifptr_t zup = &C::foo; + cout << zup << endl; + vifptr_t baz = reinterpret_cast(zup); + cout << baz << endl; + (c.*zup)(123); + (*baz)(1234, 321); + return 0; +}