Memory Allocation

Posted on 1999-01-10
Last Modified: 2010-05-18
Sorry for sticking in this group with assembly programs
I don't know why when I use 48h service (int 21h) to allocate memory, the returned address is always smaller than my ds segment register value. So that any subsequent rep overwrites my original data in the data segment.
I have tried to solve it using memory allocation strategy,
but other program would crash after it. Can you help?

here is a little bit code:

In the allocaion module:
mov ah, 48h
add bx, 0fh
mov cl ,4
shr bx, cl
int 21h


Question by:whluk
  • 4
  • 3
  • 2
LVL 22

Expert Comment

ID: 1181820
>>the returned address is always smaller than my
>> ds segment register value
That shouldn't matter as long as you do not write past the end of the allocated memory.  So the problem might lie in how you are using this memory.

If the carry flag is clear, the segment of the allocated memory is returned AX, but if the carry flag is set, an error code is returned in AX (and that error code is likely to be a small value), thus you might need to check the carry flag.


Author Comment

ID: 1181821
I beg your pardon. The problem being is that the allocated memory spans thru my original data segment. Even though I have declared the data segment as the data segment, that area is still allocated for other uses.

Author Comment

ID: 1181822
By the way, I know that the returned address is in the AX register.
LVL 22

Expert Comment

ID: 1181823
Can you post an example showing the addresses and lengths involved?  Is this for a COM or EXE program?  
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.


Author Comment

ID: 1181824
This is the entire module that you need.
This is produced by VCom's Sourcer
I'm afraid this chunk may be too complex for you to step thru.


public _mt_allocate

data_1e            equ      0                  ; (0000:0000=0F9Eh)
data_2e            equ      2                  ; (0000:0002=0C9h)
data_3e            equ      12h                  ; (0000:0012=70h)
data_4e            equ      13h                  ; (0000:0013=0)
data_5e            equ      14h                  ; (0000:0014=0FF54h)
data_6e            equ      16h                  ; (0000:0016=0)
data_7e            equ      18h                  ; (0000:0018=79h)
data_8e            equ      1Eh                  ; (0000:001E=0)
data_9e            equ      20h                  ; (0000:0020=0)
data_10e      equ      24h                  ; (0000:0024=28h)
data_11e      equ      2Ah                  ; (0000:002A=0D035h)
data_12e      equ      30h                  ; (0000:0030=6Ah)
data_13e      equ      36h                  ; (0000:0036=35h)
data_14e      equ      38h                  ; (0000:0038=9Ah)
data_15e      equ      3Ah                  ; (0000:003A=0D035h)
data_16e      equ      3Ch                  ; (0000:003C=65h)
data_17e      equ      3Eh                  ; (0000:003E=70h)
data_18e      equ      40h                  ; (0000:0040=0Fh)
data_19e      equ      41h                  ; (0000:0041=0)
data_20e      equ      42h                  ; (0000:0042=0D457h)
data_21e      equ      44h                  ; (0000:0044=4Dh)
data_22e      equ      45h                  ; (0000:0045=0F8h)
data_23e      equ      46h                  ; (0000:0046=0)
data_24e      equ      48h                  ; (0000:0048=0F841h)
data_25e      equ      4Ah                  ; (0000:004A=0F000h)
data_26e      equ      4Ch                  ; (0000:004C=24C2h)
data_27e      equ      4Eh                  ; (0000:004E=0FD62h)
data_28e      equ      50h                  ; (0000:0050=0E739h)
data_29e      equ      52h                  ; (0000:0052=0F000h)
data_30e      equ      54h                  ; (0000:0054=53Ah)
data_31e      equ      56h                  ; (0000:0056=295h)
data_32e      equ      58h                  ; (0000:0058=42Dh)
data_33e      equ      5Ch                  ; (0000:005C=0A28h)
data_34e      equ      60h                  ; (0000:0060=0E000h)
data_35e      equ      64h                  ; (0000:0064=2Fh)

data_36e      equ      68h                  ; (0000:0068=0FE6Eh)
data_37e      equ      6Ah                  ; (0000:006A=0)
data_38e      equ      6Eh                  ; (0000:006E=5Bh)
data_39e      equ      6Fh                  ; (0000:006F=0CBh)
data_40e      equ      70h                  ; (0000:0070=1Dh)
data_41e      equ      72h                  ; (0000:0072=5A6h)
data_42e      equ      74h                  ; (0000:0074=0F0A4h)
data_43e      equ      76h                  ; (0000:0076=0F000h)
data_44e      equ      78h                  ; (0000:0078=22h)
data_45e      equ      79h                  ; (0000:0079=5)
data_46e      equ      7Ah                  ; (0000:007A=0)
data_47e      equ      7Ch                  ; (0000:007C=9Dh)
data_48e      equ      80h                  ; (0000:0080=0A8h)
data_49e      equ      84h                  ; (0000:0084=445h)
data_50e      equ      86h                  ; (0000:0086=4BFh)
data_51e      equ      88h                  ; (0000:0088=314h)
data_52e      equ      8Ah                  ; (0000:008A=1Bh)
data_53e      equ      8Ch                  ; (0000:008C=8325h)
data_54e      equ      8Eh                  ; (0000:008E=804h)
data_55e      equ      90h                  ; (0000:0090=178h)
data_56e      equ      92h                  ; (0000:0092=61Bh)
data_57e      equ      94h                  ; (0000:0094=0FBCh)
data_58e      equ      96h                  ; (0000:0096=0C9h)
data_59e      equ      0D6h                  ; (0000:00D6=0C9h)
data_60e      equ      100h                  ; (0000:0100=59h)
data_61e      equ      10Ch                  ; (0000:010C=9Dh)
data_62e      equ      156h                  ; (0000:0156=0)
data_63e      equ      196h                  ; (0000:0196=0)
data_64e      equ      198h                  ; (0000:0198=0)
data_65e      equ      19Ah                  ; (0000:019A=0)
data_66e      equ      19Ch                  ; (0000:019C=40h)
data_67e      equ      19Eh                  ; (0000:019E=5A1h)
data_68e      equ      1A0h                  ; (0000:01A0=0B0h)
data_69e      equ      1A2h                  ; (0000:01A2=0F000h)
data_70e      equ      1A4h                  ; (0000:01A4=55B0h)
data_71e      equ      1A6h                  ; (0000:01A6=0F000h)
data_72e      equ      1A8h                  ; (0000:01A8=0B0h)
data_73e      equ      1AAh                  ; (0000:01AA=0F000h)
data_74e      equ      1ACh                  ; (0000:01AC=55B0h)
data_75e      equ      1AEh                  ; (0000:01AE=0F000h)
data_76e      equ      1B0h                  ; (0000:01B0=0B0h)
data_77e      equ      1B2h                  ; (0000:01B2=0F000h)
data_78e      equ      1B4h                  ; (0000:01B4=48h)
data_79e      equ      1B5h                  ; (0000:01B5=50h)
data_80e      equ      1B6h                  ; (0000:01B6=0)
data_81e      equ      1B8h                  ; (0000:01B8=0B0h)
data_82e      equ      1BCh                  ; (0000:01BC=0B0h)
data_83e      equ      1C0h                  ; (0000:01C0=35h)
data_84e      equ      2C0h                  ; (0000:02C0=0)
data_85e      equ      3C0h                  ; (0000:03C0=0)
data_86e      equ      3C4h                  ; (0000:03C4=28h)
data_87e      equ      3DAh                  ; (0000:03DA=40h)
equip_bits_      equ      410h                  ; (0000:0410=0C627h)
keybd_flags_1_      equ      417h                  ; (0000:0417=20h)
video_mode_      equ      449h                  ; (0000:0449=3)
video_columns_      equ      44Ah                  ; (0000:044A=50h)
video_buf_siz_      equ      44Ch                  ; (0000:044C=1000h)

video_segment_      equ      44Eh                  ; (0000:044E=0)
data_88e      equ      450h                  ; (0000:0450=4Fh)
video_page_      equ      462h                  ; (0000:0462=0)
video_port_      equ      463h                  ; (0000:0463=3D4h)
video_mode_reg_      equ      465h                  ; (0000:0465=29h)
video_color_      equ      466h                  ; (0000:0466=30h)
video_rows_      equ      484h                  ; (0000:0484=18h)
video_pixels_      equ      485h                  ; (0000:0485=10h)
video_options_      equ      487h                  ; (0000:0487=60h)
data_89e      equ      5FCh                  ;*(0000:05FC=0B8h)
data_90e      equ      60Eh                  ;*(0000:060E=0)
data_91e      equ      610h                  ;*(0000:0610=0)
data_92e      equ      612h                  ;*(0000:0612=0)
data_93e      equ      614h                  ;*(0000:0614=0)
data_94e      equ      615h                  ;*(0000:0615=0)
data_95e      equ      616h                  ;*(0000:0616=0)
data_96e      equ      61Ah                  ;*(0000:061A=0)
data_97e      equ      61Eh                  ;*(0000:061E=0)
data_98e      equ      622h                  ;*(0000:0622=0)
data_99e      equ      626h                  ;*(0000:0626=0)
data_100e      equ      62Ah                  ;*(0000:062A=0)
data_101e      equ      62Eh                  ;*(0000:062E=0)
data_102e      equ      634h                  ;*(0000:0634=0)
data_103e      equ      636h                  ;*(0000:0636=0)
data_104e      equ      637h                  ;*(0000:0637=0)
data_105e      equ      638h                  ;*(0000:0638=0)
data_106e      equ      639h                  ;*(0000:0639=0)
data_107e      equ      63Ah                  ;*(0000:063A=0)
data_108e      equ      63Bh                  ;*(0000:063B=43h)
data_109e      equ      63Ch                  ;*(0000:063C=4Fh)
data_110e      equ      63Dh                  ;*(0000:063D=4Eh)
data_111e      equ      63Eh                  ;*(0000:063E=20h)
data_112e      equ      640h                  ;*(0000:0640=0)
data_113e      equ      642h                  ;*(0000:0642=0)
data_114e      equ      644h                  ;*(0000:0644=0)
data_115e      equ      646h                  ;*(0000:0646=0)
data_116e      equ      648h                  ;*(0000:0648=0)
data_117e      equ      64Ah                  ;*(0000:064A=0)
data_118e      equ      64Ch                  ;*(0000:064C=0)
data_119e      equ      64Eh                  ;*(0000:064E=0)
data_120e      equ      650h                  ;*(0000:0650=0)
data_121e      equ      652h                  ;*(0000:0652=0)
data_122e      equ      656h                  ;*(0000:0656=0)
data_123e      equ      658h                  ;*(0000:0658=0)
data_124e      equ      65Ah                  ;*(0000:065A=0)
data_125e      equ      65Ch                  ;*(0000:065C=0)
data_126e      equ      65Eh                  ;*(0000:065E=0)
data_127e      equ      660h                  ;*(0000:0660=0)
data_128e      equ      662h                  ;*(0000:0662=0)
data_129e      equ      664h                  ;*(0000:0664=0)
data_130e      equ      666h                  ;*(0000:0666=0)
data_131e      equ      668h                  ;*(0000:0668=0)
data_132e      equ      66Ah                  ;*(0000:066A=0)
data_133e      equ      66Ch                  ;*(0000:066C=0)
data_134e      equ      66Eh                  ;*(0000:066E=0)
data_135e      equ      670h                  ;*(0000:0670=0)
data_136e      equ      672h                  ;*(0000:0672=0)

