+ Reply to Thread
Results 1 to 10 of 10

Thread: calling all coders!!!!!!!     submit to reddit submit to twitter

  1. #1
    Puppetmaster
    Join Date
    Mar 2006
    Posts
    72
    BG Level
    2

    calling all coders!!!!!!!

    need some people who know alot about MMF and the WinAPI who can help fix the old x64 windower launcher!!!!

    Issues:
    1. xres and yres is not sticking in memory, instead game resolution is being pulled from ffxi config
    2. console key can only be single char, not F12 etcetc



    Code:
    int _tmain(int argc, _TCHAR* argv[])
    {
    	printf("x64 compatible launcher v3.23\n");
    	printf("\n");
    
    	STARTUPINFO startupinfo = { sizeof(STARTUPINFO) };
    	PROCESS_INFORMATION processinformation = {0};
    
    	TCHAR exedir[MAX_PATH];
    	TCHAR HookPath[MAX_PATH];
    	TCHAR GamePath[MAX_PATH];
    	TCHAR WindowerPath[MAX_PATH];
    
    	// No idea what this is
    	LPTSTR args = _T(" /game eAZcFcB");
    
    	if(GetFileAttributes(_T("hook.dll"))==0xFFFFFFFF)
    	{
    		printf("Launcher must be run from the windower directory.");
    		getchar();
    		return 0;
    	}
    
    	int real_xres = GetSystemMetrics(SM_CXSCREEN);
    	int real_yres = GetSystemMetrics(SM_CYSCREEN);
    
    	TCHAR lang[3],conkey[2];
    	int xres,yres,truefull,trueresize,debug,fullscreen;
    	int region;
    
    	GetPrivateProfileString(_T("Windower Settings"),_T("Language"),_T("EU"),lang,sizeof(lang),_T(".\\Windower.ini"));
    	GetPrivateProfileString(_T("Windower Settings"),_T("Console Key"),_T("`"),conkey,sizeof(conkey),_T(".\\Windower.ini"));
    	xres=GetPrivateProfileInt(_T("Windower Settings"),_T("X Resolution"),real_xres,_T(".\\Windower.ini"));
    	yres=GetPrivateProfileInt(_T("Windower Settings"),_T("Y Resolution"),real_yres,_T(".\\Windower.ini"));
    	truefull=GetPrivateProfileInt(_T("Windower Settings"),_T("True Fullscreen"),0,_T(".\\Windower.ini"));
    	trueresize=GetPrivateProfileInt(_T("Windower Settings"),_T("True Resizing"),0,_T(".\\Windower.ini"));
    	debug=GetPrivateProfileInt(_T("Windower Settings"),_T("Debug"),0,_T(".\\Windower.ini"));
    
    	if(xres>real_xres) xres=real_xres;
    	if(yres>real_yres) yres=real_yres;
    	if(xres!=real_xres || yres!=real_yres)
    		fullscreen = 0;
    	else
    		fullscreen = 1;
    
    	HKEY hKey = NULL;
    	if(!_tcscmp(lang,_T("NA")) || !_tcscmp(lang,_T("US")))
    	{
    		RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\PlayOnlineUS\\InstallFolder"),0,KEY_READ,&hKey);
    		region = 1;
    	}
    	else if(!_tcscmp(lang,_T("JP")))
    	{
    		RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\PlayOnline\\InstallFolder"),0,KEY_READ,&hKey);
    		region = 0;
    	}
    	else if(!_tcscmp(lang,_T("EU")))
    	{
    		RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\PlayOnlineEU\\InstallFolder"),0,KEY_READ,&hKey);
    		region = 2;
    	}
    
    	if(!hKey)
    	{
    		printf("Couldn't open PlayOnline registry key.  Check windower.ini");
    		getchar();
    		return 0;
    	}
    
    	DWORD dwLen=sizeof(exedir);
    	if(RegQueryValueEx(hKey,_T("1000"),NULL,NULL,(LPBYTE)exedir,&dwLen))
    	{
    		printf("Couldn't read PlayOnline registry key.  Check windower.ini");
    		getchar();
    		return 0;
    	}
    
    	CloseHandle(hKey);
    
    	GetCurrentDirectory(sizeof(WindowerPath),WindowerPath);
    	
    	_tcscpy(GamePath,exedir);
    	_tcscat(GamePath,_T("\\pol.exe"));
    
    	_tcscpy(HookPath,WindowerPath);
    	_tcscat(HookPath,_T("\\hook.dll"));
    
    	HANDLE hMap = CreateFileMapping(INVALID_HANDLE_VALUE,0,PAGE_READWRITE,0,0x8034,_T("WindowerMMFSettingsHandler"));
    	LPBYTE pMap = (LPBYTE)MapViewOfFile(hMap,FILE_MAP_WRITE,0,0,0);
    
    	_tcscpy((LPWSTR)pMap,exedir);
    	_tcscpy((LPWSTR)(pMap+0x4000),WindowerPath);
    
    	struct _data
    	{
    		DWORD region;
    		DWORD x;
    		DWORD y;
    		BYTE true_resizing,true_fullscreen,fullscreen,unk4;
    		WORD console,unk5;
    		BYTE unk[32];
    	};
    	_data* pParms = (_data*)(pMap+0x8000);
    
    	pParms->region=region;
    	pParms->x=xres;
    	pParms->y=yres;
    	pParms->true_resizing=trueresize;
    	pParms->true_fullscreen=truefull;
    	pParms->fullscreen=fullscreen;
    	pParms->unk4=0;
    	pParms->console=conkey[0];
    
    	printf("Loading game........");
    	BOOL result = CreateProcess(GamePath,
    		args,
    		NULL,
    		NULL,
    		FALSE,
    		CREATE_SUSPENDED|NORMAL_PRIORITY_CLASS,
    		NULL,
    		exedir,
    		&startupinfo,
    		&processinformation
    		);
    
    	if(!result)
    	{
    		printf("Game load failed - error %08x\n",GetLastError());
    		getchar();
    	}
    	printf("Done... Hooking...\n");
    
    	HANDLE hLibModule;
    	LPVOID pLibRemote = VirtualAllocEx(processinformation.hProcess,NULL,sizeof(HookPath),MEM_COMMIT,PAGE_READWRITE);
    	WriteProcessMemory(processinformation.hProcess,pLibRemote,HookPath,sizeof(HookPath),NULL);
    	HANDLE hThread = CreateRemoteThread(processinformation.hProcess,NULL,0,(LPTHREAD_START_ROUTINE)::GetProcAddress(GetModuleHandle(_T("Kernel32")),"LoadLibraryW"), pLibRemote, 0, NULL);
    	WaitForSingleObject(hThread,INFINITE);
    	GetExitCodeThread(hThread,(LPDWORD)&hLibModule);
    	CloseHandle(hThread);
    	VirtualFreeEx(processinformation.hProcess,pLibRemote,sizeof(HookPath),MEM_RELEASE);
    
    	if(!hLibModule)
    	{
    		printf("Load of hook.dll failed.. continuing anyway without windower.\n");
    	}
    
    	printf("Done.. Running game..\n");
    
    	ResumeThread(processinformation.hThread);
    
    	printf("Closing handles.......");
    	CloseHandle(processinformation.hProcess);
    	CloseHandle(processinformation.hThread);
    	printf("Done!  Thanks for travelling with us\n");
    	return 0;
    }

  2. #2

  3. #3

    the funny thing is, is thats kuai irl

  4. #4

    i have a little shorter hair tho

  5. #5

    Quote Originally Posted by Kuai
    i have a little shorter hair tho
    On your back?

    EDIT: THAT GUYS ASS STARTS AT HIS SHOULDER BLADES!!!!!!!!!!!!!

  6. #6
    Groovebox
    Guest

    EDIT: THAT GUYS ASS STARTS AT HIS SHOULDER BLADES!!!!!!!!!!!!!
    This comment made me ROFL for like 10 minutes XD XD XD

  7. #7
    Puppetmaster
    Join Date
    Apr 2005
    Posts
    53
    BG Level
    2

    Quote Originally Posted by Tape
    Quote Originally Posted by Kuai
    i have a little shorter hair tho
    On your back?

    EDIT: THAT GUYS ASS STARTS AT HIS SHOULDER BLADES!!!!!!!!!!!!!
    I had to look back at the picture real quick to confirm this, and then I saw it was true. Needless to say... ROFL!

  8. #8
    E. Body
    Join Date
    Jun 2006
    Posts
    2,182
    BG Level
    7
    FFXIV Character
    Bro Teampill
    FFXIV Server
    Gilgamesh
    FFXI Server
    Ifrit

    On a serious note, I'd turn all your warning levels up to 4, and treat all warnings as errors. I see a bunch of unintialized variables, always set them to a value.

    As far as the values of those two vars not sticking in memory, when do they lose the expected values? Are you stepping into main and dropping them in the watch window, and seeing what line causes the value to change?

    Can't tell you much about the console char though, I haven't done much x64 coding. What happens when you hit the line that assigns the value? Is it some garbage value, or...?

  9. #9
    Puppetmaster
    Join Date
    Mar 2006
    Posts
    72
    BG Level
    2

    Code:
    _data* pParms = (_data*)(pMap+0x8000);

    its an MMF, i think its putting in wrong place, just gotta find correct memloc

  10. #10
    Melee Summoner
    Join Date
    May 2005
    Posts
    45
    BG Level
    1

    pParms->x=xres;
    pParms->y=yres;
    I'm guessing the values go bad right there. I didn't compile or run the code so I'm just guessing. The x and y data members of the _data structure are DWORD types and xres and yres are int so you're implying a cast here. Probably generates a warning in your compiler, but executes anyway. Try doing a reinterpret_cast or something like that so it's a safe cast instead of just letting the compiler handle it. Your values might be getting corrupted by this implied cast.

    You say xres and yres are being pulled from FFXI config, and it's not, it's pulling them from Windower. It's also pulling your current screen resolution using GetSystemMetrics and storing those values in real_xres and real_yres. So I'm not sure quite what you're talking about. "Not sticking in memory" tells me that you either have corrupted values due to a bad assignment (see above) or that you are using pointers incorrectly somewhere and are dereferencing the wrong object.

    Kind of hard to tell from your description, so excuse me if I'm sounding kind of vague. =/

    As far as the single char thing, windows messages are handled in such a way that single chars generate a WM_CHAR message in a WINAPI application, and everything else generates a different type message. Whatever function the guy who wrote this is using probably deals with a WM_CHAR message, which is probably why you can only use a character key to handle console stuff. The only thing you can probably do is isolate the funtion and see if there is a similar funtion in MSDN that will handle WM_SYSKEY message types or something like that (maybe make an overloaded function?).

Similar Threads

  1. Calling all car auido people: New Head unit, time for speakers.
    By The.Answer in forum General Discussion
    Replies: 12
    Last Post: 2009-05-14, 21:11
  2. Calling all Dark Tower fans
    By Mr.City in forum General Discussion
    Replies: 28
    Last Post: 2007-01-18, 06:22
  3. Calling all importers : Where are you getting your Wii ?
    By Lordwafik in forum General Discussion
    Replies: 15
    Last Post: 2006-11-13, 09:39
  4. Calling all Artists
    By Jerseyprophet in forum General Discussion
    Replies: 2
    Last Post: 2006-11-09, 21:36