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
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
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
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HostInterop", "HostInterop\HostInterop.vcxproj", "{0DF42D0B-0F87-475E-9E2C-9E32776B2AD5}"
|
||||
EndProject
|
||||
|
@ -52,6 +52,10 @@
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<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.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@ -95,11 +99,5 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</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" />
|
||||
</Project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -92,7 +92,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>..\Builds\Debug\texthook\vnrhost.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@ -134,19 +134,12 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="HostInterop.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AssemblyInfo.cpp" />
|
||||
<ClCompile Include="HostInterop.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="HostInterop.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -6,18 +6,10 @@
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<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>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="HostInterop.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="HostInterop.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
@ -25,8 +17,10 @@
|
||||
<ClCompile Include="AssemblyInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="HostInterop.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Binary file not shown.
Binary file not shown.
@ -75,7 +75,7 @@ void ProcessWindow::RefreshProcess()
|
||||
void ProcessWindow::AttachProcess()
|
||||
{
|
||||
DWORD pid = GetSelectedPID();
|
||||
if (InjectProcessById(pid))
|
||||
if (InjectProcess(pid))
|
||||
RefreshThreadWithPID(pid, true);
|
||||
else
|
||||
ConsoleOutput(L"NextHooker: could not inject");
|
||||
@ -84,7 +84,7 @@ void ProcessWindow::AttachProcess()
|
||||
void ProcessWindow::DetachProcess()
|
||||
{
|
||||
DWORD pid = GetSelectedPID();
|
||||
DetachProcessById(pid);
|
||||
::DetachProcess(pid);
|
||||
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)))
|
||||
{
|
||||
pid = std::stoul(m[1].str());
|
||||
InjectProcessById(pid);
|
||||
InjectProcess(pid);
|
||||
}
|
||||
else if (regex_match(cmd, m, wregex(L"/h(.+)", wregex::icase)))
|
||||
{
|
||||
HookParam 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)))
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
if (StartHost())
|
||||
{
|
||||
SetUnhandledExceptionFilter(UnhandledExcept);
|
||||
GetHostHookManager(&man);
|
||||
man = GetHostHookManager();
|
||||
pfman = new ProfileManager();
|
||||
DefaultSettings();
|
||||
LoadSettings();
|
||||
|
@ -488,7 +488,7 @@ void RegisterProcess(DWORD pid)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void HookManager::AddConsoleOutput(LPCWSTR text)
|
||||
void HookManager::AddConsoleOutput(std::wstring text)
|
||||
{
|
||||
HM_LOCK;
|
||||
int len = wcslen(text) * 2;
|
||||
TextThread *console = textThreadsByParams[{ 0, -1UL, -1UL, -1UL }];
|
||||
console->AddSentence(std::wstring(text));
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
void ClearCurrent();
|
||||
void SelectCurrent(DWORD num);
|
||||
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 RemoveProcessContext(DWORD pid); // private
|
||||
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;
|
||||
|
||||
@ -110,26 +110,26 @@ DLLEXPORT bool InjectProcessById(DWORD processId, DWORD timeout)
|
||||
return false;
|
||||
}
|
||||
|
||||
DLLEXPORT bool DetachProcessById(DWORD processId)
|
||||
DLLEXPORT bool DetachProcess(DWORD processId)
|
||||
{
|
||||
DWORD command = HOST_COMMAND_DETACH;
|
||||
DWORD unused;
|
||||
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);
|
||||
if (commandPipe == nullptr) return false;
|
||||
|
||||
BYTE buffer[PIPE_BUFFER_SIZE] = {};
|
||||
*(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());
|
||||
DWORD unused;
|
||||
return WriteFile(commandPipe, buffer, sizeof(DWORD) + sizeof(HookParam) + name.size(), &unused, nullptr);
|
||||
|
@ -12,10 +12,10 @@
|
||||
DLLEXPORT void OpenHost();
|
||||
DLLEXPORT bool StartHost();
|
||||
DLLEXPORT void CloseHost();
|
||||
DLLEXPORT void GetHostHookManager(HookManager **hookman);
|
||||
DLLEXPORT bool InjectProcessById(DWORD pid, DWORD timeout = 5000);
|
||||
DLLEXPORT bool DetachProcessById(DWORD pid);
|
||||
DLLEXPORT bool InsertHook(DWORD pid, const HookParam *hp, std::string name = "");
|
||||
DLLEXPORT HookManager* GetHostHookManager();
|
||||
DLLEXPORT bool InjectProcess(DWORD pid, DWORD timeout = 5000);
|
||||
DLLEXPORT bool DetachProcess(DWORD pid);
|
||||
DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name = "");
|
||||
DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr);
|
||||
|
||||
// EOF
|
||||
|
Loading…
Reference in New Issue
Block a user