PS-X EXE Loader

General Programming help in C, C++ or ASM, Compiling / Debugging, and R3000A Central Processing Unit (CPU) information
Post Reply
Z3R0X
Interested PSXDEV User
Interested PSXDEV User
Posts: 8
Joined: Jul 31, 2018

PS-X EXE Loader

Post by Z3R0X » 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

User avatar
Dedok179
Serious PSXDEV User
Serious PSXDEV User
Posts: 86
Joined: Jun 11, 2015
I am a: Programmer, Beginning reverser
PlayStation Model: SCPH-5502
Discord: Dedok179#2632
Location: Tula,RU

Post by Dedok179 » June 28th, 2019, 7:40 am

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.

Z3R0X
Interested PSXDEV User
Interested PSXDEV User
Posts: 8
Joined: Jul 31, 2018

Post by Z3R0X » June 29th, 2019, 2:07 am

Thank you so much for your help :praise

User avatar
Dedok179
Serious PSXDEV User
Serious PSXDEV User
Posts: 86
Joined: Jun 11, 2015
I am a: Programmer, Beginning reverser
PlayStation Model: SCPH-5502
Discord: Dedok179#2632
Location: Tula,RU

Post by Dedok179 » June 29th, 2019, 2:22 am

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 :)

Yagotzirck
Verified
Extreme PSXDEV User
Extreme PSXDEV User
Posts: 131
Joined: Jul 17, 2013

Post by Yagotzirck » 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

User avatar
Dedok179
Serious PSXDEV User
Serious PSXDEV User
Posts: 86
Joined: Jun 11, 2015
I am a: Programmer, Beginning reverser
PlayStation Model: SCPH-5502
Discord: Dedok179#2632
Location: Tula,RU

Post by Dedok179 » June 29th, 2019, 9:13 pm

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

User avatar
Dedok179
Serious PSXDEV User
Serious PSXDEV User
Posts: 86
Joined: Jun 11, 2015
I am a: Programmer, Beginning reverser
PlayStation Model: SCPH-5502
Discord: Dedok179#2632
Location: Tula,RU

Post by Dedok179 » June 29th, 2019, 9:22 pm

All the secrets have long been revealed INC. I just do as he did.

Z3R0X
Interested PSXDEV User
Interested PSXDEV User
Posts: 8
Joined: Jul 31, 2018

Post by Z3R0X » 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.

User avatar
Dedok179
Serious PSXDEV User
Serious PSXDEV User
Posts: 86
Joined: Jun 11, 2015
I am a: Programmer, Beginning reverser
PlayStation Model: SCPH-5502
Discord: Dedok179#2632
Location: Tula,RU

Post by Dedok179 » June 30th, 2019, 5:08 am

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.

User avatar
inc^lightforce
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 248
Joined: Mar 07, 2013
I am a: Programmer Windows+PS1, GFX Artist
PlayStation Model: Black
Location: Germany

Post by inc^lightforce » October 26th, 2019, 10:19 am

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
You do not have the required permissions to view the files attached to this post.

User avatar
inc^lightforce
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 248
Joined: Mar 07, 2013
I am a: Programmer Windows+PS1, GFX Artist
PlayStation Model: Black
Location: Germany

Post by inc^lightforce » October 26th, 2019, 10:40 am

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;
You do not have the required permissions to view the files attached to this post.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests