1. Roland Smith
  2. PowerBuilder
  3. Tuesday, 19 September 2023 17:52 PM UTC

I'm using CreateProcess to run an EXE and WaitForSingleObject to wait for it to finish.

My problem is that I need the EXE process to have the same security access as the calling EXE. I'm guessing the lpProcessAttributes argument needs to be populated but how that is done, I don't know.

Who is viewing this page
Accepted Answer
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 19 September 2023 19:12 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Roland,

Through this StackOverflow post I found that you can use the function CreateProcessWithTokenW to create a process passing it a specific process access token. Additionally, I found this other function GetCurrentProcessToken that retrieves the access token for the current process.
I haven't personally tested this but it might work.

 

Regards,
Francisco

Comment
  1. Roland Smith
  2. Tuesday, 19 September 2023 19:39 PM UTC
It turns out that security wasn't the issue. The actual problem was that I had quotes around the filename in the command line string passed to CreateProcess. The secondary EXE couldn't open the file because it had quotes in the filename string. Once I removed the quotes it started working.

I'll look at this when I get a chance. Thanks.
  1. Helpful 2
  1. Miguel Leeuwe
  2. Wednesday, 20 September 2023 04:02 AM UTC
Just in case:

Beware also of TAB characters. We use CatSoft's DLL (combined or not with OLE), to be able to drag and drop Outlook emails onto a dw. The e-mail's Subject is being used as the filename and who knows why, some of our customers have TABs in the Subject. It turns out that the file can be saved with a TAB character, but afterwards opening the .msg / .eml file won't work.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 19 September 2023 19:55 PM UTC
  2. PowerBuilder
  3. # 1

@Roland - Glad to hear you found the cause of the issue!

@Franscisco - I'm not sure the GetCurrentProcessToken API will be useful in this case. I found the following in the description of that API:

Excellent find regarding the CreateProcessWithTokenW API function, however! I was not aware of that API.

Comment
  1. Roland Smith
  2. Wednesday, 20 September 2023 13:38 PM UTC
I just noticed this in the help for CreateProcess:



Creates a new process and its primary thread. The new process runs in the security context of the calling process.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 19 September 2023 18:50 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Roland - 

If it were me, I'd search C++ "heavy hitter" web sites like StackOverflow.com using search arguments "createprocess" and "security_attributes"... at least to get started, and see what turns up.

Best regards, John

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.