summaryrefslogtreecommitdiff
path: root/Bpq32.c
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2026-09-29 21:39:24 +0100
committerDave Hibberd <hibby@debian.org>2026-09-29 21:39:24 +0100
commit592e5967b8fcd79423802071319d0c646f2080df (patch)
tree0eef3a28cfe1a939caf9d61e419a56d79b3c38e3 /Bpq32.c
parent23de03a0c8bf8a564cc0442f49d050ed11e372b8 (diff)
New upstream version 6.0.25.41+repackupstream/6.0.25.41+repack
Diffstat (limited to 'Bpq32.c')
-rw-r--r--Bpq32.c376
1 files changed, 182 insertions, 194 deletions
diff --git a/Bpq32.c b/Bpq32.c
index 3b5121f..5652e1f 100644
--- a/Bpq32.c
+++ b/Bpq32.c
@@ -1322,7 +1322,29 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// Change INP3 to XR 'standard' (29)
// Swap L4INDEX and L4ID in Packet Trace API (30)
// More INP3 fixes (30)
-
+// Starting NCMP implementation
+// Fix AGWAPI inbound connect for APPL Numbers above 1 (31)
+// More INP3 changes (enforce RIF refresh at hourly intervals and time out nodes (31)
+// Save, forward and display XR extended INP3 Options (31)
+// Check packets from APRS-IS against Exclude list (32)
+// Fix authorisation of Web Save Config File (32)
+// Add missing calls to va_end() (32)
+// Apply EXCLUDE to APRS and Digi (32)
+// Move background processing on Linux from the 100mS timer loop and run more frequently (33)
+// Fix sorting INP3 routes when TT is the same and hops differ (34)
+// Fix flawed calculation of inp3 TT percentage change on very low values to fix repeated sending of unchanged routes (34)
+// Change Web Driver windows to use Winsocks to give quicker refresh when changed (35)
+// Fix timer problem introduced in v33 (36)
+// Add LOCALNOTSECURE config param to require signin for web access from 127.0.0.1 (36)
+// Convert Web Terminal to winsocks (37)
+// More fixes for timer problem introduced in v33 (38)
+// Changes to INP3 poison reverse and alias reporting (39)
+// L4 Connect Ack now sent via routing table (39)
+// Debug info is now written to a log file rather than syslog (Linux) or Debugview (Windows) (40)
+// Backtrace now includes source file info and is written to Debug log (40)
+// Add Telnet Server config option "noWebSocks" to disable use of Websocks for Terminal and Driver windows (41)
+// Log outpur from running disconnect script (41)
+// Prevent Rigcontrol scan from changing frequency when PTT is active (41)
#define CKernel
@@ -1334,7 +1356,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
#include "time.h"
#include "stdio.h"
-#include <fcntl.h>
+#include <fcntl.h>
#include "compatbits.h"
#include "AsmStrucs.h"
@@ -1417,8 +1439,6 @@ void * HSMODEMExtInit(EXTPORTDATA * PortEntry);
void * FreeDataExtInit(EXTPORTDATA * PortEntry);
void * SIXPACKExtInit(EXTPORTDATA * PortEntry);
-VOID RealCloseAllPrograms();
-
extern char * ConfigBuffer; // Config Area
VOID REMOVENODE(dest_list * DEST);
DllExport int ConvFromAX25(unsigned char * incall,unsigned char * outcall);
@@ -1431,6 +1451,7 @@ void initADSB();
int CloseAllSessions();
int CloseAllLinks();
void NETROMTCPResolve();
+DllExport VOID APIENTRY CloseDebugLog();
extern BOOL ADIFLogEnabled;
@@ -1538,7 +1559,7 @@ int _C_Q_ADD(VOID *PQ, VOID *PBUFF, char * File, int Line);
VOID SetWindowTextSupport();
int WritetoConsoleSupport(char * buff);
VOID PMClose();
-VOID MySetWindowText(HWND hWnd, char * Msg);
+VOID MySetWindowText(struct TNCINFO * TNC, HWND hWnd, char * Msg);
BOOL CreateMonitorWindow(char * MonSize);
VOID FormatTime3(char * Time, time_t cTime);
void * zalloc(int len);
@@ -1563,8 +1584,8 @@ extern char ReportDest[7];
extern UCHAR ConfigDirectory[260];
+DllExport VOID __cdecl Debugprintf(const char * format, ...);
-VOID __cdecl Debugprintf(const char * format, ...);
VOID __cdecl Consoleprintf(const char * format, ...);
DllExport int APIENTRY CloseBPQ32();
@@ -1701,15 +1722,13 @@ VOID * _Q_REM(VOID *Q, char * File, int Line);
UINT ReleaseBuffer(UINT *BUFF);
-VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime );
-
DllExport int APIENTRY DeallocateStream(int stream);
int VECTORLENGTH = sizeof (struct _BPQVECSTRUC);
int FirstEntry = 1;
BOOL CloseLast = TRUE; // If the user started BPQ32.exe, don't close it when other programs close
-BOOL Closing = FALSE; // Set if Close All called - prevents respawning bpq32.exe
+extern BOOL Closing = FALSE; // Set if Close All called - prevents respawning bpq32.exe
BOOL BPQ32_EXE; // Set if Process is running BPQ32.exe. Not initialised.
// Used to Kill surplus BPQ32.exe processes
@@ -1775,8 +1794,6 @@ int interval;
VOID CALLBACK SetupTermSessions(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime);
-
-TIMERPROC lpTimerFunc = (TIMERPROC) TimerProc;
TIMERPROC lpSetupTermSessions = (TIMERPROC) SetupTermSessions;
@@ -1813,6 +1830,9 @@ int needADSB = 0;
extern int AGWPort;
+extern time_t NOW; // From time()
+
+
Tell_Sessions();
@@ -1826,15 +1846,13 @@ void LoadToolHelperRoutines()
{
HINSTANCE ExtDriver=0;
int err;
- char msg[100];
ExtDriver=LoadLibrary("kernel32.dll");
if (ExtDriver == NULL)
{
err=GetLastError();
- sprintf(msg,"BPQ32 Error loading kernel32.dll - Error code %d\n", err);
- OutputDebugString(msg);
+ Debugprintf("BPQ32 Error loading kernel32.dll - Error code %d", err);
return;
}
@@ -1845,8 +1863,7 @@ void LoadToolHelperRoutines()
if (CreateToolHelp32SnapShotPtr == 0)
{
err=GetLastError();
- sprintf(msg,"BPQ32 Error getting CreateToolhelp32Snapshot entry point - Error code %d\n", err);
- OutputDebugString(msg);
+ Debugprintf("BPQ32 Error getting CreateToolhelp32Snapshot entry point - Error code %d\n", err);
return;
}
}
@@ -1865,8 +1882,8 @@ BOOL GetProcess(int ProcessID, char * Program)
hProcessSnap = (HANDLE)CreateToolHelp32SnapShotPtr(TH32CS_SNAPPROCESS, 0);
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
- OutputDebugString( "CreateToolhelp32Snapshot (of processes) Failed\n" );
- return( FALSE );
+ Debugprintf("CreateToolhelp32Snapshot (of processes) Failed\n" );
+ return( FALSE );
}
// Set the size of the structure before using it.
@@ -1876,7 +1893,7 @@ BOOL GetProcess(int ProcessID, char * Program)
// and exit if unsuccessful
if( !Process32Firstptr( hProcessSnap, &pe32 ) )
{
- OutputDebugString( "Process32First Failed\n" ); // Show cause of failure
+ Debugprintf( "Process32First Failed" ); // Show cause of failure
CloseHandle( hProcessSnap ); // Must clean up the snapshot object!
return( FALSE );
}
@@ -1924,7 +1941,7 @@ BOOL IsProcess(int ProcessID)
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
- OutputDebugString( "CreateToolhelp32Snapshot (of processes) Failed\n" );
+ Debugprintf( "CreateToolhelp32Snapshot (of processes) Failed" );
return(TRUE); // Don't know, so assume ok
}
@@ -1932,7 +1949,7 @@ BOOL IsProcess(int ProcessID)
if( !Process32Firstptr( hProcessSnap, &pe32 ) )
{
- OutputDebugString( "Process32First Failed\n" ); // Show cause of failure
+ Debugprintf( "Process32First Failed" ); // Show cause of failure
CloseHandle( hProcessSnap ); // Must clean up the snapshot object!
return(TRUE); // Don't know, so assume ok
}
@@ -1997,8 +2014,8 @@ VOID CheckforLostProcesses()
{
// Process has died - Treat as a detach
- sprintf(Log,"BPQ32 Process %d Died\n", ProcessID);
- OutputDebugString(Log);
+ sprintf(Log,"BPQ32 Process %d Died", ProcessID);
+ Debugprintf(Log);
// Remove Tray Icon Entry
@@ -2007,8 +2024,7 @@ VOID CheckforLostProcesses()
if (PIDArray[i] == ProcessID)
{
hWndArray[i] = 0;
- sprintf(Log,"BPQ32 Removing Tray Item %s\n", PopupText[i]);
- OutputDebugString(Log);
+ Debugprintf(Log,"BPQ32 Removing Tray Item %s", PopupText[i]);
DeleteMenu(trayMenu,TRAYBASEID+i,MF_BYCOMMAND);
}
}
@@ -2017,7 +2033,7 @@ VOID CheckforLostProcesses()
if (Semaphore.Flag == 1 && ProcessID == Semaphore.SemProcessID)
{
- OutputDebugString("BPQ32 Process was holding Semaphore - attempting recovery\r\n");
+ Debugprintf("BPQ32 Process was holding Semaphore - attempting recovery");
Debugprintf("Last Sem Call %d %x %x %x %x %x %x", SemHeldByAPI,
Sem_eax, Sem_ebx, Sem_ecx, Sem_edx, Sem_esi, Sem_edi);
@@ -2039,7 +2055,7 @@ VOID CheckforLostProcesses()
TimerHandle=0;
TimerInst=0xffffffff;
// Tell_Sessions();
- OutputDebugString("BPQ32 Process was running timer \n");
+ Debugprintf("BPQ32 Process was running timer");
if (MinimizetoTray)
Shell_NotifyIcon(NIM_DELETE,&niData);
@@ -2079,7 +2095,7 @@ VOID MonitorTimerThread(int x)
if (Semaphore.Flag == 1 && TimerInst == Semaphore.SemProcessID)
{
- OutputDebugString("BPQ32 Process was holding Semaphore - attempting recovery\r\n");
+ Debugprintf("BPQ32 Process was holding Semaphore - attempting recovery");
Debugprintf("Last Sem Call %d %x %x %x %x %x %x", SemHeldByAPI,
Sem_eax, Sem_ebx, Sem_ecx, Sem_edx, Sem_esi, Sem_edi);
Semaphore.Flag = 0;
@@ -2100,7 +2116,7 @@ VOID MonitorTimerThread(int x)
if (Closing == FALSE && AttachingProcess == FALSE)
{
- OutputDebugString("BPQ32 Reloading BPQ32.exe\n");
+ Debugprintf("BPQ32 Reloading BPQ32.exe");
StartBPQ32();
}
@@ -2113,38 +2129,24 @@ VOID MonitorTimerThread(int x)
VOID WritetoTraceSupport(struct TNCINFO * TNC, char * Msg, int Len);
-VOID TimerProcX();
+VOID * _Q_REM_NP(VOID *PQ, char * File, int Line);
-VOID CALLBACK TimerProc(
- HWND hwnd, // handle of window for timer messages
- UINT uMsg, // WM_TIMER message
- UINT idEvent, // timer identifier
- DWORD dwTime) // current system time
-{
- KillTimer(NULL,TimerHandle);
- TimerProcX();
- TimerHandle = SetTimer(NULL,0,100,lpTimerFunc);
-}
-VOID TimerProcX()
-{
- struct _EXCEPTION_POINTERS exinfo;
+#define Q_REM_NP(s) _Q_REM_NP(s, __FILE__, __LINE__)
- //
- // Get semaphore before proceeeding
- //
-
- GetSemaphore(&Semaphore, 2);
+void Semaphored100msCode()
+{
+ // code that doesn't need to run every tick - run every 100 mS
+ // Runs under semaphore
- // Get time since last run
+ if (IPActive) Poll_IP();
+ if (PMActive) Poll_PM();
+ if (RigActive) Rig_Poll();
+ if (APRSActive)Poll_APRS();
- QueryPerformanceCounter(&currentTime);
+ if (NeedWebMailRefresh)
+ DoRefreshWebMailIndex();
- interval = (int)(currentTime.QuadPart - lastRunTime.QuadPart) / ticksPerMillisec;
- lastRunTime.QuadPart = currentTime.QuadPart;
-
- //Debugprintf("%d", interval);
-
- // Process WINMORTraceQ
+ CheckWL2KReportTimer();
while (WINMORTraceQ)
{
@@ -2162,15 +2164,11 @@ VOID TimerProcX()
while (WritetoConsoleQ)
{
- UINT * Buffer = Q_REM(&WritetoConsoleQ);
+ UINT * Buffer = Q_REM_NP(&WritetoConsoleQ);
WritetoConsoleSupport((char *)&Buffer[2]);
- RelBuff(Buffer);
+ free(Buffer);
}
- strcpy(EXCEPTMSG, "Timer ReconfigProcessing");
-
- __try
- {
if (trayMenu == NULL)
SetupTrayIcon();
@@ -2200,7 +2198,7 @@ VOID TimerProcX()
SetupBPQDirectory();
WritetoConsole("Reconfiguring ...\n\n");
- OutputDebugString("BPQ32 Reconfiguring ...\n");
+ Debugprintf("BPQ32 Reconfiguring ...");
GetWindowRect(FrameWnd, &FRect);
@@ -2240,7 +2238,7 @@ VOID TimerProcX()
Consoleprintf("G8BPQ AX25 Packet Switch System Version %s %s", TextVerstring, Datestring);
Consoleprintf(VerCopyright);
-
+
Start();
NETROMTCPResolve();
@@ -2260,10 +2258,10 @@ VOID TimerProcX()
if (HOSTVEC->HOSTSESSION !=0)
{
// Had a connection
-
+
HOSTVEC->HOSTSESSION=0;
HOSTVEC->HOSTFLAGS |=3; // Disconnected
-
+
PostMessage(HOSTVEC->HOSTHANDLE, BPQMsg, i, 4);
}
}
@@ -2273,7 +2271,7 @@ VOID TimerProcX()
APPL_Q = 0;
OpenReportingSockets();
-
+
WritetoConsole("\n\nReconfiguration Complete\n");
if (IPRequired) IPActive = Init_IP();
@@ -2298,7 +2296,7 @@ VOID TimerProcX()
InvalidateRect(hConsWnd, NULL, TRUE);
RigActive = Rig_Init();
-
+
if (NUMBEROFTNCPORTS)
{
FreeSemaphore(&Semaphore);
@@ -2309,8 +2307,8 @@ VOID TimerProcX()
FreeSemaphore(&Semaphore);
AGWActive = AGWAPIInit();
GetSemaphore(&Semaphore, 0);
-
- OutputDebugString("BPQ32 Reconfiguration Complete\n");
+
+ Debugprintf("BPQ32 Reconfiguration Complete");
}
}
@@ -2326,7 +2324,7 @@ VOID TimerProcX()
Rig_Close();
Sleep(6000); // Allow any CATPTT, HAMLIB and FLRIG threads to close
RigActive = Rig_Init();
-
+
WritetoConsole("Rigcontrol Reconfiguration Complete\n");
}
}
@@ -2340,87 +2338,49 @@ VOID TimerProcX()
APRSReconfigFlag = FALSE;
APRSClose();
APRSActive = Init_APRS();
-
+
WritetoConsole("APRS Reconfiguration Complete\n");
}
}
+}
- }
- #include "StdExcept.c"
-
- if (Semaphore.Flag && Semaphore.SemProcessID == GetCurrentProcessId())
- FreeSemaphore(&Semaphore);
-
- }
-
- strcpy(EXCEPTMSG, "Timer Processing");
-
- __try
- {
- if (IPActive) Poll_IP();
- if (PMActive) Poll_PM();
- if (RigActive) Rig_Poll();
-
- if (NeedWebMailRefresh)
- DoRefreshWebMailIndex();
-
- CheckGuardZone();
-
- if (APRSActive)
- {
- Poll_APRS();
- CheckGuardZone();
- }
-
- CheckWL2KReportTimer();
+DllExport VOID APIENTRY RealCloseAllPrograms();
- CheckGuardZone();
-
- TIMERINTERRUPT();
- CheckGuardZone();
+VOID UnSemaphored100msCode()
+{
+ // code that doesn't need to run every tick - run every 100 mS
+ // Runs without semaphore
- FreeSemaphore(&Semaphore); // SendLocation needs to get the semaphore
+ if (NUMBEROFTNCPORTS)
+ TNCTimer();
- if (NUMBEROFTNCPORTS)
- TNCTimer();
+ if (AGWActive)
+ Poll_AGW();
- if (AGWActive)
- Poll_AGW();
+ DRATSPoll();
+ RHPPoll();
- DRATSPoll();
- RHPPoll();
+ CheckGuardZone();
- CheckGuardZone();
+ strcpy(EXCEPTMSG, "HTTP Timer Processing");
- strcpy(EXCEPTMSG, "HTTP Timer Processing");
+ HTTPTimer();
- HTTPTimer();
+ CheckGuardZone();
- CheckGuardZone();
+ strcpy(EXCEPTMSG, "WL2K Report Timer Processing");
- strcpy(EXCEPTMSG, "WL2K Report Timer Processing");
+ if (ReportTimer)
+ {
+ ReportTimer--;
- if (ReportTimer)
- {
- ReportTimer--;
-
- if (ReportTimer == 0)
- {
- ReportTimer = REPORTINTERVAL;
- SendLocation();
- }
+ if (ReportTimer == 0)
+ {
+ ReportTimer = REPORTINTERVAL;
+ SendLocation();
}
}
-
- #include "StdExcept.c"
-
- if (Semaphore.Flag && Semaphore.SemProcessID == GetCurrentProcessId())
- FreeSemaphore(&Semaphore);
-
- }
-
- CheckGuardZone();
if (CloseAllTimer == 50) // First entry
{
@@ -2435,7 +2395,7 @@ VOID TimerProcX()
if (CloseAllTimer == 40) // First entry
CloseAllLinks(); // No sessions closed so close links now
-
+
if (CloseAllTimer)
{
// See if any links left
@@ -2468,9 +2428,9 @@ VOID TimerProcX()
if(CloseAllTimer == 0)
RealCloseAllPrograms();
}
- return;
}
+
HANDLE NPHandle;
int (WINAPI FAR *GetModuleFileNameExPtr)() = NULL;
@@ -2557,7 +2517,7 @@ FirstInit()
_beginthread(MonitorThread,0,0);
- TimerHandle=SetTimer(NULL,0,100,lpTimerFunc);
+// TimerHandle=SetTimer(NULL,0,100,lpTimerFunc);
TimerInst=GetCurrentProcessId();
SessHandle = SetTimer(NULL, 0, 5000, lpSetupTermSessions);
@@ -2566,7 +2526,7 @@ FirstInit()
if (ADIFLogEnabled)
ADIFWriteFreqList();
- OutputDebugString("BPQ32 Port Initialisation Complete\n");
+ Debugprintf("BPQ32 Port Initialisation Complete");
if (needAIS)
initAIS();
@@ -2579,6 +2539,30 @@ FirstInit()
int Check_Timer()
{
+ if (FirstInitDone == 0)
+ {
+ GetSemaphore(&Semaphore, 3);
+
+ if (_stricmp(pgm, "bpq32.exe") == 0)
+ {
+ FirstInit();
+ FreeSemaphore(&Semaphore);
+ if (NUMBEROFTNCPORTS)
+ InitializeTNCEmulator();
+
+ AGWActive = AGWAPIInit();
+ FirstInitDone=1; // Only init in BPQ32.exe
+ return 0;
+ }
+ else
+ {
+ FreeSemaphore(&Semaphore);
+ return 0;
+ }
+ }
+
+ return 0;
+
if (Closing)
return 0;
@@ -2629,7 +2613,7 @@ int Check_Timer()
}
GetSemaphore(&Semaphore, 3);
- OutputDebugString("BPQ32 Reinitialising External Ports and Attaching Timer\n");
+ Debugprintf("BPQ32 Reinitialising External Ports and Attaching Timer");
if (!ProcessConfig())
{
@@ -2740,7 +2724,6 @@ int Check_Timer()
else
ShowWindow(FrameWnd, SW_RESTORE);
- TimerHandle=SetTimer(NULL,0,100,lpTimerFunc);
TimerInst=GetCurrentProcessId();
SessHandle = SetTimer(NULL, 0, 5000, lpSetupTermSessions);
@@ -2778,9 +2761,6 @@ Tell_Sessions()
BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReserved)
{
- DWORD n;
- char buf[350];
-
int i;
unsigned int ProcessID;
@@ -2946,7 +2926,7 @@ BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReser
if (Mutex != NULL)
{
- OutputDebugString("Another BPQ32.dll is loaded\n");
+ Debugprintf("Another BPQ32.dll is loaded");
i=MessageBox(NULL,"BPQ32 DLL already loaded from another directory\nIf you REALLY want this, hit OK, else hit Cancel","BPQ32",MB_OKCANCEL);
FreeSemaphore(&Semaphore);
@@ -3020,7 +3000,7 @@ BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReser
if (Mutex != NULL)
{
- OutputDebugString("Another BPQ32.dll is loaded\n");
+ Debugprintf("Another BPQ32.dll is loaded");
MessageBox(NULL,"BPQ32 DLL already loaded from another directory","BPQ32",MB_ICONSTOP);
FreeSemaphore(&Semaphore);
return (0);
@@ -3080,15 +3060,15 @@ SkipInit:
_beginthread(MonitorTimerThread,0,0);
- FreeSemaphore(&Semaphore);
-
AttachedPIDList[AttachedProcesses++] = GetCurrentProcessId();
if (_stricmp(pgm,"bpq32.exe") == 0 && AttachingProcess == 1) AttachingProcess = 0;
GetProcess(GetCurrentProcessId(),pgm);
- n=sprintf(buf,"BPQ32 DLL Attach complete - Program %s - %d Process(es) Attached\n",pgm,AttachedProcesses);
- OutputDebugString(buf);
+ Debugprintf("BPQ32 DLL Attach complete - Program %s - %d Process(es) Attached\n",pgm,AttachedProcesses);
+
+ FreeSemaphore(&Semaphore);
+
// Set up local variables
@@ -3145,10 +3125,7 @@ SkipInit:
{
if (PIDArray[i] == ProcessID)
{
- char Log[80];
hWndArray[i] = 0;
- sprintf(Log,"BPQ32 Removing Tray Item %s\n", PopupText[i]);
- OutputDebugString(Log);
DeleteMenu(trayMenu,TRAYBASEID+i,MF_BYCOMMAND);
}
}
@@ -3172,7 +3149,7 @@ SkipInit:
{
PEXTPORTDATA PORTVEC=(PEXTPORTDATA)PORTTABLE;
- OutputDebugString("BPQ32 Process with Timer closing\n");
+ Debugprintf("BPQ32 Process with Timer closing\n");
// Call Port Close Routines
@@ -3218,7 +3195,7 @@ SkipInit:
if (AttachedProcesses && Closing == FALSE && AttachingProcess == 0) // Other processes
{
- OutputDebugString("BPQ32 Reloading BPQ32.exe\n");
+ Debugprintf("BPQ32 Reloading BPQ32.exe\n");
StartBPQ32();
}
}
@@ -3267,13 +3244,42 @@ SkipInit:
}
GetProcess(GetCurrentProcessId(),pgm);
- n=sprintf(buf,"BPQ32 DLL Detach complete - Program %s - %d Process(es) Attached\n",pgm,AttachedProcesses);
- OutputDebugString(buf);
+ Debugprintf("BPQ32 DLL Detach complete - Program %s - %d Process(es) Attached\n",pgm,AttachedProcesses);
return 1;
}
return 1;
}
+DllExport int APIENTRY RunBPQ32Background()
+{
+ // Called every 10 Ms or so from BPQ32.EXE
+
+ // Get time since last run
+
+ QueryPerformanceCounter(&currentTime);
+
+ interval = (int)(currentTime.QuadPart - lastRunTime.QuadPart) / ticksPerMillisec;
+ lastRunTime.QuadPart = currentTime.QuadPart;
+
+
+ GetSemaphore(&Semaphore, 2);
+
+ if (TIMERINTERRUPT()) // Calls BG code and slower timer routines
+ {
+ // 100 mS has elapsed
+
+ NOW = time(NULL);
+
+ Semaphored100msCode();
+ FreeSemaphore(&Semaphore);
+ UnSemaphored100msCode();
+ }
+ else
+ FreeSemaphore(&Semaphore);
+
+
+ return 1;
+}
DllExport int APIENTRY CloseBPQ32()
{
@@ -3285,7 +3291,7 @@ DllExport int APIENTRY CloseBPQ32()
if (Semaphore.Flag == 1 && ProcessID == Semaphore.SemProcessID)
{
- OutputDebugString("BPQ32 Process holding Semaphore called CloseBPQ32 - attempting recovery\r\n");
+ Debugprintf("BPQ32 Process holding Semaphore called CloseBPQ32 - attempting recovery\r\n");
Debugprintf("Last Sem Call %d %x %x %x %x %x %x", SemHeldByAPI,
Sem_eax, Sem_ebx, Sem_ecx, Sem_edx, Sem_esi, Sem_edi);
@@ -3295,7 +3301,7 @@ DllExport int APIENTRY CloseBPQ32()
if (TimerInst == ProcessID)
{
- OutputDebugString("BPQ32 Process with Timer called CloseBPQ32\n");
+ Debugprintf("BPQ32 Process with Timer called CloseBPQ32\n");
if (MinimizetoTray)
Shell_NotifyIcon(NIM_DELETE,&niData);
@@ -3336,7 +3342,7 @@ DllExport int APIENTRY CloseBPQ32()
if (AttachedProcesses > 1 && Closing == FALSE && AttachingProcess == 0) // Other processes
{
- OutputDebugString("BPQ32 Reloading BPQ32.exe\n");
+ Debugprintf("BPQ32 Reloading BPQ32.exe\n");
StartBPQ32();
}
}
@@ -3505,11 +3511,11 @@ if (_winver < 0x0600)
sprintf(msg,"BPQ32 Ver %s Loaded from: %s by %s\n", VersionString, DLLName, pgm);
WritetoConsole(msg);
- OutputDebugString(msg);
- FormatTime3(Time, time(NULL));
+ Debugprintf(msg);
+ FormatTime3(Time, NOW);
sprintf(msg,"Loaded %s\n", Time);
WritetoConsole(msg);
- OutputDebugString(msg);
+ Debugprintf(msg);
#pragma warning(push)
#pragma warning(disable : 4996)
@@ -3526,12 +3532,12 @@ if (_winver < 0x0600)
#pragma warning(pop)
WritetoConsole(msg);
- OutputDebugString(msg);
+ Debugprintf(msg);
i=sprintf(msg,"BPQ32 Using config from: %s\n\n",BPQDirectory);
WritetoConsole(&msg[6]);
msg[i-1]=0;
- OutputDebugString(msg);
+ Debugprintf(msg);
// Don't write the Version Key if loaded by regsvr32.exe (Installer is running with Admin rights,
// so will write the wrong tree on )
@@ -3565,8 +3571,6 @@ HANDLE OpenConfigFile(char *fn)
UCHAR Value[MAX_PATH];
FILETIME LastWriteTime;
SYSTEMTIME Time;
- char Msg[256];
-
// If no directory, use current
if (BPQDirectory[0] == 0)
@@ -3591,11 +3595,9 @@ HANDLE OpenConfigFile(char *fn)
GetFileTime(handle, NULL, NULL, &LastWriteTime);
FileTimeToSystemTime(&LastWriteTime, &Time);
- sprintf(Msg,"BPQ32 Config File %s Created %.2d:%.2d %d/%.2d/%.2d\n", Value,
+ Debugprintf("BPQ32 Config File %s Created %.2d:%.2d %d/%.2d/%.2d\n", Value,
Time.wHour, Time.wMinute, Time.wYear, Time.wMonth, Time.wDay);
- OutputDebugString(Msg);
-
return(handle);
}
@@ -4652,7 +4654,7 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
}
wsprintf(Title,"BPQ32 Beacon Configuration");
- MySetWindowText(UIhWnd, Title);
+ MySetWindowText(0, UIhWnd, Title);
ShowWindow(UIhWnd, SW_NORMAL);
OnTabbedDialogInit(UIhWnd); // Set up pages
@@ -5347,7 +5349,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
wsprintf(Title,"BPQ32 Beacon Utility Version");
- MySetWindowText(UIhWnd, Title);
+ MySetWindowText(0, UIhWnd, Title);
return 0;
}
@@ -5546,24 +5548,23 @@ DllExport int APIENTRY WritetoConsole(char * buff)
DllExport VOID * APIENTRY GetBuff();
+int C_Q_ADD_NP(VOID *PQ, VOID *PBUFF);
+
int WritetoConsoleLocal(char * buff)
{
int len=strlen(buff);
UINT * buffptr;
- if (Semaphore.Flag == 0)
- return WritetoConsoleSupport(buff);
-
- buffptr = GetBuff();
+ buffptr = (UINT *)zalloc(512);
if (buffptr == 0) // No buffers, so send direct
- return WritetoConsoleSupport(buff);
+ return 0;
if (len > 300)
len = 300;
memcpy(&buffptr[2], buff, len + 1);
- C_Q_ADD(&WritetoConsoleQ, buffptr);
+ C_Q_ADD_NP(&WritetoConsoleQ, buffptr);
return 0;
}
@@ -5600,7 +5601,7 @@ int WritetoConsoleSupport(char * buff)
DllExport VOID APIENTRY BPQOutputDebugString(char * String)
{
- OutputDebugString(String);
+ Debugprintf(String);
return;
}
@@ -5667,7 +5668,7 @@ BOOLEAN CheckifBPQ32isLoaded()
{
if (AttachingProcess == 0) // Already starting BPQ32
{
- OutputDebugString("BPQ32 No other bpq32 programs running - Loading BPQ32.exe\n");
+ Debugprintf("BPQ32 No other bpq32 programs running - Loading BPQ32.exe");
StartBPQ32();
}
return FALSE;
@@ -5764,7 +5765,7 @@ BOOLEAN StartBPQ32()
strcat(Errbuff,Value);
strcat(Errbuff," failed ");
strcat(Errbuff,buff);
- OutputDebugString(Errbuff);
+ Debugprintf(Errbuff);
AttachingProcess = 0;
return FALSE;
}
@@ -5822,18 +5823,6 @@ DllExport VOID * APIENTRY GetBuff()
}
-VOID __cdecl Debugprintf(const char * format, ...)
-{
- char Mess[10000];
- va_list(arglist);
-
- va_start(arglist, format);
- vsprintf(Mess, format, arglist);
- strcat(Mess, "\r\n");
- OutputDebugString(Mess);
-
- return;
-}
unsigned short int compute_crc(unsigned char *buf, int txlen);
@@ -6096,7 +6085,7 @@ DllExport VOID APIENTRY CloseAllPrograms()
ShowWindow(hwndClosing, SW_SHOW);
}
-VOID RealCloseAllPrograms()
+DllExport VOID APIENTRY RealCloseAllPrograms()
{
hookNodeClosing("Shutdown");
Sleep(500);
@@ -6349,7 +6338,6 @@ DllExport BOOL APIENTRY SaveReg(char * KeyIn, HANDLE hFile)
{
if (len > 76)
{
- len += sprintf(&RegLine[len], "\\\r\n", RegLine);
strcat(RegLine, "\\\r\n");
WriteFile(hFile, RegLine, len, &written, NULL);
strcpy(RegLine, " ");