|
That was my suspicion, but I wanted to be certain prior to proceeding. Thanks for your help,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I have seen code like this what does new is doing on the declaration of this function. Is it better to define this way or it's some kind of shortcut. Thanks
public Class A:UserControl
{
public new int Width
{
}
}
|
|
|
|
|
netJP12L wrote: what does new is doing on the declaration of this function.
They hide that information in the documentation[^]
led mike
|
|
|
|
|
I have a custom string being spit out from a log file that I would like make into a DateTime object.
The problem is I have no idea how to do this simply.
Mon Feb 25 07:21:00 2008
The string does not parse straight to a DateTime object and I do not have anyway of changing the format of the incoming string.
|
|
|
|
|
|
Thanks, didn't realize that function was for doing that kind of parsing.
Took me just a few secs to have it up and running properly.
|
|
|
|
|
Sunset Towers wrote: didn't realize that function was for doing that kind of parsing.
Yeah, darn Microsoft keeps hiding the kind of information in the documentation.
led mike
|
|
|
|
|
Hi ho
I've noticed something weird. When I try to read an unexisting address location (using ReadProcessMemory of kernel32 libraries), it gives an exception. This is totally normal. Then I'm able to retrieve the error code with GetLastError(). This code can be formatted, which returns a nice string message in my native language.
But now I've noticed something that's not quite normal. When I run the application normally, and the expected exception happens, the FormatMessage returns something like:
"A Read/WriteProcessMemory-operation is only partly executed."
Riiiiiight... Now the weirdest thing is, if I put a debugging breakpoint just before I retrieve the error code with GetLastError(), and then do a step-by-step running (you know, the F11/F10 thing), it returns something totally different:
"Tried to point to an unexisting token."
Which is the message I want, because that's exactly what I did wrong. But still he doesn't return it if I don't put a breakpoint just before the GetLastError() function. It's as if the system needs a little time to store the error code, and my program is too fast requesting it. I tried a System.Threading.Thread.Sleep(100); or so, but that didn't work.
Here's my code, if that helps:
<br />
if (!ReadProcessMemory(handle, new IntPtr(address), buffer, length, out bytesReadPtr))<br />
{<br />
StringBuilder str = new StringBuilder();<br />
str.Capacity = 1000;<br />
FormatMessage(<br />
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,<br />
IntPtr.Zero,<br />
GetLastError(),<br />
0,<br />
str,<br />
1000,<br />
IntPtr.Zero);<br />
throw new Exception("Unable to read process memory.\n" + str.ToString());<br />
}<br />
Anyone knows what's going on?
Thanks in advance.
(Btw. Can't I use decent tabs in code on this forum? )
modified on Sunday, March 2, 2008 12:03 PM
|
|
|
|
|
Dear all,
I wrote this piece of code to clear all the textboxes on a control all at once.
foreach (Control control in tabpage.Controls)<br />
{<br />
if (control.GetType() == typeof(TextBox));<br />
{<br />
control.Text = "";<br />
}<br />
}
It works , but .. it also clears all the labels in the control ; however labels are not of type Textbox.
Could somebody tell me what I am doing wrong ?
kind regards,
|
|
|
|
|
Addition to the previous post ... this works :
for (int i = 0; i < this.Controls.Count; i++ )<br />
{<br />
if (this.Controls[i] is TextBox)<br />
{<br />
this.Controls[i].Text = "";<br />
}<br />
}
I'm puzzled now
|
|
|
|
|
Rick van Woudenberg,
foreach (Control control in Controls)
{
if (control is TextBox)
{
TextBox textBox = control as TextBox;
textBox.Text = string.Empty;
}
}
Regards,
Gareth.
|
|
|
|
|
Hi remove the semicolon on the following statement
if (control.GetType() == typeof(TextBox));
then it should work
Regards
Srini
|
|
|
|
|
Hi ho
I've been experimenting with reading memory of other processes for a while now. And I've noticed the virtual addresses are quite weird.
First of all I can't access anything from 0x0 till 0xFFFF. This seems to be a forbidden area or so. :p I've never found a process that didn't have this 'offset'. The first readable address socket is 0x10000. I first thought this previous forbidden area (lower than 0x10000) was a Windows header or so, but it seems this 0x10000 and further is the windows header, including some data like the windir, cpu architecture, and so on.
Now you'd think the actual data of the process itself is just after this Windows header, but that's often not the case. Suddenly there's another piece of memory that's not accessible there. That keeps on going for a while.
Now I searched up some interesting addresses for certain processes (like the Minesweeper of Windows XP), and I can for example find the width and height of a minefield. But when you look at the actual address of this data, it's extremely high (relatively of course): 0x1005334. This is a hundred times higher than the first memory address that's accessible (0x10000).
I've researched a bit, but I can't find information about a certain structure Windows uses for process memory. Maybe there's a fixed virtual address where it actually starts to be interesting to read memory, because that's the actual memory allocated by the process itself?
Thanks in advance.
|
|
|
|
|
Hi,
virtual addresses get assigned by the linker, based on some defaults and a lot of optional
choices you can specify. It gets reported in the optional map file. As a result the address map
can be structured in many ways, all equaly valid.
Not sure how this is a C# question, Minesweeper is a lot older than any .NET stuff.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I'm not talking about Minesweeper, I'm talking about any existing process that runs on Windows. :p I'd really like to find some pattern that can be used to find significant memory data more easily.
My final purpose is to make addons for applications that actually don't support addons.
|
|
|
|
|
Good luck then. I just told you things can be anywhere, it is a matter of choice.
Will your add-ons be programmed in C#? and apply to native code programs???
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks, hehehe. I'll just try to make a monitoring program first then, that logs what changes in memory. Then I can see what action changes which addresses.
Yes I will be making addons programmed in C#, applied to native code programs (as far as I know).
|
|
|
|
|
Hi Guys,
I need some help please. I have the following code being called in my timer_elapsed function and my timer is being enabled in the onstart of the windows service. This worked fine with .net 1.1 but ever since I have converted the application to .net 2.0, my service shuts down without notice when there is trafic in client requests i.e. ProcessClientRequest call. When I try to restart the service upon shut down it gives me an error saying "Only one usage of each socket address (protocol/network address/port) is normally permitted"
So I have to stop and wait a few and restart and it works fine and then again when there is much activity in processclientrequest call it shuts down.
I know this is not much information but please help me if you have any ideas.
Writ2ErrLog("Service Timer Initialized");
string sErr = "Application is ready for processing";
try
{
Writ2ErrLog(sErr);
m_tMonitor = new TD.Timer(new TD.TimerCallback(MonitorFunc), 1, 0, 45000);//45 sec
if (m_sServerAddr == string.Empty)
{
m_sServerAddr = Dns.GetHostName();
}
if (m_nPort == -1)
{
m_nPort = 1024;
}
IPHostEntry hostEntry = Dns.GetHostEntry(m_sServerAddr);
IPAddress ipAddress = hostEntry.AddressList[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, m_nPort);
m_svSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
m_svSocket.Bind(ipEndPoint);
m_svSocket.Listen(10);
while (true)
{
try
{
Socket rtSocket = m_svSocket.Accept();
if (rtSocket.Connected)
{
TD.WaitCallback myCallBack = new TD.WaitCallback(ProcessClientRequest);
TD.ThreadPool.QueueUserWorkItem(myCallBack, rtSocket);
}
}
catch (Exception ex)
{
Writ2ErrLog(ex.Message);
break;
}
}
}
catch (Exception ex)
{
m_svSocket.Close();
m_tMonitor.Dispose();
sErr = "Start Error " + ex.Message;
}
finally
{
if (sErr != string.Empty)
{
Debug.WriteLine(sErr);
Writ2ErrLog(sErr);
}
}
Sameer
|
|
|
|
|
hi all,
i just want to read outlook express 6 contacts using c#. how to do that bcoz using outlook object library you can just browse only the outlook contacts but for outlook express how we can do that?
plz.. any one can help me out.
Regards,
kiran
kiran
|
|
|
|
|
Kiran, judging by the list of unanswered questions on the web, it appears Outlook Express doesn't support a programming model. You may have to manually parse the contacts file.
p.s. you're more likely to receive answers in this forum if you refrain from using text/IM speak like 'bcoz', 'plz', etc.
*edit* apparently it's possible, but possibly undocumented. see http://www.nektra.com/products/oeapi/[^]
|
|
|
|
|
Hi!
I get this confusing error when I start my program:
"this Cannot obtain value of local or argument '<this>' as it is not available at this instruction pointer, possibly because it has been optimized away."
The exception window pops up and I get: "NullReferenceException was unhandled" which this text also is visable "Object reference not set to an instance of an object".
What does this error mean? I'm tring to make a dynamic event. The error occurs where I have written the name of the event, when the event is so possed to start. Not where I have declared the delegate and the event.
/Mc_Topaz
|
|
|
|
|
Can you show us some code where it's occurring?
|
|
|
|
|
<br />
class Variant<br />
{ <br />
public enum e_Type<br />
{<br />
null_,<br />
bool_,<br />
int_,<br />
float_,<br />
double_,<br />
string_<br />
}<br />
<br />
e_Type m_type = e_Type.null_;<br />
public e_Type type() { return m_type; }<br />
<br />
private bool m_bool = false;<br />
private int m_int = 0;<br />
private float m_float = 0;<br />
private double m_double = 0;<br />
private string m_string = "";<br />
<br />
public delegate void DataChangedDelegate();<br />
public event DataChangedDelegate DataChanged;<br />
<br />
public Variant(bool val) { m_type = e_Type.bool_; m_bool = val; DataChanged(); }<br />
<br />
public static implicit operator Variant(bool val) { Variant V = new Variant(val); return V; }<br />
<br />
<br />
}
<br />
This is the code which contains the event and delgate stuff.
I get the problem when the program comes to "DataChanged();" inside "Variant(bool val)".
If I run this statement, the error occurs as described earlier:
Variant a = true;
If I put a breakpoint at DataChanged();, The debugger reports:
"<this> Cannot obtain value of local or argument '<this>' as it is not available at this instruction pointer, possibly because it has been optimized away."
I hope you can help me.
modified on Tuesday, February 26, 2008 3:58 AM
|
|
|
|
|
Are you running under Debug mode? Usually I get that debugger error when I'm debugging an app built in Release mode.
In any case, if all else fails, just print the exception details to the output window via Debug.WriteLine. (Or perhaps its as easy as gareth says, and it's just that your event has no listeners.)
|
|
|
|
|
Mc_Topaz,
If (eventName != null)
new eventName();
Regards,
Gareth.
|
|
|
|
|