├── CopyFileFunction ├── CopyFileFunction.sln └── CopyFileFunction │ ├── CopyFileFunction.cpp │ ├── CopyFileFunction.vcxproj │ ├── CopyFileFunction.vcxproj.filters │ └── CopyFileFunction.vcxproj.user ├── CreateDirectoryFunction ├── CreateDirectoryFunction.sln └── CreateDirectoryFunction │ ├── CreateDirectoryFunction.cpp │ ├── CreateDirectoryFunction.vcxproj │ ├── CreateDirectoryFunction.vcxproj.filters │ └── CreateDirectoryFunction.vcxproj.user ├── CreateFileFunction ├── CreateFileFunction.sln └── CreateFileFunction │ ├── CreateFileFunction.cpp │ ├── CreateFileFunction.vcxproj │ ├── CreateFileFunction.vcxproj.filters │ └── CreateFileFunction.vcxproj.user ├── CreateMailSlots ├── CreateMailSlots.sln ├── CreateMailSlots │ ├── CreateMailSlots.cpp │ ├── CreateMailSlots.vcxproj │ ├── CreateMailSlots.vcxproj.filters │ └── CreateMailSlots.vcxproj.user └── CreateMailSlotsCliente │ ├── CreateMailSlotsCliente.cpp │ ├── CreateMailSlotsCliente.vcxproj │ ├── CreateMailSlotsCliente.vcxproj.filters │ └── CreateMailSlotsCliente.vcxproj.user ├── CreateMutexAndCreateThreadFunction ├── CreateMutexAndCreateThreadFunction.sln └── CreateMutexAndCreateThreadFunction │ ├── CreateMutexAndCreateThreadFunction.cpp │ ├── CreateMutexAndCreateThreadFunction.vcxproj │ ├── CreateMutexAndCreateThreadFunction.vcxproj.filters │ └── CreateMutexAndCreateThreadFunction.vcxproj.user ├── CreateMutexFunction ├── CreateMutexFunction.sln ├── CreateMutexFunction │ ├── CreateMutexFunction.cpp │ ├── CreateMutexFunction.vcxproj │ ├── CreateMutexFunction.vcxproj.filters │ └── CreateMutexFunction.vcxproj.user └── OpenMutexFunction │ ├── OpenMutexFunction.cpp │ ├── OpenMutexFunction.vcxproj │ ├── OpenMutexFunction.vcxproj.filters │ └── OpenMutexFunction.vcxproj.user ├── CreateNamedPipeFunction ├── CreateNamedPipeCliente │ ├── CreateNamedPipeCliente.cpp │ ├── CreateNamedPipeCliente.vcxproj │ ├── CreateNamedPipeCliente.vcxproj.filters │ └── CreateNamedPipeCliente.vcxproj.user ├── CreateNamedPipeFunction.sln └── CreateNamedPipeFunction │ ├── CreateNamedPipeFunction.cpp │ ├── CreateNamedPipeFunction.vcxproj │ ├── CreateNamedPipeFunction.vcxproj.filters │ └── CreateNamedPipeFunction.vcxproj.user ├── CreatePipeFunction ├── CreatePipeFunction.sln └── CreatePipeFunction │ ├── CreatePipeFunction.cpp │ ├── CreatePipeFunction.vcxproj │ ├── CreatePipeFunction.vcxproj.filters │ └── CreatePipeFunction.vcxproj.user ├── CreateProcessFunction ├── CreateProcessFunction.sln └── CreateProcessFunction │ ├── CreateProcessFunction.cpp │ ├── CreateProcessFunction.vcxproj │ ├── CreateProcessFunction.vcxproj.filters │ └── CreateProcessFunction.vcxproj.user ├── CreateRemoteThreadFunction ├── CreateRemoteThreadFunction.sln └── CreateRemoteThreadFunction │ ├── CreateRemoteThreadFunction.cpp │ ├── CreateRemoteThreadFunction.vcxproj │ ├── CreateRemoteThreadFunction.vcxproj.filters │ └── CreateRemoteThreadFunction.vcxproj.user ├── CreateSemaphoreFunction ├── CreateSemaphoreFunction.sln ├── CreateSemaphoreFunction │ ├── CreateSemaphoreFunction.cpp │ ├── CreateSemaphoreFunction.vcxproj │ ├── CreateSemaphoreFunction.vcxproj.filters │ └── CreateSemaphoreFunction.vcxproj.user └── OpenSemaphoreFunction │ ├── OpenSemaphoreFunction.cpp │ ├── OpenSemaphoreFunction.vcxproj │ ├── OpenSemaphoreFunction.vcxproj.filters │ └── OpenSemaphoreFunction.vcxproj.user ├── CreateThreadFunction ├── CreateThreadFunction.sln └── CreateThreadFunction │ ├── CreateThreadFunction.cpp │ ├── CreateThreadFunction.vcxproj │ ├── CreateThreadFunction.vcxproj.filters │ └── CreateThreadFunction.vcxproj.user ├── CreateThreadWithCustomParamsFunction ├── CreateThreadWithCustomParamsFunction.sln └── CreateThreadWithCustomParamsFunction │ ├── CreateThreadWithCustomParamsFunction.cpp │ ├── CreateThreadWithCustomParamsFunction.vcxproj │ ├── CreateThreadWithCustomParamsFunction.vcxproj.filters │ └── CreateThreadWithCustomParamsFunction.vcxproj.user ├── CriticalSectionFunction ├── CriticalSectionFunction.sln └── CriticalSectionFunction │ ├── CriticalSectionFunction.cpp │ ├── CriticalSectionFunction.vcxproj │ ├── CriticalSectionFunction.vcxproj.filters │ └── CriticalSectionFunction.vcxproj.user ├── FileMappingIPCFunction ├── FileMappingIPCFunction.sln ├── FileMappingIPCFunction │ ├── FileMappingIPCFunction.cpp │ ├── FileMappingIPCFunction.vcxproj │ ├── FileMappingIPCFunction.vcxproj.filters │ └── FileMappingIPCFunction.vcxproj.user └── FileMappingIPCFunctionClient │ ├── FileMappingIPCFunctionClient.cpp │ ├── FileMappingIPCFunctionClient.vcxproj │ ├── FileMappingIPCFunctionClient.vcxproj.filters │ └── FileMappingIPCFunctionClient.vcxproj.user ├── HardLinkFunction ├── HardLinkFunction.sln └── HardLinkFunction │ ├── HardLinkFunction.cpp │ ├── HardLinkFunction.vcxproj │ ├── HardLinkFunction.vcxproj.filters │ └── HardLinkFunction.vcxproj.user ├── RegistryInWindows ├── RegistryInWindows.sln └── RegistryInWindows │ ├── RegistryInWindows.cpp │ ├── RegistryInWindows.vcxproj │ ├── RegistryInWindows.vcxproj.filters │ └── RegistryInWindows.vcxproj.user ├── RenameAndMoveFileFunction ├── RenameAndMoveFileFunction.sln └── RenameAndMoveFileFunction │ ├── RenameAndMoveFileFunction.cpp │ ├── RenameAndMoveFileFunction.vcxproj │ ├── RenameAndMoveFileFunction.vcxproj.filters │ └── RenameAndMoveFileFunction.vcxproj.user ├── SoftLinkFunction ├── SoftLinkFunction.sln └── SoftLinkFunction │ ├── SoftLinkFunction.cpp │ ├── SoftLinkFunction.vcxproj │ ├── SoftLinkFunction.vcxproj.filters │ └── SoftLinkFunction.vcxproj.user ├── SystemParametersInfoAForSetDesktopWallpaperFunction ├── SystemParametersInfoAForSetDesktopWallpaperFunction.sln └── SystemParametersInfoAForSetDesktopWallpaperFunction │ ├── SystemParametersInfoAForSetDesktopWallpaperFunction.cpp │ ├── SystemParametersInfoAForSetDesktopWallpaperFunction.vcxproj │ ├── SystemParametersInfoAForSetDesktopWallpaperFunction.vcxproj.filters │ └── SystemParametersInfoAForSetDesktopWallpaperFunction.vcxproj.user ├── URLDownloadToFileFunction ├── URLDownloadToFileFunction.sln └── URLDownloadToFileFunction │ ├── URLDownloadToFileFunction.cpp │ ├── URLDownloadToFileFunction.vcxproj │ ├── URLDownloadToFileFunction.vcxproj.filters │ └── URLDownloadToFileFunction.vcxproj.user ├── WSAWinsocketFunction ├── WSAWinsocketFunction.sln ├── WSAWinsocketFunction │ ├── WSAWinsocketFunction.cpp │ ├── WSAWinsocketFunction.vcxproj │ ├── WSAWinsocketFunction.vcxproj.filters │ └── WSAWinsocketFunction.vcxproj.user └── WSAWinsocketFunctionCliente │ ├── WSAWinsocketFunctionCliente.cpp │ ├── WSAWinsocketFunctionCliente.vcxproj │ ├── WSAWinsocketFunctionCliente.vcxproj.filters │ └── WSAWinsocketFunctionCliente.vcxproj.user └── WSAWinsocketTCPFunction ├── WSAWinsocketTCPFunction.sln ├── WSAWinsocketTCPFunction ├── WSAWinsocketTCPFunction.cpp ├── WSAWinsocketTCPFunction.vcxproj ├── WSAWinsocketTCPFunction.vcxproj.filters └── WSAWinsocketTCPFunction.vcxproj.user └── WSAWinsocketTCPFunctionCliente ├── WSAWinsocketTCPFunctionCliente.cpp ├── WSAWinsocketTCPFunctionCliente.vcxproj ├── WSAWinsocketTCPFunctionCliente.vcxproj.filters └── WSAWinsocketTCPFunctionCliente.vcxproj.user /CopyFileFunction/CopyFileFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CopyFileFunction", "CopyFileFunction\CopyFileFunction.vcxproj", "{F3D1C5DE-2586-4642-841A-6CC6AF2BDCCE}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {F3D1C5DE-2586-4642-841A-6CC6AF2BDCCE}.Debug|x64.ActiveCfg = Debug|x64 17 | {F3D1C5DE-2586-4642-841A-6CC6AF2BDCCE}.Debug|x64.Build.0 = Debug|x64 18 | {F3D1C5DE-2586-4642-841A-6CC6AF2BDCCE}.Debug|x86.ActiveCfg = Debug|Win32 19 | {F3D1C5DE-2586-4642-841A-6CC6AF2BDCCE}.Debug|x86.Build.0 = Debug|Win32 20 | {F3D1C5DE-2586-4642-841A-6CC6AF2BDCCE}.Release|x64.ActiveCfg = Release|x64 21 | {F3D1C5DE-2586-4642-841A-6CC6AF2BDCCE}.Release|x64.Build.0 = Release|x64 22 | {F3D1C5DE-2586-4642-841A-6CC6AF2BDCCE}.Release|x86.ActiveCfg = Release|Win32 23 | {F3D1C5DE-2586-4642-841A-6CC6AF2BDCCE}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {4922B9CD-70AE-4C7F-A3E0-585A07E9B48E} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CopyFileFunction/CopyFileFunction/CopyFileFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main() -> int 5 | { 6 | std::cout << "Hello World!\n"; 7 | 8 | 9 | //https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-copyfile 10 | 11 | BOOL bCpy = CopyFile( 12 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\muhahah.txt", //In 13 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\dir2\\muhahhaha.txt", //In 14 | TRUE //In 15 | ); 16 | 17 | if (!bCpy) { 18 | std::operator<<(std::cout, "Erro ao copiar arquivo: ").operator<<(GetLastError()).operator<<(std::endl); 19 | } 20 | 21 | std::operator<<(std::cout, "Sucesso ao copiar arquivo !").operator<<(std::endl); 22 | 23 | std::cin.get(); 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /CopyFileFunction/CopyFileFunction/CopyFileFunction.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {f3d1c5de-2586-4642-841a-6cc6af2bdcce} 25 | CopyFileFunction 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | true 129 | true 130 | true 131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /CopyFileFunction/CopyFileFunction/CopyFileFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CopyFileFunction/CopyFileFunction/CopyFileFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateDirectoryFunction/CreateDirectoryFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateDirectoryFunction", "CreateDirectoryFunction\CreateDirectoryFunction.vcxproj", "{712A8F20-180A-4397-9007-0194F46D341F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {712A8F20-180A-4397-9007-0194F46D341F}.Debug|x64.ActiveCfg = Debug|x64 17 | {712A8F20-180A-4397-9007-0194F46D341F}.Debug|x64.Build.0 = Debug|x64 18 | {712A8F20-180A-4397-9007-0194F46D341F}.Debug|x86.ActiveCfg = Debug|Win32 19 | {712A8F20-180A-4397-9007-0194F46D341F}.Debug|x86.Build.0 = Debug|Win32 20 | {712A8F20-180A-4397-9007-0194F46D341F}.Release|x64.ActiveCfg = Release|x64 21 | {712A8F20-180A-4397-9007-0194F46D341F}.Release|x64.Build.0 = Release|x64 22 | {712A8F20-180A-4397-9007-0194F46D341F}.Release|x86.ActiveCfg = Release|Win32 23 | {712A8F20-180A-4397-9007-0194F46D341F}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {0D5DF28A-EB15-4784-A445-53F0495E4813} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CreateDirectoryFunction/CreateDirectoryFunction/CreateDirectoryFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | auto main() -> int 6 | { 7 | 8 | std::cout << "Hello World!\n"; 9 | 10 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createdirectorya 11 | BOOL bDir = CreateDirectory( 12 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\dirnovo", //in 13 | NULL //in opt 14 | ); 15 | 16 | if (!bDir) { 17 | DWORD err = GetLastError(); 18 | std::operator<<(std::cout, "Erro ao criar diretorio ").operator<<(err).operator<<(std::endl); 19 | } 20 | 21 | std::operator<<(std::cout, "SUCESSO ao criar diretorio !").operator<<(std::endl); 22 | 23 | std::cin.get(); 24 | 25 | bDir = RemoveDirectory( 26 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\dirnovo" 27 | ); 28 | 29 | if (!bDir) { 30 | DWORD err = GetLastError(); 31 | std::operator<<(std::cout, "Erro ao excluir diretorio ").operator<<(err).operator<<(std::endl); 32 | } 33 | 34 | std::operator<<(std::cout, "SUCESSO ao excluir diretorio !").operator<<(std::endl); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /CreateDirectoryFunction/CreateDirectoryFunction/CreateDirectoryFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateDirectoryFunction/CreateDirectoryFunction/CreateDirectoryFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateFileFunction/CreateFileFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateFileFunction", "CreateFileFunction\CreateFileFunction.vcxproj", "{C03EC08C-AABB-4ECA-AE75-E0956DFDCD46}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C03EC08C-AABB-4ECA-AE75-E0956DFDCD46}.Debug|x64.ActiveCfg = Debug|x64 17 | {C03EC08C-AABB-4ECA-AE75-E0956DFDCD46}.Debug|x64.Build.0 = Debug|x64 18 | {C03EC08C-AABB-4ECA-AE75-E0956DFDCD46}.Debug|x86.ActiveCfg = Debug|Win32 19 | {C03EC08C-AABB-4ECA-AE75-E0956DFDCD46}.Debug|x86.Build.0 = Debug|Win32 20 | {C03EC08C-AABB-4ECA-AE75-E0956DFDCD46}.Release|x64.ActiveCfg = Release|x64 21 | {C03EC08C-AABB-4ECA-AE75-E0956DFDCD46}.Release|x64.Build.0 = Release|x64 22 | {C03EC08C-AABB-4ECA-AE75-E0956DFDCD46}.Release|x86.ActiveCfg = Release|Win32 23 | {C03EC08C-AABB-4ECA-AE75-E0956DFDCD46}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {18890788-D04F-4BA2-991E-C39EB6835BEE} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CreateFileFunction/CreateFileFunction/CreateFileFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main() -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea 10 | HANDLE hFile = CreateFile( 11 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\Teste.teste", //[in] 12 | GENERIC_READ | GENERIC_WRITE, //[in] 13 | FILE_SHARE_READ | FILE_SHARE_WRITE, //[in] 14 | NULL, //[optional] 15 | CREATE_NEW, //[in] 16 | FILE_ATTRIBUTE_NORMAL, //[in] 17 | NULL //[optional] 18 | ); 19 | 20 | if (hFile == INVALID_HANDLE_VALUE) 21 | std::operator<<(std::cout, "O Handle para o arquivo não foi aberto ").operator<<(GetLastError()).operator<<(std::endl); 22 | 23 | std::operator<<(std::cout, "O arquivo foi criado com sucesso !").operator<<(std::endl); 24 | 25 | 26 | 27 | /// 28 | /// WRITE FILE 29 | /// 30 | char buffer[]{ "Olá mundo real !" }; 31 | DWORD dwNumbBytesBuffer = strlen(buffer); 32 | DWORD dwNumbBytesWrite = 0; 33 | 34 | 35 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-writefile 36 | BOOL bFile = WriteFile( 37 | hFile, //[in] 38 | buffer, //[in] 39 | dwNumbBytesBuffer, //[in] 40 | &dwNumbBytesWrite,//[out, optional] 41 | NULL //[out, optional] 42 | ); 43 | 44 | if (!bFile) 45 | std::operator<<(std::cout, "O Arquivo não foi escrito ").operator<<(GetLastError()).operator<<(std::endl); 46 | 47 | 48 | std::operator<<(std::cout, "Sucesso ao escrever no arquivo ").operator<<(std::endl); 49 | 50 | 51 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile 52 | bFile = ReadFile( 53 | hFile, //[in] 54 | buffer, //[out] 55 | dwNumbBytesBuffer,//[in] 56 | &dwNumbBytesWrite,//[out, optional] 57 | NULL//[in, out, optional] 58 | ); 59 | 60 | if (!bFile) 61 | std::operator<<(std::cout, "Erro ao ler o arquivo ").operator<<(GetLastError()).operator<<(std::endl); 62 | 63 | std::operator<<(std::cout, "Sucesso ao ler o arquivo !").operator<<(std::endl); 64 | std::cout << buffer << std::endl; 65 | 66 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 67 | BOOL bClosed = CloseHandle( 68 | hFile //[in] 69 | ); 70 | 71 | if (!bClosed) 72 | std::operator<<(std::cout, "O Handle não foi fechado ").operator<<(GetLastError()).operator<<(std::endl); 73 | 74 | std::operator<<(std::cout, "O Handle foi fechado com sucesso !").operator<<(std::endl); 75 | 76 | return 0; 77 | } -------------------------------------------------------------------------------- /CreateFileFunction/CreateFileFunction/CreateFileFunction.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {c03ec08c-aabb-4eca-ae75-e0956dfdcd46} 25 | CreateFileFunction 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | true 129 | true 130 | true 131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /CreateFileFunction/CreateFileFunction/CreateFileFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateFileFunction/CreateFileFunction/CreateFileFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateMailSlots/CreateMailSlots.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateMailSlots", "CreateMailSlots\CreateMailSlots.vcxproj", "{9310F9BD-D374-44F8-B91A-36E5D1F898C6}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateMailSlotsCliente", "CreateMailSlotsCliente\CreateMailSlotsCliente.vcxproj", "{894D3A91-B02C-4CE7-B5C8-1FECB2F815F2}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {9310F9BD-D374-44F8-B91A-36E5D1F898C6}.Debug|x64.ActiveCfg = Debug|x64 19 | {9310F9BD-D374-44F8-B91A-36E5D1F898C6}.Debug|x64.Build.0 = Debug|x64 20 | {9310F9BD-D374-44F8-B91A-36E5D1F898C6}.Debug|x86.ActiveCfg = Debug|Win32 21 | {9310F9BD-D374-44F8-B91A-36E5D1F898C6}.Debug|x86.Build.0 = Debug|Win32 22 | {9310F9BD-D374-44F8-B91A-36E5D1F898C6}.Release|x64.ActiveCfg = Release|x64 23 | {9310F9BD-D374-44F8-B91A-36E5D1F898C6}.Release|x64.Build.0 = Release|x64 24 | {9310F9BD-D374-44F8-B91A-36E5D1F898C6}.Release|x86.ActiveCfg = Release|Win32 25 | {9310F9BD-D374-44F8-B91A-36E5D1F898C6}.Release|x86.Build.0 = Release|Win32 26 | {894D3A91-B02C-4CE7-B5C8-1FECB2F815F2}.Debug|x64.ActiveCfg = Debug|x64 27 | {894D3A91-B02C-4CE7-B5C8-1FECB2F815F2}.Debug|x64.Build.0 = Debug|x64 28 | {894D3A91-B02C-4CE7-B5C8-1FECB2F815F2}.Debug|x86.ActiveCfg = Debug|Win32 29 | {894D3A91-B02C-4CE7-B5C8-1FECB2F815F2}.Debug|x86.Build.0 = Debug|Win32 30 | {894D3A91-B02C-4CE7-B5C8-1FECB2F815F2}.Release|x64.ActiveCfg = Release|x64 31 | {894D3A91-B02C-4CE7-B5C8-1FECB2F815F2}.Release|x64.Build.0 = Release|x64 32 | {894D3A91-B02C-4CE7-B5C8-1FECB2F815F2}.Release|x86.ActiveCfg = Release|Win32 33 | {894D3A91-B02C-4CE7-B5C8-1FECB2F815F2}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {298958A5-E382-4AE7-81F0-060F25965B8E} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /CreateMailSlots/CreateMailSlots/CreateMailSlots.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | /* 10 | Mailslots: 11 | 1 - Mailslots é um outro mecanismo de IPC 12 | 2 - Usado como um meio de comunicação 13 | 3 - Mailslots geralmente são usados para tramitir pequenas mensagens, por exemplo: diagramas 14 | 4 - Mailslots podem ser usados localmente ou via rede 15 | 5 - Mailslots é uma interface cliente-servidor 16 | 6 - No Mailslots somente o cliente escreve as mensagens que serão armazenadas no mailslot e depois o cleinte que pode obter ou seja ler a mensagem 17 | 7 - Geralmente mailslots é uma troca de comunicação 18 | 8 - Mailslots não fornecem nenhuma confirmação que a mensagem foi recebida 19 | 9 - Pode-se enviar apenas 424 bytes de mensagem 20 | 21 | 22 | Servidor Cliente 23 | 1 - CreateMailSlots 1 - CreateFile 24 | 2 - ReadFile 2 - WriteFile 25 | 3 - CloseHandle 3 - CloseHandle 26 | */ 27 | 28 | //https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createmailslota 29 | HANDLE hSlots = CreateMailslot( 30 | _In_ L"\\\\.\\mailslot\\KEOWUMAILSLOTS", //[in] 31 | _In_ NULL, //[in] 32 | _In_ MAILSLOT_WAIT_FOREVER, //[in] 33 | _In_opt_ NULL //[in, optional] 34 | ); 35 | 36 | if (hSlots == INVALID_HANDLE_VALUE) 37 | std::operator<<(std::cout, "Erro ao tentar criar um mailslots: ").operator<<(GetLastError()).operator<<(std::endl); 38 | 39 | std::operator<<(std::cout, "Sucesso ao criar mailslots").operator<<(std::endl); 40 | 41 | char cBufferRead[1024]{ 0 }; 42 | DWORD dwBufferSizeRead = sizeof(cBufferRead); 43 | DWORD dwBufferSizeReaded = 0; 44 | 45 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile 46 | BOOL bReadFile = ReadFile( 47 | _In_ hSlots, //[in] 48 | _Out_ cBufferRead, //[out] 49 | _In_ dwBufferSizeRead, //[in] 50 | _Out_opt_ &dwBufferSizeReaded, //[out, optional] 51 | _In_opt_z_ NULL //[in, out, optional] 52 | ); 53 | 54 | if (!bReadFile) 55 | std::operator<<(std::cout, "Falha ao ler o arquivo: ").operator<<(GetLastError()).operator<<(std::endl); 56 | 57 | std::operator<<(std::cout, "Sucesso ao ler o arquivo !").operator<<(std::endl); 58 | 59 | std::printf("Cliente devolveu: %s \n", cBufferRead); 60 | 61 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 62 | BOOL bClosed = CloseHandle( 63 | _In_ hSlots //[in] 64 | ); 65 | 66 | if(!bClosed) 67 | std::operator<<(std::cout, "Falha ao fechar o handle: ").operator<<(GetLastError()).operator<<(std::endl); 68 | 69 | std::operator<<(std::cout, "Sucesso ao fechar o handle !").operator<<(std::endl); 70 | 71 | return 0; 72 | } -------------------------------------------------------------------------------- /CreateMailSlots/CreateMailSlots/CreateMailSlots.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {9310f9bd-d374-44f8-b91a-36e5d1f898c6} 25 | CreateMailSlots 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | true 129 | true 130 | true 131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /CreateMailSlots/CreateMailSlots/CreateMailSlots.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateMailSlots/CreateMailSlots/CreateMailSlots.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateMailSlots/CreateMailSlotsCliente/CreateMailSlotsCliente.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea 10 | HANDLE hFileMailSlots = CreateFile( 11 | _In_ L"\\\\.\\mailslot\\KEOWUMAILSLOTS", //[in] 12 | _In_ GENERIC_READ | GENERIC_WRITE, //[in] 13 | _In_ 0, //[in] 14 | _In_opt_ NULL, //[in, optional] 15 | _In_ OPEN_EXISTING, //[in] 16 | _In_ FILE_ATTRIBUTE_NORMAL, //[in] 17 | _In_opt_ NULL //[in, optional] 18 | ); 19 | 20 | if (hFileMailSlots == INVALID_HANDLE_VALUE) 21 | std::operator<<(std::cout, "Falhou em criar arquivo para obter handle para mailslots: ").operator<<(GetLastError()).operator<<(std::endl); 22 | 23 | std::operator<<(std::cout, "Sucesso ao obter handle para mailslots !").operator<<(std::endl); 24 | 25 | char cBufferToWrite[44]{ "Ola mundo do Keowu através de Mailslots !!" }; 26 | DWORD dwBufferSizeWrite = sizeof(cBufferToWrite); 27 | DWORD dwNumberOfBytesWrittern = 0; 28 | 29 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-writefile 30 | BOOL bWriteFile = WriteFile( 31 | _In_ hFileMailSlots, //[in] 32 | _In_ cBufferToWrite, //[in] 33 | _In_ dwBufferSizeWrite, //[in] 34 | _Out_opt_ &dwNumberOfBytesWrittern, //[out, optional] 35 | _In_opt_z_ NULL //[in, out, optional] 36 | ); 37 | 38 | if (!bWriteFile) 39 | std::operator<<(std::cout, "Falhou em escreve no mailslots !!").operator<<(std::endl); 40 | 41 | std::operator<<(std::cout, "Sucesso ao escrever no mailslots !!").operator<<(std::endl); 42 | 43 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 44 | BOOL bClosed = CloseHandle( 45 | _In_ hFileMailSlots //[in] 46 | ); 47 | 48 | if(!bClosed) 49 | std::operator<<(std::cout, "Falha em fechar o handle: ").operator<<(std::endl); 50 | 51 | std::operator<<(std::cout, "Sucesso ao fechar o handle !").operator<<(std::endl); 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /CreateMailSlots/CreateMailSlotsCliente/CreateMailSlotsCliente.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateMailSlots/CreateMailSlotsCliente/CreateMailSlotsCliente.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateMutexAndCreateThreadFunction/CreateMutexAndCreateThreadFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateMutexAndCreateThreadFunction", "CreateMutexAndCreateThreadFunction\CreateMutexAndCreateThreadFunction.vcxproj", "{BCDD2A2A-2C27-4909-AC2A-F973B5CC7748}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {BCDD2A2A-2C27-4909-AC2A-F973B5CC7748}.Debug|x64.ActiveCfg = Debug|x64 17 | {BCDD2A2A-2C27-4909-AC2A-F973B5CC7748}.Debug|x64.Build.0 = Debug|x64 18 | {BCDD2A2A-2C27-4909-AC2A-F973B5CC7748}.Debug|x86.ActiveCfg = Debug|Win32 19 | {BCDD2A2A-2C27-4909-AC2A-F973B5CC7748}.Debug|x86.Build.0 = Debug|Win32 20 | {BCDD2A2A-2C27-4909-AC2A-F973B5CC7748}.Release|x64.ActiveCfg = Release|x64 21 | {BCDD2A2A-2C27-4909-AC2A-F973B5CC7748}.Release|x64.Build.0 = Release|x64 22 | {BCDD2A2A-2C27-4909-AC2A-F973B5CC7748}.Release|x86.ActiveCfg = Release|Win32 23 | {BCDD2A2A-2C27-4909-AC2A-F973B5CC7748}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {447FF0B7-D18B-406B-AFFE-8148751A1AC1} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CreateMutexAndCreateThreadFunction/CreateMutexAndCreateThreadFunction/CreateMutexAndCreateThreadFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | HANDLE g_hMutex, g_hTid1, g_hTid2; // não faça isso em aplicação release, ou você pode deixar que terceiros brinquem com seus handles 5 | int g_count = 1; 6 | 7 | auto WINAPI FunctEven(LPVOID params) -> DWORD{ 8 | 9 | while ( g_count < 10 ) { 10 | 11 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject 12 | WaitForSingleObject( 13 | _In_ g_hMutex, //[in] 14 | _In_ INFINITE //[in] 15 | ); 16 | 17 | if (g_count % 2 == 0) 18 | std::cout << "Par -> " << g_count++ << std::endl; 19 | 20 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-releasemutex 21 | ReleaseMutex( 22 | _In_ g_hMutex //[in] 23 | ); 24 | } 25 | 26 | return 0; 27 | } 28 | 29 | auto WINAPI FunctOdd(LPVOID params) -> DWORD { 30 | 31 | while (g_count < 10) { 32 | 33 | WaitForSingleObject( 34 | _In_ g_hMutex, //[in] 35 | _In_ INFINITE //[in] 36 | ); 37 | 38 | if (g_count % 2 == 1) 39 | std::cout << "Impar -> " << g_count++ << std::endl; 40 | 41 | ReleaseMutex( 42 | _In_ g_hMutex //[in] 43 | ); 44 | 45 | } 46 | 47 | return 0; 48 | } 49 | 50 | auto main( ) -> int 51 | { 52 | 53 | std::cout << "Hello World!\n"; 54 | 55 | /* 56 | Sincronização de Thread: 57 | 1 - Escrever o número par e ímpar usando Thread e Mutex 58 | 2 - CreateMutex 59 | 3 - Criar duas threads 60 | 4 - Criar thread chamada de muha, Thread muha usa as API's WaitForSingleObject e ReleaseMutex 61 | 5 - No método main, usar a API CloseHandle 62 | */ 63 | std::operator<<(std::cout, "Sincronizacao entre threads !!").operator<<(std::endl); 64 | 65 | DWORD dTID = 0; 66 | 67 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createmutexa 68 | g_hMutex = CreateMutex( 69 | _In_ NULL, //[in, optional] 70 | _In_ FALSE, //[in] 71 | _In_ NULL //[in, optional] 72 | ); 73 | 74 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread 75 | g_hTid1 = CreateThread( 76 | _In_ NULL, //[in, optional] 77 | _In_ NULL, //[in] 78 | _In_ FunctEven, //[in] 79 | _In_ NULL, //[in, optional] 80 | _In_ NULL, //[in] 81 | _Out_ &dTID //[out, optional] 82 | ); 83 | 84 | g_hTid2 = CreateThread( 85 | _In_ NULL, //[in, optional] 86 | _In_ NULL, //[in] 87 | _In_ FunctOdd, //[in] 88 | _In_ NULL, //[in, optional] 89 | _In_ NULL, //[in] 90 | _Out_ NULL //[out, optional] 91 | ); 92 | 93 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 94 | BOOL bClosed = CloseHandle( 95 | _In_ g_hTid1 //[in] 96 | ); 97 | 98 | if (!bClosed) 99 | std::operator<<(std::cout, "Erro ao fechar o HANDLE: ").operator<<(GetLastError()).operator<<(std::endl); 100 | 101 | bClosed = CloseHandle( 102 | _In_ g_hTid2 //[in] 103 | ); 104 | 105 | if (!bClosed) 106 | std::operator<<(std::cout, "Erro ao fechar o HANDLE: ").operator<<(GetLastError()).operator<<(std::endl); 107 | 108 | return 0; 109 | } -------------------------------------------------------------------------------- /CreateMutexAndCreateThreadFunction/CreateMutexAndCreateThreadFunction/CreateMutexAndCreateThreadFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateMutexAndCreateThreadFunction/CreateMutexAndCreateThreadFunction/CreateMutexAndCreateThreadFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateMutexFunction/CreateMutexFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateMutexFunction", "CreateMutexFunction\CreateMutexFunction.vcxproj", "{CB92C240-02E8-4BA1-88D7-8E95A3309C11}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenMutexFunction", "OpenMutexFunction\OpenMutexFunction.vcxproj", "{2B518FB2-14B3-4006-87A7-AAD04CBC408D}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {CB92C240-02E8-4BA1-88D7-8E95A3309C11}.Debug|x64.ActiveCfg = Debug|x64 19 | {CB92C240-02E8-4BA1-88D7-8E95A3309C11}.Debug|x64.Build.0 = Debug|x64 20 | {CB92C240-02E8-4BA1-88D7-8E95A3309C11}.Debug|x86.ActiveCfg = Debug|Win32 21 | {CB92C240-02E8-4BA1-88D7-8E95A3309C11}.Debug|x86.Build.0 = Debug|Win32 22 | {CB92C240-02E8-4BA1-88D7-8E95A3309C11}.Release|x64.ActiveCfg = Release|x64 23 | {CB92C240-02E8-4BA1-88D7-8E95A3309C11}.Release|x64.Build.0 = Release|x64 24 | {CB92C240-02E8-4BA1-88D7-8E95A3309C11}.Release|x86.ActiveCfg = Release|Win32 25 | {CB92C240-02E8-4BA1-88D7-8E95A3309C11}.Release|x86.Build.0 = Release|Win32 26 | {2B518FB2-14B3-4006-87A7-AAD04CBC408D}.Debug|x64.ActiveCfg = Debug|x64 27 | {2B518FB2-14B3-4006-87A7-AAD04CBC408D}.Debug|x64.Build.0 = Debug|x64 28 | {2B518FB2-14B3-4006-87A7-AAD04CBC408D}.Debug|x86.ActiveCfg = Debug|Win32 29 | {2B518FB2-14B3-4006-87A7-AAD04CBC408D}.Debug|x86.Build.0 = Debug|Win32 30 | {2B518FB2-14B3-4006-87A7-AAD04CBC408D}.Release|x64.ActiveCfg = Release|x64 31 | {2B518FB2-14B3-4006-87A7-AAD04CBC408D}.Release|x64.Build.0 = Release|x64 32 | {2B518FB2-14B3-4006-87A7-AAD04CBC408D}.Release|x86.ActiveCfg = Release|Win32 33 | {2B518FB2-14B3-4006-87A7-AAD04CBC408D}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {CFA19857-66D7-4A48-9D13-2C2F080D5D3A} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /CreateMutexFunction/CreateMutexFunction/CreateMutexFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main() -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | /* 10 | 1º Mutex é um mecanismo de bloqueio 11 | 2º Mutex tem somente um estado entre locked e unlocked 12 | 3º Mutex tem dois "proprietarios" o que adiquire o lock e o que libera o lock 13 | 4º Se o mutex é locked com NON-RECURSIVE um deadlock vai ocorrer 14 | 5º Mutex só é usado para sincronização de thread 15 | 6º No Windows: 16 | i. Mutex nomeada 17 | ii. Mutex não nomeada 18 | */ 19 | 20 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createmutexa 21 | HANDLE hMutex = CreateMutex( 22 | NULL, //[in, optional] 23 | FALSE, //[in] 24 | NULL //[in, optional] -> Mutex não nomeado 25 | ); 26 | 27 | if (hMutex == INVALID_HANDLE_VALUE) 28 | std::operator<<(std::cout, "Não foi possível criar o mutex: ").operator<<(GetLastError()).operator<<(std::endl); 29 | 30 | std::operator<<(std::cout, "Sucesso ao criar o mutex !").operator<<(std::endl); 31 | 32 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 33 | if (!CloseHandle( 34 | hMutex //[in] 35 | )) 36 | std::operator<<(std::cout, "O Handle para o mutex não pode ser fechado: ").operator<<(GetLastError()).operator<<(std::endl); 37 | 38 | 39 | /* 40 | Exemplo com mutex nomeado 41 | */ 42 | 43 | hMutex = CreateMutex( 44 | NULL,//[in, optional] 45 | FALSE,//[in] 46 | L"MeuMutex"//[in, optional] -> Nome do mutex 47 | ); 48 | 49 | if (hMutex == INVALID_HANDLE_VALUE) 50 | std::operator<<(std::cout, "Não foi possível criar o mutex: ").operator<<(GetLastError()).operator<<(std::endl); 51 | 52 | std::operator<<(std::cout, "Sucesso ao criar o mutex !").operator<<(std::endl); 53 | 54 | std::cin.get(); 55 | 56 | if(!CloseHandle( 57 | hMutex 58 | )) 59 | std::operator<<(std::cout, "O Handle para o mutex não pode ser fechado: ").operator<<(GetLastError()).operator<<(std::endl); 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /CreateMutexFunction/CreateMutexFunction/CreateMutexFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateMutexFunction/CreateMutexFunction/CreateMutexFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateMutexFunction/OpenMutexFunction/OpenMutexFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-openmutexw 10 | HANDLE hMutex = OpenMutex( 11 | MUTEX_ALL_ACCESS, //[in] 12 | FALSE, //[in] 13 | L"MeuMutex" //[in] 14 | ); 15 | 16 | if (hMutex == INVALID_HANDLE_VALUE) 17 | std::operator<<(std::cout, "Não foi possível abrir o mutex: ").operator<<(GetLastError()).operator<<(std::endl); 18 | 19 | std::operator<<(std::cout, "Sucesso ao abrir o mutex !").operator<<(std::endl); 20 | 21 | std::cin.get(); 22 | 23 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 24 | if(!CloseHandle( 25 | hMutex 26 | )) 27 | std::operator<<(std::cout, "O Handle para o mutex não pode ser fechado: ").operator<<(GetLastError()).operator<<(std::endl); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /CreateMutexFunction/OpenMutexFunction/OpenMutexFunction.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {2b518fb2-14b3-4006-87a7-aad04cbc408d} 25 | OpenMutexFunction 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | true 129 | true 130 | true 131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /CreateMutexFunction/OpenMutexFunction/OpenMutexFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateMutexFunction/OpenMutexFunction/OpenMutexFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateNamedPipeFunction/CreateNamedPipeCliente/CreateNamedPipeCliente.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea 10 | HANDLE hCreateFile = CreateFile( 11 | _In_ L"\\\\.\\pipe\\KeowuPipe", //[in] 12 | _In_ GENERIC_READ | GENERIC_WRITE, //[in] 13 | _In_ 0, //[in] 14 | _In_opt_ NULL, //[in, optional] 15 | _In_ OPEN_EXISTING, //[in] 16 | _In_ FILE_ATTRIBUTE_NORMAL, //[in] 17 | _In_opt_ NULL //[in, optional] 18 | ); 19 | 20 | if (hCreateFile == INVALID_HANDLE_VALUE) 21 | std::operator<<(std::cout, "Erro ao criar um handle: ").operator<<(GetLastError()).operator<<(std::endl); 22 | 23 | std::operator<<(std::cout, "Sucesso ao abrir um handle !").operator<<(std::endl); 24 | 25 | DWORD dwNumberBytesWrite = 0; 26 | char cBufferWrite[26]{ "Olá mundo, from Keowu !!" }; 27 | DWORD dwSizeOfBuffer = sizeof(cBufferWrite); 28 | 29 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-writefile 30 | BOOL bWriteFile = WriteFile( 31 | _In_ hCreateFile, //[in] 32 | _In_ cBufferWrite, //[in] 33 | _In_ dwSizeOfBuffer, //[in] 34 | _Out_opt_ &dwNumberBytesWrite, //[out, optional] 35 | _In_opt_z_ NULL //[in, out, optional] 36 | ); 37 | 38 | if(!bWriteFile) 39 | std::operator<<(std::cout, "Erro ao escrever arquivo pipe: ").operator<<(GetLastError()).operator<<(std::endl); 40 | 41 | std::operator<<(std::cout, "Sucesso ao escrever no arquivo pipe !").operator<<(std::endl); 42 | 43 | DWORD dwNumberBytesRead = 0; 44 | char cBufferRead[1024]{ 0 }; 45 | DWORD dwSizeOfBufferRead = sizeof(cBufferRead); 46 | 47 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile 48 | BOOL bReadFile = ReadFile( 49 | _In_ hCreateFile, //[in] 50 | _Out_ cBufferRead, //[out] 51 | _In_ dwSizeOfBufferRead, //[in] 52 | _Out_opt_ &dwNumberBytesRead, //[out, optional] 53 | _In_opt_z_ NULL //[in, out, optional] 54 | ); 55 | 56 | if (!bReadFile) 57 | std::operator<<(std::cout, "Erro ao ler o arquivo pipe: ").operator<<(GetLastError()).operator<<(std::endl); 58 | 59 | std::operator<<(std::cout, "Sucesso ao ler o arquivo pipe !").operator<<(std::endl); 60 | 61 | std::printf("Dados obtidos pelo cliente(este) do servidor(pipe server): %s", cBufferRead); 62 | 63 | std::cin.get(); 64 | 65 | return 0; 66 | } -------------------------------------------------------------------------------- /CreateNamedPipeFunction/CreateNamedPipeCliente/CreateNamedPipeCliente.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateNamedPipeFunction/CreateNamedPipeCliente/CreateNamedPipeCliente.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateNamedPipeFunction/CreateNamedPipeFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateNamedPipeFunction", "CreateNamedPipeFunction\CreateNamedPipeFunction.vcxproj", "{8FD2231E-9144-4926-9879-FF8CBBDEF9F8}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateNamedPipeCliente", "CreateNamedPipeCliente\CreateNamedPipeCliente.vcxproj", "{8EC29AB5-16E2-4168-B96A-47E20F61CC33}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {8FD2231E-9144-4926-9879-FF8CBBDEF9F8}.Debug|x64.ActiveCfg = Debug|x64 19 | {8FD2231E-9144-4926-9879-FF8CBBDEF9F8}.Debug|x64.Build.0 = Debug|x64 20 | {8FD2231E-9144-4926-9879-FF8CBBDEF9F8}.Debug|x86.ActiveCfg = Debug|Win32 21 | {8FD2231E-9144-4926-9879-FF8CBBDEF9F8}.Debug|x86.Build.0 = Debug|Win32 22 | {8FD2231E-9144-4926-9879-FF8CBBDEF9F8}.Release|x64.ActiveCfg = Release|x64 23 | {8FD2231E-9144-4926-9879-FF8CBBDEF9F8}.Release|x64.Build.0 = Release|x64 24 | {8FD2231E-9144-4926-9879-FF8CBBDEF9F8}.Release|x86.ActiveCfg = Release|Win32 25 | {8FD2231E-9144-4926-9879-FF8CBBDEF9F8}.Release|x86.Build.0 = Release|Win32 26 | {8EC29AB5-16E2-4168-B96A-47E20F61CC33}.Debug|x64.ActiveCfg = Debug|x64 27 | {8EC29AB5-16E2-4168-B96A-47E20F61CC33}.Debug|x64.Build.0 = Debug|x64 28 | {8EC29AB5-16E2-4168-B96A-47E20F61CC33}.Debug|x86.ActiveCfg = Debug|Win32 29 | {8EC29AB5-16E2-4168-B96A-47E20F61CC33}.Debug|x86.Build.0 = Debug|Win32 30 | {8EC29AB5-16E2-4168-B96A-47E20F61CC33}.Release|x64.ActiveCfg = Release|x64 31 | {8EC29AB5-16E2-4168-B96A-47E20F61CC33}.Release|x64.Build.0 = Release|x64 32 | {8EC29AB5-16E2-4168-B96A-47E20F61CC33}.Release|x86.ActiveCfg = Release|Win32 33 | {8EC29AB5-16E2-4168-B96A-47E20F61CC33}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {4F3E7E3E-42B9-4891-A202-AE25E42A6059} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /CreateNamedPipeFunction/CreateNamedPipeFunction/CreateNamedPipeFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | /* 10 | Named Pipe 11 | 12 | 1. Named Pipe é bidirecional ou unidirecional ou Full Duplex 13 | 2. Pode-se fazer simultaneamente operações leitura e escrita 14 | 3. Named Pipe é usado pra sobrepor a rede 15 | 4. é uma extenção do Pipe Tradicional 16 | 17 | Passos para programar: 18 | 19 | Servidor: Cliente: 20 | 1. Criar um pipe nomeado (CreateNamedPipe) 1. CreateFile ou CallNamedPipe 21 | 2. ConnectNamedPipe 2. WriteFile/ReadFile/TransactNamedPipe 22 | 3. WriteFile ou ReadFile 3. CloseHandle 23 | 4. FlushFileBuffers 24 | 5. DisconnectNamedPipe 25 | 6. CloseHandle 26 | */ 27 | 28 | BOOL bWriteFile; 29 | char cWriteFileBuffer[27]{"Hello World from Keowu !!!"}; 30 | DWORD dwWriteBufferSize = sizeof(cWriteFileBuffer); 31 | DWORD dwBytesWritten = 0; 32 | 33 | BOOL bReadFile; 34 | char cReadFileBuffer[1024]{ 0 }; 35 | DWORD dwReadBufferSize = sizeof(cReadFileBuffer); 36 | DWORD dwReadBytes = 0; 37 | 38 | //1º Criar o pipe 39 | char cInputBuffer[1024]{ 0 }; 40 | char cOutputBuffer[1024]{ 0 }; 41 | DWORD dwSizeInputOfBuffer = sizeof(cInputBuffer); 42 | DWORD dwSizeOutputOfBuffer = sizeof(cOutputBuffer); 43 | 44 | //https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createnamedpipea 45 | HANDLE hCreateNamedPipe = CreateNamedPipe( 46 | _In_ L"\\\\.\\pipe\\KeowuPipe", //[in] 47 | _In_ PIPE_ACCESS_DUPLEX, //[in] 48 | _In_ PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, //[in] 49 | _In_ PIPE_UNLIMITED_INSTANCES, //[in] 50 | _In_ dwSizeOutputOfBuffer, //[in] 51 | _In_ dwSizeInputOfBuffer, //[in] 52 | _In_ 0, //[in] 53 | _In_opt_ NULL //[in, optional 54 | ); 55 | 56 | if (hCreateNamedPipe == INVALID_HANDLE_VALUE) 57 | std::operator<<(std::cout, "Falhou ao criar o PIPE: ").operator<<(GetLastError()).operator<<(std::endl); 58 | 59 | std::operator<<(std::cout, "Sucesso ao criar o pipe\n"); 60 | 61 | //2º Conectar o pipe 62 | 63 | //https://docs.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-connectnamedpipe 64 | BOOL bConnectedNamedPipe = ConnectNamedPipe( 65 | _In_ hCreateNamedPipe, //[in] 66 | _In_opt_z_ NULL //[in, out, optional] 67 | ); 68 | 69 | if(!bConnectedNamedPipe) 70 | std::operator<<(std::cout, "Falhou ao conectar no PIPE: ").operator<<(GetLastError()).operator<<(std::endl); 71 | 72 | std::operator<<(std::cout, "Sucesso ao connectar ao pipe\n"); 73 | 74 | //Escrevendo arquivo 75 | 76 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-writefile 77 | bWriteFile = WriteFile( 78 | _In_ hCreateNamedPipe, //[in] 79 | _In_ cWriteFileBuffer, //[in] 80 | _In_ dwWriteBufferSize, //[in] 81 | _Out_opt_ &dwBytesWritten, //[out, optional] 82 | _In_opt_z_ NULL //[in, out, optional] 83 | ); 84 | 85 | if (!bWriteFile) 86 | std::operator<<(std::cout, "Não foi possível escrever: ").operator<<(GetLastError()).operator<<(std::endl); 87 | 88 | std::operator<<(std::cout, "Sucesso ao escrever !").operator<<(std::endl); 89 | 90 | //Flush buffer 91 | 92 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-flushfilebuffers 93 | BOOL bFlush = FlushFileBuffers( 94 | _In_ hCreateNamedPipe //[in] 95 | ); 96 | 97 | if (!bFlush) 98 | std::operator<<(std::cout, "Não foi possível fazer o flush do buffer: ").operator<<(GetLastError()).operator<<(std::endl); 99 | 100 | std::operator<<(std::cout, "Sucesso ao fazer o flush do buffer !").operator<<(std::endl); 101 | 102 | //Lendo arquivo 103 | 104 | //https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile 105 | bReadFile = ReadFile( 106 | _In_ hCreateNamedPipe, //[in] 107 | _Out_ cReadFileBuffer, //[out] 108 | _In_ dwReadBufferSize, //[in] 109 | _Out_opt_ &dwReadBytes, //[out, optional] 110 | _In_opt_z_ NULL //[in, out, optional] 111 | ); 112 | 113 | if (!bReadFile) 114 | std::operator<<(std::cout, "Não foi possível ler: ").operator<<(GetLastError()).operator<<(std::endl); 115 | 116 | std::operator<<(std::cout, "Sucesso ao ler !").operator<<(std::endl); 117 | 118 | std::printf("Dados do cliente: %s\n", cReadFileBuffer); 119 | 120 | //Disconecta o Pipe 121 | 122 | //https://docs.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-disconnectnamedpipe 123 | BOOL bDisconnect = DisconnectNamedPipe( 124 | _In_ hCreateNamedPipe //[in] 125 | ); 126 | 127 | if (!bDisconnect) 128 | std::operator<<(std::cout, "Não foi possível desconectar do pipe: ").operator<<(GetLastError()).operator<<(std::endl); 129 | 130 | std::operator<<(std::cout, "Sucesso ao desconectar !").operator<<(std::endl); 131 | 132 | //Fechar o handle 133 | 134 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 135 | BOOL bClosed = CloseHandle( 136 | _In_ hCreateNamedPipe //[in] 137 | ); 138 | 139 | if (!bClosed) 140 | std::operator<<(std::cout, "Não foi possível fechar o handle: ").operator<<(GetLastError()).operator<<(std::endl); 141 | 142 | std::operator<<(std::cout, "Sucesso ao fechar o handle !").operator<<(std::endl); 143 | 144 | return 0; 145 | } -------------------------------------------------------------------------------- /CreateNamedPipeFunction/CreateNamedPipeFunction/CreateNamedPipeFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateNamedPipeFunction/CreateNamedPipeFunction/CreateNamedPipeFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreatePipeFunction/CreatePipeFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreatePipeFunction", "CreatePipeFunction\CreatePipeFunction.vcxproj", "{99E82FD5-0401-4903-AE0B-0C07D13B9B29}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {99E82FD5-0401-4903-AE0B-0C07D13B9B29}.Debug|x64.ActiveCfg = Debug|x64 17 | {99E82FD5-0401-4903-AE0B-0C07D13B9B29}.Debug|x64.Build.0 = Debug|x64 18 | {99E82FD5-0401-4903-AE0B-0C07D13B9B29}.Debug|x86.ActiveCfg = Debug|Win32 19 | {99E82FD5-0401-4903-AE0B-0C07D13B9B29}.Debug|x86.Build.0 = Debug|Win32 20 | {99E82FD5-0401-4903-AE0B-0C07D13B9B29}.Release|x64.ActiveCfg = Release|x64 21 | {99E82FD5-0401-4903-AE0B-0C07D13B9B29}.Release|x64.Build.0 = Release|x64 22 | {99E82FD5-0401-4903-AE0B-0C07D13B9B29}.Release|x86.ActiveCfg = Release|Win32 23 | {99E82FD5-0401-4903-AE0B-0C07D13B9B29}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {E317DBBD-1558-4CAD-A14B-F64DBC2B242D} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CreatePipeFunction/CreatePipeFunction/CreatePipeFunction.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keowu/winsystemprogramming/f63f57350c29118acefb4d112cdcbd50aecfaa54/CreatePipeFunction/CreatePipeFunction/CreatePipeFunction.cpp -------------------------------------------------------------------------------- /CreatePipeFunction/CreatePipeFunction/CreatePipeFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreatePipeFunction/CreatePipeFunction/CreatePipeFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateProcessFunction/CreateProcessFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateProcessFunction", "CreateProcessFunction\CreateProcessFunction.vcxproj", "{23C6E0B8-00B6-44AA-A821-BFEC4EF7CD1F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {23C6E0B8-00B6-44AA-A821-BFEC4EF7CD1F}.Debug|x64.ActiveCfg = Debug|x64 17 | {23C6E0B8-00B6-44AA-A821-BFEC4EF7CD1F}.Debug|x64.Build.0 = Debug|x64 18 | {23C6E0B8-00B6-44AA-A821-BFEC4EF7CD1F}.Debug|x86.ActiveCfg = Debug|Win32 19 | {23C6E0B8-00B6-44AA-A821-BFEC4EF7CD1F}.Debug|x86.Build.0 = Debug|Win32 20 | {23C6E0B8-00B6-44AA-A821-BFEC4EF7CD1F}.Release|x64.ActiveCfg = Release|x64 21 | {23C6E0B8-00B6-44AA-A821-BFEC4EF7CD1F}.Release|x64.Build.0 = Release|x64 22 | {23C6E0B8-00B6-44AA-A821-BFEC4EF7CD1F}.Release|x86.ActiveCfg = Release|Win32 23 | {23C6E0B8-00B6-44AA-A821-BFEC4EF7CD1F}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {96776213-56A7-4D55-820F-AAE103600A99} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CreateProcessFunction/CreateProcessFunction/CreateProcessFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | /* 10 | Definição de processos: 11 | - Um programa em execução é chamado de processo 12 | ou 13 | - Processo é uma estrutura de dados que armazena informações sobre seu estado na memória 14 | 15 | 1º CreateProcess - Cria um novo processo 16 | 2º GetProcessID - obtem o PID do processo 17 | 3º GetThreadID - obtem o TID do processo 18 | 4º WaitForSingleObject - Espera um signal 19 | 6º CloseHandle - fecha um processoe sua thread primária 20 | */ 21 | 22 | HANDLE hProc; 23 | HANDLE hThread; 24 | 25 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa 26 | STARTUPINFO sInfo{ 0 }; //ou ZeroMemory 27 | 28 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-process_information 29 | PROCESS_INFORMATION pInfo{ 0 }; //ou ZeroMemory 30 | 31 | //https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366920(v=vs.85) 32 | ZeroMemory( 33 | &sInfo, //[in] 34 | sizeof(sInfo) //[in] 35 | ); 36 | 37 | ZeroMemory( 38 | &pInfo, //[in] 39 | sizeof(pInfo) //[in] 40 | ); 41 | 42 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa 43 | BOOL bProc = CreateProcess( 44 | L"C:\\Program Files\\VMProtect Ultimate Partner Edition\\VMProtect.exe", //[in, optional] 45 | NULL, //[in, out, optional] 46 | NULL, //[in, optional] 47 | NULL, //[in, optional] 48 | FALSE, //[in] 49 | NORMAL_PRIORITY_CLASS, //[in] NORMAL_PRIORITY_CLASS ou outras flags ou NULL para não usar flag 50 | NULL, //[in] 51 | NULL, //[in, optional] 52 | &sInfo, //[in] 53 | &pInfo //[out] 54 | ); 55 | 56 | if (!bProc) 57 | std::operator<<(std::cout, "Não foi possível criar o processo, erro obtido: ").operator<<(GetLastError()).operator<<(std::endl); 58 | 59 | 60 | std::operator<<(std::cout, "O Processo foi criado com sucesso !").operator<<(std::endl); 61 | 62 | std::operator<<(std::cout, "PID(PROCESS ID): ").operator<<(std::hex).operator<<(pInfo.dwProcessId).operator<<(std::endl); 63 | 64 | std::operator<<(std::cout, "TID(Thread ID): ").operator<<(std::hex).operator<<(pInfo.dwThreadId).operator<<(std::endl); 65 | 66 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getprocessid 67 | std::operator<<(std::cout, "PID(WINAPI): ").operator<<(std::hex).operator<<(GetProcessId(pInfo.hProcess)).operator<<(std::endl); 68 | 69 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreadid 70 | std::operator<<(std::cout, "TID(WINAPI): ").operator<<(std::hex).operator<<(GetThreadId(pInfo.hThread)).operator<<(std::endl); 71 | 72 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject 73 | WaitForSingleObject( 74 | pInfo.hProcess, //[in] 75 | 10 //[in] 76 | ); 77 | 78 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 79 | CloseHandle( 80 | pInfo.hProcess //[in] 81 | ); 82 | 83 | CloseHandle( 84 | pInfo.hThread //[in] 85 | ); 86 | 87 | std::cin.get(); 88 | 89 | return 0; 90 | } -------------------------------------------------------------------------------- /CreateProcessFunction/CreateProcessFunction/CreateProcessFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateProcessFunction/CreateProcessFunction/CreateProcessFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateRemoteThreadFunction/CreateRemoteThreadFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateRemoteThreadFunction", "CreateRemoteThreadFunction\CreateRemoteThreadFunction.vcxproj", "{FAC80F95-A83B-4A62-8A69-26C81C67901B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {FAC80F95-A83B-4A62-8A69-26C81C67901B}.Debug|x64.ActiveCfg = Debug|x64 17 | {FAC80F95-A83B-4A62-8A69-26C81C67901B}.Debug|x64.Build.0 = Debug|x64 18 | {FAC80F95-A83B-4A62-8A69-26C81C67901B}.Debug|x86.ActiveCfg = Debug|Win32 19 | {FAC80F95-A83B-4A62-8A69-26C81C67901B}.Debug|x86.Build.0 = Debug|Win32 20 | {FAC80F95-A83B-4A62-8A69-26C81C67901B}.Release|x64.ActiveCfg = Release|x64 21 | {FAC80F95-A83B-4A62-8A69-26C81C67901B}.Release|x64.Build.0 = Release|x64 22 | {FAC80F95-A83B-4A62-8A69-26C81C67901B}.Release|x86.ActiveCfg = Release|Win32 23 | {FAC80F95-A83B-4A62-8A69-26C81C67901B}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {7DF9C91A-DC81-4C6F-B9EC-346DBA0C5C30} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CreateRemoteThreadFunction/CreateRemoteThreadFunction/CreateRemoteThreadFunction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | NÃO COPIE E COLE ESSE MEU EXEMPLO EM UM SOFTWARE DE RELEASE, A NÃO SER QUE VOCÊ SEJA RETARDADO ! 3 | */ 4 | #include 5 | #include 6 | 7 | 8 | DWORD WINAPI MinhaThread(LPVOID params) { 9 | 10 | for (;;) 11 | std::operator<<(std::cout, "AEEEE BROTHER ESTOU EM OUTRO ENDERECO VIRTUAL LMAO").operator<<(std::endl); 12 | 13 | return 0; 14 | } 15 | 16 | 17 | auto main( ) -> int 18 | { 19 | std::cout << "Hello World!\n"; 20 | 21 | /* 22 | * CreateRemoteThread: 23 | Permite criar uma thread que é executada no espaço de endereço virtual de outro processo. 24 | */ 25 | 26 | //https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-findwindowa 27 | HWND hwProc = FindWindowA( 28 | NULL, //[in, optional] 29 | "Cheat Engine 7.4" //[in, optional] 30 | ); 31 | 32 | if (!hwProc) { 33 | std::operator<<(std::cout, "Não foi encontrado esse processo, erro: ").operator<<(GetLastError()).operator<<(std::endl); 34 | exit(-1); 35 | } 36 | 37 | DWORD PID = 0; 38 | 39 | //https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowthreadprocessid 40 | GetWindowThreadProcessId( 41 | hwProc, //[in] 42 | &PID //[out, optional] 43 | ); 44 | 45 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-openprocess 46 | HANDLE hProc = OpenProcess( 47 | PROCESS_ALL_ACCESS, //[in] 48 | TRUE, //[in] 49 | PID //[in] 50 | ); 51 | 52 | if (!hProc) { 53 | std::operator<<(std::cout, "Não foi possível abrir o processo, erro: ").operator<<(GetLastError()).operator<<(std::endl); 54 | exit(-1); 55 | } 56 | 57 | DWORD dTID = 0; 58 | 59 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createremotethread 60 | HANDLE hTidProcMem = CreateRemoteThread( 61 | hProc, //[in] 62 | NULL, //[in] 63 | 0, //[in] 64 | MinhaThread, //[in] 65 | NULL, //[in] 66 | NULL, //[in] 67 | &dTID //[out] 68 | ); 69 | 70 | if (hTidProcMem == INVALID_HANDLE_VALUE) { 71 | std::operator<<(std::cout, "Não foi possível iniciar a thread remota: ").operator<<(GetLastError()).operator<<(std::endl); 72 | exit(-1); 73 | } 74 | 75 | std::cin.get(); 76 | 77 | return 0; 78 | } -------------------------------------------------------------------------------- /CreateRemoteThreadFunction/CreateRemoteThreadFunction/CreateRemoteThreadFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateRemoteThreadFunction/CreateRemoteThreadFunction/CreateRemoteThreadFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateSemaphoreFunction/CreateSemaphoreFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateSemaphoreFunction", "CreateSemaphoreFunction\CreateSemaphoreFunction.vcxproj", "{A3EEC81B-71B2-4E66-97D6-492BB1654432}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenSemaphoreFunction", "OpenSemaphoreFunction\OpenSemaphoreFunction.vcxproj", "{143321AF-275B-46A1-81C6-3CA07BD3CA88}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {A3EEC81B-71B2-4E66-97D6-492BB1654432}.Debug|x64.ActiveCfg = Debug|x64 19 | {A3EEC81B-71B2-4E66-97D6-492BB1654432}.Debug|x64.Build.0 = Debug|x64 20 | {A3EEC81B-71B2-4E66-97D6-492BB1654432}.Debug|x86.ActiveCfg = Debug|Win32 21 | {A3EEC81B-71B2-4E66-97D6-492BB1654432}.Debug|x86.Build.0 = Debug|Win32 22 | {A3EEC81B-71B2-4E66-97D6-492BB1654432}.Release|x64.ActiveCfg = Release|x64 23 | {A3EEC81B-71B2-4E66-97D6-492BB1654432}.Release|x64.Build.0 = Release|x64 24 | {A3EEC81B-71B2-4E66-97D6-492BB1654432}.Release|x86.ActiveCfg = Release|Win32 25 | {A3EEC81B-71B2-4E66-97D6-492BB1654432}.Release|x86.Build.0 = Release|Win32 26 | {143321AF-275B-46A1-81C6-3CA07BD3CA88}.Debug|x64.ActiveCfg = Debug|x64 27 | {143321AF-275B-46A1-81C6-3CA07BD3CA88}.Debug|x64.Build.0 = Debug|x64 28 | {143321AF-275B-46A1-81C6-3CA07BD3CA88}.Debug|x86.ActiveCfg = Debug|Win32 29 | {143321AF-275B-46A1-81C6-3CA07BD3CA88}.Debug|x86.Build.0 = Debug|Win32 30 | {143321AF-275B-46A1-81C6-3CA07BD3CA88}.Release|x64.ActiveCfg = Release|x64 31 | {143321AF-275B-46A1-81C6-3CA07BD3CA88}.Release|x64.Build.0 = Release|x64 32 | {143321AF-275B-46A1-81C6-3CA07BD3CA88}.Release|x86.ActiveCfg = Release|Win32 33 | {143321AF-275B-46A1-81C6-3CA07BD3CA88}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {6822DE5D-2CC6-4B57-807F-DD1DC6182F5A} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /CreateSemaphoreFunction/CreateSemaphoreFunction/CreateSemaphoreFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | /* 10 | Semaphore: 11 | 1 - Semaphore é uma variável inteira (Mutex é um objeto) 12 | 2 - Semaphore é um mecanismo de signals (Mutex é um mecanismo de locking) 13 | 3 - No Semaphore o valor pode ser modificado usando operações WAIT & SIGNAL (Mutex - Somente Locked e Unlocked) 14 | 4 - Semaphore tem dois tipos (Mutex não tem categoria) 15 | i. Semaphore Binário(Binary Semaphore) 16 | ii. Semaphor de contagem(Counting Semaphore) 17 | 5 - O valor de um Semaphore pode ser modiciado por um processo adquirindo ou liberando o Semaphore 18 | (Mutex - Somente quem adquiriu o lock pode fazer unlocking por exemplo um Mutual Ownership) 19 | */ 20 | 21 | //https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsemaphorea 22 | HANDLE hSemaphore = CreateSemaphore( 23 | _In_opt_ NULL, //[In, Optional] 24 | _In_ 1, //[In] 25 | _In_ 1, //[In] 26 | _In_opt_ NULL //[In, Optional] -> Unamed Semaphore 27 | ); 28 | 29 | if (!hSemaphore) 30 | std::operator<<(std::cout, "Erro ao criar o unamed semaphore: ").operator<<(GetLastError()).operator<<(std::endl); 31 | 32 | std::operator<<(std::cout, "Sucesso ao criar o unamed semaphore").operator<<(std::endl); 33 | 34 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 35 | BOOL bClosed = CloseHandle( 36 | _In_ hSemaphore //[In] 37 | ); 38 | 39 | if(!bClosed) 40 | std::operator<<(std::cout, "Erro ao fechar o handle: ").operator<<(GetLastError()).operator<<(std::endl); 41 | 42 | std::cin.get(); 43 | 44 | hSemaphore = CreateSemaphore( 45 | _In_opt_ NULL, //[In, Optional] 46 | _In_ 1, //[In] 47 | _In_ 1, //[In] 48 | _In_opt_ L"ONomeDoSemaphoreVaiAqui" //[In, Optional] -> Named Semaphore 49 | ); 50 | 51 | if (!hSemaphore) 52 | std::operator<<(std::cout, "Erro ao criar o semaphore named: ").operator<<(GetLastError()).operator<<(std::endl); 53 | 54 | std::operator<<(std::cout, "Sucesso ao criar o semaphore named").operator<<(std::endl); 55 | 56 | bClosed = CloseHandle( 57 | _In_ hSemaphore //[In] 58 | ); 59 | 60 | if (!bClosed) 61 | std::operator<<(std::cout, "Erro ao fechar o handle: ").operator<<(GetLastError()).operator<<(std::endl); 62 | 63 | return 0; 64 | } -------------------------------------------------------------------------------- /CreateSemaphoreFunction/CreateSemaphoreFunction/CreateSemaphoreFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateSemaphoreFunction/CreateSemaphoreFunction/CreateSemaphoreFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateSemaphoreFunction/OpenSemaphoreFunction/OpenSemaphoreFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-opensemaphorew 10 | HANDLE hSem = OpenSemaphore( 11 | _In_ SEMAPHORE_ALL_ACCESS, //[in] 12 | _In_ FALSE, //[in] 13 | _In_ L"ONomeDoSemaphoreVaiAqui" //[in] 14 | ); 15 | 16 | if (!hSem) 17 | std::operator<<(std::cout, "Erro ao abrir o semaphore nomeado: ").operator<<(GetLastError()).operator<<(std::endl); 18 | 19 | std::operator<<(std::cout, "Sucesso ao abrir o semaphore nomeado").operator<<(std::endl); 20 | 21 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 22 | BOOL bClosed = CloseHandle( 23 | _In_ hSem //[in] 24 | ); 25 | 26 | if (!bClosed) 27 | std::operator<<(std::cout, "Erro ao fechar o handle: ").operator<<(GetLastError()).operator<<(std::endl); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /CreateSemaphoreFunction/OpenSemaphoreFunction/OpenSemaphoreFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateSemaphoreFunction/OpenSemaphoreFunction/OpenSemaphoreFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateThreadFunction/CreateThreadFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateThreadFunction", "CreateThreadFunction\CreateThreadFunction.vcxproj", "{74C66ABD-ED60-43F5-9ED5-7562BD4E0E45}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {74C66ABD-ED60-43F5-9ED5-7562BD4E0E45}.Debug|x64.ActiveCfg = Debug|x64 17 | {74C66ABD-ED60-43F5-9ED5-7562BD4E0E45}.Debug|x64.Build.0 = Debug|x64 18 | {74C66ABD-ED60-43F5-9ED5-7562BD4E0E45}.Debug|x86.ActiveCfg = Debug|Win32 19 | {74C66ABD-ED60-43F5-9ED5-7562BD4E0E45}.Debug|x86.Build.0 = Debug|Win32 20 | {74C66ABD-ED60-43F5-9ED5-7562BD4E0E45}.Release|x64.ActiveCfg = Release|x64 21 | {74C66ABD-ED60-43F5-9ED5-7562BD4E0E45}.Release|x64.Build.0 = Release|x64 22 | {74C66ABD-ED60-43F5-9ED5-7562BD4E0E45}.Release|x86.ActiveCfg = Release|Win32 23 | {74C66ABD-ED60-43F5-9ED5-7562BD4E0E45}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {429848FE-87B1-4A27-8C74-E0394853DB2E} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CreateThreadFunction/CreateThreadFunction/CreateThreadFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //Use DWORD WINAPI assinatura e LPVOID para parametros 5 | DWORD WINAPI MinhaThread(LPVOID lpParams) { 6 | 7 | 8 | while (TRUE) 9 | std::operator<<(std::cout, "Poxa Brother tou preso no loop, vou ficar ruim da cabeca assim !").operator<<(std::endl); 10 | 11 | 12 | return 0; 13 | } 14 | 15 | 16 | auto main( ) -> int 17 | { 18 | 19 | std::cout << "Hello World!\n"; 20 | 21 | 22 | /* 23 | Definição: 24 | Thread é uma entidade independente que roda com um processo. 25 | Notas: 26 | 1 - Thread compartilha alguns recursos com o processo exceto STACK e Registradores 27 | 2 - Por padrão o máximo que um thread pode ter de tamanho no Windows é 1 MB de stack 28 | 3 - Podem ser criados no máximo 2048 threads no Window em um processo em execução(De acordo com a documentação da Microsoft) 29 | 4 - Terminar uma thread não necessáriamente removera o objeto dela do sistema operacional isso só acontecera se o último handle dela for fechado 30 | 5 - Para mais informações o GOOGLE é seu amigo! 31 | */ 32 | 33 | DWORD hTID = 0; 34 | 35 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread 36 | HANDLE hThread = CreateThread( 37 | NULL, //[in, optional] 38 | 100, //[in] 39 | MinhaThread, //[in] 40 | NULL, //[in, optional] 41 | NULL, //[in] -> NULL é uma macro que expande para zero, zero inicia a thread automáticamente, CREATE_SUSPENDED suspende a thread e STACK_SIZE_PARAM_IS_A_RESERVATION reserva a stack para a thread 42 | &hTID //[out, optional] 43 | ); 44 | 45 | if (hThread == INVALID_HANDLE_VALUE) 46 | std::operator<<(std::cout, "Não foi possivel criar a thread: ").operator<<(GetLastError()).operator<<(std::endl); 47 | 48 | std::operator<<(std::cout, "Sucesso ao criar a thread para matar ela aperte qualquer tecla").operator<<(std::endl); 49 | 50 | std::cin.get(); 51 | 52 | std::operator<<(std::cout, "Matei a thread: ").operator<<(std::hex).operator<<(hTID).operator<<(std::endl); 53 | 54 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread 55 | BOOL bThread = TerminateThread( 56 | hThread, //[in, out] 57 | 0x00 //[in] 58 | ); 59 | 60 | if (!bThread) 61 | std::operator<<(std::cout, "A thread não pode ser encerrada: ").operator<<(GetLastError()).operator<<(std::endl); 62 | 63 | std::operator<<(std::cout, "A Thread foi encerrada com sucesso !").operator<<(std::endl); 64 | 65 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 66 | BOOL bClosed = CloseHandle( 67 | hThread //[in] 68 | ); 69 | 70 | if (!bClosed) 71 | std::operator<<(std::cout, "Não foi possível fechar o Handle !").operator<<(GetLastError()).operator<<(std::endl); 72 | 73 | std::operator<<(std::cout, "o Handle foi fechado com sucesso !").operator<<(std::endl); 74 | 75 | //CRIANDO UMA THREAD SUSPENSA 76 | 77 | hThread = CreateThread( 78 | NULL, //[in, optional] 79 | 100, //[in] 80 | MinhaThread, //[in] 81 | NULL, //[in, optional] 82 | CREATE_SUSPENDED, //[in] -> NULL é uma macro que expande para zero, zero inicia a thread automáticamente, CREATE_SUSPENDED suspende a thread e STACK_SIZE_PARAM_IS_A_RESERVATION reserva a stack para a thread 83 | &hTID //[out, optional] 84 | ); 85 | 86 | if(hThread == INVALID_HANDLE_VALUE) 87 | std::operator<<(std::cout, "Não foi possivel criar a thread: ").operator<<(GetLastError()).operator<<(std::endl); 88 | 89 | std::operator<<(std::cout, "Sucesso ao criar a thread!").operator<<(std::endl); 90 | 91 | std::operator<<(std::cout, "Apete uma tecla para iniciar a thread que estava em espera ").operator<<(std::endl); 92 | 93 | std::cin.get(); 94 | 95 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-resumethread 96 | if (!ResumeThread( 97 | hThread //[in] 98 | ) == -1) 99 | std::operator<<(std::cout, "A Thread não pode ser retomada um erro aconteceu: ").operator<<(GetLastError()).operator<<(std::endl); 100 | 101 | std::operator<<(std::cout, "Sucesso ao resumar a thread !").operator<<(std::endl); 102 | 103 | return 0; 104 | } -------------------------------------------------------------------------------- /CreateThreadFunction/CreateThreadFunction/CreateThreadFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateThreadFunction/CreateThreadFunction/CreateThreadFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CreateThreadWithCustomParamsFunction/CreateThreadWithCustomParamsFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateThreadWithCustomParamsFunction", "CreateThreadWithCustomParamsFunction\CreateThreadWithCustomParamsFunction.vcxproj", "{153ACFEF-854B-4735-AEC2-5F3AF0F398F3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {153ACFEF-854B-4735-AEC2-5F3AF0F398F3}.Debug|x64.ActiveCfg = Debug|x64 17 | {153ACFEF-854B-4735-AEC2-5F3AF0F398F3}.Debug|x64.Build.0 = Debug|x64 18 | {153ACFEF-854B-4735-AEC2-5F3AF0F398F3}.Debug|x86.ActiveCfg = Debug|Win32 19 | {153ACFEF-854B-4735-AEC2-5F3AF0F398F3}.Debug|x86.Build.0 = Debug|Win32 20 | {153ACFEF-854B-4735-AEC2-5F3AF0F398F3}.Release|x64.ActiveCfg = Release|x64 21 | {153ACFEF-854B-4735-AEC2-5F3AF0F398F3}.Release|x64.Build.0 = Release|x64 22 | {153ACFEF-854B-4735-AEC2-5F3AF0F398F3}.Release|x86.ActiveCfg = Release|Win32 23 | {153ACFEF-854B-4735-AEC2-5F3AF0F398F3}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {CE1187F1-0C4E-4264-B664-59E2801930A1} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CreateThreadWithCustomParamsFunction/CreateThreadWithCustomParamsFunction/CreateThreadWithCustomParamsFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | typedef struct blastruct{ 6 | std::int32_t idade; 7 | bool isInfeliz; 8 | }; 9 | 10 | 11 | DWORD WINAPI MinhaThread(LPVOID params) { 12 | 13 | auto bla = *reinterpret_cast(params); 14 | 15 | std::printf("\nIDADE: %d, FELIZ: %d", bla.idade, bla.isInfeliz); 16 | 17 | return 0; 18 | } 19 | 20 | 21 | auto main() -> int 22 | { 23 | 24 | std::cout << "Hello World!\n"; 25 | 26 | DWORD dTID; 27 | 28 | blastruct* bla = reinterpret_cast(malloc(sizeof(blastruct))); 29 | 30 | ZeroMemory(bla, sizeof(bla)); 31 | 32 | bla->idade = 400; 33 | 34 | bla->isInfeliz = false; 35 | 36 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread 37 | HANDLE hThread = CreateThread( 38 | NULL, //[in, optional] 39 | 0, //[in] 40 | MinhaThread, //[in] 41 | (void*)bla, //[in, optional] 42 | NULL, //[in] 43 | &dTID //[out, optional] 44 | ); 45 | 46 | if (hThread == INVALID_HANDLE_VALUE) 47 | std::operator<<(std::cout, "Ocorreu um erro ao abrir um handle para a thread: ").operator<<(GetLastError()).operator<<(std::endl); 48 | 49 | std::operator<<(std::cout, "Sucesso ao criar um handle para a thread, ela comecou a executar !"); 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /CreateThreadWithCustomParamsFunction/CreateThreadWithCustomParamsFunction/CreateThreadWithCustomParamsFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CreateThreadWithCustomParamsFunction/CreateThreadWithCustomParamsFunction/CreateThreadWithCustomParamsFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CriticalSectionFunction/CriticalSectionFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CriticalSectionFunction", "CriticalSectionFunction\CriticalSectionFunction.vcxproj", "{A5D3DD70-FB79-43BF-891F-7AC867635AFE}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A5D3DD70-FB79-43BF-891F-7AC867635AFE}.Debug|x64.ActiveCfg = Debug|x64 17 | {A5D3DD70-FB79-43BF-891F-7AC867635AFE}.Debug|x64.Build.0 = Debug|x64 18 | {A5D3DD70-FB79-43BF-891F-7AC867635AFE}.Debug|x86.ActiveCfg = Debug|Win32 19 | {A5D3DD70-FB79-43BF-891F-7AC867635AFE}.Debug|x86.Build.0 = Debug|Win32 20 | {A5D3DD70-FB79-43BF-891F-7AC867635AFE}.Release|x64.ActiveCfg = Release|x64 21 | {A5D3DD70-FB79-43BF-891F-7AC867635AFE}.Release|x64.Build.0 = Release|x64 22 | {A5D3DD70-FB79-43BF-891F-7AC867635AFE}.Release|x86.ActiveCfg = Release|Win32 23 | {A5D3DD70-FB79-43BF-891F-7AC867635AFE}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {A937EC55-1573-46CD-9B50-F645BE575394} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CriticalSectionFunction/CriticalSectionFunction/CriticalSectionFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int g_count = 1; // Brother, evite deixar global! 5 | 6 | //https://docs.microsoft.com/pt-br/windows/win32/sync/critical-section-objects 7 | CRITICAL_SECTION g_criticalSec; 8 | 9 | auto WINAPI FunctEven(LPVOID params) -> DWORD { 10 | 11 | while (g_count < 10) { 12 | 13 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-entercriticalsection 14 | EnterCriticalSection( 15 | _Inout_ &g_criticalSec //[in, out] 16 | ); 17 | 18 | if (g_count % 2 == 0) 19 | std::cout << "Par -> " << g_count++ << std::endl; 20 | 21 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-leavecriticalsection 22 | LeaveCriticalSection( 23 | _Inout_ &g_criticalSec //[in, out] 24 | ); 25 | 26 | } 27 | 28 | return 0; 29 | } 30 | 31 | auto WINAPI FunctOdd(LPVOID params) -> DWORD { 32 | 33 | while (g_count < 10) { 34 | 35 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-entercriticalsection 36 | EnterCriticalSection( 37 | _Inout_ &g_criticalSec //[in, out] 38 | ); 39 | 40 | if (g_count % 2 == 1) 41 | std::cout << "Impar -> " << g_count++ << std::endl; 42 | 43 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-leavecriticalsection 44 | LeaveCriticalSection( 45 | _Inout_ &g_criticalSec //[in, out] 46 | ); 47 | 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | auto main() -> int 54 | { 55 | 56 | std::cout << "Hello World!\n"; 57 | 58 | /* 59 | Critical Section no Windows 60 | 61 | Seção creitica é uma região de código que precisa ser executada atomicamente ou com operação indivisivel 62 | Seção critica usada para sincronização 63 | Isso provê um "lock" similar ao do mutex 64 | O Processo só é responsável por alocar memória usada pelo critical section. 65 | 66 | Exemplo: 67 | 68 | do { 69 | Entry_Section(); 70 | //CRITICAL_SECTION 71 | Exit_Section(); 72 | }while(TRUE); 73 | 74 | Diferenças entre o CRITICAL_SECTION e o MUTEX 75 | 76 | Critical section: 77 | 1. Objeto C.S não é compartilhado pelo processo 78 | 2. C.S é usado por somente uma thread de um processo 79 | 3. Ele não consegue comunicar com o kernel 80 | 4. É consideravelmente mais rápido que Event, Mutex e Semaphore 81 | 82 | Mutex: 83 | 1. Objeto Mutex é compartilhado pelos processos 84 | 2. É usado em mais de um processo 85 | 3. Ele pode comunicar com o Kernel 86 | 4. Ele é lento e pode ocasionar um risco de deadlock 87 | 88 | Critical Section API's: 89 | 1. InitializeCriticalSection 90 | 2. InitializeCriticalSectionAndSpinCount 91 | 3. EnterCriticalSection 92 | 4. TryEnterCriticalSection 93 | 5. LeaveCriticalSection 94 | 6. SetCriticalSectionSpinCount 95 | 7. DeleteCriticalSection 96 | */ 97 | 98 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initializecriticalsection 99 | InitializeCriticalSection( 100 | _Out_ &g_criticalSec //[out] 101 | ); 102 | 103 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread 104 | auto hThread = CreateThread( 105 | _In_opt_ NULL, //[in, optional] 106 | _In_ 0, //[in] 107 | _In_ FunctEven, //[in] 108 | _In_opt_ __drv_aliasesMem NULL, //[in, out] 109 | _In_ 0, //[in] 110 | _Out_opt_ 0 //[out, optional] 111 | ); 112 | 113 | if (hThread == INVALID_HANDLE_VALUE) 114 | std::operator<<(std::cout, "Falhou ao criar a thread: ").operator<<(GetLastError()); 115 | 116 | std::operator<<(std::cout, "Sucesso ao criar a thread !\n"); 117 | 118 | //https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread 119 | auto hThread2 = CreateThread( 120 | _In_opt_ NULL, //[in, optional] 121 | _In_ 0, //[in] 122 | _In_ FunctOdd, //[in] 123 | _In_opt_ __drv_aliasesMem NULL, //[in, out] 124 | _In_ 0, //[in] 125 | _Out_opt_ 0 //[out, optional] 126 | ); 127 | 128 | if (hThread2 == INVALID_HANDLE_VALUE) 129 | std::operator<<(std::cout, "Falhou ao criar a thread: ").operator<<(GetLastError()); 130 | 131 | std::operator<<(std::cout, "Sucesso ao criar a thread !\n"); 132 | 133 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject 134 | auto dwWaitForSingle = WaitForSingleObject( 135 | _In_ hThread, //[in] 136 | _In_ INFINITE //[in] 137 | ); 138 | 139 | if (dwWaitForSingle == WAIT_FAILED) 140 | std::operator<<(std::cout, "Falhou ao esperar pelo objeto: ").operator<<(GetLastError()); 141 | 142 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject 143 | dwWaitForSingle = WaitForSingleObject( 144 | _In_ hThread2, //[in] 145 | _In_ INFINITE //[in] 146 | ); 147 | 148 | if(dwWaitForSingle == WAIT_FAILED) 149 | std::operator<<(std::cout, "Falhou ao esperar pelo objeto: ").operator<<(GetLastError()); 150 | 151 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 152 | if (!CloseHandle( 153 | _In_ _Post_ptr_invalid_ hThread //[in] 154 | )) 155 | std::operator<<(std::cout, "Falhou ao fechar o HANDLE !\n"); 156 | 157 | //https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle 158 | if(!CloseHandle( 159 | _In_ _Post_ptr_invalid_ hThread2 //[in] 160 | )) 161 | std::operator<<(std::cout, "Falhou ao fechar o HANDLE !\n"); 162 | 163 | //https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-deletecriticalsection 164 | DeleteCriticalSection( 165 | _Inout_ &g_criticalSec //[in, out] 166 | ); 167 | 168 | return 0; 169 | } -------------------------------------------------------------------------------- /CriticalSectionFunction/CriticalSectionFunction/CriticalSectionFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /CriticalSectionFunction/CriticalSectionFunction/CriticalSectionFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /FileMappingIPCFunction/FileMappingIPCFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileMappingIPCFunction", "FileMappingIPCFunction\FileMappingIPCFunction.vcxproj", "{6F289C5C-A5B1-4D0D-8D29-ADB156F7C038}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileMappingIPCFunctionClient", "FileMappingIPCFunctionClient\FileMappingIPCFunctionClient.vcxproj", "{98F64816-1CBC-4921-A0DF-7629E6026D2A}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {6F289C5C-A5B1-4D0D-8D29-ADB156F7C038}.Debug|x64.ActiveCfg = Debug|x64 19 | {6F289C5C-A5B1-4D0D-8D29-ADB156F7C038}.Debug|x64.Build.0 = Debug|x64 20 | {6F289C5C-A5B1-4D0D-8D29-ADB156F7C038}.Debug|x86.ActiveCfg = Debug|Win32 21 | {6F289C5C-A5B1-4D0D-8D29-ADB156F7C038}.Debug|x86.Build.0 = Debug|Win32 22 | {6F289C5C-A5B1-4D0D-8D29-ADB156F7C038}.Release|x64.ActiveCfg = Release|x64 23 | {6F289C5C-A5B1-4D0D-8D29-ADB156F7C038}.Release|x64.Build.0 = Release|x64 24 | {6F289C5C-A5B1-4D0D-8D29-ADB156F7C038}.Release|x86.ActiveCfg = Release|Win32 25 | {6F289C5C-A5B1-4D0D-8D29-ADB156F7C038}.Release|x86.Build.0 = Release|Win32 26 | {98F64816-1CBC-4921-A0DF-7629E6026D2A}.Debug|x64.ActiveCfg = Debug|x64 27 | {98F64816-1CBC-4921-A0DF-7629E6026D2A}.Debug|x64.Build.0 = Debug|x64 28 | {98F64816-1CBC-4921-A0DF-7629E6026D2A}.Debug|x86.ActiveCfg = Debug|Win32 29 | {98F64816-1CBC-4921-A0DF-7629E6026D2A}.Debug|x86.Build.0 = Debug|Win32 30 | {98F64816-1CBC-4921-A0DF-7629E6026D2A}.Release|x64.ActiveCfg = Release|x64 31 | {98F64816-1CBC-4921-A0DF-7629E6026D2A}.Release|x64.Build.0 = Release|x64 32 | {98F64816-1CBC-4921-A0DF-7629E6026D2A}.Release|x86.ActiveCfg = Release|Win32 33 | {98F64816-1CBC-4921-A0DF-7629E6026D2A}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {A7BCFBC8-0FFF-4345-A773-F022CE3BEFA7} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /FileMappingIPCFunction/FileMappingIPCFunction/FileMappingIPCFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | /* 10 | Mapeamento de arquivos intermédio do IPC(Inter comunication process): 11 | 1 - Mapeamento de arquivo é semelhante ao conceito da memória compartilhada 12 | 2 - Mapeamento é local do sistema e não pode ser usado em rede 13 | 3 - Sem que que criamos um objeto de arquivo mapeado esse objeto é tratado como um block e memória compartilhada 14 | 4 - Isso é útil quando informações entre processos mudam com frequencia 15 | Por exemplo: 16 | Suponha que eu tenho muitas informações de recursos então: 17 | i. 1º O Processo obtem informações 18 | ii. 2º Processo muda essas informações 19 | iii. 3º Processo mostrara essas informações na tela 20 | 5 - Sempre que um objeto de arquivo mapeado requer alguma técnica de sincronização outro processo contamina a informação. 21 | 22 | Como funciona o mapeamento de arquivos: 23 | Temos três maneiras que uma aplicação compartilha um objeto de arquivo mapeado: 24 | 1 - Herança 25 | 2 - Arquivo nomeado mapeado 26 | 3 - Duplicação de Handle 27 | 28 | Exemplo de funcionamento: 29 | i. 1º O Processo sempre cria um objeto de arquivo mapeado 30 | ii. 2º Process(filho) obtem um handle do processo pai 31 | 32 | 33 | Servidor ou "Pai" Cliente ou "Filho" 34 | 35 | 1 - CreateFileMapping 1 - OpenFileMapping 36 | 2 - MapViewOfFile 2 - MapViewOfFile 37 | 3 - CopyMemory 3 - Escrever o conteúdo do arquivo 38 | 4 - UnMapViewOfFile 4 - UnMapViewOfFile 39 | 5 - CloseHandle 40 | 41 | //Seria Keowu - kernel + Owu 42 | */ 43 | 44 | char bufferMapp[35]{ "Hello world, keowu keowu keowu !!" }; 45 | size_t szBufferMapp = sizeof(bufferMapp); 46 | 47 | //https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createfilemappinga 48 | HANDLE hFile = CreateFileMapping( 49 | _In_ INVALID_HANDLE_VALUE, //[in] 50 | _In_ NULL, //[in, optional] 51 | _In_ PAGE_EXECUTE_READWRITE, //[in] 52 | _In_ 0, //[in] 53 | _In_ 256, //[in] 54 | _In_opt_ L"Local\\KeowuFileMapp" //[in, optional] 55 | ); 56 | 57 | if (hFile == INVALID_HANDLE_VALUE) 58 | std::operator<<(std::cout, "Falhou ao criar handle código: ").operator<<(GetLastError()).operator<<(std::endl); 59 | 60 | std::operator<<(std::cout, "Sucesso ao criar o handle").operator<<(std::endl); 61 | 62 | //https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile 63 | PCHAR lpBuffer = (PCHAR)MapViewOfFile( 64 | _In_ hFile, //[in] 65 | _In_ FILE_MAP_ALL_ACCESS, //[in] 66 | _In_ 0, //[in] 67 | _In_ 0,//[in] 68 | _In_ 256 //[in] 69 | ); 70 | 71 | if (!lpBuffer) 72 | std::operator<<(std::cout, "Falhou ao usar mapviewoffile: ").operator<<(GetLastError()).operator<<(std::endl); 73 | 74 | std::operator<<(std::cout, "Sucesso ao usar mapviewoffile !").operator<<(std::endl); 75 | 76 | https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366535(v=vs.85) 77 | CopyMemory( 78 | _In_ lpBuffer, //[in] 79 | _In_ bufferMapp, //[in] 80 | _In_ szBufferMapp //[in] 81 | ); 82 | 83 | //https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-unmapviewoffile 84 | BOOL bUnmap = UnmapViewOfFile( 85 | _In_ lpBuffer //[in] 86 | ); 87 | 88 | if(!bUnmap) 89 | std::operator<<(std::cout, "Falhou ao usar UnmapViewOfFile: ").operator<<(GetLastError()).operator<<(std::endl); 90 | 91 | std::operator<<(std::cout, "Sucesso ao usar UnmapViewOfFile !").operator<<(std::endl); 92 | 93 | if(!CloseHandle( 94 | _In_ hFile //[in] 95 | )) 96 | std::operator<<(std::cout, "Falhou ao fechar o handle: ").operator<<(GetLastError()).operator<<(std::endl); 97 | 98 | std::operator<<(std::cout, "Sucesso ao fechar o handle !").operator<<(std::endl); 99 | 100 | return 0; 101 | } -------------------------------------------------------------------------------- /FileMappingIPCFunction/FileMappingIPCFunction/FileMappingIPCFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /FileMappingIPCFunction/FileMappingIPCFunction/FileMappingIPCFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /FileMappingIPCFunction/FileMappingIPCFunctionClient/FileMappingIPCFunctionClient.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | //https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-openfilemappinga 10 | HANDLE hFileMap = OpenFileMapping( 11 | _In_ FILE_MAP_ALL_ACCESS, //[in] 12 | _In_ FALSE, //[in] 13 | _In_ L"Local\\KeowuFileMapp" //[in] 14 | ); 15 | 16 | //https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile 17 | PCHAR buffer = (PCHAR)MapViewOfFile( 18 | _In_ hFileMap, //[in] 19 | _In_ FILE_MAP_ALL_ACCESS, //[in] 20 | _In_ 0, //[in] 21 | _In_ 0, //[in] 22 | _In_ 256 //[in] 23 | ); 24 | 25 | if (!buffer) 26 | std::operator<<(std::cout, "Não foi possível mapear arquivo: ").operator<<(GetLastError()).operator<<(std::endl); 27 | 28 | std::operator<<(std::cout, "Sucesso em mapear arquivo !").operator<<(std::endl); 29 | 30 | std::printf("Enviado do servidor -> %s", buffer); 31 | 32 | //https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-unmapviewoffile 33 | BOOL bUnmapFile = UnmapViewOfFile( 34 | _In_ buffer //[in] 35 | ); 36 | 37 | if(!bUnmapFile) 38 | std::operator<<(std::cout, "Não foi possível fazer unmap do arquivo: ").operator<<(GetLastError()).operator<<(std::endl); 39 | 40 | std::operator<<(std::cout, "Sucesso em unmapear arquivo !").operator<<(std::endl); 41 | 42 | if(!CloseHandle( 43 | hFileMap 44 | )) 45 | std::operator<<(std::cout, "O Handle não pode ser fechado: ").operator<<(GetLastError()).operator<<(std::endl); 46 | 47 | std::operator<<(std::cout, "Sucesso ao fechar o handle !").operator<<(std::endl); 48 | 49 | return 0; 50 | } -------------------------------------------------------------------------------- /FileMappingIPCFunction/FileMappingIPCFunctionClient/FileMappingIPCFunctionClient.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /FileMappingIPCFunction/FileMappingIPCFunctionClient/FileMappingIPCFunctionClient.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /HardLinkFunction/HardLinkFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HardLinkFunction", "HardLinkFunction\HardLinkFunction.vcxproj", "{3B46B9C6-3B6E-4DDF-A17E-2FA7E81E32E5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {3B46B9C6-3B6E-4DDF-A17E-2FA7E81E32E5}.Debug|x64.ActiveCfg = Debug|x64 17 | {3B46B9C6-3B6E-4DDF-A17E-2FA7E81E32E5}.Debug|x64.Build.0 = Debug|x64 18 | {3B46B9C6-3B6E-4DDF-A17E-2FA7E81E32E5}.Debug|x86.ActiveCfg = Debug|Win32 19 | {3B46B9C6-3B6E-4DDF-A17E-2FA7E81E32E5}.Debug|x86.Build.0 = Debug|Win32 20 | {3B46B9C6-3B6E-4DDF-A17E-2FA7E81E32E5}.Release|x64.ActiveCfg = Release|x64 21 | {3B46B9C6-3B6E-4DDF-A17E-2FA7E81E32E5}.Release|x64.Build.0 = Release|x64 22 | {3B46B9C6-3B6E-4DDF-A17E-2FA7E81E32E5}.Release|x86.ActiveCfg = Release|Win32 23 | {3B46B9C6-3B6E-4DDF-A17E-2FA7E81E32E5}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {35E2280D-7EF7-4C57-B6AE-D32820ED755A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /HardLinkFunction/HardLinkFunction/HardLinkFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main() -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | /* 10 | * Hardlink 11 | 1 - Um arquivo pode ter dois diferentes nomes 12 | 2 - Hardlink somente pode ser criado para arquivos e não para diretórios 13 | 3 - Se você excluir o arquivo original, então ele podera ser acessivel via um hardlink do arquivo 14 | 4 - Isso é criado na memória(Memória Física) 15 | */ 16 | 17 | //https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createhardlinka 18 | BOOL hFile = CreateHardLink( 19 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\a.txt", 20 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\testeardlink.txt", 21 | NULL 22 | ); 23 | 24 | if (!hFile) 25 | std::operator<<(std::cout, "Erro ao criar um hardlink").operator<<(std::endl); 26 | 27 | std::operator<<(std::cout, "Sucesso ao criar hardlink").operator<<(std::endl); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /HardLinkFunction/HardLinkFunction/HardLinkFunction.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {3b46b9c6-3b6e-4ddf-a17e-2fa7e81e32e5} 25 | HardLinkFunction 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | true 129 | true 130 | true 131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /HardLinkFunction/HardLinkFunction/HardLinkFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /HardLinkFunction/HardLinkFunction/HardLinkFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /RegistryInWindows/RegistryInWindows.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RegistryInWindows", "RegistryInWindows\RegistryInWindows.vcxproj", "{EAA6AAFE-2C91-49A6-9DE3-12B294D2ED3E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {EAA6AAFE-2C91-49A6-9DE3-12B294D2ED3E}.Debug|x64.ActiveCfg = Debug|x64 17 | {EAA6AAFE-2C91-49A6-9DE3-12B294D2ED3E}.Debug|x64.Build.0 = Debug|x64 18 | {EAA6AAFE-2C91-49A6-9DE3-12B294D2ED3E}.Debug|x86.ActiveCfg = Debug|Win32 19 | {EAA6AAFE-2C91-49A6-9DE3-12B294D2ED3E}.Debug|x86.Build.0 = Debug|Win32 20 | {EAA6AAFE-2C91-49A6-9DE3-12B294D2ED3E}.Release|x64.ActiveCfg = Release|x64 21 | {EAA6AAFE-2C91-49A6-9DE3-12B294D2ED3E}.Release|x64.Build.0 = Release|x64 22 | {EAA6AAFE-2C91-49A6-9DE3-12B294D2ED3E}.Release|x86.ActiveCfg = Release|Win32 23 | {EAA6AAFE-2C91-49A6-9DE3-12B294D2ED3E}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {58FF73A2-3842-4071-8969-7AA2ACC10424} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /RegistryInWindows/RegistryInWindows/RegistryInWindows.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | auto main( ) -> int 6 | { 7 | 8 | std::cout << "Hello World!\n"; 9 | 10 | 11 | /* 12 | Os Registros: 13 | 14 | Os registros podem ser definidos como uma "database" hierarquica e centralizada para aplicações 15 | e para configurações do sistema operacional 16 | 17 | Informação: Registros no Windows são armazenados seguindo o padrão chave/valor 18 | 19 | Os registros podem conter informações como por exemplo: 20 | 21 | 1 - Número da versão, número da build, e dados do usuário. 22 | 2 - Informações sobre o computador como por exemplo tipo do processador 23 | 3 - Informações especificas do usuário 24 | 4 - Segurança da informação 25 | 5 - Serviços instalados, isso incluí drivers/anticheats etc 26 | 6 - Nome do arquivo e extensões 27 | 28 | Chaves de registro: 29 | 1 - HKEY_LOCAL_MACHINE: É armazenado informações fisicas sobre a maquna com os softwares instalados. 30 | 2 - HKEY_USERS: É definido informaões de configurações para o usuário 31 | 3 - HKEY_CURRENT_CONFIG: Contem configurações para o usuário como fontes e resoluções 32 | 4 - HKEY_CLASSES_ROOT: Contem entradas para mapeamento de arquivos e extenções 33 | 5 - HKEY_CURRENT_USER: Contem informações especificas do usuário 34 | 35 | Para Windows internals você pode acessar os registros através do regedit.exe 36 | 37 | 38 | */ 39 | 40 | //https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regcreatekeyexa 41 | 42 | HKEY hKey; 43 | 44 | LONG lReg = RegCreateKeyEx( 45 | HKEY_LOCAL_MACHINE, //[in] -> HKEY_CLASSES_ROOT, HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE e HKEY_USERS 46 | L"Software\\VmpSoftware\\VmProtect\\License\\licenseID", //[in] -> https://docs.microsoft.com/en-us/windows/desktop/SysInfo/structure-of-the-registry 47 | NULL, //[optional] 48 | NULL, //[in] 49 | REG_OPTION_NON_VOLATILE, //[in] -> REG_OPTION_BACKUP_RESTORE, REG_OPTION_CREATE_LINK, REG_OPTION_VOLATILE e a MAIS COMUM QUE É A REG_OPTION_NON_VOLATILE 50 | KEY_ALL_ACCESS | KEY_WOW64_64KEY, //[in] -> https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-key-security-and-access-rights 51 | NULL, //[optional] 52 | &hKey, //[out] 53 | NULL //[optional] 54 | ); 55 | 56 | 57 | if (lReg == ERROR_SUCCESS) 58 | std::operator<<(std::cout, "Erro ao criar a chave de registro ").operator<<(GetLastError()).operator<<(std::endl); 59 | 60 | 61 | std::operator<<(std::cout, "Sucesso ao criar chave de registro !").operator<<(std::endl); 62 | 63 | std::cin.get(); 64 | 65 | DWORD dwData = 777; 66 | 67 | //https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsetvalueexa 68 | lReg = RegSetValueEx( 69 | hKey, //[in] 70 | L"LICENSEID_OLAMUNDO", //[in, optional] 71 | NULL, //Brisas da Microsoft [Reserved] 72 | REG_DWORD, //[in] REG_DWORD - Um número de 32-bit -> https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types 73 | reinterpret_cast(& dwData), //[in] 74 | sizeof(dwData) //[in] 75 | ); 76 | 77 | if (lReg != ERROR_SUCCESS) 78 | std::operator<<(std::cout, "Erro ao definir valor para a chave de registro ").operator<<(GetLastError()).operator<<(std::endl); 79 | 80 | std::operator<<(std::cout, "Sucesso ao definir um valor para a chave de registro !").operator<<(std::endl); 81 | 82 | //https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey 83 | RegCloseKey( 84 | hKey //[in] 85 | ); 86 | 87 | 88 | return 0; 89 | } -------------------------------------------------------------------------------- /RegistryInWindows/RegistryInWindows/RegistryInWindows.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {eaa6aafe-2c91-49a6-9de3-12b294d2ed3e} 25 | RegistryInWindows 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | true 129 | true 130 | true 131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /RegistryInWindows/RegistryInWindows/RegistryInWindows.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /RegistryInWindows/RegistryInWindows/RegistryInWindows.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /RenameAndMoveFileFunction/RenameAndMoveFileFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenameAndMoveFileFunction", "RenameAndMoveFileFunction\RenameAndMoveFileFunction.vcxproj", "{079B7E08-B161-41F2-8EBB-1B0F681C086C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {079B7E08-B161-41F2-8EBB-1B0F681C086C}.Debug|x64.ActiveCfg = Debug|x64 17 | {079B7E08-B161-41F2-8EBB-1B0F681C086C}.Debug|x64.Build.0 = Debug|x64 18 | {079B7E08-B161-41F2-8EBB-1B0F681C086C}.Debug|x86.ActiveCfg = Debug|Win32 19 | {079B7E08-B161-41F2-8EBB-1B0F681C086C}.Debug|x86.Build.0 = Debug|Win32 20 | {079B7E08-B161-41F2-8EBB-1B0F681C086C}.Release|x64.ActiveCfg = Release|x64 21 | {079B7E08-B161-41F2-8EBB-1B0F681C086C}.Release|x64.Build.0 = Release|x64 22 | {079B7E08-B161-41F2-8EBB-1B0F681C086C}.Release|x86.ActiveCfg = Release|Win32 23 | {079B7E08-B161-41F2-8EBB-1B0F681C086C}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {CB0AF8AD-32ED-4DD8-B521-08C0DD855553} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /RenameAndMoveFileFunction/RenameAndMoveFileFunction/RenameAndMoveFileFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main() -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | //https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefile 10 | BOOL bMove = MoveFile( 11 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\muhahah.txt", //In 12 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\dir2\\muhahahNew.txt" //In 13 | ); 14 | 15 | 16 | if (!bMove) 17 | std::operator<<(std::cout, "Erro ao mover arquivo ").operator<<(GetLastError()).operator<<(std::endl); 18 | 19 | std::operator<<(std::cout, "Sucesso ao mover o arquivo !").operator<<(std::endl); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /RenameAndMoveFileFunction/RenameAndMoveFileFunction/RenameAndMoveFileFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /RenameAndMoveFileFunction/RenameAndMoveFileFunction/RenameAndMoveFileFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /SoftLinkFunction/SoftLinkFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SoftLinkFunction", "SoftLinkFunction\SoftLinkFunction.vcxproj", "{4E3FCB5A-1F90-4657-BC14-DAF8B3AA0F52}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {4E3FCB5A-1F90-4657-BC14-DAF8B3AA0F52}.Debug|x64.ActiveCfg = Debug|x64 17 | {4E3FCB5A-1F90-4657-BC14-DAF8B3AA0F52}.Debug|x64.Build.0 = Debug|x64 18 | {4E3FCB5A-1F90-4657-BC14-DAF8B3AA0F52}.Debug|x86.ActiveCfg = Debug|Win32 19 | {4E3FCB5A-1F90-4657-BC14-DAF8B3AA0F52}.Debug|x86.Build.0 = Debug|Win32 20 | {4E3FCB5A-1F90-4657-BC14-DAF8B3AA0F52}.Release|x64.ActiveCfg = Release|x64 21 | {4E3FCB5A-1F90-4657-BC14-DAF8B3AA0F52}.Release|x64.Build.0 = Release|x64 22 | {4E3FCB5A-1F90-4657-BC14-DAF8B3AA0F52}.Release|x86.ActiveCfg = Release|Win32 23 | {4E3FCB5A-1F90-4657-BC14-DAF8B3AA0F52}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {3078340E-F770-438C-B9D5-5A73C267887A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /SoftLinkFunction/SoftLinkFunction/SoftLinkFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main() -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | /* 10 | 1 - Um arquivo pode ter diferentes nomes 11 | 2 - Soft link pode ser criado para arquivos e diretórios 12 | 3 - Se o arquivo original for excluído, então vou não pode acessar o arquivo soft link 13 | 4 - Soft link é um atalho para o arquivo original 14 | */ 15 | 16 | //https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinka 17 | BOOL bSym = CreateSymbolicLink( 18 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\testeardlink.txt", 19 | L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\testeardlink2.txt", 20 | NULL // 0(NULL) para arquivos, SYMBOLIC_LINK_FLAG_DIRECTORY(Para diretórios) 21 | ); 22 | 23 | if (!bSym) 24 | std::operator<<(std::cout, "Falhou ao criar o symboliclink ").operator<<(GetLastError()).operator<<(std::endl); 25 | 26 | std::operator<<(std::cout, "Sucesso ao criar o symboliclink !").operator<<(std::endl); 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /SoftLinkFunction/SoftLinkFunction/SoftLinkFunction.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {4e3fcb5a-1f90-4657-bc14-daf8b3aa0f52} 25 | SoftLinkFunction 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | true 129 | true 130 | true 131 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 132 | true 133 | 134 | 135 | Console 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /SoftLinkFunction/SoftLinkFunction/SoftLinkFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /SoftLinkFunction/SoftLinkFunction/SoftLinkFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /SystemParametersInfoAForSetDesktopWallpaperFunction/SystemParametersInfoAForSetDesktopWallpaperFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SystemParametersInfoAForSetDesktopWallpaperFunction", "SystemParametersInfoAForSetDesktopWallpaperFunction\SystemParametersInfoAForSetDesktopWallpaperFunction.vcxproj", "{3F5E47D3-1DC5-45B5-8CCF-297B0F2BFAD0}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {3F5E47D3-1DC5-45B5-8CCF-297B0F2BFAD0}.Debug|x64.ActiveCfg = Debug|x64 17 | {3F5E47D3-1DC5-45B5-8CCF-297B0F2BFAD0}.Debug|x64.Build.0 = Debug|x64 18 | {3F5E47D3-1DC5-45B5-8CCF-297B0F2BFAD0}.Debug|x86.ActiveCfg = Debug|Win32 19 | {3F5E47D3-1DC5-45B5-8CCF-297B0F2BFAD0}.Debug|x86.Build.0 = Debug|Win32 20 | {3F5E47D3-1DC5-45B5-8CCF-297B0F2BFAD0}.Release|x64.ActiveCfg = Release|x64 21 | {3F5E47D3-1DC5-45B5-8CCF-297B0F2BFAD0}.Release|x64.Build.0 = Release|x64 22 | {3F5E47D3-1DC5-45B5-8CCF-297B0F2BFAD0}.Release|x86.ActiveCfg = Release|Win32 23 | {3F5E47D3-1DC5-45B5-8CCF-297B0F2BFAD0}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {0C860C19-298F-4CAC-852D-322113982273} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /SystemParametersInfoAForSetDesktopWallpaperFunction/SystemParametersInfoAForSetDesktopWallpaperFunction/SystemParametersInfoAForSetDesktopWallpaperFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | auto main( ) -> int 5 | { 6 | 7 | std::cout << "Hello World!\n"; 8 | 9 | std::basic_string< char, std::char_traits< char >, std::allocator< char > > path( "C:\\Users\\oimeuchapavm\\Downloads\\imags\\ElonMuskTorso.png" ); 10 | 11 | //https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfow 12 | if (!SystemParametersInfoW( 13 | _In_ SPI_SETDESKWALLPAPER, //[in] 14 | _In_ 0, //[in] 15 | _Inout_ _Pre_maybenull_ _Post_valid_(void*)path.c_str(), //[in, out] 16 | _In_ SPIF_SENDCHANGE //[in] 17 | )) 18 | std::operator<<(std::cout, "Erro ao definir wallpaper !\n"); 19 | 20 | std::operator<<(std::cout, "Sucesso ao definir wallpaper !"); 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /SystemParametersInfoAForSetDesktopWallpaperFunction/SystemParametersInfoAForSetDesktopWallpaperFunction/SystemParametersInfoAForSetDesktopWallpaperFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /SystemParametersInfoAForSetDesktopWallpaperFunction/SystemParametersInfoAForSetDesktopWallpaperFunction/SystemParametersInfoAForSetDesktopWallpaperFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /URLDownloadToFileFunction/URLDownloadToFileFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "URLDownloadToFileFunction", "URLDownloadToFileFunction\URLDownloadToFileFunction.vcxproj", "{7D7DA54D-9FBB-48A2-98FC-90FC0DDFA6E5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7D7DA54D-9FBB-48A2-98FC-90FC0DDFA6E5}.Debug|x64.ActiveCfg = Debug|x64 17 | {7D7DA54D-9FBB-48A2-98FC-90FC0DDFA6E5}.Debug|x64.Build.0 = Debug|x64 18 | {7D7DA54D-9FBB-48A2-98FC-90FC0DDFA6E5}.Debug|x86.ActiveCfg = Debug|Win32 19 | {7D7DA54D-9FBB-48A2-98FC-90FC0DDFA6E5}.Debug|x86.Build.0 = Debug|Win32 20 | {7D7DA54D-9FBB-48A2-98FC-90FC0DDFA6E5}.Release|x64.ActiveCfg = Release|x64 21 | {7D7DA54D-9FBB-48A2-98FC-90FC0DDFA6E5}.Release|x64.Build.0 = Release|x64 22 | {7D7DA54D-9FBB-48A2-98FC-90FC0DDFA6E5}.Release|x86.ActiveCfg = Release|Win32 23 | {7D7DA54D-9FBB-48A2-98FC-90FC0DDFA6E5}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {B8F6532B-EEC0-46C0-88C5-2680937BB8B3} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /URLDownloadToFileFunction/URLDownloadToFileFunction/URLDownloadToFileFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | auto main( ) -> int 6 | { 7 | //Vá nas configurações do projeto -> Vinculador -> Entrada -> Dependências adicioanis -> Editar -> coloque Urlmon.lib 8 | 9 | std::cout << "Hello World!\n"; 10 | 11 | /* 12 | Baixa bits da Internet e os salva em um arquivo. 13 | */ 14 | 15 | //https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775123(v=vs.85) 16 | HRESULT hRes = URLDownloadToFile( 17 | _In_opt_ NULL, //[in, optional] 18 | _In_ L"https://avatars.githubusercontent.com/u/42323126?v=4", //[in] 19 | _In_ L"C:\\Users\\oimeuchapavm\\Downloads\\Nova pasta (2)\\file.png", //[in] 20 | _In_opt_ NULL, //[in, optional] 21 | _In_opt_ NULL //[in, optional] 22 | ); 23 | 24 | if (hRes != S_OK) 25 | std::operator<<(std::cout, "Erro ao tentar fazer download do arquivo !\n"); 26 | 27 | std::operator<<(std::cout, "Sucesso ao baixar o arquivo brother, vá lá na pasta conferir !\n"); 28 | 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /URLDownloadToFileFunction/URLDownloadToFileFunction/URLDownloadToFileFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /URLDownloadToFileFunction/URLDownloadToFileFunction/URLDownloadToFileFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /WSAWinsocketFunction/WSAWinsocketFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WSAWinsocketFunction", "WSAWinsocketFunction\WSAWinsocketFunction.vcxproj", "{0355D727-53E1-42F8-8100-B67A58282682}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WSAWinsocketFunctionCliente", "WSAWinsocketFunctionCliente\WSAWinsocketFunctionCliente.vcxproj", "{DAA90474-BE4B-4883-8CE0-21DE74C1BCF1}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {0355D727-53E1-42F8-8100-B67A58282682}.Debug|x64.ActiveCfg = Debug|x64 19 | {0355D727-53E1-42F8-8100-B67A58282682}.Debug|x64.Build.0 = Debug|x64 20 | {0355D727-53E1-42F8-8100-B67A58282682}.Debug|x86.ActiveCfg = Debug|Win32 21 | {0355D727-53E1-42F8-8100-B67A58282682}.Debug|x86.Build.0 = Debug|Win32 22 | {0355D727-53E1-42F8-8100-B67A58282682}.Release|x64.ActiveCfg = Release|x64 23 | {0355D727-53E1-42F8-8100-B67A58282682}.Release|x64.Build.0 = Release|x64 24 | {0355D727-53E1-42F8-8100-B67A58282682}.Release|x86.ActiveCfg = Release|Win32 25 | {0355D727-53E1-42F8-8100-B67A58282682}.Release|x86.Build.0 = Release|Win32 26 | {DAA90474-BE4B-4883-8CE0-21DE74C1BCF1}.Debug|x64.ActiveCfg = Debug|x64 27 | {DAA90474-BE4B-4883-8CE0-21DE74C1BCF1}.Debug|x64.Build.0 = Debug|x64 28 | {DAA90474-BE4B-4883-8CE0-21DE74C1BCF1}.Debug|x86.ActiveCfg = Debug|Win32 29 | {DAA90474-BE4B-4883-8CE0-21DE74C1BCF1}.Debug|x86.Build.0 = Debug|Win32 30 | {DAA90474-BE4B-4883-8CE0-21DE74C1BCF1}.Release|x64.ActiveCfg = Release|x64 31 | {DAA90474-BE4B-4883-8CE0-21DE74C1BCF1}.Release|x64.Build.0 = Release|x64 32 | {DAA90474-BE4B-4883-8CE0-21DE74C1BCF1}.Release|x86.ActiveCfg = Release|Win32 33 | {DAA90474-BE4B-4883-8CE0-21DE74C1BCF1}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {034A3E90-0BD5-4FE6-ABB1-5C7CC7DA5B8C} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /WSAWinsocketFunction/WSAWinsocketFunction/WSAWinsocketFunction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | auto main( ) -> int 6 | { 7 | //Para compilar vá em Vinculador -> input -> Dependências adicionais -> editar -> coloque WS2_32.lib 8 | std::cout << "Hello World!\n"; 9 | 10 | /* 11 | Programando o socket do Windows 12 | 13 | O que é o socket: 14 | Socket é um endpoint no qual é usado para comunicação entre dois nós de rede. 15 | Socket é uma interface que segue a arquitetura cliente-servidor 16 | 17 | Socket 18 | [ Server ] --------------- [Cliente] 19 | 20 | Tipos de socket: 21 | - Sockets de internet 22 | - Unix sockets 23 | - x.25 sockets entre outros. 24 | 25 | Internet sockets: 26 | Internet socket é caracterizado por um endereço ip(4 Bytes) e uma porta(2 bytes) 27 | é um protocolo de transporte 28 | 29 | Tipos: 30 | 1. Sockets de stream(Stream Sock) 31 | i. Orientado a conexão 32 | ii. Confiar no TCP que provê dois caminhos de conexão 33 | 2. Sockets de datagram(Dgram Sock) 34 | i. A conexão não é confiável 35 | ii. Confiar no UDP 36 | 37 | User Datagram Protocol: 38 | 1. Orientado a mensagem 39 | 2. perdas de conexão por exemplo: sem conexão ou manutenções 40 | 3. Tamanho pequeno(Cabeçalho do UDP é 60% menor que o cabeçalho do TCP) 41 | 4. Pequeno tamanho do pacote, cabeçalho do UDP tem 8 Bytes. 42 | 5. Não possui detecção de erros 43 | 6. Se perder data então não é possivel recuperar 44 | 7. Dados corrompidos podem ser descartados conforme a ordem 45 | 8. Exemplo é um e-mail 46 | 47 | [ABCDE] ----------------------> [ABDE] 48 | [C] 49 | 50 | Protocolo de conexão: 51 | Servidor Cliente 52 | [Socket] [Socket] 53 | [Bind] [Bind] 54 | [Recv] [Send] 55 | [Send] [Recv] 56 | [Close] [Close] 57 | 58 | Passos para programar o UDP: 59 | 60 | Servidor: Cliente: 61 | [WSAStartUp] [WSAStartUp] 62 | [Preencher a struct do cliente Cliente ou Servidor] [Preencher a struct do cliente ou servidor] 63 | [Socket] [Socket] 64 | [Bind] [Send e Recv] 65 | [Recv e send] [CloseSocket] 66 | [closesocket] [WSACleanUp] 67 | [WSACleanUp] 68 | 69 | */ 70 | 71 | WSADATA wSocketData{ 0 }; 72 | 73 | SOCKET uDPSocketServer{ 0 }; 74 | struct sockaddr_in UDPCliente { 0 }; 75 | 76 | char buffer[512]{ 0 }; 77 | int iBufferLen = sizeof(buffer) + 1; 78 | 79 | int iUDPClienteLen = sizeof(UDPCliente) + 1; 80 | 81 | //Iniciando winsock 82 | 83 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsastartup 84 | int iWsaStartup = WSAStartup( 85 | _In_ MAKEWORD(2, 2), //[in] 86 | _Out_ &wSocketData //[out] 87 | ); 88 | 89 | if (iWsaStartup != 0) 90 | std::operator<<(std::cout, "Falhou em iniciar o socket com WSAStartup !\n"); 91 | 92 | std::operator<<(std::cout, "Sucesso ao criar socket com WSAStartup !\n"); 93 | 94 | //Preencher detalhes da struct 95 | UDPCliente.sin_family = AF_INET; 96 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-inet_addr 97 | UDPCliente.sin_addr.S_un.S_addr = inet_addr( 98 | _In_ "127.0.0.1" //[in] 99 | ); 100 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-htons 101 | UDPCliente.sin_port = htons( 102 | _In_ 8001 //[in] 103 | ); 104 | 105 | //Criar o socket 106 | 107 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket 108 | uDPSocketServer = socket( 109 | _In_ AF_INET, //[in] 110 | _In_ SOCK_DGRAM, //[in] 111 | _In_ IPPROTO_UDP //[in] 112 | ); 113 | 114 | if(uDPSocketServer == INVALID_SOCKET) 115 | std::operator<<(std::cout, "Falhou em iniciar o socket: !").operator<<(WSAGetLastError()).operator<<("\n"); 116 | 117 | std::operator<<(std::cout, "Sucesso ao criar socket !\n"); 118 | 119 | //Bind 120 | 121 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind 122 | int iBind = bind( 123 | _In_ uDPSocketServer, //[in] 124 | _In_reads_bytes_(UDPCliente) (SOCKADDR *)&UDPCliente, //[in] 125 | sizeof(UDPCliente) //[in] 126 | ); 127 | 128 | if(iBind == SOCKET_ERROR) 129 | std::operator<<(std::cout, "O Bind falhou ao ser efetuado: ").operator<<(WSAGetLastError()).operator<<("\n"); 130 | 131 | std::operator<<(std::cout, "Sucesso ao fazer o bind !\n"); 132 | 133 | //recv dados 134 | 135 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recvfrom 136 | int iReceiveFrom = recvfrom( 137 | _In_ uDPSocketServer, //[in] 138 | _Out_ buffer, //[out] 139 | _In_ iBufferLen, //[in] 140 | _In_ MSG_PEEK, //[in] 141 | _Out_writes_bytes_to_opt_(*iUDPClienteLen, *iUDPClienteLen) (SOCKADDR*)&UDPCliente, //[out] 142 | _In_opt_z_ &iUDPClienteLen //[in, out, optional] 143 | ); 144 | 145 | if(iReceiveFrom == SOCKET_ERROR) 146 | std::operator<<(std::cout, "Erro ao receber: ").operator<<(WSAGetLastError()).operator<<("\n"); 147 | 148 | std::operator<<(std::cout, "Sucesso ao receber dados !\n"); 149 | 150 | std::printf("Recebido: %s\n", buffer); 151 | 152 | //fechando socket 153 | 154 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-closesocket 155 | int iCloseSocket = closesocket( 156 | _In_ uDPSocketServer //[in] 157 | ); 158 | 159 | if(iCloseSocket == SOCKET_ERROR) 160 | std::operator<<(std::cout, "Erro ao fechar socket: ").operator<<(WSAGetLastError()).operator<<("\n"); 161 | 162 | std::operator<<(std::cout, "Sucesso ao fechar socket !\n"); 163 | 164 | //limpando 165 | 166 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsacleanup 167 | int iWsaCleanup = WSACleanup( 168 | ); 169 | 170 | if(iWsaCleanup == SOCKET_ERROR) 171 | std::operator<<(std::cout, "Erro ao limpar socket: ").operator<<(WSAGetLastError()).operator<<("\n"); 172 | 173 | std::operator<<(std::cout, "Sucesso ao limpar o socket !\n"); 174 | 175 | return 0; 176 | } -------------------------------------------------------------------------------- /WSAWinsocketFunction/WSAWinsocketFunction/WSAWinsocketFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /WSAWinsocketFunction/WSAWinsocketFunction/WSAWinsocketFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /WSAWinsocketFunction/WSAWinsocketFunctionCliente/WSAWinsocketFunctionCliente.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | auto main( ) -> int 6 | { 7 | //Para compilar vá em Vinculador -> input -> Dependências adicionais -> editar -> coloque WS2_32.lib 8 | 9 | std::cout << "Hello World!\n"; 10 | 11 | 12 | WSADATA wSocketData{ 0 }; 13 | 14 | SOCKET uDPSocketServer{ 0 }; 15 | struct sockaddr_in UDPServer { 0 }; 16 | 17 | char buffer[512]{ "Ola mundo !! Do Keowu, HELLO WORLD FROM KEOWU !! "}; 18 | int iBufferLen = sizeof(buffer) + 1; 19 | 20 | int iUDPServerLen = sizeof(UDPServer) + 1; 21 | 22 | //Iniciando winsock 23 | 24 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsastartup 25 | int iWsaStartup = WSAStartup( 26 | _In_ MAKEWORD(2, 2), //[in] 27 | _Out_ & wSocketData //[out] 28 | ); 29 | 30 | if (iWsaStartup != 0) 31 | std::operator<<(std::cout, "Falhou em iniciar o socket com WSAStartup !\n"); 32 | 33 | std::operator<<(std::cout, "Sucesso ao criar socket com WSAStartup !\n"); 34 | 35 | //Preencher detalhes da struct 36 | UDPServer.sin_family = AF_INET; 37 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsastartup 38 | UDPServer.sin_addr.S_un.S_addr = inet_addr( 39 | _In_ "127.0.0.1" //[in] 40 | ); 41 | ////https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-htons 42 | UDPServer.sin_port = htons( 43 | _In_ 8001 //[in] 44 | ); 45 | 46 | //Criar o socket 47 | 48 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket 49 | uDPSocketServer = socket( 50 | _In_ AF_INET, //[in] 51 | _In_ SOCK_DGRAM, //[in] 52 | _In_ IPPROTO_UDP //[in] 53 | ); 54 | 55 | if (uDPSocketServer == INVALID_SOCKET) 56 | std::operator<<(std::cout, "Falhou em iniciar o socket: !").operator<<(WSAGetLastError()).operator<<("\n"); 57 | 58 | std::operator<<(std::cout, "Sucesso ao criar socket !\n"); 59 | 60 | //send dados 61 | 62 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-sendto 63 | int iSendFrom = sendto( 64 | _In_ uDPSocketServer, //[in] 65 | _In_ buffer, //[in] 66 | _In_ iBufferLen, //[in] 67 | _In_ MSG_DONTROUTE, //[in] 68 | _In_ (SOCKADDR*)&UDPServer, //[in] 69 | _In_ iUDPServerLen //[in] 70 | ); 71 | 72 | if (iSendFrom == SOCKET_ERROR) 73 | std::operator<<(std::cout, "Erro ao enviar: ").operator<<(WSAGetLastError()).operator<<("\n"); 74 | 75 | std::operator<<(std::cout, "Sucesso ao enviar dados !\n"); 76 | 77 | //fechando socket 78 | 79 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-closesocket 80 | int iCloseSocket = closesocket( 81 | _In_ uDPSocketServer //[in] 82 | ); 83 | 84 | if (iCloseSocket == SOCKET_ERROR) 85 | std::operator<<(std::cout, "Erro ao fechar socket: ").operator<<(WSAGetLastError()).operator<<("\n"); 86 | 87 | std::operator<<(std::cout, "Sucesso ao fechar socket !\n"); 88 | 89 | //limpando 90 | 91 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsacleanup 92 | int iWsaCleanup = WSACleanup( 93 | ); 94 | 95 | if (iWsaCleanup == SOCKET_ERROR) 96 | std::operator<<(std::cout, "Erro ao limpar socket: ").operator<<(WSAGetLastError()).operator<<("\n"); 97 | 98 | std::operator<<(std::cout, "Sucesso ao limpar o socket !\n"); 99 | 100 | 101 | return 0; 102 | } -------------------------------------------------------------------------------- /WSAWinsocketFunction/WSAWinsocketFunctionCliente/WSAWinsocketFunctionCliente.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /WSAWinsocketFunction/WSAWinsocketFunctionCliente/WSAWinsocketFunctionCliente.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /WSAWinsocketTCPFunction/WSAWinsocketTCPFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32328.378 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WSAWinsocketTCPFunction", "WSAWinsocketTCPFunction\WSAWinsocketTCPFunction.vcxproj", "{6196E6A3-9551-4785-A65F-93B24E33739E}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WSAWinsocketTCPFunctionCliente", "WSAWinsocketTCPFunctionCliente\WSAWinsocketTCPFunctionCliente.vcxproj", "{17150DC8-9DA1-4DC5-87EF-8570BE6D3568}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {6196E6A3-9551-4785-A65F-93B24E33739E}.Debug|x64.ActiveCfg = Debug|x64 19 | {6196E6A3-9551-4785-A65F-93B24E33739E}.Debug|x64.Build.0 = Debug|x64 20 | {6196E6A3-9551-4785-A65F-93B24E33739E}.Debug|x86.ActiveCfg = Debug|Win32 21 | {6196E6A3-9551-4785-A65F-93B24E33739E}.Debug|x86.Build.0 = Debug|Win32 22 | {6196E6A3-9551-4785-A65F-93B24E33739E}.Release|x64.ActiveCfg = Release|x64 23 | {6196E6A3-9551-4785-A65F-93B24E33739E}.Release|x64.Build.0 = Release|x64 24 | {6196E6A3-9551-4785-A65F-93B24E33739E}.Release|x86.ActiveCfg = Release|Win32 25 | {6196E6A3-9551-4785-A65F-93B24E33739E}.Release|x86.Build.0 = Release|Win32 26 | {17150DC8-9DA1-4DC5-87EF-8570BE6D3568}.Debug|x64.ActiveCfg = Debug|x64 27 | {17150DC8-9DA1-4DC5-87EF-8570BE6D3568}.Debug|x64.Build.0 = Debug|x64 28 | {17150DC8-9DA1-4DC5-87EF-8570BE6D3568}.Debug|x86.ActiveCfg = Debug|Win32 29 | {17150DC8-9DA1-4DC5-87EF-8570BE6D3568}.Debug|x86.Build.0 = Debug|Win32 30 | {17150DC8-9DA1-4DC5-87EF-8570BE6D3568}.Release|x64.ActiveCfg = Release|x64 31 | {17150DC8-9DA1-4DC5-87EF-8570BE6D3568}.Release|x64.Build.0 = Release|x64 32 | {17150DC8-9DA1-4DC5-87EF-8570BE6D3568}.Release|x86.ActiveCfg = Release|Win32 33 | {17150DC8-9DA1-4DC5-87EF-8570BE6D3568}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {14DEB6C0-307A-4787-BC0B-26C66C695EE7} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /WSAWinsocketTCPFunction/WSAWinsocketTCPFunction/WSAWinsocketTCPFunction.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /WSAWinsocketTCPFunction/WSAWinsocketTCPFunction/WSAWinsocketTCPFunction.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /WSAWinsocketTCPFunction/WSAWinsocketTCPFunctionCliente/WSAWinsocketTCPFunctionCliente.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | auto main( ) -> int 6 | { 7 | 8 | //Para compilar vá em Vinculador -> input -> Dependências adicionais -> editar -> coloque WS2_32.lib 9 | std::cout << "Hello World!\n"; 10 | 11 | WSADATA WinsockData{ 0 }; 12 | 13 | struct sockaddr_in TCPServerAdd { 0 }; 14 | struct sockaddr_in TCPClientAdd { 0 }; 15 | int iTCPClientAdd = sizeof(TCPClientAdd); 16 | 17 | char SenderBuff[512] = "Hello Servidor chegou sim !"; 18 | int iSenderBuffer = strlen(SenderBuff) + 1; 19 | 20 | char RecvBuffer[512]{ 0 }; 21 | int iRecvBuffer = sizeof(RecvBuffer) + 1; 22 | 23 | //1º WSAStartUp 24 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsastartup 25 | int iWsaStartup = WSAStartup( 26 | _In_ MAKEWORD(2, 2), //[in] 27 | _Out_ &WinsockData //[out] 28 | ); 29 | 30 | if (iWsaStartup != NULL) 31 | std::operator<<(std::cout, "Erro ao inicializar WSA !\n"); 32 | 33 | std::operator<<(std::cout, "Sucesso ao inicializar WSAStartUp !\n"); 34 | 35 | //2º Preencher a struct 36 | TCPServerAdd.sin_family = AF_INET; 37 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-inet_addr 38 | TCPServerAdd.sin_addr.S_un.S_addr = inet_addr( 39 | _In_ "127.0.0.1" //[in] 40 | ); 41 | 42 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-htons 43 | TCPServerAdd.sin_port = htons( 44 | _In_ 8000 //[in] 45 | ); 46 | 47 | //3º Criar o socket 48 | 49 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket 50 | SOCKET TCPClientSocket = socket( 51 | _In_ AF_INET, //[in] 52 | _In_ SOCK_STREAM, //[in] 53 | _In_ IPPROTO_TCP //[in] 54 | ); 55 | 56 | if (TCPClientSocket == INVALID_SOCKET) 57 | std::operator<<(std::cout, "Erro ao inicializar socket TCP: ").operator<<(WSAGetLastError()).operator<<("\n"); 58 | 59 | std::operator<<(std::cout, "Sucesso ao inicializar o socket TCP !\n"); 60 | 61 | //4º Conectar 62 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect 63 | int iConnect = connect( 64 | _In_ TCPClientSocket, //[in] 65 | _In_reads_bytes_(TCPServerAdd) (SOCKADDR*)&TCPServerAdd, //[in] 66 | _In_ sizeof(TCPServerAdd) //[in] 67 | ); 68 | 69 | if(iConnect == SOCKET_ERROR) 70 | std::operator<<(std::cout, "Erro ao conectar socket TCP: ").operator<<(WSAGetLastError()).operator<<("\n"); 71 | 72 | std::operator<<(std::cout, "Sucesso ao conectar o socket TCP !\n"); 73 | 74 | //5º Receber dados do Cliente 75 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv 76 | int iRecv = recv( 77 | _In_ TCPClientSocket, //[in] 78 | _Out_ RecvBuffer, //[out] 79 | _In_ iRecvBuffer, //[in] 80 | _In_ 0 //[in] 81 | ); 82 | 83 | if (iRecv == SOCKET_ERROR) 84 | std::operator<<(std::cout, "Erro receber informações do cliente: ").operator<<(WSAGetLastError()).operator<<("\n"); 85 | 86 | std::operator<<(std::cout, "Sucesso ao receber informações para o cliente !\n"); 87 | 88 | std::printf("Recebido: %s \n", RecvBuffer); 89 | 90 | //6º Enviar dados para o servidor 91 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send 92 | int iSend = send( 93 | _In_ TCPClientSocket, //[in] 94 | _In_reads_bytes_(iSenderBuffer) SenderBuff, //[in] 95 | _In_ iSenderBuffer, //[in] 96 | _In_ 0 //[in] 97 | ); 98 | 99 | if(iSend == SOCKET_ERROR) 100 | std::operator<<(std::cout, "Erro ao enviar buffer: ").operator<<(WSAGetLastError()).operator<<("\n"); 101 | 102 | std::operator<<(std::cout, "Sucesso ao enviar buffer !\n"); 103 | 104 | //7º Fechar socket 105 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-closesocket 106 | int iSocketClose = closesocket( 107 | _In_ TCPClientSocket //[in] 108 | ); 109 | 110 | if (iSocketClose == SOCKET_ERROR) 111 | std::operator<<(std::cout, "Erro ao fechar o socket: ").operator<<(WSAGetLastError()).operator<<("\n"); 112 | 113 | std::operator<<(std::cout, "Sucesso ao fechar o socket !\n"); 114 | 115 | //8º cleanup 116 | //https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsacleanup 117 | int iWSACleanUp = WSACleanup( 118 | ); 119 | 120 | if (iWSACleanUp == INVALID_SOCKET) 121 | std::operator<<(std::cout, "Erro ao fazer o WSACleanUp: ").operator<<(WSAGetLastError()).operator<<("\n"); 122 | 123 | std::operator<<(std::cout, "Sucesso ao fazer o WSACleanUp !\n"); 124 | 125 | return 0; 126 | } -------------------------------------------------------------------------------- /WSAWinsocketTCPFunction/WSAWinsocketTCPFunctionCliente/WSAWinsocketTCPFunctionCliente.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Arquivos de Origem 20 | 21 | 22 | -------------------------------------------------------------------------------- /WSAWinsocketTCPFunction/WSAWinsocketTCPFunctionCliente/WSAWinsocketTCPFunctionCliente.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | --------------------------------------------------------------------------------