mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 14:08:22 +00:00
[TOOLS]
Fix some compiler warnings, improve formatting, diagnostic messages. svn path=/trunk/; revision=58591
This commit is contained in:
parent
fad117e7de
commit
99afe97aa2
6 changed files with 48 additions and 43 deletions
|
@ -1,4 +1,6 @@
|
||||||
|
/*
|
||||||
|
* Generates assembly definitions from the target headers.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -104,7 +106,7 @@ int main(int argc, char* argv[])
|
||||||
/* Verify the PE signature */
|
/* Verify the PE signature */
|
||||||
if (signature != 0x4550)
|
if (signature != 0x4550)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid signature: 0x%lx.\n", signature);
|
fprintf(stderr, "Invalid signature: 0x%x.\n", signature);
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -430,7 +430,7 @@ registry_callback (HINF hInf, PWCHAR Section, BOOL Delete)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* get flags */
|
/* get flags */
|
||||||
if (InfHostGetIntField (Context, 4, &Flags) != 0)
|
if (InfHostGetIntField (Context, 4, (INT *)&Flags) != 0)
|
||||||
Flags = 0;
|
Flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -562,6 +562,8 @@ RegQueryValueExA(
|
||||||
rc = RegQueryValueExW(hKey, lpValueNameW, lpReserved, lpType, lpData, lpcbData);
|
rc = RegQueryValueExW(hKey, lpValueNameW, lpReserved, lpType, lpData, lpcbData);
|
||||||
if (lpValueNameW)
|
if (lpValueNameW)
|
||||||
free(lpValueNameW);
|
free(lpValueNameW);
|
||||||
|
if (rc != ERROR_SUCCESS)
|
||||||
|
return rc;
|
||||||
return ERROR_UNSUCCESSFUL;
|
return ERROR_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
@ -19,7 +20,8 @@ typedef unsigned __int32 uint32_t;
|
||||||
#define SW_SHOWNORMAL 1
|
#define SW_SHOWNORMAL 1
|
||||||
#define SW_SHOWMINNOACTIVE 7
|
#define SW_SHOWMINNOACTIVE 7
|
||||||
|
|
||||||
typedef struct _GUID {
|
typedef struct _GUID
|
||||||
|
{
|
||||||
uint32_t Data1;
|
uint32_t Data1;
|
||||||
uint16_t Data2;
|
uint16_t Data2;
|
||||||
uint16_t Data3;
|
uint16_t Data3;
|
||||||
|
@ -140,7 +142,7 @@ int main(int argc, const char *argv[])
|
||||||
LNK_HEADER Header;
|
LNK_HEADER Header;
|
||||||
uint16_t uhTmp;
|
uint16_t uhTmp;
|
||||||
uint32_t dwTmp;
|
uint32_t dwTmp;
|
||||||
|
|
||||||
for (i = 1; i < argc; ++i)
|
for (i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
if (argv[i][0] != '-' && argv[i][0] != '/')
|
if (argv[i][0] != '-' && argv[i][0] != '/')
|
||||||
|
@ -166,8 +168,8 @@ int main(int argc, const char *argv[])
|
||||||
else if (!strcmp(argv[i] + 1, "g") && i + 1 < argc)
|
else if (!strcmp(argv[i] + 1, "g") && i + 1 < argc)
|
||||||
{
|
{
|
||||||
unsigned Data4Tmp[8], j;
|
unsigned Data4Tmp[8], j;
|
||||||
|
|
||||||
sscanf(argv[++i], "{%8lx-%4hx-%4hx-%2x%2x-%2x%2x%2x%2x%2x%2x}",
|
sscanf(argv[++i], "{%8x-%4hx-%4hx-%2x%2x-%2x%2x%2x%2x%2x%2x}",
|
||||||
&Guid.Data1, &Guid.Data2, &Guid.Data3,
|
&Guid.Data1, &Guid.Data2, &Guid.Data3,
|
||||||
&Data4Tmp[0], &Data4Tmp[1], &Data4Tmp[2], &Data4Tmp[3],
|
&Data4Tmp[0], &Data4Tmp[1], &Data4Tmp[2], &Data4Tmp[3],
|
||||||
&Data4Tmp[4], &Data4Tmp[5], &Data4Tmp[6], &Data4Tmp[7]);
|
&Data4Tmp[4], &Data4Tmp[5], &Data4Tmp[6], &Data4Tmp[7]);
|
||||||
|
@ -177,7 +179,7 @@ int main(int argc, const char *argv[])
|
||||||
else
|
else
|
||||||
printf("Invalid option: %s\n", argv[i]);
|
printf("Invalid option: %s\n", argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pszTarget || bHelp)
|
if (!pszTarget || bHelp)
|
||||||
{
|
{
|
||||||
printf("Usage: %s [-o path][-d descr][-w path][-c cmd_line_args][-i icon_path [nr]][-h][-g guid] target\n"
|
printf("Usage: %s [-o path][-d descr][-w path][-c cmd_line_args][-i icon_path [nr]][-h][-g guid] target\n"
|
||||||
|
@ -191,14 +193,14 @@ int main(int argc, const char *argv[])
|
||||||
"target\tAbsolute or relative to guid specified with -g option path\n", argv[0]);
|
"target\tAbsolute or relative to guid specified with -g option path\n", argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFile = fopen(pszOutputPath, "wb");
|
pFile = fopen(pszOutputPath, "wb");
|
||||||
if (!pFile)
|
if (!pFile)
|
||||||
{
|
{
|
||||||
printf("Failed to open %s\n", pszOutputPath);
|
printf("Failed to open %s\n", pszOutputPath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
memset(&Header, 0, sizeof(Header));
|
memset(&Header, 0, sizeof(Header));
|
||||||
Header.Signature = (uint32_t)'L';
|
Header.Signature = (uint32_t)'L';
|
||||||
|
@ -215,7 +217,7 @@ int main(int argc, const char *argv[])
|
||||||
Header.IconNr = IconNr;
|
Header.IconNr = IconNr;
|
||||||
Header.Show = bMinimized ? SW_SHOWMINNOACTIVE : SW_SHOWNORMAL;
|
Header.Show = bMinimized ? SW_SHOWMINNOACTIVE : SW_SHOWNORMAL;
|
||||||
fwrite(&Header, sizeof(Header), 1, pFile);
|
fwrite(&Header, sizeof(Header), 1, pFile);
|
||||||
|
|
||||||
if (Header.Flags & LINK_ID_LIST)
|
if (Header.Flags & LINK_ID_LIST)
|
||||||
{
|
{
|
||||||
ID_LIST_FILE IdListFile;
|
ID_LIST_FILE IdListFile;
|
||||||
|
@ -223,12 +225,12 @@ int main(int argc, const char *argv[])
|
||||||
ID_LIST_DRIVE IdListDrive;
|
ID_LIST_DRIVE IdListDrive;
|
||||||
unsigned cbListSize = sizeof(IdListGuid) + sizeof(uint16_t), cchName;
|
unsigned cbListSize = sizeof(IdListGuid) + sizeof(uint16_t), cchName;
|
||||||
const char *pszName = pszTarget;
|
const char *pszName = pszTarget;
|
||||||
|
|
||||||
// ID list
|
// ID list
|
||||||
// It seems explorer does not accept links without id list. List is relative to desktop.
|
// It seems explorer does not accept links without id list. List is relative to desktop.
|
||||||
|
|
||||||
pszName = pszTarget;
|
pszName = pszTarget;
|
||||||
|
|
||||||
if (pszName[0] && pszName[1] == ':')
|
if (pszName[0] && pszName[1] == ':')
|
||||||
{
|
{
|
||||||
cbListSize += sizeof(IdListDrive);
|
cbListSize += sizeof(IdListDrive);
|
||||||
|
@ -236,32 +238,32 @@ int main(int argc, const char *argv[])
|
||||||
while (*pszName == '\\' || *pszName == '/')
|
while (*pszName == '\\' || *pszName == '/')
|
||||||
++pszName;
|
++pszName;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*pszName)
|
while (*pszName)
|
||||||
{
|
{
|
||||||
cchName = 0;
|
cchName = 0;
|
||||||
while (pszName[cchName] && pszName[cchName] != '\\' && pszName[cchName] != '/')
|
while (pszName[cchName] && pszName[cchName] != '\\' && pszName[cchName] != '/')
|
||||||
++cchName;
|
++cchName;
|
||||||
|
|
||||||
if (cchName != 1 || pszName[0] != '.')
|
if (cchName != 1 || pszName[0] != '.')
|
||||||
cbListSize += sizeof(IdListFile) + 2 * (cchName + 1);
|
cbListSize += sizeof(IdListFile) + 2 * (cchName + 1);
|
||||||
|
|
||||||
pszName += cchName;
|
pszName += cchName;
|
||||||
while (*pszName == '\\' || *pszName == '/')
|
while (*pszName == '\\' || *pszName == '/')
|
||||||
++pszName;
|
++pszName;
|
||||||
}
|
}
|
||||||
|
|
||||||
uhTmp = cbListSize;
|
uhTmp = cbListSize;
|
||||||
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile); // size
|
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile); // size
|
||||||
|
|
||||||
IdListGuid.Size = sizeof(IdListGuid);
|
IdListGuid.Size = sizeof(IdListGuid);
|
||||||
IdListGuid.Type = PT_GUID;
|
IdListGuid.Type = PT_GUID;
|
||||||
IdListGuid.dummy = 0x50;
|
IdListGuid.dummy = 0x50;
|
||||||
IdListGuid.guid = Guid;
|
IdListGuid.guid = Guid;
|
||||||
fwrite(&IdListGuid, sizeof(IdListGuid), 1, pFile);
|
fwrite(&IdListGuid, sizeof(IdListGuid), 1, pFile);
|
||||||
|
|
||||||
pszName = pszTarget;
|
pszName = pszTarget;
|
||||||
|
|
||||||
if (isalpha(pszName[0]) && pszName[1] == ':')
|
if (isalpha(pszName[0]) && pszName[1] == ':')
|
||||||
{
|
{
|
||||||
memset(&IdListDrive, 0, sizeof(IdListDrive));
|
memset(&IdListDrive, 0, sizeof(IdListDrive));
|
||||||
|
@ -273,13 +275,13 @@ int main(int argc, const char *argv[])
|
||||||
while(*pszName == '\\' || *pszName == '/')
|
while(*pszName == '\\' || *pszName == '/')
|
||||||
++pszName;
|
++pszName;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*pszName)
|
while (*pszName)
|
||||||
{
|
{
|
||||||
cchName = 0;
|
cchName = 0;
|
||||||
while (pszName[cchName] && pszName[cchName] != '\\' && pszName[cchName] != '/')
|
while (pszName[cchName] && pszName[cchName] != '\\' && pszName[cchName] != '/')
|
||||||
++cchName;
|
++cchName;
|
||||||
|
|
||||||
if (cchName != 1 || pszName[0] != '.')
|
if (cchName != 1 || pszName[0] != '.')
|
||||||
{
|
{
|
||||||
memset(&IdListFile, 0, sizeof(IdListFile));
|
memset(&IdListFile, 0, sizeof(IdListFile));
|
||||||
|
@ -294,16 +296,16 @@ int main(int argc, const char *argv[])
|
||||||
fwrite(pszName, cchName, 1, pFile);
|
fwrite(pszName, cchName, 1, pFile);
|
||||||
fputc(0, pFile);
|
fputc(0, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
pszName += cchName;
|
pszName += cchName;
|
||||||
while (*pszName == '\\' || *pszName == '/')
|
while (*pszName == '\\' || *pszName == '/')
|
||||||
++pszName;
|
++pszName;
|
||||||
}
|
}
|
||||||
|
|
||||||
uhTmp = 0; // list end
|
uhTmp = 0; // list end
|
||||||
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Header.Flags & LINK_DESCRIPTION)
|
if (Header.Flags & LINK_DESCRIPTION)
|
||||||
{
|
{
|
||||||
// Dscription
|
// Dscription
|
||||||
|
@ -311,7 +313,7 @@ int main(int argc, const char *argv[])
|
||||||
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
||||||
fputs(pszDescription, pFile);
|
fputs(pszDescription, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Header.Flags & LINK_RELATIVE_PATH)
|
if (Header.Flags & LINK_RELATIVE_PATH)
|
||||||
{
|
{
|
||||||
// Relative Path
|
// Relative Path
|
||||||
|
@ -319,7 +321,7 @@ int main(int argc, const char *argv[])
|
||||||
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
||||||
fputs(pszTarget, pFile);
|
fputs(pszTarget, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Header.Flags & LINK_WORKING_DIR)
|
if (Header.Flags & LINK_WORKING_DIR)
|
||||||
{
|
{
|
||||||
// Working Dir
|
// Working Dir
|
||||||
|
@ -327,7 +329,7 @@ int main(int argc, const char *argv[])
|
||||||
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
||||||
fputs(pszWorkingDir, pFile);
|
fputs(pszWorkingDir, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Header.Flags & LINK_CMD_LINE_ARGS)
|
if (Header.Flags & LINK_CMD_LINE_ARGS)
|
||||||
{
|
{
|
||||||
// Command line arguments
|
// Command line arguments
|
||||||
|
@ -335,7 +337,7 @@ int main(int argc, const char *argv[])
|
||||||
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
||||||
fputs(pszCmdLineArgs, pFile);
|
fputs(pszCmdLineArgs, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Header.Flags & LINK_ICON)
|
if (Header.Flags & LINK_ICON)
|
||||||
{
|
{
|
||||||
// Command line arguments
|
// Command line arguments
|
||||||
|
@ -343,12 +345,12 @@ int main(int argc, const char *argv[])
|
||||||
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
fwrite(&uhTmp, sizeof(uhTmp), 1, pFile);
|
||||||
fputs(pszIcon, pFile);
|
fputs(pszIcon, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra stuff
|
// Extra stuff
|
||||||
dwTmp = 0;
|
dwTmp = 0;
|
||||||
fwrite(&dwTmp, sizeof(dwTmp), 1, pFile);
|
fwrite(&dwTmp, sizeof(dwTmp), 1, pFile);
|
||||||
|
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ RelocateSection(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Unknown relocatation type %ld address %ld\n",
|
printf("Unknown relocatation type %d, address 0x%lx\n",
|
||||||
pReloc->Type, pReloc->VirtualAddress);
|
pReloc->Type, pReloc->VirtualAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
free(pData);
|
free(pData);
|
||||||
fclose(pSourceFile);
|
fclose(pSourceFile);
|
||||||
fprintf(stderr, "Failed to read source file: %ld\n", nFileSize);
|
fprintf(stderr, "Failed to read %ld bytes from source file\n", nFileSize);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ int main(int argc, char *argv[])
|
||||||
if (!pDestFile)
|
if (!pDestFile)
|
||||||
{
|
{
|
||||||
free(pData);
|
free(pData);
|
||||||
fprintf(stderr, "Couldn't open dest file '%s'\n", pszDestFile);
|
fprintf(stderr, "Couldn't open destination file '%s'\n", pszDestFile);
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
|
||||||
for (i = 0; i < pFileHeader->NumberOfSections; i++)
|
for (i = 0; i < pFileHeader->NumberOfSections; i++)
|
||||||
{
|
{
|
||||||
/* Check if this is '.text' section */
|
/* Check if this is '.text' section */
|
||||||
if ((strcmp(pSectionHeader->Name, ".text") == 0) &&
|
if ((strcmp((char*)pSectionHeader->Name, ".text") == 0) &&
|
||||||
(pSectionHeader->SizeOfRawData != 0))
|
(pSectionHeader->SizeOfRawData != 0))
|
||||||
{
|
{
|
||||||
RelocateSection(pData,
|
RelocateSection(pData,
|
||||||
|
@ -146,7 +146,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
free(pData);
|
free(pData);
|
||||||
fclose(pDestFile);
|
fclose(pDestFile);
|
||||||
fprintf(stderr, "Failed to write data %ld\n",
|
fprintf(stderr, "Failed to write %ld bytes to destination file\n",
|
||||||
pSectionHeader->SizeOfRawData);
|
pSectionHeader->SizeOfRawData);
|
||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
|
@ -162,4 +162,3 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ GetStabInfo(void *FileData, PIMAGE_FILE_HEADER PEFileHeader,
|
||||||
for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++)
|
for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++)
|
||||||
{
|
{
|
||||||
/* printf("section: '%.08s'\n", PESectionHeaders[Idx].Name); */
|
/* printf("section: '%.08s'\n", PESectionHeaders[Idx].Name); */
|
||||||
if ((strncmp((char*)PESectionHeaders[Idx].Name, ".stab", 5) == 0)
|
if ((strncmp((char *) PESectionHeaders[Idx].Name, ".stab", 5) == 0)
|
||||||
&& (PESectionHeaders[Idx].Name[5] == 0))
|
&& (PESectionHeaders[Idx].Name[5] == 0))
|
||||||
{
|
{
|
||||||
/* printf(".stab section found. Size %d\n",
|
/* printf(".stab section found. Size %d\n",
|
||||||
|
@ -70,7 +70,7 @@ GetStabInfo(void *FileData, PIMAGE_FILE_HEADER PEFileHeader,
|
||||||
*StabSymbolsBase = (void *)((char *) FileData + PESectionHeaders[Idx].PointerToRawData);
|
*StabSymbolsBase = (void *)((char *) FileData + PESectionHeaders[Idx].PointerToRawData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp((char*)PESectionHeaders[Idx].Name, ".stabstr", 8) == 0)
|
if (strncmp((char *) PESectionHeaders[Idx].Name, ".stabstr", 8) == 0)
|
||||||
{
|
{
|
||||||
/* printf(".stabstr section found. Size %d\n",
|
/* printf(".stabstr section found. Size %d\n",
|
||||||
PESectionHeaders[Idx].SizeOfRawData); */
|
PESectionHeaders[Idx].SizeOfRawData); */
|
||||||
|
@ -528,7 +528,7 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
||||||
if ((0 == StartOfRawData
|
if ((0 == StartOfRawData
|
||||||
|| InSectionHeaders[Section].PointerToRawData < StartOfRawData)
|
|| InSectionHeaders[Section].PointerToRawData < StartOfRawData)
|
||||||
&& 0 != InSectionHeaders[Section].PointerToRawData
|
&& 0 != InSectionHeaders[Section].PointerToRawData
|
||||||
&& 0 != (strncmp(InSectionHeaders[Section].Name, ".stab", 5)))
|
&& 0 != (strncmp((char *) InSectionHeaders[Section].Name, ".stab", 5)))
|
||||||
{
|
{
|
||||||
StartOfRawData = InSectionHeaders[Section].PointerToRawData;
|
StartOfRawData = InSectionHeaders[Section].PointerToRawData;
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
||||||
OutRelocSection = NULL;
|
OutRelocSection = NULL;
|
||||||
for (Section = 0; Section < InFileHeader->NumberOfSections; Section++)
|
for (Section = 0; Section < InFileHeader->NumberOfSections; Section++)
|
||||||
{
|
{
|
||||||
if (0 != (strncmp(InSectionHeaders[Section].Name, ".stab", 5)))
|
if (0 != (strncmp((char *) InSectionHeaders[Section].Name, ".stab", 5)))
|
||||||
{
|
{
|
||||||
*CurrentSectionHeader = InSectionHeaders[Section];
|
*CurrentSectionHeader = InSectionHeaders[Section];
|
||||||
CurrentSectionHeader->PointerToLinenumbers = 0;
|
CurrentSectionHeader->PointerToLinenumbers = 0;
|
||||||
|
|
Loading…
Reference in a new issue