Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- char msg1[]="Message1";
- char msg2[]="Message2";
- int main(){
- std::string c;
- SECURITY_ATTRIBUTES sa={0};
- SECURITY_DESCRIPTOR sd={0};
- InitializeSecurityDescriptor(
- &sd,
- SECURITY_DESCRIPTOR_REVISION);
- SetSecurityDescriptorDacl(
- &sd,
- TRUE,
- NULL,
- FALSE);
- sa.bInheritHandle=false;
- sa.lpSecurityDescriptor=&sd;
- sa.nLength=sizeof(sa);
- HANDLE ch1=CreateNamedPipe (
- "\\.\pipe\testpipe",
- PIPE_ACCESS_DUPLEX,
- PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE| PIPE_WAIT,
- PIPE_UNLIMITED_INSTANCES,
- sizeof msg1, 4, 0, &sa
- );
- if(ch1==INVALID_HANDLE_VALUE){
- std::cout<<"ch1 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- HANDLE ch2=CreateNamedPipe(
- "\\.\pipe\testpipe",
- PIPE_ACCESS_DUPLEX,
- PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE| PIPE_WAIT,
- PIPE_UNLIMITED_INSTANCES,
- sizeof msg1, 4, 0, &sa
- );
- if(ch2==INVALID_HANDLE_VALUE){
- std::cout<<"ch2 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- ConnectNamedPipe(ch1, 0);
- ConnectNamedPipe(ch2, 0);
- unsigned long foo;
- if(TransactNamedPipe(ch1, msg1, sizeof msg1, &foo, sizeof foo, &foo, 0)==0){
- std::cout<<"transact1 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- if(TransactNamedPipe(ch2, msg2, sizeof msg2, &foo, sizeof foo, &foo, 0)==0){
- std::cout<<"transact2 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- std::cout<<"Finishedn";
- std::getline(std::cin, c);
- return 0;
- }
- #include <windows.h>
- #include <iostream>
- char msg1[]="Message1n";
- char msg2[]="Message2n";
- int main(){
- std::string c;
- std::cout<<"Server name:n";
- std::string sname;
- std::cin>>sname;
- std::cin.ignore();
- NETRESOURCE nr={0};
- if(sname!="."){
- std::string sname2=std::string("\\")+sname;
- nr.dwType = RESOURCETYPE_ANY;
- nr.lpRemoteName = &sname2[0];
- DWORD ret=WNetAddConnection2( &nr, "", "", 0);
- if(ret!=NO_ERROR){
- std::cout<<"WNetAddConnection2 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- }
- std::string pname=std::string("\\")+sname+std::string("\pipe\testpipe");
- HANDLE phandle1=CreateFile (
- pname.c_str(),
- GENERIC_READ|GENERIC_WRITE,
- 0, 0, OPEN_EXISTING, 0,0
- );
- if(phandle1==INVALID_HANDLE_VALUE){
- std::cout<<"CreateFile1 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- HANDLE phandle2=CreateFile (
- pname.c_str(),
- GENERIC_READ|GENERIC_WRITE,
- 0, 0, OPEN_EXISTING, 0,0
- );
- if(phandle2==INVALID_HANDLE_VALUE){
- std::cout<<"CreateFile2 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- char msg[sizeof(msg1)];
- unsigned long s;
- unsigned long foo=0;
- if(ReadFile(phandle1, &msg, sizeof msg1, &s, 0)==0){
- std::cout<<"ReadFile1 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- std::cout<<msg<<"n";
- if(WriteFile (phandle1, &foo, sizeof foo, &foo, 0)==0){
- std::cout<<"WriteFile1 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- if(ReadFile(phandle2, &msg, sizeof msg1, &s, 0)==0){
- std::cout<<"ReadFile2 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- std::cout<<msg<<"n";
- if(WriteFile (phandle2, &foo, sizeof foo, &foo, 0)==0){
- std::cout<<"WriteFile2 "<<GetLastError()<<"n";
- std::getline(std::cin, c);
- return 1;
- }
- std::cout<<"Finishedn";
- std::getline(std::cin, c);
- return 0;
- }
- [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesLanmanServerParameters]
- "ServiceDll"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,
- 00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,
- 73,00,72,00,76,00,73,00,76,00,63,00,2e,00,64,00,6c,00,6c,00,00,00
- "ServiceDllUnloadOnStop"=dword:00000001
- "EnableAuthenticateUserSharing"=dword:00000001
- "NullSessionPipes"=hex(7):74,00,65,00,73,00,74,00,70,00,69,00,70,00,65,00,00,
- 00,41,00,6e,00,6f,00,6e,00,79,00,6d,00,6f,00,75,00,73,00,50,00,69,00,70,00,
- 65,00,00,00,00,00
- "autodisconnect"=dword:0000000f
- "enableforcedlogoff"=dword:00000001
- "enablesecuritysignature"=dword:00000000
- "requiresecuritysignature"=dword:00000000
- "restrictnullsessaccess"=dword:00000000
- "Lmannounce"=dword:00000000
- "Size"=dword:00000001
- "AdjustedNullSessionPipes"=dword:00000003
- "Guid"=hex:eb,c5,75,fd,46,51,ce,4c,8f,64,a9,70,12,f6,05,6e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement