Log In  

Hi,

I played around with Pico-8 and wanted a fancy way to build and run
custom cart when the idea came to me like the urge to go π :

I NEEDED A DEDICATED SPLORE SERVER !

One hour later it was alive

Showing custom list and loading whatever I want directly from SPLORE.
I was surprised at how simple it is to make a proxy.

First I edited "drivers\etc\hosts" but it lacked flexibility...

Then I came up with the idea of ​​replacing wininet.dll by a custom script.
That way you just put (or remove) the file near pico.exe and start it.
No user hack, no patch, no third party.

You can make your own proxy with the MASM32 code below
(I think I can share it with you because it does not disclose any flaws or infringe any copyright)
(The code of the server may be more sensitive to disclose)

Anyway, I swear that no "pico8.exe" were harmed during the making of this progam.

.386
.model flat, stdcall
option casemap :none
option Prologue:none
option Epilogue:none

include windows.inc
include user32.inc
include kernel32.inc

includelib user32.lib
includelib kernel32.lib

.data

  _Wininet           dd 0
  _InternetOpenA     dd 0
  _InternetOpenUrlA  dd 0
  _InternetReadFile  dd 0
  _sInternetOpenA    db "InternetOpenA"                  , 0
  _sInternetOpenUrlA db "InternetOpenUrlA"               , 0
  _sInternetReadFile db "InternetReadFile"               , 0
  _URL               db "http://127.0.0.1:80"            , 0 ;<=== YOUR SERVER URL HERE
  _SysDLL            db "c:\windows\system32\WININET.DLL", 0 ;<=== YOUR PATH HERE
  temp               db 260 DUP(0)                           ; GIVE IT SOME SPACE !!

.code

; MAIN DLL FUNCTION
_DllMainCRTStartup proc instance:DWORD,reason:DWORD,unused:DWORD

  ; ONLY ON PROCESS ATTACH
  mov eax, [esp+8]
  cmp eax, 1
  jne @next

  ; GET REAL "WININET.DLL"
  push offset _SysDLL
  call LoadLibraryA
  mov _Wininet, eax

  ; GET REAL "InternetOpen"
  push offset _sInternetOpenA
  push _Wininet
  call GetProcAddress
  mov _InternetOpenA, eax 

  ; GET REAL "InternetOpenUrl"
  push offset _sInternetOpenUrlA
  push _Wininet
  call GetProcAddress
  mov _InternetOpenUrlA, eax 

  ; GET REAL "InternetReadFile"
  push offset _sInternetReadFile
  push _Wininet
  call GetProcAddress
  mov _InternetReadFile, eax 

@next:
  mov eax, 1
  ret 12
_DllMainCRTStartup endp

; FAKE "InternetOpen"
InternetOpenA proc
  jmp [_InternetOpenA]
InternetOpenA endp

; FAKE "InternetReadFile"
InternetReadFile proc
  jmp [_InternetReadFile]
InternetReadFile endp

; FAKE "InternetOpenUrl"
InternetOpenUrlA proc

  ; LAZY STRING REPLACE ^^
  mov eax, [esp+8]
  add eax, 25
  push eax
  push offset _URL
  call lstrcat
  mov [esp+8], eax

  ; CALL REAL "InternetOpenUrl"
  jmp [_InternetOpenUrlA]
InternetOpenUrlA endp

end

; DEF FILE LOOK LIKE =>
;LIBRARY WININET
;EXPORTS 
;
;InternetOpenA     @1
;InternetOpenUrlA  @2
;InternetReadFile  @3

Unfortunately while the dedicated server works perfectly, the SPLORE internal cache ttl make it useless for its original purpose (eg:dynamic build and run).

If you have any new idea to use such a product let me know.

.

P#89697 2021-03-28 17:08

You inspired me to run a little test:

$ export http_proxy=http://localhost:42/
$ pico8 -splore

…and splore can’t refresh categories! so this means that pico8 respects the standard HTTP proxy environment variable, which is an easier, cleaner and more cross-platform way to override the server address! Now we have to reverse-engineer more of the bbs splore protocol.

That’s a good find for people making custom arcarde cabinets or offline consoles (a raspberry pi for example can most probably run a simple Python server and pico8), with more than one list available. The alternative with a custom cart that browses local files needs a bit of code to have navigation and menu and everything, and 'ls' in a cart doesn’t return directories so has limited usefulness.

P#89706 2021-03-28 22:31

I think there's a SPLORE tab that explores the carts directory tree - not at my computer this second to check but I remember running carts that way.

P#89707 2021-03-28 23:11
1

Yes of course, but you can’t have splore for local carts only, hiding bbs categories if you’re making an offline console.

P#89712 2021-03-29 02:16

I described the protocol on My website.

P#89719 2021-03-29 08:56

That’s great detective work 👍

P#89725 2021-03-29 18:29

[Please log in to post a comment]