I re-wrote the whole thing, since it was becoming pretty hard for me to follow. This is the new function for handling read/write requests:
fsInterface::fsStart()
{
fsData dat;
char * chData;
int x = 0;
for( ; ; )
{
x = recv(*fsSock, (char *) &dat, sizeof(fsData), 0);
if(x = 0)
{
printf("Connection closed\n");
return 0;
}
if(x = SOCKET_ERROR)
{
printf("Error %i while receiving data\n", WSAGetLastError());
return 0;
}
if (dat.header == FS_READ)
{
chData = new char [dat.dwSize];
if(!FSUIPC_Read(dat.dwOffset, dat.dwSize, chData, &err))
{
printf("Error %i while reading from FSUIPC\n", err);
return 0;
}
if(!FSUIPC_Process(&err))
{
printf("Error %i while calling FSUIPC_Process\n", err);
return 0;
}
if(send(*fsSock, (char *) &dat, sizeof(fsData), 0)== SOCKET_ERROR)
{
printf("Error %i while sending data\n", WSAGetLastError());
return 0;
}
if(send(*fsSock, chData, dat.dwSize, 0) == SOCKET_ERROR)
{
printf("Error %i while sending data\n", WSAGetLastError());
}
}
if (dat.header == FS_WRITE)
{
chData = new char [dat.dwSize];
x = recv(*fsSock, chData, dat.dwSize, 0);
if(x = 0)
{
printf("Connection closed\n");
return 0;
}
if(x = SOCKET_ERROR)
{
printf("Error %i while receiving data\n", WSAGetLastError());
return 0;
}
if(!FSUIPC_Write(dat.dwOffset, dat.dwSize, chData, &err))
{
printf("Error %i while writing to FSUIPC\n", err);
return 0;
}
if(!FSUIPC_Process(&err))
{
printf("Error %i while calling FSUIPC_Process\n", err);
return 0;
}
}
}
}
At least I know the whole thing will build, and the TCP/IP code I wrote works. Still can't test it without a registration key, I'll try to get around to taking care of that tomorrow.