NO

Author Topic: PEStripW and .dbg file  (Read 4071 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1981
PEStripW and .dbg file
« on: August 20, 2010, 12:36:25 pm »
PellesC IDE debugger support .dbg files.

With this tool you can take away debug information from exe

Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <imagehlp.h>

#pragma lib "imagehlp.lib"

TCHAR szAppName[] = "PEStripW";
/*
BOOL SplitSymbols(PSTR ImageName, PSTR SymbolsPath, PSTR SymbolFilePath, DWORD Flags);
SPLITSYM_EXTRACT_ALL, SPLITSYM_REMOVE_PRIVATE, SPLITSYM_SYMBOLPATH_IS_SRC
*/

int LastError(HWND hWnd)
{
LPVOID lpMsgBuf;
 
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);

// Display the string.
MessageBox( hWnd, lpMsgBuf, szAppName, MB_OK|MB_ICONERROR );

// Free the buffer.
LocalFree( lpMsgBuf );
return 0;
}

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
{
int nLen;
TCHAR szTmp[260], szDbgFile[260];

if (!*lpCmdLine) {
MessageBox(0, TEXT("usage: PEStrip.exe file"), szAppName, MB_OK);
return 1;
}
//wsprintf(szDbgFile, "%s.dbg", lpCmdLine);
lstrcpy(szDbgFile, lpCmdLine);
nLen = lstrlen(szDbgFile);
lstrcpy(&szDbgFile[nLen-3], TEXT("dbg"));
if (SplitSymbols(lpCmdLine, NULL, szDbgFile, SPLITSYM_EXTRACT_ALL)) {
wsprintf(szTmp, TEXT("%s stripped to %s"), lpCmdLine, szDbgFile);
MessageBox(0, szTmp, szAppName, MB_OK);
} else {
//wsprintf(szTmp, "%s: Error %d", lpCmdLine, GetLastError());
//MessageBox(0, szTmp, szAppName, MB_OK | MB_ICONERROR);
LastError(0);
}
return 0;
}
« Last Edit: August 20, 2010, 01:57:47 pm by timovjl »
May the source be with you

saliha

  • Guest
Re: PEStripW and .dbg file
« Reply #1 on: February 26, 2011, 08:59:42 am »
To generate a .DBG file in this format, you can use REBASE.EXE, which is provided with the Win32 SDK.
Please see the Win32 SDK documentation for more details.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1981
Re: PEStripW and .dbg file
« Reply #2 on: February 26, 2011, 09:10:44 am »
PellesC have porebase.exe for that too.
May the source be with you