Create a Process And Open Pipe Connection object. 
  114{
  115    HANDLE              PipeHandle;
  118    char *              BufferToRead;
  119    char *              BufferToSend;
  120    char                HandshakeBuffer[] = "Hello, Dear Test Process... Yes, I'm HyperDbg Debugger :)";
  121    PROCESS_INFORMATION ProcessInfo;
  122    STARTUPINFO         StartupInfo;
  124 
  128    if (!PipeHandle)
  129    {
  130        
  131        
  132        
  134    }
  135 
  137 
  138    if (!BufferToRead)
  139    {
  140        
  141        
  142        
  144    }
  145 
  147 
  148    if (!BufferToSend)
  149    {
  150        
  151        
  152        
  153        free(BufferToSend);
  155    }
  156 
  159 
  160    strcpy(BufferToSend, HandshakeBuffer);
  161 
  162    
  163    
  164    
  165 
  166    ZeroMemory(&StartupInfo, sizeof(StartupInfo));
  167 
  168    
  169    
  170    
  171    StartupInfo.cb = sizeof StartupInfo;
  172 
  173    
  174    
  175    
  177    {
  178        
  179        
  180        
  181        free(BufferToRead);
  182        free(BufferToSend);
  183 
  185    }
  186 
  187    if (CreateProcess(
g_TestLocation, CmdArgs, NULL, NULL, 
FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo))
 
  188    {
  189        
  190        
  191        
  193        {
  194            
  195            
  196            
  197            free(BufferToRead);
  198            free(BufferToSend);
  199 
  201        }
  202 
  203        ReadBytes =
  205 
  206        if (!ReadBytes)
  207        {
  208            
  209            
  210            
  211 
  212            free(BufferToRead);
  213            free(BufferToSend);
  214 
  216        }
  217 
  218        if (strcmp(BufferToRead, "Hey there, Are you HyperDbg?") == 0)
  219        {
  220            
  221            
  222            
  223 
  224            
  225            
  226            
  228                PipeHandle,
  229                BufferToSend,
  230                (
UINT32)strlen(BufferToSend) + 1);
 
  231 
  232            if (!SentMessageResult)
  233            {
  234                
  235                
  236                
  237 
  238                free(BufferToRead);
  239                free(BufferToSend);
  240 
  242            }
  243 
  244            
  245            
  246            
  248 
  250 
  251            if (!ReadBytes)
  252            {
  253                
  254                
  255                
  256 
  257                free(BufferToRead);
  258                free(BufferToSend);
  259 
  261            }
  262 
  263            if (strcmp(BufferToRead, "Wow! I miss you... Would you plz send test cases?") == 0)
  264            {
  265                
  266                
  267                
  268                *ConnectionPipeHandle = PipeHandle;
  269                *ThreadHandle         = ProcessInfo.hThread;
  270                *ProcessHandle        = ProcessInfo.hProcess;
  271 
  272                free(BufferToRead);
  273                free(BufferToSend);
  274 
  276            }
  277 
  278            ShowMessages(
"err, could not handshake with the test process\n");
 
  279 
  280            free(BufferToRead);
  281            free(BufferToSend);
  282 
  284        }
  285        else
  286        {
  287            ShowMessages(
"err, the process could not be started\n");
 
  288 
  289            free(BufferToRead);
  290            free(BufferToSend);
  291 
  293        }
  294    }
  295 
  296    free(BufferToRead);
  297    free(BufferToSend);
  298 
  300}
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned int UINT32
Definition BasicTypes.h:48
#define TEST_CASE_MAXIMUM_BUFFERS_TO_COMMUNICATE
Maximum buffer to communicate between debugger and debuggee process.
Definition Definition.h:60
UINT32 NamedPipeServerReadClientMessage(HANDLE PipeHandle, char *BufferToSave, int MaximumReadBufferLength)
read client message from the named pipe
Definition namedpipe.cpp:88
BOOLEAN NamedPipeServerSendMessageToClient(HANDLE PipeHandle, char *BufferToSend, int BufferSize)
Definition namedpipe.cpp:123
BOOLEAN NamedPipeServerWaitForClientConntection(HANDLE PipeHandle)
wait for client connection
Definition namedpipe.cpp:58
HANDLE NamedPipeServerCreatePipe(LPCSTR PipeName, UINT32 OutputBufferSize, UINT32 InputBufferSize)
Create a named pipe server.
Definition namedpipe.cpp:27
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
TCHAR g_TestLocation[MAX_PATH]
Holds the location test-hyperdbg.exe.
Definition globals.h:441
BOOLEAN SetupTestName(_Inout_updates_bytes_all_(BufferLength) PCHAR TestLocation, ULONG BufferLength)
Definition tests.cpp:26
#define TEST_PROCESS_NAME
exe name of test process
Definition tests.h:22