[skip ci] Merge pull request #124 from qhy040404/windowhook

This commit is contained in:
HolographicHat
2025-01-17 22:13:43 +08:00
committed by GitHub
3 changed files with 16 additions and 0 deletions

View File

@@ -100,6 +100,7 @@
<ClInclude Include="src\il2cpp-types.h" />
<ClInclude Include="src\il2cpp-init.h" />
<ClInclude Include="src\NamedPipe.h" />
<ClInclude Include="src\ntprivate.h" />
<ClInclude Include="src\util.h" />
<ClInclude Include="src\Zydis.h" />
</ItemGroup>

View File

@@ -9,6 +9,7 @@
#include "util.h"
#include "il2cpp-init.h"
#include "il2cpp-types.h"
#include "ntprivate.h"
CRITICAL_SECTION CriticalSection;
void SetBreakpoint(HANDLE thread, uintptr_t address, bool enable, uint8_t index = 0);
@@ -200,6 +201,11 @@ BOOL __stdcall DllMain(HMODULE hInstance, DWORD fdwReason, LPVOID lpReserved)
if (fdwReason == DLL_PROCESS_ATTACH)
{
if (hInstance)
{
LdrAddRefDll(LDR_ADDREF_DLL_PIN, hInstance);
}
if (const auto hThread = CreateThread(nullptr, 0, ThreadProc, hInstance, 0, nullptr)) {
CloseHandle(hThread);
}

9
lib/src/ntprivate.h Normal file
View File

@@ -0,0 +1,9 @@
#pragma once
#include <Windows.h>
#include <bcrypt.h>
#pragma comment(lib, "ntdll.lib")
#define LDR_ADDREF_DLL_PIN 0x00000001
EXTERN_C NTSYSAPI NTSTATUS NTAPI LdrAddRefDll(_In_ ULONG Flags, _In_ PVOID DllHandle);