public void GetCDKeyList() { UPLAY_Overlapped uplay_Overlapped = default(UPLAY_Overlapped); IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(uplay_Overlapped)); Marshal.StructureToPtr(uplay_Overlapped, intPtr, true); overlappedMap.Add(intPtr, uplay_Overlapped); IntPtr ptr; Int32 num = UplayInvokes.UPLAY_USER_GetCdKeys(out ptr, intPtr); if (num != 0) { UplayInvokes.UPLAY_Update(); while (!UplayInvokes.UPLAY_HasOverlappedOperationCompleted(intPtr)) { Thread.Sleep(5); UplayInvokes.UPLAY_Update(); } m_keys.Clear(); UPLAY_USER_CdKeyList uplay_USER_CdKeyList = (UPLAY_USER_CdKeyList)Marshal.PtrToStructure(ptr, typeof(UPLAY_USER_CdKeyList)); IntPtr list = uplay_USER_CdKeyList.list; for (Int32 i = 0; i < uplay_USER_CdKeyList.count; i++) { UPLAY_USER_CdKey uplay_USER_CdKey = (UPLAY_USER_CdKey)Marshal.PtrToStructure(list, typeof(UPLAY_USER_CdKey)); m_keys.Add(uplay_USER_CdKey.keyUtf8); list = new IntPtr(list.ToInt32() + IntPtr.Size); } } }
private void WaitForOverlapped(IntPtr p_overlapped) { UplayInvokes.UPLAY_Update(); while (!UplayInvokes.UPLAY_HasOverlappedOperationCompleted(p_overlapped)) { Thread.Sleep(5); UplayInvokes.UPLAY_Update(); } }
public void Update() { if (m_startingRendezVous) { StartUpState startUpState = (StartUpState)RendezVousInvokes.LegacyRendezVousGetStartUpState(); if (startUpState == StartUpState.SUCCESSFUL) { m_startingRendezVous = false; String userName = GetUserName(); String password = GetPassword(); GetCDKeyList(); if (m_keys.Count > 0) { RendezVousInvokes.LegacyRendezVousLogIn(userName, password, m_keys[0]); m_connectingToRendezVous = true; m_unlockingKeyNr = -1; } } else if (startUpState == StartUpState.FAILURE) { m_startingRendezVous = false; m_isOfflineMode = true; } } if (m_connectingToRendezVous) { if (m_unlockingKeyNr == -1) { LogInState logInState = (LogInState)RendezVousInvokes.LegacyRendezVousGetLogInState(); if (logInState == LogInState.SUCCESSFUL) { m_unlockingKeyNr = 0; RendezVousInvokes.LegacyRendezVousActivateAnyKey(m_keys[m_unlockingKeyNr]); } else if (logInState == LogInState.FAILURE) { m_isOfflineMode = true; m_connectingToRendezVous = false; } } else { EActivateKeyResult unlockPrivilegeState = GetUnlockPrivilegeState(); if (unlockPrivilegeState != EActivateKeyResult.ACTIVATE_WAITING) { m_unlockingKeyNr++; if (m_unlockingKeyNr < m_keys.Count) { RendezVousInvokes.LegacyRendezVousActivateAnyKey(m_keys[m_unlockingKeyNr]); } else { DoneLogin(); } } } } if (m_isSettingAction) { SetActionState setActionState = (SetActionState)RendezVousInvokes.LegacyRendezVousGetActionsState(); if (setActionState == SetActionState.SUCCESSFUL) { if (OnActionCompleted != null && m_settingActionID >= 0) { ActionCompletedEventArgs e = new ActionCompletedEventArgs(m_settingActionID, true); OnActionCompleted(this, e); } m_isSettingAction = false; m_settingActionID = -1; } else if (setActionState == SetActionState.FAILURE) { if (OnActionCompleted != null && m_settingActionID >= 0) { ActionCompletedEventArgs e2 = new ActionCompletedEventArgs(m_settingActionID, false); OnActionCompleted(this, e2); } m_isSettingAction = false; m_settingActionID = -1; } } List <IntPtr> list = new List <IntPtr>(); foreach (IntPtr intPtr in overlappedMap.Keys) { if (UplayInvokes.UPLAY_HasOverlappedOperationCompleted(intPtr)) { list.Add(intPtr); } } foreach (IntPtr intPtr2 in list) { overlappedMap.Remove(intPtr2); Marshal.FreeHGlobal(intPtr2); } list.Clear(); if (UplayInvokes.UPLAY_Update() == 0) { m_isForceQuit = true; } UPLAY_Event uplay_Event; while (UplayInvokes.UPLAY_GetNextEvent(out uplay_Event)) { Debug.Log("Received uplay Event! : " + uplay_Event.type); if (uplay_Event.type == UPLAY_EventType.UPLAY_Event_UserAccountSharing) { m_isRendezVousConnected = false; m_isOfflineMode = true; } } }