View previous topic :: View next topic |
Author |
Message |
denismu321 Newbie cheater Reputation: 0
Joined: 24 Dec 2018 Posts: 20
|
Posted: Wed Jun 02, 2021 1:38 pm Post subject: Need some guidance with this code |
|
|
Hi there , I could need some guidance with this code of mine.
I am injecting a dll into a process and allocate a console.
Now I want to print some specifics of the target process.
Here is the code :
Code: |
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
TCHAR buff[256];
int length = ::GetWindowTextLengthA(hwnd);
::GetWindowTextA(hwnd, (LPSTR)buff, length);
int nCtrlID = ::GetDlgCtrlID(hwnd);
printf("ID is %d\n", nCtrlID);
return TRUE;
}
void OnEnumerateChildCtrls(HWND window)
{
EnumChildWindows(window, EnumWindowsProc, 0);
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
GetStdHandle(STD_OUTPUT_HANDLE);
AllocConsole();
fprintf(stdout, "Test!");
fflush(stdout);
HWND hwnd = (HWND)0x00B407E2;
const char* szBuf;
LRESULT res;
char buff[255];
WNDENUMPROC wndenum;
int returnPointer{};
SendMessageTimeoutA(hwnd, WM_GETTEXT, NULL, NULL, SMTO_NORMAL, 10000, (PDWORD_PTR)returnPointer);
int length = GetWindowTextLengthA(hwnd);
GetWindowTextA(hwnd, (LPSTR)buff, length);
printf("Copied %d characters. Contents: %s\n", length, buff);
//printf("buffer contains %s\n", buff);*/
OnEnumerateChildCtrls(hwnd);
break;
}
return TRUE;
}
|
All it gives me is a black console with this caption, "Valve.Steam.Client"
Perhaps there is some advice ?
Thank you in advance .
|
|
Back to top |
|
|
atom0s Moderator Reputation: 199
Joined: 25 Jan 2006 Posts: 8519 Location: 127.0.0.1
|
Posted: Wed Jun 02, 2021 9:04 pm Post subject: |
|
|
You need to reroute the standard input handles to the console. The process may have altered them to a different output or are swallowing them in general. You may also need to call AttachConsole afterward to attach it to the process properly depending on any counter-measures or alterations they may be doing.
The stream related things you need to reroute would be:
"CONIN$" (read) -> stdin - Used for input from the user into the console.
"CONOUT$" (write) -> stderr - Used for error related output.
"CONOUT$" (write) -> stdout - Used for standard output.
There are multiple ways to redirect/set these such as using freopen/freopen_s or the direct 'std' stream objects.
_________________
- Retired. |
|
Back to top |
|
|
denismu321 Newbie cheater Reputation: 0
Joined: 24 Dec 2018 Posts: 20
|
Posted: Thu Jun 03, 2021 6:49 am Post subject: Thanks for replying so fast |
|
|
Hi ,thank you for reaching out to me so fast.
Could you provide some little code to help grasp
the concept ?
I'd be rather thankful for that.
|
|
Back to top |
|
|
denismu321 Newbie cheater Reputation: 0
Joined: 24 Dec 2018 Posts: 20
|
Posted: Fri Jun 04, 2021 4:12 pm Post subject: Hi again |
|
|
I found out what function you meant atom0s.
It was freopen("CONOUT$","w",stdout);
Now I have another problem.
Do you know of a simple way to hook WS32_send functions.
The DLL Injector I wrote works (most of the time).
But I cannot hook WS32_send ,and I am doing this with detours
library on Visual Studio c++.
Any guidance would be appreciated.
|
|
Back to top |
|
|
atom0s Moderator Reputation: 199
Joined: 25 Jan 2006 Posts: 8519 Location: 127.0.0.1
|
Posted: Tue Jun 08, 2021 2:52 pm Post subject: |
|
|
At this point it's pretty clear you're just piecing stuff you find around the web together. I'm not going to hand you code that you aren't going to understand, there's no point.
I'd suggest you take the time to learn what you are doing. There are thousands of libraries, tutorials, etc. on hooking things with C++, and so many different copy-paste examples of hooking the exact thing you are requesting.
_________________
- Retired. |
|
Back to top |
|
|
denismu321 Newbie cheater Reputation: 0
Joined: 24 Dec 2018 Posts: 20
|
Posted: Tue Jun 08, 2021 11:39 pm Post subject: Hi |
|
|
Sorry ,I did not request anything.
Even if it may have seemed so.
I just asked for some advice.
I am going to try my luck on my own, like you suggested.
Thanks for replying.
Kind regards,
Denis.
|
|
Back to top |
|
|
HotHeap !BEWARE! Deletes post on answer Reputation: 2
Joined: 06 Oct 2018 Posts: 4
|
|
Back to top |
|
|
|