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

port to 64 bit windows

parent 25b4f1c3
......@@ -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<n; ++i)
p[i]=0;
}
#endif
// Create standard handles, try to start child from command line.
......@@ -135,7 +146,11 @@ BOOL StartChildProcess(LPCSTR lpszCmdLine, BOOL bShowChildWindow)
hProcess = GetCurrentProcess();
// Set up the security attributes struct.
#ifdef _WIN64
my_zero_memory (&sa,sizeof(SECURITY_ATTRIBUTES));
#else
ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
#endif
sa.nLength= sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
......@@ -324,7 +339,11 @@ HANDLE PrepAndLaunchRedirectedChild(LPCSTR lpszCmdLine,
// Set up the start up info struct.
STARTUPINFO si;
#ifdef _WIN64
my_zero_memory (&si, sizeof(STARTUPINFO));
#else
ZeroMemory(&si, sizeof(STARTUPINFO));
#endif
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
si.hStdOutput = hStdOut;
......@@ -489,12 +508,21 @@ static int ProcessThread()
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.
int WriteChildStdIn(LPCSTR lpszInput)
{
DWORD nBytesWrote;
DWORD Length = strlen(lpszInput);
DWORD Length = my_strlen(lpszInput);
if (m_hStdInWrite != NULL && Length > 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;
......
......@@ -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.
......
......@@ -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;
......
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