void login_client_trilogy_handle_credentials_result(LoginClient* client, uint32_t accountId) { ProtocolHandler* handler = login_client_handler(client); if (accountId == 0) { login_trilogy_err_literal(handler, ERR_CREDENTIALS); } else { Basic* basic = protocol_handler_basic(handler); PacketTrilogy* packet = packet_trilogy_create_type(basic, TrilogyOp_Session, LoginTrilogy_Session); Aligned write; Aligned* w = &write; aligned_init(basic, w, packet_trilogy_data(packet), packet_trilogy_length(packet)); // sessionId aligned_write_snprintf_full_advance(w, sizeof_field(LoginTrilogy_Session, sessionId), "LS#%u", accountId); // "unused" aligned_write_literal_null_terminated(w, "unused"); // unknown aligned_write_uint32(w, 4); login_trilogy_schedule_packet(handler, packet); login_client_set_state(client, LoginClientTrilogy_AcceptedCredentials); } }
static void login_trilogy_handle_op_session_key(LoginClient* client, ProtocolHandler* handler) { Basic* basic; PacketTrilogy* packet; Aligned write; Aligned* w = &write; if (login_client_get_state(client) != LoginClientTrilogy_AcceptedCredentials) return; basic = protocol_handler_basic(handler); packet = packet_trilogy_create(basic, TrilogyOp_SessionKey, sizeof_field(LoginClient, sessionKey) + 1); aligned_init(basic, w, packet_trilogy_data(packet), packet_trilogy_length(packet)); aligned_write_uint8(w, 0); aligned_write_buffer(w, login_client_session_key(client), sizeof_field(LoginClient, sessionKey) - 1); aligned_write_uint8(w, 0); login_trilogy_schedule_packet(handler, packet); }
//=================================== void DirMonitor::TaskComplete ( unsigned bytes, OVERLAPPED * ) { s_critsect.Enter(); { if (m_handle == INVALID_HANDLE_VALUE) { // The monitor is ready to be deleted } // If no bytes read then m_buffer wasn't large enough to hold all the // updates; scan the directory to see which files need to be updated else if (!bytes) { ScanDirectoryForChanges_CS(); } // Otherwise process the file notifications else for (const FILE_NOTIFY_INFORMATION * info = (const FILE_NOTIFY_INFORMATION *) m_buffer;;) { // Validate the structure // DebugMsg(" %u: %.*S\n", info->Action, info->FileNameLength / sizeof(info->FileName[0]), info->FileName); #ifdef ASSERTIONS_ENABLED size_t offset = (size_t) ((const byte *) info - (const byte *) m_buffer); ASSERT(offset < bytes); ASSERT(offset < sizeof_field(DirMonitor, m_buffer)); #endif // Deleting or renaming a file does not cause re-parsing if ((info->Action == FILE_ACTION_REMOVED) || (info->Action == FILE_ACTION_RENAMED_OLD_NAME)) { // DebugMsg("%.*S deleted\n", info->FileNameLength / sizeof(info->FileName[0]), filename); } else { // Convert to lowercase for hash matching wchar filename[MAX_PATH]; StrCopy(filename, min(_countof(filename), info->FileNameLength / sizeof(info->FileName[0]) + 1), info->FileName); CharLowerW(filename); // Reparse if file changed CheckReparseFile_CS(filename); } // Move to next entry if (!info->NextEntryOffset) break; info = (const FILE_NOTIFY_INFORMATION *) ((const byte *) info + info->NextEntryOffset); } WatchDirectory_CS(); } s_critsect.Leave(); }