|
This sounds like the sort of code I wouldn't like anywhere near my computer.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
I have to agree with Chris - that sounds like malicious software, invasion of privacy, almost certainly illegal in many countries.
We do not condone, support, or assist in the production of malicious code in any way, form, or manner. This is a professional site for professional developers.
If you want to know how to create such things, you need to visit a hacking site: but be sure to disable all firewalls and antivirus products first or they won't trust you enough to tell you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
To be honest, even if you could find out how to hide the program on the computer and keep it hidden from the process list, you're still going to be caught out if someone is actively monitoring network traffic. There will be sudden spikes of high load on the network with no apparent cause - and that's when the investigations would start. Your code would soon be located and removed and then it would feature in every AV software patch released. All because you want to write something that looks like it has malicious intent.
So, no, we aren't going to help you write software like this.
This space for rent
|
|
|
|
|
For the time being, I'll assume your motives are less nefarious since I supported similar commercial products for a few years:
1) An activity monitor with a "religious" theme that would popup quotes
2) A total "desktop" manager with reminders; notes; activity charts; keystrokes and mouse moves over time; thumbnails; emails; etc.
Access was always there though; I'd prefer "unobtrusive" versus "stealth".
Anyway, the user needs to supply the "app" with an email server address / credentials; or the "app" has to get them from you somehow; which usually involves "calling home" if not imbedded in software or config files (a bad idea).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
modified 23-Aug-17 12:44pm.
|
|
|
|
|
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
|
|
|
|
|