|
iceeeeman wrote: but for a particular application that I need, it doesn't seem to work, it returns empty string..
Please post some of your code to show where the problem occurs, the above tells us nothing.
It's time for a new signature.
|
|
|
|
|
Hi Richard, thanks for your prompt reply
ReturnString returns empty, here's the code that I've used
Win32.GetWindowThreadProcessId(ListViewHWND, out ProcessID);
ListViewProcessPointer = Win32.OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_QUERY_INFORMATION, 0, ProcessID);
ListViewItemPointer = Win32.VirtualAllocEx(ListViewProcessPointer, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(Win32.LVITEM)), MEM_COMMIT, PAGE_READWRITE);
ListViewPointer_item = Win32.VirtualAllocEx(ListViewProcessPointer, IntPtr.Zero, 1512, MEM_COMMIT, PAGE_READWRITE);
ListViewPointer_subitem = Win32.VirtualAllocEx(ListViewProcessPointer, IntPtr.Zero, 1512, MEM_COMMIT, PAGE_READWRITE);
ListViewItem.cchTextMax = 1512;
string[,] ReturnString = new string[300, 2];
int ReturnStringIndex = 0;
for(int i = 0; i < totalItem; i++)
{
ListViewItem.iSubItem = 0;
ListViewItem.pszText = ListViewPointer_item;
Win32.WriteProcessMemory(ListViewProcessPointer, ListViewItemPointer, ref ListViewItem, Marshal.SizeOf(typeof(Win32.LVITEM)), IntPtr.Zero);
Win32.SendMessage(ListViewHWND, LVM_GETITEMTEXT, i, ListViewItemPointer);
ListViewItem.iSubItem = 0;
ListViewItem.pszText = ListViewPointer_subitem;
Win32.WriteProcessMemory(ListViewProcessPointer, ListViewItemPointer, ref ListViewItem, Marshal.SizeOf(typeof(Win32.LVITEM)), IntPtr.Zero);
Win32.SendMessage(ListViewHWND, LVM_GETITEMTEXT, i, ListViewItemPointer);
IntPtr bytesReaded;
Win32.ReadProcessMemory(ListViewProcessPointer, ListViewPointer_item, ListViewItemBuffer, 1512, out bytesReaded);
Win32.ReadProcessMemory(ListViewProcessPointer, ListViewPointer_subitem, ListViewSubItemBuffer, 1512, out bytesReaded);
MessageBox.Show(ListViewSubItemBuffer+"");
ReturnString[ReturnStringIndex, 0] = Encoding.ASCII.GetString(ListViewItemBuffer);
ReturnString[ReturnStringIndex, 1] = Encoding.ASCII.GetString(ListViewSubItemBuffer);
ReturnStringIndex++;
}
|
|
|
|
|
I can see nothing obvious in the above, but since this is an extract there are a number of declarations missing. I would suggest you try stepping through your code with the debugger and verifying the correct values for your variables and pointers. Also please use the "code block" button when posting code to ensure it is surrounded by <pre></pre> tags.
It's time for a new signature.
|
|
|
|
|
Hi Richard, I tried using Stealing Program's Memory[^] in C#, and also in C++. They worked fine for the demo application provided with it, but when I tried to use it with a another application, I am just able to get the total number of Items in the Listview, without the Items
Could you please help
Thanks
|
|
|
|
|
Sorry but this is a system that I have never used. You could try posting a message in the forum at the end of the article to see if the author or any other user has the answer.
It's time for a new signature.
|
|
|
|
|
Hi
Is there any way to configure ASP.Net, C# application to store all the session values into custom storage.
Session["UserName"] = "XXX";
this has to call my own adopter and send the values rather than In-Memory/SQL Server.
Thanks
|
|
|
|
|
I don't know if this will address your question or not but it is bad practice to directly use the Session object in code. By using a static wrapper class you can have all calls to session centralized as well as strongly and statically typed (a good thing). You then have the freedom to completely control the underlying implementation.
The link below addresses a custom provider.
http://msdn.microsoft.com/en-us/library/ms178587.aspx[^]
|
|
|
|
|
My Qestion: It is possible to call the Class instance name I get with
FieldInfo[] myFieldInfo;
.......
myFieldInfo[i].Name
(Example from MSDN)
Thanks
|
|
|
|
|
Your question is not very clear. Could you clarify what exactly it is that you want to do?
|
|
|
|
|
Sorry for my unclear question.
What I want is to call a method via its class-instance name (I have already create a instance) at runtime from another class in the same assembly.
The problem is, I don´t know the class instance name at compile time.
So I get the name via reflection (FieldInfo class).
Probably a method like "methodInfo.Invoke" can do the job, but so far I´m understand
the class instance must known at compile time.
Thanks
|
|
|
|
|
Just to be clear on that, you have a field of a particular type, and you want to invoke a method on this field instance at run-time. Is that right?
|
|
|
|
|
Something like this should work:
class SomeType
{
public void Foo()
{
Console.WriteLine("SomeType.Foo");
}
}
class AnotherType
{
private SomeType someType = new SomeType();
}
class App
{
static void Main()
{
AnotherType another = new AnotherType();
string fieldName = "someType";
FieldInfo fi = another.GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
object fieldValue = fi.GetValue(another);
SomeType someType = fieldValue as SomeType;
if(someType != null)
{
someType.Foo();
}
}
}
|
|
|
|
|
Works perfect! Exactly what I´m searching for.
Thanks.
Regards
|
|
|
|
|
I've just spent a few days creating a User Control in a library, and for a project I want several similar controls. The new controls will contain some of the same elements, in different positions perhaps, and with different names, but the overall User Controls should be of the same size, color, font, etc.
Is there an easier way than manually creating each User Control and adding back all the elements, just to make something almost, but not quite identical to the original?
[EDIT]
I opened the project folder, located the three basic files for the control - .cs, .resx, .Designer - and copied them to a subfolder. I then renamed them and copied them back to the original project folder. Then I used Add Existing Item in VS to locate the renamed files and add them to my project. It choked, of course, because of ambiguity. Using Find and Replace, I opened all the new files, closed all the files I wanted to keep, and selected the option to Find and Replace in all open files, using the original filename and new file name as arguments. It worked like a charm, and will save me hours of manual editing. It even builds without error...
[/EDIT]
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
A good user control is like an onion...
But seriously, make a user control with the basic shape and colour and then specialize from that.
|
|
|
|
|
I have, but now I want to duplicate it several times within the project, but using different names for each copy. I'm thinking I might be able to get away with building the project now, then adding "existing items" from the project folder and giving them new names. Will that work?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Sounds dreadful... maybe you're looking implants[^].
|
|
|
|
|
Your Implant idea is excellent, but I've already done what I added to the original post. Easy stuff, and no tedious retyping. Change the text in the labels, drag 'em around a bit, file off the serial numbers and, voila! A new control is born.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I have a treeview that I populate with data from various tables in mysql db. I also update the tables based on user actions. I was wondering, is it more efficient to use a mysqlDataAdapter for this or just CommandText and MySql Reader for populating and then separate CommandText statements for updating?
|
|
|
|
|
A reader done right is usually, almost always, faster than a data adapter, dataset solution. In the cases where timings show a data adapter executing faster there is usually a flaw in logic. Where the Data Adapter and data set solutions are usually faster is in Dev/Time not run time.
|
|
|
|
|
|
While I wasn't looking for an answer to that question, it will certainly come in handy for a project I'm working on - one of several. Thanks!
Is not a reader a one-way solution, though; that is, for reading from a database in one direction? And a data adapter is more of a random access solution? Such additional overhead would certainly explain the performance difference.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
A common misconception. ADO.NET is exclusively a fast-forward, read-only cursor. The data adapter uses a data reader behind the scenes to get the data. What the data adapter does is attempt to infer the schema from the available result sets and then read to the end of all cursors populating a data set. You then get your data in a handy data set with associated overhead.
AFAIK there is not an ADO.NET solution intended to maintain an open cursor to the DB at all.
|
|
|
|
|
with associated unnecessary overhead
|
|
|
|
|
Back to the books...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|