-
Notifications
You must be signed in to change notification settings - Fork 12
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
optimized #4
base: main
Are you sure you want to change the base?
optimized #4
Conversation
@@ -134,6 +134,11 @@ | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
m_apc_state = (KAPC_STATE*)ExAllocatePool(NonPagedPool, sizeof(KAPC_STATE)); | ||
if (attach) | ||
{ | ||
m_apc_state = (KAPC_STATE*)ExAllocatePool2(NonPagedPool, sizeof(KAPC_STATE), '2cba'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain please why this is necessary?
handles_allocation_size += 0x10000; | ||
handles_pool = ExAllocatePool(PagedPool, handles_allocation_size); | ||
handles_pool = ExAllocatePool2(PagedPool, handles_allocation_size, '1cba'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain please why this is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good question. Generally speaking, Microsoft Windows is updating its document all the time. Judging whether it succeeds in allocating pools is always required. Other changes could be ignored if using an old version wdk.
According to the Microsoft document, ExAllocatePool is obsolete and has been deprecated in Windows 10, version 2004. It has been replaced by ExAllocatePool2. From then on, Microsoft always encourages developers to have a tag while allocating a pool. The following image prevents me to build it when regarding warnings as errors in kernel mode.
After my testing, ExAllocatePool2 is not always successful, but ExAllocatePoolZero on my system could succeed. I have no good ideas on this point. Maybe it is better to judge which one to use first according to the system.
The same as the ProcessReference.cpp.
Many Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool :)
Why you didn't choose ExAllocatePoolWithTag?
Because ExAllocatePool2 is supported only from new windows version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExAllocatePoolWithTag is also replaced by ExAllocatePool2.
I don't know why Microsoft would like to do this. Maybe it is safer to use the new API.
Click here to see related documents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExAllocatePool2 and ExAllocatePoolZero are both functions that are supported from new versions of windows.
ExAllocatePoolWithTag is maybe deprecated in the new WDK toolset but there is background compatibility in the windows kernel, you should compile with WDK from from lower version.
Please use ExAllocatePoolWithTag
Remove DbgPrint
I have removed three files that don't make sense but changed while I was editing the two .cpp files. |
@@ -1,163 +0,0 @@ | |||
<?xml version="1.0" encoding="utf-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you delete this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of file would be changed as soon as I open the .sln file via VS 2022. So I would like to remove the change in pull request.
m_apc_state = (KAPC_STATE*)ExAllocatePool(NonPagedPool, sizeof(KAPC_STATE)); | ||
if (attach) | ||
{ | ||
m_apc_state = (KAPC_STATE*)ExAllocatePool2(NonPagedPool, sizeof(KAPC_STATE), '2cba'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExAllocatePool2 and ExAllocatePoolZero are both functions that are supported from new versions of windows.
ExAllocatePoolWithTag is maybe deprecated in the new WDK toolset but there is background compatibility in the windows kernel, you should compile with WDK from from lower version.
Please use ExAllocatePoolWithTag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's OK in an older version.
handles_allocation_size += 0x10000; | ||
handles_pool = ExAllocatePool(PagedPool, handles_allocation_size); | ||
handles_pool = ExAllocatePool2(PagedPool, handles_allocation_size, '1cba'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExAllocatePool2 and ExAllocatePoolZero are both functions that are supported from new versions of windows.
ExAllocatePoolWithTag is maybe deprecated in the new WDK toolset but there is background compatibility in the windows kernel, you should compile with WDK from from lower version.
Please use ExAllocatePoolWithTag
@@ -1,149 +0,0 @@ | |||
<?xml version="1.0" encoding="utf-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you delete this file?
ISSUE #3