|
Aiding in the development of malware can be punishable by law in the Netherlands.
I would recommend against too many assumptions, just to be on the safe side.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You ASSume too much.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Quote: I need it so that the program continues to run in stealth mode so that no one knows it's installed on the computer. Malware is the only software that has such a requirement.
|
|
|
|
|
Nowhere did I encourage running in "stealth" mode.
I patiently pointed out "my" user had access and the software runs "unobtrusive" (in the taskbar).
In the one case it was "Nanny software"; the other case an "owner" productivity tool.
Part of putting up an effective defence is knowing the techniques you want to protect against.
A "discusssion" is not an invitation to participate in a particular activity.
Some of you are so busy trying to make "points", you completely miss any opportunity to gain relevant knowledge.
Even if the OP's intentention was "malware", a better approach would be to "discourage" that behaviour instead of everyone riding off on their high horses.
If I call everything you produce "crap", it doesn't make it so.
And everyone trying to understand "key logging", etc, is not intent on making "malware".
Get a grip.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
You're welcome
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Fortunately that crap of code snippet is so full of bad practices that we are likely to be safe from your malware...
Ever heard of formatting of DateTime values? What could happen when the code is executed around midnight? What about other screen sizes? What about 2 or even 3 screens? How many changes must be done when the directory name changes? Oh, look, "C:\Intel\Logs" is write-protected for non-administrative users.
Yeah, I am pretty that crap would fail on my machine. Malware-writers deserve failure.
|
|
|
|
|
Guys,
I am working on creating intel.hex file from the inputted .txt file. The format of Intel Hex file is
Steps that I follow....
1. Input a .txt file using combo-box and browse button (working fine)
2. Read .txt file using StreamReader (Working fine)
3. Read a single line of the txt file as string (working fine)
4. Get the length of the string ( Now here is a twist)
If I just do str.length, I get the length of the string but it is not of use for me...
Lets take an example of a txt file having data 123456GCTJ
the string str = "123456GCTJ" and str.length = 10
However, since I am converting this text to intel hex format, the string is actually this way...
12, 34, 56, G, C, T, J -> Length = 7
Now, I have to do this dynamically.
Question 1. How to get the string length? Do I have to write my own function? or Do I have to define a public class and associate it with the string like... str.getlengthForIntel()
5. Once, I have length, append the data to the format i.e. Start of Frame + Address + Data + checksum
(Working Fine)
6. Checksum (how to get the checksum? I have written below piece of code which I doubt will work once we have solution to above question)
private string GetChecksum(string strData)
{
byte checksum = 0;
char[] DataArray = strData.ToCharArray();
byte ArrayLen = 0;
string strAscii;
while (ArrayLen < strData.Length)
{
if ((DataArray[ArrayLen]) != ':')
{
checksum += (byte)(GetNumberFromString(DataArray[ArrayLen], DataArray[ArrayLen + 1]));
ArrayLen++;
}
ArrayLen++;
}
checksum = (byte)(~(int)checksum);
checksum += 1;
strAscii = ((checksum & 0xF0) >> 4).ToString("X") + (checksum & 0x0F).ToString("X");
return strAscii;
}
private byte GetNumberFromString(char cHighByte, char cLowByte)
{
uint uHighByte, uLowByte;
uint uFinalNum;
uHighByte = GetHexValueFromAscii(cHighByte);
uLowByte = GetHexValueFromAscii(cLowByte);
uFinalNum = (uHighByte << 4) + uLowByte;
return (byte)uFinalNum;
}
private byte GetHexValueFromAscii(char Ascii)
{
byte HexNum;
if ((Ascii >= 0x30) && (Ascii <= 0x39))
{
HexNum = (byte)(Ascii & 0x0F);
}
else
{
HexNum = (byte)Ascii;
}
return HexNum;
}
|
|
|
|
|
Quote: the string str = "123456GCTJ" and str.length = 10 What are you expected to do with that string? Do you need to convert it into some other form, or does it get transmitted exactly as is? If the latter then you just need to write a method that scans the content and counts the number of pairs of digits (as one item) and the number of single characters. The total will give you the required length. As to the checksum: what are the requirements?
|
|
|
|
|
Psudonym wrote: Question 1. How to get the string length? Do I have to write my own function? or Do I have to define a public class and associate it with the string like... str.getlengthForIntel()
Yes. There is no standard function which will do that for you, so you will have to code it yourself.
Which way to go? Up to you - but I'd say that a class just for one function is a little inefficient. It's possible that an extension method might work out, but I'd probably make it a method within the processing class myself.
Psudonym wrote: Checksum (how to get the checksum?
Wikipedia gives a good explanation of the checksum calculation:Intel HEX - Wikipedia[^] - it's not complicated at all, unlike CRC or more modern checksums, it's just a sum followed by a twos complement.
So write a function that reads your text string and converts it to a byte array, then write a second function that sums the array into a byte, discarding any carry, and complement it.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hello,
apparently, the link for intel hex file is not pasted in previous post. Here it is..
[^]
Now, the txt file data has to be converted to this file format.
Lets take an example of txt - 1234GCTJ
When I read this txt into string, I get "1234GCTJ"
To get checksum of it, I need to convert it into hex which is...
12, 34, 'G', 'C', 'T', 'J'
So, I read the string into CharArray and then convert ASCII to HEX.
Now, it is possible that the input text is...
1G234K
In this case, the chararray will give me 0x31, 'G', 0x32, 0x33, 0x34, 'K'
And I will have to convert it into equivalent Hex ie. 1, 'G', 23, 4, 'K'
I am wondering, how to do that.
I hope I have clearly specified my requirement.
|
|
|
|
|
Why is that giving you difficulty?
It's pretty trivial: loop through each character in the input.
if the previous char was a digit, then if the current is also a digit, convert them both to a single value and add them to the output and continue with the next character. If not, add the last digit to the output as a nibble. (i.e. '0' becomes a 0 byte, '1' becomes a 1 byte, ...
If the current char is a digit, save it for next time.
If it isn't, add it directly to the output.
After the loop finishes, check if the last character was an un-output digit and output if needed.
One loop, a bool, a byte variable, and a List<byte> to output to: this isn't a complex operation, and shouldn't take a developer more than a couple of minutes to write...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That is not how Intel hex works!
when your data is a text string, then each charactershould be turned in a two-digit hex number wether it is a digit or not.
|
|
|
|
|
Guys,
Thank you for help!
Well, I thought to go with slightly simpler approach...
string = "1234GCTJ"
Now, I will use it as it is for checksum calculation meaning, I will do checksum calculation as...
0x31, 0x32, 0x33, 0x34, 'G', 'C', 'T', 'J'
I won't use them like ... 12, 34, 'G', 'C', 'T', 'J'
Here it is..
StrLine is the Txt read line-by-line from the inputted file
string strLine;
int iBytelen;
long lBaseAddress = 0x7830;
string subString;
string strTempStrForChecksum;
uint iLoopcntr, iLoopcntrcopy;
int index;
subString = strLine.Trim().Substring(0, strLine.Length - 1);
strTempStrForChecksum = ":" + iBytelen.ToString("X") + lBaseAddress.ToString("X") + "00" + subString;
strTempStrForChecksum += GetChecksum(strTempStrForChecksum);
pFile.Write(strTempStrForChecksum + "\n");
But, there is problem here also...
the SubString holds the actual text bytes i.e. "1234GCTJ"
And
strTempStrForChecksum = ":" + iBytelen.ToString("X") + lBaseAddress.ToString("X") + "00" + subString;
I am expecting subString to print it in hex format i.e. 31323334'G''C''T''J'
So, I tried
subString.ToString("X")
but it is throwing compilation error.
Then I tried subString.ToCharArray()
but it is also not giving expected output.
Please let me know how to do this?
|
|
|
|
|
That isn't what Luke was saying: intel hex format is all in hex:
So your string "1234GCTJ" would be stored in Intel hex format as a string: "313233344743544A" with the appropriate line wrapping.
Read the link I gave you: it explains Intel hex format pretty well.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Sir!
Correct...this is what exactly I am trying to do now.
My previous understanding was wrong and I realised it.
And my code is fairly working i.e. formatting and calculating checksum. But only one part I am struggling with...
string strLine;
int iBytelen;
long lBaseAddress = 0x7830;
string subString;
string strTempStrForChecksum;
uint iLoopcntr, iLoopcntrcopy;
int index;
subString = strLine.Trim().Substring(0, strLine.Length - 1);
strTempStrForChecksum = ":" + iBytelen.ToString("X") + lBaseAddress.ToString("X") + "00" + subString;
strTempStrForChecksum += GetChecksum(strTempStrForChecksum);
pFile.Write(strTempStrForChecksum + "\n");
I am expecting this as outputting... intel formatted string but actual output still has 1234GCTJ
instead of 31323333447...
subString.ToString("X") and subString.ToCharArray() is what I tried to converted 1234GCTJ to 31323334... but none of them are working.
|
|
|
|
|
If you want "Intel hex" do exactly what the spec says; if you want something else, don't call it "Intel hex".
Whatever you do, calculating the checksum does not involve the textual representation, it starts off with the data bytes no matter what they represent.
|
|
|
|
|
Guys,
I could solve the problem.
This is the solution...
private string ToHexString(string str)
{
var sb = new StringBuilder();
var bytes = Encoding.Unicode.GetBytes(str);
for(int i=0; i<str.Length; i++)
{
byte b = (byte)str[i];
sb.Append(b.ToString("X"));
}
return sb.ToString();
}
}
}
However, this has opened up new problem.
Now the checksum is wrong
When I pass string "Quote: :107830003132313131303031323331323334363120 "
for checksum calculation, the expected o/p is 0x2B however the function returns "20".
this is the function...
private string GetChecksum(string strData)
{
byte checksum = 0;
char[] DataArray = strData.ToCharArray();
byte ArrayLen = 0;
string strAscii;
while (ArrayLen < strData.Length)
{
if ((DataArray[ArrayLen]) != ':')
{
checksum += (byte)DataArray[ArrayLen];
}
ArrayLen++;
}
checksum = (byte)(~(int)checksum);
checksum += 1;
strAscii = ((checksum & 0xF0) >> 4).ToString("X") + (checksum & 0x0F).ToString("X");
return strAscii;
}
When I debug the problem, I could see, the function received first 1 in string as 31. I know that is the problem, it should receive first 10 as 10 and not as 31 30
|
|
|
|
|
private void VtfGraphicalViewMode(Page page, float x, float y)
{
AddCaptionAndRectangle(page, "Vertical Forces Graph", x, y, CHAR_WIDTH, CHAR_HEIGHT);
ceTe.DynamicPDF.PageElements.Charting.Chart chart =
new ceTe.DynamicPDF.PageElements.Charting.Chart(x + 10, y + 25, CHAR_WIDTH - 25, CHAR_HEIGHT - 25, ceTe.DynamicPDF.Font.Helvetica, 10, RgbColor.Black);
ceTe.DynamicPDF.PageElements.Charting.PlotArea plotArea = chart.PrimaryPlotArea;
ceTe.DynamicPDF.PageElements.Charting.Title headerTitle =
new ceTe.DynamicPDF.PageElements.Charting.Title("Vertical Forces (VTF)");
chart.HeaderTitles.Add(headerTitle);
if (vtfGraph.Count > 0)
{
ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries leftVTFLineSeries =
new ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries("Left VTF");
leftVTFLineSeries.Values.Add(vtfGraph.GetLeftVTF(0, 100));
ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries rightVTFLineSeries =
new ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries("Right VTF");
rightVTFLineSeries.Values.Add(vtfGraph.GetRightVTF(0, 100));
ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries totalVTFLineSeries =
new ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries("Total VTF");
totalVTFLineSeries.Values.Add(vtfGraph.GetTotalVTF(0, 100));
plotArea.Series.Add(leftVTFLineSeries);
plotArea.Series.Add(rightVTFLineSeries);
plotArea.Series.Add(totalVTFLineSeries);
}
page.Elements.Add(chart);
}
Regards,
Manjum
|
|
|
|
|
And?
If you are waiting for permission, consider it given.
If you have a problem, then it's probably a good idea to explain what problem you are having, where you are having it, and what help you need in solving it...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I want to add many items after scan them one by one from database into datatable
public void CheckItem( string itemcode)
{
string constring = @"Data Source=.;Initial Catalog=pos;User id = sa;password=123";
SqlCommand objCmd = new SqlCommand();
objCmd.Parameters.Clear();
using (SqlConnection objCnn = new SqlConnection(constring))
{
objCnn.Open();
using (objCmd = objCnn.CreateCommand())
{
objCmd.CommandType = CommandType.Text;
objCmd.CommandText = "SELECT * FROM Items where Item_Code=@Item_Code";
objCmd.Parameters.Add(new SqlParameter("@Item_Code", itemcode));
SqlDataReader myreader = objCmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(myreader);
decimal sumprice=0;
if (dt.Rows.Count <= 0)
dt = objDT.NewRow();
dt.Columns.Add("", typeof(decimal));
dataGridView1.DataSource = dt;
}
}
}
|
|
|
|
|
I suggest moving the instantiation of the datatable to a class level (outside of you method) and each time you populate dt you add the dt rows to the class level table.
The class level table is the one that will be bound to your DGV
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
anyone cal add code in this for that
public class VerticalForceGraph
{
private List<verticalforce> vtfList = new List<verticalforce>();
public int BufferSize { get; set; }
public void Add(VerticalForce vtf)
{
vtfList.Add(vtf);
// remove first item if condition
if(vtfList.Count > BufferSize)
{
// vtfList.RemoveRange(1, 1);
vtfList.RemoveAt(0);
}
}
public int[] GetLeftVTF()
{
return vtfList.Select(x => x.Left).ToArray();
}
public int[] GetRightVTF()
{
return vtfList.Select(x => x.Right).ToArray();
}
public int[] GetTotalVTF()
{
return vtfList.Select(x => x.Total).ToArray();
}
}
// and i want to cal it here and draw graph
private void VtfGraphicalViewMode(Graphics graphics)
{
Pen yellowPen = new Pen(Color.Yellow, 2);
Pen bluePen = new Pen(Color.Blue, 2);
Pen redPen = new Pen(Color.Red, 2);
int hOffset = heatmapWidth / 2;
int vOffset = heatmapHeight / 2;
//Display title
using (Font title_font = new Font("Times New Roman", 20))
{
using (StringFormat string_format = new StringFormat())
{
string_format.Alignment = StringAlignment.Center;
string_format.LineAlignment = StringAlignment.Center;
Point title_center = new Point(this.heatmapWidth / 2, 20);
Point titleleft = new Point(this.heatmapHeight / 4, heatmapWidth/10);
Font leftfornt = new Font("Times New Roman", 10);
Font totalfont = new Font("Times New Roman", 10);
Font rightfont = new Font("Times New Roman", 10);
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.DrawRectangle(outline, new Rectangle(heatmapCoord_X, heatmapCoord_Y, heatmapWidth, heatmapHeight));
Rectangle graph_area = new Rectangle(heatmapCoord_X, heatmapCoord_Y, heatmapWidth, heatmapHeight);
graphics.FillRectangle(Brushes.LightBlue, graph_area);
graphics.DrawString("VTF Grahical View",
title_font, Brushes.Blue,
title_center, string_format);
graphics.DrawString("Left VTF", leftfornt, Brushes.Blue, titleleft, string_format);
//Y-axis
int xOffset = 50;
int yOffset = 20;
graphics.DrawLine(Pens.Blue,
heatmapCoord_X + xOffset, heatmapCoord_Y + (heatmapHeight - 50),heatmapCoord_X + xOffset, heatmapCoord_Y + yOffset
);
//X-axis
graphics.DrawLine(Pens.Blue,
heatmapCoord_X + (heatmapWidth - 10), heatmapCoord_Y + (heatmapHeight - 50), heatmapCoord_X + xOffset, heatmapCoord_Y + (heatmapHeight - 50)
);
|
|
|
|
|
You haven't described a problem at all as your "question" makes no sense. Your code makes even less sense.
We have no idea what you're having a problem with or what you're asking.
|
|
|
|
|
namespace VistaBalanceAlgorithms
{
public class VerticalForce
{
public static float SteadyStateTotalForce = 1;
public static bool SteadyState = false;
public VerticalForce(float[] frameValues)
{
Left = 0;
Right = 0;
Total = 0;
if (frameValues != null)
{
float leftForce = frameValues.Take(frameValues.Length / 2).Sum();
float rightForce = frameValues.Skip(frameValues.Length / 2).Sum();
Left = (int)((leftForce / SteadyStateTotalForce) * 100);
Right = (int)((rightForce / SteadyStateTotalForce) * 100);
Left = Left < 0 ? 0 : Left;
Right = Right < 0 ? 0 : Right;
Total = Left + Right;
}
}
public int Left { get; protected set; }
public int Right { get; protected set; }
public int Total { get; protected set; }
}
public class VerticalForceGraph
{
private List<VerticalForce> vtfList = new List<VerticalForce>();
public int BufferSize { get; set; }
public void Add(VerticalForce vtf)
{
vtfList.Add(vtf);
if(vtfList.Count > BufferSize)
{
vtfList.RemoveAt(0);
}
}
public int[] GetLeftVTF()
{
return vtfList.Select(x => x.Left).ToArray();
}
public int[] GetRightVTF()
{
return vtfList.Select(x => x.Right).ToArray();
}
public int[] GetTotalVTF()
{
return vtfList.Select(x => x.Total).ToArray();
}
}
}
here i want to cal it on another class
//here i only created rectangle inside panel and draw x and y acc to panel scale
private void HeatmapViewMode(Graphics graphics)
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.DrawRectangle(borderPen, new Rectangle(heatmapCoord_X, heatmapCoord_Y, heatmapWidth, heatmapHeight));
Pen semiTransPen = new Pen(Color.FromArgb(128, 0, 0, 255), 3);
var points = m_CopTail.GetPoints().Select(c => { c.X = c.X - m_AutocenterOffsetX; c.Y = c.Y - m_AutocenterOffsetY; return c; }).ToArray();
if (points != null && points.Length > 1)
{
SizeF copPointSize = new SizeF(10, 10);
SizeF centerOffset = new SizeF(copPointSize.Width / 2, copPointSize.Height / 2);
PointF copPoint = new PointF(COP.X - m_AutocenterOffsetX - centerOffset.Width,
COP.Y - m_AutocenterOffsetY - centerOffset.Height);
graphics.FillEllipse(Brushes.Red, new RectangleF(copPoint, copPointSize));
if (m_CopTail.TimeRange.TotalSeconds > 0)
graphics.DrawCurve(semiTransPen, points);
if ((Mode == ModeOfOperation.STABILITY_MODE && m_CopTail.HasAutoCenter() == true) ||
(m_CopTail.HasAutoCenter() == true && CopArrow == true))
{
PointF centerPoint = new PointF(heatmapCoord_X + heatmapWidth / 2f,
heatmapCoord_Y + heatmapHeight / 2f);
PointF endPoint = new PointF(copPoint.X + centerOffset.Width, copPoint.Y + centerOffset.Height);
var distance = Math.Sqrt(Math.Pow((centerPoint.X - endPoint.X), 2) + Math.Pow((centerPoint.Y - endPoint.Y), 2));
float triggerZoneDiameter = 30f;
StabilityTriggerZoneDraw(graphics, triggerZoneDiameter, distance > triggerZoneDiameter);
graphics.DrawLine(stabilityArrowPen, centerPoint, endPoint);
}
if (heatmap != null)
heatmap.Draw(graphics, heatmapCoord_X - m_AutocenterOffsetX, heatmapCoord_Y - m_AutocenterOffsetY, 80);
}
}
|
|
|
|
|
It's "calibrate", not "cal". Yes, it makes a difference when talking to other people who are not involved in your project.
So, what's the problem? You still haven't described the problem you're having.
|
|
|
|
|