diff options
author | nrootconauto@gmail.com <nrootconauto@gmail.com> | 2022-07-26 15:33:33 -0400 |
---|---|---|
committer | nrootconauto@gmail.com <nrootconauto@gmail.com> | 2022-07-26 15:33:33 -0400 |
commit | af14779183758fbefe67d2ca99170b64bb173c21 (patch) | |
tree | 4c699a9b6dbf9aa6120bbd617bcf65256bee2f90 | |
parent | be4c83095777fbe353a75bb4637158614cb9a3fe (diff) |
Windows fixesHolyHeap
VFsFSize and VFsUnixTime work properly on windows.
Fixed a bug in MSCallback.
Cursor is always normal on draw.
-rw-r--r-- | WIN_window.c | 6 | ||||
-rw-r--r-- | runtime.c | 12 | ||||
-rw-r--r-- | tos_aot.c | 9 | ||||
-rw-r--r-- | vfs.c | 17 |
4 files changed, 33 insertions, 11 deletions
diff --git a/WIN_window.c b/WIN_window.c index 696b608..efcfb66 100644 --- a/WIN_window.c +++ b/WIN_window.c @@ -371,7 +371,7 @@ static int MSCallback(HWND hwnd,void *d,UINT msg,WPARAM w,LPARAM e) { ent:; int x2=x-cx,y2=y-cy; if(x2>=640) x2=640; - if(x2>=480) y2=480; + if(y2>=480) y2=480; if(y2<0) y2=0; if(x2<0) x2=0; FFI_CALL_TOS_4(ms_cb,x2,y2,z,state); @@ -384,6 +384,7 @@ void SetMSCallback(void *fptr) { ms_cb=fptr; } LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); +static HANDLE normal_c; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR lpCmdLine, int nCmdShow) { MSG msg; HWND hwnd; @@ -422,7 +423,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR lpCmdLine, NewDrawWindow()->win=hwnd; argv=CommandLineToArgvA_wine(lpCmdLine,&argc); _main(argc,argv); - SetCursor(LoadCursor(NULL,IDC_ARROW)); + SetCursor(normal_c=LoadCursor(NULL,IDC_ARROW)); ShowWindow(hwnd, nCmdShow); while (GetMessage(&msg, NULL, 0, 0)) { DispatchMessage(&msg); @@ -510,6 +511,7 @@ LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { MSCallback(hwnd,NULL,msg,wParam,lParam); break; case WM_PAINT: + SetCursor(normal_c); WaitForSingleObject(mutex,INFINITE); GetClientRect(hwnd,&rct); CenterWindow(hwnd,&cx,&cy); @@ -66,11 +66,6 @@ static void *STK_DyadListen(int64_t *stk) { static void *STK_DyadConnect(int64_t *stk) { return dyad_connect(stk[0],stk[1],stk[2]); } -static void UnblockSignals() { - sigset_t all; - sigfillset(&all); - sigprocmask(SIG_UNBLOCK,&all,NULL); -} static void STK_DyadWrite(int64_t *stk) { dyad_write(stk[0],stk[1],stk[2]); } @@ -97,6 +92,13 @@ static STK_DyadSetOnListenCallback(int64_t *stk) { dyad_addListener(stk[0],DYAD_EVENT_ACCEPT,&DyadListenCB,stk[1],stk[2]); } #endif +static void UnblockSignals() { + #ifndef TARGET_WIN32 + sigset_t all; + sigfillset(&all); + sigprocmask(SIG_UNBLOCK,&all,NULL); + #endif +} typedef struct CType CType; static int64_t BFFS(int64_t v) { if(!v) return -1; @@ -245,9 +245,16 @@ void *Load(char *fn,int64_t ld_flags) { #ifndef TARGET_WIN32 signal(SIGBUS,FualtCB->data[0].val); #endif - signal(SIGSEGV,FualtCB->data[0].val); } LoadPass2((char*)bfh_addr+bfh_addr->patch_table_offset,mod_base,ld_flags); //Stuff may still be using data once we exit //PoopFree(bfh_addr); } +#ifdef TARGET_WIN32 +void FualtCB() { + vec_CHash_t *FualtCB=map_get(&TOSLoader,"FualtRoutine"); + if(FualtCB) + FFI_CALL_TOS_0(FualtCB->data[0].val); + exit(1); +} +#endif @@ -342,6 +342,7 @@ char *__VFsFileNameAbs(char *name) { end: vec_deinit(&head); TD_FREE(file); + VFsInplaceHostDelims(path.data); if(!failed) return path.data; vec_deinit(&path); @@ -368,19 +369,29 @@ int64_t VFsUnixTime(char *name) { char *fn=__VFsFileNameAbs(name); int64_t t64; FILETIME t; - GetFileTime(fn,NULL,NULL,&t); + if(!fn) return 0; + if(!__FExists(fn)) + return 0; + HANDLE fh=CreateFileA(fn,GENERIC_READ,0,NULL,OPEN_ALWAYS,0,NULL); + GetFileTime(fh,NULL,NULL,&t); t64=t.dwLowDateTime|(t.dwHighDateTime<<32); TD_FREE(fn); + CloseHandle(fh); return t64; } int64_t VFsFSize(char *name) { char *fn=__VFsFileNameAbs(name); int64_t s64; int32_t h32; - s64=GetFileSize(fn,&h32); + if(!fn) return 0; + if(!__FExists(fn)) + return 0; + HANDLE fh=CreateFileA(fn,GENERIC_READ,0,NULL,OPEN_ALWAYS,0,NULL); + s64=GetFileSize(fh,&h32); s64|=h32<<32; TD_FREE(fn); - return fn; + CloseHandle(fh); + return s64; } #endif char *VFsFileNameAbs(char *name) { |