Remover “Copia de Evaluación” de Windows 7 RC7100

Primero que todo tengo que agradecer a deepxw por compartir el codigo fuente del programa para remover el famoso “watermark” ó “Copia de Evaluación”

*///////////////////////////////////////////////// /////////////////////////////////////////////////

#include “stdafx.h” # include “stdafx.h”
#include “RemoveWatermark.h” # include “RemoveWatermark.h”
#include <windows.h> # include <windows.h>
#include <Imagehlp.h> # include <Imagehlp.h>
#include <shlwapi.h> # include <shlwapi.h>

#pragma comment(lib, “ImageHlp.lib” ) # pragma comment (lib, “ImageHlp.lib”)
#pragma comment(lib, “Version.lib”) # pragma comment (lib, “Version.lib”)
#pragma comment(lib, “shlwapi.lib”) # pragma comment (lib, “shlwapi.lib”)

// / /
// Using the Strsafe.h Functions / / Uso de la Strsafe.h Funciones
// / /
#define STRSAFE_LIB     // use the functions in library form # define STRSAFE_LIB / / utilizar las funciones en forma de biblioteca
#include <strsafe.h> # include <strsafe.h>
// / /

// / /
// Variables / / Variables
// / /

HANDLE  m_hConsole;    // Handle of console MANGO m_hConsole / / Asa de consola

// / /
// Functions / / Funciones
// / /

// Get the PE file version info / / Obtener la información de versión del archivo PE
BOOL GetDllFileVersion(LPCTSTR lpszFileName, PMYVERSIONINFO pVersionInfo); BOOL GetDllFileVersion (LPCTSTR lpszFileName, PMYVERSIONINFO pVersionInfo);

// Get watermark string from user32.dll.mui / / Obtener agua cadena de user32.dll.mui
BOOL GetWatermarkFromMuiFile(LPTSTR pszFile); BOOL GetWatermarkFromMuiFile (LPTSTR pszFile);

// Load string from resource with special langID / / Cadena de carga de los recursos, con especial langID
BOOL LoadStringExx( BOOL LoadStringExx (
HINSTANCE hInst,   // Hinstance of lib HINSTANCE hInst, / / HInstance de lib
WORD wLangID,    // Language ID of resource PALABRA wLangID, / / ID de recursos de idiomas
PRES_STRING_INFO pInfo  // Pointer to the string info PRES_STRING_INFO pInfo / / Puntero a la cadena de información
); );

// Zero watermark string From Mui File / / Cero agua cadena de Mui Archivo
BOOL ZeroWatermarkFromMuiFile( BOOL ZeroWatermarkFromMuiFile (
LPCTSTR pszFile,      // The MUI file name LPCTSTR pszFile, / / El nombre de archivo MUI
PSINGLE_LIST_ENTRY pStringsHead  // Pointer to the string info PSINGLE_LIST_ENTRY pStringsHead / / Puntero a la cadena de información
); );

// Moves the cursor to x, y in console window / / Mueve el cursor a la x, y en la ventana de la consola
void gotoX(SHORT x); vacío gotoX (CORTO x);

////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////
// / /
// Main entry / / Entrada principal
// / /
int _tmain(int argc, _TCHAR* argv[]) int _tmain (int argc, _TCHAR * argv [])
{ (
SetConsoleTitle(_T(“Remove Watermark Demo  (Code by deepxw)”)); SetConsoleTitle (_T ( “Eliminar agua Demo (Código de deepxw )”));

_tcprintf(_T(“Notice:\n”)); _tcprintf (_T ( “Aviso: \ n”));
_tcprintf(_T(“  This program is not a full function tool, it’s only a demo for programer!\n\n”)); _tcprintf (_T ( “Este programa no es una completa herramienta de función, es sólo una demostración de programador! \ n \ n”));

// get handle of current console / / Obtener de la actual consola de manejar
m_hConsole = GetStdHandle(STD_OUTPUT_HANDLE); m_hConsole = GetStdHandle (STD_OUTPUT_HANDLE);

// Get Watermark string / / Obtener la cadena de agua
// GetWatermarkFromMuiFile(_T(“b:\\user32.dll.mui”)); / / GetWatermarkFromMuiFile (_T ( “b: \ \ user32.dll.mui”));

// / /
// Check args / / Check args
// / /

if (argc == 2) if (argc == 2)
{ (
// Get Watermark string / / Obtener la cadena de agua
GetWatermarkFromMuiFile(argv[1]); GetWatermarkFromMuiFile (argv [1]);
} )
else algo más
{ (
_tcprintf(_T(“Usage:\n”)); _tcprintf (_T ( “Uso: \ n”));
_tcprintf(_T(“  RemoveWatermark   MuiFileName\n”)); _tcprintf (_T ( “RemoveWatermark MuiFileName \ n”));
} )

getchar(); getchar ();

return 0; return 0;
} )

/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// /////////////////////////////////////////////////
// / /
// Get watermark string from user32.dll.mui / / Obtener agua cadena de user32.dll.mui
/* / *
715,  “%wsWindows %ws” 715, “%% wsWindows fue”
716,  “%ws Build %ws” 716, “Construcción%% se fue”
717,  “Evaluation copy.” 717, “copia de evaluación”.
718,  “For testing purposes only.” 718, “Para propósitos de prueba solamente.”
723,  “%wsMicrosoft (R) Windows (R) (Build %ws: %ws)” 723, “% wsMicrosoft (R) Windows (R) (% fue Construye:% era)”
737,  “This copy of Windows is not genuine” 737, “Esta copia de Windows no es original”
738,  “Test Mode” 738, “Test Mode”
*/ * /
BOOL GetWatermarkFromMuiFile(LPTSTR pszFile) BOOL GetWatermarkFromMuiFile (LPTSTR pszFile)
{ (
_tcprintf(_T(“File name:\t%s\n”), pszFile); _tcprintf (_T ( “Nombre de archivo: \ t% s \ n”), pszFile);

if (!PathFileExists(pszFile)) if (! PathFileExists (pszFile))
{ (
_tcprintf(_T(“File not found!\n”)); _tcprintf (_T ( “Archivo no encontrado! \ n”));
return FALSE; return false;
} )

// / /
// Check file version, we need to get the language ID of the mui file. / / Comprobar la versión del archivo, tenemos que obtener el identificador de idioma de la mui archivo.
// / /

MYVERSIONINFO vi; MYVERSIONINFO vi;

ZeroMemory(&vi, sizeof(MYVERSIONINFO)); ZeroMemory (y vi, sizeof (MYVERSIONINFO));
vi.dwSize = sizeof(MYVERSIONINFO); vi.dwSize = sizeof (MYVERSIONINFO);
if (!GetDllFileVersion(pszFile, &vi)) if (! GetDllFileVersion (pszFile, y vi))
{ (
_tcprintf(_T(“Fail to get file version info!\n”)); _tcprintf (_T ( “Fail versión del archivo para obtener información! \ n”));
return FALSE; return false;
} )

_tcprintf(_T(“File version:\t%s\n”), vi.szShortVersion); _tcprintf (_T ( “Versión del archivo: \ t% s \ n”), vi.szShortVersion);

// / /
// Load mui file to memory / / Carga de archivos en la memoria mui
// / /

HINSTANCE  hInstLib  = NULL; HINSTANCE hInstLib = NULL;

hInstLib = LoadLibraryEx(pszFile, NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE); hInstLib = LoadLibraryEx (pszFile, NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
if( NULL == hInstLib ) if (hInstLib == NULL)
{ (
_tcprintf(_T(“Fail to open file user32.dll.mui!\n”)); _tcprintf (_T ( “rechazo a abrir el archivo user32.dll.mui! \ n”));
return FALSE; return false;
} )

// / /
// Get file type / / Obtener tipo de archivo
// / /

PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER)((DWORD_PTR)hInstLib – 1); PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER) ((DWORD_PTR) hInstLib – 1);
PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS) (pDOSHeader->e_lfanew + (DWORD_PTR)pDOSHeader); PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS) (pDOSHeader-> e_lfanew + (DWORD_PTR) pDOSHeader);

_tcprintf(_T(“File type:\t”)); _tcprintf (_T ( “Tipo de archivo: \ t”));
switch (pNTHeader->FileHeader.Machine) switch (pNTHeader-> FileHeader.Machine)
{ (
case IMAGE_FILE_MACHINE_I386: IMAGE_FILE_MACHINE_I386 caso:
_tcprintf(_T(“x86″)); _tcprintf (_T ( “x86″));
break; break;
case IMAGE_FILE_MACHINE_AMD64: IMAGE_FILE_MACHINE_AMD64 caso:
_tcprintf(_T(“x64″)); _tcprintf (_T ( “x64″));
break; break;
case IMAGE_FILE_MACHINE_IA64: IMAGE_FILE_MACHINE_IA64 caso:
_tcprintf(_T(“ia64″)); _tcprintf (_T ( “ia64″));
break; break;

default: por defecto:
_tcprintf(_T(“Unknown\nThis is not a valid file.\n”)); _tcprintf (_T ( “desconocido \ nEste no es un archivo válido. \ n”));

FreeLibrary(hInstLib); FreeLibrary (hInstLib);
return FALSE; return false;
} )

UINT  uStringID; UStringID UINT;
INT  uStringIDS[] = {715, 716, 717, 718, 738, 723, 737}; UINT uStringIDS [] = (715, 716, 717, 718, 738, 723, 737);
BOOL  bHasPatched  = FALSE; BOOL bHasPatched = FALSE;
UINT  i    = 0; UINT i = 0;
UINT  uMatchingString = 0; UINT uMatchingString = 0;

// Create string info lists / / Crear listas de cadena de información
SINGLE_LIST_ENTRY StringsHead; SINGLE_LIST_ENTRY StringsHead;
PSINGLE_LIST_ENTRY psLink; PSINGLE_LIST_ENTRY PSLINK;
PRES_STRING_INFO pStrInfo; PRES_STRING_INFO pStrInfo;

StringsHead.Next = NULL; StringsHead.Next = NULL;

_tcprintf(_T(“\n\n   ID  String                                                Offset  Len Mod”)); _tcprintf (_T ( “\ n \ n Cadena ID Offset Len Mod.”));
_tcprintf(  _T(“\n—–  —————————————————-  ——  — —”)); _tcprintf (_T ( “\ n —– ————————————– ————– —— — —”));

