forked from Public-Mirror/Textractor
continue implementing interop
This commit is contained in:
parent
a5232b605e
commit
a2924f4a2c
3
GUI.sln
3
GUI.sln
@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
VisualStudioVersion = 15.0.27703.2042
|
VisualStudioVersion = 15.0.27703.2042
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GUI", "GUI\GUI.csproj", "{D847D0DC-78F5-4722-8E06-1A124B957353}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GUI", "GUI\GUI.csproj", "{D847D0DC-78F5-4722-8E06-1A124B957353}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{0DF42D0B-0F87-475E-9E2C-9E32776B2AD5} = {0DF42D0B-0F87-475E-9E2C-9E32776B2AD5}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HostInterop", "HostInterop\HostInterop.vcxproj", "{0DF42D0B-0F87-475E-9E2C-9E32776B2AD5}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HostInterop", "HostInterop\HostInterop.vcxproj", "{0DF42D0B-0F87-475E-9E2C-9E32776B2AD5}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -52,6 +52,10 @@
|
|||||||
<Prefer32Bit>true</Prefer32Bit>
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="HostInterop, Version=1.0.6776.17683, Culture=neutral, processorArchitecture=x86">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\Builds\Debug\Debug\HostInterop.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
@ -95,11 +99,5 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\HostInterop\HostInterop.vcxproj">
|
|
||||||
<Project>{0df42d0b-0f87-475e-9e2c-9e32776b2ad5}</Project>
|
|
||||||
<Name>HostInterop</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -92,7 +92,7 @@
|
|||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>..\Builds\Debug\texthook\vnrhost.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>..\Builds\Debug\texthook\vnrhost.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
@ -134,19 +134,12 @@
|
|||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="HostInterop.h" />
|
|
||||||
<ClInclude Include="stdafx.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="AssemblyInfo.cpp" />
|
<ClCompile Include="AssemblyInfo.cpp" />
|
||||||
<ClCompile Include="HostInterop.cpp" />
|
<ClCompile Include="HostInterop.cpp" />
|
||||||
<ClCompile Include="stdafx.cpp">
|
</ItemGroup>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
<ItemGroup>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
<ClInclude Include="HostInterop.h" />
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
@ -6,18 +6,10 @@
|
|||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Header Files">
|
<Filter Include="Header Files">
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
<UniqueIdentifier>{344ee2d7-eda2-4003-8c18-092ff651deb3}</UniqueIdentifier>
|
||||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="HostInterop.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="stdafx.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="HostInterop.cpp">
|
<ClCompile Include="HostInterop.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
@ -25,8 +17,10 @@
|
|||||||
<ClCompile Include="AssemblyInfo.cpp">
|
<ClCompile Include="AssemblyInfo.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="stdafx.cpp">
|
</ItemGroup>
|
||||||
<Filter>Source Files</Filter>
|
<ItemGroup>
|
||||||
</ClCompile>
|
<ClInclude Include="HostInterop.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Binary file not shown.
Binary file not shown.
@ -75,7 +75,7 @@ void ProcessWindow::RefreshProcess()
|
|||||||
void ProcessWindow::AttachProcess()
|
void ProcessWindow::AttachProcess()
|
||||||
{
|
{
|
||||||
DWORD pid = GetSelectedPID();
|
DWORD pid = GetSelectedPID();
|
||||||
if (InjectProcessById(pid))
|
if (InjectProcess(pid))
|
||||||
RefreshThreadWithPID(pid, true);
|
RefreshThreadWithPID(pid, true);
|
||||||
else
|
else
|
||||||
ConsoleOutput(L"NextHooker: could not inject");
|
ConsoleOutput(L"NextHooker: could not inject");
|
||||||
@ -84,7 +84,7 @@ void ProcessWindow::AttachProcess()
|
|||||||
void ProcessWindow::DetachProcess()
|
void ProcessWindow::DetachProcess()
|
||||||
{
|
{
|
||||||
DWORD pid = GetSelectedPID();
|
DWORD pid = GetSelectedPID();
|
||||||
DetachProcessById(pid);
|
::DetachProcess(pid);
|
||||||
RefreshThreadWithPID(pid, false);
|
RefreshThreadWithPID(pid, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,13 +35,13 @@ DWORD ProcessCommand(const std::wstring& cmd, DWORD pid)
|
|||||||
if (regex_match(cmd, m, wregex(L"/p(\\d+)", wregex::icase)))
|
if (regex_match(cmd, m, wregex(L"/p(\\d+)", wregex::icase)))
|
||||||
{
|
{
|
||||||
pid = std::stoul(m[1].str());
|
pid = std::stoul(m[1].str());
|
||||||
InjectProcessById(pid);
|
InjectProcess(pid);
|
||||||
}
|
}
|
||||||
else if (regex_match(cmd, m, wregex(L"/h(.+)", wregex::icase)))
|
else if (regex_match(cmd, m, wregex(L"/h(.+)", wregex::icase)))
|
||||||
{
|
{
|
||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
if (Parse(m[1].str(), hp))
|
if (Parse(m[1].str(), hp))
|
||||||
InsertHook(pid, &hp);
|
InsertHook(pid, hp);
|
||||||
}
|
}
|
||||||
else if (regex_match(cmd, m, wregex(L":(?:h|help)", wregex::icase)))
|
else if (regex_match(cmd, m, wregex(L":(?:h|help)", wregex::icase)))
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
if (StartHost())
|
if (StartHost())
|
||||||
{
|
{
|
||||||
SetUnhandledExceptionFilter(UnhandledExcept);
|
SetUnhandledExceptionFilter(UnhandledExcept);
|
||||||
GetHostHookManager(&man);
|
man = GetHostHookManager();
|
||||||
pfman = new ProfileManager();
|
pfman = new ProfileManager();
|
||||||
DefaultSettings();
|
DefaultSettings();
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
|
@ -488,7 +488,7 @@ void RegisterProcess(DWORD pid)
|
|||||||
{
|
{
|
||||||
for (auto i = pf->Hooks().begin(); i != pf->Hooks().end(); ++i)
|
for (auto i = pf->Hooks().begin(); i != pf->Hooks().end(); ++i)
|
||||||
{
|
{
|
||||||
InsertHook(pid, &i->get()->HP(), toMultiByteString(i->get()->Name()));
|
InsertHook(pid, i->get()->HP(), toMultiByteString(i->get()->Name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,10 +141,9 @@ void HookManager::DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD spl, con
|
|||||||
it->AddText(text, len);
|
it->AddText(text, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HookManager::AddConsoleOutput(LPCWSTR text)
|
void HookManager::AddConsoleOutput(std::wstring text)
|
||||||
{
|
{
|
||||||
HM_LOCK;
|
HM_LOCK;
|
||||||
int len = wcslen(text) * 2;
|
|
||||||
TextThread *console = textThreadsByParams[{ 0, -1UL, -1UL, -1UL }];
|
TextThread *console = textThreadsByParams[{ 0, -1UL, -1UL, -1UL }];
|
||||||
console->AddSentence(std::wstring(text));
|
console->AddSentence(std::wstring(text));
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
void ClearCurrent();
|
void ClearCurrent();
|
||||||
void SelectCurrent(DWORD num);
|
void SelectCurrent(DWORD num);
|
||||||
void SetCurrent(TextThread *it);
|
void SetCurrent(TextThread *it);
|
||||||
void AddConsoleOutput(LPCWSTR text);
|
void AddConsoleOutput(std::wstring text);
|
||||||
void DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD split, const BYTE *text, int len);
|
void DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD split, const BYTE *text, int len);
|
||||||
void RemoveProcessContext(DWORD pid); // private
|
void RemoveProcessContext(DWORD pid); // private
|
||||||
void RemoveSingleHook(DWORD pid, DWORD addr);
|
void RemoveSingleHook(DWORD pid, DWORD addr);
|
||||||
|
@ -78,7 +78,7 @@ DLLEXPORT void CloseHost()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DLLEXPORT bool InjectProcessById(DWORD processId, DWORD timeout)
|
DLLEXPORT bool InjectProcess(DWORD processId, DWORD timeout)
|
||||||
{
|
{
|
||||||
if (processId == GetCurrentProcessId()) return false;
|
if (processId == GetCurrentProcessId()) return false;
|
||||||
|
|
||||||
@ -110,26 +110,26 @@ DLLEXPORT bool InjectProcessById(DWORD processId, DWORD timeout)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLLEXPORT bool DetachProcessById(DWORD processId)
|
DLLEXPORT bool DetachProcess(DWORD processId)
|
||||||
{
|
{
|
||||||
DWORD command = HOST_COMMAND_DETACH;
|
DWORD command = HOST_COMMAND_DETACH;
|
||||||
DWORD unused;
|
DWORD unused;
|
||||||
return WriteFile(man->GetHostPipe(processId), &command, sizeof(command), &unused, nullptr);
|
return WriteFile(man->GetHostPipe(processId), &command, sizeof(command), &unused, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
DLLEXPORT void GetHostHookManager(HookManager** hookman)
|
DLLEXPORT HookManager* GetHostHookManager()
|
||||||
{
|
{
|
||||||
*hookman = man;
|
return man;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLLEXPORT bool InsertHook(DWORD pid, const HookParam *hp, std::string name)
|
DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name)
|
||||||
{
|
{
|
||||||
HANDLE commandPipe = man->GetHostPipe(pid);
|
HANDLE commandPipe = man->GetHostPipe(pid);
|
||||||
if (commandPipe == nullptr) return false;
|
if (commandPipe == nullptr) return false;
|
||||||
|
|
||||||
BYTE buffer[PIPE_BUFFER_SIZE] = {};
|
BYTE buffer[PIPE_BUFFER_SIZE] = {};
|
||||||
*(DWORD*)buffer = HOST_COMMAND_NEW_HOOK;
|
*(DWORD*)buffer = HOST_COMMAND_NEW_HOOK;
|
||||||
*(HookParam*)(buffer + sizeof(DWORD)) = *hp;
|
*(HookParam*)(buffer + sizeof(DWORD)) = hp;
|
||||||
if (name.size()) strcpy((char*)buffer + sizeof(DWORD) + sizeof(HookParam), name.c_str());
|
if (name.size()) strcpy((char*)buffer + sizeof(DWORD) + sizeof(HookParam), name.c_str());
|
||||||
DWORD unused;
|
DWORD unused;
|
||||||
return WriteFile(commandPipe, buffer, sizeof(DWORD) + sizeof(HookParam) + name.size(), &unused, nullptr);
|
return WriteFile(commandPipe, buffer, sizeof(DWORD) + sizeof(HookParam) + name.size(), &unused, nullptr);
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
DLLEXPORT void OpenHost();
|
DLLEXPORT void OpenHost();
|
||||||
DLLEXPORT bool StartHost();
|
DLLEXPORT bool StartHost();
|
||||||
DLLEXPORT void CloseHost();
|
DLLEXPORT void CloseHost();
|
||||||
DLLEXPORT void GetHostHookManager(HookManager **hookman);
|
DLLEXPORT HookManager* GetHostHookManager();
|
||||||
DLLEXPORT bool InjectProcessById(DWORD pid, DWORD timeout = 5000);
|
DLLEXPORT bool InjectProcess(DWORD pid, DWORD timeout = 5000);
|
||||||
DLLEXPORT bool DetachProcessById(DWORD pid);
|
DLLEXPORT bool DetachProcess(DWORD pid);
|
||||||
DLLEXPORT bool InsertHook(DWORD pid, const HookParam *hp, std::string name = "");
|
DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name = "");
|
||||||
DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr);
|
DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr);
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user