mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-22 19:36:11 +00:00
130 lines
4.7 KiB
C#
130 lines
4.7 KiB
C#
|
// Decompiled with JetBrains decompiler
|
|||
|
// Type: Toya.Upgrade.AppFile
|
|||
|
// Assembly: Toya.Upgrade, Version=1.0.0.0, Culture=neutral, PublicKeyToken=17364d3304d11368
|
|||
|
// MVID: 0375251D-E018-4B03-B16E-A2B257E37C3F
|
|||
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare.00004-msil\Virus.Win32.Virut.af-aff9bba96e482313952036dcb188d1e61b55115cab9bc23c4a365ea2decdb065.exe
|
|||
|
|
|||
|
using System;
|
|||
|
using System.Runtime.InteropServices;
|
|||
|
using System.Text;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace Toya.Upgrade
|
|||
|
{
|
|||
|
public class AppFile
|
|||
|
{
|
|||
|
private static string filePath = Application.StartupPath + "\\Toya.ini";
|
|||
|
private static StringBuilder sbAdjustINIValues = new StringBuilder(2048);
|
|||
|
private static StringBuilder sbTemp = new StringBuilder(2048);
|
|||
|
private static string[] AdjustINIValues;
|
|||
|
private static string[] INIValues;
|
|||
|
private static int Count = 28;
|
|||
|
private static int index = 0;
|
|||
|
private static string temp;
|
|||
|
|
|||
|
[DllImport("kernel32")]
|
|||
|
private static extern long WritePrivateProfileString(
|
|||
|
string section,
|
|||
|
string key,
|
|||
|
string val,
|
|||
|
string filePath);
|
|||
|
|
|||
|
[DllImport("kernel32")]
|
|||
|
private static extern int GetPrivateProfileString(
|
|||
|
string section,
|
|||
|
string key,
|
|||
|
string def,
|
|||
|
StringBuilder retVal,
|
|||
|
int size,
|
|||
|
string filePath);
|
|||
|
|
|||
|
public static long Write(string section, string key, string val) => AppFile.WritePrivateProfileString(section, key, val, AppFile.filePath);
|
|||
|
|
|||
|
public static string Read(
|
|||
|
string section,
|
|||
|
string key,
|
|||
|
string def,
|
|||
|
StringBuilder retVal,
|
|||
|
int size)
|
|||
|
{
|
|||
|
AppFile.GetPrivateProfileString(section, key, def, AppFile.sbTemp, size, AppFile.filePath);
|
|||
|
return AppFile.sbTemp.ToString();
|
|||
|
}
|
|||
|
|
|||
|
public static string Read(string section, string key, int size)
|
|||
|
{
|
|||
|
AppFile.GetPrivateProfileString(section, key, "无法读取对应数值", AppFile.sbTemp, size, AppFile.filePath);
|
|||
|
return AppFile.sbTemp.ToString();
|
|||
|
}
|
|||
|
|
|||
|
public static string Read(string section, string key, string def, int size)
|
|||
|
{
|
|||
|
AppFile.GetPrivateProfileString(section, key, def, AppFile.sbTemp, size, AppFile.filePath);
|
|||
|
return AppFile.sbTemp.ToString();
|
|||
|
}
|
|||
|
|
|||
|
public static void AdjustINIValue(string section, string key, string val) => AppFile.AdjustINIValue(section, key, val, AppFile.filePath);
|
|||
|
|
|||
|
private static void AdjustINIValue(string section, string key, string val, string filePath)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (val.Trim() == "")
|
|||
|
return;
|
|||
|
AppFile.GetPrivateProfileString(section, key, "", AppFile.sbAdjustINIValues, 2048, filePath);
|
|||
|
AppFile.INIValues = AppFile.sbAdjustINIValues.ToString().Split('\\');
|
|||
|
AppFile.AdjustINIValues = val.Trim().Split(' ');
|
|||
|
foreach (string adjustIniValue in AppFile.AdjustINIValues)
|
|||
|
{
|
|||
|
if (adjustIniValue != "")
|
|||
|
{
|
|||
|
AppFile.index = -1;
|
|||
|
for (int index = 0; index < AppFile.INIValues.Length; ++index)
|
|||
|
{
|
|||
|
if (adjustIniValue == AppFile.INIValues[index])
|
|||
|
{
|
|||
|
AppFile.index = index;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
if (AppFile.index == -1 && AppFile.INIValues.Length < AppFile.Count)
|
|||
|
{
|
|||
|
AppFile.INIValues = (string[]) AppFile.Redim((Array) AppFile.INIValues, AppFile.INIValues.Length + 1);
|
|||
|
AppFile.INIValues[AppFile.INIValues.Length - 1] = adjustIniValue;
|
|||
|
}
|
|||
|
if (AppFile.index > 0 && AppFile.index < AppFile.INIValues.Length)
|
|||
|
{
|
|||
|
AppFile.temp = AppFile.INIValues[AppFile.index - 1];
|
|||
|
AppFile.INIValues[AppFile.index - 1] = adjustIniValue;
|
|||
|
AppFile.INIValues[AppFile.index] = AppFile.temp;
|
|||
|
}
|
|||
|
if (AppFile.index == -1 && AppFile.INIValues.Length >= AppFile.Count)
|
|||
|
AppFile.INIValues[AppFile.INIValues.Length - 2] = adjustIniValue;
|
|||
|
}
|
|||
|
}
|
|||
|
AppFile.sbAdjustINIValues.Remove(0, AppFile.sbAdjustINIValues.Length);
|
|||
|
foreach (string iniValue in AppFile.INIValues)
|
|||
|
{
|
|||
|
if (iniValue != "")
|
|||
|
{
|
|||
|
AppFile.sbAdjustINIValues.Append(iniValue);
|
|||
|
AppFile.sbAdjustINIValues.Append("\\");
|
|||
|
}
|
|||
|
}
|
|||
|
AppFile.WritePrivateProfileString(section, key, AppFile.sbAdjustINIValues.ToString(), filePath);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
throw ex;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private static Array Redim(Array origArray, int desiredSize)
|
|||
|
{
|
|||
|
Array instance = Array.CreateInstance(origArray.GetType().GetElementType(), desiredSize);
|
|||
|
Array.Copy(origArray, 0, instance, 0, Math.Min(origArray.Length, desiredSize));
|
|||
|
return instance;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|