Page 1 of 1

PS-X EXE Loader

Posted: June 28th, 2019, 4:31 am
by Z3R0X
Hello, everyone, I'm learning a bit about C programing using PSYQ I managed to compile a small exe with music using hitman mod and some TIM sprites with this site expemples, but now I want to make a loader for another exe from X game, I use UPX to compress the main game exe but I don't know how to link them, this is what I have so far: :roll:
- I know that the exe files have the entry point pointer is at 0x10.
- UPX decompression routine starts at 0x800, followed by the compressed exe data and is 2048 aligned.
- The combined exe files are smaller that the original game exe.
- I can do a jump to an offset when I exit the loader, I try to find the UPX decompression routine, but I think my loader trash the compressed data of the main exe :(
What I don't know: :(
- If exe files have the size somewhere in the header and when the PS calls some LoadExecutable function a parameter of the size of the exe is passed.
- How to load the main exe when I exit the loader

Re: PS-X EXE Loader

Posted: June 28th, 2019, 7:40 am
by Dedok179
Z3R0X wrote: June 28th, 2019, 4:31 am Hello, everyone, I'm learning a bit about C programing using PSYQ I managed to compile a small exe with music using hitman mod and some TIM sprites with this site expemples, but now I want to make a loader for another exe from X game, I use UPX to compress the main game exe but I don't know how to link them, this is what I have so far: :roll:
- I know that the exe files have the entry point pointer is at 0x10.
- UPX decompression routine starts at 0x800, followed by the compressed exe data and is 2048 aligned.
- The combined exe files are smaller that the original game exe.
- I can do a jump to an offset when I exit the loader, I try to find the UPX decompression routine, but I think my loader trash the compressed data of the main exe :(
What I don't know: :(
- If exe files have the size somewhere in the header and when the PS calls some LoadExecutable function a parameter of the size of the exe is passed.
- How to load the main exe when I exit the loader
Write me in PM, explain what exactly is needed and I will write the code.

Re: PS-X EXE Loader

Posted: June 29th, 2019, 2:07 am
by Z3R0X
Thank you so much for your help :praise

Re: PS-X EXE Loader

Posted: June 29th, 2019, 2:22 am
by Dedok179
Z3R0X wrote: June 29th, 2019, 2:07 am Thank you so much for your help :praise
I was glad to help, subscribe to your channel :)

Re: PS-X EXE Loader

Posted: June 29th, 2019, 8:57 pm
by Yagotzirck
I don't mean to stick my nose in someone else's business, everyone is free to do whatever they want afterall, but... was there a specific reason to solve the problem in PM, rather than on the thread itself in such a way to also help other people who might stumble upon a similar issue in the future? :shrug

Re: PS-X EXE Loader

Posted: June 29th, 2019, 9:13 pm
by Dedok179
Yagotzirck wrote: June 29th, 2019, 8:57 pm I don't mean to stick my nose in someone else's business, everyone is free to do whatever they want afterall, but... was there a specific reason to solve the problem in PM, rather than on the thread itself in such a way to also help other people who might stumble upon a similar issue in the future? :shrug
No problem. The start address for the jump is easily searched through the IDA, the address of the depack for the depack.src is calculated manually, depending on how the file is unpacked into memory, basically it is the standard address 8000F800.
I compressed the file after compiling it using UPX, otherwise it is not included in the disk image in size. To replace the file in the disk image via CDmage, it will automatically set the file to the desired size if it is smaller.
Source good

Re: PS-X EXE Loader

Posted: June 29th, 2019, 9:22 pm
by Dedok179
All the secrets have long been revealed INC. I just do as he did.

Re: PS-X EXE Loader

Posted: June 30th, 2019, 3:41 am
by Z3R0X
I found that the address that you need to jump is at 0x10 in the EXE header if you don't have IDA.
Thank you once again Dedok179, I'm refining everything to release better things in my channel, so people can enjoy better releases.

Re: PS-X EXE Loader

Posted: June 30th, 2019, 5:08 am
by Dedok179
Z3R0X wrote: June 30th, 2019, 3:41 am I found that the address that you need to jump is at 0x10 in the EXE header if you don't have IDA.
Thank you once again Dedok179, I'm refining everything to release better things in my channel, so people can enjoy better releases.
Yeah. had seen. There will be time I will write a tool that pulls out the start address and the depack automatically calculates.

Re: PS-X EXE Loader

Posted: October 26th, 2019, 10:19 am
by inc^lightforce
Z3R0X wrote: June 30th, 2019, 3:41 am I found that the address that you need to jump is at 0x10 in the EXE header if you don't have IDA.
Thank you once again Dedok179, I'm refining everything to release better things in my channel, so people can enjoy better releases.
just use our/ my "Magic Sector Key" Tool.
all information you will get in one hit. no sniffing in the psx exe file is needed, just simple load a game *bin and wait.

Image

Re: PS-X EXE Loader

Posted: October 26th, 2019, 10:40 am
by inc^lightforce
Z3R0X wrote: June 28th, 2019, 4:31 am
- How to load the main exe when I exit the loader
here is an example taken from one of my SourceCode


to get the exactly Exec Address you must run the DOLCT.BAT. the files can be found in the attachment.
- DOLCT.BAT
- LCT.EXE

1. rename the original SLUS.. ps1 EXE to game.rnc
2. copy the file into the same folder next to DOLCT.BAT and LCT.EXE
3. run the batch

output = PatchData.txt
see here:

Code: Select all

=============================
Magic PSX Patching Tool v0.1 
-----------------------------
  (c) 2000 - AVH of PARADOX  
=============================

Load address...........: 0x80010000
Decrunch to............: 0x8000f800
Exec address...........: 0x8006a1a8 <------ this is the address that need to be inserted into the source code as you can see below

Patch GetVideoMode() at: 0x8007888c (0x24020001 for PAL, 0x24020000 for NTSC)
                         0x80078890 (NOP out)

Patch X-Delta at.......: 0x8006b7a8 (0x24900030 for PAL, 0x24900010 for NTSC)
                         0x8006b7ac (0x24900030 for PAL, 0x24900010 for NTSC)

as you can see, the tool also print the video system Mode Address. if you wanna code a pal 2 ntsc or ntsc2pal selector you now have the values

how to use? see one of my examples in my workshop

REMEMBER:
always do this steps before packing the SLUS, otherwise you fail

Example from my source code

Code: Select all

  MOD_Stop();MOD_Free();VSync(3); 
  PadStop();
  ResetGraph(0);
  StopCallback();
//-------------------------------------------------------------------------------
//------------------PATCH FUNCTION- DECRUNCH THE GAME------------
//------------------------------------------------------------------------------
EnterCriticalSection();
depack1();
start1();
ExitCriticalSection();
//-------------------------------------------------------------
//************************* starts game ***********************
//-------------------------------------------------------------
asm("nop");
asm("j 0x8006a1a8"); // Execution Address --> Load Game after PAD BREAK
asm("nop");

 return 0;