const correctness

c++ / delphi package - dll injection and api hooking

const correctness

Postby _NN_ » Sun Jul 08, 2018 11:56 am

Is there a reason why excludedPIDs not const ?

Code: Select all
  inline madCHookApi(BOOL) InjectLibraryA(LPCSTR pDriverName, LPCSTR pLibFileName, DWORD dwSession, BOOL bSystemProcesses, BOOL bPermanent, LPCSTR pIncludeMask, LPCSTR pExcludeMask, PULONG pExcludePIDs, PINJECT_APPROVAL_CALLBACK_ROUTINE callback, PVOID callbackContext, DWORD dwTimeOut)


Can it be changed to PCULONG pExcludePIDs ?
_NN_
 
Posts: 37
Joined: Mon Jan 21, 2013 4:00 pm

Re: const correctness

Postby madshi » Mon Jul 09, 2018 7:47 am

I suppose I could change that. But what would be the big benefit of that change?
madshi
Site Admin
 
Posts: 9719
Joined: Sun Mar 21, 2004 5:25 pm

Re: const correctness

Postby _NN_ » Mon Jul 09, 2018 8:11 am

Like all constants.
It just makes Code less buggy.
I define list of constant integers in order to prevent accidental code that changes them.
_NN_
 
Posts: 37
Joined: Mon Jan 21, 2013 4:00 pm

Re: const correctness

Postby madshi » Mon Jul 09, 2018 8:26 am

But it wouldn't have any effect on *your* code, would it? I mean you'd still have to allocate memory for the PIDs (or use the stack) and initialize it, so since you have to write to the array to initialize it, it's not really "constant", right? I suppose making the parameter const might have an effect on my code, but likely not on yours, or am I wrong?
madshi
Site Admin
 
Posts: 9719
Joined: Sun Mar 21, 2004 5:25 pm

Re: const correctness

Postby _NN_ » Mon Jul 09, 2018 9:11 am

Sure.
It just says that your code doesn’t change the content of array.
_NN_
 
Posts: 37
Joined: Mon Jan 21, 2013 4:00 pm

Re: const correctness

Postby _NN_ » Mon Jul 16, 2018 1:34 pm

As well in SendIpcMessage, the parameter PVOID pMessageBuf could be PCVOID to allow putting constant messages.
I hope you don't change the data in this function :)
_NN_
 
Posts: 37
Joined: Mon Jan 21, 2013 4:00 pm


Return to madCodeHook

Who is online

Users browsing this forum: No registered users and 2 guests

cron