Code to run in windowed mode ( 2008 )

Results 1 to 9 of 9
  1. #1
    Enthusiast espanish is offline
    MemberRank
    Aug 2010 Join Date
    36Posts

    Code to run in windowed mode ( 2008 )

    First you will need to put this functions in you Src :

    Code:
    long __stdcall MSetWindowLongA( HWND hWnd, int nIndex, DWORD dwNewLong )
    {
    	if( ( nIndex == GWL_STYLE ) ){
    
    		char szClassName[12];
    		GetClassNameA( hWnd, szClassName, 11 );
    		
    		if( !strcmp( "RealSpace2", szClassName ) ){
    			dwNewLong = 2161049600;
    			
    			*(PBYTE)( (DWORD)( *(PDWORD)((DWORD)&dwNewLong + 4) ) + 8 ) = 0;				
    		}
    	}
    
    	return SetWindowLongA( hWnd, nIndex, (long)dwNewLong );
    }
    
    void MIATHook( DWORD dwIATAddress, DWORD dwFunction )
    {
    	DWORD dwOld;
    
    	VirtualProtect( (LPVOID)dwIATAddress, 4, PAGE_EXECUTE_READWRITE, &dwOld );
    
    	*(DWORD*)dwIATAddress = (DWORD)dwFunction;
    	VirtualProtect( (LPVOID)dwIATAddress, 4, dwOld, &dwOld );
    }
    Soo, in you main thread, when the hooks are applied you do this :

    Code:
    if( MessageBoxA( NULL, "Run in windowed mode ?", "You GunZ", MB_YESNO ) == IDYES ){
    	MIATHook( (DWORD)0x62245C, (DWORD)MSetWindowLongA );
    }
    Compile and run, when you start the game will show a MsgBox asking if you want to start in windowed mode.


    Credits :

    Me.


  2. #2
    Member Hideasu is offline
    MemberRank
    Aug 2011 Join Date
    CanadaLocation
    78Posts

    Re: Code to run in windowed mode ( 2008 )

    Usefull, usefull, keep posting some great release like that, they are soo rare these day...

  3. #3
    Enthusiast eduardo03 is offline
    MemberRank
    Feb 2011 Join Date
    36Posts

    Re: Code to run in windowed mode ( 2008 )

    NICE =]
    Thanks man, this is very most useful!

  4. #4
    Ran Dev allen003 is offline
    MemberRank
    Sep 2009 Join Date
    PhilippineLocation
    663Posts

    Re: Code to run in windowed mode ( 2008 )

    can you also include the fps in the upper corner pls that would be awesome who dev map.

  5. #5
    Proficient Member Mr_Troy is offline
    MemberRank
    Jun 2007 Join Date
    172Posts

    Re: Code to run in windowed mode ( 2008 )

    Quote Originally Posted by allen003 View Post
    can you also include the fps in the upper corner pls that would be awesome who dev map.
    That would require either a hook on Gunz' rendering functions or a DirectX hook.

    Gunz d3d device pointer for 07 = 0x68BC2C

  6. #6
    Good Guy George qet123 is offline
    MemberRank
    Apr 2009 Join Date
    DesertLocation
    1,432Posts

    Re: Code to run in windowed mode ( 2008 )

    Very usefull
    Last edited by qet123; 27-11-11 at 01:28 PM.

  7. #7
    I am THE DON Joe9099 is offline
    MemberRank
    Jan 2007 Join Date
    England, UkLocation
    3,655Posts

    Re: Code to run in windowed mode ( 2008 )

    Quote Originally Posted by allen003 View Post
    can you also include the fps in the upper corner pls that would be awesome who dev map.
    Whats the point, get fraps, run it same time as GunZ running obviously, then it will show ur fps in game in the corners... like over 1000 or some ridiculous FPS lol xD

  8. #8
    Retired. Don't PM. SecretsOThePast is offline
    DeveloperRank
    Jan 2009 Join Date
    643Posts

    Re: Code to run in windowed mode ( 2008 )

    There's also another way to do windowed mode, requires hooking this function (in 08, it's in 07 too in the same spot)

    0x00497C60

    This is actually "void SetModeParams()". 0x00686D18 is set to 1 no matter what. If it is set to 0, GunZ is restarted in windowed mode on each device reset. You'll need to hook the function and set this stuff, which is easy:
    Code:
    LODWORD(dword_686D10) = *(_DWORD *)(GetVideo() + 8);
      LODWORD(dword_686D14) = *(_DWORD *)(GetVideo() + 12);
      result = GetVideo();
      dword_686D1C = (*(_DWORD *)(result + 16) != 32) + 22;
    which roughly translates to,
    Code:
    nWidth = ZGetConfiguration()->nWidth;
    nHeight = ZGetConfiguration()->nHeight;
    ZGetConfiguration()->nColorBits == 32 ? 
    		PixelFormat = 22 : PixelFormat = 23;
    Using this method you could probably change the configuration options to support the windowed mode byte, which is also in GetVideo(), being the first 4 bytes of the struct.

    Quote Originally Posted by Mr_Troy View Post
    That would require either a hook on Gunz' rendering functions or a DirectX hook.

    Gunz d3d device pointer for 07 = 0x68BC2C
    Re-add me on MSN, I accidentally declined your request about 5 days ago. You should know who I am :p

  9. #9
    Proficient Member Mr_Troy is offline
    MemberRank
    Jun 2007 Join Date
    172Posts

    Re: Code to run in windowed mode ( 2008 )

    You can also just change this BYTE to 0 : 0x4954A6 (07) at Gunz startup.



Advertisement