You don't offer a lot of details but I can answer some of your questions:
- no need to add a "parameter" to the manifest; there is no such parameter
- no need to detect, from your process, when Chrome closes
Chrome starts your native messaging host whenever you send a message to it or, if you're using long lived connection, when you open the connection. The application should close when the STDIN stream closes (simply put, you can't read anymore from stdin).
For a single threaded app, the flow looks like this:
1. Read request from stdin
2. process request
3. write response to stdout;
Repeat 1-3 as long as you can read from stdin; if you can't read from stdin, break the loop and exit.
std::string req;
while(!(req=read_request()).empty())
{
//process request and send response
}
read_request
is up to you to implement: the first 4 BYTES of the request contain the message length so read those 4 first then read len bytes that contain the actual JSON request. If you can't read anything (empty), then the while loop will break and you exit the app.