PHNT: Fix macro usage, Update headers

This commit is contained in:
dmex
2018-06-28 09:48:48 +10:00
parent 3bbdbfb8ec
commit 2f09632c09
14 changed files with 193 additions and 34 deletions
+1 -1
View File
@@ -459,7 +459,7 @@ CreateResult:
if (result->Display.Buffer = PhAllocateForMemorySearch(displayLength + sizeof(WCHAR)))
{
memcpy(result->Display.Buffer, displayBuffer, displayLength);
result->Display.Buffer[displayLength / sizeof(WCHAR)] = 0;
result->Display.Buffer[displayLength / sizeof(WCHAR)] = UNICODE_NULL;
result->Display.Length = displayLength;
}
+1 -1
View File
@@ -178,7 +178,7 @@ PhDelayExecution(
{
LARGE_INTEGER interval;
interval.QuadPart = Interval * -10000LL;
interval.QuadPart = Interval * -PH_TIMEOUT_MS;
return NtDelayExecution(FALSE, &interval);
}
+1 -1
View File
@@ -61,7 +61,7 @@ typedef BOOL (WINAPI *_SymGetLineFromAddrW64)(
typedef ULONG64 (WINAPI *_SymLoadModuleExW)(
_In_ HANDLE hProcess,
_In_ HANDLE hFile,
_In_opt_ HANDLE hFile,
_In_ PCWSTR ImageName,
_In_ PCWSTR ModuleName,
_In_ ULONG64 BaseOfDll,
+1 -1
View File
@@ -472,7 +472,7 @@ PPH_STRING PhSidToStringSid(
)))
{
string->Length = us.Length;
string->Buffer[us.Length / sizeof(WCHAR)] = 0;
string->Buffer[us.Length / sizeof(WCHAR)] = UNICODE_NULL;
return string;
}
+2 -2
View File
@@ -402,8 +402,8 @@ BOOLEAN PhGetMappedWslImageSymbols(
entry = PTR_ADD_OFFSET(MappedWslImage->Header, section->sh_offset);
stringTable = PhGetMappedWslImageSectionData(MappedWslImage, NULL, section->sh_link);
// NOTE: Some entries include the version in the symbol name (e.g. NAME@VERSION)
// instead of using a version record entry from SHT_SUNW_versym -dmex
// NOTE: SHT_DYNSYM entries include the version in the symbol name (e.g. printf@GLIBC_2.2.5)
// instead of using a version record entry from the SHT_SUNW_versym section -dmex
versionTable = PhGetMappedWslImageSectionDataByType(MappedWslImage, SHT_SUNW_versym);
versionRecords = PhpParseMappedWslImageVersionRecords(MappedWslImage, stringTable);
+27 -28
View File
@@ -1100,10 +1100,9 @@ NTSTATUS PhGetProcessMappedFileName(
)
{
NTSTATUS status;
PVOID buffer;
SIZE_T bufferSize;
SIZE_T returnLength;
PUNICODE_STRING unicodeString;
PUNICODE_STRING buffer;
bufferSize = 0x100;
buffer = PhAllocate(bufferSize);
@@ -1139,8 +1138,7 @@ NTSTATUS PhGetProcessMappedFileName(
return status;
}
unicodeString = (PUNICODE_STRING)buffer;
*FileName = PhCreateStringFromUnicodeString(unicodeString);
*FileName = PhCreateStringFromUnicodeString(buffer);
PhFree(buffer);
return status;
@@ -2980,7 +2978,7 @@ NTSTATUS PhpUnloadDriver(
// Use a bogus name.
RtlInitUnicodeString(&valueName, L"ImagePath");
NtSetValueKey(serviceKeyHandle, &valueName, 0, REG_SZ, imagePath.Buffer, imagePath.Length + 2);
NtSetValueKey(serviceKeyHandle, &valueName, 0, REG_SZ, imagePath.Buffer, imagePath.Length + sizeof(WCHAR));
}
status = NtUnloadDriver(&fullServiceKeyNameUs);
@@ -3203,8 +3201,8 @@ BOOLEAN NTAPI PhpEnumProcessModulesCallback(
if (indexOfLastBackslash != -1)
{
Entry->BaseDllName.Buffer = Entry->FullDllName.Buffer + indexOfLastBackslash + 1;
Entry->BaseDllName.Length = Entry->FullDllName.Length - (USHORT)indexOfLastBackslash * 2 - 2;
Entry->BaseDllName.Buffer = PTR_ADD_OFFSET(Entry->FullDllName.Buffer, PTR_ADD_OFFSET(indexOfLastBackslash * sizeof(WCHAR), sizeof(WCHAR)));
Entry->BaseDllName.Length = Entry->FullDllName.Length - (USHORT)indexOfLastBackslash * sizeof(WCHAR) - sizeof(WCHAR);
Entry->BaseDllName.MaximumLength = Entry->BaseDllName.Length;
}
else
@@ -3217,7 +3215,7 @@ BOOLEAN NTAPI PhpEnumProcessModulesCallback(
// Read the full DLL name string and add a null terminator.
fullDllNameOriginal = Entry->FullDllName.Buffer;
fullDllNameBuffer = PhAllocate(Entry->FullDllName.Length + 2);
fullDllNameBuffer = PhAllocate(Entry->FullDllName.Length + sizeof(WCHAR));
Entry->FullDllName.Buffer = fullDllNameBuffer;
if (NT_SUCCESS(status = NtReadVirtualMemory(
@@ -3228,11 +3226,11 @@ BOOLEAN NTAPI PhpEnumProcessModulesCallback(
NULL
)))
{
fullDllNameBuffer[Entry->FullDllName.Length / sizeof(WCHAR)] = 0;
fullDllNameBuffer[Entry->FullDllName.Length / sizeof(WCHAR)] = UNICODE_NULL;
}
else
{
fullDllNameBuffer[0] = 0;
fullDllNameBuffer[0] = UNICODE_NULL;
Entry->FullDllName.Length = 0;
}
@@ -3242,20 +3240,19 @@ BOOLEAN NTAPI PhpEnumProcessModulesCallback(
if (
NT_SUCCESS(status) &&
(ULONG_PTR)baseDllNameOriginal >= (ULONG_PTR)fullDllNameOriginal &&
(ULONG_PTR)baseDllNameOriginal + Entry->BaseDllName.Length >= (ULONG_PTR)baseDllNameOriginal &&
(ULONG_PTR)baseDllNameOriginal + Entry->BaseDllName.Length <= (ULONG_PTR)fullDllNameOriginal + Entry->FullDllName.Length
(ULONG_PTR)PTR_ADD_OFFSET(baseDllNameOriginal, Entry->BaseDllName.Length) >= (ULONG_PTR)baseDllNameOriginal &&
(ULONG_PTR)PTR_ADD_OFFSET(baseDllNameOriginal, Entry->BaseDllName.Length) <= (ULONG_PTR)PTR_ADD_OFFSET(fullDllNameOriginal, Entry->FullDllName.Length)
)
{
baseDllNameBuffer = NULL;
Entry->BaseDllName.Buffer = (PWCHAR)((ULONG_PTR)Entry->FullDllName.Buffer +
((ULONG_PTR)baseDllNameOriginal - (ULONG_PTR)fullDllNameOriginal));
Entry->BaseDllName.Buffer = PTR_ADD_OFFSET(Entry->FullDllName.Buffer, PTR_SUB_OFFSET(baseDllNameOriginal, fullDllNameOriginal));
}
else
{
// Read the base DLL name string and add a null terminator.
baseDllNameBuffer = PhAllocate(Entry->BaseDllName.Length + 2);
baseDllNameBuffer = PhAllocate(Entry->BaseDllName.Length + sizeof(WCHAR));
Entry->BaseDllName.Buffer = baseDllNameBuffer;
if (NT_SUCCESS(NtReadVirtualMemory(
@@ -3266,11 +3263,11 @@ BOOLEAN NTAPI PhpEnumProcessModulesCallback(
NULL
)))
{
baseDllNameBuffer[Entry->BaseDllName.Length / sizeof(WCHAR)] = 0;
baseDllNameBuffer[Entry->BaseDllName.Length / sizeof(WCHAR)] = UNICODE_NULL;
}
else
{
baseDllNameBuffer[0] = 0;
baseDllNameBuffer[0] = UNICODE_NULL;
Entry->BaseDllName.Length = 0;
}
}
@@ -3278,7 +3275,9 @@ BOOLEAN NTAPI PhpEnumProcessModulesCallback(
if (WindowsVersion >= WINDOWS_8)
{
LDR_DDAG_NODE ldrDagNode = { 0 };
LDR_DDAG_NODE ldrDagNode;
memset(&ldrDagNode, 0, sizeof(LDR_DDAG_NODE));
if (NT_SUCCESS(NtReadVirtualMemory(
ProcessHandle,
@@ -3585,8 +3584,8 @@ BOOLEAN NTAPI PhpEnumProcessModules32Callback(
if (indexOfLastBackslash != -1)
{
nativeEntry.BaseDllName.Buffer = nativeEntry.FullDllName.Buffer + indexOfLastBackslash + 1;
nativeEntry.BaseDllName.Length = nativeEntry.FullDllName.Length - (USHORT)indexOfLastBackslash * 2 - 2;
nativeEntry.BaseDllName.Buffer = PTR_ADD_OFFSET(nativeEntry.FullDllName.Buffer, PTR_ADD_OFFSET(indexOfLastBackslash * sizeof(WCHAR), sizeof(WCHAR)));
nativeEntry.BaseDllName.Length = nativeEntry.FullDllName.Length - (USHORT)indexOfLastBackslash * sizeof(WCHAR) - sizeof(WCHAR);
nativeEntry.BaseDllName.MaximumLength = nativeEntry.BaseDllName.Length;
}
else
@@ -3598,7 +3597,7 @@ BOOLEAN NTAPI PhpEnumProcessModules32Callback(
{
// Read the base DLL name string and add a null terminator.
baseDllNameBuffer = PhAllocate(nativeEntry.BaseDllName.Length + 2);
baseDllNameBuffer = PhAllocate(nativeEntry.BaseDllName.Length + sizeof(WCHAR));
if (NT_SUCCESS(NtReadVirtualMemory(
ProcessHandle,
@@ -3608,11 +3607,11 @@ BOOLEAN NTAPI PhpEnumProcessModules32Callback(
NULL
)))
{
baseDllNameBuffer[nativeEntry.BaseDllName.Length / sizeof(WCHAR)] = 0;
baseDllNameBuffer[nativeEntry.BaseDllName.Length / sizeof(WCHAR)] = UNICODE_NULL;
}
else
{
baseDllNameBuffer[0] = 0;
baseDllNameBuffer[0] = UNICODE_NULL;
nativeEntry.BaseDllName.Length = 0;
}
@@ -3620,7 +3619,7 @@ BOOLEAN NTAPI PhpEnumProcessModules32Callback(
// Read the full DLL name string and add a null terminator.
fullDllNameBuffer = PhAllocate(nativeEntry.FullDllName.Length + 2);
fullDllNameBuffer = PhAllocate(nativeEntry.FullDllName.Length + sizeof(WCHAR));
if (NT_SUCCESS(NtReadVirtualMemory(
ProcessHandle,
@@ -3630,7 +3629,7 @@ BOOLEAN NTAPI PhpEnumProcessModules32Callback(
NULL
)))
{
fullDllNameBuffer[nativeEntry.FullDllName.Length / sizeof(WCHAR)] = 0;
fullDllNameBuffer[nativeEntry.FullDllName.Length / sizeof(WCHAR)] = UNICODE_NULL;
if (!(parameters->Flags & PH_ENUM_PROCESS_MODULES_DONT_RESOLVE_WOW64_FS))
{
@@ -5341,10 +5340,10 @@ PPH_STRING PhGetFileName(
PH_STRINGREF systemRoot;
PhGetSystemRoot(&systemRoot);
newFileName = PhCreateStringEx(NULL, systemRoot.Length + 2 + FileName->Length);
newFileName = PhCreateStringEx(NULL, systemRoot.Length + sizeof(WCHAR) + FileName->Length);
memcpy(newFileName->Buffer, systemRoot.Buffer, systemRoot.Length);
newFileName->Buffer[systemRoot.Length / sizeof(WCHAR)] = OBJ_NAME_PATH_SEPARATOR;
memcpy(PTR_ADD_OFFSET(newFileName->Buffer, systemRoot.Length + 2), FileName->Buffer, FileName->Length);
memcpy(PTR_ADD_OFFSET(newFileName->Buffer, systemRoot.Length + sizeof(WCHAR)), FileName->Buffer, FileName->Length);
}
else if (FileName->Length != 0 && FileName->Buffer[0] == OBJ_NAME_PATH_SEPARATOR)
{
@@ -5362,7 +5361,7 @@ PPH_STRING PhGetFileName(
// If the file name starts with "\Windows", prepend the system drive.
if (PhStartsWithString2(newFileName, L"\\Windows", TRUE))
{
newFileName = PhCreateStringEx(NULL, FileName->Length + 2 * sizeof(WCHAR));
newFileName = PhCreateStringEx(NULL, FileName->Length + sizeof(WCHAR) * sizeof(WCHAR));
newFileName->Buffer[0] = USER_SHARED_DATA->NtSystemRoot[0];
newFileName->Buffer[1] = ':';
memcpy(&newFileName->Buffer[2], FileName->Buffer, FileName->Length);
+20
View File
@@ -1,3 +1,23 @@
/*
* Process Hacker -
* Debugger support functions
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NTDBG_H
#define _NTDBG_H
+20
View File
@@ -1,3 +1,23 @@
/*
* Process Hacker -
* Executive support library functions
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NTEXAPI_H
#define _NTEXAPI_H
+20
View File
@@ -1,3 +1,23 @@
/*
* Process Hacker -
* Graphics device interface support
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NTGDI_H
#define _NTGDI_H
+20
View File
@@ -1,3 +1,23 @@
/*
* Process Hacker -
* File management support
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NTIOAPI_H
#define _NTIOAPI_H
+20
View File
@@ -1,3 +1,23 @@
/*
* Process Hacker -
* Loader support functions
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NTLDR_H
#define _NTLDR_H
+20
View File
@@ -1,3 +1,23 @@
/*
* Process Hacker -
* National Language Support functions
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NTNLS_H
#define _NTNLS_H
+20
View File
@@ -1,3 +1,23 @@
/*
* Process Hacker -
* RTL support functions
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NTRTL_H
#define _NTRTL_H
+20
View File
@@ -1,3 +1,23 @@
/*
* Process Hacker -
* Authorization functions
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NTSEAPI_H
#define _NTSEAPI_H