8000 Merge master branch by dxgldotorg · Pull Request #61 · dxgldotorg/dxgl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Merge master branch #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions minhook/build/DXGL/libMinHook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
<Lib />
Expand All @@ -182,8 +181,7 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
<Lib />
Expand Down
60 changes: 58 additions & 2 deletions minhook/src/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,52 @@ static BOOL EnumerateThreads(PFROZEN_THREADS pThreads)
return succeeded;
}

typedef long NTSTATUS;
#define OBJ_INHERIT (ULONG)2;

typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING;

typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor;
PVOID SecurityQualityOfService;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;

typedef struct _CLIENT_ID {
HANDLE UniqueProcess;
HANDLE UniqueThread;
} CLIENT_ID;

static NTSTATUS(NTAPI *_NtOpenThread)(PHANDLE ThreadHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, CLIENT_ID *ClientID) = NULL;
static HANDLE(WINAPI *__OpenThread)(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId) = NULL;
static BOOL OpenThreadFail = FALSE;
static HANDLE WINAPI OpenThreadNT(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId)
{
OBJECT_ATTRIBUTES attrib;
CLIENT_ID id;
HANDLE handle = 0;
NTSTATUS error;
ZeroMemory(&attrib, sizeof(OBJECT_ATTRIBUTES));
attrib.Length = sizeof(OBJECT_ATTRIBUTES);
if(bInheritHandle) attrib.Attributes = OBJ_INHERIT;
id.UniqueProcess = 0;
id.UniqueThread = ULongToHandle(dwThreadId);
error = _NtOpenThread(&handle, dwDesiredAccess, &attrib, &id);
if (error) return 0;
else return handle;
}

static HANDLE WINAPI _OpenThread(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId)
{
HANDLE hKernel32;
HANDLE hNtdll;
if (!__OpenThread)
{
if (OpenThreadFail) return NULL;
Expand All @@ -345,8 +386,23 @@ static HANDLE WINAPI _OpenThread(DWORD dwDesiredAccess, BOOL bInheritHandle, DW
__OpenThread = GetProcAddress(hKernel32, "OpenThread");
if (!__OpenThread)
{
OpenThreadFail = TRUE;
return NULL;
// Try NtOpenThread
hNtdll = GetModuleHandle(_T("ntdll.dll"));
if (hNtdll)
{
_NtOpenThread = GetProcAddress(hNtdll,"NtOpenThread");
if (_NtOpenThread) __OpenThread = OpenThreadNT;
else
{
OpenThreadFail = TRUE;
return NULL;
}
}
else
{
OpenThreadFail = TRUE;
return NULL;
}
}
}
return __OpenThread(dwDesiredAccess, bInheritHandle, dwThreadId);
Expand Down
0