GithubHelp home page GithubHelp logo

Comments (1)

bigianb avatar bigianb commented on May 25, 2024

The hang was because the param was not being filled in when the file does not have a valid handle.

The code below solves that ... but it still has problems - I think because the params are not right. Needs more investigation.

void CMcServ::Read(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram)
{
	FILECMD* cmd = reinterpret_cast<FILECMD*>(args);

	CLog::GetInstance().Print(LOG_NAME, "Read(handle = %i, size = 0x%08X, bufferAddress = 0x%08X, paramAddress = 0x%08X);\r\n",
	                          cmd->handle, cmd->size, cmd->bufferAddress, cmd->paramAddress);

    if(cmd->paramAddress != 0)
    {
        //This param buffer is used in the callback after calling this method... No clue what it's for
        reinterpret_cast<uint32*>(&ram[cmd->paramAddress])[0] = 0;
        reinterpret_cast<uint32*>(&ram[cmd->paramAddress])[1] = 0;
    }
    
    assert(cmd->bufferAddress != 0);
    void* dst = &ram[cmd->bufferAddress];
    
	auto file = GetFileFromHandle(cmd->handle);
	if(file == nullptr)
	{
		ret[0] = -4;
        } 
        else if(file->IsEOF())
	{
		ret[0] = 0;
	}
	else
	{
		ret[0] = static_cast<uint32>(file->Read(dst, cmd->size));

		//Sync pointer for games that write after read without seeking or flushing
		file->Seek(file->Tell(), Framework::STREAM_SEEK_SET);
	}
}

from play-.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.