Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


BASICFreak

Member Since 07 May 2006
Offline Last Active Jun 15 2014 10:11 PM

Topics I've Started

Link ASM object (aout) in AR archive? [GNU DJGPP] [NASM]

24 May 2014 - 10:04 PM

I hope I placed this in the right topic as AR and LD are "Tools" rolleyes.gif .

 

First note I realize my build script should be a MakeFile, but it's a cmd script.

 

Second note I have attempted to search Google, this Forum, and OSDEV but the keywords here are way to vague and only 2 letters so all results I saw did not relate to my situation.

 

 

 

Ok, I have currently one ASM file containing all the assembly code I need; but, while rewriting parts of the project I decided I want to break this one ASM file into about 6.

 

Let me dump some of the build script here before I get into my question...:

...

@ECHO IDT.C
gcc %GCC_OPTIONS% ./OBJ/IDT.O ./DRIVERSRC/SYSTEM/CPU/IDT.c
@ECHO IRQ.ASM
nasm -f aout ./DRIVERSRC/SYSTEM/CPU/IRQ.ASM ./OBJ/IRQA.O
@ECHO IRQ.C
gcc %GCC_OPTIONS% ./OBJ/IRQ.O ./DRIVERSRC/SYSTEM/CPU/IRQ.c

...

ar rvs ./DRIVER/sys.a ./OBJ/8259.O ./OBJ/GDT.O ./OBJ/IDT.O ./OBJ/IRQA.O ./OBJ/IRQ.O ./OBJ/TSS.O ./OBJ/FAT12.O
ar rvs ./DRIVER/sys.a ./OBJ/VFS.O ./OBJ/PAGEDIR.O ./OBJ/PAGEFAULT.O ./OBJ/PAGETABLE.O ./OBJ/PHYSICAL.O
ar rvs ./DRIVER/sys.a ./OBJ/VIRTUAL.O
@ECHO START.ASM
nasm -f aout ./KERNELSRC/START.ASM -o ./OBJ/START.O
@ECHO MAIN.C
gcc %GCC_OPTIONS% ./OBJ/MAIN.O ./KERNELSRC/MAIN.c
@ECHO COMMAND.C
gcc %GCC_OPTIONS% ./OBJ/COMMAND.O ./KERNELSRC/COMMAND.c
@ECHO LINKING KERNEL.BIN
LD -T %LD_SCRIPT% -o %OUTPUT_FILE% ./OBJ/START.O ./OBJ/MAIN.O ./OBJ/COMMAND.O ./LIB/lib.a ./DRIVER/sys.a ./DRIVER/hw.a

...

As you can see above my only ASM file "START.ASM" is compiled format AOUT and placed in directly with the LD command - this works fine.

 

But when I split this source file into the appropriate sections I run into one of two problems:

1. Add to the archive - Error returned "./DRIVER/sys.a: could not read symbols: File truncated"

2. Add files to LD command - LD becomes too long and the system cannot process it.

 

The reason I oppose a MakeFile so much is I am constantly rebuilding / testing and a simple BATCH loop with a menu is great - plus I haven't sat down to find out how one is constructed...huh.png

 

So, anyways, my question is - Is there a way to archive ASM and C objects in the same library, or is there an all-together better way of doing this?


Returning a Char Array from function in C

20 September 2013 - 08:00 PM

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>


FILE *FS;
FILE *LF;


unsigned int HexDec(char Hx[16])
{
    unsigned int ret;
    ret = (long int)strtol(Hx, NULL, 16);
    return ret;
}
char DecHex(unsigned int Dec) //4 bytes
{
    char ret[16];
    sprintf(ret,"%08x", Dec);
    return ret;
}
char BinHex(char Bin[16]) //4 Bytes
{
    char ret[16];
    sprintf(ret, "%02x%02x%02x%02x", (unsigned int) Bin[0] & 0xFF, (unsigned int) Bin[1] & 0xFF, (unsigned int) Bin[2] & 0xFF, (unsigned int) Bin[3] & 0xFF);
    return ret;
}
void main()
{
    char BIN[16] = "AA55";
    char HEX[16] = BinHex(BIN);
    unsigned int DEC = HexDec(HEX);
    char DECHEX[16] = DecHex(DEC);
    printf("Bin: %s\n\n", BIN);
    printf("To Hex: %s\nTo Dec: %u\n\n Dec %u to Hex %s\n", HEX, DEC, DEC, DECHEX);
}
 
I am currently rewriting horrible looking test code and trying to get some functions to clean up, but I'm running into the issue where I must have arrays not pointers returned to be able to manipulate the data being processed.
 
​The end goal is to give me access to my custom File System threw linux terminal. Currently my first code works flawlessly, but the code is so hard to read and has the same segments over and over again (these segments are what I'm trying to get into functions).
 
The function DecHex is the main one I am worried about returning as an array because my code currently looks like:
 
//sprintf(hx,"%08x",(unsigned int) filesize);  what is currently here
hx = DecHex(filesize);
printf("Hex value of Decimal value %ld  is %s\n",filesize,hx);
sprintf (tmp, "%c%c", hx[6], hx[7]);
tmpb = strtol(tmp, NULL, 16);
printf("%s - %u\n", tmp, tmpb);
putc(tmpb, FS);
sprintf (tmp, "%c%c", hx[4], hx[5]);
tmpb = strtol(tmp, NULL, 16);
printf("%s - %u\n", tmp, tmpb);
putc(tmpb, FS);
sprintf (tmp, "%c%c", hx[2], hx[3]);
tmpb = strtol(tmp, NULL, 16);
printf("%s - %u\n", tmp, tmpb);
putc(tmpb, FS);
sprintf (tmp, "%c%c", hx[0], hx[1]);
tmpb = strtol(tmp, NULL, 16);
printf("%s - %u\n", tmp, tmpb);
putc(tmpb, FS);
 
 
And as I stated my old code is bad for the eyes (~900 lines of confusing), I am getting to that part but first I need this pointer array issue fixed.
 
If you need my old code for something let me know, otherwise it is best kept away from eyes lol.
 
Any help is appreciated, Thanks in advance B T Hoover
 

MySQL Database Structure and Data Lister

06 July 2013 - 02:35 AM

First here is the code:

<?php
require './includes/config.ini.php';
?>
<html>
    <head>
        <title>Database Structure</title>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
        <center><h1><?PHP echo $database; ?></h1>
            <table border="1" cellspacing="0" width="820">
                <tr>
                    <td width="175">Table</td>
                    <td width="175">Field</td>
                    <td width="175">Field Type</td>
                    <td width="290">Value</td>
                </tr>
        
<?PHP
mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());


$tableresults = mysql_query("SHOW TABLES");
while ( $tablerows = mysql_fetch_array($tableresults) )
{
    $structureresults = mysql_query("DESCRIBE ".$tablerows[0]);
    while ( $structurerows = mysql_fetch_array($structureresults) )
    {
        $result = mysql_query("SELECT * FROM ".$tablerows[0]);
        while ( $row = mysql_fetch_array($result) )
        {
            echo '<tr>
                    <td>'.$tablerows[0].'</td>
                    <td>'.$structurerows['Field'].'</td>
                    <td>'.$structurerows['Type'].'</td>
                    <td>'.$row[$tablerows['Field']].'</td>
                </tr>';
        }
    }
}
?>
            </table>
        </center>
    </body>
</html>

The issue I am having is I am not displaying any of the values from the table, all other information is displaying fine, anyone have any ideas.

 

Could it be that I cannot use a variable to locate an array point?

 

 

Any help is greatly appreciated

 

BASICFreak

 


First complex BATCH file

10 September 2011 - 06:10 PM

This was my first time to use any commands in a BATCH file, I never thought it could get so confusing.

It took me 13 whole hours of trial and error and research.
I couldn't find a tool to do exactly what I wanted and figure it may be of use to others.

The script has no output while running, and can take a very long time to process depending on your registry size

FILE NAME = REGKEYEXTRACTOR.CMD


@ECHO OFF
setlocal enableextensions enabledelayedexpansion
COLOR 1F
CLS
SET ARGS=0
SET OPTS=0
SET OPTIONS=
FOR %%x IN (%*) DO SET /A ARGS+=1
IF %ARGS% LSS 1 GOTO ERROR
IF "%1" == "" GOTO ERROR
IF "%1" == "/?" GOTO ERROR
SET RtKy=%1
SHIFT
IF NOT X%1X==XX (
	SET OPTIONS=%1
	SET OPTION_ALL=%1
	SET /A OPTS+=1
)
IF NOT X%OPTIONS%X==XX GOTO LOOP
:LOOP
SHIFT
IF X%1X==XX GOTO ENDLOOP
SET OPTIONS=%OPTIONS% %1
SET OPTION_ALL=%OPTION_ALL%~%1
SET /A OPTS+=1
GOTO LOOP
:ENDLOOP
IF %OPTS% GEQ 1 GOTO GETOPTIONS
GOTO :EOF

:GETOPTIONS
FOR /F "USEBACKQ TOKENS=1-%OPTS% DELIMS=~" %%A IN ('%OPTION_ALL%') DO (
IF %OPTS% GEQ 1 SET OPTION_1=%%A
IF %OPTS% GEQ 2 SET OPTION_2=%%B
IF %OPTS% GEQ 3 SET OPTION_3=%%C
IF %OPTS% GEQ 4 SET OPTION_4=%%D
IF %OPTS% GEQ 5 SET OPTION_5=%%E
IF %OPTS% GEQ 6 SET OPTION_6=%%F
IF %OPTS% GEQ 7 SET OPTION_7=%%G
IF %OPTS% GEQ 8 SET OPTION_8=%%H
IF %OPTS% GEQ 9 SET OPTION_9=%%I
IF %OPTS% GEQ 10 SET OPTION_10=%%J
IF %OPTS% GEQ 11 SET OPTION_11=%%K
IF %OPTS% GEQ 12 SET OPTION_12=%%L
IF %OPTS% GEQ 13 SET OPTION_13=%%M
IF %OPTS% GEQ 14 SET OPTION_14=%%N
IF %OPTS% GEQ 15 SET OPTION_15=%%O
IF %OPTS% GEQ 16 SET OPTION_16=%%P
IF %OPTS% GEQ 17 SET OPTION_17=%%Q
IF %OPTS% GEQ 18 SET OPTION_18=%%R
IF %OPTS% GEQ 19 SET OPTION_19=%%S
IF %OPTS% GEQ 20 SET OPTION_20=%%T
)
IF "%OPTION_1%"=="/I" (
	IF %OPTS% EQU 2 (
		IF NOT X%OPTION_2%X==XX (
			SET INFILE=%OPTION_2%
			GOTO INPUTTEXT
		) ELSE (
			GOTO ERROR
		)
	) ELSE (
		GOTO ERROR
	)
)ELSE IF "%OPTION_1%"=="/i" (
	IF %OPTS% EQU 2 (
		IF NOT X%OPTION_2%X==XX (
			SET INFILE=%OPTION_2%
			GOTO INPUTTEXT
		) ELSE (
			GOTO ERROR
		)
	) ELSE (
		GOTO ERROR
	)
) ELSE (
	GOTO QUERY
)
GOTO :EOF


:INPUTTEXT
FINDSTR /B /C:"HKEY" %INFILE% > TEMP.TXT
ECHO Windows Registry Editor Version 5.00 > %RtKy%-FINAL.REG
ECHO. >> %RtKy%-FINAL.REG
FOR /F "TOKENS=1* DELIMS=\" %%A IN (TEMP.TXT) DO (
REG EXPORT "%RtKy%\%%B" TMP.REG /Y
TYPE TMP.REG > TEMP.REG
DEL TMP.REG /Q
FOR /F "SKIP=2 TOKENS=*" %%a IN (TEMP.REG) DO @ECHO %%a >> %RtKy%-FINAL.REG
DEL TEMP.REG /Q
)
DEL TEMP.TXT
GOTO :EOF

:QUERY
REG QUERY %RtKY% %OPTIONS% > QUERYTEMP.TXT
SET INFILE=QUERYTEMP.TXT
GOTO INPUTTEXT
GOTO :EOF

:ERROR
ECHO REGKEYEXTRACTOR.CMD
ECHO By Brian T. Hoover A.K.A. BASIC.Freak
ECHO.
ECHO USSAGE  REGKEYEXTRACTOR.CMD RootKey [OPTIONS]
ECHO EXAMPLE REGKEYEXTRACTOR.CMD HKLM /S /F "FOO bar" /Z
ECHO     	REGKEYEXTRACTOR.CMD HKLM /I hklm.TXT
ECHO.
ECHO RootKey - [ HKLM ^| HKCU ^| HKCR ^| HKU ^| HKCC ]
ECHO.
ECHO [OPTIONS]    -- WARNING DO NOT USE A '~' IN OPTIONS! --
ECHO /I "InputFile"  -  USE A PRE-OUTPUTED REG QURY FILE
ECHO.
ECHO   ----------------------------  OR  ----------------------------
ECHO.
ECHO /S      Queries all subkeys and values recursively (like dir /s).
ECHO.
ECHO /se 	Specifies the separator (length of 1 character only) in
ECHO     	data string for REG_MULTI_SZ. Defaults to "\0" as the separator.
ECHO.
ECHO /f      Specifies the data or pattern to search for.
ECHO     	Use double quotes if a string contains spaces. Default is "*".
ECHO.
ECHO /k      Specifies to search in key names only.
ECHO.
ECHO /d      Specifies the search in data only.
ECHO.
ECHO /c      Specifies that the search is case sensitive.
ECHO     	The default search is case insensitive.
ECHO.
ECHO /e      Specifies to return only exact matches.
ECHO     	By default all the matches are returned.
ECHO.
ECHO /t      Specifies registry value data type.
ECHO     	Valid types are:
ECHO       	REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ,
ECHO       	REG_DWORD, REG_QWORD, REG_BINARY, REG_NONE
ECHO     	Defaults to all types.
ECHO.
ECHO /z      Verbose: Shows the numeric equivalent for the type of the valuename.
GOTO :EOF



enjoy Posted Image

[web] domTT problems.

25 January 2011 - 04:44 AM

here is the source my page displays, minus some private and unimportant information:

<html> 
    <head> 
        <script TYPE="text/javascript"> 
        <!--
        var downStrokeField;
        function autojump(fieldName,nextFieldName,fakeMaxLength)
        {
            var myForm=document.forms[document.forms.length - 1];
            var myField=myForm.elements[fieldName];
            myField.nextField=myForm.elements[nextFieldName];
            if (myField.maxLength == null)
                myField.maxLength=fakeMaxLength;
            myField.onkeydown=autojump_keyDown;
            myField.onkeyup=autojump_keyUp;
        }
        function autojump_keyDown()
        {
            this.beforeLength=this.value.length;
            downStrokeField=this;
        }
        function autojump_keyUp()
        {
            if (
                (this == downStrokeField) &&
                    (this.value.length > this.beforeLength) &&
                        (this.value.length >= this.maxLength)
                )
                this.nextField.focus();
                downStrokeField=null;
        }
        //-->
        </SCRIPT> 
        <script type="text/javascript" language="javascript"> 
            var domTT_styleClass = 'domTTOverlib';
            var domTT_maxWidth = false;
            try
            {
                var winCloseButton = document.createElement('img');
                winCloseButton.src = './images/close.png'
                    winCloseButton.style.verticalAlign = 'bottom';
            }
            // permission denied
            catch (e)
            {
                var winCloseButton = 'X';
            }
        </script> 
        <style type='text/css' media='print'> 
            .dontPrint
            {
                display : none
            }
            body
            {
                color: #000000;
                background-color: #FFFFFF;
            }
            body a:link
            {
                color: #000000;
            }
            body a:visited
            {
                color: #000000;
            }
            body a:hover
            {
                color: #000000;
            }
            body a:active
            {
                color: #000000;
            }
        </style> 
        
<style> 
                    @import url("./css/frame.css");
                  </style> 
<style> 
                    @import url("./css/ratingSystem.css");
                  </style> 
<script type="text/javascript" language="javascript" src="./js/domTT.js"></script> 
<script type="text/javascript" language="javascript" src="./js/CursorFinder.js"></script> 
<script type="text/javascript" language="javascript" src="./js/domLib.js"></script> 
<script type="text/javascript" language="javascript" src="./js/alphaAPI.js"></script> 
<script type="text/javascript" language="javascript" src="./js/domTT_drag.js"></script> 
<script type="text/javascript" language="javascript" src="./js/fadomatic.js"></script> 
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
 
        <title>****</title> 
    </head> 
    <body bgcolor=#000000 text=#FFFF00 alink=#FFFFFF hlink=#FFFFFF link=#FFFFFF vlink=#FFFFFF><center> 
        <script type="text/javascript"> 
	<!--
		if(window.location != "****") window.location = "****"	//-->
	</script> 
        <table border=0 width=920> 
                <tr height=85> 
		<td valign=center align=center width=20%>Welcome Back,<br>****<br><a href="logout.php">
		Log Out</a></td> 
		<td valign=center align=center width=20%><a href="#void" onclick="return makeFalse(domTT_activate(this, event, 'id', 'cust', 'caption', 'Add Customer', 'content', '&lt;iframe src=&quot;addCust.php&quot; style=&quot;width: 700px; height: 575px;&quot;&gt;&lt;/iframe&gt;', 'type', 'sticky', 'styleClass', 'domTTWin', 'closeLink', winCloseButton, 'draggable', true, 'closeAction', 'destroy'));">
		Add Customer</a></td> 
*unimportant*
		<hr><br><script type="text/javascript" language="javascript"> 
            var domTT_styleClass = 'RSTitle';
        </script><form method=post> 
 
            <table border="0" width="425"> 
 
                <tr> 
 
                    <td width="20%"><img alt="" src="./images/4.png" onmouseover='domTT_activate(this, event, "content", "****<br>Marked As: Good<hr>****", "styleClass", "RSTitle", "trail", "true");'></td> 
 
                    <td width="40%">152</td> 
 
                    <td width="20%">****</td> 
 
                    <td width="40%"><input type="submit" name="btnChangeCustomer" value="Change"></td> 
 
                </tr></table></form>
*unimportant*
                </table></center> 
</body> 
</html>

I checked that I am correctly locating the JavaScript and CSS Files

after I edited some code on this page, none of the DomTT is working, and I have not edited any of the domTT scripts or calls.
all the code left out and replaced with *unimportant* was links and forms and **** was another person's (or my) private information

I'm trying to find where I went wrong, even when I uploaded the code from right before this change it still did not work

if you need more of the code or for me to give a link to a "demo" page just ask and I'll post as much as I can.

PARTNERS