This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

76
hookproc/APIENTRY.HPP Normal file
View File

@@ -0,0 +1,76 @@
#ifndef _HOOKPROC_APIENTRY_HPP_
#define _HOOKPROC_APIENTRY_HPP_
#ifndef _COMMON_CODEGEN_HPP_
#include <common/codegen.hpp>
#endif
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
class APIEntry : private CodeGen
{
public:
APIEntry(DWORD stackLength,DWORD instanceAddress,DWORD hookAddress);
virtual ~APIEntry();
DWORD codeBase(void)const;
protected:
void entryPoint(DWORD entryPoint);
private:
enum {CodeLength=1024,FirstArgument=8,IATOffset=5,IATInstance=9};
APIEntry(const APIEntry &someAPIEntry);
APIEntry &operator=(const APIEntry &someAPIEntry);
void createThunk(DWORD stackLength);
void saveIATAddress(DWORD hookAddress);
void saveIATInstance(DWORD instanceAddress);
};
inline
APIEntry::APIEntry(DWORD stackLength,DWORD instanceAddress,DWORD hookAddress)
: CodeGen(CodeLength)
{
createThunk(stackLength);
saveIATAddress(hookAddress);
saveIATInstance(instanceAddress);
}
inline
APIEntry::APIEntry(const APIEntry &/*someAPIEntry*/)
{ // no implementation
}
inline
APIEntry::~APIEntry()
{
}
inline
APIEntry &APIEntry::operator=(const APIEntry &/*someAPIEntry*/)
{ // no implementation
return *this;
}
inline
DWORD APIEntry::codeBase(void)const
{
return base();
}
inline
void APIEntry::saveIATAddress(DWORD hookAddress)
{
((PureViewOfFile&)((CodeGen&)*this)).push();
((PureViewOfFile&)((CodeGen&)*this)).seek(IATOffset,PureViewOfFile::SeekSet);
((PureViewOfFile&)((CodeGen&)*this)).write((int)hookAddress);
((PureViewOfFile&)((CodeGen&)*this)).pop();
}
inline
void APIEntry::saveIATInstance(DWORD instanceAddress)
{
((PureViewOfFile&)((CodeGen&)*this)).push();
((PureViewOfFile&)((CodeGen&)*this)).seek(IATInstance,PureViewOfFile::SeekSet);
((PureViewOfFile&)((CodeGen&)*this)).write((int)instanceAddress);
((PureViewOfFile&)((CodeGen&)*this)).pop();
}
#endif