From 7f0e57694d90e834b5028d2f84fad9fb4dbac187 Mon Sep 17 00:00:00 2001 From: John van Groningen Date: Fri, 16 Jun 2006 11:24:30 +0000 Subject: [PATCH] port to 64 bit windows --- Win/PatchConsoleEvents/Redirect.c | 34 ++++++++++- Win/PatchConsoleEvents/cCrossCallMaarten.c | 66 ++++++++++++++-------- Win/thread_message.c | 10 ++-- 3 files changed, 80 insertions(+), 30 deletions(-) diff --git a/Win/PatchConsoleEvents/Redirect.c b/Win/PatchConsoleEvents/Redirect.c index 3422b9a..7bc05d9 100644 --- a/Win/PatchConsoleEvents/Redirect.c +++ b/Win/PatchConsoleEvents/Redirect.c @@ -109,6 +109,17 @@ BOOL WINAPI IsWinNT() return TRUE; } +#ifdef _WIN64 +static void my_zero_memory (void *a,size_t n) +{ + unsigned char *p; + size_t i; + + p=a; + for (i=0; i 0) { if (!WriteFile(m_hStdInWrite, lpszInput, Length, &nBytesWrote, NULL)) @@ -543,7 +571,11 @@ BOOL AddMainWindowHook (BOOL dummy) { if (g_pWndProc == NULL) { +#ifdef _WIN64 + g_pWndProc = (WNDPROC)SetWindowLongPtr(ghMainWindow,GWLP_WNDPROC,(LONG_PTR)SubClassWndProc); +#else g_pWndProc = (WNDPROC)SetWindowLong(ghMainWindow,GWL_WNDPROC,(LPARAM)SubClassWndProc); +#endif return TRUE; } return FALSE; diff --git a/Win/PatchConsoleEvents/cCrossCallMaarten.c b/Win/PatchConsoleEvents/cCrossCallMaarten.c index ced21b7..352e321 100644 --- a/Win/PatchConsoleEvents/cCrossCallMaarten.c +++ b/Win/PatchConsoleEvents/cCrossCallMaarten.c @@ -42,7 +42,7 @@ void EvalCcRqSETWINDOWICON (CrossCallInfo *pcci) hIcon = LoadIcon ((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(idIcon)); - hPrevIcon = SendMessage(hWnd,WM_SETICON,(WPARAM)ICON_BIG,(LPARAM)hIcon); + hPrevIcon = (HICON) SendMessage(hWnd,WM_SETICON,(WPARAM)ICON_BIG,(LPARAM)hIcon); MakeReturn0Cci (pcci); } @@ -116,6 +116,7 @@ PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBmp) return pbmi; } +#if 0 char *CreateBMPFile(PBITMAPINFO pbi, HBITMAP hBMP) { BITMAPFILEHEADER hdr; // bitmap file-header @@ -195,6 +196,7 @@ char *CreateBMPFile(PBITMAPINFO pbi, HBITMAP hBMP) GlobalFree((HGLOBAL)lpBits); return sf; } +#endif void EvalCcRqGETBITMAPRESOURCE (CrossCallInfo *pcci) { @@ -215,12 +217,12 @@ void EvalCcRqGETBITMAPRESOURCE (CrossCallInfo *pcci) if (hBitmap == 0) { MakeReturn4Cci (pcci, 0, 0, 0, 0); return; - }; + }; pbi = CreateBitmapInfoStruct(hBitmap); // data = CreateBMPFile(pbi, hBitmap); - MakeReturn4Cci (pcci,hBitmap,0/*data*/,pbi->bmiHeader.biWidth,pbi->bmiHeader.biHeight); + MakeReturn4Cci (pcci,(size_t)hBitmap,0/*data*/,pbi->bmiHeader.biWidth,pbi->bmiHeader.biHeight); GlobalFree(pbi); return; /* @@ -237,7 +239,7 @@ void EvalCcRqGETBITMAPRESOURCE (CrossCallInfo *pcci) */ } -void WinGetBitmapResource(int idBitmap, int intoolbox, int *outbitmap, int *width, int *height, int *outtoolbox) +void WinGetBitmapResource(int idBitmap, int intoolbox, size_t *outbitmap, int *width, int *height, int *outtoolbox) { HANDLE hBitmap; char* data; @@ -260,12 +262,16 @@ void WinGetBitmapResource(int idBitmap, int intoolbox, int *outbitmap, int *widt *width = pbi->bmiHeader.biWidth; *height = pbi->bmiHeader.biHeight; GlobalFree(pbi); - *outbitmap = hBitmap; + *outbitmap = (size_t)hBitmap; *outtoolbox = intoolbox; return; } +#ifdef _WIN64 +static int APIENTRY DirectorySelectorHook (HWND hdlg, UINT uiMsg, LPARAM wParam, LPARAM lParam) +#else static UINT APIENTRY DirectorySelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +#endif { if (uiMsg == BFFM_INITIALIZED) { @@ -275,7 +281,11 @@ static UINT APIENTRY DirectorySelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam return 0; } +#ifdef _WIN64 +static UINT_PTR APIENTRY FileSelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +#else static UINT APIENTRY FileSelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +#endif { if (uiMsg == WM_INITDIALOG) { @@ -286,9 +296,9 @@ static UINT APIENTRY FileSelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPA x = (GetSystemMetrics (SM_CXSCREEN)>>1) - ((rect.right-rect.left)>>1); y = (GetSystemMetrics (SM_CYSCREEN)>>1) - ((rect.bottom-rect.top)>>1); SetWindowPos (hdlg, NULL, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); - - if ((lParam != NULL) && (((LPOPENFILENAME)lParam)->lCustData != NULL)) - SendMessage(GetParent(hdlg),CDM_SETCONTROLTEXT,IDOK,((LPOPENFILENAME)lParam)->lCustData); + + if (lParam!=0 && ((LPOPENFILENAME)lParam)->lCustData!=0) + SendMessage(GetParent(hdlg),CDM_SETCONTROLTEXT,IDOK,((LPOPENFILENAME)lParam)->lCustData); } return 0; @@ -364,7 +374,11 @@ void EvalCcRqALTFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textp } else { +#ifdef _WIN64 + ofn.lStructSize = sizeof (OPENFILENAME_NT4); +#else ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; +#endif } ofn.hwndOwner = GetActiveWindow (); @@ -389,7 +403,7 @@ void EvalCcRqALTFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textp // | OFN_ENABLEHOOK; // PA: OFN_ENABLEHOOK added from Ronny ofn.lpstrDefExt = NULL; - ofn.lCustData = NULL; + ofn.lCustData = (LPARAM)NULL; ofn.lpfnHook = &FileSelectorHook; // PA: &FileSelectorHook instead of NULL from Ronny ofn.lpTemplateName = NULL; #if (_WIN32_WINNT >= 0x0500) @@ -402,12 +416,12 @@ void EvalCcRqALTFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textp if (success) { - MakeReturn2Cci (pcci, success, (int) ofn.lpstrFile); + MakeReturn2Cci (pcci, success, (size_t) ofn.lpstrFile); /* and have the calling clean function deallocate the filename buffer */ } else { - MakeReturn2Cci (pcci, success, (int) NULL); + MakeReturn2Cci (pcci, success, (size_t) NULL); rfree (ofn.lpstrFile); } } @@ -437,7 +451,11 @@ void EvalCcRqALTFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; boo } else { +#ifdef _WIN64 + ofn.lStructSize = sizeof (OPENFILENAME_NT4); +#else ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; +#endif } ofn.hwndOwner = GetActiveWindow (); @@ -470,7 +488,7 @@ void EvalCcRqALTFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; boo okptr = NULL; /* the calling clean function will deallocate the memory allocated for this empty string */ - ofn.lCustData = okptr; + ofn.lCustData = (LPARAM) okptr; ofn.lpfnHook = &FileSelectorHook; // PA: &FileSelectorHook instead of NULL from Ronny ofn.lpTemplateName = NULL; #if (_WIN32_WINNT >= 0x0500) @@ -483,12 +501,12 @@ void EvalCcRqALTFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; boo if (success) { - MakeReturn2Cci (pcci, success, (int) ofn.lpstrFile); + MakeReturn2Cci (pcci, success, (size_t) ofn.lpstrFile); /* and have the calling clean function deallocate the filename buffer */ } else { - MakeReturn2Cci (pcci, success, (int) NULL); + MakeReturn2Cci (pcci, success, (size_t) NULL); rfree (ofn.lpstrFile); } } @@ -499,10 +517,10 @@ void EvalCcRqALTDIRECTORYDIALOG (CrossCallInfo *pcci) /* no params; bool, text LPITEMIDLIST pidlReturn; BROWSEINFO bi; char *s; - char *initialptr; + LPARAM initialptr; char title[17] = "Select Directory\0"; - initialptr = (char *) pcci->p1; + initialptr = (LPARAM) pcci->p1; bi.hwndOwner = GetActiveWindow (); bi.pidlRoot = NULL; @@ -522,13 +540,13 @@ void EvalCcRqALTDIRECTORYDIALOG (CrossCallInfo *pcci) /* no params; bool, text CoTaskMemFree (pidlReturn); CoUninitialize (); // Uninitialise the COM library - MakeReturn2Cci (pcci, (int)TRUE, (int)s); + MakeReturn2Cci (pcci, TRUE, (size_t)s); /* and have the calling Clean function deallocate the directory name buffer. */ } else { CoUninitialize (); // Uninitialise the COM library - MakeReturn2Cci (pcci, (int)FALSE, (int)NULL); + MakeReturn2Cci (pcci, FALSE, (size_t)NULL); } } @@ -536,17 +554,17 @@ void EvalCcRqSHELLDEFAULT (CrossCallInfo *pcci) /* parentPtr, controlPtr, textPt { HWND hwndParent; /* The handle to the window. */ TOOLINFO ti; /* The tool information that is sent to the tooltip control. */ - char *file; - int verb,retn; + LPCTSTR file,verb; + HINSTANCE retn; rectTTId++; hwndParent = NULL;//GetActiveWindow();//ghMainWindow; - verb = (INT) pcci->p1; - file = (char *)pcci->p2; + verb = (LPCTSTR)pcci->p1; + file = (LPCTSTR)pcci->p2; - retn = (int)ShellExecute(hwndParent,verb,file,0,0,1); - MakeReturn1Cci (pcci,retn); + retn = ShellExecute(hwndParent,verb,file,0,0,1); + MakeReturn1Cci (pcci,(size_t)retn); } /* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121. diff --git a/Win/thread_message.c b/Win/thread_message.c index 840efc9..5051c9c 100644 --- a/Win/thread_message.c +++ b/Win/thread_message.c @@ -47,7 +47,7 @@ void install_compiler_result_handler (void) } int start_compiler_process (CleanString compiler_path,CleanString compiler_directory,CleanString command, - int *compiler_thread_id_p,int *compiler_thread_handle_p,int *compiler_process_handle_p) + int *compiler_thread_id_p,size_t *compiler_thread_handle_p,size_t *compiler_process_handle_p) { PSTR application_name,command_line,env,dir; STARTUPINFO si; @@ -107,7 +107,7 @@ int get_integers_from_message (int wm_number,int *i1_p,int *i2_p) #define PM_QS_POSTMESSAGE ((QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16) -int get_integers_from_thread_message (int wm_number,int thread_handle,int *i1_p,int *i2_p) +int get_integers_from_thread_message (int wm_number,size_t thread_handle,int *i1_p,int *i2_p) { MSG message; int r; @@ -139,7 +139,7 @@ int get_integers_from_thread_message (int wm_number,int thread_handle,int *i1_p, return r; } -int get_string_from_file_map_and_delete_map (int file_map,CleanString s) +int get_string_from_file_map_and_delete_map (size_t file_map,CleanString s) { int l,i; char *chars,*p; @@ -161,7 +161,7 @@ int get_string_from_file_map_and_delete_map (int file_map,CleanString s) return 1; } -int send_string_to_thread (int thread_id,int process_handle,int wm_number,CleanString s) +int send_string_to_thread (int thread_id,size_t process_handle,int wm_number,CleanString s) { HANDLE file_map,file_map2; char *chars,*p1; @@ -176,7 +176,7 @@ int send_string_to_thread (int thread_id,int process_handle,int wm_number,CleanS if (l==0 || chars[l-1]!='\0') return 0; - file_map=CreateFileMapping ((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE,0,l,NULL); + file_map=CreateFileMapping ((HANDLE)(-1),NULL,PAGE_READWRITE,0,l,NULL); if (file_map==NULL) return 0; -- GitLab