📄 tmloader.c
字号:
/*
tmloader.c
960919 TR Pulled in from tmclnt sources
this file handles all the interfaces with tmldr.exe.
tmldr under win'95 is a Win32 server application that services
requests from vtmman via queues between ring 3 and ring0.
for cummunication from tmldr.exe to vtmman - tmldr calls vtmman
functions directly via deviceioctl.
TMIF_DIOC_TMLDRREGISTER -> loaderCreate
TMIF_DIOC_TMLDRUNREGISTER -> loaderDestroy
TMIF_DIOC_TMLDRCOMPLETION -> loaderRequestComplete
TMIF_DIOC_TMLDRLOADIMAGE -> loaderDownloadImage
TMIF_DIOC_TMLDRPATCHMEMORY -> loaderPatchMemory
for communication from vtmman to tmldr.exe - the request queue is
used.
TMIF_TMLDRREQ_LOADEXECUTEABLE <- loaderTMLDRRequest
TMIF_TMLDRREQ_LOADTASK <- loaderTMLDRRequest
TMIF_TMLDRREQ_GETSYMBOLADDR <- loaderTMLDRRequest
*/
/*----------------------------------------------------------------------------
SYSTEM INCLUDE FILES
----------------------------------------------------------------------------*/
#define WANTVXDWRAPS
#include <basedef.h>
#include <vmm.h>
#include <vxdwraps.h>
#include <vwin32.h>
/*----------------------------------------------------------------------------
DRIVER SPECIFIC INCLUDE FILES
----------------------------------------------------------------------------*/
#include "vxstd.h"
#include "vxwin.h"
#include "vxdbg.h"
#include "tmwincom.h"
#include "tmshare.h"
#include "tmman32.h"
#include "tmif.h"
#include "tmloader.h"
#include "cqueue.h"
/*
loaderCreate
this function creates a loader object to communicate with tmldr.exe
since there is only one instance of this object in the entire system
this object ptr is stored to th driver object data structure not in
the device data structure.
*/
STATUS loaderCreate ( PVOID pContainer,
PVOID pLoaderRegisterArg, PVOID *ppObject)
{
PTMLOADER_OBJECT this;
STATUS Status;
PTMIF_STRUCT_TMLDRREGISTER pLoaderRegister = pLoaderRegisterArg;
if ( *((PTMLOADER_OBJECT *)ppObject) )
{
this = *((PTMLOADER_OBJECT *)ppObject);
}
else
{
// create the tmloader object
if ( ( this = vxdMalloc ( sizeof ( TMLOADER_OBJECT ) ) ) == NULL )
{
DP(0,"vtmman:loaderCreate:vxdMalloc:TMLOADER_OBJECT :FAIL\n");
Status = TM_STATUS ( TMLOADER_ERR_OUTOFMEMORY );
goto loaderCreate_fail1;
}
FlagSet ( this->Flags, TMLOADER_FLAGDYNAMICALLOC );
}
this->Size = sizeof ( TMLOADER_OBJECT );
FlagSet ( this->Flags, TMLOADER_FLAGINITIALIZED );
// create the queue for passing requests to ring 3
if ( cqueueCreate ( TMIF_LOADER_REQUEST_COUNT,
sizeof ( TMIF_STRUCT_TMLDRREQUEST ), NULL,
&this->pQueue ) != TRUE )
{
DP(0,"vtmman:loaderCreate:vxdMalloc:pQueue:FAIL\n");
Status = TM_STATUS( TMLOADER_ERR_ADVISORYQCREATEFAIL );
goto loaderCreate_fail2;
}
// create the overlapped obj for ring 3 event notifications
if ( ( this->pOverlappedObject =
vxdMalloc ( sizeof ( OVERLAPPED ) ) ) == NULL )
{
DP(0,"vtmman:loaderCreate:vxdMalloc:pvOverlappedObject:FAIL\n");
Status = TM_STATUS( TMLOADER_ERR_OVERLAPPEDALLCOATIONFAIL );
goto loaderCreate_fail3;
}
*((PTMLOADER_OBJECT *)ppObject) = this;
return TMOK;
loaderCreate_fail4 :
vxdFree ( this->pOverlappedObject );
loaderCreate_fail3 :
cqueueDestroy ( this->pQueue );
loaderCreate_fail2 :
vxdFree ( this );
loaderCreate_fail1 :
return Status;
}
STATUS loaderDestroy ( PVOID pLoader )
{
PTMLOADER_OBJECT this = ( PTMLOADER_OBJECT)pLoader;
FlagClr( this->Flags, TMLOADER_FLAGALLOCATED );
vxdFree ( this->pOverlappedObject );
cqueueDestroy ( this->pQueue );
vxdFree ( this );
return TMOK;
}
/*
loaderTMLDRSendRequest
this fucntion is used for all communication between vtmman and tmldr.
it inserts the request in to the request queue and then signals the
worker thread in tmldr.
*/
STATUS loaderTMLDRSendRequest ( PVOID pLoader,
PVOID pRequestArg )
{
PTMLOADER_OBJECT this = (PTMLOADER_OBJECT)pLoader;
PTMIF_STRUCT_TMLDRREQUEST pRequest = (PVOID)pRequestArg;
if ( cqueueInsert (
this->pQueue, pRequest ) != TRUE )
{
return TM_STATUS ( TMLOADER_ERR_ADVISORYQFULL );
}
if ( ! this->Ring3ThreadActive )
{
this->Ring3ThreadActive = TRUE;
winVWIN32_DIOCCompletionRoutine (
((OVERLAPPED *)this->pOverlappedObject)->O_Internal );
}
}
/*
loaderDownloadImage
this function basically does a memcopy from the tmldr's address space to
the SDRAM address specified.
*/
STATUS loaderDownloadImage ( PVOID pLoader , PVOID pSectionTable,
DWORD SectionCount )
{
PTMLOADER_OBJECT this = (PTMLOADER_OBJECT)pLoader;
DWORD IdxSection;
for ( IdxSection = 0 ; IdxSection < SectionCount ; IdxSection ++ )
{
// copy the task into the memory area specified.
}
return TMOK;
}
/*
loaderPatchMemory
Patches the physical memory locations with the given values
*/
STATUS loaderPatchMemory( PVOID pLoader , PVOID pPatchTable,
DWORD PatchCount )
{
PTMLOADER_OBJECT this = (PTMLOADER_OBJECT)pLoader;
DWORD IdxPatch;
for ( IdxPatch = 0 ; IdxPatch < PatchCount ; IdxPatch ++ )
{
// copy the task into the memory area specified.
}
return TMOK;
}
/*
loaderRequestComplete
*/
STATUS loaderRequestComplete( PVOID pLoader )
{
PTMLOADER_OBJECT this = (PTMLOADER_OBJECT)dwHandle;
this->Ring3ThreadActive = FALSE;
if ( ! cqueueIsEmpty ( this->pQueue ) )
{
this->Ring3ThreadActive = TRUE;
winVWIN32_DIOCCompletionRoutine (
((OVERLAPPED *)this->pOverlappedObject)->O_Internal );
}
return TMOK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -