Commit 7f0e5769 authored by John van Groningen's avatar John van Groningen
Browse files

port to 64 bit windows

parent 25b4f1c3
...@@ -109,6 +109,17 @@ BOOL WINAPI IsWinNT() ...@@ -109,6 +109,17 @@ BOOL WINAPI IsWinNT()
return TRUE; 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<n; ++i)
p[i]=0;
}
#endif
// Create standard handles, try to start child from command line. // Create standard handles, try to start child from command line.
...@@ -135,7 +146,11 @@ BOOL StartChildProcess(LPCSTR lpszCmdLine, BOOL bShowChildWindow) ...@@ -135,7 +146,11 @@ BOOL StartChildProcess(LPCSTR lpszCmdLine, BOOL bShowChildWindow)
hProcess = GetCurrentProcess(); hProcess = GetCurrentProcess();
// Set up the security attributes struct. // Set up the security attributes struct.
#ifdef _WIN64
my_zero_memory (&sa,sizeof(SECURITY_ATTRIBUTES));
#else
ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES)); ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
#endif
sa.nLength= sizeof(SECURITY_ATTRIBUTES); sa.nLength= sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL; sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE; sa.bInheritHandle = TRUE;
...@@ -324,7 +339,11 @@ HANDLE PrepAndLaunchRedirectedChild(LPCSTR lpszCmdLine, ...@@ -324,7 +339,11 @@ HANDLE PrepAndLaunchRedirectedChild(LPCSTR lpszCmdLine,
// Set up the start up info struct. // Set up the start up info struct.
STARTUPINFO si; STARTUPINFO si;
#ifdef _WIN64
my_zero_memory (&si, sizeof(STARTUPINFO));
#else
ZeroMemory(&si, sizeof(STARTUPINFO)); ZeroMemory(&si, sizeof(STARTUPINFO));
#endif
si.cb = sizeof(STARTUPINFO); si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
si.hStdOutput = hStdOut; si.hStdOutput = hStdOut;
...@@ -489,12 +508,21 @@ static int ProcessThread() ...@@ -489,12 +508,21 @@ static int ProcessThread()
return 0; return 0;
} }
int my_strlen (const char *s)
{
int l;
for (l = 0; s[l]!='\0'; l++)
;
return l;
}
// Function that write to the child stdin. // Function that write to the child stdin.
int WriteChildStdIn(LPCSTR lpszInput) int WriteChildStdIn(LPCSTR lpszInput)
{ {
DWORD nBytesWrote; DWORD nBytesWrote;
DWORD Length = strlen(lpszInput); DWORD Length = my_strlen(lpszInput);
if (m_hStdInWrite != NULL && Length > 0) if (m_hStdInWrite != NULL && Length > 0)
{ {
if (!WriteFile(m_hStdInWrite, lpszInput, Length, &nBytesWrote, NULL)) if (!WriteFile(m_hStdInWrite, lpszInput, Length, &nBytesWrote, NULL))
...@@ -543,7 +571,11 @@ BOOL AddMainWindowHook (BOOL dummy) ...@@ -543,7 +571,11 @@ BOOL AddMainWindowHook (BOOL dummy)
{ {
if (g_pWndProc == NULL) 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); g_pWndProc = (WNDPROC)SetWindowLong(ghMainWindow,GWL_WNDPROC,(LPARAM)SubClassWndProc);
#endif
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
......
...@@ -42,7 +42,7 @@ void EvalCcRqSETWINDOWICON (CrossCallInfo *pcci) ...@@ -42,7 +42,7 @@ void EvalCcRqSETWINDOWICON (CrossCallInfo *pcci)
hIcon = LoadIcon ((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(idIcon)); 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); MakeReturn0Cci (pcci);
} }
...@@ -116,6 +116,7 @@ PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBmp) ...@@ -116,6 +116,7 @@ PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBmp)
return pbmi; return pbmi;
} }
#if 0
char *CreateBMPFile(PBITMAPINFO pbi, HBITMAP hBMP) char *CreateBMPFile(PBITMAPINFO pbi, HBITMAP hBMP)
{ {
BITMAPFILEHEADER hdr; // bitmap file-header BITMAPFILEHEADER hdr; // bitmap file-header
...@@ -195,6 +196,7 @@ char *CreateBMPFile(PBITMAPINFO pbi, HBITMAP hBMP) ...@@ -195,6 +196,7 @@ char *CreateBMPFile(PBITMAPINFO pbi, HBITMAP hBMP)
GlobalFree((HGLOBAL)lpBits); GlobalFree((HGLOBAL)lpBits);
return sf; return sf;
} }
#endif
void EvalCcRqGETBITMAPRESOURCE (CrossCallInfo *pcci) void EvalCcRqGETBITMAPRESOURCE (CrossCallInfo *pcci)
{ {
...@@ -215,12 +217,12 @@ void EvalCcRqGETBITMAPRESOURCE (CrossCallInfo *pcci) ...@@ -215,12 +217,12 @@ void EvalCcRqGETBITMAPRESOURCE (CrossCallInfo *pcci)
if (hBitmap == 0) { if (hBitmap == 0) {
MakeReturn4Cci (pcci, 0, 0, 0, 0); MakeReturn4Cci (pcci, 0, 0, 0, 0);
return; return;
}; };
pbi = CreateBitmapInfoStruct(hBitmap); pbi = CreateBitmapInfoStruct(hBitmap);
// data = CreateBMPFile(pbi, 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); GlobalFree(pbi);
return; return;
/* /*
...@@ -237,7 +239,7 @@ void EvalCcRqGETBITMAPRESOURCE (CrossCallInfo *pcci) ...@@ -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; HANDLE hBitmap;
char* data; char* data;
...@@ -260,12 +262,16 @@ void WinGetBitmapResource(int idBitmap, int intoolbox, int *outbitmap, int *widt ...@@ -260,12 +262,16 @@ void WinGetBitmapResource(int idBitmap, int intoolbox, int *outbitmap, int *widt
*width = pbi->bmiHeader.biWidth; *width = pbi->bmiHeader.biWidth;
*height = pbi->bmiHeader.biHeight; *height = pbi->bmiHeader.biHeight;
GlobalFree(pbi); GlobalFree(pbi);
*outbitmap = hBitmap; *outbitmap = (size_t)hBitmap;
*outtoolbox = intoolbox; *outtoolbox = intoolbox;
return; 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) static UINT APIENTRY DirectorySelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
#endif
{ {
if (uiMsg == BFFM_INITIALIZED) if (uiMsg == BFFM_INITIALIZED)
{ {
...@@ -275,7 +281,11 @@ static UINT APIENTRY DirectorySelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam ...@@ -275,7 +281,11 @@ static UINT APIENTRY DirectorySelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam
return 0; 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) static UINT APIENTRY FileSelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
#endif
{ {
if (uiMsg == WM_INITDIALOG) if (uiMsg == WM_INITDIALOG)
{ {
...@@ -286,9 +296,9 @@ static UINT APIENTRY FileSelectorHook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPA ...@@ -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); x = (GetSystemMetrics (SM_CXSCREEN)>>1) - ((rect.right-rect.left)>>1);
y = (GetSystemMetrics (SM_CYSCREEN)>>1) - ((rect.bottom-rect.top)>>1); y = (GetSystemMetrics (SM_CYSCREEN)>>1) - ((rect.bottom-rect.top)>>1);
SetWindowPos (hdlg, NULL, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); SetWindowPos (hdlg, NULL, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
if ((lParam != NULL) && (((LPOPENFILENAME)lParam)->lCustData != NULL)) if (lParam!=0 && ((LPOPENFILENAME)lParam)->lCustData!=0)
SendMessage(GetParent(hdlg),CDM_SETCONTROLTEXT,IDOK,((LPOPENFILENAME)lParam)->lCustData); SendMessage(GetParent(hdlg),CDM_SETCONTROLTEXT,IDOK,((LPOPENFILENAME)lParam)->lCustData);
} }
return 0; return 0;
...@@ -364,7 +374,11 @@ void EvalCcRqALTFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textp ...@@ -364,7 +374,11 @@ void EvalCcRqALTFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textp
} }
else else
{ {
#ifdef _WIN64
ofn.lStructSize = sizeof (OPENFILENAME_NT4);
#else
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
#endif
} }
ofn.hwndOwner = GetActiveWindow (); ofn.hwndOwner = GetActiveWindow ();
...@@ -389,7 +403,7 @@ void EvalCcRqALTFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textp ...@@ -389,7 +403,7 @@ void EvalCcRqALTFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textp
// | OFN_ENABLEHOOK; // PA: OFN_ENABLEHOOK added from Ronny // | OFN_ENABLEHOOK; // PA: OFN_ENABLEHOOK added from Ronny
ofn.lpstrDefExt = NULL; ofn.lpstrDefExt = NULL;
ofn.lCustData = NULL; ofn.lCustData = (LPARAM)NULL;
ofn.lpfnHook = &FileSelectorHook; // PA: &FileSelectorHook instead of NULL from Ronny ofn.lpfnHook = &FileSelectorHook; // PA: &FileSelectorHook instead of NULL from Ronny
ofn.lpTemplateName = NULL; ofn.lpTemplateName = NULL;
#if (_WIN32_WINNT >= 0x0500) #if (_WIN32_WINNT >= 0x0500)
...@@ -402,12 +416,12 @@ void EvalCcRqALTFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textp ...@@ -402,12 +416,12 @@ void EvalCcRqALTFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textp
if (success) 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 */ /* and have the calling clean function deallocate the filename buffer */
} }
else else
{ {
MakeReturn2Cci (pcci, success, (int) NULL); MakeReturn2Cci (pcci, success, (size_t) NULL);
rfree (ofn.lpstrFile); rfree (ofn.lpstrFile);
} }
} }
...@@ -437,7 +451,11 @@ void EvalCcRqALTFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; boo ...@@ -437,7 +451,11 @@ void EvalCcRqALTFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; boo
} }
else else
{ {
#ifdef _WIN64
ofn.lStructSize = sizeof (OPENFILENAME_NT4);
#else
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
#endif
} }
ofn.hwndOwner = GetActiveWindow (); ofn.hwndOwner = GetActiveWindow ();
...@@ -470,7 +488,7 @@ void EvalCcRqALTFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; boo ...@@ -470,7 +488,7 @@ void EvalCcRqALTFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; boo
okptr = NULL; /* the calling clean function will okptr = NULL; /* the calling clean function will
deallocate the memory allocated deallocate the memory allocated
for this empty string */ for this empty string */
ofn.lCustData = okptr; ofn.lCustData = (LPARAM) okptr;
ofn.lpfnHook = &FileSelectorHook; // PA: &FileSelectorHook instead of NULL from Ronny ofn.lpfnHook = &FileSelectorHook; // PA: &FileSelectorHook instead of NULL from Ronny
ofn.lpTemplateName = NULL; ofn.lpTemplateName = NULL;
#if (_WIN32_WINNT >= 0x0500) #if (_WIN32_WINNT >= 0x0500)
...@@ -483,12 +501,12 @@ void EvalCcRqALTFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; boo ...@@ -483,12 +501,12 @@ void EvalCcRqALTFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; boo
if (success) 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 */ /* and have the calling clean function deallocate the filename buffer */
} }
else else
{ {
MakeReturn2Cci (pcci, success, (int) NULL); MakeReturn2Cci (pcci, success, (size_t) NULL);
rfree (ofn.lpstrFile); rfree (ofn.lpstrFile);
} }
} }
...@@ -499,10 +517,10 @@ void EvalCcRqALTDIRECTORYDIALOG (CrossCallInfo *pcci) /* no params; bool, text ...@@ -499,10 +517,10 @@ void EvalCcRqALTDIRECTORYDIALOG (CrossCallInfo *pcci) /* no params; bool, text
LPITEMIDLIST pidlReturn; LPITEMIDLIST pidlReturn;
BROWSEINFO bi; BROWSEINFO bi;
char *s; char *s;
char *initialptr; LPARAM initialptr;
char title[17] = "Select Directory\0"; char title[17] = "Select Directory\0";
initialptr = (char *) pcci->p1; initialptr = (LPARAM) pcci->p1;
bi.hwndOwner = GetActiveWindow (); bi.hwndOwner = GetActiveWindow ();
bi.pidlRoot = NULL; bi.pidlRoot = NULL;
...@@ -522,13 +540,13 @@ void EvalCcRqALTDIRECTORYDIALOG (CrossCallInfo *pcci) /* no params; bool, text ...@@ -522,13 +540,13 @@ void EvalCcRqALTDIRECTORYDIALOG (CrossCallInfo *pcci) /* no params; bool, text
CoTaskMemFree (pidlReturn); CoTaskMemFree (pidlReturn);
CoUninitialize (); // Uninitialise the COM library 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. */ /* and have the calling Clean function deallocate the directory name buffer. */
} }
else else
{ {
CoUninitialize (); // Uninitialise the COM library 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 ...@@ -536,17 +554,17 @@ void EvalCcRqSHELLDEFAULT (CrossCallInfo *pcci) /* parentPtr, controlPtr, textPt
{ {
HWND hwndParent; /* The handle to the window. */ HWND hwndParent; /* The handle to the window. */
TOOLINFO ti; /* The tool information that is sent to the tooltip control. */ TOOLINFO ti; /* The tool information that is sent to the tooltip control. */
char *file; LPCTSTR file,verb;
int verb,retn; HINSTANCE retn;
rectTTId++; rectTTId++;
hwndParent = NULL;//GetActiveWindow();//ghMainWindow; hwndParent = NULL;//GetActiveWindow();//ghMainWindow;
verb = (INT) pcci->p1; verb = (LPCTSTR)pcci->p1;
file = (char *)pcci->p2; file = (LPCTSTR)pcci->p2;
retn = (int)ShellExecute(hwndParent,verb,file,0,0,1); retn = ShellExecute(hwndParent,verb,file,0,0,1);
MakeReturn1Cci (pcci,retn); MakeReturn1Cci (pcci,(size_t)retn);
} }
/* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121. /* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121.
......
...@@ -47,7 +47,7 @@ void install_compiler_result_handler (void) ...@@ -47,7 +47,7 @@ void install_compiler_result_handler (void)
} }
int start_compiler_process (CleanString compiler_path,CleanString compiler_directory,CleanString command, 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; PSTR application_name,command_line,env,dir;
STARTUPINFO si; STARTUPINFO si;
...@@ -107,7 +107,7 @@ int get_integers_from_message (int wm_number,int *i1_p,int *i2_p) ...@@ -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) #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; MSG message;
int r; int r;
...@@ -139,7 +139,7 @@ int get_integers_from_thread_message (int wm_number,int thread_handle,int *i1_p, ...@@ -139,7 +139,7 @@ int get_integers_from_thread_message (int wm_number,int thread_handle,int *i1_p,
return r; 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; int l,i;
char *chars,*p; char *chars,*p;
...@@ -161,7 +161,7 @@ int get_string_from_file_map_and_delete_map (int file_map,CleanString s) ...@@ -161,7 +161,7 @@ int get_string_from_file_map_and_delete_map (int file_map,CleanString s)
return 1; 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; HANDLE file_map,file_map2;
char *chars,*p1; char *chars,*p1;
...@@ -176,7 +176,7 @@ int send_string_to_thread (int thread_id,int process_handle,int wm_number,CleanS ...@@ -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') if (l==0 || chars[l-1]!='\0')
return 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) if (file_map==NULL)
return 0; return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment