MCPcopy Create free account
hub / github.com/ThirteenAG/Ultimate-ASI-Loader / CreateFileOnServer

Method CreateFileOnServer

source/dllmain.cpp:1880–1919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1878 public:
1879 #if !X64
1880 static uint64_t CreateFileOnServer(const uint8_t* data, size_t size, int priority)
1881 {
1882 if (serverPipe == INVALID_HANDLE_VALUE)
1883 {
1884 return 0;
1885 }
1886
1887 std::lock_guard<std::mutex> lock(serverMutex);
1888
1889 ServerCommand request = {};
1890 request.command = ServerCommand::ADD_FILE;
1891 request.data_size = size;
1892 request.priority = priority;
1893
1894 DWORD bytesWritten = 0;
1895 if (!WriteFile(serverPipe, &request, sizeof(request), &bytesWritten, NULL) || bytesWritten != sizeof(request))
1896 {
1897 CloseHandle(serverPipe);
1898 serverPipe = INVALID_HANDLE_VALUE;
1899 return 0;
1900 }
1901
1902 if (size > 0 && (!WriteFile(serverPipe, data, (DWORD)size, &bytesWritten, NULL) || bytesWritten != size))
1903 {
1904 CloseHandle(serverPipe);
1905 serverPipe = INVALID_HANDLE_VALUE;
1906 return 0;
1907 }
1908
1909 uint64_t new_handle = 0;
1910 DWORD bytesRead = 0;
1911 if (!ReadFile(serverPipe, &new_handle, sizeof(new_handle), &bytesRead, NULL) || bytesRead != sizeof(new_handle))
1912 {
1913 CloseHandle(serverPipe);
1914 serverPipe = INVALID_HANDLE_VALUE;
1915 return 0;
1916 }
1917
1918 return new_handle;
1919 }
1920
1921 static bool AppendFileOnServer(uint64_t server_handle, const uint8_t* data, size_t size)
1922 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected