private void button2_Click(object sender, EventArgs e) { byte[] ipAddressByteArray = new byte[8]; // IntPtr fileMapping = OpenFileMapping(0x000f001f, false, "DataSync"); //IntPtr mapFile = MapViewOfFile(fileMapping, 0x000f001f, 0, 0, 0); // Marshal.Copy(mapFile, ipAddressByteArray, 0, 8); // IPAddress ipaddress2 = IPAddress.Parse("16.173.242.115"); //// long xx = ipaddress2.Address; // long ipAddressLong = BitConverter.ToInt64(ipAddressByteArray, 0)>>16; // IPAddress ipAddress = new IPAddress(ipAddressLong); // string ip = ipAddress.ToString(); // byte[] cookieArray = new byte[8]; //Marshal.Copy(mapFile, ipAddressByteArray, 0, 8); //int cookieLength = GetCookieLength(); IPAddress ipAddress = GetIpAddress(); DataSyncHeader syncHeader = GetHeader(); string cookie = syncHeader.Cookie; string authrizationStr = syncHeader.Authorization; int port = syncHeader.Port; textBoxIP.Text = ipAddress.ToString(); textBoxPort.Text = port.ToString(); textBoxAuthorization.Text = authrizationStr.Trim(); textBoxCookieId.Text = cookie.Trim(); }
private void WriteDebugHeaderToSharedMemory(DataSyncHeader header) { IntPtr fileMapping = OpenFileMapping(0x000f001f, false, "DataSync"); IntPtr mapFile = MapViewOfFile(fileMapping, 0x000f001f, 0, 0, 0); Marshal.StructureToPtr(header, mapFile, true); }
private void StopDebugger() { DataSyncHeader header = GetHeader(); //Disable debugger. header.Enable = 0; WriteDebugHeaderToSharedMemory(header); //Client is in hold. if (needHoldSMClient) { try { semaphoreEmpty.Release(); } catch (Exception ex) { } } if (dataSyncThread != null) { //Abort the thread. dataSyncThread.Abort(); } }
private void EnableDebug() { //To Disable it. if (debuggerEnable) { DataSyncHeader header = GetHeader(); //Disable debugger. header.Enable = 0; WriteDebugHeaderToSharedMemory(header); //Client is in hold. if (needHoldSMClient) { RemoveAllBreakPoints(); DisableTrace(); ContinueDebug(); needHoldSMClient = false; if (dataSyncThread.ThreadState == System.Threading.ThreadState.Suspended) { dataSyncThread.Resume(); } } } else //enable it. { DataSyncHeader header = GetHeader(); //Disable debugger. header.Enable = 1; WriteDebugHeaderToSharedMemory(header); } debuggerEnable = (!debuggerEnable); }
private DataSyncHeader GetHeader() { DataSyncHeader syncHeader = new DataSyncHeader(); byte[] ipAddressByteArray = new byte[8]; //IntPtr fileMapping = OpenFileMapping(0x000f001f, false, "DataSync"); //IntPtr mapFile = MapViewOfFile(fileMapping, 0x000f001f, 0, 0, 0); Marshal.PtrToStructure(mapFile, syncHeader); return(syncHeader); }
private IPAddress GetIpAddress() { DataSyncHeader syncHeader = GetHeader(); //byte[] ipAddressByteArray = new byte[8]; //IntPtr fileMapping = OpenFileMapping(0x000f001f, false, "DataSync"); //IntPtr mapFile = MapViewOfFile(fileMapping, 0x000f001f, 0, 0, 0); //Marshal.Copy(mapFile, ipAddressByteArray, 0, 8); //long ipAddressLong = BitConverter.ToInt64(ipAddressByteArray, 0) >> 16; long ipAddressLong = syncHeader.IPAddress >> 16; IPAddress ipAddress = new IPAddress(ipAddressLong); return(ipAddress); }
private void ResetConnectionInfo() { byte[] ipAddressByteArray = new byte[8]; IPAddress ipAddress = GetIpAddress(); DataSyncHeader syncHeader = GetHeader(); string cookie = syncHeader.Cookie; string authrizationStr = syncHeader.Authorization; int port = syncHeader.Port; Invoke(new UpdateUI(delegate() { textBoxIP.Text = ipAddress.ToString(); textBoxPort.Text = port.ToString(); textBoxAuthorization.Text = authrizationStr.Trim(); textBoxCookieId.Text = cookie.Trim(); })); }