I am getting the warning (treated as error):
Type Cast Pointer Truncation from HANDLE to ULONG
When I try to compile, I understand that the type has a different length as I am compiling ARM64 rather than ARM, therefore I need to change the type or static_cast
it, however I receive errors such as "expected (" when changing the line to something like this:
return static_cast<ULONG>PsGetProcessId(current_process); //this gives me invalid conversion type as
//there are no brackets around the static cast
//because I am returning its value
I add brackets, however there is always a problem and it never seems to work, always "Expected (":
return (static_cast<ULONG>)PsGetProcessId(current_process); //this bracket error
ORIGINAL CODE BELOW
ULONG memory::get_process_id_by_name(PEPROCESS start_process, const char* process_name)
{
PLIST_ENTRY active_process_links;
PEPROCESS current_process = start_process;
do
{
PKPROCESS kproc = (PKPROCESS)current_process;
PDISPATCHER_HEADER header = (PDISPATCHER_HEADER)kproc;
LPSTR current_process_name = (LPSTR)((PUCHAR)current_process + IMAGE_FILE_NAME);
if (header->SignalState == 0 && strcmp(current_process_name, process_name) == 0)
{
return (ULONG)PsGetProcessId(current_process); //warning occurs here
}
active_process_links = (PLIST_ENTRY)((PUCHAR)current_process + ACTIVE_PROCESS_LINKS_FLINK);
current_process = (PEPROCESS)(active_process_links->Flink);
current_process = (PEPROCESS)((PUCHAR)current_process - ACTIVE_PROCESS_LINKS_FLINK);
} while (start_process != current_process);
return 0;
}