data_137e      equ      676h                  ;*(0000:0676=4F43h)
data_138e      equ      678h                  ;*(0000:0678=4Eh)
data_139e      equ      106Eh                  ;*(0000:106E=44h)
data_140e      equ      14ADh                  ;*(0000:14AD=0)
data_141e      equ      1678h                  ;*(0000:1678=0)
data_142e      equ      1732h                  ;*(0000:1732=0)
data_143e      equ      17D1h                  ;*(0000:17D1=0C5h)
data_144e      equ      18E6h                  ;*(0000:18E6=56h)
data_145e      equ      1E78h                  ;*(0000:1E78=0)
data_146e      equ      1EB6h                  ;*(0000:1EB6=0)
data_147e      equ      1EF4h                  ;*(0000:1EF4=0)
data_148e      equ      1F32h                  ;*(0000:1F32=3A00h)
data_149e      equ      1F70h                  ;*(0000:1F70=4D4Dh)
data_150e      equ      1FAEh                  ;*(0000:1FAE=0)
data_151e      equ      1FECh                  ;*(0000:1FEC=0)
data_152e      equ      2000h                  ;*(0000:2000=0)
data_153e      equ      202Ah                  ;*(0000:202A=8000h)
data_154e      equ      2068h                  ;*(0000:2068=0)
data_155e      equ      20A6h                  ;*(0000:20A6=525Ch)
data_156e      equ      20E4h                  ;*(0000:20E4=0)
data_157e      equ      216Ah                  ;*(0000:216A=0)
data_158e      equ      217Ah                  ;*(0000:217A=0)
data_159e      equ      217Bh                  ;*(0000:217B=0)
data_160e      equ      217Ch                  ;*(0000:217C=0)
data_161e      equ      218Ch                  ;*(0000:218C=0)
data_162e      equ      218Dh                  ;*(0000:218D=0)
data_163e      equ      218Eh                  ;*(0000:218E=0)
data_164e      equ      2196h                  ;*(0000:2196=0)
data_165e      equ      2216h                  ;*(0000:2216=0)
data_166e      equ      2217h                  ;*(0000:2217=0)
data_168e      equ      224Ch                  ;*(0000:224C=0)
data_169e      equ      22CCh                  ;*(0000:22CC=0)
data_170e      equ      230Ch                  ;*(0000:230C=0)
data_171e      equ      234Ch                  ;*(0000:234C=0)
data_172e      equ      234Eh                  ;*(0000:234E=0)
data_173e      equ      235Ah                  ;*(0000:235A=0)
data_174e      equ      245Ah                  ;*(0000:245A=0)
data_175e      equ      265Ch                  ;*(0000:265C=3Bh)
data_176e      equ      265Dh                  ;*(0000:265D=0)
data_177e      equ      2660h                  ;*(0000:2660=0)
data_178e      equ      2666h                  ;*(0000:2666=0)
data_179e      equ      266Ch                  ;*(0000:266C=2Dh)
data_180e      equ      267Ah                  ;*(0000:267A=2Dh)
data_181e      equ      267Ch                  ;*(0000:267C=7400h)
data_182e      equ      267Eh                  ;*(0000:267E=3)
data_183e      equ      267Fh                  ;*(0000:267F=0BBh)
data_184e      equ      268Fh                  ;*(0000:268F=33C3h)
data_185e      equ      2692h                  ;*(0000:2692=0DA8Bh)
data_186e      equ      2694h                  ;*(0000:2694=3E8Bh)
data_187e      equ      2696h                  ;*(0000:2696=45h)
data_188e      equ      2697h                  ;*(0000:2697=0)
data_189e      equ      26A7h                  ;*(0000:26A7=1Eh)
data_190e      equ      26AAh                  ;*(0000:26AA=0C8h)
data_191e      equ      26D7h                  ;*(0000:26D7=1Eh)
data_192e      equ      26DAh                  ;*(0000:26DA=2Eh)
data_193e      equ      26F8h                  ;*(0000:26F8=0)
data_194e      equ      270Ah                  ;*(0000:270A=2Eh)

data_195e      equ      2722h                  ;*(0000:2722=46h)
data_196e      equ      2838h                  ;*(0000:2838=0)
data_197e      equ      283Eh                  ;*(0000:283E=0)
data_198e      equ      284Fh                  ;*(0000:284F=75h)
data_199e      equ      28DFh                  ;*(0000:28DF=2)
data_200e      equ      28E6h                  ;*(0000:28E6=0B044h)
data_201e      equ      28E8h                  ;*(0000:28E8=0E6D1h)
data_202e      equ      28EAh                  ;*(0000:28EA=64h)
data_203e      equ      28EBh                  ;*(0000:28EB=0E8h)
data_204e      equ      28FBh                  ;*(0000:28FB=8A2Eh)
data_205e      equ      28FEh                  ;*(0000:28FE=32h)
data_206e      equ      2900h                  ;*(0000:2900=5E3h)
data_207e      equ      2902h                  ;*(0000:2902=49h)
data_208e      equ      2903h                  ;*(0000:2903=0E3h)
data_209e      equ      2913h                  ;*(0000:2913=2)
data_210e      equ      2916h                  ;*(0000:2916=0)
data_211e      equ      2956h                  ;*(0000:2956=4Ch)
data_212e      equ      2996h                  ;*(0000:2996=4Dh)
data_213e      equ      29D6h                  ;*(0000:29D6=0)
data_214e      equ      2A16h                  ;*(0000:2A16=66h)
data_215e      equ      2A96h                  ;*(0000:2A96=0)
data_216e      equ      2AD6h                  ;*(0000:2AD6=8)
data_217e      equ      2B16h                  ;*(0000:2B16=0)
data_218e      equ      2B17h                  ;*(0000:2B17=75h)
data_219e      equ      2B20h                  ;*(0000:2B20=0Eh)
data_220e      equ      2B21h                  ;*(0000:2B21=0E0h)
data_221e      equ      2B22h                  ;*(0000:2B22=8)
data_222e      equ      0C03Fh                  ;*(0000:C03F=36h)
data_223e      equ      0FF6Ah                  ;*(0000:FF6A=0Ch)
data_224e      equ      0FFB0h                  ;*(0000:FFB0=2Eh)
data_225e      equ      7Ah                  ;*(0001:007A=1Bh)
data_226e      equ      90h                  ;*(0001:0090=106Ch)
data_227e      equ      92h                  ;*(0001:0092=0C9h)
data_228e      equ      0D6h                  ;*(0001:00D6=0C9h)
data_229e      equ      1B8h                  ;*(0001:01B8=0B2h)
data_230e      equ      1BCh                  ;*(0001:01BC=0CAh)
data_231e      equ      61Eh                  ;*(0001:061E=0)
data_232e      equ      626h                  ;*(0001:0626=0)
data_233e      equ      636h                  ;*(0001:0636=0)
data_234e      equ      63Ah                  ;*(0001:063A=0)
data_235e      equ      63Ch                  ;*(0001:063C=0)
data_236e      equ      1FAEh                  ;*(0001:1FAE=12B8h)
data_237e      equ      2000h                  ;*(0001:2000=0)
data_238e      equ      202Ah                  ;*(0001:202A=0A74h)
data_239e      equ      7Ah                  ;*(00C9:007A=0)
data_240e      equ      92h                  ;*(00C9:0092=0FD7Fh)
data_241e      equ      61Eh                  ;*(00C9:061E=0Fh)
data_242e      equ      63Ah                  ;*(00C9:063A=0)
data_243e      equ      1FAEh                  ;*(00C9:1FAE=1)
data_244e      equ      2000h                  ;*(00C9:2000=59h)
data_245e      equ      0FFB0h                  ;*(03EB:FFB0=0F6h)
data_246e      equ      0Fh                  ;*(061B:000F=26h)
data_247e      equ      12h                  ;*(061B:0012=5Dh)
data_248e      equ      14h                  ;*(061B:0014=4BFh)
data_249e      equ      36h                  ;*(061B:0036=1Bh)
data_250e      equ      46h                  ;*(061B:0046=0)
data_251e      equ      92h                  ;*(061B:0092=6C2Eh)

data_252e      equ      0A0h                  ;*(061B:00A0=0)
data_253e      equ      221h                  ;*(061B:0221=0Bh)
data_254e      equ      450h                  ;*(061B:0450=54h)
data_255e      equ      61Eh                  ;*(061B:061E=0A4h)
data_256e      equ      622h                  ;*(061B:0622=0C0h)
data_257e      equ      63Ah                  ;*(061B:063A=50h)
data_258e      equ      650h                  ;*(061B:0650=0B4C0h)
data_259e      equ      656h                  ;*(061B:0656=8BC3h)
data_260e      equ      658h                  ;*(061B:0658=0AADFh)
data_261e      equ      65Ah                  ;*(061B:065A=0A5A5h)
data_262e      equ      65Eh                  ;*(061B:065E=8CFCh)
data_263e      equ      662h                  ;*(061B:0662=0C3h)
data_264e      equ      664h                  ;*(061B:0664=0)
data_265e      equ      666h                  ;*(061B:0666=0)
data_266e      equ      66Ah                  ;*(061B:066A=0)
data_267e      equ      66Eh                  ;*(061B:066E=0)
data_268e      equ      670h                  ;*(061B:0670=0)
data_269e      equ      1FAEh                  ;*(061B:1FAE=8300h)
data_270e      equ      1FECh                  ;*(061B:1FEC=19E8h)
data_271e      equ      2000h                  ;*(061B:2000=35h)
data_272e      equ      2068h                  ;*(061B:2068=3531h)
data_273e      equ      20A6h                  ;*(061B:20A6=0A217h)
data_274e      equ      20E4h                  ;*(061B:20E4=2FBCh)
data_275e      equ      8000h                  ;*(061B:8000=10h)
data_276e      equ      3CBFh                  ;*(0675:3CBF=9Ah)
data_277e      equ      61Eh                  ;*(0A74:061E=16h)
data_278e      equ      626h                  ;*(0A74:0626=8Fh)
data_279e      equ      636h                  ;*(0A74:0636=0)
data_280e      equ      63Ah                  ;*(0A74:063A=0)
data_281e      equ      678h                  ;*(0A74:0678=0F0h)
data_282e      equ      1FAEh                  ;*(0A74:1FAE=8B2Eh)
data_283e      equ      202Ah                  ;*(0A74:202A=3F7Eh)
data_284e      equ      80h                  ;*(0F9E:0080=66h)
data_285e      equ      68h                  ;*(0FBC:0068=6F6h)
data_286e      equ      6Ah                  ;*(0FBC:006A=0DDh)
data_287e      equ      6Fh                  ;*(0FBC:006F=8Bh)
data_288e      equ      70h                  ;*(0FBC:0070=5E0Eh)
data_289e      equ      72h                  ;*(0FBC:0072=4119h)
data_290e      equ      74h                  ;*(0FBC:0074=0C13Bh)
data_291e      equ      76h                  ;*(0FBC:0076=1F72h)
data_292e      equ      78h                  ;*(0FBC:0078=77h)
data_293e      equ      94h                  ;*(0FBC:0094=0EB00h)
data_294e      equ      626h                  ;*(0FBC:0626=3Bh)
data_295e      equ      639h                  ;*(0FBC:0639=36h)
data_296e      equ      63Bh                  ;*(0FBC:063B=0)
data_297e      equ      1FAEh                  ;*(0FBC:1FAE=6FEh)
data_298e      equ      3CBFh                  ;*(0FBC:3CBF=21h)
data_299e      equ      1EB6h                  ;*(2000:1EB6=9A2Fh)
data_300e      equ      1FAEh                  ;*(2000:1FAE=3E2h)
data_302e      equ      3609h                  ;*(2F74:3609=0)
data_303e      equ      0FF9Eh                  ;*(2F74:FF9E=83h)
data_304e      equ      0FFA0h                  ;*(2F74:FFA0=0E6h)
data_305e      equ      0FFA2h                  ;*(2F74:FFA2=75h)
data_306e      equ      0FFA6h                  ;*(2F74:FFA6=4)
data_307e      equ      0FFAAh                  ;*(2F74:FFAA=0Fh)
data_308e      equ      0FFD2h                  ;*(2F74:FFD2=46h)
data_309e      equ      0FFD6h                  ;*(2F74:FFD6=3)

data_310e      equ      0FFD8h                  ;*(2F74:FFD8=24h)
data_311e      equ      0FFDAh                  ;*(2F74:FFDA=0E9h)
data_312e      equ      0FFDCh                  ;*(2F74:FFDC=1)
data_313e      equ      0FFE0h                  ;*(2F74:FFE0=5Eh)
data_314e      equ      0FFE4h                  ;*(2F74:FFE4=0C4h)
data_315e      equ      0FFE6h                  ;*(2F74:FFE6=0F6h)
data_316e      equ      0FFECh                  ;*(2F74:FFEC=0D1h)
data_317e      equ      0FFEEh                  ;*(2F74:FFEE=0AAh)
data_318e      equ      0FFF0h                  ;*(2F74:FFF0=46h)
data_319e      equ      0FFF2h                  ;*(2F74:FFF2=0FFh)
data_320e      equ      0FFF4h                  ;*(2F74:FFF4=0A2h)
data_398e      equ      7Ah                  ;*(3301:007A=0)
data_399e      equ      3CEh                  ;*(3301:03CE=7)
data_400e      equ      3CFh                  ;*(3301:03CF=0E9h)
data_401e      equ      61Eh                  ;*(3301:061E=53h)
data_402e      equ      626h                  ;*(3301:0626=8)
data_403e      equ      20E4h                  ;*(3301:20E4=8351h)
data_495e      equ      7509h                  ;*(3557:7509=0C68Bh)
data_499e      equ      622h                  ;*(3625:0622=0EEh)
data_500e      equ      626h                  ;*(3625:0626=8Bh)
data_501e      equ      63Ah                  ;*(3625:063A=0F7h)
data_502e      equ      650h                  ;*(3625:0650=0E1E2h)
data_503e      equ      656h                  ;*(3625:0656=5F0Ah)
data_504e      equ      658h                  ;*(3625:0658=0C7F7h)
data_505e      equ      1FAEh                  ;*(3625:1FAE=2D03h)
data_530e      equ      0                  ;*(3748:0000=5Dh)
data_601e      equ      1EF4h                  ;*(3748:1EF4=8AF6h)
data_602e      equ      1F70h                  ;*(3748:1F70=0D09Fh)
data_617e      equ      1FAEh                  ;*(380D:1FAE=0EB2Bh)
data_623e      equ      622h                  ;*(387C:0622=0FFh)
data_624e      equ      626h                  ;*(387C:0626=7Eh)
data_625e      equ      63Ah                  ;*(387C:063A=0E9h)
data_626e      equ      650h                  ;*(387C:0650=3D8h)
data_627e      equ      656h                  ;*(387C:0656=27Eh)
data_628e      equ      658h                  ;*(387C:0658=0DA8Bh)
data_629e      equ      1FAEh                  ;*(387C:1FAE=8C50h)
data_635e      equ      622h                  ;*(38DA:0622=56h)
data_636e      equ      626h                  ;*(38DA:0626=0E4h)
data_637e      equ      63Ah                  ;*(38DA:063A=0D3h)
data_638e      equ      650h                  ;*(38DA:0650=0D09Fh)
data_639e      equ      656h                  ;*(38DA:0656=520Eh)
data_640e      equ      658h                  ;*(38DA:0658=9F00h)
data_641e      equ      1FAEh                  ;*(38DA:1FAE=1074h)
data_707e      equ      622h                  ;*(3B01:0622=1Eh)
data_708e      equ      626h                  ;*(3B01:0626=0FFh)
data_709e      equ      63Ah                  ;*(3B01:063A=0D1h)
data_710e      equ      650h                  ;*(3B01:0650=1436h)
data_711e      equ      656h                  ;*(3B01:0656=1E2Bh)
data_712e      equ      658h                  ;*(3B01:0658=48h)
data_713e      equ      1FAEh                  ;*(3B01:1FAE=754Eh)
data_738e      equ      80C0h                  ;*(3B4E:80C0=0Ah)
data_739e      equ      0FF80h                  ;*(3B4E:FF80=0D1h)
data_794e      equ      622h                  ;*(3D8C:0622=14h)
data_795e      equ      626h                  ;*(3D8C:0626=0Bh)
data_796e      equ      63Ah                  ;*(3D8C:063A=8Dh)
data_797e      equ      650h                  ;*(3D8C:0650=43EBh)
data_798e      equ      656h                  ;*(3D8C:0656=3DEBh)

