Example #1
0
 private void onUploadSymbols()
 {
     using (new MethodTrace())
     {
         this._symbolParser  = null;
         this._isEnumerating = false;
         try
         {
             int timeout = this._adsClient.Timeout;
             this._adsClient.Timeout = 0x7530;
             try
             {
                 if (this._symbolInfo == null)
                 {
                     this._symbolInfo = this.readUploadInfo();
                 }
                 bool containsBaseTypes = this._symbolInfo.ContainsBaseTypes;
                 Module.Trace.TraceInformation(this._symbolInfo.Dump());
                 AdsStream symbolStream = new AdsStream(this._symbolInfo.SymbolsBlockSize);
                 this.readSymbols(symbolStream, this._symbolInfo, 0x10000);
                 Module.Trace.TraceInformation("Symbols uploaded successfully!");
                 AdsStream datatypeStream = new AdsStream(this._symbolInfo.DataTypesBlockSize);
                 this.readDataTypes(datatypeStream, this._symbolInfo, 0x10000);
                 Module.Trace.TraceInformation("DataTypes uploaded successfully!");
                 this._symbolParser = new AdsParseSymbols(this._symbolInfo.TargetPointerSize, this._symbolInfo.ContainsBaseTypes, this._symbolInfo.StringEncoding);
                 this._symbolParser.TypeResolveError += new EventHandler <DataTypeNameEventArgs>(this._symbolParser_ResolveError);
                 this._symbolParser.TypesGenerated   += new EventHandler <DataTypeEventArgs>(this._symbolParser_TypesGenerated);
                 this._symbolParser.Parse(symbolStream, datatypeStream, this._adsClient);
             }
             finally
             {
                 this._adsClient.Timeout = timeout;
             }
         }
         catch (Exception exception)
         {
             Module.Trace.TraceError(exception);
             throw;
         }
     }
 }
Example #2
0
        private SymbolUploadInfo readUploadInfo()
        {
            AdsStream dataStream = new AdsStream(0x40);

            try
            {
                int version = SymbolUploadInfo.CalcVersion(this._adsClient.Read(0xf00f, 0, dataStream));
                dataStream.Position = 0L;
                return(new SymbolUploadInfo(new BinaryReader(dataStream), version));
            }
            catch (AdsErrorException exception1)
            {
                if (exception1.ErrorCode != AdsErrorCode.DeviceServiceNotSupported)
                {
                    throw;
                }
                int version = SymbolUploadInfo.CalcVersion(this._adsClient.Read(0xf00c, 0, dataStream));
                dataStream.Position = 0L;
                return(new SymbolUploadInfo(new BinaryReader(dataStream), version));
            }
        }
Example #3
0
 public AdsBinaryWriter(AdsStream stream) : base(stream, Encoding.Default)
 {
 }
Example #4
0
        private unsafe void readSymbols(AdsStream symbolStream, SymbolUploadInfo info, int initialBlockSize)
        {
            int num = initialBlockSize;

            if (info.SymbolsBlockSize < num)
            {
                this._adsClient.Read(0xf00b, 0, symbolStream);
            }
            else
            {
                uint         num2   = 0;
                int          num3   = 0;
                int          num4   = 0;
                int          num5   = 0;
                int          length = 0;
                BinaryReader reader = new BinaryReader(symbolStream);
                while (true)
                {
                    int dataRead = 0;
                    while (true)
                    {
                        byte[] buffer;
                        length = ((num3 + num) <= symbolStream.Length) ? num : (((int)symbolStream.Length) - num3);
                        if (((buffer = symbolStream.GetBuffer()) == null) || (buffer.Length == 0))
                        {
                            numRef = null;
                        }
                        else
                        {
                            numRef = buffer;
                        }
                        AdsErrorCode adsErrorCode = this._adsClient.RawInterface.Read(0xf00b, 0x80000000 | num2, length, (void *)(numRef + num3), false, out dataRead);
                        fixed(byte *numRef = null)
                        {
                            if (adsErrorCode != AdsErrorCode.NoError)
                            {
                                if (adsErrorCode == AdsErrorCode.DeviceInvalidSize)
                                {
                                    num *= 4;
                                }
                                else
                                {
                                    TcAdsDllWrapper.ThrowAdsException(adsErrorCode);
                                }
                            }
                            if (adsErrorCode == AdsErrorCode.NoError)
                            {
                                num  = initialBlockSize;
                                num4 = num3;
                                num5 = 0;
                                symbolStream.Position = num3;
                                num5 = reader.ReadInt32();
                                while (true)
                                {
                                    if ((num5 > 0) && (num2 < info.SymbolCount))
                                    {
                                        num4 += num5;
                                        symbolStream.Position = num4;
                                        num2++;
                                        if ((num4 < (num3 + num)) && (num4 < symbolStream.Length))
                                        {
                                            num5 = reader.ReadInt32();
                                            continue;
                                        }
                                    }
                                    num3 = num4;
                                    if ((num2 < info.SymbolCount) && (num3 < symbolStream.Length))
                                    {
                                        break;
                                    }
                                    symbolStream.Position = 0L;
                                    return;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }