mirror of
https://github.com/brain-hackers/brainlilo
synced 2024-12-22 12:10:05 +09:00
modified: BrainLILO.cpp BrainLILODrv.cpp Makefile
new file: dummy.cpp
This commit is contained in:
parent
8a8fe81433
commit
bf62b2063a
@ -126,10 +126,32 @@ static void loadDriverIfNeeded(){
|
|||||||
HANDLE driver=NULL;
|
HANDLE driver=NULL;
|
||||||
|
|
||||||
wchar_t driverPath[1024];
|
wchar_t driverPath[1024];
|
||||||
getThisDllDirectoryPath(driverPath);
|
|
||||||
wcscat(driverPath, L"\\BrainLILODrv.dll");
|
getThisDllDirectoryPath(driverPath);
|
||||||
|
wcscat(driverPath, L"\\MyJITDebugger.exe");
|
||||||
|
|
||||||
TCHAR newDriverPath[128];
|
TCHAR newDriverPath[128];
|
||||||
|
wcscpy(newDriverPath,L"\\Windows\\MyJITDebugger.exe");
|
||||||
|
|
||||||
|
{
|
||||||
|
wchar_t buf[1024];
|
||||||
|
swprintf(buf, L"BrainLILO: copying \"%ls\" to \"%ls\"",
|
||||||
|
driverPath, newDriverPath);
|
||||||
|
OutputDebugString(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!CopyFile(driverPath,newDriverPath, FALSE)){
|
||||||
|
|
||||||
|
|
||||||
|
if(GetFileAttributes(newDriverPath)==(DWORD)-1){
|
||||||
|
OutputDebugString(L"BrainLILO: failed to copy");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getThisDllDirectoryPath(driverPath);
|
||||||
|
wcscat(driverPath, L"\\BrainLILODrv.dll");
|
||||||
wcscpy(newDriverPath,L"\\Windows\\BrainLILODrv.dll");
|
wcscpy(newDriverPath,L"\\Windows\\BrainLILODrv.dll");
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ static FileSystemPowerFunctionProc FileSystemPowerFunction;
|
|||||||
|
|
||||||
typedef LPVOID (*AllocPhysMemProc)(DWORD,DWORD,DWORD,DWORD,PULONG);
|
typedef LPVOID (*AllocPhysMemProc)(DWORD,DWORD,DWORD,DWORD,PULONG);
|
||||||
|
|
||||||
DWORD wReadSize;
|
DWORD FileSize;
|
||||||
unsigned long bootloaderphysaddr;
|
unsigned long bootloaderphysaddr;
|
||||||
|
|
||||||
static void disableInterrupts(){
|
static void disableInterrupts(){
|
||||||
@ -129,7 +129,7 @@ static void EDNA2_runPhysicalInvoker(){
|
|||||||
"bic r0, r0, #5\n" // disable MMU/DCache
|
"bic r0, r0, #5\n" // disable MMU/DCache
|
||||||
"mcr p15,0,r0,c1,c0,0\n" // write ctrl regs
|
"mcr p15,0,r0,c1,c0,0\n" // write ctrl regs
|
||||||
);
|
);
|
||||||
for(DWORD i=0;i<wReadSize;i++)*((char*)(0x40100000+i))=*((char*)bootloaderphysaddr+i);
|
for(DWORD i=0;i<FileSize;i++)*((char*)(0x40100000+i))=*((char*)bootloaderphysaddr+i);
|
||||||
asm volatile("ldr r0, =0x0000\n"
|
asm volatile("ldr r0, =0x0000\n"
|
||||||
"ldr r1, =0x0000\n"
|
"ldr r1, =0x0000\n"
|
||||||
"ldr r2, =0x0000\n"
|
"ldr r2, =0x0000\n"
|
||||||
@ -161,10 +161,11 @@ static DWORD EDNA2_callKernelEntryPoint(){
|
|||||||
static bool doLinux(){
|
static bool doLinux(){
|
||||||
TCHAR bootloaderFileName[128]=TEXT("\\Storage Card\\loader\\u-boot.bin");
|
TCHAR bootloaderFileName[128]=TEXT("\\Storage Card\\loader\\u-boot.bin");
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
char *bootloaderptr;
|
LPVOID bootloaderptr;
|
||||||
wchar_t buf[256];
|
wchar_t buf[256];
|
||||||
HINSTANCE dll;
|
HINSTANCE dll;
|
||||||
AllocPhysMemProc AllocPhysMem;
|
AllocPhysMemProc AllocPhysMem;
|
||||||
|
DWORD wReadSize;
|
||||||
|
|
||||||
dll=LoadLibrary(TEXT("COREDLL.DLL"));
|
dll=LoadLibrary(TEXT("COREDLL.DLL"));
|
||||||
if (dll == NULL) {
|
if (dll == NULL) {
|
||||||
@ -187,13 +188,16 @@ static bool doLinux(){
|
|||||||
swprintf(buf, L"BrainLILO: Bootloader file handle 0x%08x\n",(int)(hFile));
|
swprintf(buf, L"BrainLILO: Bootloader file handle 0x%08x\n",(int)(hFile));
|
||||||
OutputDebugString(buf);
|
OutputDebugString(buf);
|
||||||
|
|
||||||
|
FileSize=GetFileSize(hFile , NULL);
|
||||||
|
swprintf(buf, L"BrainLILO: Bootloader file size %d Byte\n",FileSize);
|
||||||
|
OutputDebugString(buf);
|
||||||
|
|
||||||
bootloaderptr=(char*)AllocPhysMem(GetFileSize(hFile , NULL),PAGE_EXECUTE_READWRITE,0,0,&bootloaderphysaddr);
|
bootloaderptr=AllocPhysMem(FileSize,PAGE_EXECUTE_READWRITE,0,0,&bootloaderphysaddr);
|
||||||
swprintf(buf, L"BrainLILO: Allocated preload memory Virtual:%p Physical:%p\n",bootloaderptr,bootloaderphysaddr);
|
swprintf(buf, L"BrainLILO: Allocated preload memory Virtual:%p Physical:%p\n",bootloaderptr,bootloaderphysaddr);
|
||||||
OutputDebugString(buf);
|
OutputDebugString(buf);
|
||||||
|
|
||||||
OutputDebugString(L"BrainLILO: Copying bootloader to allocated virtual memory...");
|
OutputDebugString(L"BrainLILO: Copying bootloader to allocated virtual memory...");
|
||||||
ReadFile(hFile , bootloaderptr , GetFileSize(hFile , NULL) , &wReadSize , NULL);
|
ReadFile(hFile , bootloaderptr , FileSize , &wReadSize , NULL);
|
||||||
OutputDebugString(L"BrainLILO: Bootloader copied! Closing file handle...");
|
OutputDebugString(L"BrainLILO: Bootloader copied! Closing file handle...");
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
|
5
Makefile
5
Makefile
@ -9,7 +9,7 @@ AS=$(PREFIX)/bin/arm-mingw32ce-as
|
|||||||
NM=$(PREFIX)/bin/arm-mingw32ce-nm
|
NM=$(PREFIX)/bin/arm-mingw32ce-nm
|
||||||
WINDRES=$(PREFIX)/bin/arm-mingw32ce-windres
|
WINDRES=$(PREFIX)/bin/arm-mingw32ce-windres
|
||||||
|
|
||||||
OUTPUT=BrainLILO.dll BrainLILODrv.dll BrainLILO.exe
|
OUTPUT=BrainLILO.dll BrainLILODrv.dll BrainLILO.exe MyJITDebugger.exe
|
||||||
|
|
||||||
CXXFLAGS= -DEV_PLATFORM_WIN32 -DUNICODE -D_UNICODE -DEV_UNSAFE_SWPRINTF -mwin32 \
|
CXXFLAGS= -DEV_PLATFORM_WIN32 -DUNICODE -D_UNICODE -DEV_UNSAFE_SWPRINTF -mwin32 \
|
||||||
-O0 -mcpu=arm926ej-s -D_WIN32_WCE=0x600 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
|
-O0 -mcpu=arm926ej-s -D_WIN32_WCE=0x600 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
|
||||||
@ -46,3 +46,6 @@ BrainLILO.exe: bootloader.cpp
|
|||||||
$(CXX) bootloader.cpp -o BrainLILO.exe $(CXXFLAGS)
|
$(CXX) bootloader.cpp -o BrainLILO.exe $(CXXFLAGS)
|
||||||
$(STRIP) BrainLILO.exe
|
$(STRIP) BrainLILO.exe
|
||||||
|
|
||||||
|
MyJITDebugger.exe: dummy.cpp
|
||||||
|
$(CXX) dummy.cpp -o MyJITDebugger.exe $(CXXFLAGS)
|
||||||
|
$(STRIP) MyJITDebugger.exe
|
Loading…
Reference in New Issue
Block a user