data_799e      equ      658h                  ;*(3D8C:0658=0CEBAh)
data_800e      equ      1FAEh                  ;*(3D8C:1FAE=0DC5Eh)
data_801e      equ      8080h                  ;*(3D8C:8080=2)
data_819e      equ      622h                  ;*(3DED:0622=8Bh)
data_820e      equ      626h                  ;*(3DED:0626=0)
data_821e      equ      63Ah                  ;*(3DED:063A=0BAh)
data_822e      equ      650h                  ;*(3DED:0650=0F02h)
data_823e      equ      656h                  ;*(3DED:0656=0E9AAh)
data_824e      equ      658h                  ;*(3DED:0658=99h)
data_825e      equ      1FAEh                  ;*(3DED:1FAE=0F6EFh)
data_826e      equ      0FF80h                  ;*(3DED:FF80=7Dh)
data_839e      equ      1000h                  ;*(3E4B:1000=4Eh)
data_840e      equ      1001h                  ;*(3E4B:1001=0E6h)
data_841e      equ      80C0h                  ;*(3E4B:80C0=3)
data_874e      equ      61Eh                  ;*(3E60:061E=0CFh)
data_875e      equ      626h                  ;*(3E60:0626=0D1h)
data_876e      equ      636h                  ;*(3E60:0636=0F3h)
data_877e      equ      63Bh                  ;*(3E60:063B=0AAh)
data_878e      equ      1F70h                  ;*(3E60:1F70=22C9h)
data_943e      equ      1FAEh                  ;*(3EDE:1FAE=7E1h)
data_944e      equ      0C906h                  ;*(3EDE:C906=3)
data_945e      equ      0D6h                  ;*(3F7E:00D6=4Eh)
data_946e      equ      61Eh                  ;*(3F7E:061E=0EBh)
data_947e      equ      626h                  ;*(3F7E:0626=0E8h)
data_948e      equ      636h                  ;*(3F7E:0636=0D2h)
data_949e      equ      63Ah                  ;*(3F7E:063A=0D0h)
data_950e      equ      63Ch                  ;*(3F7E:063C=0FBh)
data_951e      equ      678h                  ;*(3F7E:0678=0D1h)
data_952e      equ      1FAEh                  ;*(3F7E:1FAE=0C033h)
data_956e      equ      622h                  ;*(3FBE:0622=8Dh)
data_957e      equ      626h                  ;*(3FBE:0626=0EBh)
data_958e      equ      63Ah                  ;*(3FBE:063A=0CEh)
data_959e      equ      650h                  ;*(3FBE:0650=68Dh)
data_960e      equ      656h                  ;*(3FBE:0656=68Dh)
data_961e      equ      658h                  ;*(3FBE:0658=538h)
data_962e      equ      1FAEh                  ;*(3FBE:1FAE=0A5F3h)
data_1005e      equ      1FAEh                  ;*(4009:1FAE=0F175h)
data_1039e      equ      1FAEh                  ;*(408A:1FAE=468Bh)
data_1081e      equ      1C0h                  ;*(4234:01C0=0E0h)
data_1082e      equ      1EF4h                  ;*(4234:1EF4=0B0E5h)
data_1083e      equ      3603h                  ;*(4234:3603=64h)
data_1167e      equ      676h                  ;*(4350:0676=57ECh)
data_1175e      equ      1EF4h                  ;*(43BA:1EF4=0CD8Ah)
data_1176e      equ      1FAEh                  ;*(43BA:1FAE=0D38Ah)
data_1177e      equ      221Ch                  ;*(43BA:221C=0D3h)
data_1182e      equ      1FAEh                  ;*(444C:1FAE=10EFh)
data_1189e      equ      1FAEh                  ;*(44C2:1FAE=7550h)
data_1258e      equ      1FAEh                  ;*(4564:1FAE=0F6CFh)
data_1259e      equ      202Ah                  ;*(4564:202A=3EBh)
data_1319e      equ      13h                  ;*(468B:0013=2Eh)
data_1320e      equ      3Eh                  ;*(468B:003E=8B00h)
data_1321e      equ      7Ah                  ;*(468B:007A=2)
data_1322e      equ      80h                  ;*(468B:0080=0)
data_1323e      equ      81h                  ;*(468B:0081=0BAh)
data_1324e      equ      0D6h                  ;*(468B:00D6=9Ah)
data_1325e      equ      2C0h                  ;*(468B:02C0=4Ch)
data_1326e      equ      61Eh                  ;*(468B:061E=0Bh)

data_1327e      equ      622h                  ;*(468B:0622=0AAh)
data_1328e      equ      626h                  ;*(468B:0626=75h)
data_1329e      equ      678h                  ;*(468B:0678=1)
data_1330e      equ      1FAEh                  ;*(468B:1FAE=5E1Fh)
data_1331e      equ      202Ah                  ;*(468B:202A=0FFD1h)
data_1431e      equ      1FAEh                  ;*(46F9:1FAE=0B3E2h)
data_1576e      equ      622h                  ;*(4801:0622=0D1h)
data_1577e      equ      63Ah                  ;*(4801:063A=4Ch)
data_1578e      equ      650h                  ;*(4801:0650=26D9h)
data_1579e      equ      656h                  ;*(4801:0656=0E722h)
data_1580e      equ      658h                  ;*(4801:0658=0D7F6h)
data_1581e      equ      1FAEh                  ;*(4801:1FAE=0C18Bh)
data_1582e      equ      0BD01h                  ;*(4801:BD01=0E8D1h)
data_1583e      equ      84h                  ;*(4824:0084=3BADh)
data_1584e      equ      0A101h                  ;*(4824:A101=8B00h)
data_1585e      equ      0BD01h                  ;*(4824:BD01=0)
data_1661e      equ      267Ah                  ;*(48CE:267A=2BC3h)
data_1662e      equ      267Eh                  ;*(48CE:267E=3Bh)
data_1663e      equ      268Fh                  ;*(48CE:268F=5657h)
data_1669e      equ      2692h                  ;*(48E6:2692=80EBh)
data_1670e      equ      26A7h                  ;*(48E6:26A7=0D108h)
data_1702e      equ      1FECh                  ;*(494D:1FEC=0D68Bh)
data_1703e      equ      0BF02h                  ;*(494D:BF02=0)
data_1728e      equ      1100h                  ;*(49C2:1100=8Bh)
data_1729e      equ      3Ah                  ;*(4A10:003A=' [2J')
data_1730e      equ      45h                  ;*(4A10:0045=33h)
data_1731e      equ      1FAEh                  ;*(4A10:1FAE=3F2h)
data_1778e      equ      9C02h                  ;*(4A3A:9C02=8Bh)
data_1779e      equ      9C02h                  ;*(4A9B:9C02=0ACh)
data_1811e      equ      1FAEh                  ;*(4A9C:1FAE=0ABF3h)
data_1815e      equ      622h                  ;*(4B2E:0622=6)
data_1816e      equ      626h                  ;*(4B2E:0626=0EFh)
data_1817e      equ      63Ah                  ;*(4B2E:063A=0DAh)
data_1818e      equ      650h                  ;*(4B2E:0650=0D18Bh)
data_1819e      equ      656h                  ;*(4B2E:0656=8E00h)
data_1820e      equ      658h                  ;*(4B2E:0658=921Eh)
data_1821e      equ      1FAEh                  ;*(4B2E:1FAE=444h)
data_2005e      equ      1F70h                  ;*(4CE1:1F70=0D38Ah)
data_2006e      equ      5756h                  ;*(4CE1:5756=1E52h)
data_2039e      equ      1FAEh                  ;*(4DFE:1FAE=0EB00h)
data_2050e      equ      1FAEh                  ;*(4E9B:1FAE=0CBEEh)
data_2061e      equ      1FAEh                  ;*(4F03:1FAE=0E8D1h)
data_2063e      equ      196h                  ;*(4F6D:0196=18B0h)
data_2064e      equ      198h                  ;*(4F6D:0198=0B0EFh)
data_2125e      equ      1FAEh                  ;*(4F90:1FAE=374h)
data_2126e      equ      2730h                  ;*(4F90:2730=0D1h)
data_2127e      equ      2734h                  ;*(4F90:2734=0EBD1h)
data_2128e      equ      2736h                  ;*(4F90:2736=0D1h)
data_2129e      equ      2737h                  ;*(4F90:2737=0EBh)
data_2130e      equ      2848h                  ;*(4F90:2848=0DBh)
data_2163e      equ      1FAEh                  ;*(50E7:1FAE=0E1F7h)
data_2210e      equ      28E6h                  ;*(51B2:28E6=0B405h)
data_2211e      equ      28FBh                  ;*(51B2:28FB=8D42h)
data_2243e      equ      28FEh                  ;*(51D5:28FE=3CEBh)
data_2244e      equ      2913h                  ;*(51D5:2913=0A46h)
data_2272e      equ      8B55h                  ;*(5283:8B55=0)
data_2273e      equ      8500h                  ;*(5291:8500=0)

data_2329e      equ      1FAEh                  ;*(5338:1FAE=0)
data_2330e      equ      2000h                  ;*(5338:2000=0)
data_2359e      equ      1FAEh                  ;*(53C9:1FAE=0)
data_2360e      equ      68Bh                  ;*(5452:068B=0)
data_2363e      equ      7Ah                  ;*(56FF:007A=0)
data_2364e      equ      622h                  ;*(56FF:0622=0)
data_2365e      equ      61Eh                  ;*(6C2E:061E=0)
data_2366e      equ      68h                  ;*(8000:0068=0)
data_2367e      equ      70h                  ;*(8000:0070=0)
data_2368e      equ      72h                  ;*(8000:0072=0)
data_2369e      equ      74h                  ;*(8000:0074=0)
data_2370e      equ      76h                  ;*(8000:0076=0)
data_2371e      equ      78h                  ;*(8000:0078=0)
data_2372e      equ      94h                  ;*(8000:0094=0)
data_2373e      equ      1FAEh                  ;*(8000:1FAE=0)
data_2374e      equ      202Ah                  ;*(8000:202A=0)
data_2375e      equ      61Eh                  ;*(8B0C:061E=0)
data_2376e      equ      626h                  ;*(8B0C:0626=0)
data_2377e      equ      636h                  ;*(8B0C:0636=0)
data_2378e      equ      63Ah                  ;*(8B0C:063A=0)
data_2379e      equ      1FAEh                  ;*(8B0C:1FAE=0)
data_2380e      equ      202Ah                  ;*(8B0C:202A=0)
data_2381e      equ      622h                  ;*(8B90:0622=0)
data_2382e      equ      626h                  ;*(8B90:0626=0)
data_2383e      equ      7Ah                  ;*(8BA2:007A=0)
data_2384e      equ      622h                  ;*(8BA2:0622=0)
data_2385e      equ      1FAEh                  ;*(9338:1FAE=0)
data_2386e      equ      1FAEh                  ;*(93C9:1FAE=0)
data_2387e      equ      622h                  ; (AB90:0622=0)
data_2388e      equ      63Ah                  ; (AB90:063A=20h)
data_2389e      equ      1FAEh                  ; (AB90:1FAE=1818h)
data_2390e      equ      626h                  ; (B338:0626=0DBh)
data_2391e      equ      63Ah                  ; (B338:063A=20h)
data_2392e      equ      1FAEh                  ; (B338:1FAE=0)
data_2393e      equ      626h                  ; (B3C9:0626=20h)
data_2394e      equ      63Ah                  ; (B3C9:063A=0CCh)
data_2395e      equ      1FAEh                  ; (B3C9:1FAE=720h)
data_2396e      equ      622h                  ; (BA56:0622=20h)
data_2397e      equ      10h                  ; (C000:0010=9B8h)
data_2398e      equ      25h                  ; (C000:0025=20h)
data_2399e      equ      31h                  ; (C000:0031=42h)
data_2400e      equ      37h                  ; (C000:0037=0BB00h)
data_2401e      equ      40h                  ; (C000:0040=0FF00h)
data_2402e      equ      43h                  ; (C000:0043=1)
data_2403e      equ      7Dh                  ; (C000:007D=0)
data_2404e      equ      7Fh                  ; (C000:007F=0)
data_2405e      equ      0D72h                  ; (C000:0D72=0B0h)
data_2406e      equ      3DAh                  ; (D256:03DA=0)
data_2407e      equ      0FFFEh                  ; (F000:FFFE=0FCh)
data_2408e      equ      7Ah                  ; (F3E9:007A=3)
data_2409e      equ      61Eh                  ; (F3E9:061E=0)
data_2410e      equ      0                  ; (FC00:0000=0FEh)
data_2411e      equ      626h                  ; (FF24:0626=15h)
data_2412e      equ      63Ah                  ; (FF24:063A=58h)
data_2413e      equ      1FAEh                  ; (FF24:1FAE=0)
data_2414e      equ      20E4h                  ; (FF24:20E4=0)
data_2415e      equ      7Ah                  ; (FFCB:007A=0FEh)

data_2416e      equ      622h                  ; (FFCB:0622=8Bh)
data_2417e      equ      626h                  ; (FFCB:0626=2)
data_2418e      equ      678h                  ; (FFD1:0678=0)

stack_seg_a segment
stack_seg_a ends

seg_b segment
seg_b ends

;------------------------------------------------------------  seg_d   ----

seg_d           segment byte public use16 'CODE'
                assume cs:seg_d  , ds:seg_b , ss:stack_seg_a

                                          ; now data because: assumed data
            db      0BCh, 0Dh, 0Ah, 24h

;                              SUBROUTINE
;         Called from:   3326:0306

sub_12            proc      far

PARAMETER_1      =      6                  ; bp+6

            push      bp
            mov      bp,sp
            mov      dx,[bp+PARAMETER_1]
            mov      ax,1
            mov      bx,ds:data_14e            ; (0000:0038=9Ah)
            jmp      word ptr cs:data_441[bx]      ;*(34C8:0070=6Eh)    60 entries
                                          ; now data because: after jmp/ret


loc_245:                              ;  xref 34C8:0011, 001A, 0080
            mov      bx,ds:data_119e            ; (0000:064E=0)
            jmp      word ptr cs:data_441[bx]      ;*(34C8:0070=6Eh)    60 entries
                                          ; now data because: after jmp/ret


loc_246:                              ;  xref 34C8:0011, 001A, 0086, 0088
            cmp      dl,1
            jle      short loc_248            ; Jump if < or =


loc_247:                              ;  xref 34C8:0011, 001A, 0078, 007A
                                    ;            007C, 007E, 0082, 0084
                                    ;            0096
            or      dx,dx                  ; Zero ?
            jz      short loc_248            ; Jump if zero
            cmp      dx,3Fh
            ja      short loc_248            ; Jump if above

;                mov     ah,58h
;                mov     al,1
 ;               mov     bl,2
 ;               int 21h

            mov      bx,ds:data_149e            ; (0000:1F70=4D4Dh)
            mov      ah,48h                  ; 'H'
            add      bx,0Fh
            mov      cl,4
            shr      bx,cl                  ; Shift w/zeros fill
            int      21h                  ; DOS Services  ah=function 48h
                                    ;  allocate memory, bx=bytes/16
            jc      short loc_248            ; Jump if carry Set
            mov      cx,[bp+PARAMETER_1]
            shl      cx,1                  ; Shift w/zeros fill
            lea      bx,ds:data_59e            ; (0000:00D6=0C9h) Load effective addr
            add      bx,cx
            mov      [bx],ax

            lea      bx,ds:data_62e            ; (0000:0156=0) Load effective addr
            shr      cx,1                  ; Shift w/zeros fill
            add      bx,cx
            mov      dl,2
            mov      [bx],dl
            mov      es,ax
            mov      cx,ds:data_149e            ; (0000:1F70=4D4Dh)
            mov      dx,di
            xor      ax,ax                  ; Zero register
            mov      di,ax
            cld                        ; Clear direction
            shr      cx,1                  ; Shift w/zeros fill
            rep      stosw                  ; Rep when cx >0 Store ax to es:[di]
            rcl      cx,1                  ; Rotate thru carry
            rep      stosb                  ; Rep when cx >0 Store al to es:[di]
            mov      di,dx


loc_248:                              ;  xref 34C8:0011, 001A, 0022, 0026
                                    ;            002B, 003C, 0070, 0072
  ;              mov al, 1
   ;             mov bl, 0
  ;              mov ah,58h
   ;             int 21h                                ;            0074, 0076, 008A, 008C
                                    ;            008E, 0090, 0092, 0094
                                    ;            0098, 009A, 009C, 009E
            pop      bp
            retf                        ; Return far
                                          ; now data because: after jmp/ret
sub_12            endp

data_441      dw      offset loc_248            ; Data table (indexed access)
                                    ;  xref 34C8:0011, 001A
data_442      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_443      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_444      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_445      dw      offset loc_247            ;  xref 34C8:0011, 001A
data_446      dw      offset loc_247            ;  xref 34C8:0011, 001A
data_447      dw      offset loc_247            ;  xref 34C8:0011, 001A
data_448      dw      offset loc_247            ;  xref 34C8:0011, 001A
data_449      dw      offset loc_245            ;  xref 34C8:0011, 001A
data_450      dw      offset loc_247            ;  xref 34C8:0011, 001A
data_451      dw      offset loc_247            ;  xref 34C8:0011, 001A
data_452      dw      offset loc_246            ;  xref 34C8:0011, 001A
data_453      dw      offset loc_246            ;  xref 34C8:0011, 001A
data_454      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_455      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_456      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_457      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_458      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_459      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_460      dw      offset loc_247            ;  xref 34C8:0011, 001A
data_461      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_462      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_463      dw      offset loc_248            ;  xref 34C8:0011, 001A
data_464      dw      offset loc_248            ;  xref 34C8:0011, 001A

seg_d            ends
seg_allocate segment byte public use16 'CODE'
         assume cs:seg_allocate, ds:seg_b, ss:stack_seg_a
_mt_allocate proc far
       push bp
       mov bp,sp

       mov bx,[bp+6]

       call far ptr _mt_allocate2
       pop bp
_mt_allocate endp
seg_allocate ends

seg_allocate2 segment byte public use16 'CODE'
         assume cs:seg_allocate2, ds:seg_b, ss:stack_seg_a
_mt_allocate2 proc far
;      enter 0002, 00
;      sti
      push ds
      push es
      mov ax, seg_b
      mov ds, ax
;      mov es, ax


      push bx

      call far ptr sub_12
      add sp, 0002
      pop es
      pop ds
;      leave
_mt_allocate2 endp
seg_allocate2 ends


LVL 22

Expert Comment

ID: 1181825
That's not what I meant.  I mean something like.  Data Segment is 2000H, I allocate 500H bytes and get a segment address of 1900H  which would get it to overrun the data segment, but with the figures you are seeing and when the code that is doing it.

The code above seems to have data in multiple segments that are widely seperated.  That seems suspicious.  where did this come from?

Accepted Solution

yuryz earned 100 total points
ID: 1181826
you probably should mess around other subfunctions of func 42 of int 21. The main idea is when you run DOS prog, it allocates ALL the space in DOS. Before issuing some alloc (48) func, you better try to change the size of MCB which your app takes from system. (4ah of int 21h does something like that, as I recall)

If you dont like that, just write your own HEAP manager :}

Expert Comment

ID: 1181827
ahh, not subfunction of 42h, but just 4Ah of int 21h. Just checked some oldie dos help ;]
LVL 22

Expert Comment

ID: 1181828
If the EXE doesn't have an entry in the header that defines the EXE's size when loaded, then the EXE will be give all memory and the INT 21H service 48H function will be unable to allocate memory.  It will not return memory that was already allocated.  


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now