Example #1
0
void FFA_Enable()
{
	// patch!
	DoPatch(&g_takedmg_patches);
	DoPatch(&g_pkilled_patches);
	g_ffa_state = true;
	//we don't care about efficiency here
	g_last_ff_set = CVAR_GET_FLOAT("mp_friendlyfire");
	CVAR_SET_FLOAT("mp_friendlyfire", 1.0f);
	CVAR_SET_STRING("mp_freeforall", "1");
	MF_ExecuteForward(g_StateChange, CSDM_FFA_ENABLE);
}
Example #2
0
ret_code BackPatch( struct asym *sym )
/************************************/
/*
 * patching for forward reference labels in Jmp/Call instructions;
 * called by LabelCreate(), ProcDef() and data_dir(), that is, whenever
 * a (new) label is defined. The new label is the <sym> parameter.
 * During the process, the label's offset might be changed!
 *
 * field sym->fixup is a "descending" list of forward references
 * to this symbol. These fixups are only generated during pass 1.
 */
{
    struct fixup     *fixup;
    struct fixup     *next;

    DebugMsg(("BackPatch(%s) enter, seg.ofs=%s.%X\n", sym->name, sym->segment ? sym->segment->name : "NULL (!?)", sym->offset ));
    fixup = sym->fixup;
    sym->fixup = NULL;
    for( ; fixup != NULL; fixup = next ) {
        next = fixup->nextbp;
        if( DoPatch( sym, fixup ) == ERROR ) {
            return( ERROR );
        }
    }
    DebugMsg(("BackPatch(%s) exit, ofs=%X\n", sym->name, sym->offset ));
    return( NOT_ERROR );
}
Example #3
0
void WPatchApply( char *PatchName, char *TgtPath )
{
    short   flag;
    char    RelPath[ PATCH_MAX_PATH_SIZE ];
    char    FullPath[ PATCH_MAX_PATH_SIZE ];

    PatchReadOpen( PatchName );
    for( ;; ) {
        PatchReadFile( &flag, RelPath );
        if ( flag == PATCH_EOF ) break;
        strcpy( FullPath, TgtPath );
        strcat( FullPath, "\\" );
        strcat( FullPath, RelPath );
        switch( flag ) {
            case PATCH_FILE_PATCHED:
                printf( "Patching file %s\n", FullPath );
                DoPatch( "", 0,0,0, FullPath );
                break;
            case PATCH_DIR_DELETED:
                printf( "Deleting directory %s\n", FullPath );
                DirDelete( FullPath );
                break;
            case PATCH_FILE_DELETED:
                printf( "Deleting file %s\n", FullPath );
                remove( FullPath );
                break;
            case PATCH_DIR_ADDED:
                printf( "Adding directory %s\n", FullPath );
                mkdir( FullPath );
                break;
            case PATCH_FILE_ADDED:
                printf( "Adding file %s\n", FullPath );
                PatchGetFile( FullPath );
                break;
        }
    }
    PatchReadClose();
}
Example #4
0
void __declspec(dllexport) vpatchfile(HWND hwndParent, int string_size, 
                                      TCHAR *variables, stack_t **stacktop) {
  g_hwndParent=hwndParent;

  EXDLL_INIT();

  {
    TCHAR source[MAX_PATH];
    TCHAR dest[MAX_PATH];
    TCHAR exename[MAX_PATH];
    HANDLE hPatch, hSource, hDest;
    int result;

    popstring(exename);
    popstring(source);
    popstring(dest);

    hPatch = CreateFile(exename, GENERIC_READ, FILE_SHARE_READ, NULL,
                                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    if (hPatch == INVALID_HANDLE_VALUE) {
      pushstring(_T("Unable to open patch file"));
      return;
    }

    hSource = CreateFile(source, GENERIC_READ, FILE_SHARE_READ, NULL,
                                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    if (hSource == INVALID_HANDLE_VALUE) {
      CloseHandle(hPatch);
      pushstring(_T("Unable to open source file"));
      return;
    }
    
    hDest = CreateFile(dest, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                                    CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
    if (hDest == INVALID_HANDLE_VALUE) {
      CloseHandle(hPatch);
      CloseHandle(hSource);
      pushstring(_T("Unable to open output file"));
      return;
    }
        
    result = DoPatch(hPatch, hSource, hDest);

    CloseHandle(hDest);
    CloseHandle(hSource);
    CloseHandle(hPatch);

    if ((result != PATCH_SUCCESS)) {
      if (result == PATCH_ERROR)
        pushstring(_T("An error occured while patching"));
      else if (result == PATCH_CORRUPT)
        pushstring(_T("Patch data is invalid or corrupt"));
      else if (result == PATCH_NOMATCH)
        pushstring(_T("No suitable patches were found"));
      else if (result == PATCH_UPTODATE)
        pushstring(_T("OK, new version already installed"));
      DeleteFile(dest);
    } else {
      pushstring(_T("OK"));
    }

    return;
  }
}
Example #5
0
void __declspec(dllexport) vpatchfile(HWND hwndParent, int string_size, 
                                      char *variables, stack_t **stacktop)
{
  g_hwndParent=hwndParent;

  EXDLL_INIT();


  // note if you want parameters from the stack, pop them off in order.
  // i.e. if you are called via exdll::myFunction file.dat poop.dat
  // calling popstring() the first time would give you file.dat,
  // and the second time would give you poop.dat. 
  // you should empty the stack of your parameters, and ONLY your
  // parameters.

  // do your stuff here
  {
  	static char source[1024];
	static char dest[1024];
    static char exename[1024];
	HANDLE hPatch, hSource, hDest;
    int result;

	popstring(exename);
	popstring(source);
	popstring(dest);

	hPatch = CreateFile(exename, GENERIC_READ, FILE_SHARE_READ, NULL,
										OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
	if (hPatch == INVALID_HANDLE_VALUE) {
		pushstring("Unable to open patch file");
		return;
	}

	hSource = CreateFile(source, GENERIC_READ, FILE_SHARE_READ, NULL,
										OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
	if (hSource == INVALID_HANDLE_VALUE) {
		pushstring("Unable to open source file");
		return;
	}
	
	hDest = CreateFile(dest, GENERIC_READ | GENERIC_WRITE, 0, NULL,
									CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
	if (hDest == INVALID_HANDLE_VALUE) {
        pushstring("Unable to open output file");
		return;
	}
    	
	result = DoPatch(hPatch, hSource, hDest);

	CloseHandle(hDest);
	CloseHandle(hSource);
	CloseHandle(hPatch);

	if ((result != PATCH_SUCCESS)) {
		if (result == PATCH_ERROR)
			pushstring("An error occured while patching");
		else if (result == PATCH_CORRUPT)
			pushstring("Patch data is invalid or corrupt");
		else if (result == PATCH_NOMATCH)
			pushstring("No suitable patches were found");
		else if (result == PATCH_UPTODATE)
			pushstring("OK, new version already installed");
		DeleteFile(dest);
	} else {
        pushstring("OK");
	}
	
	return;
  }
}