|
That's OK, I was only doing this for fun. I can just use OllyDbg to permanently modify the opcodes, or use cheat engine to temporally modify them...but I've figured it out, and yes it is useless to do it in c#...there are much easier ways.
|
|
|
|
|
By the way, you can access pointers directly using an unsafe context -- look into this if you still feel like doing it in C#.
As for accessing certain bytes directly, you can use a mask and do a bitwise-AND and then bit-shift to move it into position.
uint x = 9;
uint MASK = 0xFFFFFFF8;
uint result = (x & MASK) >> 3;
if (result == 1)
{
Console.WriteLine("4th bit is a 1!");
}
else
{
Console.WriteLine("4th bit is a 0!");
}
|
|
|
|
|
what you call a pointer is not a pointer to the majority of us.
I think most assembly languages would call your operation "offset indirect
addressing" or something of that nature. In text: take the given address, load
an address from where it points, add the offset to it, and consider that the
effective address of the operation at hand.
That is quite different from a pointer, which offers no more than one level
of indirection: take the pointer value and consider that the effective address of
the operation at hand. See for isntance here.[^], maybe not the most technical reference, but good
enough in this matter.
The pointers that exist in C, C++, C# and many other languages obey the definition
above. Whereas the former definition is implemented in most (but not all)
handles used by Windows (all with an offset of zero, hence just a double
indirection)
FYI if the offset is to be multiplied by the size of the operand (in bytes),
then it is called "indexed indirect addressing" instead of "offset indirect
addressing".
Hope this clarifies why you could not recognize all the correct answers
given to you.
|
|
|
|
|
Could you give me a link to something that could help me with reading/writing to pointers? Or whatever it is that I am exactly talking about. Thanks...
|
|
|
|
|
whatever clever addressing modes have been defined, you must implement them
yourself. The only basic operations are read direct (i.e. from a given address)
and write direct. All indirections, double indirections, offsets, indexing,
have to be programmed from that, step by step, unlike assembly code
where they exist as basic functionality to improve code density and execution time.
Of course there is nothing that stops you from putting complex addressing modes
in separate methods; example: IntPtr eaOffsetIndirect(IntPtr base, int ofs) could
use base, read an int thru it, add offset, and return that as an IntPtr, so
the caller can immediately operate on the intended operand.
Before you ask, yes you could write a native code function that performs any
complex addressing scheme your CPU provides, but calling it (which requires
P/Invoke to cross the managed/unmanaged boundary) is likely to cause more
overhead than executing it step-by-step in a higher-level language (such as C#).
|
|
|
|
|
The problem for me is that I can't use assembly for this application, I need to do some other things such as sending keystrokes, mouse commands, moving the mouse, checking global hotkeys, and I've already written 80% of the code...so I'd like to finish it in C#...it's not a very large application so I'm not worried about causing too much clutter, and I'm only reading two pointers. So I'd like some more info on it PLEASE KTHX!;)
|
|
|
|
|
Communicating with another process takes one of three routes:
- use an appropriate CLR class, when available; no warries here
- for simple things: use an existing Win32 function, call it with P/Invoke;
works fine as long as the function does not need pointers (so SetWindowText
is fine, SendMessage may be fine depending on the message code, i.e. do
wParam/lParam hold values or pointers ?)
- for complex things: allocate memory in the other process (this requires the
use of several Win32 functions such as VirtualAllocEx), transfer data
to/from your process address space from/to the other process' address space
(using ReadProcessMemory or WriteProcessMemory), and call the intended
Win32 function (all in appropriate order!). There are some examples of this
on CodeProject, at least one article describes a C++ class that facilitates
this; I wont repeat it all.
What you were talking about before (offset indirect addressing and the like) is
not applicable to the above; at most data is read/written somewhere, and a
pointer (a real one, not something fancy) to it gets passed back/forth.
|
|
|
|
|
Hi,
Can you tell me how to import a file in other file?
thanks.
|
|
|
|
|
What types of files? What do they contain? How do you want to 'merge' them? Are they text files and you want to append one to the other? Need more information.
|
|
|
|
|
Depends on the format of the file. Would you like to tell us more about these files?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Adding to what the others said, while it's true that, for example, merging two XML files is not as simple as appending one to the other, it's also true that it's not possible to append a file at all, no matter what, you need to read your two files, merge them in memory and write them back out, either overwriting one of your existing files, or to a new file.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'm allways surpriesed how there can be no reacton from the one who has a problem, after a response 9 minutes later.
But maybe it's because the question had no "urgent" in the subject line!
All the best,
Martin
|
|
|
|
|
Martin# wrote: I'm allways surpriesed how there can be no reacton from the one who has a problem, after a response 9 minutes later.
It just goes to show you that too many people haven't got even the most basic of manners. Possibly they found the answer but just don't have the common courtesy to respond back to say they've got a solution. Or they really don't understand their own problem and are embarrased that they can't articulate themselves.
Martin# wrote: But maybe it's because the question had no "urgent" in the subject line!
Just like this one[^]
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
using (StreamWriter sw = new StreamWriter(@"C:\file1.txt")
{
using (StreamReader sr = new StreamReader(@"c:\file1.txt")
{
sw.Write(sr.ReadToEnd);
}
}
Simple solution for text files...
Hogan
|
|
|
|
|
using (StreamReader sr = new StreamReader(@"c:\file2.txt")<br />
{<br />
File.AppendAllText(@"c:\file1.txt", sr.ReadToEnd());<br />
}
|
|
|
|
|
File.AppendAllText("file1.txt", File.ReadAllText("file2.txt"));
|
|
|
|
|
Nice; a real compact framework would offer
File.Append("file1.txt", "file2.txt");
|
|
|
|
|
Those lazy Microsoft bastards!!! Why haven't they thought of everything yet!?!?!
|
|
|
|
|
|
I have a SqlDataSource on my page that calls a stored procedure that returns the id of a particular record. I am trying to taked the returned id and store that into an integer or string that will be used as a query string for the next page of processing for this record. I'm not exactly sure how to return the value when running SqlDataSource.Select(DataSourceSelectArguments.Empty). Being that SqlDataSource.Select is an enumerator, I cannot return to int or string (even after doing datatype conversion). I'm not quite sure if I can do this, but guidance would definitely be a help. I have shown the code below. Thanks in advance to those below.
//album_id is the string or int to hold returned id from stored proc
albumid;
albumid = SqlDataSource2.Select(DataSourceSelectArguments.Empty);
|
|
|
|
|
I have no idea how to return value that is in js.
I have the website script suchvar zCHAR_ID=0, fCHAR_NAME=2, tCHAR_CLASS=3,
I want to know what they equal in my C# program.
Now my problems I'm having.
I have two webbrowser because they both have diffrent funtions.
one is axWebBrowser1 other is normal webBrowser
webBrowser1.Document.InvokeScript("todo");
how can I do that with axWebBrowser1 so i can delete the webbrowser form?
I know there are more problems but I can't bother without this fixed.
|
|
|
|
|
Can anyone tell me what is the difference between Interop and AxInterop ?
To generate an Interop I simply select it from regeistred COM or BROWSE in Add reference.
I cannot do it for ActiveX. Why ?
Laurent
|
|
|
|
|
I have a custom control with a custom property. After compiling the project I place my custom control onto a windows form in VS2005. From there I change my custom property on that custom control. The problem is that the custom control doesn't repaint on the designer to show my updated change. The following is the only way I have found to make the control repaint. Invalidate() after _Test = value; doesn't work. I also looked into the System.ComponentModel namespace for something to be placed before public int Test like [Browsable(true)] but didnt find anything. I tried [RefreshProperties(RefreshProperties.Repaint)] but I think that only repaints the properties grid and not the control on the designer. Any ideas???
private int _Test = 0;
public int Test
{
get { return _Test; }
set
{
_Test = value;
Width--;
Width++;
}
}
Chris
|
|
|
|
|
Chris,
After using Invalidate(); add the following code.
Application.DoEvents();
Once you invalidate the control, windows still has to go and re-paint it. By using the line above, you are telling it to do any events right now.
Hogan
|
|
|
|
|
Ya thanks a lot. It worked great.
Chris
|
|
|
|