NO

Author Topic: Exception in pocc.exe  (Read 1357 times)

Offline HellOfMice

  • Member
  • *
  • Posts: 313
  • Never be pleased, always improve
Re: Exception in pocc.exe
« Reply #15 on: January 15, 2025, 04:02:33 AM »
Not for me >:(
--------------------------------
Kenavo

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2189
Re: Exception in pocc.exe
« Reply #16 on: January 16, 2025, 05:38:20 AM »
This code calls renamed pocc.exe as poccx.exe
An actual pocc.exe error code not even handled.
A poccx.exe have to have a full path to Pelles C bin folder.
Just a temporary solution to 24H2 problem
- rename original pocc.exe to poccx.exe
- copy fake pocc.exe to Pelles c bin folder
Code: [Select]
// pocc.c
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>

int __cdecl mainCRTStartup(void)
{
HANDLE hRead, hWrite;
SECURITY_ATTRIBUTES sa;
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD nRead, nWrite, nErr;
char *lpszCmdLine, *pChar;
char szProg[1024];
char szBuff[1024];

HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD nLen = GetModuleFileName(NULL, szProg, sizeof(szProg));
nLen -= 4;
lstrcpy(szProg+nLen, "x.exe");
OutputDebugString(szProg);
lpszCmdLine = GetCommandLine();
pChar = lpszCmdLine;
if (*pChar == '"') {
pChar++;
while (*pChar && *pChar != '"')
pChar++;
pChar++;
} else {
while (*pChar && *pChar != ' ')
pChar++;
}
while (*pChar == ' ')
pChar++;

OutputDebugString(pChar);
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
if (!CreatePipe(&hRead, &hWrite, &sa, 0)) {
// ERROR
} else {
si.cb = sizeof(STARTUPINFO);
GetStartupInfo(&si);
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.hStdOutput = hWrite;
si.hStdError = hWrite;
si.wShowWindow = SW_SHOW; //SW_HIDE;
si.lpReserved = NULL;
if (!CreateProcess(szProg, pChar, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
OutputDebugString("ERROR");
} else {
CloseHandle(hWrite);
WaitForSingleObject(pi.hProcess, 30000);
GetExitCodeProcess(pi.hProcess, &nErr);
//CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
while (TRUE) {
szBuff[0] = 0;
if (!ReadFile(hRead, szBuff, sizeof(szBuff)-1, &nRead, NULL))
break;
szBuff[nRead] = 0;
WriteFile(hStdOut, szBuff, nRead, &nWrite, NULL);
}
}
CloseHandle(hRead);
}

if (nErr == 0xC0000005) nErr = 0; // exception error
ExitProcess(nErr);
}
EDIT: fake poasm.exe too
« Last Edit: January 16, 2025, 12:09:11 PM by TimoVJL »
May the source be with you

Offline HellOfMice

  • Member
  • *
  • Posts: 313
  • Never be pleased, always improve
Re: Exception in pocc.exe
« Reply #17 on: January 16, 2025, 09:26:54 AM »
That seems a better solution than what I proposed. I will try. Thank You Timo


Philippe

--------------------------------
Kenavo

Offline HellOfMice

  • Member
  • *
  • Posts: 313
  • Never be pleased, always improve
Re: Exception in pocc.exe
« Reply #18 on: January 16, 2025, 10:32:19 AM »
Hi Timo


I have renamed the old pocc.exe to poccx.exe and unzipped yours.
I always have the error



> porc.exe -N "C:\Users\51966\Documents\DocsPhR\Assembleur\Awpe\Awpe.rc" -Fo"C:\Users\51966\Documents\DocsPhR\Assembleur\Awpe\Compile\Awpe.res"
Building Awpe.tag.
> pocc.exe -Tx64-coff -std:C2X -Zi -Ot -Ob1 -fp:precise -W1 -Gr -Ze -Zx -GX -J "C:\Users\51966\Documents\DocsPhR\Assembleur\Awpe\Create Dlg Sections.c" -Fo"C:\Users\51966\Documents\DocsPhR\Assembleur\Awpe\Compile\Create Dlg Sections.obj"
Building Awpe.tag.
> poasm.exe -AAMD64 -Zi -Gz -Fo"C:\Users\51966\Documents\DocsPhR\Assembleur\Awpe\Compile\Display Data Directories.obj" "C:\Users\51966\Documents\DocsPhR\Assembleur\Awpe\Display Data Directories.asm"
warning: Ignored in 64-bit mode: 'STDCALL'.
*** Error code: -1073741819 ***
Done.

--------------------------------
Kenavo

Offline HellOfMice

  • Member
  • *
  • Posts: 313
  • Never be pleased, always improve
Re: Exception in pocc.exe
« Reply #19 on: January 16, 2025, 10:36:41 AM »
Timo,


When the process exits could you return 0 if No errors found and just 1 if an error, like compiling, has been found.
It is for using ERRORLEVEL in a cmd file


If it is possible. I already ask to Pelle here in this forum.
--------------------------------
Kenavo

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2189
Re: Exception in pocc.exe
« Reply #20 on: January 16, 2025, 12:05:01 PM »
So you mean if exception don't happen, a real pocc.exe error code returned ?
Isn't it a bit useless thing with 24H2 ?
In working system fake pocc.exe don't even needed.
May the source be with you

Offline HellOfMice

  • Member
  • *
  • Posts: 313
  • Never be pleased, always improve
Re: Exception in pocc.exe
« Reply #21 on: January 16, 2025, 12:11:17 PM »
I can simulate a make


POCC Something.c
IF ERRORLEVEL 1 GOTO FINISHED
POASM Another.asm
IF ERRORLEVEL 1 GOTO FINISHED
POLINK ...
IF ERRORLEVEL 1 GOTO ERRORLINKER
MYPROGRAM.EXE
EXIT
:ERRORLINKER
ECHHO You are bad
:FINISHED
EXIT
--------------------------------
Kenavo

Offline alderman2

  • Member
  • *
  • Posts: 78
    • Xmag
Re: Exception in pocc.exe
« Reply #22 on: January 16, 2025, 01:04:52 PM »
This code calls renamed pocc.exe as poccx.exe
An actual pocc.exe error code not even handled.
A poccx.exe have to have a full path to Pelles C bin folder.
Just a temporary solution to 24H2 problem
- rename original pocc.exe to poccx.exe
- copy fake pocc.exe to Pelles c bin folder
Code: [Select]
// pocc.c
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>

int __cdecl mainCRTStartup(void)
{
HANDLE hRead, hWrite;
SECURITY_ATTRIBUTES sa;
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD nRead, nWrite, nErr;
char *lpszCmdLine, *pChar;
char szProg[1024];
char szBuff[1024];

HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD nLen = GetModuleFileName(NULL, szProg, sizeof(szProg));
nLen -= 4;
lstrcpy(szProg+nLen, "x.exe");
OutputDebugString(szProg);
lpszCmdLine = GetCommandLine();
pChar = lpszCmdLine;
if (*pChar == '"') {
pChar++;
while (*pChar && *pChar != '"')
pChar++;
pChar++;
} else {
while (*pChar && *pChar != ' ')
pChar++;
}
while (*pChar == ' ')
pChar++;

OutputDebugString(pChar);
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
if (!CreatePipe(&hRead, &hWrite, &sa, 0)) {
// ERROR
} else {
si.cb = sizeof(STARTUPINFO);
GetStartupInfo(&si);
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.hStdOutput = hWrite;
si.hStdError = hWrite;
si.wShowWindow = SW_SHOW; //SW_HIDE;
si.lpReserved = NULL;
if (!CreateProcess(szProg, pChar, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
OutputDebugString("ERROR");
} else {
CloseHandle(hWrite);
WaitForSingleObject(pi.hProcess, 30000);
GetExitCodeProcess(pi.hProcess, &nErr);
//CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
while (TRUE) {
szBuff[0] = 0;
if (!ReadFile(hRead, szBuff, sizeof(szBuff)-1, &nRead, NULL))
break;
szBuff[nRead] = 0;
WriteFile(hStdOut, szBuff, nRead, &nWrite, NULL);
}
}
CloseHandle(hRead);
}

if (nErr == 0xC0000005) nErr = 0; // exception error
ExitProcess(nErr);
}
EDIT: fake poasm.exe too
I renamed pocc.exe to poccXX.exe and added fake pocc.exe:
I get no error message and the exe file starts. But, my program does not change. I printed "kkkkk" in the program window before the change. After the change to fake pocc.exe, I changed the text to "xxxxx". When I compile I still get program window with "kkkkk".
I switched back to original pocc.exe and compiles. Now the program window opens with "xxxxx" printed.

Unfortunately, fake pocc.exe does not work correctly, but maybe it can be developed further ;)
I look forward to another test!

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2189
Re: Exception in pocc.exe
« Reply #23 on: January 16, 2025, 01:15:26 PM »
Unfortunately, fake pocc.exe does not work correctly, but maybe it can be developed further ;)
I look forward to another test!
rename orginal pocc.exe to poccx.exe

With DbgView.exe might be possible to see, if result of GetModuleFileName() and modification have a problem.
I don't use Program Files folder in testings.

Perhaps it's better, that MS develop 24H2 further  ;D

This code might be a problem with paths with spaces
Code: [Select]
DWORD nLen = GetModuleFileName(NULL, szProg, sizeof(szProg));
nLen -= 4;
lstrcpy(szProg+nLen, "x.exe");
OutputDebugString(szProg);
« Last Edit: January 16, 2025, 01:32:17 PM by TimoVJL »
May the source be with you

Offline HellOfMice

  • Member
  • *
  • Posts: 313
  • Never be pleased, always improve
Re: Exception in pocc.exe
« Reply #24 on: January 16, 2025, 02:06:55 PM »
I have a good solution, it runs, no reason too search for other soluce

I made change using a response file for linking


Whatever you do, find or don't find the key to solve the problem, there is a question behind, if Pelle does not come back?
Will us accept to find each time a solution, nice or not?


AMD compiler is free, on Linux and many AMD libraries. There is alsoa profiler like VTune.
Is it a solutiton?
« Last Edit: January 16, 2025, 02:13:42 PM by HellOfMice »
--------------------------------
Kenavo

Offline alderman2

  • Member
  • *
  • Posts: 78
    • Xmag
Re: Exception in pocc.exe
« Reply #25 on: January 16, 2025, 09:27:30 PM »
Unfortunately, fake pocc.exe does not work correctly, but maybe it can be developed further ;)
I look forward to another test!
rename orginal pocc.exe to poccx.exe

With DbgView.exe might be possible to see, if result of GetModuleFileName() and modification have a problem.
I don't use Program Files folder in testings.

Perhaps it's better, that MS develop 24H2 further  ;D

This code might be a problem with paths with spaces
Code: [Select]
DWORD nLen = GetModuleFileName(NULL, szProg, sizeof(szProg));
nLen -= 4;
lstrcpy(szProg+nLen, "x.exe");
OutputDebugString(szProg);
Have I understood correctly:
- Rename original pocc.exe to poccx.exe
- Place fake pocc.exe in the bin folder

Offline alderman2

  • Member
  • *
  • Posts: 78
    • Xmag
Re: Exception in pocc.exe
« Reply #26 on: January 16, 2025, 09:33:39 PM »
NOW IT WORKS!!
 ;D ;D ;D
I must have done something wrong last time (maybe spaces or something).

THANKS TimoVJL !!
« Last Edit: January 16, 2025, 09:35:26 PM by alderman2 »