• Welcome to Valhalla Legends Archive.
 

Console tab stops?

Started by brew, October 23, 2007, 06:50 AM

Previous topic - Next topic

brew

Quote from: iago on October 23, 2007, 03:07 PM
Plus, people might make silly mistakes like using "\n" instead of "\r\n" :P
I always use \n instead of \r\n :(

Hey, how would i get a handle to the thread of another process?
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

devcode

Quote from: brew on October 23, 2007, 03:51 PM
Quote from: iago on October 23, 2007, 03:07 PM
Plus, people might make silly mistakes like using "\n" instead of "\r\n" :P
I always use \n instead of \r\n :(

Hey, how would i get a handle to the thread of another process?
www.g00gles.com

brew

Quote from: devcode on October 23, 2007, 04:00 PM
Quote from: brew on October 23, 2007, 03:51 PM
Quote from: iago on October 23, 2007, 03:07 PM
Plus, people might make silly mistakes like using "\n" instead of "\r\n" :P
I always use \n instead of \r\n :(

Hey, how would i get a handle to the thread of another process?
www.g00gles.com
I lol'd.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Warrior

Quote from: iago on October 23, 2007, 03:07 PM
"\n" isn't a standard. Windows, for example, uses \r\n. Linux uses \n. iirc, Mac uses \r. So using println() guarantees, in a platform-independent way, that you'll get the proper newline character.

That may seem silly in C#, which is only typically run on Windows, but it's still a good habit. Plus, people might make silly mistakes like using "\n" instead of "\r\n" :P

I think \r just returns the text-cursor to the beginning of whatever row it's on. While \n actually advances it one row.

The good thing about C# is that due to it being a standard, you're able to make certain assumptions about it's implementation across multiple platforms. It's pretty much guaranteed to be the same, as with Java.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

Joe[x86]

Quote from: iago on October 23, 2007, 03:07 PM
"\n" isn't a standard. Windows, for example, uses \r\n. Linux uses \n. iirc, Mac uses \r. So using println() guarantees, in a platform-independent way, that you'll get the proper newline character.

That may seem silly in C#, which is only typically run on Windows, but it's still a good habit. Plus, people might make silly mistakes like using "\n" instead of "\r\n" :P

The proper way to do it in C# is Environment.NewLine, unless you're dealing with the console, in which Console.WriteLine() deals with it for you.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

MyndFyre

Quote from: Joex86] link=topic=17131.msg174176#msg174176 date=1193210404]
Quote from: iago on October 23, 2007, 03:07 PM
"\n" isn't a standard. Windows, for example, uses \r\n. Linux uses \n. iirc, Mac uses \r. So using println() guarantees, in a platform-independent way, that you'll get the proper newline character.

That may seem silly in C#, which is only typically run on Windows, but it's still a good habit. Plus, people might make silly mistakes like using "\n" instead of "\r\n" :P

The proper way to do it in C# is Environment.NewLine, unless you're dealing with the console, in which Console.WriteLine() deals with it for you.
Not necessarily.  Using Environment.NewLine, which is a string, could potentially require concatenation, which is not kosher (it can become expensive because strings are immutable).  When possible, using a TextWriter's WriteLine or StringBuilder's AppendLine is preferable.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

iago

Quote from: brew on October 23, 2007, 03:51 PM
Quote from: iago on October 23, 2007, 03:07 PM
Plus, people might make silly mistakes like using "\n" instead of "\r\n" :P
I always use \n instead of \r\n :(

Hey, how would i get a handle to the thread of another process?
The functions you need are something like:
FindWindow() to get a handle to the window
GetWindowThreadProcessId() to get the process id (I am doing the names from memory, so I could be wrong on that)
OpenProcess() to get a handle to the process

Somebody can correct me if I'm mistaken.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


brew

Quote from: iago on October 24, 2007, 10:34 AM
The functions you need are something like:
FindWindow() to get a handle to the window
GetWindowThreadProcessId() to get the process id (I am doing the names from memory, so I could be wrong on that)
OpenProcess() to get a handle to the process

Somebody can correct me if I'm mistaken.
IIRC, OpenProcess returns a handle to the process, not the thread. Perhaps you were thinking of OpenThread? (that requires a thread ID, and GetThreadID requires a thread handle, what i wanted in the first place) I've found a good way to do this-- calling CreateToolhelp32Snapshot with flags TH32CS_THREAD (I thought at first i was going to have to use a kernel mode api for this one) then call OpenThread. Thanks anyways.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

devcode

Quote from: brew on October 24, 2007, 10:51 AM
Quote from: iago on October 24, 2007, 10:34 AM
The functions you need are something like:
FindWindow() to get a handle to the window
GetWindowThreadProcessId() to get the process id (I am doing the names from memory, so I could be wrong on that)
OpenProcess() to get a handle to the process

Somebody can correct me if I'm mistaken.
IIRC, OpenProcess returns a handle to the process, not the thread. Perhaps you were thinking of OpenThread? (that requires a thread ID, and GetThreadID requires a thread handle, what i wanted in the first place) I've found a good way to do this-- calling CreateToolhelp32Snapshot with flags TH32CS_THREAD (I thought at first i was going to have to use a kernel mode api for this one) then call OpenThread. Thanks anyways.

guess g00gles musta worked out for you. lol @ kernel mode api, thats a good one

MyndFyre

Out of curiousity, why do you need a handle to an already existing thread?  When hacking a program most people create a thread within the process space.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

devcode

Quote from: MyndFyre[vL] on October 24, 2007, 11:19 AM
Out of curiousity, why do you need a handle to an already existing thread?  When hacking a program most people create a thread within the process space.

Creating a new thread in the remote process is one option but not the only one. You can get control of an existing thread using the GetThreadContext, SetThreadContext APIs and redirect execution. There are many ways to achieve the same thing..........................................

brew

Quote from: devcode on October 24, 2007, 11:14 AM
Quote from: brew on October 24, 2007, 10:51 AM
Quote from: iago on October 24, 2007, 10:34 AM
The functions you need are something like:
FindWindow() to get a handle to the window
GetWindowThreadProcessId() to get the process id (I am doing the names from memory, so I could be wrong on that)
OpenProcess() to get a handle to the process

Somebody can correct me if I'm mistaken.
IIRC, OpenProcess returns a handle to the process, not the thread. Perhaps you were thinking of OpenThread? (that requires a thread ID, and GetThreadID requires a thread handle, what i wanted in the first place) I've found a good way to do this-- calling CreateToolhelp32Snapshot with flags TH32CS_THREAD (I thought at first i was going to have to use a kernel mode api for this one) then call OpenThread. Thanks anyways.

guess g00gles musta worked out for you. lol @ kernel mode api, thats a good one
Yes, I was looking into ZwQuerySystemInformation or something like that, I think it returned a pointer to struct in a struct that had a pointer to a list of all the thread ids.
MyndFyre: To pause execution of other programs, ofcourse. I find all the threads associated with the PID, then call SuspendThread on all of them.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

MyndFyre

Isn't it easier to use the debugging APIs?

Note: I don't know the debugging APIs, so this is me speculating.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

iago

Quote from: brew on October 24, 2007, 10:51 AM
Quote from: iago on October 24, 2007, 10:34 AM
The functions you need are something like:
FindWindow() to get a handle to the window
GetWindowThreadProcessId() to get the process id (I am doing the names from memory, so I could be wrong on that)
OpenProcess() to get a handle to the process

Somebody can correct me if I'm mistaken.
IIRC, OpenProcess returns a handle to the process, not the thread. Perhaps you were thinking of OpenThread? (that requires a thread ID, and GetThreadID requires a thread handle, what i wanted in the first place) I've found a good way to do this-- calling CreateToolhelp32Snapshot with flags TH32CS_THREAD (I thought at first i was going to have to use a kernel mode api for this one) then call OpenThread. Thanks anyways.
Ah, the original question was worded funny, "Hey, how would i get a handle to the thread of another process?"

I assumed you wanted to get a handle to the process. What I think you wanted to ask was how to get a handle to a thread in another process.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


devcode

Quote from: iago on October 24, 2007, 08:42 PM
Quote from: brew on October 24, 2007, 10:51 AM
Quote from: iago on October 24, 2007, 10:34 AM
The functions you need are something like:
FindWindow() to get a handle to the window
GetWindowThreadProcessId() to get the process id (I am doing the names from memory, so I could be wrong on that)
OpenProcess() to get a handle to the process

Somebody can correct me if I'm mistaken.
IIRC, OpenProcess returns a handle to the process, not the thread. Perhaps you were thinking of OpenThread? (that requires a thread ID, and GetThreadID requires a thread handle, what i wanted in the first place) I've found a good way to do this-- calling CreateToolhelp32Snapshot with flags TH32CS_THREAD (I thought at first i was going to have to use a kernel mode api for this one) then call OpenThread. Thanks anyways.
Ah, the original question was worded funny, "Hey, how would i get a handle to the thread of another process?"

I assumed you wanted to get a handle to the process. What I think you wanted to ask was how to get a handle to a thread in another process.

Question was fine and worded properly, else he would have asked "How would i get a handle to another process". You made a mistake and you're justifying it by partly blaming for their wording so, no doesnt work like that unfortunately. Nice try though, better luck next time

|