Page 2 of 6 FirstFirst 1234 ... LastLast
Results 11 to 20 of 53

Thread: [C#] How to screenshot in MOHAA?

  1. #11
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    I may have found another way of doing it. Give me a bit to play around with it.

  2. #12
    Senior Member
    Join Date
    Feb 2012
    Location
    Egypt
    Posts
    174

    Default

    I first have to know how to use C++.. lol
    try dev c++ to create your own program if i am right ?

  3. #13
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Alright, I'm getting mad...

    I'm having compile errors due to unresolved external symbol and I don't know why....
    Code:
    // screenshot.cpp : Defines the entry point for the console application.
    //
    #include "stdafx.h"
    #include <windows.h>
    #include <iostream>
    #include <fstream>
    #include <GdiPlus.h>
    #include <stdio.h>
    #pragma comment( lib, "gdiplus" )
    
    
    // Direct3D Interfaces
    #include <d3d9.h>
    #pragma comment (lib,"d3d9.lib") 
    #include <d3dx9.h>
    #pragma comment (lib,"d3dx9.lib")
    
    
    using namespace std;
    using namespace Gdiplus;
    
    
    //Disable C4700 warning
    #pragma warning( disable : 4700 )
    
    
    //This is for debugging purposes
    ofstream outputFile;
    
    
    int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
    {
    	using namespace Gdiplus;
    	UINT  num = 0;          // number of image encoders
    	UINT  size = 0;         // size of the image encoder array in bytes
    
    
    	ImageCodecInfo* pImageCodecInfo = NULL;
    
    
    	GetImageEncodersSize(&num, &size);
    	if(size == 0)
    		return -1;  // Failure
    
    
    	pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
    	if(pImageCodecInfo == NULL)
    		return -1;  // Failure
    
    
    	GetImageEncoders(num, size, pImageCodecInfo);
    
    
    	for(UINT j = 0; j < num; ++j)
    	{
    		if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
    		{
    			*pClsid = pImageCodecInfo[j].Clsid;
    			free(pImageCodecInfo);
    			return j;  // Success
    		}    
    	}
    
    
    	free(pImageCodecInfo);
    	return 0;
    }
    
    
    void BMPtoPNG(const char* filenamebmp,const wchar_t* filenamepng)
    { 
        GdiplusStartupInput gdiplusStartupInput; 
        ULONG_PTR                    gdiplusToken; 
        GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); 
       
        HBITMAP hbm = (HBITMAP)LoadImage( NULL, filenamebmp, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); 
      
        if( hbm ) 
        { 
            Bitmap *pBitmap = Bitmap::FromHBITMAP( hbm, (HPALETTE)GetStockObject(DEFAULT_PALETTE) ); 
      
            if( pBitmap ) 
            { 
                CLSID clsidEncoder; 
      
                if( GetEncoderClsid(L"image/png", &clsidEncoder) ) 
                { 
      
                    pBitmap->Save(filenamepng, &clsidEncoder, NULL); 
                } 
      
                delete pBitmap; 
            } 
      
            DeleteObject(hbm); 
        } 
      
        Gdiplus::GdiplusShutdown(gdiplusToken);
    } 
    
    
    void takeSS()
    {
        CoInitialize(NULL);
    
    
        LPDIRECT3D9 d3d9;
        LPDIRECT3DDEVICE9 d3ddev;
        d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
    
    
        int ww = GetSystemMetrics(SM_CXSCREEN);
        int wh = GetSystemMetrics(SM_CYSCREEN);
    
    
        HWND hwnd = GetDesktopWindow();
        D3DPRESENT_PARAMETERS d3dpp;
        ZeroMemory(&d3dpp, sizeof(d3dpp));
        d3dpp.Windowed = TRUE;
        d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
        d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
        d3dpp.BackBufferCount = 1;
        d3dpp.BackBufferWidth = ww;
        d3dpp.BackBufferHeight = wh;
        d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
        d3dpp.MultiSampleQuality = 0;
        d3dpp.EnableAutoDepthStencil = TRUE;
        d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
        d3dpp.hDeviceWindow = hwnd;
        d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
        d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
        d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
    
    
        d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
    
    
        IDirect3DSurface9* render;
        IDirect3DSurface9* dest;
        d3ddev->CreateOffscreenPlainSurface(ww, wh, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &dest, NULL);
        d3ddev->GetFrontBufferData(0, dest);
    
    
        D3DLOCKED_RECT bits;
        dest->LockRect(&bits, NULL, D3DLOCK_READONLY);
    
    
    	D3DXSaveSurfaceToFile("Screenshot.bmp", D3DXIFF_BMP, dest, NULL, NULL);
    
    
        dest->UnlockRect();
    
    
        render->Release();
        dest->Release();
        d3ddev->Release();
        d3d9->Release();
    
    
        CoUninitialize();
    }
    
    
    bool isRunning() 
    { 
        //This checks if the process is already running so you don't have multiple instances running. 
        HANDLE handle = CreateMutex(NULL, true, "screenshot"); 
        if(GetLastError() != ERROR_SUCCESS) 
        { 
            MessageBox(0, "Process is already running", "Warning", MB_ICONWARNING); 
            return false; 
        } 
        else 
            return true; 
    } 
    
    
    int main()
    {	
    	//Don't show the console window
    	FreeConsole();
    
    
    	//Check if this process is running 
        if(isRunning() == false) 
            return 0; 
    
    
    	//Run this loop until we explicitly close the process
    	while(1)
    	{
    		Sleep(5000);
    
    
    		//Take a screenshot of our screen
    		takeSS();
    
    
    		//Convert BMP to PNG
    		BMPtoPNG("ScreenShot.bmp",L"ScreenShot.png");
    
    
    		//Delete BMP
    		DeleteFile("Screenshot.bmp");
    	}
    
    
    	return 0;
    }
    Error:
    Code:
    1>------ Build started: Project: screenshot, Configuration: Release Win32 ------
    1>Linking...
    1>screenshot.obj : error LNK2001: unresolved external symbol _Direct3DCreate9@4
    1>screenshot.obj : error LNK2001: unresolved external symbol _D3DXSaveSurfaceToFileA@20
    1>C:\Users\jkulikowski\Desktop\screenshot\Release\screenshot.exe : fatal error LNK1120: 2 unresolved externals
    1>Build log was saved at "file://c:\Users\jkulikowski\Desktop\screenshot\screenshot\Release\BuildLog.htm"
    1>screenshot - 3 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    I downloaded the latest DirectX SDK and installed it.

    I went to Project Properties
    C/C++ --> General --> Additional Include Directories "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include"

    Linker --> General --> Additional Library Directories "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64" and "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86"
    Linker --> additional Dependencies "d3d9.lib and d3dx9.lib"

    And all options Inherit from parent or project defaults.

    Any ideas??

  4. #14

    Default

    Quote Originally Posted by James View Post
    Alright, I'm getting mad...

    I'm having compile errors due to unresolved external symbol and I don't know why....
    Code:
    // screenshot.cpp : Defines the entry point for the console application.
    //
    #include "stdafx.h"
    #include <windows.h>
    #include <iostream>
    #include <fstream>
    #include <GdiPlus.h>
    #include <stdio.h>
    #pragma comment( lib, "gdiplus" )
    
    
    // Direct3D Interfaces
    #include <d3d9.h>
    #pragma comment (lib,"d3d9.lib") 
    #include <d3dx9.h>
    #pragma comment (lib,"d3dx9.lib")
    
    
    using namespace std;
    using namespace Gdiplus;
    
    
    //Disable C4700 warning
    #pragma warning( disable : 4700 )
    
    
    //This is for debugging purposes
    ofstream outputFile;
    
    
    int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
    {
    	using namespace Gdiplus;
    	UINT  num = 0;          // number of image encoders
    	UINT  size = 0;         // size of the image encoder array in bytes
    
    
    	ImageCodecInfo* pImageCodecInfo = NULL;
    
    
    	GetImageEncodersSize(&num, &size);
    	if(size == 0)
    		return -1;  // Failure
    
    
    	pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
    	if(pImageCodecInfo == NULL)
    		return -1;  // Failure
    
    
    	GetImageEncoders(num, size, pImageCodecInfo);
    
    
    	for(UINT j = 0; j < num; ++j)
    	{
    		if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
    		{
    			*pClsid = pImageCodecInfo[j].Clsid;
    			free(pImageCodecInfo);
    			return j;  // Success
    		}    
    	}
    
    
    	free(pImageCodecInfo);
    	return 0;
    }
    
    
    void BMPtoPNG(const char* filenamebmp,const wchar_t* filenamepng)
    { 
        GdiplusStartupInput gdiplusStartupInput; 
        ULONG_PTR                    gdiplusToken; 
        GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); 
       
        HBITMAP hbm = (HBITMAP)LoadImage( NULL, filenamebmp, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); 
      
        if( hbm ) 
        { 
            Bitmap *pBitmap = Bitmap::FromHBITMAP( hbm, (HPALETTE)GetStockObject(DEFAULT_PALETTE) ); 
      
            if( pBitmap ) 
            { 
                CLSID clsidEncoder; 
      
                if( GetEncoderClsid(L"image/png", &clsidEncoder) ) 
                { 
      
                    pBitmap->Save(filenamepng, &clsidEncoder, NULL); 
                } 
      
                delete pBitmap; 
            } 
      
            DeleteObject(hbm); 
        } 
      
        Gdiplus::GdiplusShutdown(gdiplusToken);
    } 
    
    
    void takeSS()
    {
        CoInitialize(NULL);
    
    
        LPDIRECT3D9 d3d9;
        LPDIRECT3DDEVICE9 d3ddev;
        d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
    
    
        int ww = GetSystemMetrics(SM_CXSCREEN);
        int wh = GetSystemMetrics(SM_CYSCREEN);
    
    
        HWND hwnd = GetDesktopWindow();
        D3DPRESENT_PARAMETERS d3dpp;
        ZeroMemory(&d3dpp, sizeof(d3dpp));
        d3dpp.Windowed = TRUE;
        d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
        d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
        d3dpp.BackBufferCount = 1;
        d3dpp.BackBufferWidth = ww;
        d3dpp.BackBufferHeight = wh;
        d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
        d3dpp.MultiSampleQuality = 0;
        d3dpp.EnableAutoDepthStencil = TRUE;
        d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
        d3dpp.hDeviceWindow = hwnd;
        d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
        d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
        d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
    
    
        d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
    
    
        IDirect3DSurface9* render;
        IDirect3DSurface9* dest;
        d3ddev->CreateOffscreenPlainSurface(ww, wh, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &dest, NULL);
        d3ddev->GetFrontBufferData(0, dest);
    
    
        D3DLOCKED_RECT bits;
        dest->LockRect(&bits, NULL, D3DLOCK_READONLY);
    
    
    	D3DXSaveSurfaceToFile("Screenshot.bmp", D3DXIFF_BMP, dest, NULL, NULL);
    
    
        dest->UnlockRect();
    
    
        render->Release();
        dest->Release();
        d3ddev->Release();
        d3d9->Release();
    
    
        CoUninitialize();
    }
    
    
    bool isRunning() 
    { 
        //This checks if the process is already running so you don't have multiple instances running. 
        HANDLE handle = CreateMutex(NULL, true, "screenshot"); 
        if(GetLastError() != ERROR_SUCCESS) 
        { 
            MessageBox(0, "Process is already running", "Warning", MB_ICONWARNING); 
            return false; 
        } 
        else 
            return true; 
    } 
    
    
    int main()
    {	
    	//Don't show the console window
    	FreeConsole();
    
    
    	//Check if this process is running 
        if(isRunning() == false) 
            return 0; 
    
    
    	//Run this loop until we explicitly close the process
    	while(1)
    	{
    		Sleep(5000);
    
    
    		//Take a screenshot of our screen
    		takeSS();
    
    
    		//Convert BMP to PNG
    		BMPtoPNG("ScreenShot.bmp",L"ScreenShot.png");
    
    
    		//Delete BMP
    		DeleteFile("Screenshot.bmp");
    	}
    
    
    	return 0;
    }
    Error:
    Code:
    1>------ Build started: Project: screenshot, Configuration: Release Win32 ------
    1>Linking...
    1>screenshot.obj : error LNK2001: unresolved external symbol _Direct3DCreate9@4
    1>screenshot.obj : error LNK2001: unresolved external symbol _D3DXSaveSurfaceToFileA@20
    1>C:\Users\jkulikowski\Desktop\screenshot\Release\screenshot.exe : fatal error LNK1120: 2 unresolved externals
    1>Build log was saved at "file://c:\Users\jkulikowski\Desktop\screenshot\screenshot\Release\BuildLog.htm"
    1>screenshot - 3 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    I downloaded the latest DirectX SDK and installed it.

    I went to Project Properties
    C/C++ --> General --> Additional Include Directories "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include"

    Linker --> General --> Additional Library Directories "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64" and "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86"
    Linker --> additional Dependencies "d3d9.lib and d3dx9.lib"

    And all options Inherit from parent or project defaults.

    Any ideas??
    Check you are including all the source files within your solution that you are referencing, If you are not including the source file (and thus the implementation) for the class Field in your project it won't be built and you will be unable to link during compilation.

  5. #15

    Default

    I have tried three different methods in C#. None worked. Whoever writes opengl and directx should have an easy to use capture screenshot function. wtf.

    It almost seems like you'd have to rely on hooking into the game using OGL... and somehow getting a screenshot. Don't know how to do it!
    Last edited by own3mall; September 16th, 2014 at 02:44 PM.
    Browse MOHAA Servers Post GameSpy Era

    VISIT MOHREBORN.COM FOR LATEST INFORMATION



    Medal of Honor: Game Server Browser Fixer - Patches your MOHAA, MOHSH, and MOHBT game binaries to allow you to retrieve a list of game servers within the multi-player menu in-game even after GameSpy ceases operation!

    Medal of Honor: Query Launcher - Find, browse, organize, join, get your ping, and get more information regarding all Medal of Honor (AA, SH, & BT) servers from your PC at any time!
    Medal of Honor: Web Server Master List - Find and browse all Medal of Honor servers online using your browser!
    Add your Medal of Honor Server to the Master List
    YouTube Video for Medal of Honor: Query Launcher and MOHAASERVERS.TK!



    MOHAA Mods and Utilities
    OwN-3m-All's Mods
    Make Me Stock - A program that allows you to easily move-in and move-out non-stock mods and other files at the click of a button. Automates adding / removing mods without having to copy / move files manually.



    Quality Game Servers

    Rent dedicated Dallas Texas, Kansas City, Las Vegas Nevada, Chicago, Pennsylvania, and Sofia Bulgaria MOHAA and other game servers from We Be HostiN starting at $10 a month.


  6. #16
    Banned
    Join Date
    May 2010
    Location
    fuck off?
    Posts
    1,145

    Default

    this may just produce a black screenshot, if it does, youre likely not to blame but it could work.,and always worth a shot.

  7. #17
    Client Beta Testers Appelpitje's Avatar
    Join Date
    Jan 2012
    Location
    Belgium
    Posts
    571

    Default

    James as you know c++, i think this would work: http://www.planet-source-code.com/vb...=7686&lngWId=3
    I just cant get itworking and i dont understand the language so im like i have no clue what im doing :P

  8. #18

    Default

    From MOHAAC Source:

    Code:
    public class ScreenCapture
        {
            public ScreenCapture()
            {
                eGuiSFMLAeSD46WskY.ViibXsAz0thGq();
                base();
            }
    
            public Image CaptureScreen()
            {
                return this.CaptureWindow(ScreenCapture.User32.GetDesktopWindow());
            }
    
            public void CaptureScreenToFile(string filename, ImageFormat format)
            {
                this.CaptureScreen().Save(filename, format);
            }
    
            public Image CaptureWindow(IntPtr handle)
            {
                IntPtr windowDC = ScreenCapture.User32.GetWindowDC(handle);
                ScreenCapture.User32.RECT rECT = new ScreenCapture.User32.RECT();
                ScreenCapture.User32.GetWindowRect(handle, ref rECT);
                int num = rECT.right - rECT.left;
                int num1 = rECT.bottom - rECT.top;
                IntPtr intPtr = ScreenCapture.GDI32.CreateCompatibleDC(windowDC);
                IntPtr intPtr1 = ScreenCapture.GDI32.CreateCompatibleBitmap(windowDC, num, num1);
                IntPtr intPtr2 = ScreenCapture.GDI32.SelectObject(intPtr, intPtr1);
                ScreenCapture.GDI32.BitBlt(intPtr, 0, 0, num, num1, windowDC, 0, 0, 13369376);
                ScreenCapture.GDI32.SelectObject(intPtr, intPtr2);
                ScreenCapture.GDI32.DeleteDC(intPtr);
                ScreenCapture.User32.ReleaseDC(handle, windowDC);
                Image image = Image.FromHbitmap(intPtr1);
                ScreenCapture.GDI32.DeleteObject(intPtr1);
                return image;
            }
    
            public void CaptureWindowToFile(IntPtr handle, string filename, ImageFormat format)
            {
                this.CaptureWindow(handle).Save(filename, format);
            }
    
            public void PrintScreen(string output)
            {
                Rectangle bounds = Screen.PrimaryScreen.Bounds;
                Bitmap bitmap = new Bitmap(bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                Graphics graphic = Graphics.FromImage(bitmap);
                graphic.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
                bitmap.Save(output, ImageFormat.Jpeg);
            }
    
            private class GDI32
            {
                public const int SRCCOPY = 13369376;
    
                public GDI32()
                {
                    eGuiSFMLAeSD46WskY.ViibXsAz0thGq();
                    base();
                }
    
                [DllImport("gdi32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hObjectSource, int nXSrc, int nYSrc, int dwRop);
    
                [DllImport("gdi32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, int nHeight);
    
                [DllImport("gdi32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
    
                [DllImport("gdi32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern bool DeleteDC(IntPtr hDC);
    
                [DllImport("gdi32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern bool DeleteObject(IntPtr hObject);
    
                [DllImport("gdi32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
            }
    
            private class User32
            {
                public User32()
                {
                    eGuiSFMLAeSD46WskY.ViibXsAz0thGq();
                    base();
                }
    
                [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern IntPtr GetDesktopWindow();
    
                [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern IntPtr GetWindowDC(IntPtr hWnd);
    
                [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern IntPtr GetWindowRect(IntPtr hWnd, ref ScreenCapture.User32.RECT rect);
    
                [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
                public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
    
                public struct RECT
                {
                    public readonly int left;
    
                    public readonly int top;
    
                    public readonly int right;
    
                    public readonly int bottom;
                }
            }
    Browse MOHAA Servers Post GameSpy Era

    VISIT MOHREBORN.COM FOR LATEST INFORMATION



    Medal of Honor: Game Server Browser Fixer - Patches your MOHAA, MOHSH, and MOHBT game binaries to allow you to retrieve a list of game servers within the multi-player menu in-game even after GameSpy ceases operation!

    Medal of Honor: Query Launcher - Find, browse, organize, join, get your ping, and get more information regarding all Medal of Honor (AA, SH, & BT) servers from your PC at any time!
    Medal of Honor: Web Server Master List - Find and browse all Medal of Honor servers online using your browser!
    Add your Medal of Honor Server to the Master List
    YouTube Video for Medal of Honor: Query Launcher and MOHAASERVERS.TK!



    MOHAA Mods and Utilities
    OwN-3m-All's Mods
    Make Me Stock - A program that allows you to easily move-in and move-out non-stock mods and other files at the click of a button. Automates adding / removing mods without having to copy / move files manually.



    Quality Game Servers

    Rent dedicated Dallas Texas, Kansas City, Las Vegas Nevada, Chicago, Pennsylvania, and Sofia Bulgaria MOHAA and other game servers from We Be HostiN starting at $10 a month.


  9. #19

    Default

    Well, actually, that code just produced black screenshots as well.

    So, I looked further at the source of MOHAAC, and I found this:

    Code:
    public void TakeRequestedScreenshot(bool isForced, string requestedString)
            {
                try
                {
                    if (this.Scans.IsSpecifiedMOHAARunning != null && this.Scans.IsInGame != null)
                    {
                        string str = Form1.GenerateRandomString(10);
                        string str1 = string.Concat(this.MOHAAPath, eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31164), str, eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31204));
                        if (this.Scans.IsSpecifiedMOHAARunning != null)
                        {
                            TakeScreenshotMOHAA takeScreenshotMOHAA = new TakeScreenshotMOHAA();
                            takeScreenshotMOHAA.PostToMohaaConsole(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31216), str, this.Scans.ConsoleWindowHandle);
                        }
                        while (!File.Exists(str1))
                        {
                            Thread.Sleep(1000);
                        }
                        if (File.Exists(str1))
                        {
                            string mD5HashFromFile = this.GetMD5HashFromFile(str1);
                            Bitmap image = (new TargaImage(str1)).Image;
                            int num = str1.IndexOf(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31240), StringComparison.Ordinal);
                            if (!num.Equals(-1))
                            {
                                string str2 = string.Concat(str1.Remove(num), eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31252));
                                Graphics graphic = Graphics.FromImage(image);
                                graphic.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
                                StringBuilder stringBuilder = new StringBuilder();
                                stringBuilder.AppendLine(string.Concat(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31262), this.MOHAAPlayerName));
                                stringBuilder.AppendLine(string.Concat(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31282), this.MOHAACInfo.MACID));
                                stringBuilder.AppendLine(string.Concat(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31306), this.MatchID.Text));
                                stringBuilder.AppendLine(string.Concat(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31328), this.Scans.SessionID));
                                stringBuilder.AppendLine(string.Concat(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31342), mD5HashFromFile));
                                string str3 = eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31358);
                                DateTime now = DateTime.Now;
                                stringBuilder.AppendLine(string.Concat(str3, now.ToString(CultureInfo.InvariantCulture)));
                                stringBuilder.AppendLine(string.Concat(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31374), this.Scans.MOHAAIP));
                                Graphics graphic1 = Graphics.FromImage(image);
                                Font font = new Font(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31394), 10f, FontStyle.Regular);
                                SizeF sizeF = graphic1.MeasureString(stringBuilder.ToString(), font);
                                float width = sizeF.Width;
                                SizeF sizeF1 = graphic1.MeasureString(stringBuilder.ToString(), font);
                                float height = sizeF1.Height;
                                graphic.DrawRectangle(new Pen(new SolidBrush(Color.Black), 1f), (float)(image.Width / 10), (float)(image.Height / 10), width, height);
                                graphic.FillRectangle(new SolidBrush(Color.FromArgb(200, 0, 0, 0)), (float)(image.Width / 10), (float)(image.Height / 10), width, height);
                                graphic.DrawString(stringBuilder.ToString(), font, new SolidBrush(Color.Lime), (float)(image.Width / 10), (float)(image.Height / 10));
                                image.Save(str2, ImageFormat.Jpeg);
                                if (isForced)
                                {
                                    this.GlobalConsoleControl.PostToMohaaConsole(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31442), eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31468), IntPtr.Zero);
                                    this.SendRequestedScreen(str2, requestedString);
                                }
                                if (File.Exists(str2))
                                {
                                    string mD5HashFromFile1 = this.GetMD5HashFromFile(str2);
                                    if (!Directory.Exists(this.MOHAACInfo.ScreenFolderPath))
                                    {
                                        Directory.CreateDirectory(this.MOHAACInfo.ScreenFolderPath);
                                    }
                                    this.AuthenticScreens.Add(mD5HashFromFile1.ToLower());
                                    ScreenAuthList.AddScreenToList(string.Concat(this.MOHAACInfo.ScreenFolderPath, eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31608), str, eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31614)), mD5HashFromFile1.ToLower(), this.Scans.EncUniqueID);
                                    ENDEcrypt eNDEcrypt = new ENDEcrypt();
                                    string str4 = string.Concat(this.GetMD5HashFromString(this.MatchID.Text).ToUpper(), this.GetMD5HashFromString(this.Scans.SessionID).ToUpper());
                                    byte[] numArray = eNDEcrypt.RC4(str2, string.Concat(str4, eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31628), this.Scans.EncUniqueID));
                                    this.ByteArrayToFile(string.Concat(this.MOHAACInfo.ScreenFolderPath, eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31634), str, eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31640)), numArray);
                                    this.Scans.NumberOfScreenshots = this.Scans.NumberOfScreenshots + 1;
                                }
                                this.Scans.TickCountAtLastSS = Environment.TickCount;
                            }
                        }
                    }
                }
                catch
                {
                    Log.AddLine(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(31672));
                }
            }
    The main class behind taking a screenshot:

    Code:
    using e1RlCAZENhFg7ngPa8;
    using esmiSECghiXXOHjvrI;
    using System;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Text;
    
    namespace MOHAAC
    {
        internal class TakeScreenshotMOHAA
        {
            public const uint WM_SETTEXT = 12;
    
            public const uint WM_CHAR = 258;
    
            private const int WM_GETTEXT = 13;
    
            private const int WM_GETTEXTLENGTH = 14;
    
            public TakeScreenshotMOHAA()
            {
                eGuiSFMLAeSD46WskY.ViibXsAz0thGq();
                base();
            }
    
            private int EnumChildWindowProc(IntPtr hwnd, StringBuilder lParam)
            {
                StringBuilder stringBuilder = new StringBuilder(64);
                TakeScreenshotMOHAA.GetClassName(hwnd, stringBuilder, stringBuilder.Capacity);
                StringBuilder stringBuilder1 = new StringBuilder(255);
                TakeScreenshotMOHAA.GetWindowText(hwnd, stringBuilder1, stringBuilder1.Capacity);
                if (stringBuilder.ToString().Equals(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(285244)) && this.GetSizeOfWindow(hwnd) == 0)
                {
                    TakeScreenshotMOHAA.SendMessage(hwnd, 12, IntPtr.Zero, lParam.ToString());
                    TakeScreenshotMOHAA.SendMessage(hwnd, 258, 13, 0);
                }
                return 1;
            }
    
            [DllImport("User32", CharSet=CharSet.Ansi, ExactSpelling=true, SetLastError=true)]
            private static extern int EnumChildWindows(IntPtr hWndParent, TakeScreenshotMOHAA.EnumCallBackDelegate lpEnumFunc, StringBuilder lParam);
    
            [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false, SetLastError=true)]
            private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
            [DllImport("User32", CharSet=CharSet.Ansi, EntryPoint="GetClassNameA", ExactSpelling=true, SetLastError=true)]
            private static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
    
            public string GetConsoleText(IntPtr hWnd)
            {
                int num = Convert.ToInt32(TakeScreenshotMOHAA.SendMessage(hWnd, 14, 0, 0));
                if (num <= 0)
                {
                    return string.Empty;
                }
                StringBuilder stringBuilder = new StringBuilder(num + 1);
                SendMessage2 sendMessage2 = new SendMessage2();
                sendMessage2.SendMessageToConsole(hWnd, 13, (IntPtr)stringBuilder.Capacity, stringBuilder);
                return stringBuilder.ToString();
            }
    
            public int GetSizeOfWindow(IntPtr hWnd)
            {
                return TakeScreenshotMOHAA.SendMessage(hWnd, 14, 0, 0);
            }
    
            [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
            private static extern int GetWindowText(IntPtr hWnd, StringBuilder title, int size);
    
            [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
            public static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, out int ProcessId);
    
            public bool isCorrectClass(IntPtr hWnd)
            {
                int num = Convert.ToInt32(TakeScreenshotMOHAA.SendMessage(hWnd, 14, 0, 0));
                return num > 0;
            }
    
            public bool IsScreenshotBlank(string ss)
            {
                if (!File.Exists(ss))
                {
                    return false;
                }
                byte[] byteArray = MOHAACFunctions.FileToByteArray(ss);
                double length = (double)((int)byteArray.Length);
                double num = 0;
                byte[] numArray = byteArray;
                for (int i = 0; i < (int)numArray.Length; i++)
                {
                    if (numArray[i] == 0)
                    {
                        num = num + 1;
                    }
                }
                return num / length * 100 > 90;
            }
    
            [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
            private static extern bool IsWindow(IntPtr hWnd);
    
            public void PostToMohaaConsole(string cmd, string name, IntPtr Handle)
            {
                IntPtr intPtr = TakeScreenshotMOHAA.FindWindow(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(285166), null);
                if (TakeScreenshotMOHAA.IsWindow(intPtr) && intPtr != IntPtr.Zero)
                {
                    TakeScreenshotMOHAA.EnumChildWindows(intPtr, new TakeScreenshotMOHAA.EnumCallBackDelegate(this.EnumChildWindowProc), new StringBuilder(string.Concat(cmd, eNQ3Jf6G6vENo1KFlF.eacsfnmlb(285202), name)));
                }
            }
    
            public void PostToMohaaConsole2(string cmd)
            {
                IntPtr intPtr = TakeScreenshotMOHAA.FindWindow(eNQ3Jf6G6vENo1KFlF.eacsfnmlb(285208), null);
                if (TakeScreenshotMOHAA.IsWindow(intPtr) && intPtr != IntPtr.Zero)
                {
                    TakeScreenshotMOHAA.EnumChildWindows(intPtr, new TakeScreenshotMOHAA.EnumCallBackDelegate(this.EnumChildWindowProc), new StringBuilder(cmd));
                }
            }
    
            [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=false)]
            private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
    
            [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=false)]
            private static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
    
            [DllImport("shell32.dll", CharSet=CharSet.None, EntryPoint="ShellExecuteA", ExactSpelling=false)]
            public static extern int ShellExecute(int hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
    
            private delegate int EnumCallBackDelegate(IntPtr hWnd, StringBuilder lParam);
    
            public delegate bool EnumWindowsProc(int hWnd, int lParam);
        }
    }
    It appears that MOHAAC injects code into MOHAA itself. It sends the screenshot command and waits to grab the game's outputted screenshot. Seems rather silly. I think people have bypassed the in-game screenshot command before. It then takes the screenshot image and writes the player's information onto the image. That's how it works folks. There's no easy way to take screenshots of ANY game.

    Essentially, you could write a server-side script that randomly screenshots players using stufftext, and then the client could just eat it all up and process it. That's essentially what MOHAAC does, except for the fact that he's hooked into the game to keep it all in a client package.

    In any event, MOHAAC has some scary source code in it as well. This is not your average Joe program. He must have had substantial outside help or is one of those stereotypical programmers.
    Last edited by own3mall; September 16th, 2014 at 06:26 PM.
    Browse MOHAA Servers Post GameSpy Era

    VISIT MOHREBORN.COM FOR LATEST INFORMATION



    Medal of Honor: Game Server Browser Fixer - Patches your MOHAA, MOHSH, and MOHBT game binaries to allow you to retrieve a list of game servers within the multi-player menu in-game even after GameSpy ceases operation!

    Medal of Honor: Query Launcher - Find, browse, organize, join, get your ping, and get more information regarding all Medal of Honor (AA, SH, & BT) servers from your PC at any time!
    Medal of Honor: Web Server Master List - Find and browse all Medal of Honor servers online using your browser!
    Add your Medal of Honor Server to the Master List
    YouTube Video for Medal of Honor: Query Launcher and MOHAASERVERS.TK!



    MOHAA Mods and Utilities
    OwN-3m-All's Mods
    Make Me Stock - A program that allows you to easily move-in and move-out non-stock mods and other files at the click of a button. Automates adding / removing mods without having to copy / move files manually.



    Quality Game Servers

    Rent dedicated Dallas Texas, Kansas City, Las Vegas Nevada, Chicago, Pennsylvania, and Sofia Bulgaria MOHAA and other game servers from We Be HostiN starting at $10 a month.


  10. #20
    Banned
    Join Date
    May 2010
    Location
    fuck off?
    Posts
    1,145

    Default

    so next option btw is a mirror driver (fun fun) or intercept a set of methods from Direct3D interfaces

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •