Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 929309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:09:00+00:00 2026-05-15T20:09:00+00:00

I’m trying to add a Sokoban solver (written in C++) to my program in

  • 0

I’m trying to add a Sokoban solver (written in C++) to my program in C# (I have got a class in my program that handles marshalling of C++ interface). My program loads solver.dll library which loads solver.exe. Solver.dll and Solver.exe communicate via pipes.

The problem is that when I run my program in Visual Studio (debugging) the DLL is loaded all right and the plugin’s functions works great. But when I open my program outside of Visual Studio (simple double-click on MyProgram.exe) and when I try to run solving function the error message: “Got Invalid Pipe” and “Failed to create pipe.” appear.

I’m quite at loss what might be the problem but my guess is that there’s a problem with some permissions.

Here are two parts of code from plugin author:

In solver.dll file:

 //create pipes
 SECURITY_ATTRIBUTES attr;
 attr.nLength=sizeof(attr);
 attr.lpSecurityDescriptor=NULL;
 attr.bInheritHandle=TRUE;
 if(!CreatePipe(&hPipeOutRead,&hPipeOutWrite,&attr,0)
         ||!CreatePipe(&hPipeInRead,&hPipeInWrite,&attr,0) )
 {
         ReportError("Failed to create pipe.");
         return SOKOBAN_PLUGIN_RESULT_FAILURE;
 }

 //set std handle for deliver pipe
 HANDLE hStdInSave, hStdOutSave;
 hStdInSave=GetStdHandle(STD_INPUT_HANDLE);
 hStdOutSave=GetStdHandle(STD_OUTPUT_HANDLE);
 if(hStdInSave==INVALID_HANDLE_VALUE || hStdOutSave==INVALID_HANDLE_VALUE)
 {
         ReportError("Failed to get std handles.");
         return SOKOBAN_PLUGIN_RESULT_FAILURE;
 }
 if(!SetStdHandle(STD_INPUT_HANDLE,hPipeOutRead)
         ||!SetStdHandle(STD_OUTPUT_HANDLE,hPipeInWrite) )
 {
         ReportError("Failed to redirect std handles.");
         return SOKOBAN_PLUGIN_RESULT_FAILURE;
 }

 //create BoxSearch Process
 STARTUPINFO startInfo;
 ZeroMemory(&startInfo,sizeof(startInfo));
 startInfo.cb=sizeof(startInfo);

 PROCESS_INFORMATION processInfo;
 ZeroMemory(&processInfo,sizeof(processInfo));

 char dllDir[MAX_PATH];
 char exeName[MAX_PATH+100];
 GetModuleFileName(ghinstDLL,dllDir,MAX_PATH);
 *(strrchr(dllDir,'\\')+1)=0;
 strcpy(exeName,dllDir);
 strcat(exeName,"Solver.exe");

 char cmdLine[MAX_PATH+100];
 strcpy(cmdLine,"\"");
 strcat(cmdLine,exeName);
 strcat(cmdLine,"\"");
 strcat(cmdLine," ");
 strcat(cmdLine,API_DLLCommandLine);

 BOOL launchSuccess=CreateProcess(exeName,cmdLine,NULL,NULL,TRUE,0,NULL,dllDir,&startInfo,&processInfo);

At the side of Solver.exe:

//get pipes
 hPipeRead=GetStdHandle(STD_INPUT_HANDLE),
 hPipeWrite=GetStdHandle(STD_OUTPUT_HANDLE);
 if(0==hPipeRead || INVALID_HANDLE_VALUE==hPipeRead
         ||0==hPipeWrite|| INVALID_HANDLE_VALUE==hPipeWrite)
 {
         FormattedMessageBox("Got invalid pipe.");
         return;
 }

What might be the problem? Are there any permissions related to loaded DLL (for pipes)?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:09:00+00:00Added an answer on May 15, 2026 at 8:09 pm

    Yuck, that’s fugly. This can only work well if MyProgram.exe is a console mode application. Required to get input/output redirection working. It probably works in the debugger because of the Visual Studio hosting process.

    P/Invoking AllocConsole in your program would solve the issue. I’ll guess you don’t particularly care for that console window, you’d have to rewrite that interface. Using named pipes would solve it. Realistically, it doesn’t make any sense to run the solver as a separate process. Take a look at C++/CLI to get ahead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.