for (i=0; i < sizeof(uStringIDS)/sizeof(UINT); i++) for (i = 0; i <sizeof (uStringIDS) / sizeof (UINT); i + +)
{ (
// Add a entry / / Añadir una entrada
pStrInfo = (PRES_STRING_INFO)MALLOC(sizeof(RES_STRING_INFO)); pStrInfo = (PRES_STRING_INFO) malloc (sizeof (RES_STRING_INFO));
ZeroMemory(pStrInfo, sizeof(RES_STRING_INFO)); ZeroMemory (pStrInfo, sizeof (RES_STRING_INFO));

pStrInfo->uStringID = uStringIDS[i]; pStrInfo-> uStringID = uStringIDS [i];

LoadStringExx(hInstLib, (WORD)vi.wLangID, pStrInfo); LoadStringExx (hInstLib, (WORD) vi.wLangID, pStrInfo);

if (lstrlen(pStrInfo->pszText) > 0) if (lstrlen (pStrInfo-> pszText)> 0)
{ (
uMatchingString++; uMatchingString + +;
} )

_tcprintf(_T(“\n%5d  %s”), pStrInfo->uStringID, pStrInfo->pszText); _tcprintf (_T ( “\ n% 5d% s”), pStrInfo-> uStringID, pStrInfo-> pszText);
gotoX(61); gotoX (61);
_tcprintf(_T(“0x%4X  %3d”), pStrInfo->dwFileOffset, pStrInfo->dwBytes); _tcprintf (_T ( “0x% 4X% 3D”), pStrInfo-> dwFileOffset, pStrInfo-> dwBytes);

PushEntryList(&StringsHead, &(pStrInfo->link)); PushEntryList (& StringsHead, & (pStrInfo-> enlace));

} // for(i) ) / / For (i)

// importance / / Importancia
FreeLibrary(hInstLib); FreeLibrary (hInstLib);

_tcprintf(_T(“\n\n”)); _tcprintf (_T ( “\ n \ n”));

if ( (uMatchingString > 0) && (StringsHead.Next != NULL) ) if ((uMatchingString> 0) & & (StringsHead.Next! = NULL))
{ (
_tcprintf(_T(“Do you want to patch this file?\n”)); _tcprintf (_T ( “¿Quieres parche este archivo? \ n”));
_tcprintf(_T(” (Y=Yes  /  N=No)\n:”)); _tcprintf (_T ( “(Y = Sí / N = n) \ n :”));

int iChoice = getchar(); int iChoice = getchar ();

if ( (iChoice == _T(‘y’)) || (iChoice == _T(‘Y’)) ) if ((iChoice == _T ( ‘y’)) | | (iChoice == _T ( ‘Y’)))
{ (
TCHAR szFileBackup[MAX_PATH]; TCHAR szFileBackup [MAX_PATH];

StringCbCopy(szFileBackup, sizeof(szFileBackup), pszFile); StringCbCopy (szFileBackup, sizeof (szFileBackup), pszFile);
StringCbCat(szFileBackup, sizeof(szFileBackup), _T(“.backup”)); StringCbCat (szFileBackup, sizeof (szFileBackup), _T ( “. Copia de seguridad”));

// make a backup / / Hacer una copia de seguridad
CopyFile(pszFile, szFileBackup, FALSE); CopyFile (pszFile, szFileBackup, FALSE);

// In real life, if you want to patch \windows\system32\en-us\user32.dll.mui, / / En la vida real, si quieres parche \ windows \ system32 \ es-es \ user32.dll.mui,
// because the file is in using, you must copy a temp file to do ZeroWatermarkFromMuiFile(). / / Porque el archivo está en uso, debe copiar un archivo temporal para hacer ZeroWatermarkFromMuiFile ().
// Last, using MoveFileEx() to replace the file. / / Por último, utilizando MoveFileEx () para reemplazar el archivo.

if (ZeroWatermarkFromMuiFile(pszFile, &StringsHead)) if (ZeroWatermarkFromMuiFile (pszFile, y StringsHead))
{ (
_tcprintf(_T(“\nPatch OK!\n”)); _tcprintf (_T ( “\ nPatch OK! \ n”));
} )
else algo más
{ (
_tcprintf(_T(“\nFail to patch.\n”)); _tcprintf (_T ( “\ nFail a revisión. \ n”));
} )

} // choice y ) / / Elección y
} )
else algo más
{ (
_tcprintf(_T(“Watermark string is not found, no need to patch.\n”)); _tcprintf (_T ( “cadena de agua no se encuentra, sin necesidad de parches. \ n”));
} )

// / /
// Removes all string infos, free memory / / Elimina todos los infos cadena, memoria libre
// / /
psLink = PopEntryList(&StringsHead); PSLINK PopEntryList = (& StringsHead);
while(psLink) while (PSLINK)
{ (
pStrInfo = CONTAINING_RECORD(psLink, RES_STRING_INFO, link); pStrInfo = CONTAINING_RECORD (PSLINK, RES_STRING_INFO, enlace);

// free memory / / Liberar memoria
if (pStrInfo->pszText) if (pStrInfo-> pszText)
FREE((LPVOID)(pStrInfo->pszText)); LIBRE ((LPVOID) (pStrInfo-> pszText));

FREE((LPVOID)pStrInfo); LIBRE ((LPVOID) pStrInfo);

// Removes the first entry / / Elimina la primera entrada
psLink = PopEntryList(&StringsHead); PSLINK PopEntryList = (& StringsHead);

} // while(psLink) ) / / While (PSLINK)

return TRUE; return TRUE;

} // GetWatermarkFromMuiFile ) / / GetWatermarkFromMuiFile

////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////
// / /
// Load string from resource with special langID / / Cadena de carga de los recursos, con especial langID
// / /
BOOL LoadStringExx( BOOL LoadStringExx (
HINSTANCE hInst,   // Hinstance of lib HINSTANCE hInst, / / HInstance de lib
WORD wLangID,    // Language ID of resource PALABRA wLangID, / / ID de recursos de idiomas
PRES_STRING_INFO pInfo  // Pointer to the string info PRES_STRING_INFO pInfo / / Puntero a la cadena de información
) )

{ (
HRSRC   hFindRes;  // Handle of the resources has been found HRSRC hFindRes / / Asa de los recursos se ha encontrado
HGLOBAL   hLoadRes;  // Handle of the resources has been loaded HGLOBAL hLoadRes / / Asa de los recursos se ha cargado
LPVOID   pRes;   // Pointer to the resources LPVOID presión; / / Puntero a los recursos
UINT   nBlockID;  // String block ID UINT nBlockID / / bloque de cadenas de identificación

pInfo->dwFileOffset = 0;  // String offset in the file pInfo-> dwFileOffset = 0; / / Cadena de compensar en el archivo
pInfo->dwBytes  = 0;  // String length, in bytes pInfo-> dwBytes = 0; / / longitud de la cadena, en bytes
pInfo->pszText  = NULL; pInfo-> pszText = NULL;

nBlockID = pInfo->uStringID / 16 + 1; = nBlockID pInfo-> uStringID / 16 + 1;

__try __try
{ (
// find the string block / / Encontrar la cadena de bloque
hFindRes = FindResourceEx(hInst, RT_STRING, MAKEINTRESOURCE(nBlockID), wLangID); hFindRes = FindResourceEx (hInst, RT_STRING, MAKEINTRESOURCE (nBlockID), wLangID);
if(!hFindRes ) if (! hFindRes)
{ (
__leave; __leave;
} )

hLoadRes = LoadResource(hInst, hFindRes); hLoadRes = LoadResource (hInst, hFindRes);
if(!hLoadRes ) if (! hLoadRes)
{ (
__leave; __leave;
} )

pRes = LockResource(hLoadRes); = presión LockResource (hLoadRes);
if(!pRes ) if (! PRES)
{ (
__leave; __leave;
} )

WCHAR*  pParse  = (WCHAR *)pRes;    // Pointer to the String block WCHAR * pParse = (WCHAR *) presión; / / Puntero a la cadena de bloque
UINT  nIndex  = pInfo->uStringID % 16;  // Calculate the string index UINT nIndex = pInfo-> uStringID% 16 / / Calcular el índice de la cadena
int   nLen; int nLen;
UINT  i; UINT i;

// 16 strings per block / / 16 cuerdas por bloque
for( i = 0; i < (nIndex & 15); i++ ) for (i = 0; i <(nIndex y 15); i + +)
{ (
pParse += 1 + (int)*pParse; pParse + = 1 + (int) * pParse;
} )

// OK, we get it / / OK, tenemos que
nLen = (UINT)*pParse;  // The length of the target string. nLen = (UINT) * pParse; / / La longitud de la cadena objetivo.
pParse += 1;    // Pointer to the target string pParse + = 1; / / Puntero a la cadena objetivo

// Main point, calculate the string offset / / Punto principal, el cálculo de la cadena compensar
pInfo->dwFileOffset = (DWORD) ( (DWORD_PTR)pParse – (DWORD_PTR)hInst ) + 1; pInfo-> dwFileOffset = (DWORD) ((DWORD_PTR) pParse – (DWORD_PTR) hInst) + 1;
pInfo->dwBytes  = nLen * sizeof(WCHAR); pInfo-> dwBytes = nLen * sizeof (WCHAR);

// allocate memory / / Asignar memoria
pInfo->pszText = (LPWSTR)MALLOC((nLen + 1) * sizeof(WCHAR)); pInfo-> pszText = (LPWSTR) malloc ((nLen + 1) * sizeof (WCHAR));
if (!pInfo->pszText) if (! pInfo-> pszText)
__leave; __leave;

// copy string for return / / Copiar la cadena de retorno
CopyMemory((LPVOID)pInfo->pszText, (LPVOID)pParse, pInfo->dwBytes); CopyMemory ((LPVOID) pInfo-> pszText, (LPVOID) pParse, pInfo-> dwBytes);
*(PWCHAR)((DWORD_PTR)pInfo->pszText + pInfo->dwBytes) = 0; * (PWCHAR) ((DWORD_PTR) pInfo-> pszText + pInfo-> dwBytes) = 0;

//TRACEF(_T(“String ID: %5d \t%s”), pszText); / / TRACEF (_T ( “Cadena de ID:% 5d \ t% s”), pszText);

} )
__finally __finally
{ (
// Clean up, free memory / / Limpiar, memoria libre

if (pRes) si (PRES)
UnlockResource(pRes); UnlockResource (PRES);

if (hFindRes) if (hFindRes)
FreeResource(hFindRes); FreeResource (hFindRes);
} )

// if pointer is null, we return a NULL string / / Si el puntero es nulo, volvemos una cadena NULL
if (!pInfo->pszText) if (! pInfo-> pszText)
{ (
pInfo->pszText  = (LPWSTR)MALLOC(sizeof(WCHAR)); pInfo-> pszText = (LPWSTR) malloc (sizeof (WCHAR));
pInfo->pszText[0] = 0; pInfo-> pszText [0] = 0;
} )

return TRUE; return TRUE;

} // LoadStringExx() ) / / LoadStringExx ()

///////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// /
// / /
// Zero watermark string From Mui File / / Cero agua cadena de Mui Archivo
// / /
// In order to make the procedure simple, so use the simplest method. / / A fin de que el procedimiento de simple, así que use el método más simple.
// / /
BOOL ZeroWatermarkFromMuiFile( BOOL ZeroWatermarkFromMuiFile (
LPCTSTR pszFile,      // The MUI file name LPCTSTR pszFile, / / El nombre de archivo MUI
PSINGLE_LIST_ENTRY pStringsHead  // Pointer to the string info PSINGLE_LIST_ENTRY pStringsHead / / Puntero a la cadena de información
) )
{ (
BOOL    bRet   = FALSE; BOOL bret = FALSE;

HANDLE    hFile   = NULL; MANGO hFile = NULL;
HANDLE    hMapping  = NULL; MANGO hMapping = NULL;
PUCHAR    pView   = NULL; Puchar pView = NULL;
PIMAGE_NT_HEADERS pNTHeader  = NULL; PIMAGE_NT_HEADERS pNTHeader = NULL;
PIMAGE_DOS_HEADER pDOSHeader  = NULL; PIMAGE_DOS_HEADER pDOSHeader = NULL;
DWORD    dwHeaderSum  = 0; DWORD dwHeaderSum = 0;
DWORD    dwCorrectSum = 0; DWORD dwCorrectSum = 0;
DWORD    dwFileSize  = 0; DWORD dwFileSize = 0;

__try __try
{ (
// Open file / / Abrir el archivo
hFile = CreateFile(pszFile, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); hFile = CreateFile (pszFile, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (INVALID_HANDLE_VALUE == hFile) if (hFile == INVALID_HANDLE_VALUE)
__leave; __leave;

dwFileSize = GetFileSize(hFile, NULL); dwFileSize = GetFileSize (hFile, NULL);

// Create mapping / / Crear la cartografía
hMapping = CreateFileMapping(hFile, 0, PAGE_READWRITE, 0, 0, NULL); hMapping = CreateFileMapping (hFile, 0, PAGE_READWRITE, 0, 0, NULL);
if (!hMapping) if (! hMapping)
__leave; __leave;

// MapView of the PE file / / Mapview del archivo PE
pView = (PUCHAR)MapViewOfFile(hMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); pView = (Puchar) MapViewOfFile (hMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (!pView) if (! pView)
__leave; __leave;

// Make sure it’s a valid PE file / / Asegurarse de que un archivo PE válido
pDOSHeader = (PIMAGE_DOS_HEADER)pView; pDOSHeader = (PIMAGE_DOS_HEADER) pView;
pNTHeader = (PIMAGE_NT_HEADERS)(pDOSHeader->e_lfanew + (ULONG_PTR)pDOSHeader); pNTHeader = (PIMAGE_NT_HEADERS) (pDOSHeader-> e_lfanew + (ULONG_PTR) pDOSHeader);
if(pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE || pNTHeader->Signature != IMAGE_NT_SIGNATURE) if (pDOSHeader-> e_magic! = IMAGE_DOS_SIGNATURE | | pNTHeader-> Firma! IMAGE_NT_SIGNATURE =)
__leave; __leave;

// / /
// OK, Ready to Zero the watermark string / / OK, Listo para la marca de agua cadena Cero
// / /

PRES_STRING_INFO pStrInfo; PRES_STRING_INFO pStrInfo;
PSINGLE_LIST_ENTRY psLink  = pStringsHead->Next; PSINGLE_LIST_ENTRY PSLINK = pStringsHead-> Siguiente;

// Enumerate all entrys / / Enumerar todos los entrys
while(psLink) while (PSLINK)
{ (
// Get the string info / / Obtener la cadena de información
pStrInfo = CONTAINING_RECORD(psLink, RES_STRING_INFO, link); pStrInfo = CONTAINING_RECORD (PSLINK, RES_STRING_INFO, enlace);

// Make sure the info is correct / / Asegúrese de que la información es correcta
if ( (pStrInfo->dwFileOffset > 0×200) if ((pStrInfo-> dwFileOffset> 0×200)
&& (pStrInfo->dwFileOffset < dwFileSize) & & (PStrInfo-> dwFileOffset <dwFileSize)
&& (pStrInfo->dwBytes > 0) ) & & (PStrInfo-> dwBytes> 0))
{ (
// Real work, zero the string / / Real de trabajo, la cadena de cero
ZeroMemory((LPVOID)((ULONG_PTR)pView + pStrInfo->dwFileOffset), pStrInfo->dwBytes); ZeroMemory ((LPVOID) ((ULONG_PTR) pView + pStrInfo-> dwFileOffset), pStrInfo-> dwBytes);
} )

// Get next entry / / Obtener la próxima entrada
psLink = psLink->Next; PSLINK = PSLINK-> Siguiente;

} // while(psLink) ) / / While (PSLINK)

// / /
// OK, we are try to fix the checksum of this file / / OK, nos tratan de fijar la suma de comprobación de este archivo
// / /

// Get correct checksum of the PE file / / Obtener correcta comprobación de los archivos PE
pNTHeader = CheckSumMappedFile((LPVOID)pView, dwFileSize, &dwHeaderSum, &dwCorrectSum); pNTHeader = CheckSumMappedFile ((LPVOID) pView, dwFileSize, y dwHeaderSum, y dwCorrectSum);

//TRACEF(_T(“Header checksum: %08X \tCorrect checksum: %0X\n”), dwHeaderSum, dwCorrectSum); / / TRACEF (_T ( “suma de comprobación de cabecera:% 08X \ tCorrect checksum:% 0X \ n”), dwHeaderSum, dwCorrectSum);

if (!pNTHeader) if (! pNTHeader)
{ (
//TRACEF(_T(“Fail to re-checksum.\n”)); / / TRACEF (_T ( “No se re-checksum. \ N”));
__leave; __leave;
} )

// Update the correct checksum to the file header / / Actualización de la correcta comprobación en el archivo de cabecera
pNTHeader->OptionalHeader.CheckSum = dwCorrectSum; pNTHeader-> OptionalHeader.CheckSum = dwCorrectSum;

// / /
// All done, OK! / / Todo listo, OK!
// / /
bRet = TRUE; bret = TRUE;

} // end try ) / / Fin de intentar
__finally __finally
{ (
// / /
// Clean up / / Limpieza
// / /

if (pView) if (pView)
UnmapViewOfFile((LPCVOID)pView); UnmapViewOfFile ((LPCVOID) pView);

if (hMapping) if (hMapping)
{ (
if (!CloseHandle(hMapping)) if (! CloseHandle (hMapping))
bRet = FALSE; bret = FALSE;
} )

if (hFile) if (hFile)
{ (
if (!CloseHandle(hFile)) if (! CloseHandle (hFile))
bRet = FALSE; bret = FALSE;
} )

} //__finally ) / / __finally

return bRet; bret retorno;

} // ZeroWatermarkFromMuiFile() ) / / ZeroWatermarkFromMuiFile ()

////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////
// Get the PE file version info / / Obtener la información de versión del archivo PE
// Last modified, / / Última modificación,
// 2008.12.24, added bOK / / 2008-12-24, añadió BOK
// / /
BOOL GetDllFileVersion(LPCTSTR pszFileName, PMYVERSIONINFO pVersionInfo) BOOL GetDllFileVersion (LPCTSTR pszFileName, PMYVERSIONINFO pVersionInfo)
{ (
// Check struct size / / Comprobar el tamaño struct
if (sizeof(MYVERSIONINFO) != pVersionInfo->dwSize) if (sizeof (MYVERSIONINFO)! = pVersionInfo-> dwSize)
return FALSE; return false;

BOOL bOK   = FALSE; BOOL BOK = FALSE;
DWORD   dwHandle = NULL; DWORD dwHandle = NULL;
DWORD   dwVerSize; DWORD dwVerSize;

// Get the file version info size / / Obtener el tamaño de archivo de información de versión
dwVerSize = GetFileVersionInfoSize(pszFileName, &dwHandle); dwVerSize = GetFileVersionInfoSize (pszFileName, y dwHandle);
if(dwVerSize == 0) if (dwVerSize == 0)
return FALSE; return false;

LPVOID    pbuf  = NULL; LPVOID pbuf = NULL;
UINT    uLen  = 0; Ulen UINT = 0;
VS_FIXEDFILEINFO *pFileInfo; VS_FIXEDFILEINFO * pFileInfo;

pbuf = MALLOC(dwVerSize); pbuf = malloc (dwVerSize);
if(!pbuf) if (! pbuf)
return FALSE; return false;

__try __try
{ (
bOK = GetFileVersionInfo(pszFileName, dwHandle, dwVerSize, pbuf); BOK = GetFileVersionInfo (pszFileName, dwHandle, dwVerSize, pbuf);
if (!bOK) if (! BOK)
__leave; __leave;

bOK = VerQueryValue(pbuf, (LPTSTR)(“\\”), (LPVOID*)&pFileInfo, &uLen); BOK VerQueryValue = (pbuf, (LPTSTR) ( “\ \”), (* LPVOID) & pFileInfo, y Ulen);
if (!bOK) if (! BOK)
__leave; __leave;

// get data / / Obtener datos
pVersionInfo->wMajorVersion  = HIWORD(pFileInfo->dwProductVersionMS); pVersionInfo-> = wMajorVersion HiWord (pFileInfo-> dwProductVersionMS);
pVersionInfo->wMinorVersion  = LOWORD(pFileInfo->dwProductVersionMS); pVersionInfo-> wMinorVersion = LoWord (pFileInfo-> dwProductVersionMS);
pVersionInfo->wBuildNumber  = HIWORD(pFileInfo->dwProductVersionLS); pVersionInfo-> = wBuildNumber HiWord (pFileInfo-> dwProductVersionLS);
pVersionInfo->wRevisionNumber = LOWORD(pFileInfo->dwProductVersionLS); pVersionInfo-> wRevisionNumber = LoWord (pFileInfo-> dwProductVersionLS);

StringCbPrintf(pVersionInfo->szShortVersion, StringCbPrintf (pVersionInfo-> szShortVersion,
sizeof(pVersionInfo->szShortVersion), _T(“%u.%u.%u.%u”), \ sizeof (pVersionInfo-> szShortVersion), _T ( “% u.% u.% u.% u”), \
pVersionInfo->wMajorVersion, pVersionInfo->wMinorVersion, \ pVersionInfo-> wMajorVersion, pVersionInfo-> wMinorVersion, \
pVersionInfo->wBuildNumber, pVersionInfo->wRevisionNumber pVersionInfo-> wBuildNumber, pVersionInfo-> wRevisionNumber
); );

bOK  = TRUE; BOK = TRUE;

} )
__finally __finally
{ (
// clean up / / Limpiar

if (pbuf) if (pbuf)
FREE(pbuf); LIBRE (pbuf);

} )

return   bOK; BOK retorno;

} // GetDllFileVersion() ) / / GetDllFileVersion ()

////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////
// / /
// Moves the cursor to x, y in console window / / Mueve el cursor a la x, y en la ventana de la consola
// ie x=left\right y=top\bottom / / Es decir, x = izquierda \ superior derecho y = \ fondo
// / /
void gotoX(SHORT x) vacío gotoX (CORTO x)
{ (
CONSOLE_SCREEN_BUFFER_INFO csbiInfo; CONSOLE_SCREEN_BUFFER_INFO csbiInfo;

// Get the current screen buffer size and window position. / / Obtener el actual tamaño del búfer de pantalla y posición de la ventana.
if (!GetConsoleScreenBufferInfo(m_hConsole, &csbiInfo)) if (! GetConsoleScreenBufferInfo (m_hConsole, y csbiInfo))
{ (
return; retorno;
} )

COORD point; COORD punto;

point.X = x; point.X = x;
point.Y = csbiInfo.dwCursorPosition.Y; point.Y = csbiInfo.dwCursorPosition.Y;
SetConsoleCursorPosition(m_hConsole, point); SetConsoleCursorPosition (m_hConsole, punto);
} )

Fin

Removewatermaker.cpp

Atte. [MonsterPack]

Escribe un comentario




Nosotros

Que tal! Les damos la cordial bienvenida a todos los visitantes de este blog Pasqueño dedicado a la tecnología e informática. Aqui encontrarán post’s relacionados a los últimos avances científicos - tecnológicos del medio, con sus respectivos reviews, anotaciones y conclusiones; analizados e interpretados por los autores de esta web, para que ustedes esten al tanto de las innovaciones.

 

Julio 2009
L M X J V S D
« Jun   Ago »
 12345
6789101112
13141516171819
20212223242526
2728293031  

[Frases ó Tonterias]

Las rosas son #ffa5f5 las violetas son #ad00bd.

Blog Stats

  • 23,725 hits

Páginas

Cambiar de:

Labcitec

Páginas

Vuestros Lectores:

free counters