Skip to content

Commit

Permalink
Link to NtQueryInformationProcess directly
Browse files Browse the repository at this point in the history
  • Loading branch information
32th-System committed Feb 21, 2024
1 parent ffa341f commit 097ed89
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
8 changes: 1 addition & 7 deletions thprac/src/thprac/thprac_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,8 @@ bool PromptUser(thprac_prompt_t info, THGameSig* gameSig = nullptr)
}

uintptr_t GetGameModuleBase(HANDLE hProc) {
static decltype(NtQueryInformationProcess)* _NtQueryInformationProcess;

if (!_NtQueryInformationProcess) {
_NtQueryInformationProcess = (decltype(NtQueryInformationProcess)*)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "NtQueryInformationProcess");
}

PROCESS_BASIC_INFORMATION pbi;
_NtQueryInformationProcess(hProc, ProcessBasicInformation, &pbi, sizeof(pbi), nullptr);
NtQueryInformationProcess(hProc, ProcessBasicInformation, &pbi, sizeof(pbi), nullptr);

LPVOID based = (LPVOID)((uintptr_t)pbi.PebBaseAddress + offsetof(PEB, ImageBaseAddress));

Expand Down
4 changes: 2 additions & 2 deletions thprac/src/thprac/utils/wininternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ typedef enum _PROCESSINFOCLASS {
ProcessBreakOnTermination = 29
} PROCESSINFOCLASS;

__kernel_entry NTSTATUS
extern "C" __kernel_entry NTSTATUS
NTAPI
NtQueryInformationProcess(
IN HANDLE ProcessHandle,
IN PROCESSINFOCLASS ProcessInformationClass,
OUT PVOID ProcessInformation,
IN ULONG ProcessInformationLength,
OUT PULONG ReturnLength OPTIONAL);
OUT PULONG ReturnLength OPTIONAL);
2 changes: 1 addition & 1 deletion thprac/thprac.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<FixedBaseAddress>false</FixedBaseAddress>
<AdditionalDependencies>kernel32.lib;user32.lib;freetype.lib;gdi32.lib</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;ntdll.lib;user32.lib;freetype.lib;gdi32.lib</AdditionalDependencies>
<GenerateMapFile>true</GenerateMapFile>
<RandomizedBaseAddress>true</RandomizedBaseAddress>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down

0 comments on commit 097ed89

Please sign in to comment.